[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 03/30: groff: Migrate to modern getopt_long(3) usage.
From: |
G. Branden Robinson |
Subject: |
[groff] 03/30: groff: Migrate to modern getopt_long(3) usage. |
Date: |
Sun, 22 Dec 2024 19:39:15 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit c2405a3233fc07c09a40556b2124fdb6cc9cb262
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu Dec 19 23:58:40 2024 -0600
groff: Migrate to modern getopt_long(3) usage.
* src/roff/groff/groff.cpp (main): Migrate to modern getopt_long(3)
usage. Drop `opterr` assignment; prefix the option string with ":"
instead. Handle return of `:`, emit an appropriate usage diagnostic,
and exit with status 2.
---
ChangeLog | 7 +++++++
src/roff/groff/groff.cpp | 9 +++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 83572e8ef..8cad79e3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,13 @@
not whether a graphic actually appears. But having a test
script that doesn't work right when you try it is a bad look.
+2024-12-19 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/groff/groff.cpp (main): Migrate to modern
+ getopt_long(3) usage. Drop `opterr` assignment; prefix the
+ option string with ":" instead. Handle return of `:`, emit an
+ appropriate usage diagnostic, and exit with status 2.
+
2024-12-19 G. Branden Robinson <g.branden.robinson@gmail.com>
[groff]: Regression-test Savannah #66587.
diff --git a/src/roff/groff/groff.cpp b/src/roff/groff/groff.cpp
index 05c83a281..b20e35845 100644
--- a/src/roff/groff/groff.cpp
+++ b/src/roff/groff/groff.cpp
@@ -182,10 +182,9 @@ int main(int argc, char **argv)
{ "version", no_argument, 0, 'v' },
{ NULL, 0, 0, 0 }
};
- opterr = 0;
while ((opt = getopt_long(
argc, argv,
- "abcCd:D:eEf:F:gGhiI:jJkK:lL:m:M:"
+ ":abcCd:D:eEf:F:gGhiI:jJkK:lL:m:M:"
"n:No:pP:r:RsStT:UvVw:W:XzZ",
long_options, NULL))
!= EOF) {
@@ -379,6 +378,12 @@ int main(int argc, char **argv)
usage(stderr);
xexit(2);
break;
+ case ':':
+ error("command-line option '%1' requires an argument",
+ char(optopt));
+ usage(stderr);
+ xexit(2);
+ break;
default:
assert(0 == "no case to handle option character");
break;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 03/30: groff: Migrate to modern getopt_long(3) usage.,
G. Branden Robinson <=