public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] print help for undocumented options
@ 2015-10-14 17:16 Martin Sebor
  2015-10-14 17:24 ` Joseph Myers
  0 siblings, 1 reply; 16+ messages in thread
From: Martin Sebor @ 2015-10-14 17:16 UTC (permalink / raw)
  To: Gcc Patch List

Gcc's online help (the output of gcc --help -v) includes a large
number of undocumented options (197 in 5.1.0).  For example, the
section listing language-related options starts with the following
and another 44 or so undocumented options:

   The following options are language-related:
     --all-warnings           This switch lacks documentation
     --ansi                   This switch lacks documentation
     --assert                 This switch lacks documentation
     ...

It turns out that all of those in the section above and a good
number of others are synonyms for other options that are in fact
documented.  Rather than duplicating the documentation for the
alternate options, the small patchlet below modifies the
print_filtered_help function to print the help for the documented
alias along with its name.  With it applied, the number of options
that "lack documentation" drops to 114, and the section above looks
like this:

   The following options are language-related:
     --all-warnings           Enable most warning messages.  Same
                              as -Wall
     --ansi                   A synonym for -std=c89 (for C) or
                              -std=c++98 (for C++).  Same as -ansi
     -A<question>=<answer>    Assert the <answer> to <question>.
                              Putting '-' before <question> disables
                              the <answer> to <question>.  Same as -A
     -A<question>=<answer>    Assert the <answer> to <question>.
                              Putting '-' before <question> disables
                              the <answer> to <question>.  Same as -A

2015-10-14  Martin Sebor  <msebor@redhat.com>

	* options.c (print_filtered_help): Print help for aliased
	option and its name instead of undocumented text for
	undocumented options.

diff --git a/gcc/opts.c b/gcc/opts.c
index 2bbf653..e441924 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1010,7 +1010,7 @@ print_filtered_help (unsigned int include_flags,
    const char *help;
    bool found = false;
    bool displayed = false;
-  char new_help[128];
+  char new_help[256];

    if (include_flags == CL_PARAMS)
      {
@@ -1086,6 +1086,23 @@ print_filtered_help (unsigned int include_flags,
         {
           if (exclude_flags & CL_UNDOCUMENTED)
             continue;
+
+         if (option->alias_target < N_OPTS
+             && cl_options [option->alias_target].help)
+           {
+             /* For undocumented options that are aliases for other
+                options that are documented, print the other option's
+                help and name.  */
+             help = cl_options [option->alias_target].help;
+
+             snprintf (new_help, sizeof new_help, "%s", help);
+             snprintf (new_help + strlen (new_help),
+                       sizeof new_help - strlen (new_help),
+                       ".  Same as %s",
+                       cl_options [option->alias_target].opt_text);
+             help = new_help;
+           }
+         else
             help = undocumented_msg;
         }

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-10-22 23:22 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-14 17:16 [PATCH] print help for undocumented options Martin Sebor
2015-10-14 17:24 ` Joseph Myers
2015-10-14 18:22   ` Martin Sebor
2015-10-14 19:40     ` Joseph Myers
2015-10-14 23:33       ` Martin Sebor
2015-10-15 21:46         ` Joseph Myers
2015-10-21 21:16           ` [PATCH 1 of 2] " Martin Sebor
2015-10-21 21:40             ` Joseph Myers
2015-10-22 10:27             ` Eric Botcazou
2015-10-22 16:35               ` Martin Sebor
2015-10-22 21:39                 ` [PATCH 3 of 3] " Martin Sebor
2015-10-22 22:07                   ` Joseph Myers
2015-10-22 23:22                     ` Martin Sebor
2015-10-23  0:05                       ` Joseph Myers
2015-10-21 21:19           ` [PATCH 2 of 2] " Martin Sebor
2015-10-21 21:38             ` Joseph Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).