diff options
Diffstat (limited to 'gl/stdio.in.h')
| -rw-r--r-- | gl/stdio.in.h | 721 |
1 files changed, 588 insertions, 133 deletions
diff --git a/gl/stdio.in.h b/gl/stdio.in.h index 59cbea3d..bc454454 100644 --- a/gl/stdio.in.h +++ b/gl/stdio.in.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* A GNU-like <stdio.h>. | 1 | /* A GNU-like <stdio.h>. |
| 2 | 2 | ||
| 3 | Copyright (C) 2004, 2007-2023 Free Software Foundation, Inc. | 3 | Copyright (C) 2004, 2007-2025 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is free software: you can redistribute it and/or modify | 5 | This file is free software: you can redistribute it and/or modify |
| 6 | it under the terms of the GNU Lesser General Public License as | 6 | it under the terms of the GNU Lesser General Public License as |
| @@ -20,7 +20,7 @@ | |||
| 20 | #endif | 20 | #endif |
| 21 | @PRAGMA_COLUMNS@ | 21 | @PRAGMA_COLUMNS@ |
| 22 | 22 | ||
| 23 | #if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H | 23 | #if defined __need_FILE || defined __need___FILE || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H || defined _GL_SKIP_GNULIB_STDIO_H |
| 24 | /* Special invocation convention: | 24 | /* Special invocation convention: |
| 25 | - Inside glibc header files. | 25 | - Inside glibc header files. |
| 26 | - On OSF/1 5.1 we have a sequence of nested includes | 26 | - On OSF/1 5.1 we have a sequence of nested includes |
| @@ -36,16 +36,40 @@ | |||
| 36 | 36 | ||
| 37 | #ifndef _@GUARD_PREFIX@_STDIO_H | 37 | #ifndef _@GUARD_PREFIX@_STDIO_H |
| 38 | 38 | ||
| 39 | #define _GL_ALREADY_INCLUDING_STDIO_H | 39 | /* Suppress macOS deprecation warnings for sprintf and vsprintf. */ |
| 40 | #if (defined __APPLE__ && defined __MACH__) && !defined _POSIX_C_SOURCE | ||
| 41 | # ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ | ||
| 42 | # include <AvailabilityMacros.h> | ||
| 43 | # endif | ||
| 44 | # if (defined MAC_OS_X_VERSION_MIN_REQUIRED \ | ||
| 45 | && 130000 <= MAC_OS_X_VERSION_MIN_REQUIRED) | ||
| 46 | # define _POSIX_C_SOURCE 200809L | ||
| 47 | # define _GL_DEFINED__POSIX_C_SOURCE | ||
| 48 | # endif | ||
| 49 | #endif | ||
| 50 | |||
| 51 | #define _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H | ||
| 40 | 52 | ||
| 41 | /* The include_next requires a split double-inclusion guard. */ | 53 | /* The include_next requires a split double-inclusion guard. */ |
| 42 | #@INCLUDE_NEXT@ @NEXT_STDIO_H@ | 54 | #@INCLUDE_NEXT@ @NEXT_STDIO_H@ |
| 43 | 55 | ||
| 44 | #undef _GL_ALREADY_INCLUDING_STDIO_H | 56 | #undef _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H |
| 57 | |||
| 58 | #ifdef _GL_DEFINED__POSIX_C_SOURCE | ||
| 59 | # undef _GL_DEFINED__POSIX_C_SOURCE | ||
| 60 | # undef _POSIX_C_SOURCE | ||
| 61 | #endif | ||
| 45 | 62 | ||
| 46 | #ifndef _@GUARD_PREFIX@_STDIO_H | 63 | #ifndef _@GUARD_PREFIX@_STDIO_H |
| 47 | #define _@GUARD_PREFIX@_STDIO_H | 64 | #define _@GUARD_PREFIX@_STDIO_H |
| 48 | 65 | ||
| 66 | /* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT, | ||
| 67 | _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW, | ||
| 68 | GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ | ||
| 69 | #if !_GL_CONFIG_H_INCLUDED | ||
| 70 | #error "Please include config.h first." | ||
| 71 | #endif | ||
| 72 | |||
| 49 | /* Get va_list. Needed on many systems, including glibc 2.8. */ | 73 | /* Get va_list. Needed on many systems, including glibc 2.8. */ |
| 50 | #include <stdarg.h> | 74 | #include <stdarg.h> |
| 51 | 75 | ||
| @@ -53,7 +77,8 @@ | |||
| 53 | 77 | ||
| 54 | /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8 | 78 | /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8 |
| 55 | and eglibc 2.11.2. | 79 | and eglibc 2.11.2. |
| 56 | May also define off_t to a 64-bit type on native Windows. */ | 80 | May also define off_t to a 64-bit type on native Windows. |
| 81 | Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */ | ||
| 57 | #include <sys/types.h> | 82 | #include <sys/types.h> |
| 58 | 83 | ||
| 59 | /* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */ | 84 | /* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */ |
| @@ -95,7 +120,7 @@ | |||
| 95 | that can be freed by passing them as the Ith argument to the | 120 | that can be freed by passing them as the Ith argument to the |
| 96 | function F. */ | 121 | function F. */ |
| 97 | #ifndef _GL_ATTRIBUTE_DEALLOC | 122 | #ifndef _GL_ATTRIBUTE_DEALLOC |
| 98 | # if __GNUC__ >= 11 | 123 | # if __GNUC__ >= 11 && !defined __clang__ |
| 99 | # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) | 124 | # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) |
| 100 | # else | 125 | # else |
| 101 | # define _GL_ATTRIBUTE_DEALLOC(f, i) | 126 | # define _GL_ATTRIBUTE_DEALLOC(f, i) |
| @@ -116,12 +141,44 @@ | |||
| 116 | # endif | 141 | # endif |
| 117 | #endif | 142 | #endif |
| 118 | 143 | ||
| 144 | /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly | ||
| 145 | allocated memory. */ | ||
| 146 | #ifndef _GL_ATTRIBUTE_MALLOC | ||
| 147 | # if __GNUC__ >= 3 || defined __clang__ | ||
| 148 | # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) | ||
| 149 | # else | ||
| 150 | # define _GL_ATTRIBUTE_MALLOC | ||
| 151 | # endif | ||
| 152 | #endif | ||
| 153 | |||
| 154 | /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. | ||
| 155 | */ | ||
| 156 | #ifndef _GL_ATTRIBUTE_NOTHROW | ||
| 157 | # if defined __cplusplus | ||
| 158 | # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4 | ||
| 159 | # if __cplusplus >= 201103L | ||
| 160 | # define _GL_ATTRIBUTE_NOTHROW noexcept (true) | ||
| 161 | # else | ||
| 162 | # define _GL_ATTRIBUTE_NOTHROW throw () | ||
| 163 | # endif | ||
| 164 | # else | ||
| 165 | # define _GL_ATTRIBUTE_NOTHROW | ||
| 166 | # endif | ||
| 167 | # else | ||
| 168 | # if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__ | ||
| 169 | # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) | ||
| 170 | # else | ||
| 171 | # define _GL_ATTRIBUTE_NOTHROW | ||
| 172 | # endif | ||
| 173 | # endif | ||
| 174 | #endif | ||
| 175 | |||
| 119 | /* An __attribute__ __format__ specifier for a function that takes a format | 176 | /* An __attribute__ __format__ specifier for a function that takes a format |
| 120 | string and arguments, where the format string directives are the ones | 177 | string and arguments, where the format string directives are the ones |
| 121 | standardized by ISO C99 and POSIX. | 178 | standardized by ISO C99 and POSIX. |
| 122 | _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */ | 179 | _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */ |
| 123 | /* __gnu_printf__ is supported in GCC >= 4.4. */ | 180 | /* __gnu_printf__ is supported in GCC >= 4.4. */ |
| 124 | #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) | 181 | #if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4) && !defined __clang__ |
| 125 | # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__ | 182 | # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__ |
| 126 | #else | 183 | #else |
| 127 | # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__ | 184 | # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__ |
| @@ -193,24 +250,102 @@ | |||
| 193 | # undef putc_unlocked | 250 | # undef putc_unlocked |
| 194 | #endif | 251 | #endif |
| 195 | 252 | ||
| 253 | |||
| 254 | /* Maximum number of characters produced by printing a NaN value. */ | ||
| 255 | #ifndef _PRINTF_NAN_LEN_MAX | ||
| 256 | # if defined __FreeBSD__ || defined __DragonFly__ \ | ||
| 257 | || defined __NetBSD__ \ | ||
| 258 | || (defined __APPLE__ && defined __MACH__) | ||
| 259 | /* On BSD systems, a NaN value prints as just "nan", without a sign. */ | ||
| 260 | # define _PRINTF_NAN_LEN_MAX 3 | ||
| 261 | # elif (__GLIBC__ >= 2) || MUSL_LIBC || defined __OpenBSD__ || defined __sun || defined __CYGWIN__ | ||
| 262 | /* glibc, musl libc, OpenBSD, Solaris libc, and Cygwin produce "[-]nan". */ | ||
| 263 | # define _PRINTF_NAN_LEN_MAX 4 | ||
| 264 | # elif defined _AIX | ||
| 265 | /* AIX produces "[-]NaNQ". */ | ||
| 266 | # define _PRINTF_NAN_LEN_MAX 5 | ||
| 267 | # elif defined _WIN32 && !defined __CYGWIN__ | ||
| 268 | /* On native Windows, the output can be: | ||
| 269 | - with MSVC ucrt: "[-]nan" or "[-]nan(ind)" or "[-]nan(snan)", | ||
| 270 | - with mingw: "[-]1.#IND" or "[-]1.#QNAN". */ | ||
| 271 | # define _PRINTF_NAN_LEN_MAX 10 | ||
| 272 | # elif defined __sgi | ||
| 273 | /* On IRIX, the output typically is "[-]nan0xNNNNNNNN" with 8 hexadecimal | ||
| 274 | digits. */ | ||
| 275 | # define _PRINTF_NAN_LEN_MAX 14 | ||
| 276 | # else | ||
| 277 | /* We don't know, but 32 should be a safe maximum. */ | ||
| 278 | # define _PRINTF_NAN_LEN_MAX 32 | ||
| 279 | # endif | ||
| 280 | #endif | ||
| 281 | |||
| 282 | |||
| 283 | #if (defined _WIN32 && !defined __CYGWIN__) && !defined _UCRT | ||
| 284 | /* Workarounds against msvcrt bugs. */ | ||
| 285 | _GL_FUNCDECL_SYS (gl_consolesafe_fwrite, size_t, | ||
| 286 | (const void *ptr, size_t size, size_t nmemb, FILE *fp), | ||
| 287 | _GL_ARG_NONNULL ((1, 4))); | ||
| 288 | # if defined __MINGW32__ | ||
| 289 | _GL_FUNCDECL_SYS (gl_consolesafe_fprintf, int, | ||
| 290 | (FILE *restrict fp, const char *restrict format, ...), | ||
| 291 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | ||
| 292 | _GL_ARG_NONNULL ((1, 2))); | ||
| 293 | _GL_FUNCDECL_SYS (gl_consolesafe_printf, int, | ||
| 294 | (const char *restrict format, ...), | ||
| 295 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) | ||
| 296 | _GL_ARG_NONNULL ((1))); | ||
| 297 | _GL_FUNCDECL_SYS (gl_consolesafe_vfprintf, int, | ||
| 298 | (FILE *restrict fp, | ||
| 299 | const char *restrict format, va_list args), | ||
| 300 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | ||
| 301 | _GL_ARG_NONNULL ((1, 2))); | ||
| 302 | _GL_FUNCDECL_SYS (gl_consolesafe_vprintf, int, | ||
| 303 | (const char *restrict format, va_list args), | ||
| 304 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0) | ||
| 305 | _GL_ARG_NONNULL ((1))); | ||
| 306 | # endif | ||
| 307 | #endif | ||
| 308 | |||
| 309 | |||
| 310 | #if @GNULIB_DZPRINTF@ | ||
| 311 | /* Prints formatted output to file descriptor FD. | ||
| 312 | Returns the number of bytes written to the file descriptor. Upon | ||
| 313 | failure, returns -1 with errno set. | ||
| 314 | Failure code EOVERFLOW can only occur when a width > INT_MAX is used. | ||
| 315 | Therefore, if the format string is valid and does not use %ls/%lc | ||
| 316 | directives nor widths, the only possible failure codes are ENOMEM | ||
| 317 | and the possible failure codes from write(), excluding EINTR. */ | ||
| 318 | _GL_FUNCDECL_SYS (dzprintf, off64_t, | ||
| 319 | (int fd, const char *restrict format, ...), | ||
| 320 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | ||
| 321 | _GL_ARG_NONNULL ((2))); | ||
| 322 | _GL_CXXALIAS_SYS (dzprintf, off64_t, | ||
| 323 | (int fd, const char *restrict format, ...)); | ||
| 324 | #endif | ||
| 325 | |||
| 196 | #if @GNULIB_DPRINTF@ | 326 | #if @GNULIB_DPRINTF@ |
| 327 | /* Prints formatted output to file descriptor FD. | ||
| 328 | Returns the number of bytes written to the file descriptor. Upon | ||
| 329 | failure, returns a negative value. */ | ||
| 197 | # if @REPLACE_DPRINTF@ | 330 | # if @REPLACE_DPRINTF@ |
| 198 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 331 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 199 | # define dprintf rpl_dprintf | 332 | # define dprintf rpl_dprintf |
| 200 | # endif | 333 | # endif |
| 201 | _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...) | 334 | _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...), |
| 202 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 335 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 203 | _GL_ARG_NONNULL ((2))); | 336 | _GL_ARG_NONNULL ((2))); |
| 204 | _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...)); | 337 | _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...)); |
| 205 | # else | 338 | # else |
| 206 | # if !@HAVE_DPRINTF@ | 339 | # if !@HAVE_DPRINTF@ |
| 207 | _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...) | 340 | _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...), |
| 208 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 341 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 209 | _GL_ARG_NONNULL ((2))); | 342 | _GL_ARG_NONNULL ((2))); |
| 210 | # endif | 343 | # endif |
| 211 | _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...)); | 344 | _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...)); |
| 212 | # endif | 345 | # endif |
| 346 | # if __GLIBC__ >= 2 | ||
| 213 | _GL_CXXALIASWARN (dprintf); | 347 | _GL_CXXALIASWARN (dprintf); |
| 348 | # endif | ||
| 214 | #elif defined GNULIB_POSIXCHECK | 349 | #elif defined GNULIB_POSIXCHECK |
| 215 | # undef dprintf | 350 | # undef dprintf |
| 216 | # if HAVE_RAW_DECL_DPRINTF | 351 | # if HAVE_RAW_DECL_DPRINTF |
| @@ -225,7 +360,7 @@ _GL_WARN_ON_USE (dprintf, "dprintf is unportable - " | |||
| 225 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 360 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 226 | # define fclose rpl_fclose | 361 | # define fclose rpl_fclose |
| 227 | # endif | 362 | # endif |
| 228 | _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); | 363 | _GL_FUNCDECL_RPL (fclose, int, (FILE *stream), _GL_ARG_NONNULL ((1))); |
| 229 | _GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); | 364 | _GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); |
| 230 | # else | 365 | # else |
| 231 | _GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); | 366 | _GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); |
| @@ -272,8 +407,10 @@ _GL_CXXALIASWARN (fcloseall); | |||
| 272 | # define fdopen rpl_fdopen | 407 | # define fdopen rpl_fdopen |
| 273 | # endif | 408 | # endif |
| 274 | _GL_FUNCDECL_RPL (fdopen, FILE *, | 409 | _GL_FUNCDECL_RPL (fdopen, FILE *, |
| 275 | (int fd, const char *mode) | 410 | (int fd, const char *mode), |
| 276 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); | 411 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 412 | _GL_ATTRIBUTE_MALLOC | ||
| 413 | _GL_ATTRIBUTE_NODISCARD); | ||
| 277 | _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); | 414 | _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); |
| 278 | # elif defined _WIN32 && !defined __CYGWIN__ | 415 | # elif defined _WIN32 && !defined __CYGWIN__ |
| 279 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 416 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| @@ -282,21 +419,41 @@ _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); | |||
| 282 | # endif | 419 | # endif |
| 283 | _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode)); | 420 | _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode)); |
| 284 | # else | 421 | # else |
| 285 | # if __GNUC__ >= 11 | 422 | # if __GNUC__ >= 11 && !defined __clang__ |
| 286 | /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ | 423 | /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ |
| 424 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 | ||
| 287 | _GL_FUNCDECL_SYS (fdopen, FILE *, | 425 | _GL_FUNCDECL_SYS (fdopen, FILE *, |
| 288 | (int fd, const char *mode) | 426 | (int fd, const char *mode), |
| 289 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); | 427 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 428 | _GL_ATTRIBUTE_MALLOC | ||
| 429 | _GL_ATTRIBUTE_NODISCARD) | ||
| 430 | _GL_ATTRIBUTE_NOTHROW; | ||
| 431 | # else | ||
| 432 | _GL_FUNCDECL_SYS (fdopen, FILE *, | ||
| 433 | (int fd, const char *mode), | ||
| 434 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) | ||
| 435 | _GL_ATTRIBUTE_MALLOC | ||
| 436 | _GL_ATTRIBUTE_NODISCARD); | ||
| 437 | # endif | ||
| 290 | # endif | 438 | # endif |
| 291 | _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); | 439 | _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); |
| 292 | # endif | 440 | # endif |
| 293 | _GL_CXXALIASWARN (fdopen); | 441 | _GL_CXXALIASWARN (fdopen); |
| 294 | #else | 442 | #else |
| 295 | # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen | 443 | # if @GNULIB_FCLOSE@ && (__GNUC__ >= 11 && !defined __clang__) && !defined fdopen |
| 296 | /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ | 444 | /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ |
| 445 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 | ||
| 446 | _GL_FUNCDECL_SYS (fdopen, FILE *, | ||
| 447 | (int fd, const char *mode), | ||
| 448 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) | ||
| 449 | _GL_ATTRIBUTE_MALLOC) | ||
| 450 | _GL_ATTRIBUTE_NOTHROW; | ||
| 451 | # else | ||
| 297 | _GL_FUNCDECL_SYS (fdopen, FILE *, | 452 | _GL_FUNCDECL_SYS (fdopen, FILE *, |
| 298 | (int fd, const char *mode) | 453 | (int fd, const char *mode), |
| 299 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); | 454 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 455 | _GL_ATTRIBUTE_MALLOC); | ||
| 456 | # endif | ||
| 300 | # endif | 457 | # endif |
| 301 | # if defined GNULIB_POSIXCHECK | 458 | # if defined GNULIB_POSIXCHECK |
| 302 | # undef fdopen | 459 | # undef fdopen |
| @@ -331,7 +488,7 @@ _GL_CXXALIASWARN (fdopen); | |||
| 331 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 488 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 332 | # define fflush rpl_fflush | 489 | # define fflush rpl_fflush |
| 333 | # endif | 490 | # endif |
| 334 | _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream)); | 491 | _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream), ); |
| 335 | _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream)); | 492 | _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream)); |
| 336 | # else | 493 | # else |
| 337 | _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); | 494 | _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); |
| @@ -352,7 +509,7 @@ _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " | |||
| 352 | # undef fgetc | 509 | # undef fgetc |
| 353 | # define fgetc rpl_fgetc | 510 | # define fgetc rpl_fgetc |
| 354 | # endif | 511 | # endif |
| 355 | _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); | 512 | _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream), _GL_ARG_NONNULL ((1))); |
| 356 | _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream)); | 513 | _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream)); |
| 357 | # else | 514 | # else |
| 358 | _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream)); | 515 | _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream)); |
| @@ -369,8 +526,8 @@ _GL_CXXALIASWARN (fgetc); | |||
| 369 | # define fgets rpl_fgets | 526 | # define fgets rpl_fgets |
| 370 | # endif | 527 | # endif |
| 371 | _GL_FUNCDECL_RPL (fgets, char *, | 528 | _GL_FUNCDECL_RPL (fgets, char *, |
| 372 | (char *restrict s, int n, FILE *restrict stream) | 529 | (char *restrict s, int n, FILE *restrict stream), |
| 373 | _GL_ARG_NONNULL ((1, 3))); | 530 | _GL_ARG_NONNULL ((1, 3)) _GL_ATTRIBUTE_NODISCARD); |
| 374 | _GL_CXXALIAS_RPL (fgets, char *, | 531 | _GL_CXXALIAS_RPL (fgets, char *, |
| 375 | (char *restrict s, int n, FILE *restrict stream)); | 532 | (char *restrict s, int n, FILE *restrict stream)); |
| 376 | # else | 533 | # else |
| @@ -406,16 +563,18 @@ _GL_CXXALIASWARN (fileno); | |||
| 406 | # define fopen rpl_fopen | 563 | # define fopen rpl_fopen |
| 407 | # endif | 564 | # endif |
| 408 | _GL_FUNCDECL_RPL (fopen, FILE *, | 565 | _GL_FUNCDECL_RPL (fopen, FILE *, |
| 409 | (const char *restrict filename, const char *restrict mode) | 566 | (const char *restrict filename, const char *restrict mode), |
| 410 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); | 567 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 568 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD); | ||
| 411 | _GL_CXXALIAS_RPL (fopen, FILE *, | 569 | _GL_CXXALIAS_RPL (fopen, FILE *, |
| 412 | (const char *restrict filename, const char *restrict mode)); | 570 | (const char *restrict filename, const char *restrict mode)); |
| 413 | # else | 571 | # else |
| 414 | # if __GNUC__ >= 11 | 572 | # if __GNUC__ >= 11 && !defined __clang__ |
| 415 | /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ | 573 | /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ |
| 416 | _GL_FUNCDECL_SYS (fopen, FILE *, | 574 | _GL_FUNCDECL_SYS (fopen, FILE *, |
| 417 | (const char *restrict filename, const char *restrict mode) | 575 | (const char *restrict filename, const char *restrict mode), |
| 418 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); | 576 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 577 | _GL_ATTRIBUTE_NODISCARD); | ||
| 419 | # endif | 578 | # endif |
| 420 | _GL_CXXALIAS_SYS (fopen, FILE *, | 579 | _GL_CXXALIAS_SYS (fopen, FILE *, |
| 421 | (const char *restrict filename, const char *restrict mode)); | 580 | (const char *restrict filename, const char *restrict mode)); |
| @@ -424,10 +583,10 @@ _GL_CXXALIAS_SYS (fopen, FILE *, | |||
| 424 | _GL_CXXALIASWARN (fopen); | 583 | _GL_CXXALIASWARN (fopen); |
| 425 | # endif | 584 | # endif |
| 426 | #else | 585 | #else |
| 427 | # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fopen | 586 | # if @GNULIB_FCLOSE@ && (__GNUC__ >= 11 && !defined __clang__) && !defined fopen |
| 428 | /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ | 587 | /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ |
| 429 | _GL_FUNCDECL_SYS (fopen, FILE *, | 588 | _GL_FUNCDECL_SYS (fopen, FILE *, |
| 430 | (const char *restrict filename, const char *restrict mode) | 589 | (const char *restrict filename, const char *restrict mode), |
| 431 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); | 590 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); |
| 432 | # endif | 591 | # endif |
| 433 | # if defined GNULIB_POSIXCHECK | 592 | # if defined GNULIB_POSIXCHECK |
| @@ -438,7 +597,26 @@ _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX complian | |||
| 438 | # endif | 597 | # endif |
| 439 | #endif | 598 | #endif |
| 440 | 599 | ||
| 600 | #if @GNULIB_FZPRINTF@ | ||
| 601 | /* Prints formatted output to stream FP. | ||
| 602 | Returns the number of bytes written to the stream. Upon failure, | ||
| 603 | returns -1 with the stream's error indicator set. | ||
| 604 | Failure cause EOVERFLOW can only occur when a width > INT_MAX is used. | ||
| 605 | Therefore, if the format string is valid and does not use %ls/%lc | ||
| 606 | directives nor widths, the only possible failure causes are ENOMEM | ||
| 607 | and the possible failure causes from fwrite(). */ | ||
| 608 | _GL_FUNCDECL_SYS (fzprintf, off64_t, | ||
| 609 | (FILE *restrict fp, const char *restrict format, ...), | ||
| 610 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | ||
| 611 | _GL_ARG_NONNULL ((1, 2))); | ||
| 612 | _GL_CXXALIAS_SYS (fzprintf, off64_t, | ||
| 613 | (FILE *restrict fp, const char *restrict format, ...)); | ||
| 614 | #endif | ||
| 615 | |||
| 441 | #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@ | 616 | #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@ |
| 617 | /* Prints formatted output to stream FP. | ||
| 618 | Returns the number of bytes written to the stream. Upon failure, | ||
| 619 | returns a negative value with the stream's error indicator set. */ | ||
| 442 | # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \ | 620 | # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \ |
| 443 | || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) | 621 | || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) |
| 444 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 622 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| @@ -447,12 +625,12 @@ _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX complian | |||
| 447 | # define GNULIB_overrides_fprintf 1 | 625 | # define GNULIB_overrides_fprintf 1 |
| 448 | # if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ | 626 | # if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ |
| 449 | _GL_FUNCDECL_RPL (fprintf, int, | 627 | _GL_FUNCDECL_RPL (fprintf, int, |
| 450 | (FILE *restrict fp, const char *restrict format, ...) | 628 | (FILE *restrict fp, const char *restrict format, ...), |
| 451 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 629 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 452 | _GL_ARG_NONNULL ((1, 2))); | 630 | _GL_ARG_NONNULL ((1, 2))); |
| 453 | # else | 631 | # else |
| 454 | _GL_FUNCDECL_RPL (fprintf, int, | 632 | _GL_FUNCDECL_RPL (fprintf, int, |
| 455 | (FILE *restrict fp, const char *restrict format, ...) | 633 | (FILE *restrict fp, const char *restrict format, ...), |
| 456 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3) | 634 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3) |
| 457 | _GL_ARG_NONNULL ((1, 2))); | 635 | _GL_ARG_NONNULL ((1, 2))); |
| 458 | # endif | 636 | # endif |
| @@ -465,6 +643,11 @@ _GL_CXXALIAS_SYS (fprintf, int, | |||
| 465 | # if __GLIBC__ >= 2 | 643 | # if __GLIBC__ >= 2 |
| 466 | _GL_CXXALIASWARN (fprintf); | 644 | _GL_CXXALIASWARN (fprintf); |
| 467 | # endif | 645 | # endif |
| 646 | #elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO | ||
| 647 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 648 | # undef fprintf | ||
| 649 | # define fprintf gl_consolesafe_fprintf | ||
| 650 | # endif | ||
| 468 | #endif | 651 | #endif |
| 469 | #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK | 652 | #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK |
| 470 | # if !GNULIB_overrides_fprintf | 653 | # if !GNULIB_overrides_fprintf |
| @@ -487,15 +670,17 @@ _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - " | |||
| 487 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 670 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 488 | # define fpurge rpl_fpurge | 671 | # define fpurge rpl_fpurge |
| 489 | # endif | 672 | # endif |
| 490 | _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); | 673 | _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream), _GL_ARG_NONNULL ((1))); |
| 491 | _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream)); | 674 | _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream)); |
| 492 | # else | 675 | # else |
| 493 | # if !@HAVE_DECL_FPURGE@ | 676 | # if !@HAVE_DECL_FPURGE@ |
| 494 | _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); | 677 | _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream), _GL_ARG_NONNULL ((1))); |
| 495 | # endif | 678 | # endif |
| 496 | _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); | 679 | _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); |
| 497 | # endif | 680 | # endif |
| 681 | # if __GLIBC__ >= 2 | ||
| 498 | _GL_CXXALIASWARN (fpurge); | 682 | _GL_CXXALIASWARN (fpurge); |
| 683 | # endif | ||
| 499 | #elif defined GNULIB_POSIXCHECK | 684 | #elif defined GNULIB_POSIXCHECK |
| 500 | # undef fpurge | 685 | # undef fpurge |
| 501 | # if HAVE_RAW_DECL_FPURGE | 686 | # if HAVE_RAW_DECL_FPURGE |
| @@ -510,7 +695,7 @@ _GL_WARN_ON_USE (fpurge, "fpurge is not always present - " | |||
| 510 | # undef fputc | 695 | # undef fputc |
| 511 | # define fputc rpl_fputc | 696 | # define fputc rpl_fputc |
| 512 | # endif | 697 | # endif |
| 513 | _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); | 698 | _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream), _GL_ARG_NONNULL ((2))); |
| 514 | _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); | 699 | _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); |
| 515 | # else | 700 | # else |
| 516 | _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); | 701 | _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); |
| @@ -527,7 +712,7 @@ _GL_CXXALIASWARN (fputc); | |||
| 527 | # define fputs rpl_fputs | 712 | # define fputs rpl_fputs |
| 528 | # endif | 713 | # endif |
| 529 | _GL_FUNCDECL_RPL (fputs, int, | 714 | _GL_FUNCDECL_RPL (fputs, int, |
| 530 | (const char *restrict string, FILE *restrict stream) | 715 | (const char *restrict string, FILE *restrict stream), |
| 531 | _GL_ARG_NONNULL ((1, 2))); | 716 | _GL_ARG_NONNULL ((1, 2))); |
| 532 | _GL_CXXALIAS_RPL (fputs, int, | 717 | _GL_CXXALIAS_RPL (fputs, int, |
| 533 | (const char *restrict string, FILE *restrict stream)); | 718 | (const char *restrict string, FILE *restrict stream)); |
| @@ -548,8 +733,8 @@ _GL_CXXALIASWARN (fputs); | |||
| 548 | # endif | 733 | # endif |
| 549 | _GL_FUNCDECL_RPL (fread, size_t, | 734 | _GL_FUNCDECL_RPL (fread, size_t, |
| 550 | (void *restrict ptr, size_t s, size_t n, | 735 | (void *restrict ptr, size_t s, size_t n, |
| 551 | FILE *restrict stream) | 736 | FILE *restrict stream), |
| 552 | _GL_ARG_NONNULL ((4))); | 737 | _GL_ARG_NONNULL ((4)) _GL_ATTRIBUTE_NODISCARD); |
| 553 | _GL_CXXALIAS_RPL (fread, size_t, | 738 | _GL_CXXALIAS_RPL (fread, size_t, |
| 554 | (void *restrict ptr, size_t s, size_t n, | 739 | (void *restrict ptr, size_t s, size_t n, |
| 555 | FILE *restrict stream)); | 740 | FILE *restrict stream)); |
| @@ -571,8 +756,8 @@ _GL_CXXALIASWARN (fread); | |||
| 571 | # endif | 756 | # endif |
| 572 | _GL_FUNCDECL_RPL (freopen, FILE *, | 757 | _GL_FUNCDECL_RPL (freopen, FILE *, |
| 573 | (const char *restrict filename, const char *restrict mode, | 758 | (const char *restrict filename, const char *restrict mode, |
| 574 | FILE *restrict stream) | 759 | FILE *restrict stream), |
| 575 | _GL_ARG_NONNULL ((2, 3))); | 760 | _GL_ARG_NONNULL ((2, 3)) _GL_ATTRIBUTE_NODISCARD); |
| 576 | _GL_CXXALIAS_RPL (freopen, FILE *, | 761 | _GL_CXXALIAS_RPL (freopen, FILE *, |
| 577 | (const char *restrict filename, const char *restrict mode, | 762 | (const char *restrict filename, const char *restrict mode, |
| 578 | FILE *restrict stream)); | 763 | FILE *restrict stream)); |
| @@ -599,9 +784,9 @@ _GL_WARN_ON_USE (freopen, | |||
| 599 | # define fscanf rpl_fscanf | 784 | # define fscanf rpl_fscanf |
| 600 | # endif | 785 | # endif |
| 601 | _GL_FUNCDECL_RPL (fscanf, int, | 786 | _GL_FUNCDECL_RPL (fscanf, int, |
| 602 | (FILE *restrict stream, const char *restrict format, ...) | 787 | (FILE *restrict stream, const char *restrict format, ...), |
| 603 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3) | 788 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3) |
| 604 | _GL_ARG_NONNULL ((1, 2))); | 789 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD); |
| 605 | _GL_CXXALIAS_RPL (fscanf, int, | 790 | _GL_CXXALIAS_RPL (fscanf, int, |
| 606 | (FILE *restrict stream, const char *restrict format, ...)); | 791 | (FILE *restrict stream, const char *restrict format, ...)); |
| 607 | # else | 792 | # else |
| @@ -655,7 +840,7 @@ _GL_CXXALIASWARN (fscanf); | |||
| 655 | # undef fseek | 840 | # undef fseek |
| 656 | # define fseek rpl_fseek | 841 | # define fseek rpl_fseek |
| 657 | # endif | 842 | # endif |
| 658 | _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence) | 843 | _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence), |
| 659 | _GL_ARG_NONNULL ((1))); | 844 | _GL_ARG_NONNULL ((1))); |
| 660 | _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); | 845 | _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); |
| 661 | # else | 846 | # else |
| @@ -678,12 +863,12 @@ _GL_CXXALIASWARN (fseek); | |||
| 678 | # undef fseeko | 863 | # undef fseeko |
| 679 | # define fseeko rpl_fseeko | 864 | # define fseeko rpl_fseeko |
| 680 | # endif | 865 | # endif |
| 681 | _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence) | 866 | _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence), |
| 682 | _GL_ARG_NONNULL ((1))); | 867 | _GL_ARG_NONNULL ((1))); |
| 683 | _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); | 868 | _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); |
| 684 | # else | 869 | # else |
| 685 | # if ! @HAVE_DECL_FSEEKO@ | 870 | # if ! @HAVE_DECL_FSEEKO@ |
| 686 | _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence) | 871 | _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence), |
| 687 | _GL_ARG_NONNULL ((1))); | 872 | _GL_ARG_NONNULL ((1))); |
| 688 | # endif | 873 | # endif |
| 689 | _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); | 874 | _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); |
| @@ -721,7 +906,8 @@ _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB " | |||
| 721 | # undef ftell | 906 | # undef ftell |
| 722 | # define ftell rpl_ftell | 907 | # define ftell rpl_ftell |
| 723 | # endif | 908 | # endif |
| 724 | _GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1))); | 909 | _GL_FUNCDECL_RPL (ftell, long, (FILE *fp), |
| 910 | _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); | ||
| 725 | _GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); | 911 | _GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); |
| 726 | # else | 912 | # else |
| 727 | _GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); | 913 | _GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); |
| @@ -741,11 +927,13 @@ _GL_CXXALIASWARN (ftell); | |||
| 741 | # undef ftello | 927 | # undef ftello |
| 742 | # define ftello rpl_ftello | 928 | # define ftello rpl_ftello |
| 743 | # endif | 929 | # endif |
| 744 | _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); | 930 | _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp), |
| 931 | _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); | ||
| 745 | _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); | 932 | _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); |
| 746 | # else | 933 | # else |
| 747 | # if ! @HAVE_DECL_FTELLO@ | 934 | # if ! @HAVE_DECL_FTELLO@ |
| 748 | _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); | 935 | _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp), |
| 936 | _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); | ||
| 749 | # endif | 937 | # endif |
| 750 | _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); | 938 | _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); |
| 751 | # endif | 939 | # endif |
| @@ -778,7 +966,7 @@ _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB " | |||
| 778 | # endif | 966 | # endif |
| 779 | _GL_FUNCDECL_RPL (fwrite, size_t, | 967 | _GL_FUNCDECL_RPL (fwrite, size_t, |
| 780 | (const void *restrict ptr, size_t s, size_t n, | 968 | (const void *restrict ptr, size_t s, size_t n, |
| 781 | FILE *restrict stream) | 969 | FILE *restrict stream), |
| 782 | _GL_ARG_NONNULL ((1, 4))); | 970 | _GL_ARG_NONNULL ((1, 4))); |
| 783 | _GL_CXXALIAS_RPL (fwrite, size_t, | 971 | _GL_CXXALIAS_RPL (fwrite, size_t, |
| 784 | (const void *restrict ptr, size_t s, size_t n, | 972 | (const void *restrict ptr, size_t s, size_t n, |
| @@ -793,20 +981,20 @@ _GL_CXXALIAS_SYS (fwrite, size_t, | |||
| 793 | which sometimes causes an unwanted diagnostic for fwrite calls. | 981 | which sometimes causes an unwanted diagnostic for fwrite calls. |
| 794 | This affects only function declaration attributes under certain | 982 | This affects only function declaration attributes under certain |
| 795 | versions of gcc and clang, and is not needed for C++. */ | 983 | versions of gcc and clang, and is not needed for C++. */ |
| 796 | # if (0 < __USE_FORTIFY_LEVEL \ | 984 | # if (0 < __USE_FORTIFY_LEVEL \ |
| 797 | && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \ | 985 | && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \ |
| 798 | && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \ | 986 | && (3 < __GNUC__ + (4 <= __GNUC_MINOR__) || defined __clang__) \ |
| 799 | && !defined __cplusplus) | 987 | && !defined __cplusplus) |
| 800 | # undef fwrite | 988 | # undef fwrite |
| 801 | # undef fwrite_unlocked | 989 | # undef fwrite_unlocked |
| 802 | extern size_t __REDIRECT (rpl_fwrite, | 990 | _GL_EXTERN_C size_t __REDIRECT (rpl_fwrite, |
| 803 | (const void *__restrict, size_t, size_t, | 991 | (const void *__restrict, size_t, size_t, |
| 804 | FILE *__restrict), | 992 | FILE *__restrict), |
| 805 | fwrite); | 993 | fwrite); |
| 806 | extern size_t __REDIRECT (rpl_fwrite_unlocked, | 994 | _GL_EXTERN_C size_t __REDIRECT (rpl_fwrite_unlocked, |
| 807 | (const void *__restrict, size_t, size_t, | 995 | (const void *__restrict, size_t, size_t, |
| 808 | FILE *__restrict), | 996 | FILE *__restrict), |
| 809 | fwrite_unlocked); | 997 | fwrite_unlocked); |
| 810 | # define fwrite rpl_fwrite | 998 | # define fwrite rpl_fwrite |
| 811 | # define fwrite_unlocked rpl_fwrite_unlocked | 999 | # define fwrite_unlocked rpl_fwrite_unlocked |
| 812 | # endif | 1000 | # endif |
| @@ -814,6 +1002,11 @@ extern size_t __REDIRECT (rpl_fwrite_unlocked, | |||
| 814 | # if __GLIBC__ >= 2 | 1002 | # if __GLIBC__ >= 2 |
| 815 | _GL_CXXALIASWARN (fwrite); | 1003 | _GL_CXXALIASWARN (fwrite); |
| 816 | # endif | 1004 | # endif |
| 1005 | #elif (defined _WIN32 && !defined __CYGWIN__) && !defined _UCRT | ||
| 1006 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1007 | # undef fwrite | ||
| 1008 | # define fwrite gl_consolesafe_fwrite | ||
| 1009 | # endif | ||
| 817 | #endif | 1010 | #endif |
| 818 | 1011 | ||
| 819 | #if @GNULIB_GETC@ | 1012 | #if @GNULIB_GETC@ |
| @@ -822,7 +1015,7 @@ _GL_CXXALIASWARN (fwrite); | |||
| 822 | # undef getc | 1015 | # undef getc |
| 823 | # define getc rpl_fgetc | 1016 | # define getc rpl_fgetc |
| 824 | # endif | 1017 | # endif |
| 825 | _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); | 1018 | _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream), _GL_ARG_NONNULL ((1))); |
| 826 | _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream)); | 1019 | _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream)); |
| 827 | # else | 1020 | # else |
| 828 | _GL_CXXALIAS_SYS (getc, int, (FILE *stream)); | 1021 | _GL_CXXALIAS_SYS (getc, int, (FILE *stream)); |
| @@ -838,7 +1031,7 @@ _GL_CXXALIASWARN (getc); | |||
| 838 | # undef getchar | 1031 | # undef getchar |
| 839 | # define getchar rpl_getchar | 1032 | # define getchar rpl_getchar |
| 840 | # endif | 1033 | # endif |
| 841 | _GL_FUNCDECL_RPL (getchar, int, (void)); | 1034 | _GL_FUNCDECL_RPL (getchar, int, (void), ); |
| 842 | _GL_CXXALIAS_RPL (getchar, int, (void)); | 1035 | _GL_CXXALIAS_RPL (getchar, int, (void)); |
| 843 | # else | 1036 | # else |
| 844 | _GL_CXXALIAS_SYS (getchar, int, (void)); | 1037 | _GL_CXXALIAS_SYS (getchar, int, (void)); |
| @@ -863,8 +1056,8 @@ _GL_CXXALIASWARN (getchar); | |||
| 863 | _GL_FUNCDECL_RPL (getdelim, ssize_t, | 1056 | _GL_FUNCDECL_RPL (getdelim, ssize_t, |
| 864 | (char **restrict lineptr, size_t *restrict linesize, | 1057 | (char **restrict lineptr, size_t *restrict linesize, |
| 865 | int delimiter, | 1058 | int delimiter, |
| 866 | FILE *restrict stream) | 1059 | FILE *restrict stream), |
| 867 | _GL_ARG_NONNULL ((1, 2, 4))); | 1060 | _GL_ARG_NONNULL ((1, 2, 4)) _GL_ATTRIBUTE_NODISCARD); |
| 868 | _GL_CXXALIAS_RPL (getdelim, ssize_t, | 1061 | _GL_CXXALIAS_RPL (getdelim, ssize_t, |
| 869 | (char **restrict lineptr, size_t *restrict linesize, | 1062 | (char **restrict lineptr, size_t *restrict linesize, |
| 870 | int delimiter, | 1063 | int delimiter, |
| @@ -874,15 +1067,17 @@ _GL_CXXALIAS_RPL (getdelim, ssize_t, | |||
| 874 | _GL_FUNCDECL_SYS (getdelim, ssize_t, | 1067 | _GL_FUNCDECL_SYS (getdelim, ssize_t, |
| 875 | (char **restrict lineptr, size_t *restrict linesize, | 1068 | (char **restrict lineptr, size_t *restrict linesize, |
| 876 | int delimiter, | 1069 | int delimiter, |
| 877 | FILE *restrict stream) | 1070 | FILE *restrict stream), |
| 878 | _GL_ARG_NONNULL ((1, 2, 4))); | 1071 | _GL_ARG_NONNULL ((1, 2, 4)) _GL_ATTRIBUTE_NODISCARD); |
| 879 | # endif | 1072 | # endif |
| 880 | _GL_CXXALIAS_SYS (getdelim, ssize_t, | 1073 | _GL_CXXALIAS_SYS (getdelim, ssize_t, |
| 881 | (char **restrict lineptr, size_t *restrict linesize, | 1074 | (char **restrict lineptr, size_t *restrict linesize, |
| 882 | int delimiter, | 1075 | int delimiter, |
| 883 | FILE *restrict stream)); | 1076 | FILE *restrict stream)); |
| 884 | # endif | 1077 | # endif |
| 1078 | # if __GLIBC__ >= 2 | ||
| 885 | _GL_CXXALIASWARN (getdelim); | 1079 | _GL_CXXALIASWARN (getdelim); |
| 1080 | # endif | ||
| 886 | #elif defined GNULIB_POSIXCHECK | 1081 | #elif defined GNULIB_POSIXCHECK |
| 887 | # undef getdelim | 1082 | # undef getdelim |
| 888 | # if HAVE_RAW_DECL_GETDELIM | 1083 | # if HAVE_RAW_DECL_GETDELIM |
| @@ -905,8 +1100,8 @@ _GL_WARN_ON_USE (getdelim, "getdelim is unportable - " | |||
| 905 | # endif | 1100 | # endif |
| 906 | _GL_FUNCDECL_RPL (getline, ssize_t, | 1101 | _GL_FUNCDECL_RPL (getline, ssize_t, |
| 907 | (char **restrict lineptr, size_t *restrict linesize, | 1102 | (char **restrict lineptr, size_t *restrict linesize, |
| 908 | FILE *restrict stream) | 1103 | FILE *restrict stream), |
| 909 | _GL_ARG_NONNULL ((1, 2, 3))); | 1104 | _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD); |
| 910 | _GL_CXXALIAS_RPL (getline, ssize_t, | 1105 | _GL_CXXALIAS_RPL (getline, ssize_t, |
| 911 | (char **restrict lineptr, size_t *restrict linesize, | 1106 | (char **restrict lineptr, size_t *restrict linesize, |
| 912 | FILE *restrict stream)); | 1107 | FILE *restrict stream)); |
| @@ -914,14 +1109,14 @@ _GL_CXXALIAS_RPL (getline, ssize_t, | |||
| 914 | # if !@HAVE_DECL_GETLINE@ | 1109 | # if !@HAVE_DECL_GETLINE@ |
| 915 | _GL_FUNCDECL_SYS (getline, ssize_t, | 1110 | _GL_FUNCDECL_SYS (getline, ssize_t, |
| 916 | (char **restrict lineptr, size_t *restrict linesize, | 1111 | (char **restrict lineptr, size_t *restrict linesize, |
| 917 | FILE *restrict stream) | 1112 | FILE *restrict stream), |
| 918 | _GL_ARG_NONNULL ((1, 2, 3))); | 1113 | _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD); |
| 919 | # endif | 1114 | # endif |
| 920 | _GL_CXXALIAS_SYS (getline, ssize_t, | 1115 | _GL_CXXALIAS_SYS (getline, ssize_t, |
| 921 | (char **restrict lineptr, size_t *restrict linesize, | 1116 | (char **restrict lineptr, size_t *restrict linesize, |
| 922 | FILE *restrict stream)); | 1117 | FILE *restrict stream)); |
| 923 | # endif | 1118 | # endif |
| 924 | # if @HAVE_DECL_GETLINE@ | 1119 | # if __GLIBC__ >= 2 && @HAVE_DECL_GETLINE@ |
| 925 | _GL_CXXALIASWARN (getline); | 1120 | _GL_CXXALIASWARN (getline); |
| 926 | # endif | 1121 | # endif |
| 927 | #elif defined GNULIB_POSIXCHECK | 1122 | #elif defined GNULIB_POSIXCHECK |
| @@ -951,24 +1146,58 @@ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); | |||
| 951 | # endif | 1146 | # endif |
| 952 | _GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream)); | 1147 | _GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream)); |
| 953 | # else | 1148 | # else |
| 1149 | # if @HAVE_DECL_GETW@ | ||
| 1150 | # if defined __APPLE__ && defined __MACH__ | ||
| 1151 | /* The presence of the declaration depends on _POSIX_C_SOURCE. */ | ||
| 1152 | _GL_FUNCDECL_SYS (getw, int, (FILE *restrict stream), ); | ||
| 1153 | # endif | ||
| 954 | _GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream)); | 1154 | _GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream)); |
| 1155 | # endif | ||
| 955 | # endif | 1156 | # endif |
| 1157 | # if __GLIBC__ >= 2 | ||
| 956 | _GL_CXXALIASWARN (getw); | 1158 | _GL_CXXALIASWARN (getw); |
| 1159 | # endif | ||
| 1160 | #endif | ||
| 1161 | |||
| 1162 | #if @GNULIB_OBSTACK_ZPRINTF@ | ||
| 1163 | struct obstack; | ||
| 1164 | /* Grows an obstack with formatted output. Returns the number of | ||
| 1165 | bytes added to OBS. No trailing nul byte is added, and the | ||
| 1166 | object should be closed with obstack_finish before use. | ||
| 1167 | Upon memory allocation error, calls obstack_alloc_failed_handler. | ||
| 1168 | Upon other error, returns -1 with errno set. | ||
| 1169 | |||
| 1170 | Failure code EOVERFLOW can only occur when a width > INT_MAX is used. | ||
| 1171 | Therefore, if the format string is valid and does not use %ls/%lc | ||
| 1172 | directives nor widths, the only possible failure code is through | ||
| 1173 | obstack_alloc_failed_handler. */ | ||
| 1174 | _GL_FUNCDECL_SYS (obstack_zprintf, ptrdiff_t, | ||
| 1175 | (struct obstack *obs, const char *format, ...), | ||
| 1176 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | ||
| 1177 | _GL_ARG_NONNULL ((1, 2))); | ||
| 1178 | _GL_CXXALIAS_SYS (obstack_zprintf, ptrdiff_t, | ||
| 1179 | (struct obstack *obs, const char *format, ...)); | ||
| 1180 | _GL_FUNCDECL_SYS (obstack_vzprintf, ptrdiff_t, | ||
| 1181 | (struct obstack *obs, const char *format, va_list args), | ||
| 1182 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | ||
| 1183 | _GL_ARG_NONNULL ((1, 2))); | ||
| 1184 | _GL_CXXALIAS_SYS (obstack_vzprintf, ptrdiff_t, | ||
| 1185 | (struct obstack *obs, const char *format, va_list args)); | ||
| 957 | #endif | 1186 | #endif |
| 958 | 1187 | ||
| 959 | #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ | 1188 | #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ |
| 960 | struct obstack; | 1189 | struct obstack; |
| 961 | /* Grow an obstack with formatted output. Return the number of | 1190 | /* Grows an obstack with formatted output. Returns the number of |
| 962 | bytes added to OBS. No trailing nul byte is added, and the | 1191 | bytes added to OBS. No trailing nul byte is added, and the |
| 963 | object should be closed with obstack_finish before use. Upon | 1192 | object should be closed with obstack_finish before use. |
| 964 | memory allocation error, call obstack_alloc_failed_handler. Upon | 1193 | Upon memory allocation error, calls obstack_alloc_failed_handler. |
| 965 | other error, return -1. */ | 1194 | Upon other error, returns -1. */ |
| 966 | # if @REPLACE_OBSTACK_PRINTF@ | 1195 | # if @REPLACE_OBSTACK_PRINTF@ |
| 967 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1196 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 968 | # define obstack_printf rpl_obstack_printf | 1197 | # define obstack_printf rpl_obstack_printf |
| 969 | # endif | 1198 | # endif |
| 970 | _GL_FUNCDECL_RPL (obstack_printf, int, | 1199 | _GL_FUNCDECL_RPL (obstack_printf, int, |
| 971 | (struct obstack *obs, const char *format, ...) | 1200 | (struct obstack *obs, const char *format, ...), |
| 972 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 1201 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 973 | _GL_ARG_NONNULL ((1, 2))); | 1202 | _GL_ARG_NONNULL ((1, 2))); |
| 974 | _GL_CXXALIAS_RPL (obstack_printf, int, | 1203 | _GL_CXXALIAS_RPL (obstack_printf, int, |
| @@ -976,7 +1205,7 @@ _GL_CXXALIAS_RPL (obstack_printf, int, | |||
| 976 | # else | 1205 | # else |
| 977 | # if !@HAVE_DECL_OBSTACK_PRINTF@ | 1206 | # if !@HAVE_DECL_OBSTACK_PRINTF@ |
| 978 | _GL_FUNCDECL_SYS (obstack_printf, int, | 1207 | _GL_FUNCDECL_SYS (obstack_printf, int, |
| 979 | (struct obstack *obs, const char *format, ...) | 1208 | (struct obstack *obs, const char *format, ...), |
| 980 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 1209 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 981 | _GL_ARG_NONNULL ((1, 2))); | 1210 | _GL_ARG_NONNULL ((1, 2))); |
| 982 | # endif | 1211 | # endif |
| @@ -989,7 +1218,7 @@ _GL_CXXALIASWARN (obstack_printf); | |||
| 989 | # define obstack_vprintf rpl_obstack_vprintf | 1218 | # define obstack_vprintf rpl_obstack_vprintf |
| 990 | # endif | 1219 | # endif |
| 991 | _GL_FUNCDECL_RPL (obstack_vprintf, int, | 1220 | _GL_FUNCDECL_RPL (obstack_vprintf, int, |
| 992 | (struct obstack *obs, const char *format, va_list args) | 1221 | (struct obstack *obs, const char *format, va_list args), |
| 993 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 1222 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 994 | _GL_ARG_NONNULL ((1, 2))); | 1223 | _GL_ARG_NONNULL ((1, 2))); |
| 995 | _GL_CXXALIAS_RPL (obstack_vprintf, int, | 1224 | _GL_CXXALIAS_RPL (obstack_vprintf, int, |
| @@ -997,7 +1226,7 @@ _GL_CXXALIAS_RPL (obstack_vprintf, int, | |||
| 997 | # else | 1226 | # else |
| 998 | # if !@HAVE_DECL_OBSTACK_PRINTF@ | 1227 | # if !@HAVE_DECL_OBSTACK_PRINTF@ |
| 999 | _GL_FUNCDECL_SYS (obstack_vprintf, int, | 1228 | _GL_FUNCDECL_SYS (obstack_vprintf, int, |
| 1000 | (struct obstack *obs, const char *format, va_list args) | 1229 | (struct obstack *obs, const char *format, va_list args), |
| 1001 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 1230 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1002 | _GL_ARG_NONNULL ((1, 2))); | 1231 | _GL_ARG_NONNULL ((1, 2))); |
| 1003 | # endif | 1232 | # endif |
| @@ -1009,7 +1238,7 @@ _GL_CXXALIASWARN (obstack_vprintf); | |||
| 1009 | 1238 | ||
| 1010 | #if @GNULIB_PCLOSE@ | 1239 | #if @GNULIB_PCLOSE@ |
| 1011 | # if !@HAVE_PCLOSE@ | 1240 | # if !@HAVE_PCLOSE@ |
| 1012 | _GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); | 1241 | _GL_FUNCDECL_SYS (pclose, int, (FILE *stream), _GL_ARG_NONNULL ((1))); |
| 1013 | # endif | 1242 | # endif |
| 1014 | _GL_CXXALIAS_SYS (pclose, int, (FILE *stream)); | 1243 | _GL_CXXALIAS_SYS (pclose, int, (FILE *stream)); |
| 1015 | _GL_CXXALIASWARN (pclose); | 1244 | _GL_CXXALIASWARN (pclose); |
| @@ -1029,7 +1258,7 @@ _GL_WARN_ON_USE (pclose, "pclose is unportable - " | |||
| 1029 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1258 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1030 | # define perror rpl_perror | 1259 | # define perror rpl_perror |
| 1031 | # endif | 1260 | # endif |
| 1032 | _GL_FUNCDECL_RPL (perror, void, (const char *string)); | 1261 | _GL_FUNCDECL_RPL (perror, void, (const char *string), ); |
| 1033 | _GL_CXXALIAS_RPL (perror, void, (const char *string)); | 1262 | _GL_CXXALIAS_RPL (perror, void, (const char *string)); |
| 1034 | # else | 1263 | # else |
| 1035 | _GL_CXXALIAS_SYS (perror, void, (const char *string)); | 1264 | _GL_CXXALIAS_SYS (perror, void, (const char *string)); |
| @@ -1051,24 +1280,28 @@ _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " | |||
| 1051 | # define popen rpl_popen | 1280 | # define popen rpl_popen |
| 1052 | # endif | 1281 | # endif |
| 1053 | _GL_FUNCDECL_RPL (popen, FILE *, | 1282 | _GL_FUNCDECL_RPL (popen, FILE *, |
| 1054 | (const char *cmd, const char *mode) | 1283 | (const char *cmd, const char *mode), |
| 1055 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); | 1284 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) |
| 1285 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD); | ||
| 1056 | _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); | 1286 | _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); |
| 1057 | # else | 1287 | # else |
| 1058 | # if !@HAVE_POPEN@ || __GNUC__ >= 11 | 1288 | # if !@HAVE_POPEN@ || (__GNUC__ >= 11 && !defined __clang__) |
| 1059 | _GL_FUNCDECL_SYS (popen, FILE *, | 1289 | _GL_FUNCDECL_SYS (popen, FILE *, |
| 1060 | (const char *cmd, const char *mode) | 1290 | (const char *cmd, const char *mode), |
| 1061 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); | 1291 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) |
| 1292 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD); | ||
| 1062 | # endif | 1293 | # endif |
| 1063 | _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); | 1294 | _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); |
| 1064 | # endif | 1295 | # endif |
| 1065 | _GL_CXXALIASWARN (popen); | 1296 | _GL_CXXALIASWARN (popen); |
| 1066 | #else | 1297 | #else |
| 1067 | # if @GNULIB_PCLOSE@ && __GNUC__ >= 11 && !defined popen | 1298 | # if @GNULIB_PCLOSE@ \ |
| 1299 | && (__GNUC__ >= 11 && !defined __clang__) && !defined popen | ||
| 1068 | /* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */ | 1300 | /* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */ |
| 1069 | _GL_FUNCDECL_SYS (popen, FILE *, | 1301 | _GL_FUNCDECL_SYS (popen, FILE *, |
| 1070 | (const char *cmd, const char *mode) | 1302 | (const char *cmd, const char *mode), |
| 1071 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); | 1303 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) |
| 1304 | _GL_ATTRIBUTE_MALLOC); | ||
| 1072 | # endif | 1305 | # endif |
| 1073 | # if defined GNULIB_POSIXCHECK | 1306 | # if defined GNULIB_POSIXCHECK |
| 1074 | # undef popen | 1307 | # undef popen |
| @@ -1079,7 +1312,24 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " | |||
| 1079 | # endif | 1312 | # endif |
| 1080 | #endif | 1313 | #endif |
| 1081 | 1314 | ||
| 1315 | #if @GNULIB_ZPRINTF@ | ||
| 1316 | /* Prints formatted output to standard output. | ||
| 1317 | Returns the number of bytes written to standard output. Upon failure, | ||
| 1318 | returns -1 with stdout's error indicator set. | ||
| 1319 | Failure cause EOVERFLOW can only occur when a width > INT_MAX is used. | ||
| 1320 | Therefore, if the format string is valid and does not use %ls/%lc | ||
| 1321 | directives nor widths, the only possible failure causes are ENOMEM | ||
| 1322 | and the possible failure causes from fwrite(). */ | ||
| 1323 | _GL_FUNCDECL_SYS (zprintf, off64_t, (const char *restrict format, ...), | ||
| 1324 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) | ||
| 1325 | _GL_ARG_NONNULL ((1))); | ||
| 1326 | _GL_CXXALIAS_SYS (zprintf, off64_t, (const char *restrict format, ...)); | ||
| 1327 | #endif | ||
| 1328 | |||
| 1082 | #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ | 1329 | #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ |
| 1330 | /* Prints formatted output to standard output. | ||
| 1331 | Returns the number of bytes written to standard output. Upon failure, | ||
| 1332 | returns a negative value with stdout's error indicator set. */ | ||
| 1083 | # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ | 1333 | # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ |
| 1084 | || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) | 1334 | || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) |
| 1085 | # if defined __GNUC__ || defined __clang__ | 1335 | # if defined __GNUC__ || defined __clang__ |
| @@ -1091,14 +1341,14 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " | |||
| 1091 | _GL_FUNCDECL_RPL_1 (__printf__, int, | 1341 | _GL_FUNCDECL_RPL_1 (__printf__, int, |
| 1092 | (const char *restrict format, ...) | 1342 | (const char *restrict format, ...) |
| 1093 | __asm__ (@ASM_SYMBOL_PREFIX@ | 1343 | __asm__ (@ASM_SYMBOL_PREFIX@ |
| 1094 | _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) | 1344 | _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)), |
| 1095 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) | 1345 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) |
| 1096 | _GL_ARG_NONNULL ((1))); | 1346 | _GL_ARG_NONNULL ((1))); |
| 1097 | # else | 1347 | # else |
| 1098 | _GL_FUNCDECL_RPL_1 (__printf__, int, | 1348 | _GL_FUNCDECL_RPL_1 (__printf__, int, |
| 1099 | (const char *restrict format, ...) | 1349 | (const char *restrict format, ...) |
| 1100 | __asm__ (@ASM_SYMBOL_PREFIX@ | 1350 | __asm__ (@ASM_SYMBOL_PREFIX@ |
| 1101 | _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) | 1351 | _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)), |
| 1102 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2) | 1352 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2) |
| 1103 | _GL_ARG_NONNULL ((1))); | 1353 | _GL_ARG_NONNULL ((1))); |
| 1104 | # endif | 1354 | # endif |
| @@ -1108,7 +1358,7 @@ _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); | |||
| 1108 | # define printf rpl_printf | 1358 | # define printf rpl_printf |
| 1109 | # endif | 1359 | # endif |
| 1110 | _GL_FUNCDECL_RPL (printf, int, | 1360 | _GL_FUNCDECL_RPL (printf, int, |
| 1111 | (const char *restrict format, ...) | 1361 | (const char *restrict format, ...), |
| 1112 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) | 1362 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) |
| 1113 | _GL_ARG_NONNULL ((1))); | 1363 | _GL_ARG_NONNULL ((1))); |
| 1114 | _GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...)); | 1364 | _GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...)); |
| @@ -1120,6 +1370,11 @@ _GL_CXXALIAS_SYS (printf, int, (const char *restrict format, ...)); | |||
| 1120 | # if __GLIBC__ >= 2 | 1370 | # if __GLIBC__ >= 2 |
| 1121 | _GL_CXXALIASWARN (printf); | 1371 | _GL_CXXALIASWARN (printf); |
| 1122 | # endif | 1372 | # endif |
| 1373 | #elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO | ||
| 1374 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1375 | # undef printf | ||
| 1376 | # define printf gl_consolesafe_printf | ||
| 1377 | # endif | ||
| 1123 | #endif | 1378 | #endif |
| 1124 | #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK | 1379 | #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK |
| 1125 | # if !GNULIB_overrides_printf | 1380 | # if !GNULIB_overrides_printf |
| @@ -1137,7 +1392,7 @@ _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - " | |||
| 1137 | # undef putc | 1392 | # undef putc |
| 1138 | # define putc rpl_fputc | 1393 | # define putc rpl_fputc |
| 1139 | # endif | 1394 | # endif |
| 1140 | _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); | 1395 | _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream), _GL_ARG_NONNULL ((2))); |
| 1141 | _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream)); | 1396 | _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream)); |
| 1142 | # else | 1397 | # else |
| 1143 | _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); | 1398 | _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); |
| @@ -1153,7 +1408,7 @@ _GL_CXXALIASWARN (putc); | |||
| 1153 | # undef putchar | 1408 | # undef putchar |
| 1154 | # define putchar rpl_putchar | 1409 | # define putchar rpl_putchar |
| 1155 | # endif | 1410 | # endif |
| 1156 | _GL_FUNCDECL_RPL (putchar, int, (int c)); | 1411 | _GL_FUNCDECL_RPL (putchar, int, (int c), ); |
| 1157 | _GL_CXXALIAS_RPL (putchar, int, (int c)); | 1412 | _GL_CXXALIAS_RPL (putchar, int, (int c)); |
| 1158 | # else | 1413 | # else |
| 1159 | _GL_CXXALIAS_SYS (putchar, int, (int c)); | 1414 | _GL_CXXALIAS_SYS (putchar, int, (int c)); |
| @@ -1169,7 +1424,7 @@ _GL_CXXALIASWARN (putchar); | |||
| 1169 | # undef puts | 1424 | # undef puts |
| 1170 | # define puts rpl_puts | 1425 | # define puts rpl_puts |
| 1171 | # endif | 1426 | # endif |
| 1172 | _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1))); | 1427 | _GL_FUNCDECL_RPL (puts, int, (const char *string), _GL_ARG_NONNULL ((1))); |
| 1173 | _GL_CXXALIAS_RPL (puts, int, (const char *string)); | 1428 | _GL_CXXALIAS_RPL (puts, int, (const char *string)); |
| 1174 | # else | 1429 | # else |
| 1175 | _GL_CXXALIAS_SYS (puts, int, (const char *string)); | 1430 | _GL_CXXALIAS_SYS (puts, int, (const char *string)); |
| @@ -1190,9 +1445,17 @@ _GL_CXXALIASWARN (puts); | |||
| 1190 | # endif | 1445 | # endif |
| 1191 | _GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream)); | 1446 | _GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream)); |
| 1192 | # else | 1447 | # else |
| 1448 | # if @HAVE_DECL_PUTW@ | ||
| 1449 | # if defined __APPLE__ && defined __MACH__ | ||
| 1450 | /* The presence of the declaration depends on _POSIX_C_SOURCE. */ | ||
| 1451 | _GL_FUNCDECL_SYS (putw, int, (int w, FILE *restrict stream), ); | ||
| 1452 | # endif | ||
| 1193 | _GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream)); | 1453 | _GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream)); |
| 1454 | # endif | ||
| 1194 | # endif | 1455 | # endif |
| 1456 | # if __GLIBC__ >= 2 | ||
| 1195 | _GL_CXXALIASWARN (putw); | 1457 | _GL_CXXALIASWARN (putw); |
| 1458 | # endif | ||
| 1196 | #endif | 1459 | #endif |
| 1197 | 1460 | ||
| 1198 | #if @GNULIB_REMOVE@ | 1461 | #if @GNULIB_REMOVE@ |
| @@ -1201,7 +1464,7 @@ _GL_CXXALIASWARN (putw); | |||
| 1201 | # undef remove | 1464 | # undef remove |
| 1202 | # define remove rpl_remove | 1465 | # define remove rpl_remove |
| 1203 | # endif | 1466 | # endif |
| 1204 | _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1))); | 1467 | _GL_FUNCDECL_RPL (remove, int, (const char *name), _GL_ARG_NONNULL ((1))); |
| 1205 | _GL_CXXALIAS_RPL (remove, int, (const char *name)); | 1468 | _GL_CXXALIAS_RPL (remove, int, (const char *name)); |
| 1206 | # else | 1469 | # else |
| 1207 | _GL_CXXALIAS_SYS (remove, int, (const char *name)); | 1470 | _GL_CXXALIAS_SYS (remove, int, (const char *name)); |
| @@ -1223,7 +1486,7 @@ _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - " | |||
| 1223 | # define rename rpl_rename | 1486 | # define rename rpl_rename |
| 1224 | # endif | 1487 | # endif |
| 1225 | _GL_FUNCDECL_RPL (rename, int, | 1488 | _GL_FUNCDECL_RPL (rename, int, |
| 1226 | (const char *old_filename, const char *new_filename) | 1489 | (const char *old_filename, const char *new_filename), |
| 1227 | _GL_ARG_NONNULL ((1, 2))); | 1490 | _GL_ARG_NONNULL ((1, 2))); |
| 1228 | _GL_CXXALIAS_RPL (rename, int, | 1491 | _GL_CXXALIAS_RPL (rename, int, |
| 1229 | (const char *old_filename, const char *new_filename)); | 1492 | (const char *old_filename, const char *new_filename)); |
| @@ -1248,14 +1511,14 @@ _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - " | |||
| 1248 | # define renameat rpl_renameat | 1511 | # define renameat rpl_renameat |
| 1249 | # endif | 1512 | # endif |
| 1250 | _GL_FUNCDECL_RPL (renameat, int, | 1513 | _GL_FUNCDECL_RPL (renameat, int, |
| 1251 | (int fd1, char const *file1, int fd2, char const *file2) | 1514 | (int fd1, char const *file1, int fd2, char const *file2), |
| 1252 | _GL_ARG_NONNULL ((2, 4))); | 1515 | _GL_ARG_NONNULL ((2, 4))); |
| 1253 | _GL_CXXALIAS_RPL (renameat, int, | 1516 | _GL_CXXALIAS_RPL (renameat, int, |
| 1254 | (int fd1, char const *file1, int fd2, char const *file2)); | 1517 | (int fd1, char const *file1, int fd2, char const *file2)); |
| 1255 | # else | 1518 | # else |
| 1256 | # if !@HAVE_RENAMEAT@ | 1519 | # if !@HAVE_RENAMEAT@ |
| 1257 | _GL_FUNCDECL_SYS (renameat, int, | 1520 | _GL_FUNCDECL_SYS (renameat, int, |
| 1258 | (int fd1, char const *file1, int fd2, char const *file2) | 1521 | (int fd1, char const *file1, int fd2, char const *file2), |
| 1259 | _GL_ARG_NONNULL ((2, 4))); | 1522 | _GL_ARG_NONNULL ((2, 4))); |
| 1260 | # endif | 1523 | # endif |
| 1261 | _GL_CXXALIAS_SYS (renameat, int, | 1524 | _GL_CXXALIAS_SYS (renameat, int, |
| @@ -1281,18 +1544,18 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - " | |||
| 1281 | _GL_FUNCDECL_RPL_1 (__scanf__, int, | 1544 | _GL_FUNCDECL_RPL_1 (__scanf__, int, |
| 1282 | (const char *restrict format, ...) | 1545 | (const char *restrict format, ...) |
| 1283 | __asm__ (@ASM_SYMBOL_PREFIX@ | 1546 | __asm__ (@ASM_SYMBOL_PREFIX@ |
| 1284 | _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)) | 1547 | _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)), |
| 1285 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) | 1548 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) |
| 1286 | _GL_ARG_NONNULL ((1))); | 1549 | _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); |
| 1287 | _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...)); | 1550 | _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...)); |
| 1288 | # else | 1551 | # else |
| 1289 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1552 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1290 | # undef scanf | 1553 | # undef scanf |
| 1291 | # define scanf rpl_scanf | 1554 | # define scanf rpl_scanf |
| 1292 | # endif | 1555 | # endif |
| 1293 | _GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...) | 1556 | _GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...), |
| 1294 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) | 1557 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) |
| 1295 | _GL_ARG_NONNULL ((1))); | 1558 | _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); |
| 1296 | _GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...)); | 1559 | _GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...)); |
| 1297 | # endif | 1560 | # endif |
| 1298 | # else | 1561 | # else |
| @@ -1303,7 +1566,31 @@ _GL_CXXALIASWARN (scanf); | |||
| 1303 | # endif | 1566 | # endif |
| 1304 | #endif | 1567 | #endif |
| 1305 | 1568 | ||
| 1569 | #if @GNULIB_SNZPRINTF@ | ||
| 1570 | /* Prints formatted output to string STR. Similar to sprintf, but the | ||
| 1571 | additional parameter SIZE limits how much is written into STR. | ||
| 1572 | STR may be NULL, in which case nothing will be written. | ||
| 1573 | Returns the string length of the formatted string (which may be larger | ||
| 1574 | than SIZE). Upon failure, returns -1 with errno set. | ||
| 1575 | Failure code EOVERFLOW can only occur when a width > INT_MAX is used. | ||
| 1576 | Therefore, if the format string is valid and does not use %ls/%lc | ||
| 1577 | directives nor widths, the only possible failure code is ENOMEM. */ | ||
| 1578 | _GL_FUNCDECL_SYS (snzprintf, ptrdiff_t, | ||
| 1579 | (char *restrict str, size_t size, | ||
| 1580 | const char *restrict format, ...), | ||
| 1581 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) | ||
| 1582 | _GL_ARG_NONNULL ((3))); | ||
| 1583 | _GL_CXXALIAS_SYS (snzprintf, ptrdiff_t, | ||
| 1584 | (char *restrict str, size_t size, | ||
| 1585 | const char *restrict format, ...)); | ||
| 1586 | #endif | ||
| 1587 | |||
| 1306 | #if @GNULIB_SNPRINTF@ | 1588 | #if @GNULIB_SNPRINTF@ |
| 1589 | /* Prints formatted output to string STR. Similar to sprintf, but the | ||
| 1590 | additional parameter SIZE limits how much is written into STR. | ||
| 1591 | STR may be NULL, in which case nothing will be written. | ||
| 1592 | Returns the string length of the formatted string (which may be larger | ||
| 1593 | than SIZE). Upon failure, returns a negative value. */ | ||
| 1307 | # if @REPLACE_SNPRINTF@ | 1594 | # if @REPLACE_SNPRINTF@ |
| 1308 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1595 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1309 | # define snprintf rpl_snprintf | 1596 | # define snprintf rpl_snprintf |
| @@ -1311,7 +1598,7 @@ _GL_CXXALIASWARN (scanf); | |||
| 1311 | # define GNULIB_overrides_snprintf 1 | 1598 | # define GNULIB_overrides_snprintf 1 |
| 1312 | _GL_FUNCDECL_RPL (snprintf, int, | 1599 | _GL_FUNCDECL_RPL (snprintf, int, |
| 1313 | (char *restrict str, size_t size, | 1600 | (char *restrict str, size_t size, |
| 1314 | const char *restrict format, ...) | 1601 | const char *restrict format, ...), |
| 1315 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) | 1602 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) |
| 1316 | _GL_ARG_NONNULL ((3))); | 1603 | _GL_ARG_NONNULL ((3))); |
| 1317 | _GL_CXXALIAS_RPL (snprintf, int, | 1604 | _GL_CXXALIAS_RPL (snprintf, int, |
| @@ -1321,7 +1608,7 @@ _GL_CXXALIAS_RPL (snprintf, int, | |||
| 1321 | # if !@HAVE_DECL_SNPRINTF@ | 1608 | # if !@HAVE_DECL_SNPRINTF@ |
| 1322 | _GL_FUNCDECL_SYS (snprintf, int, | 1609 | _GL_FUNCDECL_SYS (snprintf, int, |
| 1323 | (char *restrict str, size_t size, | 1610 | (char *restrict str, size_t size, |
| 1324 | const char *restrict format, ...) | 1611 | const char *restrict format, ...), |
| 1325 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) | 1612 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) |
| 1326 | _GL_ARG_NONNULL ((3))); | 1613 | _GL_ARG_NONNULL ((3))); |
| 1327 | # endif | 1614 | # endif |
| @@ -1340,6 +1627,23 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - " | |||
| 1340 | # endif | 1627 | # endif |
| 1341 | #endif | 1628 | #endif |
| 1342 | 1629 | ||
| 1630 | #if @GNULIB_SZPRINTF@ | ||
| 1631 | /* Prints formatted output to string STR. | ||
| 1632 | Returns the string length of the formatted string. Upon failure, | ||
| 1633 | returns -1 with errno set. | ||
| 1634 | Failure code EOVERFLOW can only occur when a width > INT_MAX is used. | ||
| 1635 | Therefore, if the format string is valid and does not use %ls/%lc | ||
| 1636 | directives nor widths, the only possible failure code is ENOMEM. */ | ||
| 1637 | _GL_FUNCDECL_SYS (szprintf, ptrdiff_t, | ||
| 1638 | (char *restrict str, | ||
| 1639 | const char *restrict format, ...), | ||
| 1640 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | ||
| 1641 | _GL_ARG_NONNULL ((1, 2))); | ||
| 1642 | _GL_CXXALIAS_SYS (szprintf, ptrdiff_t, | ||
| 1643 | (char *restrict str, | ||
| 1644 | const char *restrict format, ...)); | ||
| 1645 | #endif | ||
| 1646 | |||
| 1343 | /* Some people would argue that all sprintf uses should be warned about | 1647 | /* Some people would argue that all sprintf uses should be warned about |
| 1344 | (for example, OpenBSD issues a link warning for it), | 1648 | (for example, OpenBSD issues a link warning for it), |
| 1345 | since it can cause security holes due to buffer overruns. | 1649 | since it can cause security holes due to buffer overruns. |
| @@ -1350,13 +1654,16 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - " | |||
| 1350 | GNULIB_POSIXCHECK is defined. */ | 1654 | GNULIB_POSIXCHECK is defined. */ |
| 1351 | 1655 | ||
| 1352 | #if @GNULIB_SPRINTF_POSIX@ | 1656 | #if @GNULIB_SPRINTF_POSIX@ |
| 1657 | /* Prints formatted output to string STR. | ||
| 1658 | Returns the string length of the formatted string. Upon failure, | ||
| 1659 | returns a negative value. */ | ||
| 1353 | # if @REPLACE_SPRINTF@ | 1660 | # if @REPLACE_SPRINTF@ |
| 1354 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1661 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1355 | # define sprintf rpl_sprintf | 1662 | # define sprintf rpl_sprintf |
| 1356 | # endif | 1663 | # endif |
| 1357 | # define GNULIB_overrides_sprintf 1 | 1664 | # define GNULIB_overrides_sprintf 1 |
| 1358 | _GL_FUNCDECL_RPL (sprintf, int, | 1665 | _GL_FUNCDECL_RPL (sprintf, int, |
| 1359 | (char *restrict str, const char *restrict format, ...) | 1666 | (char *restrict str, const char *restrict format, ...), |
| 1360 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 1667 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 1361 | _GL_ARG_NONNULL ((1, 2))); | 1668 | _GL_ARG_NONNULL ((1, 2))); |
| 1362 | _GL_CXXALIAS_RPL (sprintf, int, | 1669 | _GL_CXXALIAS_RPL (sprintf, int, |
| @@ -1397,14 +1704,18 @@ _GL_CXXALIASWARN (tempnam); | |||
| 1397 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1704 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1398 | # define tmpfile rpl_tmpfile | 1705 | # define tmpfile rpl_tmpfile |
| 1399 | # endif | 1706 | # endif |
| 1400 | _GL_FUNCDECL_RPL (tmpfile, FILE *, (void) | 1707 | _GL_FUNCDECL_RPL (tmpfile, FILE *, (void), |
| 1401 | _GL_ATTRIBUTE_DEALLOC (fclose, 1)); | 1708 | _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 1709 | _GL_ATTRIBUTE_MALLOC | ||
| 1710 | _GL_ATTRIBUTE_NODISCARD); | ||
| 1402 | _GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); | 1711 | _GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); |
| 1403 | # else | 1712 | # else |
| 1404 | # if __GNUC__ >= 11 | 1713 | # if __GNUC__ >= 11 && !defined __clang__ |
| 1405 | /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ | 1714 | /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ |
| 1406 | _GL_FUNCDECL_SYS (tmpfile, FILE *, (void) | 1715 | _GL_FUNCDECL_SYS (tmpfile, FILE *, (void), |
| 1407 | _GL_ATTRIBUTE_DEALLOC (fclose, 1)); | 1716 | _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 1717 | _GL_ATTRIBUTE_MALLOC | ||
| 1718 | _GL_ATTRIBUTE_NODISCARD); | ||
| 1408 | # endif | 1719 | # endif |
| 1409 | _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); | 1720 | _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); |
| 1410 | # endif | 1721 | # endif |
| @@ -1412,10 +1723,12 @@ _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); | |||
| 1412 | _GL_CXXALIASWARN (tmpfile); | 1723 | _GL_CXXALIASWARN (tmpfile); |
| 1413 | # endif | 1724 | # endif |
| 1414 | #else | 1725 | #else |
| 1415 | # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile | 1726 | # if @GNULIB_FCLOSE@ \ |
| 1727 | && (__GNUC__ >= 11 && !defined __clang__) && !defined tmpfile | ||
| 1416 | /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ | 1728 | /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ |
| 1417 | _GL_FUNCDECL_SYS (tmpfile, FILE *, (void) | 1729 | _GL_FUNCDECL_SYS (tmpfile, FILE *, (void), |
| 1418 | _GL_ATTRIBUTE_DEALLOC (fclose, 1)); | 1730 | _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 1731 | _GL_ATTRIBUTE_MALLOC); | ||
| 1419 | # endif | 1732 | # endif |
| 1420 | # if defined GNULIB_POSIXCHECK | 1733 | # if defined GNULIB_POSIXCHECK |
| 1421 | # undef tmpfile | 1734 | # undef tmpfile |
| @@ -1426,6 +1739,31 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " | |||
| 1426 | # endif | 1739 | # endif |
| 1427 | #endif | 1740 | #endif |
| 1428 | 1741 | ||
| 1742 | #if @GNULIB_VASZPRINTF@ | ||
| 1743 | /* Prints formatted output to a string dynamically allocated with malloc(). | ||
| 1744 | If the memory allocation succeeds, it stores the address of the string in | ||
| 1745 | *RESULT and returns the number of resulting bytes, excluding the trailing | ||
| 1746 | NUL. Upon memory allocation error, or some other error, it returns -1 | ||
| 1747 | with errno set. | ||
| 1748 | Failure code EOVERFLOW can only occur when a width > INT_MAX is used. | ||
| 1749 | Therefore, if the format string is valid and does not use %ls/%lc | ||
| 1750 | directives nor widths, the only possible failure code is ENOMEM. */ | ||
| 1751 | _GL_FUNCDECL_SYS (aszprintf, ptrdiff_t, | ||
| 1752 | (char **result, const char *format, ...), | ||
| 1753 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | ||
| 1754 | _GL_ARG_NONNULL ((1, 2)) | ||
| 1755 | _GL_ATTRIBUTE_NODISCARD); | ||
| 1756 | _GL_CXXALIAS_SYS (aszprintf, ptrdiff_t, | ||
| 1757 | (char **result, const char *format, ...)); | ||
| 1758 | _GL_FUNCDECL_SYS (vaszprintf, ptrdiff_t, | ||
| 1759 | (char **result, const char *format, va_list args), | ||
| 1760 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | ||
| 1761 | _GL_ARG_NONNULL ((1, 2)) | ||
| 1762 | _GL_ATTRIBUTE_NODISCARD); | ||
| 1763 | _GL_CXXALIAS_SYS (vaszprintf, ptrdiff_t, | ||
| 1764 | (char **result, const char *format, va_list args)); | ||
| 1765 | #endif | ||
| 1766 | |||
| 1429 | #if @GNULIB_VASPRINTF@ | 1767 | #if @GNULIB_VASPRINTF@ |
| 1430 | /* Write formatted output to a string dynamically allocated with malloc(). | 1768 | /* Write formatted output to a string dynamically allocated with malloc(). |
| 1431 | If the memory allocation succeeds, store the address of the string in | 1769 | If the memory allocation succeeds, store the address of the string in |
| @@ -1437,17 +1775,19 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " | |||
| 1437 | # endif | 1775 | # endif |
| 1438 | # define GNULIB_overrides_asprintf | 1776 | # define GNULIB_overrides_asprintf |
| 1439 | _GL_FUNCDECL_RPL (asprintf, int, | 1777 | _GL_FUNCDECL_RPL (asprintf, int, |
| 1440 | (char **result, const char *format, ...) | 1778 | (char **result, const char *format, ...), |
| 1441 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 1779 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 1442 | _GL_ARG_NONNULL ((1, 2))); | 1780 | _GL_ARG_NONNULL ((1, 2)) |
| 1781 | _GL_ATTRIBUTE_NODISCARD); | ||
| 1443 | _GL_CXXALIAS_RPL (asprintf, int, | 1782 | _GL_CXXALIAS_RPL (asprintf, int, |
| 1444 | (char **result, const char *format, ...)); | 1783 | (char **result, const char *format, ...)); |
| 1445 | # else | 1784 | # else |
| 1446 | # if !@HAVE_VASPRINTF@ | 1785 | # if !@HAVE_VASPRINTF@ |
| 1447 | _GL_FUNCDECL_SYS (asprintf, int, | 1786 | _GL_FUNCDECL_SYS (asprintf, int, |
| 1448 | (char **result, const char *format, ...) | 1787 | (char **result, const char *format, ...), |
| 1449 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 1788 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 1450 | _GL_ARG_NONNULL ((1, 2))); | 1789 | _GL_ARG_NONNULL ((1, 2)) |
| 1790 | _GL_ATTRIBUTE_NODISCARD); | ||
| 1451 | # endif | 1791 | # endif |
| 1452 | _GL_CXXALIAS_SYS (asprintf, int, | 1792 | _GL_CXXALIAS_SYS (asprintf, int, |
| 1453 | (char **result, const char *format, ...)); | 1793 | (char **result, const char *format, ...)); |
| @@ -1459,17 +1799,19 @@ _GL_CXXALIASWARN (asprintf); | |||
| 1459 | # endif | 1799 | # endif |
| 1460 | # define GNULIB_overrides_vasprintf 1 | 1800 | # define GNULIB_overrides_vasprintf 1 |
| 1461 | _GL_FUNCDECL_RPL (vasprintf, int, | 1801 | _GL_FUNCDECL_RPL (vasprintf, int, |
| 1462 | (char **result, const char *format, va_list args) | 1802 | (char **result, const char *format, va_list args), |
| 1463 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 1803 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1464 | _GL_ARG_NONNULL ((1, 2))); | 1804 | _GL_ARG_NONNULL ((1, 2)) |
| 1805 | _GL_ATTRIBUTE_NODISCARD); | ||
| 1465 | _GL_CXXALIAS_RPL (vasprintf, int, | 1806 | _GL_CXXALIAS_RPL (vasprintf, int, |
| 1466 | (char **result, const char *format, va_list args)); | 1807 | (char **result, const char *format, va_list args)); |
| 1467 | # else | 1808 | # else |
| 1468 | # if !@HAVE_VASPRINTF@ | 1809 | # if !@HAVE_VASPRINTF@ |
| 1469 | _GL_FUNCDECL_SYS (vasprintf, int, | 1810 | _GL_FUNCDECL_SYS (vasprintf, int, |
| 1470 | (char **result, const char *format, va_list args) | 1811 | (char **result, const char *format, va_list args), |
| 1471 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 1812 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1472 | _GL_ARG_NONNULL ((1, 2))); | 1813 | _GL_ARG_NONNULL ((1, 2)) |
| 1814 | _GL_ATTRIBUTE_NODISCARD); | ||
| 1473 | # endif | 1815 | # endif |
| 1474 | _GL_CXXALIAS_SYS (vasprintf, int, | 1816 | _GL_CXXALIAS_SYS (vasprintf, int, |
| 1475 | (char **result, const char *format, va_list args)); | 1817 | (char **result, const char *format, va_list args)); |
| @@ -1477,13 +1819,32 @@ _GL_CXXALIAS_SYS (vasprintf, int, | |||
| 1477 | _GL_CXXALIASWARN (vasprintf); | 1819 | _GL_CXXALIASWARN (vasprintf); |
| 1478 | #endif | 1820 | #endif |
| 1479 | 1821 | ||
| 1822 | #if @GNULIB_VDZPRINTF@ | ||
| 1823 | /* Prints formatted output to file descriptor FD. | ||
| 1824 | Returns the number of bytes written to the file descriptor. Upon | ||
| 1825 | failure, returns -1 with errno set. | ||
| 1826 | Failure code EOVERFLOW can only occur when a width > INT_MAX is used. | ||
| 1827 | Therefore, if the format string is valid and does not use %ls/%lc | ||
| 1828 | directives nor widths, the only possible failure codes are ENOMEM | ||
| 1829 | and the possible failure codes from write(), excluding EINTR. */ | ||
| 1830 | _GL_FUNCDECL_SYS (vdzprintf, off64_t, | ||
| 1831 | (int fd, const char *restrict format, va_list args), | ||
| 1832 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | ||
| 1833 | _GL_ARG_NONNULL ((2))); | ||
| 1834 | _GL_CXXALIAS_SYS (vdzprintf, off64_t, | ||
| 1835 | (int fd, const char *restrict format, va_list args)); | ||
| 1836 | #endif | ||
| 1837 | |||
| 1480 | #if @GNULIB_VDPRINTF@ | 1838 | #if @GNULIB_VDPRINTF@ |
| 1839 | /* Prints formatted output to file descriptor FD. | ||
| 1840 | Returns the number of bytes written to the file descriptor. Upon | ||
| 1841 | failure, returns a negative value. */ | ||
| 1481 | # if @REPLACE_VDPRINTF@ | 1842 | # if @REPLACE_VDPRINTF@ |
| 1482 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1843 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1483 | # define vdprintf rpl_vdprintf | 1844 | # define vdprintf rpl_vdprintf |
| 1484 | # endif | 1845 | # endif |
| 1485 | _GL_FUNCDECL_RPL (vdprintf, int, | 1846 | _GL_FUNCDECL_RPL (vdprintf, int, |
| 1486 | (int fd, const char *restrict format, va_list args) | 1847 | (int fd, const char *restrict format, va_list args), |
| 1487 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 1848 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1488 | _GL_ARG_NONNULL ((2))); | 1849 | _GL_ARG_NONNULL ((2))); |
| 1489 | _GL_CXXALIAS_RPL (vdprintf, int, | 1850 | _GL_CXXALIAS_RPL (vdprintf, int, |
| @@ -1491,7 +1852,7 @@ _GL_CXXALIAS_RPL (vdprintf, int, | |||
| 1491 | # else | 1852 | # else |
| 1492 | # if !@HAVE_VDPRINTF@ | 1853 | # if !@HAVE_VDPRINTF@ |
| 1493 | _GL_FUNCDECL_SYS (vdprintf, int, | 1854 | _GL_FUNCDECL_SYS (vdprintf, int, |
| 1494 | (int fd, const char *restrict format, va_list args) | 1855 | (int fd, const char *restrict format, va_list args), |
| 1495 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 1856 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1496 | _GL_ARG_NONNULL ((2))); | 1857 | _GL_ARG_NONNULL ((2))); |
| 1497 | # endif | 1858 | # endif |
| @@ -1511,7 +1872,28 @@ _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " | |||
| 1511 | # endif | 1872 | # endif |
| 1512 | #endif | 1873 | #endif |
| 1513 | 1874 | ||
| 1875 | #if @GNULIB_VFZPRINTF@ | ||
| 1876 | /* Prints formatted output to stream FP. | ||
| 1877 | Returns the number of bytes written to the stream. Upon failure, | ||
| 1878 | returns -1 with the stream's error indicator set. | ||
| 1879 | Failure cause EOVERFLOW can only occur when a width > INT_MAX is used. | ||
| 1880 | Therefore, if the format string is valid and does not use %ls/%lc | ||
| 1881 | directives nor widths, the only possible failure causes are ENOMEM | ||
| 1882 | and the possible failure causes from fwrite(). */ | ||
| 1883 | _GL_FUNCDECL_SYS (vfzprintf, off64_t, | ||
| 1884 | (FILE *restrict fp, | ||
| 1885 | const char *restrict format, va_list args), | ||
| 1886 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | ||
| 1887 | _GL_ARG_NONNULL ((1, 2))); | ||
| 1888 | _GL_CXXALIAS_SYS (vfzprintf, off64_t, | ||
| 1889 | (FILE *restrict fp, | ||
| 1890 | const char *restrict format, va_list args)); | ||
| 1891 | #endif | ||
| 1892 | |||
| 1514 | #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@ | 1893 | #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@ |
| 1894 | /* Prints formatted output to stream FP. | ||
| 1895 | Returns the number of bytes written to the stream. Upon failure, | ||
| 1896 | returns a negative value with the stream's error indicator set. */ | ||
| 1515 | # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \ | 1897 | # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \ |
| 1516 | || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) | 1898 | || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) |
| 1517 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1899 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| @@ -1521,13 +1903,13 @@ _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " | |||
| 1521 | # if @GNULIB_VFPRINTF_POSIX@ | 1903 | # if @GNULIB_VFPRINTF_POSIX@ |
| 1522 | _GL_FUNCDECL_RPL (vfprintf, int, | 1904 | _GL_FUNCDECL_RPL (vfprintf, int, |
| 1523 | (FILE *restrict fp, | 1905 | (FILE *restrict fp, |
| 1524 | const char *restrict format, va_list args) | 1906 | const char *restrict format, va_list args), |
| 1525 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 1907 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1526 | _GL_ARG_NONNULL ((1, 2))); | 1908 | _GL_ARG_NONNULL ((1, 2))); |
| 1527 | # else | 1909 | # else |
| 1528 | _GL_FUNCDECL_RPL (vfprintf, int, | 1910 | _GL_FUNCDECL_RPL (vfprintf, int, |
| 1529 | (FILE *restrict fp, | 1911 | (FILE *restrict fp, |
| 1530 | const char *restrict format, va_list args) | 1912 | const char *restrict format, va_list args), |
| 1531 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0) | 1913 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0) |
| 1532 | _GL_ARG_NONNULL ((1, 2))); | 1914 | _GL_ARG_NONNULL ((1, 2))); |
| 1533 | # endif | 1915 | # endif |
| @@ -1545,6 +1927,11 @@ _GL_CXXALIAS_SYS_CAST (vfprintf, int, | |||
| 1545 | # if __GLIBC__ >= 2 | 1927 | # if __GLIBC__ >= 2 |
| 1546 | _GL_CXXALIASWARN (vfprintf); | 1928 | _GL_CXXALIASWARN (vfprintf); |
| 1547 | # endif | 1929 | # endif |
| 1930 | #elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO | ||
| 1931 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1932 | # undef vfprintf | ||
| 1933 | # define vfprintf gl_consolesafe_vfprintf | ||
| 1934 | # endif | ||
| 1548 | #endif | 1935 | #endif |
| 1549 | #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK | 1936 | #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK |
| 1550 | # if !GNULIB_overrides_vfprintf | 1937 | # if !GNULIB_overrides_vfprintf |
| @@ -1564,9 +1951,9 @@ _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - " | |||
| 1564 | # endif | 1951 | # endif |
| 1565 | _GL_FUNCDECL_RPL (vfscanf, int, | 1952 | _GL_FUNCDECL_RPL (vfscanf, int, |
| 1566 | (FILE *restrict stream, | 1953 | (FILE *restrict stream, |
| 1567 | const char *restrict format, va_list args) | 1954 | const char *restrict format, va_list args), |
| 1568 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0) | 1955 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0) |
| 1569 | _GL_ARG_NONNULL ((1, 2))); | 1956 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD); |
| 1570 | _GL_CXXALIAS_RPL (vfscanf, int, | 1957 | _GL_CXXALIAS_RPL (vfscanf, int, |
| 1571 | (FILE *restrict stream, | 1958 | (FILE *restrict stream, |
| 1572 | const char *restrict format, va_list args)); | 1959 | const char *restrict format, va_list args)); |
| @@ -1580,7 +1967,26 @@ _GL_CXXALIASWARN (vfscanf); | |||
| 1580 | # endif | 1967 | # endif |
| 1581 | #endif | 1968 | #endif |
| 1582 | 1969 | ||
| 1970 | #if @GNULIB_VZPRINTF@ | ||
| 1971 | /* Prints formatted output to standard output. | ||
| 1972 | Returns the number of bytes written to standard output. Upon failure, | ||
| 1973 | returns -1 with stdout's error indicator set. | ||
| 1974 | Failure cause EOVERFLOW can only occur when a width > INT_MAX is used. | ||
| 1975 | Therefore, if the format string is valid and does not use %ls/%lc | ||
| 1976 | directives nor widths, the only possible failure causes are ENOMEM | ||
| 1977 | and the possible failure causes from fwrite(). */ | ||
| 1978 | _GL_FUNCDECL_SYS (vzprintf, off64_t, | ||
| 1979 | (const char *restrict format, va_list args), | ||
| 1980 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0) | ||
| 1981 | _GL_ARG_NONNULL ((1))); | ||
| 1982 | _GL_CXXALIAS_SYS (vzprintf, off64_t, | ||
| 1983 | (const char *restrict format, va_list args)); | ||
| 1984 | #endif | ||
| 1985 | |||
| 1583 | #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ | 1986 | #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ |
| 1987 | /* Prints formatted output to standard output. | ||
| 1988 | Returns the number of bytes written to standard output. Upon failure, | ||
| 1989 | returns a negative value with stdout's error indicator set. */ | ||
| 1584 | # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \ | 1990 | # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \ |
| 1585 | || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) | 1991 | || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) |
| 1586 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1992 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| @@ -1588,11 +1994,11 @@ _GL_CXXALIASWARN (vfscanf); | |||
| 1588 | # endif | 1994 | # endif |
| 1589 | # define GNULIB_overrides_vprintf 1 | 1995 | # define GNULIB_overrides_vprintf 1 |
| 1590 | # if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ | 1996 | # if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ |
| 1591 | _GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args) | 1997 | _GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args), |
| 1592 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0) | 1998 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0) |
| 1593 | _GL_ARG_NONNULL ((1))); | 1999 | _GL_ARG_NONNULL ((1))); |
| 1594 | # else | 2000 | # else |
| 1595 | _GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args) | 2001 | _GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args), |
| 1596 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0) | 2002 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0) |
| 1597 | _GL_ARG_NONNULL ((1))); | 2003 | _GL_ARG_NONNULL ((1))); |
| 1598 | # endif | 2004 | # endif |
| @@ -1607,6 +2013,11 @@ _GL_CXXALIAS_SYS_CAST (vprintf, int, | |||
| 1607 | # if __GLIBC__ >= 2 | 2013 | # if __GLIBC__ >= 2 |
| 1608 | _GL_CXXALIASWARN (vprintf); | 2014 | _GL_CXXALIASWARN (vprintf); |
| 1609 | # endif | 2015 | # endif |
| 2016 | #elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO | ||
| 2017 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 2018 | # undef vprintf | ||
| 2019 | # define vprintf gl_consolesafe_vprintf | ||
| 2020 | # endif | ||
| 1610 | #endif | 2021 | #endif |
| 1611 | #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK | 2022 | #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK |
| 1612 | # if !GNULIB_overrides_vprintf | 2023 | # if !GNULIB_overrides_vprintf |
| @@ -1624,9 +2035,9 @@ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - " | |||
| 1624 | # undef vscanf | 2035 | # undef vscanf |
| 1625 | # define vscanf rpl_vscanf | 2036 | # define vscanf rpl_vscanf |
| 1626 | # endif | 2037 | # endif |
| 1627 | _GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args) | 2038 | _GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args), |
| 1628 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0) | 2039 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0) |
| 1629 | _GL_ARG_NONNULL ((1))); | 2040 | _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); |
| 1630 | _GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args)); | 2041 | _GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args)); |
| 1631 | # else | 2042 | # else |
| 1632 | _GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args)); | 2043 | _GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args)); |
| @@ -1636,7 +2047,31 @@ _GL_CXXALIASWARN (vscanf); | |||
| 1636 | # endif | 2047 | # endif |
| 1637 | #endif | 2048 | #endif |
| 1638 | 2049 | ||
| 2050 | #if @GNULIB_VSNZPRINTF@ | ||
| 2051 | /* Prints formatted output to string STR. Similar to sprintf, but the | ||
| 2052 | additional parameter SIZE limits how much is written into STR. | ||
| 2053 | STR may be NULL, in which case nothing will be written. | ||
| 2054 | Returns the string length of the formatted string (which may be larger | ||
| 2055 | than SIZE). Upon failure, returns -1 with errno set. | ||
| 2056 | Failure code EOVERFLOW can only occur when a width > INT_MAX is used. | ||
| 2057 | Therefore, if the format string is valid and does not use %ls/%lc | ||
| 2058 | directives nor widths, the only possible failure code is ENOMEM. */ | ||
| 2059 | _GL_FUNCDECL_SYS (vsnzprintf, ptrdiff_t, | ||
| 2060 | (char *restrict str, size_t size, | ||
| 2061 | const char *restrict format, va_list args), | ||
| 2062 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) | ||
| 2063 | _GL_ARG_NONNULL ((3))); | ||
| 2064 | _GL_CXXALIAS_SYS (vsnzprintf, ptrdiff_t, | ||
| 2065 | (char *restrict str, size_t size, | ||
| 2066 | const char *restrict format, va_list args)); | ||
| 2067 | #endif | ||
| 2068 | |||
| 1639 | #if @GNULIB_VSNPRINTF@ | 2069 | #if @GNULIB_VSNPRINTF@ |
| 2070 | /* Prints formatted output to string STR. Similar to vsprintf, but the | ||
| 2071 | additional parameter SIZE limits how much is written into STR. | ||
| 2072 | STR may be NULL, in which case nothing will be written. | ||
| 2073 | Returns the string length of the formatted string (which may be larger | ||
| 2074 | than SIZE). Upon failure, returns a negative value. */ | ||
| 1640 | # if @REPLACE_VSNPRINTF@ | 2075 | # if @REPLACE_VSNPRINTF@ |
| 1641 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 2076 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1642 | # define vsnprintf rpl_vsnprintf | 2077 | # define vsnprintf rpl_vsnprintf |
| @@ -1644,7 +2079,7 @@ _GL_CXXALIASWARN (vscanf); | |||
| 1644 | # define GNULIB_overrides_vsnprintf 1 | 2079 | # define GNULIB_overrides_vsnprintf 1 |
| 1645 | _GL_FUNCDECL_RPL (vsnprintf, int, | 2080 | _GL_FUNCDECL_RPL (vsnprintf, int, |
| 1646 | (char *restrict str, size_t size, | 2081 | (char *restrict str, size_t size, |
| 1647 | const char *restrict format, va_list args) | 2082 | const char *restrict format, va_list args), |
| 1648 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) | 2083 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) |
| 1649 | _GL_ARG_NONNULL ((3))); | 2084 | _GL_ARG_NONNULL ((3))); |
| 1650 | _GL_CXXALIAS_RPL (vsnprintf, int, | 2085 | _GL_CXXALIAS_RPL (vsnprintf, int, |
| @@ -1654,7 +2089,7 @@ _GL_CXXALIAS_RPL (vsnprintf, int, | |||
| 1654 | # if !@HAVE_DECL_VSNPRINTF@ | 2089 | # if !@HAVE_DECL_VSNPRINTF@ |
| 1655 | _GL_FUNCDECL_SYS (vsnprintf, int, | 2090 | _GL_FUNCDECL_SYS (vsnprintf, int, |
| 1656 | (char *restrict str, size_t size, | 2091 | (char *restrict str, size_t size, |
| 1657 | const char *restrict format, va_list args) | 2092 | const char *restrict format, va_list args), |
| 1658 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) | 2093 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) |
| 1659 | _GL_ARG_NONNULL ((3))); | 2094 | _GL_ARG_NONNULL ((3))); |
| 1660 | # endif | 2095 | # endif |
| @@ -1673,7 +2108,27 @@ _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " | |||
| 1673 | # endif | 2108 | # endif |
| 1674 | #endif | 2109 | #endif |
| 1675 | 2110 | ||
| 2111 | #if @GNULIB_VSZPRINTF@ | ||
| 2112 | /* Prints formatted output to string STR. | ||
| 2113 | Returns the string length of the formatted string. Upon failure, | ||
| 2114 | returns -1 with errno set. | ||
| 2115 | Failure code EOVERFLOW can only occur when a width > INT_MAX is used. | ||
| 2116 | Therefore, if the format string is valid and does not use %ls/%lc | ||
| 2117 | directives nor widths, the only possible failure code is ENOMEM. */ | ||
| 2118 | _GL_FUNCDECL_SYS (vszprintf, ptrdiff_t, | ||
| 2119 | (char *restrict str, | ||
| 2120 | const char *restrict format, va_list args), | ||
| 2121 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | ||
| 2122 | _GL_ARG_NONNULL ((1, 2))); | ||
| 2123 | _GL_CXXALIAS_SYS (vszprintf, ptrdiff_t, | ||
| 2124 | (char *restrict str, | ||
| 2125 | const char *restrict format, va_list args)); | ||
| 2126 | #endif | ||
| 2127 | |||
| 1676 | #if @GNULIB_VSPRINTF_POSIX@ | 2128 | #if @GNULIB_VSPRINTF_POSIX@ |
| 2129 | /* Prints formatted output to string STR. | ||
| 2130 | Returns the string length of the formatted string. Upon failure, | ||
| 2131 | returns a negative value. */ | ||
| 1677 | # if @REPLACE_VSPRINTF@ | 2132 | # if @REPLACE_VSPRINTF@ |
| 1678 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 2133 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1679 | # define vsprintf rpl_vsprintf | 2134 | # define vsprintf rpl_vsprintf |
| @@ -1681,7 +2136,7 @@ _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " | |||
| 1681 | # define GNULIB_overrides_vsprintf 1 | 2136 | # define GNULIB_overrides_vsprintf 1 |
| 1682 | _GL_FUNCDECL_RPL (vsprintf, int, | 2137 | _GL_FUNCDECL_RPL (vsprintf, int, |
| 1683 | (char *restrict str, | 2138 | (char *restrict str, |
| 1684 | const char *restrict format, va_list args) | 2139 | const char *restrict format, va_list args), |
| 1685 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 2140 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1686 | _GL_ARG_NONNULL ((1, 2))); | 2141 | _GL_ARG_NONNULL ((1, 2))); |
| 1687 | _GL_CXXALIAS_RPL (vsprintf, int, | 2142 | _GL_CXXALIAS_RPL (vsprintf, int, |
