gbranden pushed a commit to branch master
in repository groff.

commit 4a17213d0aa188961f9d0a43b06fdaab3471e5ca
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Oct 18 18:04:54 2024 -0500

    [xtotroff]: Tweak command-line option handling.
    
    * src/utils/xtotroff/xtotroff.c (main): Emit our own diagnostic for an
      invalid command-line option.
---
 ChangeLog                     | 5 +++++
 src/utils/xtotroff/xtotroff.c | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 6490fa6ed..0a98e47ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-10-18  G. Branden Robinson <[email protected]>
+
+       * src/utils/xtotroff/xtotroff.c (main): Emit our own diagnostic
+       for an invalid command-line option.
+
 2024-10-18  G. Branden Robinson <[email protected]>
 
        * src/utils/pfbtops/pfbtops.c (main): Emit our own diagnostic
diff --git a/src/utils/xtotroff/xtotroff.c b/src/utils/xtotroff/xtotroff.c
index ab599c722..a421b3a55 100644
--- a/src/utils/xtotroff/xtotroff.c
+++ b/src/utils/xtotroff/xtotroff.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2022 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2024 Free Software Foundation, Inc.
      Written by James Clark ([email protected])
 
 This file is part of groff.
@@ -293,6 +293,7 @@ int main(int argc, char **argv)
 
   program_name = argv[0];
 
+  opterr = 0;
   while ((opt = getopt_long(argc, argv, "d:gr:s:v", long_options,
                            NULL)) != EOF) {
     switch (opt) {
@@ -317,6 +318,8 @@ int main(int argc, char **argv)
       xtotroff_exit(EXIT_SUCCESS);
       break;
     case '?':
+      fprintf(stderr, "%s: unrecognized command-line option '%c'\n",
+             program_name, (char) optopt);
       usage(stderr);
       xtotroff_exit(2);
       break;

_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to