[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 09/19: [gxditview]: Accept groff(1)'s `-v` option.
From: |
G. Branden Robinson |
Subject: |
[groff] 09/19: [gxditview]: Accept groff(1)'s `-v` option. |
Date: |
Sun, 22 Sep 2024 00:33:04 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit a386043f030120d50c5fb2ec4d2e26bfe8284ae0
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Sep 20 21:04:02 2024 -0500
[gxditview]: Accept groff(1)'s `-v` option.
* src/devices/xditview/xditview.c (Syntax): Report `-v` as an accepted
synonym of `-version` and `--version` in usage message.
(main): Refactor argument processing. Accept `-v`. Handle early-exit
options (`--help`, `--version` and their synonyms) _before_ checking
for an excess argument count, another error condition.
* src/devices/xditview/gxditview.1.man (Synopsis): Document `-v` option.
Now "groff -vX" works. Don't say I never did nothin' for ya, Alameda.
---
ChangeLog | 14 ++++++++++++++
src/devices/xditview/gxditview.1.man | 9 +++++++--
src/devices/xditview/xditview.c | 29 ++++++++++++++++-------------
3 files changed, 37 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fe04059dd..a98da9f64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-09-20 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [gxditview]: Accept the `-v` option groff(1) may supply.
+
+ * src/devices/xditview/xditview.c (Syntax): Report `-v` as an
+ accepted synonym of `-version` and `--version` in usage message.
+ (main): Refactor argument processing. Accept `-v`. Handle
+ early-exit options {`--help`, `--version` and their synonyms}
+ _before_ checking for an excess argument count, another error
+ condition.
+
+ * src/devices/xditview/gxditview.1.man (Synopsis): Document
+ `-v` option.
+
2024-09-20 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/input.cpp (remove_macro, rename_macro)
diff --git a/src/devices/xditview/gxditview.1.man
b/src/devices/xditview/gxditview.1.man
index 5ddeaf9b7..bf32186a5 100644
--- a/src/devices/xditview/gxditview.1.man
+++ b/src/devices/xditview/gxditview.1.man
@@ -85,11 +85,15 @@ output in X11
.
.P
.SY gxditview
+.B \-v
+.YS
+.
+.SY gxditview
.B \-version
.YS
.
.SY gxditview
-.B \%\-\-version
+.B \-\-version
.YS
.
.
@@ -463,7 +467,8 @@ and
.B \-\-help
display a usage message,
while
-.B \-version
+.BR \-v ,
+.BR \-version ,
and
.B \%\-\-version
show version information;
diff --git a/src/devices/xditview/xditview.c b/src/devices/xditview/xditview.c
index 1f56940b2..2be55230b 100644
--- a/src/devices/xditview/xditview.c
+++ b/src/devices/xditview/xditview.c
@@ -138,8 +138,8 @@ Syntax(const char *progname, bool had_error)
" [-printCommand command]"
" [-resolution resolution]"
" [file]\n", progname);
- (void) fprintf (stream, "usage: %s {-version | --version}\n",
- progname);
+ (void) fprintf (stream, "usage: %s {-v | -version | --version}"
+ "\n", progname);
(void) fprintf (stream, "usage: %s {-help | --help}\n",
progname);
if (had_error)
@@ -221,19 +221,22 @@ int main(int argc, char **argv)
toplevel = XtAppInitialize(&xtcontext, "GXditview",
options, XtNumber (options),
- &argc, argv, fallback_resources, NULL, 0);
+ &argc, argv, fallback_resources, NULL, 0);
+ /*
+ * XXX: This is not as flexible as GNU getopt, but good enough to
+ * work when called by groff.
+ */
+ if ((strcmp(argv[1], "-help") == 0)
+ || (strcmp(argv[1], "--help") == 0))
+ Syntax(argv[0], false /* did not have error */);
+ else if ((strcmp(argv[1], "-v") == 0)
+ || (strcmp(argv[1], "-version") == 0)
+ || (strcmp(argv[1], "--version") == 0)) {
+ (void) printf("GNU gxditview (groff) version %s\n",
+ Version_string);
+ exit(EXIT_SUCCESS);
if (argc > 2)
Syntax(argv[0], true /* had error */);
- else if (argc == 2) {
- if ((strcmp(argv[1], "-help") == 0)
- || (strcmp(argv[1], "--help") == 0))
- Syntax(argv[0], false /* did not have error */);
- else if ((strcmp(argv[1], "-version") == 0)
- || (strcmp(argv[1], "--version") == 0)) {
- (void) printf("GNU gxditview (groff) version %s\n",
- Version_string);
- exit(EXIT_SUCCESS);
- }
}
XtGetApplicationResources(toplevel, (XtPointer)&app_resources,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 09/19: [gxditview]: Accept groff(1)'s `-v` option.,
G. Branden Robinson <=