From 0f9f41f177b4713a6792a2bc87dfbb186b8926bd Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 5 Feb 2023 11:34:18 -0800 Subject: Add -help option Signed-off-by: Alan Coopersmith --- configure.ac | 2 +- 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]) diff --git a/xbiff.c b/xbiff.c index 6e06b64..ea96fb2 100644 --- a/xbiff.c +++ b/xbiff.c @@ -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 -- cgit v1.2.3