From patchwork Wed Oct 14 17:16:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 530305 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8976C14029E for ; Thu, 15 Oct 2015 04:16:46 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=wmRFCSYN; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type :content-transfer-encoding; q=dns; s=default; b=KSlKSGtY7SecQpIC okrguIirCGcnR16os0nZZaMd5QdFNE28Is3zjQKzJ5ebiIcs+Ob/gYmp3s1Sy/lY lO0sjHHWr91SwqabBpD4xAkYrETyXHS+XWvP/uk4S/H4lTaeCHEpTWvAxJN7QkKB 6vhMiJCu/uRcvQReqgyxZxCxE0s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type :content-transfer-encoding; s=default; bh=jmlN8luCVFPU7DAetxWNjd xstYA=; b=wmRFCSYNAmSsBx5sn+MHYMMMbXyFbi6KB/PzwO3Fw7xaP7xfqYOFvW 4aAYglOQfuzhrf/Uv0OwEF9D7GGBckquGuDIpk2sumEw3IHzudC2Se0b2kasPE0T vQxXK+Ux97cDPMOwaA5UlWSdRRkWGqr4re4eGlhhWXKeLsQ2NVhaQ= Received: (qmail 19742 invoked by alias); 14 Oct 2015 17:16:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 19733 invoked by uid 89); 14 Oct 2015 17:16:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qg0-f47.google.com Received: from mail-qg0-f47.google.com (HELO mail-qg0-f47.google.com) (209.85.192.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 14 Oct 2015 17:16:38 +0000 Received: by qgeo38 with SMTP id o38so4629950qge.0 for ; Wed, 14 Oct 2015 10:16:35 -0700 (PDT) X-Received: by 10.140.147.129 with SMTP id 123mr5842882qht.12.1444842995822; Wed, 14 Oct 2015 10:16:35 -0700 (PDT) Received: from [192.168.0.26] (97-124-165-221.hlrn.qwest.net. [97.124.165.221]) by smtp.gmail.com with ESMTPSA id 187sm3704066qhf.16.2015.10.14.10.16.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2015 10:16:35 -0700 (PDT) Message-ID: <561E8DF1.7070909@gmail.com> Date: Wed, 14 Oct 2015 11:16:33 -0600 From: Martin Sebor User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Gcc Patch List Subject: [PATCH] print help for undocumented options X-IsSubscribed: yes 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= Assert the to . Putting '-' before disables the to . Same as -A -A= Assert the to . Putting '-' before disables the to . Same as -A 2015-10-14 Martin Sebor * 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; }