* [committed] Don't use argv[0] in usage
@ 2021-03-26 9:14 Tom de Vries
0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2021-03-26 9:14 UTC (permalink / raw)
To: dwz, jakub, mark
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 <tdevries@suse.de>
* 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:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-26 9:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26 9:14 [committed] Don't use argv[0] in usage Tom de Vries
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).