Mercurial > ~dholland > hg > tradcpp > index.cgi
diff main.c @ 105:600f36cd7353
don't use getprogname() in the name of portability
author | David A. Holland |
---|---|
date | Tue, 11 Jun 2013 11:24:48 -0400 |
parents | 51848a7584e0 |
children | 2b0b61fd1a36 |
line wrap: on
line diff
--- a/main.c Tue Jun 11 11:13:58 2013 -0400 +++ b/main.c Tue Jun 11 11:24:48 2013 -0400 @@ -873,10 +873,14 @@ DEAD static void -usage(void) +usage(const char *argv0) { - fprintf(stderr, "Usage: %s [options] [infile [outfile]]\n", - getprogname()); + const char *progname; + + progname = strrchr(argv0, '/'); + progname = progname == NULL ? argv0 : progname + 1; + + fprintf(stderr, "Usage: %s [options] [infile [outfile]]\n", progname); fprintf(stderr, "Common options:\n"); fprintf(stderr, " -C Retain comments\n"); fprintf(stderr, " -Dmacro[=def] Predefine macro\n"); @@ -983,7 +987,7 @@ i++; continue; } - usage(); + usage(argv[0]); } if (i < argc) { inputfile = argv[i++]; @@ -992,7 +996,7 @@ outputfile = argv[i++]; } if (i < argc) { - usage(); + usage(argv[0]); } mode.output_file = outputfile;