[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 05/30: [grolj4]: Revise missing option argument handling.
From: |
G. Branden Robinson |
Subject: |
[groff] 05/30: [grolj4]: Revise missing option argument handling. |
Date: |
Sun, 22 Dec 2024 19:39:15 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit a1a16e71ec21c4e9085b82cf2e071e6460994e31
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Dec 21 16:23:34 2024 -0600
[grolj4]: Revise missing option argument handling.
* src/devices/grolj4/lj4.cpp (main): Align missing command-line option
handling with refactoring underway. Migrate from stdio.h functions
for emitting diagnostics in favor of "libgroff.a" functions. Continue
to muddle through if `-d`'s option is missing, assuming long-side
duplexing as before. Emit usage message and exit with status 2 in all
other cases.
---
ChangeLog | 9 +++++++++
src/devices/grolj4/lj4.cpp | 22 +++++++++++++---------
2 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ff043b3c0..1dcd4c339 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-12-21 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/devices/grolj4/lj4.cpp (main): Align missing command-line
+ option handling with refactoring underway. Migrate from stdio.h
+ functions for emitting diagnostics in favor of "libgroff.a"
+ functions. Continue to muddle through if `-d`'s option is
+ missing, assuming long-side duplexing as before. Emit usage
+ message and exit with status 2 in all other cases.
+
2024-12-20 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/input.cpp (main): Migrate to modern
diff --git a/src/devices/grolj4/lj4.cpp b/src/devices/grolj4/lj4.cpp
index f882dd89f..34cc62c59 100644
--- a/src/devices/grolj4/lj4.cpp
+++ b/src/devices/grolj4/lj4.cpp
@@ -635,15 +635,6 @@ int main(int argc, char **argv)
case 'I':
// ignore include search path
break;
- case ':':
- if (optopt == 'd') {
- fprintf(stderr, "duplex assumed to be long-side\n");
- duplex_flag = 1;
- } else
- fprintf(stderr, "command-line option '%c' requires an"
- " argument\n", optopt);
- fflush(stderr);
- break;
case 'd':
if (!isdigit(*optarg)) // this ugly hack prevents -d without
optind--; // args from messing up the arg list
@@ -707,6 +698,19 @@ int main(int argc, char **argv)
usage(stderr);
exit(2);
break;
+ case ':':
+ if (optopt == 'd') {
+ warning("command-line option 'd' requires an argument; assuming"
+ " duplexing on long side");
+ duplex_flag = 1;
+ }
+ else {
+ error("command-line option '%1' requires an argument",
+ char(optopt));
+ usage(stderr);
+ exit(2);
+ }
+ break;
default:
assert(0 == "unhandled getopt_long return value");
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 05/30: [grolj4]: Revise missing option argument handling.,
G. Branden Robinson <=