groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 02/27: [refer]: Report invalid cmd option intelligibly.


From: G. Branden Robinson
Subject: [groff] 02/27: [refer]: Report invalid cmd option intelligibly.
Date: Tue, 3 May 2022 14:27:04 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 46321cffe2dd937011f74fa5260e1a27e7312b29
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Apr 30 00:08:16 2022 +1000

    [refer]: Report invalid cmd option intelligibly.
    
    * src/preproc/refer/refer.cpp (main): When complaining of unrecognized
      option, report the entire option string (after the leading dash), not
      just its first character.
    
    $ refer --version
    GNU refer (groff) version 1.22.4
    $ refer --dummy-long-option
    refer: unrecognized option '-'
    $ ./build/refer --version
    GNU refer (groff) version 1.23.0.rc1.2294-363f
    $ ./build/refer --dummy-long-option
    ./build/refer: error: unrecognized option '-dummy-long-option'
    
    Also add a TODO comment and kill off trailing whitespace on a code line.
---
 ChangeLog                   | 6 ++++++
 src/preproc/refer/refer.cpp | 5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 16a9ad4e..710edfd0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-04-29  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/preproc/refer/refer.cpp (main): When complaining of
+       unrecognized option, report the entire option string (after
+       the leading dash), not just its first character.
+
 2022-04-29  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/libs/libgroff/error.cpp: Trivially refactor.  Explicitly
diff --git a/src/preproc/refer/refer.cpp b/src/preproc/refer/refer.cpp
index e93064f7..670db0c1 100644
--- a/src/preproc/refer/refer.cpp
+++ b/src/preproc/refer/refer.cpp
@@ -116,11 +116,12 @@ int main(int argc, char **argv)
   int bib_flag = 0;
   int done_spec = 0;
 
+  // TODO: Migrate to getopt_long; see, e.g., src/preproc/eqn/main.cpp.
   for (--argc, ++argv;
        !finished_options && argc > 0 && argv[0][0] == '-'
        && argv[0][1] != '\0';
        argv++, argc--) {
-    const char *opt = argv[0] + 1; 
+    const char *opt = argv[0] + 1;
     while (opt != 0 && *opt != '\0') {
       switch (*opt) {
       case 'C':
@@ -356,7 +357,7 @@ int main(int argc, char **argv)
        }
        // fall through
       default:
-       error("unrecognized option '%1'", *opt);
+       error("unrecognized option '%1'", opt);
        usage(stderr);
        exit(1);
        break;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]