]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
xprintf, xprintf-posix, xprintf-gnu: Use *zprintf.
authorBruno Haible <bruno@clisp.org>
Wed, 25 Dec 2024 18:13:53 +0000 (19:13 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 25 Dec 2024 18:13:53 +0000 (19:13 +0100)
* lib/xprintf.h (xprintf, xvprintf, xfprintf, xvfprintf): Change return
type to off64_t. Move documentation from xprintf.c to here. Mention
EOVERFLOW as another possible error unrelated to file I/O.
* lib/xprintf.c (xprintf): Change return type to off64_t.
(xvprintf): Likewise. Use vzprintf.
(xfprintf): Change return type to off64_t.
(xvfprintf): Likewise. Use vfzprintf.
* modules/xprintf (Description): Mention also fprintf. Mention EOVERFLOW
as another possible error unrelated to file I/O.
(Depends-on): Add vzprintf, vfzprintf.
* modules/xprintf-posix (Description): Mention also fprintf. Mention
EOVERFLOW as another possible error unrelated to file I/O.
(Depends-on): Add vzprintf-posix, vfzprintf-posix. Remove vprintf-posix,
vfprintf-posix.
* modules/xprintf-gnu (Description): Mention also fprintf. Mention
EOVERFLOW as another possible error unrelated to file I/O.
(Depends-on): Add vzprintf-gnu, vfzprintf-gnu. Remove vprintf-gnu,
vfprintf-gnu.
* tests/test-xprintf-posix.c (RETTYPE): Change to off64_t.
* tests/test-xfprintf-posix.c (RETTYPE): Likewise.
* NEWS: Document the change.

ChangeLog
NEWS
lib/xprintf.c
lib/xprintf.h
modules/xprintf
modules/xprintf-gnu
modules/xprintf-posix
tests/test-xfprintf-posix.c
tests/test-xprintf-posix.c

index e609ecf440625d22075fd026163b0b1b49e3581b..5c1a2240e79c99accfdc9a64ac4b88326f7be604 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2024-12-25  Bruno Haible  <bruno@clisp.org>
+
+       xprintf, xprintf-posix, xprintf-gnu: Use *zprintf.
+       * lib/xprintf.h (xprintf, xvprintf, xfprintf, xvfprintf): Change return
+       type to off64_t. Move documentation from xprintf.c to here. Mention
+       EOVERFLOW as another possible error unrelated to file I/O.
+       * lib/xprintf.c (xprintf): Change return type to off64_t.
+       (xvprintf): Likewise. Use vzprintf.
+       (xfprintf): Change return type to off64_t.
+       (xvfprintf): Likewise. Use vfzprintf.
+       * modules/xprintf (Description): Mention also fprintf. Mention EOVERFLOW
+       as another possible error unrelated to file I/O.
+       (Depends-on): Add vzprintf, vfzprintf.
+       * modules/xprintf-posix (Description): Mention also fprintf. Mention
+       EOVERFLOW as another possible error unrelated to file I/O.
+       (Depends-on): Add vzprintf-posix, vfzprintf-posix. Remove vprintf-posix,
+       vfprintf-posix.
+       * modules/xprintf-gnu (Description): Mention also fprintf. Mention
+       EOVERFLOW as another possible error unrelated to file I/O.
+       (Depends-on): Add vzprintf-gnu, vfzprintf-gnu. Remove vprintf-gnu,
+       vfprintf-gnu.
+       * tests/test-xprintf-posix.c (RETTYPE): Change to off64_t.
+       * tests/test-xfprintf-posix.c (RETTYPE): Likewise.
+       * NEWS: Document the change.
+
 2024-12-25  Bruno Haible  <bruno@clisp.org>
 
        stdlib: Improve change from 2024-12-23.
diff --git a/NEWS b/NEWS
index 9e08bd104806d214f359572e4e9dd005ccd7651f..e64d1583f8c02b06c1cda94e219246b7fad1038b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -74,6 +74,9 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2024-12-25  xprintf         The functions x[v][f]printf now return an 'off64_t'
+                            instead of an 'int'.
+
 2024-11-05  eealloc         This module is deprecated.  Use malloc-gnu or
                             realloc-posix instead.
 
index 732bbea4078d38c6a0e0d6ad63dd21bd64f84dd6..5d01874b63c91e91104d81200a4eae16e33d10ad 100644 (file)
@@ -14,6 +14,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
+/* written by Jim Meyering */
+
 #include <config.h>
 
 #include "xprintf.h"
 
 #define _(msgid) dgettext ("gnulib", msgid)
 
-/* written by Jim Meyering */
-
-/* Just like printf, but call error if it fails without setting the
-   stream's error indicator.  */
-int
+off64_t
 xprintf (char const *restrict format, ...)
 {
   va_list args;
-  int retval;
+  off64_t retval;
   va_start (args, format);
   retval = xvprintf (format, args);
   va_end (args);
@@ -42,25 +40,21 @@ xprintf (char const *restrict format, ...)
   return retval;
 }
 
-/* Just like vprintf, but call error if it fails without setting the
-   stream's error indicator.  */
-int
+off64_t
 xvprintf (char const *restrict format, va_list args)
 {
-  int retval = vprintf (format, args);
+  off64_t retval = vzprintf (format, args);
   if (retval < 0 && ! ferror (stdout))
     error (exit_failure, errno, _("cannot perform formatted output"));
 
   return retval;
 }
 
-/* Just like fprintf, but call error if it fails without setting the
-   stream's error indicator.  */
-int
+off64_t
 xfprintf (FILE *restrict stream, char const *restrict format, ...)
 {
   va_list args;
-  int retval;
+  off64_t retval;
   va_start (args, format);
   retval = xvfprintf (stream, format, args);
   va_end (args);
@@ -68,12 +62,10 @@ xfprintf (FILE *restrict stream, char const *restrict format, ...)
   return retval;
 }
 
-/* Just like vfprintf, but call error if it fails without setting the
-   stream's error indicator.  */
-int
+off64_t
 xvfprintf (FILE *restrict stream, char const *restrict format, va_list args)
 {
-  int retval = vfprintf (stream, format, args);
+  off64_t retval = vfzprintf (stream, format, args);
   if (retval < 0 && ! ferror (stream))
     error (exit_failure, errno, _("cannot perform formatted output"));
 
index 202dbd20227ad741eedaba87b88fa11f590b4cff..c30b5080a0e8f5e6848cba68697455c3041e550a 100644 (file)
@@ -1,4 +1,4 @@
-/* printf wrappers that fail immediately for non-file-related errors
+/* printf and fprintf wrappers that fail immediately for non-file-related errors
    Copyright (C) 2007-2024 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -30,7 +30,9 @@ extern "C" {
 #endif
 
 
-extern int xprintf (char const *restrict format, ...)
+/* Like zprintf, but call error if it fails without setting stdout's
+   error indicator, i.e. upon ENOMEM, EOVERFLOW, or EILSEQ errors.  */
+extern off64_t xprintf (char const *restrict format, ...)
 #if GNULIB_VPRINTF_POSIX
      _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 1, 2))
 #else
@@ -38,7 +40,9 @@ extern int xprintf (char const *restrict format, ...)
 #endif
      ;
 
-extern int xvprintf (char const *restrict format, va_list args)
+/* Like vzprintf, but call error if it fails without setting stdout's
+   error indicator, i.e. upon ENOMEM, EOVERFLOW, or EILSEQ errors.  */
+extern off64_t xvprintf (char const *restrict format, va_list args)
 #if GNULIB_VPRINTF_POSIX
      _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 1, 0))
 #else
@@ -46,7 +50,10 @@ extern int xvprintf (char const *restrict format, va_list args)
 #endif
      ;
 
-extern int xfprintf (FILE *restrict stream, char const *restrict format, ...)
+/* Like fzprintf, but call error if it fails without setting the stream's
+   error indicator, i.e. upon ENOMEM, EOVERFLOW, or EILSEQ errors.  */
+extern off64_t xfprintf (FILE *restrict stream, char const *restrict format,
+                         ...)
 #if GNULIB_VFPRINTF_POSIX
      _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 2, 3))
 #else
@@ -54,8 +61,10 @@ extern int xfprintf (FILE *restrict stream, char const *restrict format, ...)
 #endif
      ;
 
-extern int xvfprintf (FILE *restrict stream, char const *restrict format,
-                      va_list args)
+/* Like vfzprintf, but call error if it fails without setting the stream's
+   error indicator, i.e. upon ENOMEM, EOVERFLOW, or EILSEQ errors.  */
+extern off64_t xvfprintf (FILE *restrict stream, char const *restrict format,
+                          va_list args)
 #if GNULIB_VFPRINTF_POSIX
      _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 2, 0))
 #else
index 79c82d91685a5a31535f5abeffd3e9a1fca806e2..dfe8cbe114242fd8edee35d3b382acfc338e925c 100644 (file)
@@ -1,5 +1,6 @@
 Description:
-a wrapper around printf that calls error upon ENOMEM or EILSEQ errors
+Wrappers around printf and fprintf that call error
+upon ENOMEM, EOVERFLOW, or EILSEQ errors.
 
 Files:
 lib/xprintf.h
@@ -12,6 +13,8 @@ exitfail
 gettext-h
 gnulib-i18n
 stdarg
+vzprintf
+vfzprintf
 
 configure.ac:
 m4_ifdef([AM_XGETTEXT_OPTION],
index c0fd3f062b0983eed2581361fdc332be1f6ae58b..704a5fde6df7934f525692ba51ee6f961979290b 100644 (file)
@@ -1,6 +1,7 @@
 Description:
-A wrapper around printf with POSIX and GNU compatible format string
-interpretation, that calls error upon ENOMEM or EILSEQ errors.
+Wrappers around printf and fprintf
+with POSIX and GNU compatible format string interpretation,
+that calls error upon ENOMEM, EOVERFLOW, or EILSEQ errors.
 
 Comment:
 This module should not be used as a dependency from a test module,
@@ -12,8 +13,8 @@ Files:
 
 Depends-on:
 xprintf
-vprintf-gnu
-vfprintf-gnu
+vzprintf-gnu
+vfzprintf-gnu
 
 configure.ac:
 
index 5335d5c9c0562958669c944c866b30832b1e4f4b..98e7c6df2066ffe136a4d605d067b1dce2e03b1b 100644 (file)
@@ -1,6 +1,7 @@
 Description:
-A wrapper around printf with POSIX compatible format string interpretation,
-that calls error upon ENOMEM or EILSEQ errors.
+Wrappers around printf and fprintf
+with POSIX compatible format string interpretation,
+that calls error upon ENOMEM, EOVERFLOW, or EILSEQ errors.
 
 Comment:
 This module should not be used as a dependency from a test module,
@@ -12,8 +13,8 @@ Files:
 
 Depends-on:
 xprintf
-vprintf-posix
-vfprintf-posix
+vzprintf-posix
+vfzprintf-posix
 
 configure.ac:
 
index 18a3a0dfd98b77ccf2d717aa78afdc37a86ee24c..373d95b829dc0c4a6ae66a68561d02ba2b5c0974 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "macros.h"
 
-#define RETTYPE int
+#define RETTYPE off64_t
 #include "test-fprintf-posix.h"
 
 int
index c9e79c0e267554f4d9dda8db5edb17d483f4e3c3..38e5c2c9d6669d7951019b34f9c6a2e44e37ed04 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "macros.h"
 
-#define RETTYPE int
+#define RETTYPE off64_t
 #include "test-printf-posix.h"
 
 int