gbranden pushed a commit to branch master
in repository groff.

commit a6e4f5d6110c6d394ad97ad2ca04dc6946ac4320
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Aug 2 09:08:19 2025 -0500

    [grolbp,grotty,pre-grohtml,preconv,groff]: Tweak.
    
    Refactor slightly.  Get `usage()` functions out of the business of
    `exit()`ing, which they were doing only in successful cases.  (The
    calling scope `exit()`s with status 2 on usage errors.)  This was
    discrepant with grodvi, post-grohtml, grolj4, grops, eqn, grn, pic,
    refer, soelim, tbl, addftinfo, hpftodit, indxbib, lkbib, lookbib,
    pfbtops, tfmtodit, and xtotroff.
    
    * src/devices/grolbp/lbp.cpp (usage, main):
    * src/devices/grotty/tty.cpp (main, usage):
    * src/preproc/html/pre-html.cpp (usage, scanArguments):
    * src/preproc/preconv/preconv.cpp (usage, main):
    * src/roff/groff/groff.cpp (main, uage): Do it.
    
    Also tweak a code style white space nit in some `fputs()` and
    `fprintf()` calls, for better consistency with other usage messages.
---
 ChangeLog                       | 16 ++++++++++++++++
 src/devices/grolbp/lbp.cpp      |  8 +++-----
 src/devices/grotty/tty.cpp      |  8 +++-----
 src/preproc/html/pre-html.cpp   |  5 ++---
 src/preproc/preconv/preconv.cpp |  5 ++---
 src/roff/groff/groff.cpp        |  8 +++-----
 6 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b3ca939da..a8100985e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2025-08-02  G. Branden Robinson <[email protected]>
+
+       [grolbp,grotty,pre-grohtml,preconv,groff]: Slightly refactor.
+       Get `usage()` functions out of the business of `exit()`ing,
+       which they were doing only in successful cases.  (The calling
+       scope `exit()`s with status 2 on usage errors.)  This was
+       discrepant with grodvi, post-grohtml, grolj4, grops, eqn, grn,
+       pic, refer, soelim, tbl, addftinfo, hpftodit, indxbib, lkbib,
+       lookbib, pfbtops, tfmtodit, and xtotroff.
+
+       * src/devices/grolbp/lbp.cpp (usage, main):
+       * src/devices/grotty/tty.cpp (main, usage):
+       * src/preproc/html/pre-html.cpp (usage, scanArguments):
+       * src/preproc/preconv/preconv.cpp (usage, main):
+       * src/roff/groff/groff.cpp (main, uage): Do it.
+
 2025-08-02  G. Branden Robinson <[email protected]>
 
        * src/utils/grog/grog.pl: Trivially refactor to fix a Perl
diff --git a/src/devices/grolbp/lbp.cpp b/src/devices/grolbp/lbp.cpp
index 870b9b1f8..44783da4e 100644
--- a/src/devices/grolbp/lbp.cpp
+++ b/src/devices/grolbp/lbp.cpp
@@ -653,15 +653,12 @@ static void usage(FILE *stream)
 "usage: %s {-v | --version}\n"
 "usage: %s {-h | --help}\n",
          program_name, program_name, program_name);
-  if (stdout == stream) {
-    fputs(
-"\n"
+  if (stdout == stream)
+    fputs("\n"
 "Translate the output of troff(1) into a CaPSL and VDM format suitable"
 "\n"
 "for Canon LBP-4 and LBP-8 printers.  See the grolbp(1) manual page.\n",
          stream);
-    exit(EXIT_SUCCESS);
-  }
 }
 
 int main(int argc, char **argv)
@@ -736,6 +733,7 @@ int main(int argc, char **argv)
       }
     case 'h':
       usage(stdout);
+      exit(EXIT_SUCCESS);
       break;
     case '?':
       error("unrecognized command-line option '%1'", char(optopt));
diff --git a/src/devices/grotty/tty.cpp b/src/devices/grotty/tty.cpp
index 772ae95a3..d43371dcf 100644
--- a/src/devices/grotty/tty.cpp
+++ b/src/devices/grotty/tty.cpp
@@ -1047,6 +1047,7 @@ int main(int argc, char **argv)
       break;
     case CHAR_MAX + 1: // --help
       usage(stdout);
+      exit(EXIT_SUCCESS);
       break;
     case '?':
       error("unrecognized command-line option '%1'", char(optopt));
@@ -1080,15 +1081,12 @@ static void usage(FILE *stream)
 "usage: %s {-v | --version}\n"
 "usage: %s --help\n",
          program_name, program_name, program_name, program_name);
-  if (stdout == stream) {
-    fputs(
-"\n"
+  if (stdout == stream)
+    fputs("\n"
 "Translate the output of troff(1) into a form suitable for\n"
 "typewriter‐like devices, including terminal emulators.  See the\n"
 "grotty(1) manual page.\n",
          stream);
-    exit(EXIT_SUCCESS);
-  }
 }
 
 // Local Variables:
diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp
index 5feab1b29..78fbb2cbe 100644
--- a/src/preproc/html/pre-html.cpp
+++ b/src/preproc/html/pre-html.cpp
@@ -1581,8 +1581,7 @@ static void usage(FILE *stream)
 "usage: %s --help\n",
         program_name, program_name, program_name);
   if (stdout == stream) {
-    fputs(
-"\n"
+    fputs("\n"
 "Prepare a troff(1) document for HTML formatting.\n"
 "\n"
 "This program is not intended to be executed standalone; it is\n"
@@ -1593,7 +1592,6 @@ static void usage(FILE *stream)
     fprintf(stream,
 "'%s' is called.  See the grohtml(1) manual page.\n",
          program_name);
-    exit(EXIT_SUCCESS);
   }
 }
 
@@ -1713,6 +1711,7 @@ static int scanArguments(int argc, char **argv)
       break;
     case CHAR_MAX + 1: // --help
       usage(stdout);
+      exit(EXIT_SUCCESS);
       break;
     case '?':
       error("unrecognized command-line option '%1'", char(optopt));
diff --git a/src/preproc/preconv/preconv.cpp b/src/preproc/preconv/preconv.cpp
index 49ccd5d94..0ca91a62d 100644
--- a/src/preproc/preconv/preconv.cpp
+++ b/src/preproc/preconv/preconv.cpp
@@ -1237,7 +1237,7 @@ usage(FILE *stream)
 "usage: %s {-v | --version}\n"
 "usage: %s {-h | --help}\n",
          program_name, program_name, program_name);
-  if (stdout == stream) {
+  if (stdout == stream)
     fprintf(stream,
 "\n"
 "Read each file, convert its encoded characters to a form GNU"
@@ -1246,8 +1246,6 @@ usage(FILE *stream)
 "The default fallback encoding is '%s'.  See the preconv(1) manual"
 " page.\n",
          fallback_encoding);
-    exit(EXIT_SUCCESS);
-  }
 }
 
 // ---------------------------------------------------------
@@ -1320,6 +1318,7 @@ main(int argc, char **argv)
       break;
     case 'h':
       usage(stdout);
+      exit(EXIT_SUCCESS);
       break;
     case '?':
       error("unrecognized command-line option '%1'", char(optopt));
diff --git a/src/roff/groff/groff.cpp b/src/roff/groff/groff.cpp
index b20e35845..be5124dd8 100644
--- a/src/roff/groff/groff.cpp
+++ b/src/roff/groff/groff.cpp
@@ -298,6 +298,7 @@ int main(int argc, char **argv)
       break;
     case 'h':
       usage(stdout);
+      exit(EXIT_SUCCESS);
       break;
     case 'E':
     case 'b':
@@ -859,16 +860,13 @@ void usage(FILE *stream)
 "usage: %s {-v | --version}\n"
 "usage: %s {-h | --help}\n",
          program_name, program_name, program_name);
-  if (stdout == stream) {
-    fputs(
-"\n"
+  if (stdout == stream)
+    fputs("\n"
 "groff (GNU roff) is a typesetting system that reads plain text input\n"
 "files that include formatting commands to produce output in\n"
 "PostScript, PDF, HTML, or DVI formats or for display to a terminal.\n"
 "See the groff(1) manual page.\n",
          stream);
-    exit(EXIT_SUCCESS);
-  }
 }
 
 extern "C" {

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

Reply via email to