summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2020-06-17 16:50:52 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2020-06-17 16:50:52 -0400
commit46e7ae05d6fdd700364cb48e27f57e249e958f95 (patch)
treeabd2e3925a072b970182d1cb08bae52bae37e9ac /src
parent8f1b54ee608af86d448a9981257fa58727dfe6fc (diff)
allow most options to be long/abbreviatable for consistency,
and document (except for the print-extension) all of the options Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
Diffstat (limited to 'src')
-rw-r--r--src/twm.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/twm.c b/src/twm.c
index a981ac4..ce67806 100644
--- a/src/twm.c
+++ b/src/twm.c
@@ -229,6 +229,20 @@ usage(void)
exit(EXIT_FAILURE);
}
+static Bool
+brief_opt(const char *param, const char *option)
+{
+ size_t have = strlen(++param);
+ size_t want = strlen(option);
+ Bool result = False;
+
+ if (have <= want) {
+ if (!strncmp(param, option, have))
+ result = True;
+ }
+ return result;
+}
+
/***********************************************************************
*
* Procedure:
@@ -263,45 +277,53 @@ main(int argc, char *argv[])
printf("%s %s\n", ProgramName, Version);
exit(EXIT_SUCCESS);
case 'd': /* -display dpy */
- if (strcmp(&argv[i][1], "display"))
+ if (!brief_opt(argv[i], "display"))
usage();
if (++i >= argc)
usage();
display_name = argv[i];
continue;
case 's': /* -single */
+ if (!brief_opt(argv[i], "single"))
+ usage();
MultiScreen = FALSE;
continue;
#ifdef XPRINT
case 'n': /* -noprint */
- if (strcmp(&argv[i][1], "noprint"))
+ if (!brief_opt(argv[i], "noprint"))
usage();
NoPrintscreens = True;
continue;
#endif /* XPRINT */
case 'f': /* -file twmrcfilename */
+ if (!brief_opt(argv[i], "file"))
+ usage();
if (++i >= argc)
usage();
InitFile = argv[i];
continue;
case 'v': /* -verbose */
+ if (!brief_opt(argv[i], "verbose"))
+ usage();
PrintErrorMessages = True;
continue;
case 'c': /* -clientId */
- if (strcmp(&argv[i][1], "clientId"))
+ if (!brief_opt(argv[i], "clientId"))
usage();
if (++i >= argc)
usage();
client_id = argv[i];
continue;
case 'r': /* -restore */
- if (strcmp(&argv[i][1], "restore"))
+ if (!brief_opt(argv[i], "restore"))
usage();
if (++i >= argc)
usage();
restore_filename = argv[i];
continue;
case 'q': /* -quiet */
+ if (!brief_opt(argv[i], "quiet"))
+ usage();
PrintErrorMessages = False;
continue;
}