This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: recover -frandom-seed from .rpo file
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Alexandre Oliva <aoliva at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 09 Mar 2007 15:11:53 -0800
- Subject: Re: recover -frandom-seed from .rpo file
- References: <orlki6lltg.fsf@free.oliva.athome.lsd.ic.unicamp.br>
Alexandre Oliva wrote:
> from Alexandre Oliva <aoliva@redhat.com>
>
> * flags.h (flag_random_seed): Remove declaration, in favor of...
> * toplev.h (get_random_seed, set_random_seed): ... these.
> * tree.c (get_file_function_name): Use the former.
> * opts.c (common_handle_option): Use the latter.
> * toplev.c
>
> for gcc/cp/ChangeLog
> from Alexandre Oliva <aoliva@redhat.com>
>
> * cp/repo.c (init_repo): Initialize random_seed saved options.
> (finish_repo): Adjust.
> + if (old_args && !get_random_seed (true)
> + && (buf = strstr (old_args, "'-frandom-seed=")))
> + {
> + char *end;
> +
> + buf += sizeof ("'-frandom-seed=") - 1;
Use strlen. The sizeof hack is not necessary when compiling with GCC,
and it's harder to read.
> + for (end = buf; *end; end++)
> + if (end[0] == '\'' && (end[1] == '\0' || end[1] == ' '))
> + break;
Can you just use extract_string here? I would think so, since it looks
like you're doing the same thing that's done for the other users.
> + if (*end)
> + {
> + char *seed;
> + size_t len = end - buf;
> +
> + seed = XNEWVEC (char, len + 1);
> + memcpy (seed, buf, len);
If you use extract_string, this is just XSTRDUP.
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713