diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-05 11:34:18 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-02-05 11:38:29 -0800 |
commit | 0f9f41f177b4713a6792a2bc87dfbb186b8926bd (patch) | |
tree | 5323e07c37f5ac93b5018cf13b46d3c3247de2fb | |
parent | 44cc442a633a3ce39603fc879793a4f51b6ae132 (diff) |
Add -help option
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | xbiff.c | 15 |
2 files changed, 12 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac index 9e4ac37..3acd3dd 100644 --- a/configure.ac +++ b/configure.ac @@ -38,7 +38,7 @@ XORG_MACROS_VERSION(1.8) XORG_DEFAULT_OPTIONS # Checks for pkg-config packages -PKG_CHECK_MODULES(XBIFF, [xaw7 xmu xt >= 1.1 xbitmaps xext x11]) +PKG_CHECK_MODULES(XBIFF, [xaw7 xmu xt >= 1.1 xbitmaps xext x11 xproto >= 7.0.25]) # Checks for headers AC_CHECK_HEADERS([paths.h]) @@ -68,7 +68,8 @@ static XtActionsRec xbiff_actions[] = { { "quit", quit }, }; -static void Usage (void) +static void _X_NORETURN _X_COLD +Usage (int exitval) { const char *help_message = "where options include:\n" @@ -81,11 +82,12 @@ static void Usage (void) " -fg color foreground color\n" " -rv reverse video\n" " -shape shape the window\n" +" -help print usage info and exit\n" " -version print version info and exit\n"; fprintf (stderr, "usage: %s [-options ...]\n", ProgramName); fprintf (stderr, "%s\n", help_message); - exit (1); + exit (exitval); } @@ -102,10 +104,13 @@ main (int argc, char **argv) /* Handle args that don't require opening a display */ for (int n = 1; n < argc; n++) { const char *argn = argv[n]; - /* accept single or double dash for -version */ + /* accept single or double dash for -help & -version */ if (argn[0] == '-' && argn[1] == '-') { argn++; } + if (strcmp(argn, "-help") == 0) { + Usage(0); + } if (strcmp(argn, "-version") == 0) { puts(PACKAGE_STRING); exit(0); @@ -114,7 +119,9 @@ main (int argc, char **argv) toplevel = XtAppInitialize(&xtcontext, "XBiff", options, XtNumber (options), &argc, argv, NULL, NULL, 0); - if (argc != 1) Usage (); + if (argc != 1) { + Usage(1); + } /* * This is a hack so that f.delete will do something useful in this |