summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-02-05 11:19:32 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-02-05 11:19:32 -0800
commit44cc442a633a3ce39603fc879793a4f51b6ae132 (patch)
treee69a45e68bddd02ba9e7db40b751dd3338bd1329
parented933c78bf1208140baf6103dc5ab81080f6c6fb (diff)
Fix -version handling to not require opening a display first
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--xbiff.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/xbiff.c b/xbiff.c
index e833a2e..6e06b64 100644
--- a/xbiff.c
+++ b/xbiff.c
@@ -99,12 +99,21 @@ main (int argc, char **argv)
XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL);
+ /* 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 */
+ if (argn[0] == '-' && argn[1] == '-') {
+ argn++;
+ }
+ if (strcmp(argn, "-version") == 0) {
+ puts(PACKAGE_STRING);
+ exit(0);
+ }
+ }
+
toplevel = XtAppInitialize(&xtcontext, "XBiff", options, XtNumber (options),
&argc, argv, NULL, NULL, 0);
- if (argc == 2 && strcmp(argv[1], "-version") == 0) {
- puts(PACKAGE_STRING);
- exit(0);
- }
if (argc != 1) Usage ();
/*