From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 5DA3E3858028 for ; Fri, 26 Mar 2021 09:14:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5DA3E3858028 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7CB50AB5F; Fri, 26 Mar 2021 09:14:07 +0000 (UTC) Date: Fri, 26 Mar 2021 10:14:05 +0100 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org Subject: [committed] Don't use argv[0] in usage Message-ID: <20210326091404.GA26975@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: dwz@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Dwz mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Mar 2021 09:14:09 -0000 Hi, Using argv[0] in the usage string makes it harder to layout the usage message: ... $ ./build/dwz -? Usage: ./build/dwz [common options] [-h] [-m COMMONFILE] [-M NAME | -r] [FILES] ./build/dwz [common options] -o OUTFILE FILE ./build/dwz [ -v | -? ] ... Instead, just use "dwz". Committed to trunk. Thanks, - Tom Don't use argv[0] in usage 2021-03-26 Tom de Vries * args.c (usage): Drop progname argument. (parse_args): Update call to usage. --- args.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/args.c b/args.c index cc8c717..5f96bf3 100644 --- a/args.c +++ b/args.c @@ -355,18 +355,22 @@ print_options_help (FILE *stream, struct option_help *options_help, unsigned int /* Print usage and exit. */ static void -usage (const char *progname, int failing) +usage (int failing) { - unsigned int n; + unsigned int n, i; unsigned int indent, limit; FILE *stream = failing ? stderr : stdout; - - fprintf (stream, - ("Usage:\n" - " %s [common options] [-h] [-m COMMONFILE] [-M NAME | -r] [FILES]\n" - " %s [common options] -o OUTFILE FILE\n" - " %s [ -v | -? ]\n"), - progname, progname, progname); + const char *header_lines[] = { + "dwz [common options] [-h] [-m COMMONFILE] [-M NAME | -r] [FILES]", + "dwz [common options] -o OUTFILE FILE", + "dwz [ -v | -? ]" + }; + unsigned int nr_header_lines + = sizeof (header_lines) / sizeof (*header_lines); + + fprintf (stream, "Usage:\n"); + for (i = 0; i < nr_header_lines; ++i) + fprintf (stream, " %s\n", header_lines[i]); indent = 30; limit = 80; @@ -495,7 +499,7 @@ parse_args (int argc, char *argv[], bool *hardlink, const char **outfile) { default: case '?': - usage (argv[0], option_index == -1); + usage (option_index == -1); break; case 0: