changeset 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 91f600e6647b
children ecec7c16e3ba
files CHANGES main.c
diffstat 2 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES	Tue Jun 11 11:13:58 2013 -0400
+++ b/CHANGES	Tue Jun 11 11:24:48 2013 -0400
@@ -2,6 +2,7 @@
    - auto-recognize more builtin PowerPC and mips macros
    - pass -Wunused (partly from Baptiste Daroussin)
    - allow absolute paths in include files (partly from Baptiste Daroussin)
+   - don't use getprogname() in the name of portability
 
 release 0.1 (20130610)
    - first release, works with at least some imake templates
--- 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;