diff options
| author | Jörg Frings-Fürst <debian@jff.email> | 2026-03-10 13:24:07 +0100 |
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff.email> | 2026-03-10 13:24:07 +0100 |
| commit | cfd1f17f1a85d95ea12bca8dae42add7dad1ad11 (patch) | |
| tree | 8016486f8ee7157213f2d09ff2491bfa9c94638a /tests/stdio.in.h | |
| parent | 14e4d584d0121031ec40e6c35869745f1747ff29 (diff) | |
| parent | 1403307d6e2fb4e7b5d97a35f40d1e95134561ab (diff) | |
Merge branch 'release/debian/1.4.2-1'HEADdebian/1.4.2-1master
Diffstat (limited to 'tests/stdio.in.h')
| -rw-r--r-- | tests/stdio.in.h | 142 |
1 files changed, 87 insertions, 55 deletions
diff --git a/tests/stdio.in.h b/tests/stdio.in.h index e77798d9..33b0b8e4 100644 --- a/tests/stdio.in.h +++ b/tests/stdio.in.h @@ -1,6 +1,6 @@ /* A GNU-like <stdio.h>. - Copyright (C) 2004, 2007-2024 Free Software Foundation, Inc. + Copyright (C) 2004, 2007-2026 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -20,14 +20,9 @@ #endif @PRAGMA_COLUMNS@ -#if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H +#if defined __need_FILE || defined __need___FILE || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H || defined _GL_SKIP_GNULIB_STDIO_H /* Special invocation convention: - - Inside glibc header files. - - On OSF/1 5.1 we have a sequence of nested includes - <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> -> - <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>. - In this situation, the functions are not yet declared, therefore we cannot - provide the C++ aliases. */ + - Inside glibc header files. */ #@INCLUDE_NEXT@ @NEXT_STDIO_H@ @@ -48,12 +43,12 @@ # endif #endif -#define _GL_ALREADY_INCLUDING_STDIO_H +#define _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_STDIO_H@ -#undef _GL_ALREADY_INCLUDING_STDIO_H +#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H #ifdef _GL_DEFINED__POSIX_C_SOURCE # undef _GL_DEFINED__POSIX_C_SOURCE @@ -269,10 +264,6 @@ - with MSVC ucrt: "[-]nan" or "[-]nan(ind)" or "[-]nan(snan)", - with mingw: "[-]1.#IND" or "[-]1.#QNAN". */ # define _PRINTF_NAN_LEN_MAX 10 -# elif defined __sgi -/* On IRIX, the output typically is "[-]nan0xNNNNNNNN" with 8 hexadecimal - digits. */ -# define _PRINTF_NAN_LEN_MAX 14 # else /* We don't know, but 32 should be a safe maximum. */ # define _PRINTF_NAN_LEN_MAX 32 @@ -280,6 +271,33 @@ #endif +#if (defined _WIN32 && !defined __CYGWIN__) && !defined _UCRT +/* Workarounds against msvcrt bugs. */ +_GL_FUNCDECL_SYS (gl_consolesafe_fwrite, size_t, + (const void *ptr, size_t size, size_t nmemb, FILE *fp), + _GL_ARG_NONNULL ((1, 4))); +# if defined __MINGW32__ +_GL_FUNCDECL_SYS (gl_consolesafe_fprintf, int, + (FILE *restrict fp, const char *restrict format, ...), + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) + _GL_ARG_NONNULL ((1, 2))); +_GL_FUNCDECL_SYS (gl_consolesafe_printf, int, + (const char *restrict format, ...), + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) + _GL_ARG_NONNULL ((1))); +_GL_FUNCDECL_SYS (gl_consolesafe_vfprintf, int, + (FILE *restrict fp, + const char *restrict format, va_list args), + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) + _GL_ARG_NONNULL ((1, 2))); +_GL_FUNCDECL_SYS (gl_consolesafe_vprintf, int, + (const char *restrict format, va_list args), + _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0) + _GL_ARG_NONNULL ((1))); +# endif +#endif + + #if @GNULIB_DZPRINTF@ /* Prints formatted output to file descriptor FD. Returns the number of bytes written to the file descriptor. Upon @@ -320,7 +338,7 @@ _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...)); _GL_CXXALIASWARN (dprintf); # endif #elif defined GNULIB_POSIXCHECK -# undef dprintf +# undef dprintf /* https://lists.gnu.org/r/bug-gnulib/2025-11/msg00254.html */ # if HAVE_RAW_DECL_DPRINTF _GL_WARN_ON_USE (dprintf, "dprintf is unportable - " "use gnulib module dprintf for portability"); @@ -342,7 +360,6 @@ _GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); _GL_CXXALIASWARN (fclose); # endif #elif defined GNULIB_POSIXCHECK -# undef fclose /* Assume fclose is always declared. */ _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - " "use gnulib module fclose for portable POSIX compliance"); @@ -429,7 +446,6 @@ _GL_FUNCDECL_SYS (fdopen, FILE *, # endif # endif # if defined GNULIB_POSIXCHECK -# undef fdopen /* Assume fdopen is always declared. */ _GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - " "use gnulib module fdopen for portability"); @@ -470,7 +486,6 @@ _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); _GL_CXXALIASWARN (fflush); # endif #elif defined GNULIB_POSIXCHECK -# undef fflush /* Assume fflush is always declared. */ _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " "use gnulib module fflush for portable POSIX compliance"); @@ -563,7 +578,6 @@ _GL_FUNCDECL_SYS (fopen, FILE *, _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); # endif # if defined GNULIB_POSIXCHECK -# undef fopen /* Assume fopen is always declared. */ _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - " "use gnulib module fopen for portability"); @@ -616,11 +630,13 @@ _GL_CXXALIAS_SYS (fprintf, int, # if __GLIBC__ >= 2 _GL_CXXALIASWARN (fprintf); # endif -#endif -#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK -# if !GNULIB_overrides_fprintf +#elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fprintf +# define fprintf gl_consolesafe_fprintf # endif +#endif +#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK /* Assume fprintf is always declared. */ _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - " "use gnulib module fprintf-posix for portable " @@ -650,7 +666,6 @@ _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); _GL_CXXALIASWARN (fpurge); # endif #elif defined GNULIB_POSIXCHECK -# undef fpurge # if HAVE_RAW_DECL_FPURGE _GL_WARN_ON_USE (fpurge, "fpurge is not always present - " "use gnulib module fpurge for portability"); @@ -738,7 +753,6 @@ _GL_CXXALIAS_SYS (freopen, FILE *, _GL_CXXALIASWARN (freopen); # endif #elif defined GNULIB_POSIXCHECK -# undef freopen /* Assume freopen is always declared. */ _GL_WARN_ON_USE (freopen, "freopen on native Windows platforms is not POSIX compliant - " @@ -845,7 +859,6 @@ _GL_CXXALIASWARN (fseeko); #elif defined GNULIB_POSIXCHECK # define _GL_FSEEK_WARN /* Category 1, above. */ # undef fseek -# undef fseeko # if HAVE_RAW_DECL_FSEEKO _GL_WARN_ON_USE (fseeko, "fseeko is unportable - " "use gnulib module fseeko for portability"); @@ -909,7 +922,6 @@ _GL_CXXALIASWARN (ftello); #elif defined GNULIB_POSIXCHECK # define _GL_FTELL_WARN /* Category 1, above. */ # undef ftell -# undef ftello # if HAVE_RAW_DECL_FTELLO _GL_WARN_ON_USE (ftello, "ftello is unportable - " "use gnulib module ftello for portability"); @@ -945,7 +957,7 @@ _GL_CXXALIAS_SYS (fwrite, size_t, FILE *restrict stream)); /* Work around bug 11959 when fortifying glibc 2.4 through 2.15 - <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>, + <https://sourceware.org/PR11959>, 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++. */ @@ -970,6 +982,11 @@ _GL_EXTERN_C size_t __REDIRECT (rpl_fwrite_unlocked, # if __GLIBC__ >= 2 _GL_CXXALIASWARN (fwrite); # endif +#elif (defined _WIN32 && !defined __CYGWIN__) && !defined _UCRT +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fwrite +# define fwrite gl_consolesafe_fwrite +# endif #endif #if @GNULIB_GETC@ @@ -1016,6 +1033,17 @@ _GL_CXXALIASWARN (getchar); # undef getdelim # define getdelim rpl_getdelim # endif +# ifndef __has_feature +# define __has_feature(a) 0 +# endif +# if __GLIBC__ >= 2 && !(defined __SANITIZE_ADDRESS__ \ + || __has_feature (address_sanitizer)) +/* Arrange for the inline definition of getline() in <bits/stdio.h> + to call our getdelim() override. Do not use the __getdelim symbol + if address sanitizer is in use, otherwise it may be overridden by + __interceptor_trampoline___getdelim. */ +# define rpl_getdelim __getdelim +# endif _GL_FUNCDECL_RPL (getdelim, ssize_t, (char **restrict lineptr, size_t *restrict linesize, int delimiter, @@ -1042,7 +1070,6 @@ _GL_CXXALIAS_SYS (getdelim, ssize_t, _GL_CXXALIASWARN (getdelim); # endif #elif defined GNULIB_POSIXCHECK -# undef getdelim # if HAVE_RAW_DECL_GETDELIM _GL_WARN_ON_USE (getdelim, "getdelim is unportable - " "use gnulib module getdelim for portability"); @@ -1057,14 +1084,27 @@ _GL_WARN_ON_USE (getdelim, "getdelim is unportable - " Return the number of bytes read and stored at *LINEPTR (not including the NUL terminator), or -1 on error or EOF. */ # if @REPLACE_GETLINE@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef getline -# define getline rpl_getline -# endif _GL_FUNCDECL_RPL (getline, ssize_t, (char **restrict lineptr, size_t *restrict linesize, FILE *restrict stream), _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD); +# if defined __cplusplus +/* The C++ standard library defines std::basic_istream::getline in <istream> + or <string>. */ +# if !(__GLIBC__ >= 2) +extern "C" { +inline ssize_t +getline (char **restrict lineptr, size_t *restrict linesize, + FILE *restrict stream) +{ + return rpl_getline (lineptr, linesize, stream); +} +} +# endif +# else +# undef getline +# define getline rpl_getline +# endif _GL_CXXALIAS_RPL (getline, ssize_t, (char **restrict lineptr, size_t *restrict linesize, FILE *restrict stream)); @@ -1083,7 +1123,6 @@ _GL_CXXALIAS_SYS (getline, ssize_t, _GL_CXXALIASWARN (getline); # endif #elif defined GNULIB_POSIXCHECK -# undef getline # if HAVE_RAW_DECL_GETLINE _GL_WARN_ON_USE (getline, "getline is unportable - " "use gnulib module getline for portability"); @@ -1093,7 +1132,6 @@ _GL_WARN_ON_USE (getline, "getline is unportable - " /* It is very rare that the developer ever has full control of stdin, so any use of gets warrants an unconditional warning; besides, C11 removed it. */ -#undef gets #if HAVE_RAW_DECL_GETS && !defined __cplusplus _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); #endif @@ -1206,7 +1244,6 @@ _GL_FUNCDECL_SYS (pclose, int, (FILE *stream), _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_SYS (pclose, int, (FILE *stream)); _GL_CXXALIASWARN (pclose); #elif defined GNULIB_POSIXCHECK -# undef pclose # if HAVE_RAW_DECL_PCLOSE _GL_WARN_ON_USE (pclose, "pclose is unportable - " "use gnulib module pclose for more portability"); @@ -1230,7 +1267,6 @@ _GL_CXXALIAS_SYS (perror, void, (const char *string)); _GL_CXXALIASWARN (perror); # endif #elif defined GNULIB_POSIXCHECK -# undef perror /* Assume perror is always declared. */ _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " "use gnulib module perror for portability"); @@ -1267,7 +1303,6 @@ _GL_FUNCDECL_SYS (popen, FILE *, _GL_ATTRIBUTE_MALLOC); # endif # if defined GNULIB_POSIXCHECK -# undef popen # if HAVE_RAW_DECL_POPEN _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " "use gnulib module popen or pipe for more portability"); @@ -1333,11 +1368,13 @@ _GL_CXXALIAS_SYS (printf, int, (const char *restrict format, ...)); # if __GLIBC__ >= 2 _GL_CXXALIASWARN (printf); # endif -#endif -#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK -# if !GNULIB_overrides_printf +#elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef printf +# define printf gl_consolesafe_printf # endif +#endif +#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK /* Assume printf is always declared. */ _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - " "use gnulib module printf-posix for portable " @@ -1431,7 +1468,6 @@ _GL_CXXALIAS_SYS (remove, int, (const char *name)); _GL_CXXALIASWARN (remove); # endif #elif defined GNULIB_POSIXCHECK -# undef remove /* Assume remove is always declared. */ _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - " "use gnulib module remove for more portability"); @@ -1456,7 +1492,6 @@ _GL_CXXALIAS_SYS (rename, int, _GL_CXXALIASWARN (rename); # endif #elif defined GNULIB_POSIXCHECK -# undef rename /* Assume rename is always declared. */ _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - " "use gnulib module rename for more portability"); @@ -1484,7 +1519,6 @@ _GL_CXXALIAS_SYS (renameat, int, # endif _GL_CXXALIASWARN (renameat); #elif defined GNULIB_POSIXCHECK -# undef renameat # if HAVE_RAW_DECL_RENAMEAT _GL_WARN_ON_USE (renameat, "renameat is not portable - " "use gnulib module renameat for portability"); @@ -1578,7 +1612,6 @@ _GL_CXXALIAS_SYS (snprintf, int, _GL_CXXALIASWARN (snprintf); # endif #elif defined GNULIB_POSIXCHECK -# undef snprintf # if HAVE_RAW_DECL_SNPRINTF _GL_WARN_ON_USE (snprintf, "snprintf is unportable - " "use gnulib module snprintf for portability"); @@ -1634,7 +1667,6 @@ _GL_CXXALIAS_SYS (sprintf, int, _GL_CXXALIASWARN (sprintf); # endif #elif defined GNULIB_POSIXCHECK -# undef sprintf /* Assume sprintf is always declared. */ _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - " "use gnulib module sprintf-posix for portable " @@ -1689,7 +1721,6 @@ _GL_FUNCDECL_SYS (tmpfile, FILE *, (void), _GL_ATTRIBUTE_MALLOC); # endif # if defined GNULIB_POSIXCHECK -# undef tmpfile # if HAVE_RAW_DECL_TMPFILE _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " "use gnulib module tmpfile for portability"); @@ -1823,7 +1854,6 @@ _GL_CXXALIAS_SYS_CAST (vdprintf, int, _GL_CXXALIASWARN (vdprintf); # endif #elif defined GNULIB_POSIXCHECK -# undef vdprintf # if HAVE_RAW_DECL_VDPRINTF _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " "use gnulib module vdprintf for portability"); @@ -1885,11 +1915,13 @@ _GL_CXXALIAS_SYS_CAST (vfprintf, int, # if __GLIBC__ >= 2 _GL_CXXALIASWARN (vfprintf); # endif -#endif -#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK -# if !GNULIB_overrides_vfprintf +#elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef vfprintf +# define vfprintf gl_consolesafe_vfprintf # endif +#endif +#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK /* Assume vfprintf is always declared. */ _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - " "use gnulib module vfprintf-posix for portable " @@ -1966,11 +1998,13 @@ _GL_CXXALIAS_SYS_CAST (vprintf, int, # if __GLIBC__ >= 2 _GL_CXXALIASWARN (vprintf); # endif -#endif -#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK -# if !GNULIB_overrides_vprintf +#elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef vprintf +# define vprintf gl_consolesafe_vprintf # endif +#endif +#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK /* Assume vprintf is always declared. */ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - " "use gnulib module vprintf-posix for portable " @@ -2049,7 +2083,6 @@ _GL_CXXALIAS_SYS (vsnprintf, int, _GL_CXXALIASWARN (vsnprintf); # endif #elif defined GNULIB_POSIXCHECK -# undef vsnprintf # if HAVE_RAW_DECL_VSNPRINTF _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " "use gnulib module vsnprintf for portability"); @@ -2102,7 +2135,6 @@ _GL_CXXALIAS_SYS_CAST (vsprintf, int, _GL_CXXALIASWARN (vsprintf); # endif #elif defined GNULIB_POSIXCHECK -# undef vsprintf /* Assume vsprintf is always declared. */ _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - " "use gnulib module vsprintf-posix for portable " |
