Make a new function (hoptusage()) to fabricate an uptodate usage: ...

message based on opts[] instead of relying on a hardcoded usage string.
This commit is contained in:
david parsons
2017-02-02 20:43:18 -08:00
parent 3e8386d071
commit 1c712469dd
6 changed files with 93 additions and 44 deletions
+4 -5
View File
@@ -23,9 +23,9 @@ basename(char *p)
char *pgm = "makepage";
struct h_opt opts[] = {
{ 0, "version", 'V', 0, "show version info" },
{ 0, 0, 'F', 1, "set/show hex flags" },
{ 0, "flags", 'f', 1, "set/show named flags" },
{ 0, "version", 'V', 0, "show version info" },
{ 0, 0, 'F', "bitmap", "set/show hex flags" },
{ 0, "flags", 'f', "{+-}flags", "set/show named flags" },
} ;
#define NROPTS (sizeof opts / sizeof opts[0])
@@ -49,8 +49,7 @@ char **argv;
while ( opt = gethopt(&blob, opts, NROPTS) ) {
if ( opt == HOPTERR ) {
fprintf(stderr, "usage: %s [-V] [-F bitmap] [-f {+-}flags]"
" [file]\n", pgm);
hoptusage(pgm, opts, NROPTS, "[file]");
exit(1);
}
switch ( opt->optchar ) {