summaryrefslogtreecommitdiff
path: root/xfontsel.c
diff options
context:
space:
mode:
Diffstat (limited to 'xfontsel.c')
-rw-r--r--xfontsel.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/xfontsel.c b/xfontsel.c
index 653d532..400eb09 100644
--- a/xfontsel.c
+++ b/xfontsel.c
@@ -187,7 +187,7 @@ static XrmOptionDescRec options[] = {
{"-scaled", "scaledFonts", XrmoptionNoArg, "True"},
};
-static void Syntax(const char *call)
+static void Syntax(const char *call, int exitval)
{
fprintf (stderr, "usage: %s [-options ...] -fn font\n\n%s\n", call,
gettext(
@@ -201,7 +201,7 @@ static void Syntax(const char *call)
" -sampleUCS string sample text to use for ISO10646 fonts\n"
" -scaled use scaled instances of fonts\n"
"plus any standard toolkit options\n"));
- exit (1);
+ exit (exitval);
}
@@ -297,6 +297,22 @@ 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 -help & -version */
+ if (argn[0] == '-' && argn[1] == '-') {
+ argn++;
+ }
+ if (strcmp(argn, "-help") == 0) {
+ Syntax(argv[0], 0);
+ }
+ if (strcmp(argn, "-version") == 0) {
+ puts(PACKAGE_STRING);
+ exit(0);
+ }
+ }
+
topLevel = XtAppInitialize(&appCtx, "XFontSel", options, XtNumber(options),
&argc, argv, NULL, NULL, 0);
@@ -325,7 +341,7 @@ main(int argc, char **argv)
fprintf(stderr, " %s", argv[n]);
}
fputs("\n\n", stderr);
- Syntax(argv[0]);
+ Syntax(argv[0], 1);
}
XtAppAddActions(appCtx, xfontsel_actions, XtNumber(xfontsel_actions));