]> Savannah Git Hosting - gnulib.git/commitdiff
Move xstrtol_fatal to a new xstrtol-error module
authorPino Toscano <ptoscano@redhat.com>
Thu, 5 Dec 2019 15:18:35 +0000 (16:18 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 7 Dec 2019 09:39:56 +0000 (10:39 +0100)
The xstrtol module provides a xstrtol_fatal function which uses other
modules suitable mostly for command line handling (e.g. gettext,
getopt), and that are completely unused when using only xstrto*
functions. Furthermore, xstrtol_fatal is used only in the xstrtol-tests
(within gnulib itself).

As solution, move the xstrtol_fatal to a new xstrtol-error module,
making xstrtol-tests depend on it. Since the prototype of xstrtol_fatal
is automatically provided by xstrtol.h, it is very difficult to know
whether anyone is actually using it, so add a note about this in NEWS.

* lib/xstrtol.h: Stop including <getopt.h>.
(xstrtol_fatal): Move ...
* lib/xstrtol-error.h: ... here.  New file.
* lib/xstrtol-error.c: Include xstrtol-error.h instead of xstrtol.h.
* tests/test-xstrtol.c: Likewise.
* modules/xstrtol (Files): Remove lib/xstrtol-error.c.
(Depends-on): Remove exitfail, error, getopt-gnu, and gettext-h.
(Makefile.am): Remove xstrtol-error.c from lib_SOURCES.
* modules/xstrtol-error: New file.
* modules/xstrtol-tests (Depends-on): Add xstrtol-error.
* MODULES.html.sh: Add xstrtol-error.
* NEWS: Document the change.

ChangeLog
MODULES.html.sh
NEWS
lib/xstrtol-error.c
lib/xstrtol-error.h [new file with mode: 0644]
lib/xstrtol.h
modules/xstrtol
modules/xstrtol-error [new file with mode: 0644]
modules/xstrtol-tests
tests/test-xstrtol.c

index 493211d667d040928f09b5e59b07e8d9b7f7614b..f00b84cc781a877f1ad87ee8e0c2e627f6978cae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2019-12-05  Pino Toscano  <ptoscano@redhat.com>
+
+       Move xstrtol_fatal to a new xstrtol-error module.
+       * lib/xstrtol.h: Stop including <getopt.h>.
+       (xstrtol_fatal): Move ...
+       * lib/xstrtol-error.h: ... here.  New file.
+       * lib/xstrtol-error.c: Include xstrtol-error.h instead of xstrtol.h.
+       * tests/test-xstrtol.c: Likewise.
+       * modules/xstrtol (Files): Remove lib/xstrtol-error.c.
+       (Depends-on): Remove exitfail, error, getopt-gnu, and gettext-h.
+       (Makefile.am): Remove xstrtol-error.c from lib_SOURCES.
+       * modules/xstrtol-error: New file.
+       * modules/xstrtol-tests (Depends-on): Add xstrtol-error.
+       * MODULES.html.sh: Add xstrtol-error.
+       * NEWS: Document the change.
+
 2019-12-06  Paul Eggert  <eggert@cs.ucla.edu>
 
        nstrftime: better width support for %N, %z
index 107f16cc269b004af7df8d24aed20873578d4691..2ed3bf905257dbcf7c9619ac970fbbae2b708ebe 100755 (executable)
@@ -1861,6 +1861,7 @@ func_all_modules ()
   func_module c-strtold
   func_module xstrtod
   func_module xstrtol
+  func_module xstrtol-error
   func_module xstrtoll
   func_module xstrtold
   func_end_table
diff --git a/NEWS b/NEWS
index 2655d7fc93ebe1c01483f3a2d7d15c1b21fe4264..c0fe790e772ea520960e54d7c40de13c054ce563 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,12 @@ Important general notes
 
 Date        Modules         Changes
 
+2019-12-07  userspec        The xstrtol_fatal is moved away from the xstrtol
+            xstrtoimax      module to a new xstrtol-error module. Because of
+            xstrtol         this, using xstrtol or any of the modules using it
+            xstrtoll        does not pull automatically the exitfail, error,
+            xstrtoumax      getopt-gnu, and gettext-h modules.
+
 2019-03-16  fatal-signal    The function that you pass to at_fatal_signal now
                             takes the signal as argument.
 
index a0d10c2856180268f8023d074f85f1130814a6fd..386d22b2d99389365143ca926f63de0fd17ed30a 100644 (file)
@@ -17,7 +17,7 @@
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #include <config.h>
-#include "xstrtol.h"
+#include "xstrtol-error.h"
 
 #include <stdlib.h>
 
diff --git a/lib/xstrtol-error.h b/lib/xstrtol-error.h
new file mode 100644 (file)
index 0000000..a9cd940
--- /dev/null
@@ -0,0 +1,45 @@
+/* Error reporting interface for xstrto* functions.
+
+   Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2019 Free Software
+   Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+#ifndef XSTRTOL_ERROR_H_
+# define XSTRTOL_ERROR_H_ 1
+
+# include "xstrtol.h"
+
+# include <getopt.h>
+
+/* Report an error for an invalid integer in an option argument.
+
+   ERR is the error code returned by one of the xstrto* functions.
+
+   Use OPT_IDX to decide whether to print the short option string "C"
+   or "-C" or a long option string derived from LONG_OPTION.  OPT_IDX
+   is -2 if the short option "C" was used, without any leading "-"; it
+   is -1 if the short option "-C" was used; otherwise it is an index
+   into LONG_OPTIONS, which should have a name preceded by two '-'
+   characters.
+
+   ARG is the option-argument containing the integer.
+
+   After reporting an error, exit with a failure status.  */
+
+_Noreturn void xstrtol_fatal (enum strtol_error,
+                              int, char, struct option const *,
+                              char const *);
+
+#endif /* not XSTRTOL_ERROR_H_ */
index fff320d504120a10b5c3c975463e046915e73d90..d888120e6bae47f0c833dfebd70bc13ec4ce84bc 100644 (file)
@@ -19,7 +19,6 @@
 #ifndef XSTRTOL_H_
 # define XSTRTOL_H_ 1
 
-# include <getopt.h>
 # include <inttypes.h>
 
 # ifndef _STRTOL_ERROR
@@ -51,23 +50,4 @@ _DECLARE_XSTRTOL (xstrtoll, long long int)
 _DECLARE_XSTRTOL (xstrtoull, unsigned long long int)
 #endif
 
-/* Report an error for an invalid integer in an option argument.
-
-   ERR is the error code returned by one of the xstrto* functions.
-
-   Use OPT_IDX to decide whether to print the short option string "C"
-   or "-C" or a long option string derived from LONG_OPTION.  OPT_IDX
-   is -2 if the short option "C" was used, without any leading "-"; it
-   is -1 if the short option "-C" was used; otherwise it is an index
-   into LONG_OPTIONS, which should have a name preceded by two '-'
-   characters.
-
-   ARG is the option-argument containing the integer.
-
-   After reporting an error, exit with a failure status.  */
-
-_Noreturn void xstrtol_fatal (enum strtol_error,
-                              int, char, struct option const *,
-                              char const *);
-
 #endif /* not XSTRTOL_H_ */
index 26240ecc994fd845a066dfc3729db48bade6e655..a765f9745270d1313aacba6665d58c4a166fa64a 100644 (file)
@@ -5,22 +5,17 @@ Files:
 lib/xstrtol.h
 lib/xstrtol.c
 lib/xstrtoul.c
-lib/xstrtol-error.c
 m4/xstrtol.m4
 
 Depends-on:
 assure
-exitfail
-error
-getopt-gnu
-gettext-h
 inttypes-incomplete
 
 configure.ac:
 gl_XSTRTOL
 
 Makefile.am:
-lib_SOURCES += xstrtol.c xstrtoul.c xstrtol-error.c
+lib_SOURCES += xstrtol.c xstrtoul.c
 
 Include:
 "xstrtol.h"
diff --git a/modules/xstrtol-error b/modules/xstrtol-error
new file mode 100644 (file)
index 0000000..9c3da2a
--- /dev/null
@@ -0,0 +1,27 @@
+Description:
+Error reporting function for xstrto* functions.
+
+Files:
+lib/xstrtol-error.c
+lib/xstrtol-error.h
+
+Depends-on:
+xstrtol
+error
+exitfail
+getopt-gnu
+gettext-h
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += xstrtol-error.c
+
+Include:
+"xstrtol-error.h"
+
+License:
+GPL
+
+Maintainer:
+Jim Meyering
index da11c19608f594ab7355e2b3eb07033adda63be8..1786873d07732c3cca1cdd9be7aeb0cf6cfa405d 100644 (file)
@@ -6,6 +6,7 @@ tests/test-xstrtol.sh
 Depends-on:
 inttypes
 test-framework-sh
+xstrtol-error
 
 configure.ac:
 
index 7f9df2e3fa07dd73c9c1544aab27e8f2249bfdcc..ffac9bdead291f4ba7d110525e548b0928b81671 100644 (file)
@@ -20,7 +20,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#include "xstrtol.h"
+#include "xstrtol-error.h"
 #include "error.h"
 
 #ifndef __xstrtol