This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix --help -v output for duplicate options.
On Sun, Mar 1, 2009 at 8:14 AM, Ralf Wildenhues <Ralf.Wildenhues@gmx.de> wrote:
> The patch below fixes the problem that, if more than one *.opt file
> listed a switch, and not all of them had a help text, options.c gets at
> least one of the help texts. ?Still bad: the last one wins, which is a
> pretty arbitrary choice.
>
> One question is whether optc-gen.awk should be modified to just barf
> when it reads multiple unequal help texts. ?But since the set of
> options is target-dependent, it doesn't seem like a good idea to do so
> now; maybe later?
Can you state an example for which option is affected?
Thanks,
Richard.
> OK for 4.5?
>
> What about 4.4? ?This is not a regression in the optc-gen code AFAICS,
> but it is a regression in the sense that 4.4 has many more options that
> are listed in more than one *.opt file, thus causing more options
> without help text.
>
> (The second hunk of the patch is a trivial optimization and code
> clarification.)
>
> Thanks,
> Ralf
>
> gcc/ChangeLog:
> 2009-03-01 ?Ralf Wildenhues ?<Ralf.Wildenhues@gmx.de>
>
> ? ? ? ?* optc-gen.awk: No need to duplicate option flags twice.
> ? ? ? ?Reuse help texts for duplicate options which do not have
> ? ? ? ?any.
>
> diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
> index 2e22016..860810a 100644
> --- a/gcc/optc-gen.awk
> +++ b/gcc/optc-gen.awk
> @@ -1,4 +1,4 @@
> -# ?Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
> +# ?Copyright (C) 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
> ?# ?Contributed by Kelley Cook, June 2004.
> ?# ?Original code from Neil Booth, May 2003.
> ?#
> @@ -145,6 +145,8 @@ for (i = 0; i < n_opts; i++) {
> ? ? ? ?# ends, for example.
> ? ? ? ?while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
> ? ? ? ? ? ? ? ?flags[i + 1] = flags[i] " " flags[i + 1];
> + ? ? ? ? ? ? ? if (help[i + 1] == "")
> + ? ? ? ? ? ? ? ? ? ? ? help[i + 1] = help[i]
> ? ? ? ? ? ? ? ?i++;
> ? ? ? ? ? ? ? ?back_chain[i] = "N_OPTS";
> ? ? ? ? ? ? ? ?indices[opts[i]] = j;
> @@ -153,11 +155,10 @@ for (i = 0; i < n_opts; i++) {
> ?}
>
> ?for (i = 0; i < n_opts; i++) {
> - ? ? ? # Combine the flags of identical switches. ?Switches
> - ? ? ? # appear many times if they are handled by many front
> - ? ? ? # ends, for example.
> + ? ? ? # With identical flags, pick only the last one. ?The
> + ? ? ? # earlier loop ensured that it has all flags merged,
> + ? ? ? # and a nonempty help text if one of the texts was nonempty.
> ? ? ? ?while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
> - ? ? ? ? ? ? ? flags[i + 1] = flags[i] " " flags[i + 1];
> ? ? ? ? ? ? ? ?i++;
> ? ? ? ?}
>
>