groff-commit
[Top][All Lists]
Advanced

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

[groff] 23/80: [addftinfo]: Exit with status 2 on usage errors.


From: G. Branden Robinson
Subject: [groff] 23/80: [addftinfo]: Exit with status 2 on usage errors.
Date: Sat, 30 Nov 2024 04:02:16 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit f3681854c5aa626f011675775d4ca5b73f12f51a
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Nov 27 14:02:37 2024 -0600

    [addftinfo]: Exit with status 2 on usage errors.
    
    * src/utils/addftinfo/addftinfo.cpp: Align with modern groff
      conventions.  Add Autoconf "<config.h>"-inclusion boilerplate to this
      translation unit.  Use standard symbol `EXIT_SUCCESS` instead of zero
      literal.  Exit with status 2, not 1, on usage errors.
    
    * src/utils/addftinfo/addftinfo.1.man (Exit status): Add.
    
    * NEWS: Add addftinfo to list of programs with changed exit status
      conventions.
---
 ChangeLog                           | 13 +++++++++++++
 NEWS                                | 10 +++++-----
 src/utils/addftinfo/addftinfo.1.man | 13 +++++++++++++
 src/utils/addftinfo/addftinfo.cpp   | 18 +++++++++++-------
 4 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 19a497a64..58a681650 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-11-27  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/utils/addftinfo/addftinfo.cpp: Align with modern groff
+       conventions.  Add Autoconf "<config.h>"-inclusion boilerplate to
+       this translation unit.  Use standard symbol `EXIT_SUCCESS`
+       instead of zero literal.  Exit with status 2, not 1, on usage
+       errors.
+
+       * src/utils/addftinfo/addftinfo.1.man (Exit status): Add.
+
+       * NEWS: Add addftinfo to list of programs with changed exit
+       status conventions.
+
 2024-11-27  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * bootstrap.conf: Add "getopt-gnu" to `gnulib_modules`.
diff --git a/NEWS b/NEWS
index 2ea6b50b9..1bacc3f76 100644
--- a/NEWS
+++ b/NEWS
@@ -602,11 +602,11 @@ Output drivers
 Miscellaneous
 -------------
 
-*  The commands grodvi, post-grohtml, grolbp, grolj4, grops, grotty,
-   eqn, pre-grohtml, pic, preconv, soelim, tbl, groff, troff, hpftodit,
-   lkbib, lookbib, tfmtodit, and xtotroff now exit with status 2 instead
-   of 1 on usage errors.  grn now exits with status 2 on a usage error
-   instead of a successful status (0).
+*  The commands addftinfo, grodvi, post-grohtml, grolbp, grolj4, grops,
+   grotty, eqn, pre-grohtml, pic, preconv, soelim, tbl, groff, troff,
+   hpftodit, lkbib, lookbib, tfmtodit, and xtotroff now exit with status
+   2 instead of 1 on usage errors.  grn now exits with status 2 on a
+   usage error instead of a successful status (0).
 
 *  Support for terminal devices using the CCSID 1047 (EBCDIC) encoding
    has been withdrawn.
diff --git a/src/utils/addftinfo/addftinfo.1.man 
b/src/utils/addftinfo/addftinfo.1.man
index 53b5283ac..c96308697 100644
--- a/src/utils/addftinfo/addftinfo.1.man
+++ b/src/utils/addftinfo/addftinfo.1.man
@@ -220,6 +220,19 @@ The defaults are chosen to produce reasonable values for a 
Times font.
 .
 .
 .\" ====================================================================
+.SH "Exit status"
+.\" ====================================================================
+.
+.I \%addftinfo
+exits with
+.RB status\~ 0
+on successful operation,
+and
+.RB status\~ 2
+if the program cannot interpret its command-line arguments.
+.
+.
+.\" ====================================================================
 .SH "See also"
 .\" ====================================================================
 .
diff --git a/src/utils/addftinfo/addftinfo.cpp 
b/src/utils/addftinfo/addftinfo.cpp
index 6f4facf7f..7f6090d9d 100644
--- a/src/utils/addftinfo/addftinfo.cpp
+++ b/src/utils/addftinfo/addftinfo.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
      Written by James Clark (jjc@jclark.com)
 
 This file is part of groff.
@@ -16,11 +16,15 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
-#include "lib.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
-#include <ctype.h>
-#include <stdlib.h>
 #include <errno.h>
+#include <stdlib.h> // exit(), EXIT_SUCCESS, strtol()
+
+#include "lib.h"
+
 #include "errarg.h"
 #include "error.h"
 #include "stringclass.h"
@@ -72,7 +76,7 @@ int main(int argc, char **argv)
       version();
     if (!strcmp(argv[i],"--help")) {
       usage(stdout);
-      exit(0);
+      exit(EXIT_SUCCESS);
     }
   }
   if (argc < 4)
@@ -144,7 +148,7 @@ static void usage(FILE *stream)
 static void usage()
 {
   usage(stderr);
-  exit(1);
+  exit(2);
 }
 
 static void usage(const char *problem)
@@ -156,7 +160,7 @@ static void usage(const char *problem)
 static void version()
 {
   printf("GNU addftinfo (groff) version %s\n", Version_string);
-  exit(0);
+  exit(EXIT_SUCCESS);
 }
 
 static int get_line(FILE *fp, string *p)



reply via email to

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