summaryrefslogtreecommitdiff
path: root/tests/stdio.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stdio.in.h')
-rw-r--r--tests/stdio.in.h543
1 files changed, 407 insertions, 136 deletions
diff --git a/tests/stdio.in.h b/tests/stdio.in.h
index 4947307e..e77798d9 100644
--- a/tests/stdio.in.h
+++ b/tests/stdio.in.h
@@ -64,8 +64,8 @@
#define _@GUARD_PREFIX@_STDIO_H
/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT,
- _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK,
- HAVE_RAW_DECL_*. */
+ _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW,
+ GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
#if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first."
#endif
@@ -77,7 +77,8 @@
/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8
and eglibc 2.11.2.
- May also define off_t to a 64-bit type on native Windows. */
+ May also define off_t to a 64-bit type on native Windows.
+ Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */
#include <sys/types.h>
/* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */
@@ -119,7 +120,7 @@
that can be freed by passing them as the Ith argument to the
function F. */
#ifndef _GL_ATTRIBUTE_DEALLOC
-# if __GNUC__ >= 11
+# if __GNUC__ >= 11 && !defined __clang__
# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
# else
# define _GL_ATTRIBUTE_DEALLOC(f, i)
@@ -154,7 +155,7 @@
*/
#ifndef _GL_ATTRIBUTE_NOTHROW
# if defined __cplusplus
-# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4
+# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
# if __cplusplus >= 201103L
# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
# else
@@ -177,7 +178,7 @@
standardized by ISO C99 and POSIX.
_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */
/* __gnu_printf__ is supported in GCC >= 4.4. */
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+#if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4) && !defined __clang__
# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__
#else
# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__
@@ -279,18 +280,37 @@
#endif
+#if @GNULIB_DZPRINTF@
+/* Prints formatted output to file descriptor FD.
+ Returns the number of bytes written to the file descriptor. Upon
+ failure, returns -1 with errno set.
+ Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
+ Therefore, if the format string is valid and does not use %ls/%lc
+ directives nor widths, the only possible failure codes are ENOMEM
+ and the possible failure codes from write(), excluding EINTR. */
+_GL_FUNCDECL_SYS (dzprintf, off64_t,
+ (int fd, const char *restrict format, ...),
+ _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_SYS (dzprintf, off64_t,
+ (int fd, const char *restrict format, ...));
+#endif
+
#if @GNULIB_DPRINTF@
+/* Prints formatted output to file descriptor FD.
+ Returns the number of bytes written to the file descriptor. Upon
+ failure, returns a negative value. */
# if @REPLACE_DPRINTF@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define dprintf rpl_dprintf
# endif
-_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...)
+_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
_GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...));
# else
# if !@HAVE_DPRINTF@
-_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...)
+_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
_GL_ARG_NONNULL ((2)));
# endif
@@ -313,7 +333,7 @@ _GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define fclose rpl_fclose
# endif
-_GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
+_GL_FUNCDECL_RPL (fclose, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
# else
_GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
@@ -360,9 +380,10 @@ _GL_CXXALIASWARN (fcloseall);
# define fdopen rpl_fdopen
# endif
_GL_FUNCDECL_RPL (fdopen, FILE *,
- (int fd, const char *mode)
+ (int fd, const char *mode),
_GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
- _GL_ATTRIBUTE_MALLOC);
+ _GL_ATTRIBUTE_MALLOC
+ _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
# elif defined _WIN32 && !defined __CYGWIN__
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -371,36 +392,38 @@ _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
# endif
_GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
# else
-# if __GNUC__ >= 11
+# if __GNUC__ >= 11 && !defined __clang__
/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_FUNCDECL_SYS (fdopen, FILE *,
- (int fd, const char *mode)
- _GL_ATTRIBUTE_NOTHROW
+ (int fd, const char *mode),
_GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
- _GL_ATTRIBUTE_MALLOC);
+ _GL_ATTRIBUTE_MALLOC
+ _GL_ATTRIBUTE_NODISCARD)
+ _GL_ATTRIBUTE_NOTHROW;
# else
_GL_FUNCDECL_SYS (fdopen, FILE *,
- (int fd, const char *mode)
+ (int fd, const char *mode),
_GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
- _GL_ATTRIBUTE_MALLOC);
+ _GL_ATTRIBUTE_MALLOC
+ _GL_ATTRIBUTE_NODISCARD);
# endif
# endif
_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
# endif
_GL_CXXALIASWARN (fdopen);
#else
-# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen
+# if @GNULIB_FCLOSE@ && (__GNUC__ >= 11 && !defined __clang__) && !defined fdopen
/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_FUNCDECL_SYS (fdopen, FILE *,
- (int fd, const char *mode)
- _GL_ATTRIBUTE_NOTHROW
+ (int fd, const char *mode),
_GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
- _GL_ATTRIBUTE_MALLOC);
+ _GL_ATTRIBUTE_MALLOC)
+ _GL_ATTRIBUTE_NOTHROW;
# else
_GL_FUNCDECL_SYS (fdopen, FILE *,
- (int fd, const char *mode)
+ (int fd, const char *mode),
_GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
_GL_ATTRIBUTE_MALLOC);
# endif
@@ -438,7 +461,7 @@ _GL_CXXALIASWARN (fdopen);
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define fflush rpl_fflush
# endif
-_GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream));
+_GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream), );
_GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
# else
_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
@@ -459,7 +482,7 @@ _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
# undef fgetc
# define fgetc rpl_fgetc
# endif
-_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
+_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
# else
_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
@@ -476,8 +499,8 @@ _GL_CXXALIASWARN (fgetc);
# define fgets rpl_fgets
# endif
_GL_FUNCDECL_RPL (fgets, char *,
- (char *restrict s, int n, FILE *restrict stream)
- _GL_ARG_NONNULL ((1, 3)));
+ (char *restrict s, int n, FILE *restrict stream),
+ _GL_ARG_NONNULL ((1, 3)) _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (fgets, char *,
(char *restrict s, int n, FILE *restrict stream));
# else
@@ -513,17 +536,18 @@ _GL_CXXALIASWARN (fileno);
# define fopen rpl_fopen
# endif
_GL_FUNCDECL_RPL (fopen, FILE *,
- (const char *restrict filename, const char *restrict mode)
+ (const char *restrict filename, const char *restrict mode),
_GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
- _GL_ATTRIBUTE_MALLOC);
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (fopen, FILE *,
(const char *restrict filename, const char *restrict mode));
# else
-# if __GNUC__ >= 11
+# if __GNUC__ >= 11 && !defined __clang__
/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
_GL_FUNCDECL_SYS (fopen, FILE *,
- (const char *restrict filename, const char *restrict mode)
- _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
+ (const char *restrict filename, const char *restrict mode),
+ _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
+ _GL_ATTRIBUTE_NODISCARD);
# endif
_GL_CXXALIAS_SYS (fopen, FILE *,
(const char *restrict filename, const char *restrict mode));
@@ -532,10 +556,10 @@ _GL_CXXALIAS_SYS (fopen, FILE *,
_GL_CXXALIASWARN (fopen);
# endif
#else
-# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fopen
+# if @GNULIB_FCLOSE@ && (__GNUC__ >= 11 && !defined __clang__) && !defined fopen
/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
_GL_FUNCDECL_SYS (fopen, FILE *,
- (const char *restrict filename, const char *restrict mode)
+ (const char *restrict filename, const char *restrict mode),
_GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
# endif
# if defined GNULIB_POSIXCHECK
@@ -546,7 +570,26 @@ _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX complian
# endif
#endif
+#if @GNULIB_FZPRINTF@
+/* Prints formatted output to stream FP.
+ Returns the number of bytes written to the stream. Upon failure,
+ returns -1 with the stream's error indicator set.
+ Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
+ Therefore, if the format string is valid and does not use %ls/%lc
+ directives nor widths, the only possible failure causes are ENOMEM
+ and the possible failure causes from fwrite(). */
+_GL_FUNCDECL_SYS (fzprintf, off64_t,
+ (FILE *restrict fp, const char *restrict format, ...),
+ _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_SYS (fzprintf, off64_t,
+ (FILE *restrict fp, const char *restrict format, ...));
+#endif
+
#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
+/* Prints formatted output to stream FP.
+ Returns the number of bytes written to the stream. Upon failure,
+ returns a negative value with the stream's error indicator set. */
# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
|| (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -555,12 +598,12 @@ _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX complian
# define GNULIB_overrides_fprintf 1
# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
_GL_FUNCDECL_RPL (fprintf, int,
- (FILE *restrict fp, const char *restrict format, ...)
+ (FILE *restrict fp, const char *restrict format, ...),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
_GL_ARG_NONNULL ((1, 2)));
# else
_GL_FUNCDECL_RPL (fprintf, int,
- (FILE *restrict fp, const char *restrict format, ...)
+ (FILE *restrict fp, const char *restrict format, ...),
_GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
_GL_ARG_NONNULL ((1, 2)));
# endif
@@ -595,15 +638,17 @@ _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define fpurge rpl_fpurge
# endif
-_GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
+_GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream), _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
# else
# if !@HAVE_DECL_FPURGE@
-_GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
+_GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream), _GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (fpurge);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef fpurge
# if HAVE_RAW_DECL_FPURGE
@@ -618,7 +663,7 @@ _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
# undef fputc
# define fputc rpl_fputc
# endif
-_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
+_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream), _GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
# else
_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
@@ -635,7 +680,7 @@ _GL_CXXALIASWARN (fputc);
# define fputs rpl_fputs
# endif
_GL_FUNCDECL_RPL (fputs, int,
- (const char *restrict string, FILE *restrict stream)
+ (const char *restrict string, FILE *restrict stream),
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (fputs, int,
(const char *restrict string, FILE *restrict stream));
@@ -656,8 +701,8 @@ _GL_CXXALIASWARN (fputs);
# endif
_GL_FUNCDECL_RPL (fread, size_t,
(void *restrict ptr, size_t s, size_t n,
- FILE *restrict stream)
- _GL_ARG_NONNULL ((4)));
+ FILE *restrict stream),
+ _GL_ARG_NONNULL ((4)) _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (fread, size_t,
(void *restrict ptr, size_t s, size_t n,
FILE *restrict stream));
@@ -679,8 +724,8 @@ _GL_CXXALIASWARN (fread);
# endif
_GL_FUNCDECL_RPL (freopen, FILE *,
(const char *restrict filename, const char *restrict mode,
- FILE *restrict stream)
- _GL_ARG_NONNULL ((2, 3)));
+ FILE *restrict stream),
+ _GL_ARG_NONNULL ((2, 3)) _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (freopen, FILE *,
(const char *restrict filename, const char *restrict mode,
FILE *restrict stream));
@@ -707,9 +752,9 @@ _GL_WARN_ON_USE (freopen,
# define fscanf rpl_fscanf
# endif
_GL_FUNCDECL_RPL (fscanf, int,
- (FILE *restrict stream, const char *restrict format, ...)
+ (FILE *restrict stream, const char *restrict format, ...),
_GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
- _GL_ARG_NONNULL ((1, 2)));
+ _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (fscanf, int,
(FILE *restrict stream, const char *restrict format, ...));
# else
@@ -763,7 +808,7 @@ _GL_CXXALIASWARN (fscanf);
# undef fseek
# define fseek rpl_fseek
# endif
-_GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence)
+_GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence),
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
# else
@@ -786,12 +831,12 @@ _GL_CXXALIASWARN (fseek);
# undef fseeko
# define fseeko rpl_fseeko
# endif
-_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
+_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence),
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
# else
# if ! @HAVE_DECL_FSEEKO@
-_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
+_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence),
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
@@ -829,7 +874,8 @@ _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
# undef ftell
# define ftell rpl_ftell
# endif
-_GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1)));
+_GL_FUNCDECL_RPL (ftell, long, (FILE *fp),
+ _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
# else
_GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
@@ -849,11 +895,13 @@ _GL_CXXALIASWARN (ftell);
# undef ftello
# define ftello rpl_ftello
# endif
-_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
+_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp),
+ _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
# else
# if ! @HAVE_DECL_FTELLO@
-_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
+_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp),
+ _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
# endif
_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
# endif
@@ -886,7 +934,7 @@ _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
# endif
_GL_FUNCDECL_RPL (fwrite, size_t,
(const void *restrict ptr, size_t s, size_t n,
- FILE *restrict stream)
+ FILE *restrict stream),
_GL_ARG_NONNULL ((1, 4)));
_GL_CXXALIAS_RPL (fwrite, size_t,
(const void *restrict ptr, size_t s, size_t n,
@@ -901,20 +949,20 @@ _GL_CXXALIAS_SYS (fwrite, size_t,
which sometimes causes an unwanted diagnostic for fwrite calls.
This affects only function declaration attributes under certain
versions of gcc and clang, and is not needed for C++. */
-# if (0 < __USE_FORTIFY_LEVEL \
+# if (0 < __USE_FORTIFY_LEVEL \
&& __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
- && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \
+ && (3 < __GNUC__ + (4 <= __GNUC_MINOR__) || defined __clang__) \
&& !defined __cplusplus)
# undef fwrite
# undef fwrite_unlocked
-extern size_t __REDIRECT (rpl_fwrite,
- (const void *__restrict, size_t, size_t,
- FILE *__restrict),
- fwrite);
-extern size_t __REDIRECT (rpl_fwrite_unlocked,
- (const void *__restrict, size_t, size_t,
- FILE *__restrict),
- fwrite_unlocked);
+_GL_EXTERN_C size_t __REDIRECT (rpl_fwrite,
+ (const void *__restrict, size_t, size_t,
+ FILE *__restrict),
+ fwrite);
+_GL_EXTERN_C size_t __REDIRECT (rpl_fwrite_unlocked,
+ (const void *__restrict, size_t, size_t,
+ FILE *__restrict),
+ fwrite_unlocked);
# define fwrite rpl_fwrite
# define fwrite_unlocked rpl_fwrite_unlocked
# endif
@@ -930,7 +978,7 @@ _GL_CXXALIASWARN (fwrite);
# undef getc
# define getc rpl_fgetc
# endif
-_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
+_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
# else
_GL_CXXALIAS_SYS (getc, int, (FILE *stream));
@@ -946,7 +994,7 @@ _GL_CXXALIASWARN (getc);
# undef getchar
# define getchar rpl_getchar
# endif
-_GL_FUNCDECL_RPL (getchar, int, (void));
+_GL_FUNCDECL_RPL (getchar, int, (void), );
_GL_CXXALIAS_RPL (getchar, int, (void));
# else
_GL_CXXALIAS_SYS (getchar, int, (void));
@@ -971,8 +1019,8 @@ _GL_CXXALIASWARN (getchar);
_GL_FUNCDECL_RPL (getdelim, ssize_t,
(char **restrict lineptr, size_t *restrict linesize,
int delimiter,
- FILE *restrict stream)
- _GL_ARG_NONNULL ((1, 2, 4)));
+ FILE *restrict stream),
+ _GL_ARG_NONNULL ((1, 2, 4)) _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (getdelim, ssize_t,
(char **restrict lineptr, size_t *restrict linesize,
int delimiter,
@@ -982,8 +1030,8 @@ _GL_CXXALIAS_RPL (getdelim, ssize_t,
_GL_FUNCDECL_SYS (getdelim, ssize_t,
(char **restrict lineptr, size_t *restrict linesize,
int delimiter,
- FILE *restrict stream)
- _GL_ARG_NONNULL ((1, 2, 4)));
+ FILE *restrict stream),
+ _GL_ARG_NONNULL ((1, 2, 4)) _GL_ATTRIBUTE_NODISCARD);
# endif
_GL_CXXALIAS_SYS (getdelim, ssize_t,
(char **restrict lineptr, size_t *restrict linesize,
@@ -1015,8 +1063,8 @@ _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
# endif
_GL_FUNCDECL_RPL (getline, ssize_t,
(char **restrict lineptr, size_t *restrict linesize,
- FILE *restrict stream)
- _GL_ARG_NONNULL ((1, 2, 3)));
+ FILE *restrict stream),
+ _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (getline, ssize_t,
(char **restrict lineptr, size_t *restrict linesize,
FILE *restrict stream));
@@ -1024,8 +1072,8 @@ _GL_CXXALIAS_RPL (getline, ssize_t,
# if !@HAVE_DECL_GETLINE@
_GL_FUNCDECL_SYS (getline, ssize_t,
(char **restrict lineptr, size_t *restrict linesize,
- FILE *restrict stream)
- _GL_ARG_NONNULL ((1, 2, 3)));
+ FILE *restrict stream),
+ _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
# endif
_GL_CXXALIAS_SYS (getline, ssize_t,
(char **restrict lineptr, size_t *restrict linesize,
@@ -1064,7 +1112,7 @@ _GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream));
# if @HAVE_DECL_GETW@
# if defined __APPLE__ && defined __MACH__
/* The presence of the declaration depends on _POSIX_C_SOURCE. */
-_GL_FUNCDECL_SYS (getw, int, (FILE *restrict stream));
+_GL_FUNCDECL_SYS (getw, int, (FILE *restrict stream), );
# endif
_GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream));
# endif
@@ -1074,19 +1122,45 @@ _GL_CXXALIASWARN (getw);
# endif
#endif
+#if @GNULIB_OBSTACK_ZPRINTF@
+struct obstack;
+/* Grows an obstack with formatted output. Returns the number of
+ bytes added to OBS. No trailing nul byte is added, and the
+ object should be closed with obstack_finish before use.
+ Upon memory allocation error, calls obstack_alloc_failed_handler.
+ Upon other error, returns -1 with errno set.
+
+ Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
+ Therefore, if the format string is valid and does not use %ls/%lc
+ directives nor widths, the only possible failure code is through
+ obstack_alloc_failed_handler. */
+_GL_FUNCDECL_SYS (obstack_zprintf, ptrdiff_t,
+ (struct obstack *obs, const char *format, ...),
+ _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_SYS (obstack_zprintf, ptrdiff_t,
+ (struct obstack *obs, const char *format, ...));
+_GL_FUNCDECL_SYS (obstack_vzprintf, ptrdiff_t,
+ (struct obstack *obs, const char *format, va_list args),
+ _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_SYS (obstack_vzprintf, ptrdiff_t,
+ (struct obstack *obs, const char *format, va_list args));
+#endif
+
#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
struct obstack;
-/* Grow an obstack with formatted output. Return the number of
+/* Grows an obstack with formatted output. Returns the number of
bytes added to OBS. No trailing nul byte is added, and the
- object should be closed with obstack_finish before use. Upon
- memory allocation error, call obstack_alloc_failed_handler. Upon
- other error, return -1. */
+ object should be closed with obstack_finish before use.
+ Upon memory allocation error, calls obstack_alloc_failed_handler.
+ Upon other error, returns -1. */
# if @REPLACE_OBSTACK_PRINTF@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define obstack_printf rpl_obstack_printf
# endif
_GL_FUNCDECL_RPL (obstack_printf, int,
- (struct obstack *obs, const char *format, ...)
+ (struct obstack *obs, const char *format, ...),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (obstack_printf, int,
@@ -1094,7 +1168,7 @@ _GL_CXXALIAS_RPL (obstack_printf, int,
# else
# if !@HAVE_DECL_OBSTACK_PRINTF@
_GL_FUNCDECL_SYS (obstack_printf, int,
- (struct obstack *obs, const char *format, ...)
+ (struct obstack *obs, const char *format, ...),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
_GL_ARG_NONNULL ((1, 2)));
# endif
@@ -1107,7 +1181,7 @@ _GL_CXXALIASWARN (obstack_printf);
# define obstack_vprintf rpl_obstack_vprintf
# endif
_GL_FUNCDECL_RPL (obstack_vprintf, int,
- (struct obstack *obs, const char *format, va_list args)
+ (struct obstack *obs, const char *format, va_list args),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (obstack_vprintf, int,
@@ -1115,7 +1189,7 @@ _GL_CXXALIAS_RPL (obstack_vprintf, int,
# else
# if !@HAVE_DECL_OBSTACK_PRINTF@
_GL_FUNCDECL_SYS (obstack_vprintf, int,
- (struct obstack *obs, const char *format, va_list args)
+ (struct obstack *obs, const char *format, va_list args),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
_GL_ARG_NONNULL ((1, 2)));
# endif
@@ -1127,7 +1201,7 @@ _GL_CXXALIASWARN (obstack_vprintf);
#if @GNULIB_PCLOSE@
# if !@HAVE_PCLOSE@
-_GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
+_GL_FUNCDECL_SYS (pclose, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
_GL_CXXALIASWARN (pclose);
@@ -1147,7 +1221,7 @@ _GL_WARN_ON_USE (pclose, "pclose is unportable - "
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define perror rpl_perror
# endif
-_GL_FUNCDECL_RPL (perror, void, (const char *string));
+_GL_FUNCDECL_RPL (perror, void, (const char *string), );
_GL_CXXALIAS_RPL (perror, void, (const char *string));
# else
_GL_CXXALIAS_SYS (perror, void, (const char *string));
@@ -1169,25 +1243,26 @@ _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
# define popen rpl_popen
# endif
_GL_FUNCDECL_RPL (popen, FILE *,
- (const char *cmd, const char *mode)
+ (const char *cmd, const char *mode),
_GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
- _GL_ATTRIBUTE_MALLOC);
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
# else
-# if !@HAVE_POPEN@ || __GNUC__ >= 11
+# if !@HAVE_POPEN@ || (__GNUC__ >= 11 && !defined __clang__)
_GL_FUNCDECL_SYS (popen, FILE *,
- (const char *cmd, const char *mode)
+ (const char *cmd, const char *mode),
_GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
- _GL_ATTRIBUTE_MALLOC);
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD);
# endif
_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
# endif
_GL_CXXALIASWARN (popen);
#else
-# if @GNULIB_PCLOSE@ && __GNUC__ >= 11 && !defined popen
+# if @GNULIB_PCLOSE@ \
+ && (__GNUC__ >= 11 && !defined __clang__) && !defined popen
/* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */
_GL_FUNCDECL_SYS (popen, FILE *,
- (const char *cmd, const char *mode)
+ (const char *cmd, const char *mode),
_GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
_GL_ATTRIBUTE_MALLOC);
# endif
@@ -1200,7 +1275,24 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
# endif
#endif
+#if @GNULIB_ZPRINTF@
+/* Prints formatted output to standard output.
+ Returns the number of bytes written to standard output. Upon failure,
+ returns -1 with stdout's error indicator set.
+ Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
+ Therefore, if the format string is valid and does not use %ls/%lc
+ directives nor widths, the only possible failure causes are ENOMEM
+ and the possible failure causes from fwrite(). */
+_GL_FUNCDECL_SYS (zprintf, off64_t, (const char *restrict format, ...),
+ _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (zprintf, off64_t, (const char *restrict format, ...));
+#endif
+
#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
+/* Prints formatted output to standard output.
+ Returns the number of bytes written to standard output. Upon failure,
+ returns a negative value with stdout's error indicator set. */
# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
|| (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
# if defined __GNUC__ || defined __clang__
@@ -1212,14 +1304,14 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
_GL_FUNCDECL_RPL_1 (__printf__, int,
(const char *restrict format, ...)
__asm__ (@ASM_SYMBOL_PREFIX@
- _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
+ _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
_GL_ARG_NONNULL ((1)));
# else
_GL_FUNCDECL_RPL_1 (__printf__, int,
(const char *restrict format, ...)
__asm__ (@ASM_SYMBOL_PREFIX@
- _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
+ _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)),
_GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
_GL_ARG_NONNULL ((1)));
# endif
@@ -1229,7 +1321,7 @@ _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
# define printf rpl_printf
# endif
_GL_FUNCDECL_RPL (printf, int,
- (const char *restrict format, ...)
+ (const char *restrict format, ...),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...));
@@ -1258,7 +1350,7 @@ _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
# undef putc
# define putc rpl_fputc
# endif
-_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
+_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream), _GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
# else
_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
@@ -1274,7 +1366,7 @@ _GL_CXXALIASWARN (putc);
# undef putchar
# define putchar rpl_putchar
# endif
-_GL_FUNCDECL_RPL (putchar, int, (int c));
+_GL_FUNCDECL_RPL (putchar, int, (int c), );
_GL_CXXALIAS_RPL (putchar, int, (int c));
# else
_GL_CXXALIAS_SYS (putchar, int, (int c));
@@ -1290,7 +1382,7 @@ _GL_CXXALIASWARN (putchar);
# undef puts
# define puts rpl_puts
# endif
-_GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1)));
+_GL_FUNCDECL_RPL (puts, int, (const char *string), _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (puts, int, (const char *string));
# else
_GL_CXXALIAS_SYS (puts, int, (const char *string));
@@ -1314,7 +1406,7 @@ _GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream));
# if @HAVE_DECL_PUTW@
# if defined __APPLE__ && defined __MACH__
/* The presence of the declaration depends on _POSIX_C_SOURCE. */
-_GL_FUNCDECL_SYS (putw, int, (int w, FILE *restrict stream));
+_GL_FUNCDECL_SYS (putw, int, (int w, FILE *restrict stream), );
# endif
_GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream));
# endif
@@ -1330,7 +1422,7 @@ _GL_CXXALIASWARN (putw);
# undef remove
# define remove rpl_remove
# endif
-_GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1)));
+_GL_FUNCDECL_RPL (remove, int, (const char *name), _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (remove, int, (const char *name));
# else
_GL_CXXALIAS_SYS (remove, int, (const char *name));
@@ -1352,7 +1444,7 @@ _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
# define rename rpl_rename
# endif
_GL_FUNCDECL_RPL (rename, int,
- (const char *old_filename, const char *new_filename)
+ (const char *old_filename, const char *new_filename),
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (rename, int,
(const char *old_filename, const char *new_filename));
@@ -1377,14 +1469,14 @@ _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
# define renameat rpl_renameat
# endif
_GL_FUNCDECL_RPL (renameat, int,
- (int fd1, char const *file1, int fd2, char const *file2)
+ (int fd1, char const *file1, int fd2, char const *file2),
_GL_ARG_NONNULL ((2, 4)));
_GL_CXXALIAS_RPL (renameat, int,
(int fd1, char const *file1, int fd2, char const *file2));
# else
# if !@HAVE_RENAMEAT@
_GL_FUNCDECL_SYS (renameat, int,
- (int fd1, char const *file1, int fd2, char const *file2)
+ (int fd1, char const *file1, int fd2, char const *file2),
_GL_ARG_NONNULL ((2, 4)));
# endif
_GL_CXXALIAS_SYS (renameat, int,
@@ -1410,18 +1502,18 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - "
_GL_FUNCDECL_RPL_1 (__scanf__, int,
(const char *restrict format, ...)
__asm__ (@ASM_SYMBOL_PREFIX@
- _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf))
+ _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)),
_GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
- _GL_ARG_NONNULL ((1)));
+ _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...));
# else
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef scanf
# define scanf rpl_scanf
# endif
-_GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...)
+_GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...),
_GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
- _GL_ARG_NONNULL ((1)));
+ _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...));
# endif
# else
@@ -1432,7 +1524,31 @@ _GL_CXXALIASWARN (scanf);
# endif
#endif
+#if @GNULIB_SNZPRINTF@
+/* Prints formatted output to string STR. Similar to sprintf, but the
+ additional parameter SIZE limits how much is written into STR.
+ STR may be NULL, in which case nothing will be written.
+ Returns the string length of the formatted string (which may be larger
+ than SIZE). Upon failure, returns -1 with errno set.
+ Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
+ Therefore, if the format string is valid and does not use %ls/%lc
+ directives nor widths, the only possible failure code is ENOMEM. */
+_GL_FUNCDECL_SYS (snzprintf, ptrdiff_t,
+ (char *restrict str, size_t size,
+ const char *restrict format, ...),
+ _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
+ _GL_ARG_NONNULL ((3)));
+_GL_CXXALIAS_SYS (snzprintf, ptrdiff_t,
+ (char *restrict str, size_t size,
+ const char *restrict format, ...));
+#endif
+
#if @GNULIB_SNPRINTF@
+/* Prints formatted output to string STR. Similar to sprintf, but the
+ additional parameter SIZE limits how much is written into STR.
+ STR may be NULL, in which case nothing will be written.
+ Returns the string length of the formatted string (which may be larger
+ than SIZE). Upon failure, returns a negative value. */
# if @REPLACE_SNPRINTF@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define snprintf rpl_snprintf
@@ -1440,7 +1556,7 @@ _GL_CXXALIASWARN (scanf);
# define GNULIB_overrides_snprintf 1
_GL_FUNCDECL_RPL (snprintf, int,
(char *restrict str, size_t size,
- const char *restrict format, ...)
+ const char *restrict format, ...),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
_GL_ARG_NONNULL ((3)));
_GL_CXXALIAS_RPL (snprintf, int,
@@ -1450,7 +1566,7 @@ _GL_CXXALIAS_RPL (snprintf, int,
# if !@HAVE_DECL_SNPRINTF@
_GL_FUNCDECL_SYS (snprintf, int,
(char *restrict str, size_t size,
- const char *restrict format, ...)
+ const char *restrict format, ...),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
_GL_ARG_NONNULL ((3)));
# endif
@@ -1469,6 +1585,23 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
# endif
#endif
+#if @GNULIB_SZPRINTF@
+/* Prints formatted output to string STR.
+ Returns the string length of the formatted string. Upon failure,
+ returns -1 with errno set.
+ Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
+ Therefore, if the format string is valid and does not use %ls/%lc
+ directives nor widths, the only possible failure code is ENOMEM. */
+_GL_FUNCDECL_SYS (szprintf, ptrdiff_t,
+ (char *restrict str,
+ const char *restrict format, ...),
+ _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_SYS (szprintf, ptrdiff_t,
+ (char *restrict str,
+ const char *restrict format, ...));
+#endif
+
/* Some people would argue that all sprintf uses should be warned about
(for example, OpenBSD issues a link warning for it),
since it can cause security holes due to buffer overruns.
@@ -1479,13 +1612,16 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
GNULIB_POSIXCHECK is defined. */
#if @GNULIB_SPRINTF_POSIX@
+/* Prints formatted output to string STR.
+ Returns the string length of the formatted string. Upon failure,
+ returns a negative value. */
# if @REPLACE_SPRINTF@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define sprintf rpl_sprintf
# endif
# define GNULIB_overrides_sprintf 1
_GL_FUNCDECL_RPL (sprintf, int,
- (char *restrict str, const char *restrict format, ...)
+ (char *restrict str, const char *restrict format, ...),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (sprintf, int,
@@ -1526,16 +1662,18 @@ _GL_CXXALIASWARN (tempnam);
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define tmpfile rpl_tmpfile
# endif
-_GL_FUNCDECL_RPL (tmpfile, FILE *, (void)
+_GL_FUNCDECL_RPL (tmpfile, FILE *, (void),
_GL_ATTRIBUTE_DEALLOC (fclose, 1)
- _GL_ATTRIBUTE_MALLOC);
+ _GL_ATTRIBUTE_MALLOC
+ _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
# else
-# if __GNUC__ >= 11
+# if __GNUC__ >= 11 && !defined __clang__
/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
-_GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
+_GL_FUNCDECL_SYS (tmpfile, FILE *, (void),
_GL_ATTRIBUTE_DEALLOC (fclose, 1)
- _GL_ATTRIBUTE_MALLOC);
+ _GL_ATTRIBUTE_MALLOC
+ _GL_ATTRIBUTE_NODISCARD);
# endif
_GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
# endif
@@ -1543,9 +1681,10 @@ _GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
_GL_CXXALIASWARN (tmpfile);
# endif
#else
-# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile
+# if @GNULIB_FCLOSE@ \
+ && (__GNUC__ >= 11 && !defined __clang__) && !defined tmpfile
/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
-_GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
+_GL_FUNCDECL_SYS (tmpfile, FILE *, (void),
_GL_ATTRIBUTE_DEALLOC (fclose, 1)
_GL_ATTRIBUTE_MALLOC);
# endif
@@ -1558,6 +1697,31 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
# endif
#endif
+#if @GNULIB_VASZPRINTF@
+/* Prints formatted output to a string dynamically allocated with malloc().
+ If the memory allocation succeeds, it stores the address of the string in
+ *RESULT and returns the number of resulting bytes, excluding the trailing
+ NUL. Upon memory allocation error, or some other error, it returns -1
+ with errno set.
+ Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
+ Therefore, if the format string is valid and does not use %ls/%lc
+ directives nor widths, the only possible failure code is ENOMEM. */
+_GL_FUNCDECL_SYS (aszprintf, ptrdiff_t,
+ (char **result, const char *format, ...),
+ _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
+ _GL_ARG_NONNULL ((1, 2))
+ _GL_ATTRIBUTE_NODISCARD);
+_GL_CXXALIAS_SYS (aszprintf, ptrdiff_t,
+ (char **result, const char *format, ...));
+_GL_FUNCDECL_SYS (vaszprintf, ptrdiff_t,
+ (char **result, const char *format, va_list args),
+ _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
+ _GL_ARG_NONNULL ((1, 2))
+ _GL_ATTRIBUTE_NODISCARD);
+_GL_CXXALIAS_SYS (vaszprintf, ptrdiff_t,
+ (char **result, const char *format, va_list args));
+#endif
+
#if @GNULIB_VASPRINTF@
/* Write formatted output to a string dynamically allocated with malloc().
If the memory allocation succeeds, store the address of the string in
@@ -1569,17 +1733,19 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
# endif
# define GNULIB_overrides_asprintf
_GL_FUNCDECL_RPL (asprintf, int,
- (char **result, const char *format, ...)
+ (char **result, const char *format, ...),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
- _GL_ARG_NONNULL ((1, 2)));
+ _GL_ARG_NONNULL ((1, 2))
+ _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (asprintf, int,
(char **result, const char *format, ...));
# else
# if !@HAVE_VASPRINTF@
_GL_FUNCDECL_SYS (asprintf, int,
- (char **result, const char *format, ...)
+ (char **result, const char *format, ...),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
- _GL_ARG_NONNULL ((1, 2)));
+ _GL_ARG_NONNULL ((1, 2))
+ _GL_ATTRIBUTE_NODISCARD);
# endif
_GL_CXXALIAS_SYS (asprintf, int,
(char **result, const char *format, ...));
@@ -1591,17 +1757,19 @@ _GL_CXXALIASWARN (asprintf);
# endif
# define GNULIB_overrides_vasprintf 1
_GL_FUNCDECL_RPL (vasprintf, int,
- (char **result, const char *format, va_list args)
+ (char **result, const char *format, va_list args),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
- _GL_ARG_NONNULL ((1, 2)));
+ _GL_ARG_NONNULL ((1, 2))
+ _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (vasprintf, int,
(char **result, const char *format, va_list args));
# else
# if !@HAVE_VASPRINTF@
_GL_FUNCDECL_SYS (vasprintf, int,
- (char **result, const char *format, va_list args)
+ (char **result, const char *format, va_list args),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
- _GL_ARG_NONNULL ((1, 2)));
+ _GL_ARG_NONNULL ((1, 2))
+ _GL_ATTRIBUTE_NODISCARD);
# endif
_GL_CXXALIAS_SYS (vasprintf, int,
(char **result, const char *format, va_list args));
@@ -1609,13 +1777,32 @@ _GL_CXXALIAS_SYS (vasprintf, int,
_GL_CXXALIASWARN (vasprintf);
#endif
+#if @GNULIB_VDZPRINTF@
+/* Prints formatted output to file descriptor FD.
+ Returns the number of bytes written to the file descriptor. Upon
+ failure, returns -1 with errno set.
+ Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
+ Therefore, if the format string is valid and does not use %ls/%lc
+ directives nor widths, the only possible failure codes are ENOMEM
+ and the possible failure codes from write(), excluding EINTR. */
+_GL_FUNCDECL_SYS (vdzprintf, off64_t,
+ (int fd, const char *restrict format, va_list args),
+ _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_SYS (vdzprintf, off64_t,
+ (int fd, const char *restrict format, va_list args));
+#endif
+
#if @GNULIB_VDPRINTF@
+/* Prints formatted output to file descriptor FD.
+ Returns the number of bytes written to the file descriptor. Upon
+ failure, returns a negative value. */
# if @REPLACE_VDPRINTF@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define vdprintf rpl_vdprintf
# endif
_GL_FUNCDECL_RPL (vdprintf, int,
- (int fd, const char *restrict format, va_list args)
+ (int fd, const char *restrict format, va_list args),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
_GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL (vdprintf, int,
@@ -1623,7 +1810,7 @@ _GL_CXXALIAS_RPL (vdprintf, int,
# else
# if !@HAVE_VDPRINTF@
_GL_FUNCDECL_SYS (vdprintf, int,
- (int fd, const char *restrict format, va_list args)
+ (int fd, const char *restrict format, va_list args),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
_GL_ARG_NONNULL ((2)));
# endif
@@ -1643,7 +1830,28 @@ _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
# endif
#endif
+#if @GNULIB_VFZPRINTF@
+/* Prints formatted output to stream FP.
+ Returns the number of bytes written to the stream. Upon failure,
+ returns -1 with the stream's error indicator set.
+ Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
+ Therefore, if the format string is valid and does not use %ls/%lc
+ directives nor widths, the only possible failure causes are ENOMEM
+ and the possible failure causes from fwrite(). */
+_GL_FUNCDECL_SYS (vfzprintf, off64_t,
+ (FILE *restrict fp,
+ const char *restrict format, va_list args),
+ _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_SYS (vfzprintf, off64_t,
+ (FILE *restrict fp,
+ const char *restrict format, va_list args));
+#endif
+
#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
+/* Prints formatted output to stream FP.
+ Returns the number of bytes written to the stream. Upon failure,
+ returns a negative value with the stream's error indicator set. */
# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
|| (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1653,13 +1861,13 @@ _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
# if @GNULIB_VFPRINTF_POSIX@
_GL_FUNCDECL_RPL (vfprintf, int,
(FILE *restrict fp,
- const char *restrict format, va_list args)
+ const char *restrict format, va_list args),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
_GL_ARG_NONNULL ((1, 2)));
# else
_GL_FUNCDECL_RPL (vfprintf, int,
(FILE *restrict fp,
- const char *restrict format, va_list args)
+ const char *restrict format, va_list args),
_GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
_GL_ARG_NONNULL ((1, 2)));
# endif
@@ -1696,9 +1904,9 @@ _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
# endif
_GL_FUNCDECL_RPL (vfscanf, int,
(FILE *restrict stream,
- const char *restrict format, va_list args)
+ const char *restrict format, va_list args),
_GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
- _GL_ARG_NONNULL ((1, 2)));
+ _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (vfscanf, int,
(FILE *restrict stream,
const char *restrict format, va_list args));
@@ -1712,7 +1920,26 @@ _GL_CXXALIASWARN (vfscanf);
# endif
#endif
+#if @GNULIB_VZPRINTF@
+/* Prints formatted output to standard output.
+ Returns the number of bytes written to standard output. Upon failure,
+ returns -1 with stdout's error indicator set.
+ Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
+ Therefore, if the format string is valid and does not use %ls/%lc
+ directives nor widths, the only possible failure causes are ENOMEM
+ and the possible failure causes from fwrite(). */
+_GL_FUNCDECL_SYS (vzprintf, off64_t,
+ (const char *restrict format, va_list args),
+ _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_SYS (vzprintf, off64_t,
+ (const char *restrict format, va_list args));
+#endif
+
#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
+/* Prints formatted output to standard output.
+ Returns the number of bytes written to standard output. Upon failure,
+ returns a negative value with stdout's error indicator set. */
# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
|| (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1720,11 +1947,11 @@ _GL_CXXALIASWARN (vfscanf);
# endif
# define GNULIB_overrides_vprintf 1
# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
-_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args)
+_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
_GL_ARG_NONNULL ((1)));
# else
-_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args)
+_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args),
_GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
_GL_ARG_NONNULL ((1)));
# endif
@@ -1756,9 +1983,9 @@ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
# undef vscanf
# define vscanf rpl_vscanf
# endif
-_GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args)
+_GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args),
_GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
- _GL_ARG_NONNULL ((1)));
+ _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
_GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args));
# else
_GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args));
@@ -1768,7 +1995,31 @@ _GL_CXXALIASWARN (vscanf);
# endif
#endif
+#if @GNULIB_VSNZPRINTF@
+/* Prints formatted output to string STR. Similar to sprintf, but the
+ additional parameter SIZE limits how much is written into STR.
+ STR may be NULL, in which case nothing will be written.
+ Returns the string length of the formatted string (which may be larger
+ than SIZE). Upon failure, returns -1 with errno set.
+ Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
+ Therefore, if the format string is valid and does not use %ls/%lc
+ directives nor widths, the only possible failure code is ENOMEM. */
+_GL_FUNCDECL_SYS (vsnzprintf, ptrdiff_t,
+ (char *restrict str, size_t size,
+ const char *restrict format, va_list args),
+ _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
+ _GL_ARG_NONNULL ((3)));
+_GL_CXXALIAS_SYS (vsnzprintf, ptrdiff_t,
+ (char *restrict str, size_t size,
+ const char *restrict format, va_list args));
+#endif
+
#if @GNULIB_VSNPRINTF@
+/* Prints formatted output to string STR. Similar to vsprintf, but the
+ additional parameter SIZE limits how much is written into STR.
+ STR may be NULL, in which case nothing will be written.
+ Returns the string length of the formatted string (which may be larger
+ than SIZE). Upon failure, returns a negative value. */
# if @REPLACE_VSNPRINTF@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define vsnprintf rpl_vsnprintf
@@ -1776,7 +2027,7 @@ _GL_CXXALIASWARN (vscanf);
# define GNULIB_overrides_vsnprintf 1
_GL_FUNCDECL_RPL (vsnprintf, int,
(char *restrict str, size_t size,
- const char *restrict format, va_list args)
+ const char *restrict format, va_list args),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
_GL_ARG_NONNULL ((3)));
_GL_CXXALIAS_RPL (vsnprintf, int,
@@ -1786,7 +2037,7 @@ _GL_CXXALIAS_RPL (vsnprintf, int,
# if !@HAVE_DECL_VSNPRINTF@
_GL_FUNCDECL_SYS (vsnprintf, int,
(char *restrict str, size_t size,
- const char *restrict format, va_list args)
+ const char *restrict format, va_list args),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
_GL_ARG_NONNULL ((3)));
# endif
@@ -1805,7 +2056,27 @@ _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
# endif
#endif
+#if @GNULIB_VSZPRINTF@
+/* Prints formatted output to string STR.
+ Returns the string length of the formatted string. Upon failure,
+ returns -1 with errno set.
+ Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
+ Therefore, if the format string is valid and does not use %ls/%lc
+ directives nor widths, the only possible failure code is ENOMEM. */
+_GL_FUNCDECL_SYS (vszprintf, ptrdiff_t,
+ (char *restrict str,
+ const char *restrict format, va_list args),
+ _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_SYS (vszprintf, ptrdiff_t,
+ (char *restrict str,
+ const char *restrict format, va_list args));
+#endif
+
#if @GNULIB_VSPRINTF_POSIX@
+/* Prints formatted output to string STR.
+ Returns the string length of the formatted string. Upon failure,
+ returns a negative value. */
# if @REPLACE_VSPRINTF@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define vsprintf rpl_vsprintf
@@ -1813,7 +2084,7 @@ _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
# define GNULIB_overrides_vsprintf 1
_GL_FUNCDECL_RPL (vsprintf, int,
(char *restrict str,
- const char *restrict format, va_list args)
+ const char *restrict format, va_list args),
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (vsprintf, int,