+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.
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.
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);
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);
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"));
-/* 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
#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
#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
#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
#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
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
gettext-h
gnulib-i18n
stdarg
+vzprintf
+vfzprintf
configure.ac:
m4_ifdef([AM_XGETTEXT_OPTION],
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,
Depends-on:
xprintf
-vprintf-gnu
-vfprintf-gnu
+vzprintf-gnu
+vfzprintf-gnu
configure.ac:
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,
Depends-on:
xprintf
-vprintf-posix
-vfprintf-posix
+vzprintf-posix
+vfzprintf-posix
configure.ac:
#include "macros.h"
-#define RETTYPE int
+#define RETTYPE off64_t
#include "test-fprintf-posix.h"
int
#include "macros.h"
-#define RETTYPE int
+#define RETTYPE off64_t
#include "test-printf-posix.h"
int