This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: recover -frandom-seed from .rpo file


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]