diff options
Diffstat (limited to 'gl/stdio.in.h')
| -rw-r--r-- | gl/stdio.in.h | 587 |
1 files changed, 455 insertions, 132 deletions
diff --git a/gl/stdio.in.h b/gl/stdio.in.h index 35b9f748..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-2024 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 |
| @@ -48,12 +48,12 @@ | |||
| 48 | # endif | 48 | # endif |
| 49 | #endif | 49 | #endif |
| 50 | 50 | ||
| 51 | #define _GL_ALREADY_INCLUDING_STDIO_H | 51 | #define _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H |
| 52 | 52 | ||
| 53 | /* The include_next requires a split double-inclusion guard. */ | 53 | /* The include_next requires a split double-inclusion guard. */ |
| 54 | #@INCLUDE_NEXT@ @NEXT_STDIO_H@ | 54 | #@INCLUDE_NEXT@ @NEXT_STDIO_H@ |
| 55 | 55 | ||
| 56 | #undef _GL_ALREADY_INCLUDING_STDIO_H | 56 | #undef _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H |
| 57 | 57 | ||
| 58 | #ifdef _GL_DEFINED__POSIX_C_SOURCE | 58 | #ifdef _GL_DEFINED__POSIX_C_SOURCE |
| 59 | # undef _GL_DEFINED__POSIX_C_SOURCE | 59 | # undef _GL_DEFINED__POSIX_C_SOURCE |
| @@ -64,8 +64,8 @@ | |||
| 64 | #define _@GUARD_PREFIX@_STDIO_H | 64 | #define _@GUARD_PREFIX@_STDIO_H |
| 65 | 65 | ||
| 66 | /* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT, | 66 | /* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT, |
| 67 | _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK, | 67 | _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW, |
| 68 | HAVE_RAW_DECL_*. */ | 68 | GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ |
| 69 | #if !_GL_CONFIG_H_INCLUDED | 69 | #if !_GL_CONFIG_H_INCLUDED |
| 70 | #error "Please include config.h first." | 70 | #error "Please include config.h first." |
| 71 | #endif | 71 | #endif |
| @@ -77,7 +77,8 @@ | |||
| 77 | 77 | ||
| 78 | /* 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 |
| 79 | and eglibc 2.11.2. | 79 | and eglibc 2.11.2. |
| 80 | 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. */ | ||
| 81 | #include <sys/types.h> | 82 | #include <sys/types.h> |
| 82 | 83 | ||
| 83 | /* 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>. */ |
| @@ -119,7 +120,7 @@ | |||
| 119 | 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 |
| 120 | function F. */ | 121 | function F. */ |
| 121 | #ifndef _GL_ATTRIBUTE_DEALLOC | 122 | #ifndef _GL_ATTRIBUTE_DEALLOC |
| 122 | # if __GNUC__ >= 11 | 123 | # if __GNUC__ >= 11 && !defined __clang__ |
| 123 | # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) | 124 | # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) |
| 124 | # else | 125 | # else |
| 125 | # define _GL_ATTRIBUTE_DEALLOC(f, i) | 126 | # define _GL_ATTRIBUTE_DEALLOC(f, i) |
| @@ -154,7 +155,7 @@ | |||
| 154 | */ | 155 | */ |
| 155 | #ifndef _GL_ATTRIBUTE_NOTHROW | 156 | #ifndef _GL_ATTRIBUTE_NOTHROW |
| 156 | # if defined __cplusplus | 157 | # if defined __cplusplus |
| 157 | # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 | 158 | # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4 |
| 158 | # if __cplusplus >= 201103L | 159 | # if __cplusplus >= 201103L |
| 159 | # define _GL_ATTRIBUTE_NOTHROW noexcept (true) | 160 | # define _GL_ATTRIBUTE_NOTHROW noexcept (true) |
| 160 | # else | 161 | # else |
| @@ -177,7 +178,7 @@ | |||
| 177 | standardized by ISO C99 and POSIX. | 178 | standardized by ISO C99 and POSIX. |
| 178 | _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */ | 179 | _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */ |
| 179 | /* __gnu_printf__ is supported in GCC >= 4.4. */ | 180 | /* __gnu_printf__ is supported in GCC >= 4.4. */ |
| 180 | #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) | 181 | #if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4) && !defined __clang__ |
| 181 | # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__ | 182 | # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__ |
| 182 | #else | 183 | #else |
| 183 | # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__ | 184 | # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__ |
| @@ -279,18 +280,64 @@ | |||
| 279 | #endif | 280 | #endif |
| 280 | 281 | ||
| 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 | |||
| 282 | #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. */ | ||
| 283 | # if @REPLACE_DPRINTF@ | 330 | # if @REPLACE_DPRINTF@ |
| 284 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 331 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 285 | # define dprintf rpl_dprintf | 332 | # define dprintf rpl_dprintf |
| 286 | # endif | 333 | # endif |
| 287 | _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...) | 334 | _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...), |
| 288 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 335 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 289 | _GL_ARG_NONNULL ((2))); | 336 | _GL_ARG_NONNULL ((2))); |
| 290 | _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...)); | 337 | _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...)); |
| 291 | # else | 338 | # else |
| 292 | # if !@HAVE_DPRINTF@ | 339 | # if !@HAVE_DPRINTF@ |
| 293 | _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...) | 340 | _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...), |
| 294 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 341 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 295 | _GL_ARG_NONNULL ((2))); | 342 | _GL_ARG_NONNULL ((2))); |
| 296 | # endif | 343 | # endif |
| @@ -313,7 +360,7 @@ _GL_WARN_ON_USE (dprintf, "dprintf is unportable - " | |||
| 313 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 360 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 314 | # define fclose rpl_fclose | 361 | # define fclose rpl_fclose |
| 315 | # endif | 362 | # endif |
| 316 | _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); | 363 | _GL_FUNCDECL_RPL (fclose, int, (FILE *stream), _GL_ARG_NONNULL ((1))); |
| 317 | _GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); | 364 | _GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); |
| 318 | # else | 365 | # else |
| 319 | _GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); | 366 | _GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); |
| @@ -360,9 +407,10 @@ _GL_CXXALIASWARN (fcloseall); | |||
| 360 | # define fdopen rpl_fdopen | 407 | # define fdopen rpl_fdopen |
| 361 | # endif | 408 | # endif |
| 362 | _GL_FUNCDECL_RPL (fdopen, FILE *, | 409 | _GL_FUNCDECL_RPL (fdopen, FILE *, |
| 363 | (int fd, const char *mode) | 410 | (int fd, const char *mode), |
| 364 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) | 411 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 365 | _GL_ATTRIBUTE_MALLOC); | 412 | _GL_ATTRIBUTE_MALLOC |
| 413 | _GL_ATTRIBUTE_NODISCARD); | ||
| 366 | _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); | 414 | _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); |
| 367 | # elif defined _WIN32 && !defined __CYGWIN__ | 415 | # elif defined _WIN32 && !defined __CYGWIN__ |
| 368 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 416 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| @@ -371,36 +419,38 @@ _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); | |||
| 371 | # endif | 419 | # endif |
| 372 | _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode)); | 420 | _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode)); |
| 373 | # else | 421 | # else |
| 374 | # if __GNUC__ >= 11 | 422 | # if __GNUC__ >= 11 && !defined __clang__ |
| 375 | /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ | 423 | /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ |
| 376 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 | 424 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 |
| 377 | _GL_FUNCDECL_SYS (fdopen, FILE *, | 425 | _GL_FUNCDECL_SYS (fdopen, FILE *, |
| 378 | (int fd, const char *mode) | 426 | (int fd, const char *mode), |
| 379 | _GL_ATTRIBUTE_NOTHROW | ||
| 380 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) | 427 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 381 | _GL_ATTRIBUTE_MALLOC); | 428 | _GL_ATTRIBUTE_MALLOC |
| 429 | _GL_ATTRIBUTE_NODISCARD) | ||
| 430 | _GL_ATTRIBUTE_NOTHROW; | ||
| 382 | # else | 431 | # else |
| 383 | _GL_FUNCDECL_SYS (fdopen, FILE *, | 432 | _GL_FUNCDECL_SYS (fdopen, FILE *, |
| 384 | (int fd, const char *mode) | 433 | (int fd, const char *mode), |
| 385 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) | 434 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 386 | _GL_ATTRIBUTE_MALLOC); | 435 | _GL_ATTRIBUTE_MALLOC |
| 436 | _GL_ATTRIBUTE_NODISCARD); | ||
| 387 | # endif | 437 | # endif |
| 388 | # endif | 438 | # endif |
| 389 | _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); | 439 | _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); |
| 390 | # endif | 440 | # endif |
| 391 | _GL_CXXALIASWARN (fdopen); | 441 | _GL_CXXALIASWARN (fdopen); |
| 392 | #else | 442 | #else |
| 393 | # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen | 443 | # if @GNULIB_FCLOSE@ && (__GNUC__ >= 11 && !defined __clang__) && !defined fdopen |
| 394 | /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ | 444 | /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ |
| 395 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 | 445 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 |
| 396 | _GL_FUNCDECL_SYS (fdopen, FILE *, | 446 | _GL_FUNCDECL_SYS (fdopen, FILE *, |
| 397 | (int fd, const char *mode) | 447 | (int fd, const char *mode), |
| 398 | _GL_ATTRIBUTE_NOTHROW | ||
| 399 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) | 448 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 400 | _GL_ATTRIBUTE_MALLOC); | 449 | _GL_ATTRIBUTE_MALLOC) |
| 450 | _GL_ATTRIBUTE_NOTHROW; | ||
| 401 | # else | 451 | # else |
| 402 | _GL_FUNCDECL_SYS (fdopen, FILE *, | 452 | _GL_FUNCDECL_SYS (fdopen, FILE *, |
| 403 | (int fd, const char *mode) | 453 | (int fd, const char *mode), |
| 404 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) | 454 | _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 405 | _GL_ATTRIBUTE_MALLOC); | 455 | _GL_ATTRIBUTE_MALLOC); |
| 406 | # endif | 456 | # endif |
| @@ -438,7 +488,7 @@ _GL_CXXALIASWARN (fdopen); | |||
| 438 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 488 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 439 | # define fflush rpl_fflush | 489 | # define fflush rpl_fflush |
| 440 | # endif | 490 | # endif |
| 441 | _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream)); | 491 | _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream), ); |
| 442 | _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream)); | 492 | _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream)); |
| 443 | # else | 493 | # else |
| 444 | _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); | 494 | _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); |
| @@ -459,7 +509,7 @@ _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " | |||
| 459 | # undef fgetc | 509 | # undef fgetc |
| 460 | # define fgetc rpl_fgetc | 510 | # define fgetc rpl_fgetc |
| 461 | # endif | 511 | # endif |
| 462 | _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); | 512 | _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream), _GL_ARG_NONNULL ((1))); |
| 463 | _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream)); | 513 | _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream)); |
| 464 | # else | 514 | # else |
| 465 | _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream)); | 515 | _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream)); |
| @@ -476,8 +526,8 @@ _GL_CXXALIASWARN (fgetc); | |||
| 476 | # define fgets rpl_fgets | 526 | # define fgets rpl_fgets |
| 477 | # endif | 527 | # endif |
| 478 | _GL_FUNCDECL_RPL (fgets, char *, | 528 | _GL_FUNCDECL_RPL (fgets, char *, |
| 479 | (char *restrict s, int n, FILE *restrict stream) | 529 | (char *restrict s, int n, FILE *restrict stream), |
| 480 | _GL_ARG_NONNULL ((1, 3))); | 530 | _GL_ARG_NONNULL ((1, 3)) _GL_ATTRIBUTE_NODISCARD); |
| 481 | _GL_CXXALIAS_RPL (fgets, char *, | 531 | _GL_CXXALIAS_RPL (fgets, char *, |
| 482 | (char *restrict s, int n, FILE *restrict stream)); | 532 | (char *restrict s, int n, FILE *restrict stream)); |
| 483 | # else | 533 | # else |
| @@ -513,17 +563,18 @@ _GL_CXXALIASWARN (fileno); | |||
| 513 | # define fopen rpl_fopen | 563 | # define fopen rpl_fopen |
| 514 | # endif | 564 | # endif |
| 515 | _GL_FUNCDECL_RPL (fopen, FILE *, | 565 | _GL_FUNCDECL_RPL (fopen, FILE *, |
| 516 | (const char *restrict filename, const char *restrict mode) | 566 | (const char *restrict filename, const char *restrict mode), |
| 517 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) | 567 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 518 | _GL_ATTRIBUTE_MALLOC); | 568 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD); |
| 519 | _GL_CXXALIAS_RPL (fopen, FILE *, | 569 | _GL_CXXALIAS_RPL (fopen, FILE *, |
| 520 | (const char *restrict filename, const char *restrict mode)); | 570 | (const char *restrict filename, const char *restrict mode)); |
| 521 | # else | 571 | # else |
| 522 | # if __GNUC__ >= 11 | 572 | # if __GNUC__ >= 11 && !defined __clang__ |
| 523 | /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ | 573 | /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ |
| 524 | _GL_FUNCDECL_SYS (fopen, FILE *, | 574 | _GL_FUNCDECL_SYS (fopen, FILE *, |
| 525 | (const char *restrict filename, const char *restrict mode) | 575 | (const char *restrict filename, const char *restrict mode), |
| 526 | _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); | ||
| 527 | # endif | 578 | # endif |
| 528 | _GL_CXXALIAS_SYS (fopen, FILE *, | 579 | _GL_CXXALIAS_SYS (fopen, FILE *, |
| 529 | (const char *restrict filename, const char *restrict mode)); | 580 | (const char *restrict filename, const char *restrict mode)); |
| @@ -532,10 +583,10 @@ _GL_CXXALIAS_SYS (fopen, FILE *, | |||
| 532 | _GL_CXXALIASWARN (fopen); | 583 | _GL_CXXALIASWARN (fopen); |
| 533 | # endif | 584 | # endif |
| 534 | #else | 585 | #else |
| 535 | # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fopen | 586 | # if @GNULIB_FCLOSE@ && (__GNUC__ >= 11 && !defined __clang__) && !defined fopen |
| 536 | /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ | 587 | /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ |
| 537 | _GL_FUNCDECL_SYS (fopen, FILE *, | 588 | _GL_FUNCDECL_SYS (fopen, FILE *, |
| 538 | (const char *restrict filename, const char *restrict mode) | 589 | (const char *restrict filename, const char *restrict mode), |
| 539 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); | 590 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); |
| 540 | # endif | 591 | # endif |
| 541 | # if defined GNULIB_POSIXCHECK | 592 | # if defined GNULIB_POSIXCHECK |
| @@ -546,7 +597,26 @@ _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX complian | |||
| 546 | # endif | 597 | # endif |
| 547 | #endif | 598 | #endif |
| 548 | 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 | |||
| 549 | #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. */ | ||
| 550 | # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \ | 620 | # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \ |
| 551 | || (@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@)) |
| 552 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 622 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| @@ -555,12 +625,12 @@ _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX complian | |||
| 555 | # define GNULIB_overrides_fprintf 1 | 625 | # define GNULIB_overrides_fprintf 1 |
| 556 | # if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ | 626 | # if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ |
| 557 | _GL_FUNCDECL_RPL (fprintf, int, | 627 | _GL_FUNCDECL_RPL (fprintf, int, |
| 558 | (FILE *restrict fp, const char *restrict format, ...) | 628 | (FILE *restrict fp, const char *restrict format, ...), |
| 559 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 629 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 560 | _GL_ARG_NONNULL ((1, 2))); | 630 | _GL_ARG_NONNULL ((1, 2))); |
| 561 | # else | 631 | # else |
| 562 | _GL_FUNCDECL_RPL (fprintf, int, | 632 | _GL_FUNCDECL_RPL (fprintf, int, |
| 563 | (FILE *restrict fp, const char *restrict format, ...) | 633 | (FILE *restrict fp, const char *restrict format, ...), |
| 564 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3) | 634 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3) |
| 565 | _GL_ARG_NONNULL ((1, 2))); | 635 | _GL_ARG_NONNULL ((1, 2))); |
| 566 | # endif | 636 | # endif |
| @@ -573,6 +643,11 @@ _GL_CXXALIAS_SYS (fprintf, int, | |||
| 573 | # if __GLIBC__ >= 2 | 643 | # if __GLIBC__ >= 2 |
| 574 | _GL_CXXALIASWARN (fprintf); | 644 | _GL_CXXALIASWARN (fprintf); |
| 575 | # 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 | ||
| 576 | #endif | 651 | #endif |
| 577 | #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK | 652 | #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK |
| 578 | # if !GNULIB_overrides_fprintf | 653 | # if !GNULIB_overrides_fprintf |
| @@ -595,15 +670,17 @@ _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - " | |||
| 595 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 670 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 596 | # define fpurge rpl_fpurge | 671 | # define fpurge rpl_fpurge |
| 597 | # endif | 672 | # endif |
| 598 | _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))); |
| 599 | _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream)); | 674 | _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream)); |
| 600 | # else | 675 | # else |
| 601 | # if !@HAVE_DECL_FPURGE@ | 676 | # if !@HAVE_DECL_FPURGE@ |
| 602 | _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))); |
| 603 | # endif | 678 | # endif |
| 604 | _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); | 679 | _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); |
| 605 | # endif | 680 | # endif |
| 681 | # if __GLIBC__ >= 2 | ||
| 606 | _GL_CXXALIASWARN (fpurge); | 682 | _GL_CXXALIASWARN (fpurge); |
| 683 | # endif | ||
| 607 | #elif defined GNULIB_POSIXCHECK | 684 | #elif defined GNULIB_POSIXCHECK |
| 608 | # undef fpurge | 685 | # undef fpurge |
| 609 | # if HAVE_RAW_DECL_FPURGE | 686 | # if HAVE_RAW_DECL_FPURGE |
| @@ -618,7 +695,7 @@ _GL_WARN_ON_USE (fpurge, "fpurge is not always present - " | |||
| 618 | # undef fputc | 695 | # undef fputc |
| 619 | # define fputc rpl_fputc | 696 | # define fputc rpl_fputc |
| 620 | # endif | 697 | # endif |
| 621 | _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))); |
| 622 | _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); | 699 | _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); |
| 623 | # else | 700 | # else |
| 624 | _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); | 701 | _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); |
| @@ -635,7 +712,7 @@ _GL_CXXALIASWARN (fputc); | |||
| 635 | # define fputs rpl_fputs | 712 | # define fputs rpl_fputs |
| 636 | # endif | 713 | # endif |
| 637 | _GL_FUNCDECL_RPL (fputs, int, | 714 | _GL_FUNCDECL_RPL (fputs, int, |
| 638 | (const char *restrict string, FILE *restrict stream) | 715 | (const char *restrict string, FILE *restrict stream), |
| 639 | _GL_ARG_NONNULL ((1, 2))); | 716 | _GL_ARG_NONNULL ((1, 2))); |
| 640 | _GL_CXXALIAS_RPL (fputs, int, | 717 | _GL_CXXALIAS_RPL (fputs, int, |
| 641 | (const char *restrict string, FILE *restrict stream)); | 718 | (const char *restrict string, FILE *restrict stream)); |
| @@ -656,8 +733,8 @@ _GL_CXXALIASWARN (fputs); | |||
| 656 | # endif | 733 | # endif |
| 657 | _GL_FUNCDECL_RPL (fread, size_t, | 734 | _GL_FUNCDECL_RPL (fread, size_t, |
| 658 | (void *restrict ptr, size_t s, size_t n, | 735 | (void *restrict ptr, size_t s, size_t n, |
| 659 | FILE *restrict stream) | 736 | FILE *restrict stream), |
| 660 | _GL_ARG_NONNULL ((4))); | 737 | _GL_ARG_NONNULL ((4)) _GL_ATTRIBUTE_NODISCARD); |
| 661 | _GL_CXXALIAS_RPL (fread, size_t, | 738 | _GL_CXXALIAS_RPL (fread, size_t, |
| 662 | (void *restrict ptr, size_t s, size_t n, | 739 | (void *restrict ptr, size_t s, size_t n, |
| 663 | FILE *restrict stream)); | 740 | FILE *restrict stream)); |
| @@ -679,8 +756,8 @@ _GL_CXXALIASWARN (fread); | |||
| 679 | # endif | 756 | # endif |
| 680 | _GL_FUNCDECL_RPL (freopen, FILE *, | 757 | _GL_FUNCDECL_RPL (freopen, FILE *, |
| 681 | (const char *restrict filename, const char *restrict mode, | 758 | (const char *restrict filename, const char *restrict mode, |
| 682 | FILE *restrict stream) | 759 | FILE *restrict stream), |
| 683 | _GL_ARG_NONNULL ((2, 3))); | 760 | _GL_ARG_NONNULL ((2, 3)) _GL_ATTRIBUTE_NODISCARD); |
| 684 | _GL_CXXALIAS_RPL (freopen, FILE *, | 761 | _GL_CXXALIAS_RPL (freopen, FILE *, |
| 685 | (const char *restrict filename, const char *restrict mode, | 762 | (const char *restrict filename, const char *restrict mode, |
| 686 | FILE *restrict stream)); | 763 | FILE *restrict stream)); |
| @@ -707,9 +784,9 @@ _GL_WARN_ON_USE (freopen, | |||
| 707 | # define fscanf rpl_fscanf | 784 | # define fscanf rpl_fscanf |
| 708 | # endif | 785 | # endif |
| 709 | _GL_FUNCDECL_RPL (fscanf, int, | 786 | _GL_FUNCDECL_RPL (fscanf, int, |
| 710 | (FILE *restrict stream, const char *restrict format, ...) | 787 | (FILE *restrict stream, const char *restrict format, ...), |
| 711 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3) | 788 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3) |
| 712 | _GL_ARG_NONNULL ((1, 2))); | 789 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD); |
| 713 | _GL_CXXALIAS_RPL (fscanf, int, | 790 | _GL_CXXALIAS_RPL (fscanf, int, |
| 714 | (FILE *restrict stream, const char *restrict format, ...)); | 791 | (FILE *restrict stream, const char *restrict format, ...)); |
| 715 | # else | 792 | # else |
| @@ -763,7 +840,7 @@ _GL_CXXALIASWARN (fscanf); | |||
| 763 | # undef fseek | 840 | # undef fseek |
| 764 | # define fseek rpl_fseek | 841 | # define fseek rpl_fseek |
| 765 | # endif | 842 | # endif |
| 766 | _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence) | 843 | _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence), |
| 767 | _GL_ARG_NONNULL ((1))); | 844 | _GL_ARG_NONNULL ((1))); |
| 768 | _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); | 845 | _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); |
| 769 | # else | 846 | # else |
| @@ -786,12 +863,12 @@ _GL_CXXALIASWARN (fseek); | |||
| 786 | # undef fseeko | 863 | # undef fseeko |
| 787 | # define fseeko rpl_fseeko | 864 | # define fseeko rpl_fseeko |
| 788 | # endif | 865 | # endif |
| 789 | _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), |
| 790 | _GL_ARG_NONNULL ((1))); | 867 | _GL_ARG_NONNULL ((1))); |
| 791 | _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)); |
| 792 | # else | 869 | # else |
| 793 | # if ! @HAVE_DECL_FSEEKO@ | 870 | # if ! @HAVE_DECL_FSEEKO@ |
| 794 | _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), |
| 795 | _GL_ARG_NONNULL ((1))); | 872 | _GL_ARG_NONNULL ((1))); |
| 796 | # endif | 873 | # endif |
| 797 | _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)); |
| @@ -829,7 +906,8 @@ _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB " | |||
| 829 | # undef ftell | 906 | # undef ftell |
| 830 | # define ftell rpl_ftell | 907 | # define ftell rpl_ftell |
| 831 | # endif | 908 | # endif |
| 832 | _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); | ||
| 833 | _GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); | 911 | _GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); |
| 834 | # else | 912 | # else |
| 835 | _GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); | 913 | _GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); |
| @@ -849,11 +927,13 @@ _GL_CXXALIASWARN (ftell); | |||
| 849 | # undef ftello | 927 | # undef ftello |
| 850 | # define ftello rpl_ftello | 928 | # define ftello rpl_ftello |
| 851 | # endif | 929 | # endif |
| 852 | _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); | ||
| 853 | _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); | 932 | _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); |
| 854 | # else | 933 | # else |
| 855 | # if ! @HAVE_DECL_FTELLO@ | 934 | # if ! @HAVE_DECL_FTELLO@ |
| 856 | _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); | ||
| 857 | # endif | 937 | # endif |
| 858 | _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); | 938 | _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); |
| 859 | # endif | 939 | # endif |
| @@ -886,7 +966,7 @@ _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB " | |||
| 886 | # endif | 966 | # endif |
| 887 | _GL_FUNCDECL_RPL (fwrite, size_t, | 967 | _GL_FUNCDECL_RPL (fwrite, size_t, |
| 888 | (const void *restrict ptr, size_t s, size_t n, | 968 | (const void *restrict ptr, size_t s, size_t n, |
| 889 | FILE *restrict stream) | 969 | FILE *restrict stream), |
| 890 | _GL_ARG_NONNULL ((1, 4))); | 970 | _GL_ARG_NONNULL ((1, 4))); |
| 891 | _GL_CXXALIAS_RPL (fwrite, size_t, | 971 | _GL_CXXALIAS_RPL (fwrite, size_t, |
| 892 | (const void *restrict ptr, size_t s, size_t n, | 972 | (const void *restrict ptr, size_t s, size_t n, |
| @@ -901,9 +981,9 @@ _GL_CXXALIAS_SYS (fwrite, size_t, | |||
| 901 | which sometimes causes an unwanted diagnostic for fwrite calls. | 981 | which sometimes causes an unwanted diagnostic for fwrite calls. |
| 902 | This affects only function declaration attributes under certain | 982 | This affects only function declaration attributes under certain |
| 903 | versions of gcc and clang, and is not needed for C++. */ | 983 | versions of gcc and clang, and is not needed for C++. */ |
| 904 | # if (0 < __USE_FORTIFY_LEVEL \ | 984 | # if (0 < __USE_FORTIFY_LEVEL \ |
| 905 | && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \ | 985 | && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \ |
| 906 | && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \ | 986 | && (3 < __GNUC__ + (4 <= __GNUC_MINOR__) || defined __clang__) \ |
| 907 | && !defined __cplusplus) | 987 | && !defined __cplusplus) |
| 908 | # undef fwrite | 988 | # undef fwrite |
| 909 | # undef fwrite_unlocked | 989 | # undef fwrite_unlocked |
| @@ -922,6 +1002,11 @@ _GL_EXTERN_C size_t __REDIRECT (rpl_fwrite_unlocked, | |||
| 922 | # if __GLIBC__ >= 2 | 1002 | # if __GLIBC__ >= 2 |
| 923 | _GL_CXXALIASWARN (fwrite); | 1003 | _GL_CXXALIASWARN (fwrite); |
| 924 | # 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 | ||
| 925 | #endif | 1010 | #endif |
| 926 | 1011 | ||
| 927 | #if @GNULIB_GETC@ | 1012 | #if @GNULIB_GETC@ |
| @@ -930,7 +1015,7 @@ _GL_CXXALIASWARN (fwrite); | |||
| 930 | # undef getc | 1015 | # undef getc |
| 931 | # define getc rpl_fgetc | 1016 | # define getc rpl_fgetc |
| 932 | # endif | 1017 | # endif |
| 933 | _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); | 1018 | _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream), _GL_ARG_NONNULL ((1))); |
| 934 | _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream)); | 1019 | _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream)); |
| 935 | # else | 1020 | # else |
| 936 | _GL_CXXALIAS_SYS (getc, int, (FILE *stream)); | 1021 | _GL_CXXALIAS_SYS (getc, int, (FILE *stream)); |
| @@ -946,7 +1031,7 @@ _GL_CXXALIASWARN (getc); | |||
| 946 | # undef getchar | 1031 | # undef getchar |
| 947 | # define getchar rpl_getchar | 1032 | # define getchar rpl_getchar |
| 948 | # endif | 1033 | # endif |
| 949 | _GL_FUNCDECL_RPL (getchar, int, (void)); | 1034 | _GL_FUNCDECL_RPL (getchar, int, (void), ); |
| 950 | _GL_CXXALIAS_RPL (getchar, int, (void)); | 1035 | _GL_CXXALIAS_RPL (getchar, int, (void)); |
| 951 | # else | 1036 | # else |
| 952 | _GL_CXXALIAS_SYS (getchar, int, (void)); | 1037 | _GL_CXXALIAS_SYS (getchar, int, (void)); |
| @@ -971,8 +1056,8 @@ _GL_CXXALIASWARN (getchar); | |||
| 971 | _GL_FUNCDECL_RPL (getdelim, ssize_t, | 1056 | _GL_FUNCDECL_RPL (getdelim, ssize_t, |
| 972 | (char **restrict lineptr, size_t *restrict linesize, | 1057 | (char **restrict lineptr, size_t *restrict linesize, |
| 973 | int delimiter, | 1058 | int delimiter, |
| 974 | FILE *restrict stream) | 1059 | FILE *restrict stream), |
| 975 | _GL_ARG_NONNULL ((1, 2, 4))); | 1060 | _GL_ARG_NONNULL ((1, 2, 4)) _GL_ATTRIBUTE_NODISCARD); |
| 976 | _GL_CXXALIAS_RPL (getdelim, ssize_t, | 1061 | _GL_CXXALIAS_RPL (getdelim, ssize_t, |
| 977 | (char **restrict lineptr, size_t *restrict linesize, | 1062 | (char **restrict lineptr, size_t *restrict linesize, |
| 978 | int delimiter, | 1063 | int delimiter, |
| @@ -982,8 +1067,8 @@ _GL_CXXALIAS_RPL (getdelim, ssize_t, | |||
| 982 | _GL_FUNCDECL_SYS (getdelim, ssize_t, | 1067 | _GL_FUNCDECL_SYS (getdelim, ssize_t, |
| 983 | (char **restrict lineptr, size_t *restrict linesize, | 1068 | (char **restrict lineptr, size_t *restrict linesize, |
| 984 | int delimiter, | 1069 | int delimiter, |
| 985 | FILE *restrict stream) | 1070 | FILE *restrict stream), |
| 986 | _GL_ARG_NONNULL ((1, 2, 4))); | 1071 | _GL_ARG_NONNULL ((1, 2, 4)) _GL_ATTRIBUTE_NODISCARD); |
| 987 | # endif | 1072 | # endif |
| 988 | _GL_CXXALIAS_SYS (getdelim, ssize_t, | 1073 | _GL_CXXALIAS_SYS (getdelim, ssize_t, |
| 989 | (char **restrict lineptr, size_t *restrict linesize, | 1074 | (char **restrict lineptr, size_t *restrict linesize, |
| @@ -1015,8 +1100,8 @@ _GL_WARN_ON_USE (getdelim, "getdelim is unportable - " | |||
| 1015 | # endif | 1100 | # endif |
| 1016 | _GL_FUNCDECL_RPL (getline, ssize_t, | 1101 | _GL_FUNCDECL_RPL (getline, ssize_t, |
| 1017 | (char **restrict lineptr, size_t *restrict linesize, | 1102 | (char **restrict lineptr, size_t *restrict linesize, |
| 1018 | FILE *restrict stream) | 1103 | FILE *restrict stream), |
| 1019 | _GL_ARG_NONNULL ((1, 2, 3))); | 1104 | _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD); |
| 1020 | _GL_CXXALIAS_RPL (getline, ssize_t, | 1105 | _GL_CXXALIAS_RPL (getline, ssize_t, |
| 1021 | (char **restrict lineptr, size_t *restrict linesize, | 1106 | (char **restrict lineptr, size_t *restrict linesize, |
| 1022 | FILE *restrict stream)); | 1107 | FILE *restrict stream)); |
| @@ -1024,8 +1109,8 @@ _GL_CXXALIAS_RPL (getline, ssize_t, | |||
| 1024 | # if !@HAVE_DECL_GETLINE@ | 1109 | # if !@HAVE_DECL_GETLINE@ |
| 1025 | _GL_FUNCDECL_SYS (getline, ssize_t, | 1110 | _GL_FUNCDECL_SYS (getline, ssize_t, |
| 1026 | (char **restrict lineptr, size_t *restrict linesize, | 1111 | (char **restrict lineptr, size_t *restrict linesize, |
| 1027 | FILE *restrict stream) | 1112 | FILE *restrict stream), |
| 1028 | _GL_ARG_NONNULL ((1, 2, 3))); | 1113 | _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD); |
| 1029 | # endif | 1114 | # endif |
| 1030 | _GL_CXXALIAS_SYS (getline, ssize_t, | 1115 | _GL_CXXALIAS_SYS (getline, ssize_t, |
| 1031 | (char **restrict lineptr, size_t *restrict linesize, | 1116 | (char **restrict lineptr, size_t *restrict linesize, |
| @@ -1064,7 +1149,7 @@ _GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream)); | |||
| 1064 | # if @HAVE_DECL_GETW@ | 1149 | # if @HAVE_DECL_GETW@ |
| 1065 | # if defined __APPLE__ && defined __MACH__ | 1150 | # if defined __APPLE__ && defined __MACH__ |
| 1066 | /* The presence of the declaration depends on _POSIX_C_SOURCE. */ | 1151 | /* The presence of the declaration depends on _POSIX_C_SOURCE. */ |
| 1067 | _GL_FUNCDECL_SYS (getw, int, (FILE *restrict stream)); | 1152 | _GL_FUNCDECL_SYS (getw, int, (FILE *restrict stream), ); |
| 1068 | # endif | 1153 | # endif |
| 1069 | _GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream)); | 1154 | _GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream)); |
| 1070 | # endif | 1155 | # endif |
| @@ -1074,19 +1159,45 @@ _GL_CXXALIASWARN (getw); | |||
| 1074 | # endif | 1159 | # endif |
| 1075 | #endif | 1160 | #endif |
| 1076 | 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)); | ||
| 1186 | #endif | ||
| 1187 | |||
| 1077 | #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ | 1188 | #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ |
| 1078 | struct obstack; | 1189 | struct obstack; |
| 1079 | /* Grow an obstack with formatted output. Return the number of | 1190 | /* Grows an obstack with formatted output. Returns the number of |
| 1080 | 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 |
| 1081 | object should be closed with obstack_finish before use. Upon | 1192 | object should be closed with obstack_finish before use. |
| 1082 | memory allocation error, call obstack_alloc_failed_handler. Upon | 1193 | Upon memory allocation error, calls obstack_alloc_failed_handler. |
| 1083 | other error, return -1. */ | 1194 | Upon other error, returns -1. */ |
| 1084 | # if @REPLACE_OBSTACK_PRINTF@ | 1195 | # if @REPLACE_OBSTACK_PRINTF@ |
| 1085 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1196 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1086 | # define obstack_printf rpl_obstack_printf | 1197 | # define obstack_printf rpl_obstack_printf |
| 1087 | # endif | 1198 | # endif |
| 1088 | _GL_FUNCDECL_RPL (obstack_printf, int, | 1199 | _GL_FUNCDECL_RPL (obstack_printf, int, |
| 1089 | (struct obstack *obs, const char *format, ...) | 1200 | (struct obstack *obs, const char *format, ...), |
| 1090 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 1201 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 1091 | _GL_ARG_NONNULL ((1, 2))); | 1202 | _GL_ARG_NONNULL ((1, 2))); |
| 1092 | _GL_CXXALIAS_RPL (obstack_printf, int, | 1203 | _GL_CXXALIAS_RPL (obstack_printf, int, |
| @@ -1094,7 +1205,7 @@ _GL_CXXALIAS_RPL (obstack_printf, int, | |||
| 1094 | # else | 1205 | # else |
| 1095 | # if !@HAVE_DECL_OBSTACK_PRINTF@ | 1206 | # if !@HAVE_DECL_OBSTACK_PRINTF@ |
| 1096 | _GL_FUNCDECL_SYS (obstack_printf, int, | 1207 | _GL_FUNCDECL_SYS (obstack_printf, int, |
| 1097 | (struct obstack *obs, const char *format, ...) | 1208 | (struct obstack *obs, const char *format, ...), |
| 1098 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 1209 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 1099 | _GL_ARG_NONNULL ((1, 2))); | 1210 | _GL_ARG_NONNULL ((1, 2))); |
| 1100 | # endif | 1211 | # endif |
| @@ -1107,7 +1218,7 @@ _GL_CXXALIASWARN (obstack_printf); | |||
| 1107 | # define obstack_vprintf rpl_obstack_vprintf | 1218 | # define obstack_vprintf rpl_obstack_vprintf |
| 1108 | # endif | 1219 | # endif |
| 1109 | _GL_FUNCDECL_RPL (obstack_vprintf, int, | 1220 | _GL_FUNCDECL_RPL (obstack_vprintf, int, |
| 1110 | (struct obstack *obs, const char *format, va_list args) | 1221 | (struct obstack *obs, const char *format, va_list args), |
| 1111 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 1222 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1112 | _GL_ARG_NONNULL ((1, 2))); | 1223 | _GL_ARG_NONNULL ((1, 2))); |
| 1113 | _GL_CXXALIAS_RPL (obstack_vprintf, int, | 1224 | _GL_CXXALIAS_RPL (obstack_vprintf, int, |
| @@ -1115,7 +1226,7 @@ _GL_CXXALIAS_RPL (obstack_vprintf, int, | |||
| 1115 | # else | 1226 | # else |
| 1116 | # if !@HAVE_DECL_OBSTACK_PRINTF@ | 1227 | # if !@HAVE_DECL_OBSTACK_PRINTF@ |
| 1117 | _GL_FUNCDECL_SYS (obstack_vprintf, int, | 1228 | _GL_FUNCDECL_SYS (obstack_vprintf, int, |
| 1118 | (struct obstack *obs, const char *format, va_list args) | 1229 | (struct obstack *obs, const char *format, va_list args), |
| 1119 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 1230 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1120 | _GL_ARG_NONNULL ((1, 2))); | 1231 | _GL_ARG_NONNULL ((1, 2))); |
| 1121 | # endif | 1232 | # endif |
| @@ -1127,7 +1238,7 @@ _GL_CXXALIASWARN (obstack_vprintf); | |||
| 1127 | 1238 | ||
| 1128 | #if @GNULIB_PCLOSE@ | 1239 | #if @GNULIB_PCLOSE@ |
| 1129 | # if !@HAVE_PCLOSE@ | 1240 | # if !@HAVE_PCLOSE@ |
| 1130 | _GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); | 1241 | _GL_FUNCDECL_SYS (pclose, int, (FILE *stream), _GL_ARG_NONNULL ((1))); |
| 1131 | # endif | 1242 | # endif |
| 1132 | _GL_CXXALIAS_SYS (pclose, int, (FILE *stream)); | 1243 | _GL_CXXALIAS_SYS (pclose, int, (FILE *stream)); |
| 1133 | _GL_CXXALIASWARN (pclose); | 1244 | _GL_CXXALIASWARN (pclose); |
| @@ -1147,7 +1258,7 @@ _GL_WARN_ON_USE (pclose, "pclose is unportable - " | |||
| 1147 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1258 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1148 | # define perror rpl_perror | 1259 | # define perror rpl_perror |
| 1149 | # endif | 1260 | # endif |
| 1150 | _GL_FUNCDECL_RPL (perror, void, (const char *string)); | 1261 | _GL_FUNCDECL_RPL (perror, void, (const char *string), ); |
| 1151 | _GL_CXXALIAS_RPL (perror, void, (const char *string)); | 1262 | _GL_CXXALIAS_RPL (perror, void, (const char *string)); |
| 1152 | # else | 1263 | # else |
| 1153 | _GL_CXXALIAS_SYS (perror, void, (const char *string)); | 1264 | _GL_CXXALIAS_SYS (perror, void, (const char *string)); |
| @@ -1169,25 +1280,26 @@ _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " | |||
| 1169 | # define popen rpl_popen | 1280 | # define popen rpl_popen |
| 1170 | # endif | 1281 | # endif |
| 1171 | _GL_FUNCDECL_RPL (popen, FILE *, | 1282 | _GL_FUNCDECL_RPL (popen, FILE *, |
| 1172 | (const char *cmd, const char *mode) | 1283 | (const char *cmd, const char *mode), |
| 1173 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) | 1284 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) |
| 1174 | _GL_ATTRIBUTE_MALLOC); | 1285 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD); |
| 1175 | _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); | 1286 | _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); |
| 1176 | # else | 1287 | # else |
| 1177 | # if !@HAVE_POPEN@ || __GNUC__ >= 11 | 1288 | # if !@HAVE_POPEN@ || (__GNUC__ >= 11 && !defined __clang__) |
| 1178 | _GL_FUNCDECL_SYS (popen, FILE *, | 1289 | _GL_FUNCDECL_SYS (popen, FILE *, |
| 1179 | (const char *cmd, const char *mode) | 1290 | (const char *cmd, const char *mode), |
| 1180 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) | 1291 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) |
| 1181 | _GL_ATTRIBUTE_MALLOC); | 1292 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD); |
| 1182 | # endif | 1293 | # endif |
| 1183 | _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); | 1294 | _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); |
| 1184 | # endif | 1295 | # endif |
| 1185 | _GL_CXXALIASWARN (popen); | 1296 | _GL_CXXALIASWARN (popen); |
| 1186 | #else | 1297 | #else |
| 1187 | # if @GNULIB_PCLOSE@ && __GNUC__ >= 11 && !defined popen | 1298 | # if @GNULIB_PCLOSE@ \ |
| 1299 | && (__GNUC__ >= 11 && !defined __clang__) && !defined popen | ||
| 1188 | /* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */ | 1300 | /* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */ |
| 1189 | _GL_FUNCDECL_SYS (popen, FILE *, | 1301 | _GL_FUNCDECL_SYS (popen, FILE *, |
| 1190 | (const char *cmd, const char *mode) | 1302 | (const char *cmd, const char *mode), |
| 1191 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) | 1303 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) |
| 1192 | _GL_ATTRIBUTE_MALLOC); | 1304 | _GL_ATTRIBUTE_MALLOC); |
| 1193 | # endif | 1305 | # endif |
| @@ -1200,7 +1312,24 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " | |||
| 1200 | # endif | 1312 | # endif |
| 1201 | #endif | 1313 | #endif |
| 1202 | 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 | |||
| 1203 | #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. */ | ||
| 1204 | # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ | 1333 | # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ |
| 1205 | || (@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@)) |
| 1206 | # if defined __GNUC__ || defined __clang__ | 1335 | # if defined __GNUC__ || defined __clang__ |
| @@ -1212,14 +1341,14 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " | |||
| 1212 | _GL_FUNCDECL_RPL_1 (__printf__, int, | 1341 | _GL_FUNCDECL_RPL_1 (__printf__, int, |
| 1213 | (const char *restrict format, ...) | 1342 | (const char *restrict format, ...) |
| 1214 | __asm__ (@ASM_SYMBOL_PREFIX@ | 1343 | __asm__ (@ASM_SYMBOL_PREFIX@ |
| 1215 | _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) | 1344 | _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)), |
| 1216 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) | 1345 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) |
| 1217 | _GL_ARG_NONNULL ((1))); | 1346 | _GL_ARG_NONNULL ((1))); |
| 1218 | # else | 1347 | # else |
| 1219 | _GL_FUNCDECL_RPL_1 (__printf__, int, | 1348 | _GL_FUNCDECL_RPL_1 (__printf__, int, |
| 1220 | (const char *restrict format, ...) | 1349 | (const char *restrict format, ...) |
| 1221 | __asm__ (@ASM_SYMBOL_PREFIX@ | 1350 | __asm__ (@ASM_SYMBOL_PREFIX@ |
| 1222 | _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) | 1351 | _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)), |
| 1223 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2) | 1352 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2) |
| 1224 | _GL_ARG_NONNULL ((1))); | 1353 | _GL_ARG_NONNULL ((1))); |
| 1225 | # endif | 1354 | # endif |
| @@ -1229,7 +1358,7 @@ _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); | |||
| 1229 | # define printf rpl_printf | 1358 | # define printf rpl_printf |
| 1230 | # endif | 1359 | # endif |
| 1231 | _GL_FUNCDECL_RPL (printf, int, | 1360 | _GL_FUNCDECL_RPL (printf, int, |
| 1232 | (const char *restrict format, ...) | 1361 | (const char *restrict format, ...), |
| 1233 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) | 1362 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) |
| 1234 | _GL_ARG_NONNULL ((1))); | 1363 | _GL_ARG_NONNULL ((1))); |
| 1235 | _GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...)); | 1364 | _GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...)); |
| @@ -1241,6 +1370,11 @@ _GL_CXXALIAS_SYS (printf, int, (const char *restrict format, ...)); | |||
| 1241 | # if __GLIBC__ >= 2 | 1370 | # if __GLIBC__ >= 2 |
| 1242 | _GL_CXXALIASWARN (printf); | 1371 | _GL_CXXALIASWARN (printf); |
| 1243 | # 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 | ||
| 1244 | #endif | 1378 | #endif |
| 1245 | #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK | 1379 | #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK |
| 1246 | # if !GNULIB_overrides_printf | 1380 | # if !GNULIB_overrides_printf |
| @@ -1258,7 +1392,7 @@ _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - " | |||
| 1258 | # undef putc | 1392 | # undef putc |
| 1259 | # define putc rpl_fputc | 1393 | # define putc rpl_fputc |
| 1260 | # endif | 1394 | # endif |
| 1261 | _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))); |
| 1262 | _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)); |
| 1263 | # else | 1397 | # else |
| 1264 | _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); | 1398 | _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); |
| @@ -1274,7 +1408,7 @@ _GL_CXXALIASWARN (putc); | |||
| 1274 | # undef putchar | 1408 | # undef putchar |
| 1275 | # define putchar rpl_putchar | 1409 | # define putchar rpl_putchar |
| 1276 | # endif | 1410 | # endif |
| 1277 | _GL_FUNCDECL_RPL (putchar, int, (int c)); | 1411 | _GL_FUNCDECL_RPL (putchar, int, (int c), ); |
| 1278 | _GL_CXXALIAS_RPL (putchar, int, (int c)); | 1412 | _GL_CXXALIAS_RPL (putchar, int, (int c)); |
| 1279 | # else | 1413 | # else |
| 1280 | _GL_CXXALIAS_SYS (putchar, int, (int c)); | 1414 | _GL_CXXALIAS_SYS (putchar, int, (int c)); |
| @@ -1290,7 +1424,7 @@ _GL_CXXALIASWARN (putchar); | |||
| 1290 | # undef puts | 1424 | # undef puts |
| 1291 | # define puts rpl_puts | 1425 | # define puts rpl_puts |
| 1292 | # endif | 1426 | # endif |
| 1293 | _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))); |
| 1294 | _GL_CXXALIAS_RPL (puts, int, (const char *string)); | 1428 | _GL_CXXALIAS_RPL (puts, int, (const char *string)); |
| 1295 | # else | 1429 | # else |
| 1296 | _GL_CXXALIAS_SYS (puts, int, (const char *string)); | 1430 | _GL_CXXALIAS_SYS (puts, int, (const char *string)); |
| @@ -1314,7 +1448,7 @@ _GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream)); | |||
| 1314 | # if @HAVE_DECL_PUTW@ | 1448 | # if @HAVE_DECL_PUTW@ |
| 1315 | # if defined __APPLE__ && defined __MACH__ | 1449 | # if defined __APPLE__ && defined __MACH__ |
| 1316 | /* The presence of the declaration depends on _POSIX_C_SOURCE. */ | 1450 | /* The presence of the declaration depends on _POSIX_C_SOURCE. */ |
| 1317 | _GL_FUNCDECL_SYS (putw, int, (int w, FILE *restrict stream)); | 1451 | _GL_FUNCDECL_SYS (putw, int, (int w, FILE *restrict stream), ); |
| 1318 | # endif | 1452 | # endif |
| 1319 | _GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream)); | 1453 | _GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream)); |
| 1320 | # endif | 1454 | # endif |
| @@ -1330,7 +1464,7 @@ _GL_CXXALIASWARN (putw); | |||
| 1330 | # undef remove | 1464 | # undef remove |
| 1331 | # define remove rpl_remove | 1465 | # define remove rpl_remove |
| 1332 | # endif | 1466 | # endif |
| 1333 | _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))); |
| 1334 | _GL_CXXALIAS_RPL (remove, int, (const char *name)); | 1468 | _GL_CXXALIAS_RPL (remove, int, (const char *name)); |
| 1335 | # else | 1469 | # else |
| 1336 | _GL_CXXALIAS_SYS (remove, int, (const char *name)); | 1470 | _GL_CXXALIAS_SYS (remove, int, (const char *name)); |
| @@ -1352,7 +1486,7 @@ _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - " | |||
| 1352 | # define rename rpl_rename | 1486 | # define rename rpl_rename |
| 1353 | # endif | 1487 | # endif |
| 1354 | _GL_FUNCDECL_RPL (rename, int, | 1488 | _GL_FUNCDECL_RPL (rename, int, |
| 1355 | (const char *old_filename, const char *new_filename) | 1489 | (const char *old_filename, const char *new_filename), |
| 1356 | _GL_ARG_NONNULL ((1, 2))); | 1490 | _GL_ARG_NONNULL ((1, 2))); |
| 1357 | _GL_CXXALIAS_RPL (rename, int, | 1491 | _GL_CXXALIAS_RPL (rename, int, |
| 1358 | (const char *old_filename, const char *new_filename)); | 1492 | (const char *old_filename, const char *new_filename)); |
| @@ -1377,14 +1511,14 @@ _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - " | |||
| 1377 | # define renameat rpl_renameat | 1511 | # define renameat rpl_renameat |
| 1378 | # endif | 1512 | # endif |
| 1379 | _GL_FUNCDECL_RPL (renameat, int, | 1513 | _GL_FUNCDECL_RPL (renameat, int, |
| 1380 | (int fd1, char const *file1, int fd2, char const *file2) | 1514 | (int fd1, char const *file1, int fd2, char const *file2), |
| 1381 | _GL_ARG_NONNULL ((2, 4))); | 1515 | _GL_ARG_NONNULL ((2, 4))); |
| 1382 | _GL_CXXALIAS_RPL (renameat, int, | 1516 | _GL_CXXALIAS_RPL (renameat, int, |
| 1383 | (int fd1, char const *file1, int fd2, char const *file2)); | 1517 | (int fd1, char const *file1, int fd2, char const *file2)); |
| 1384 | # else | 1518 | # else |
| 1385 | # if !@HAVE_RENAMEAT@ | 1519 | # if !@HAVE_RENAMEAT@ |
| 1386 | _GL_FUNCDECL_SYS (renameat, int, | 1520 | _GL_FUNCDECL_SYS (renameat, int, |
| 1387 | (int fd1, char const *file1, int fd2, char const *file2) | 1521 | (int fd1, char const *file1, int fd2, char const *file2), |
| 1388 | _GL_ARG_NONNULL ((2, 4))); | 1522 | _GL_ARG_NONNULL ((2, 4))); |
| 1389 | # endif | 1523 | # endif |
| 1390 | _GL_CXXALIAS_SYS (renameat, int, | 1524 | _GL_CXXALIAS_SYS (renameat, int, |
| @@ -1410,18 +1544,18 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - " | |||
| 1410 | _GL_FUNCDECL_RPL_1 (__scanf__, int, | 1544 | _GL_FUNCDECL_RPL_1 (__scanf__, int, |
| 1411 | (const char *restrict format, ...) | 1545 | (const char *restrict format, ...) |
| 1412 | __asm__ (@ASM_SYMBOL_PREFIX@ | 1546 | __asm__ (@ASM_SYMBOL_PREFIX@ |
| 1413 | _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)) | 1547 | _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)), |
| 1414 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) | 1548 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) |
| 1415 | _GL_ARG_NONNULL ((1))); | 1549 | _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); |
| 1416 | _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...)); | 1550 | _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...)); |
| 1417 | # else | 1551 | # else |
| 1418 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1552 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1419 | # undef scanf | 1553 | # undef scanf |
| 1420 | # define scanf rpl_scanf | 1554 | # define scanf rpl_scanf |
| 1421 | # endif | 1555 | # endif |
| 1422 | _GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...) | 1556 | _GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...), |
| 1423 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) | 1557 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) |
| 1424 | _GL_ARG_NONNULL ((1))); | 1558 | _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); |
| 1425 | _GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...)); | 1559 | _GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...)); |
| 1426 | # endif | 1560 | # endif |
| 1427 | # else | 1561 | # else |
| @@ -1432,7 +1566,31 @@ _GL_CXXALIASWARN (scanf); | |||
| 1432 | # endif | 1566 | # endif |
| 1433 | #endif | 1567 | #endif |
| 1434 | 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 | |||
| 1435 | #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. */ | ||
| 1436 | # if @REPLACE_SNPRINTF@ | 1594 | # if @REPLACE_SNPRINTF@ |
| 1437 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1595 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1438 | # define snprintf rpl_snprintf | 1596 | # define snprintf rpl_snprintf |
| @@ -1440,7 +1598,7 @@ _GL_CXXALIASWARN (scanf); | |||
| 1440 | # define GNULIB_overrides_snprintf 1 | 1598 | # define GNULIB_overrides_snprintf 1 |
| 1441 | _GL_FUNCDECL_RPL (snprintf, int, | 1599 | _GL_FUNCDECL_RPL (snprintf, int, |
| 1442 | (char *restrict str, size_t size, | 1600 | (char *restrict str, size_t size, |
| 1443 | const char *restrict format, ...) | 1601 | const char *restrict format, ...), |
| 1444 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) | 1602 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) |
| 1445 | _GL_ARG_NONNULL ((3))); | 1603 | _GL_ARG_NONNULL ((3))); |
| 1446 | _GL_CXXALIAS_RPL (snprintf, int, | 1604 | _GL_CXXALIAS_RPL (snprintf, int, |
| @@ -1450,7 +1608,7 @@ _GL_CXXALIAS_RPL (snprintf, int, | |||
| 1450 | # if !@HAVE_DECL_SNPRINTF@ | 1608 | # if !@HAVE_DECL_SNPRINTF@ |
| 1451 | _GL_FUNCDECL_SYS (snprintf, int, | 1609 | _GL_FUNCDECL_SYS (snprintf, int, |
| 1452 | (char *restrict str, size_t size, | 1610 | (char *restrict str, size_t size, |
| 1453 | const char *restrict format, ...) | 1611 | const char *restrict format, ...), |
| 1454 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) | 1612 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) |
| 1455 | _GL_ARG_NONNULL ((3))); | 1613 | _GL_ARG_NONNULL ((3))); |
| 1456 | # endif | 1614 | # endif |
| @@ -1469,6 +1627,23 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - " | |||
| 1469 | # endif | 1627 | # endif |
| 1470 | #endif | 1628 | #endif |
| 1471 | 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 | |||
| 1472 | /* 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 |
| 1473 | (for example, OpenBSD issues a link warning for it), | 1648 | (for example, OpenBSD issues a link warning for it), |
| 1474 | since it can cause security holes due to buffer overruns. | 1649 | since it can cause security holes due to buffer overruns. |
| @@ -1479,13 +1654,16 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - " | |||
| 1479 | GNULIB_POSIXCHECK is defined. */ | 1654 | GNULIB_POSIXCHECK is defined. */ |
| 1480 | 1655 | ||
| 1481 | #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. */ | ||
| 1482 | # if @REPLACE_SPRINTF@ | 1660 | # if @REPLACE_SPRINTF@ |
| 1483 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1661 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1484 | # define sprintf rpl_sprintf | 1662 | # define sprintf rpl_sprintf |
| 1485 | # endif | 1663 | # endif |
| 1486 | # define GNULIB_overrides_sprintf 1 | 1664 | # define GNULIB_overrides_sprintf 1 |
| 1487 | _GL_FUNCDECL_RPL (sprintf, int, | 1665 | _GL_FUNCDECL_RPL (sprintf, int, |
| 1488 | (char *restrict str, const char *restrict format, ...) | 1666 | (char *restrict str, const char *restrict format, ...), |
| 1489 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 1667 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 1490 | _GL_ARG_NONNULL ((1, 2))); | 1668 | _GL_ARG_NONNULL ((1, 2))); |
| 1491 | _GL_CXXALIAS_RPL (sprintf, int, | 1669 | _GL_CXXALIAS_RPL (sprintf, int, |
| @@ -1526,16 +1704,18 @@ _GL_CXXALIASWARN (tempnam); | |||
| 1526 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1704 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1527 | # define tmpfile rpl_tmpfile | 1705 | # define tmpfile rpl_tmpfile |
| 1528 | # endif | 1706 | # endif |
| 1529 | _GL_FUNCDECL_RPL (tmpfile, FILE *, (void) | 1707 | _GL_FUNCDECL_RPL (tmpfile, FILE *, (void), |
| 1530 | _GL_ATTRIBUTE_DEALLOC (fclose, 1) | 1708 | _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 1531 | _GL_ATTRIBUTE_MALLOC); | 1709 | _GL_ATTRIBUTE_MALLOC |
| 1710 | _GL_ATTRIBUTE_NODISCARD); | ||
| 1532 | _GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); | 1711 | _GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); |
| 1533 | # else | 1712 | # else |
| 1534 | # if __GNUC__ >= 11 | 1713 | # if __GNUC__ >= 11 && !defined __clang__ |
| 1535 | /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ | 1714 | /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ |
| 1536 | _GL_FUNCDECL_SYS (tmpfile, FILE *, (void) | 1715 | _GL_FUNCDECL_SYS (tmpfile, FILE *, (void), |
| 1537 | _GL_ATTRIBUTE_DEALLOC (fclose, 1) | 1716 | _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 1538 | _GL_ATTRIBUTE_MALLOC); | 1717 | _GL_ATTRIBUTE_MALLOC |
| 1718 | _GL_ATTRIBUTE_NODISCARD); | ||
| 1539 | # endif | 1719 | # endif |
| 1540 | _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); | 1720 | _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); |
| 1541 | # endif | 1721 | # endif |
| @@ -1543,9 +1723,10 @@ _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); | |||
| 1543 | _GL_CXXALIASWARN (tmpfile); | 1723 | _GL_CXXALIASWARN (tmpfile); |
| 1544 | # endif | 1724 | # endif |
| 1545 | #else | 1725 | #else |
| 1546 | # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile | 1726 | # if @GNULIB_FCLOSE@ \ |
| 1727 | && (__GNUC__ >= 11 && !defined __clang__) && !defined tmpfile | ||
| 1547 | /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ | 1728 | /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ |
| 1548 | _GL_FUNCDECL_SYS (tmpfile, FILE *, (void) | 1729 | _GL_FUNCDECL_SYS (tmpfile, FILE *, (void), |
| 1549 | _GL_ATTRIBUTE_DEALLOC (fclose, 1) | 1730 | _GL_ATTRIBUTE_DEALLOC (fclose, 1) |
| 1550 | _GL_ATTRIBUTE_MALLOC); | 1731 | _GL_ATTRIBUTE_MALLOC); |
| 1551 | # endif | 1732 | # endif |
| @@ -1558,6 +1739,31 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " | |||
| 1558 | # endif | 1739 | # endif |
| 1559 | #endif | 1740 | #endif |
| 1560 | 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 | |||
| 1561 | #if @GNULIB_VASPRINTF@ | 1767 | #if @GNULIB_VASPRINTF@ |
| 1562 | /* Write formatted output to a string dynamically allocated with malloc(). | 1768 | /* Write formatted output to a string dynamically allocated with malloc(). |
| 1563 | 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 |
| @@ -1569,17 +1775,19 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " | |||
| 1569 | # endif | 1775 | # endif |
| 1570 | # define GNULIB_overrides_asprintf | 1776 | # define GNULIB_overrides_asprintf |
| 1571 | _GL_FUNCDECL_RPL (asprintf, int, | 1777 | _GL_FUNCDECL_RPL (asprintf, int, |
| 1572 | (char **result, const char *format, ...) | 1778 | (char **result, const char *format, ...), |
| 1573 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 1779 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 1574 | _GL_ARG_NONNULL ((1, 2))); | 1780 | _GL_ARG_NONNULL ((1, 2)) |
| 1781 | _GL_ATTRIBUTE_NODISCARD); | ||
| 1575 | _GL_CXXALIAS_RPL (asprintf, int, | 1782 | _GL_CXXALIAS_RPL (asprintf, int, |
| 1576 | (char **result, const char *format, ...)); | 1783 | (char **result, const char *format, ...)); |
| 1577 | # else | 1784 | # else |
| 1578 | # if !@HAVE_VASPRINTF@ | 1785 | # if !@HAVE_VASPRINTF@ |
| 1579 | _GL_FUNCDECL_SYS (asprintf, int, | 1786 | _GL_FUNCDECL_SYS (asprintf, int, |
| 1580 | (char **result, const char *format, ...) | 1787 | (char **result, const char *format, ...), |
| 1581 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) | 1788 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) |
| 1582 | _GL_ARG_NONNULL ((1, 2))); | 1789 | _GL_ARG_NONNULL ((1, 2)) |
| 1790 | _GL_ATTRIBUTE_NODISCARD); | ||
| 1583 | # endif | 1791 | # endif |
| 1584 | _GL_CXXALIAS_SYS (asprintf, int, | 1792 | _GL_CXXALIAS_SYS (asprintf, int, |
| 1585 | (char **result, const char *format, ...)); | 1793 | (char **result, const char *format, ...)); |
| @@ -1591,17 +1799,19 @@ _GL_CXXALIASWARN (asprintf); | |||
| 1591 | # endif | 1799 | # endif |
| 1592 | # define GNULIB_overrides_vasprintf 1 | 1800 | # define GNULIB_overrides_vasprintf 1 |
| 1593 | _GL_FUNCDECL_RPL (vasprintf, int, | 1801 | _GL_FUNCDECL_RPL (vasprintf, int, |
| 1594 | (char **result, const char *format, va_list args) | 1802 | (char **result, const char *format, va_list args), |
| 1595 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 1803 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1596 | _GL_ARG_NONNULL ((1, 2))); | 1804 | _GL_ARG_NONNULL ((1, 2)) |
| 1805 | _GL_ATTRIBUTE_NODISCARD); | ||
| 1597 | _GL_CXXALIAS_RPL (vasprintf, int, | 1806 | _GL_CXXALIAS_RPL (vasprintf, int, |
| 1598 | (char **result, const char *format, va_list args)); | 1807 | (char **result, const char *format, va_list args)); |
| 1599 | # else | 1808 | # else |
| 1600 | # if !@HAVE_VASPRINTF@ | 1809 | # if !@HAVE_VASPRINTF@ |
| 1601 | _GL_FUNCDECL_SYS (vasprintf, int, | 1810 | _GL_FUNCDECL_SYS (vasprintf, int, |
| 1602 | (char **result, const char *format, va_list args) | 1811 | (char **result, const char *format, va_list args), |
| 1603 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 1812 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1604 | _GL_ARG_NONNULL ((1, 2))); | 1813 | _GL_ARG_NONNULL ((1, 2)) |
| 1814 | _GL_ATTRIBUTE_NODISCARD); | ||
| 1605 | # endif | 1815 | # endif |
| 1606 | _GL_CXXALIAS_SYS (vasprintf, int, | 1816 | _GL_CXXALIAS_SYS (vasprintf, int, |
| 1607 | (char **result, const char *format, va_list args)); | 1817 | (char **result, const char *format, va_list args)); |
| @@ -1609,13 +1819,32 @@ _GL_CXXALIAS_SYS (vasprintf, int, | |||
| 1609 | _GL_CXXALIASWARN (vasprintf); | 1819 | _GL_CXXALIASWARN (vasprintf); |
| 1610 | #endif | 1820 | #endif |
| 1611 | 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 | |||
| 1612 | #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. */ | ||
| 1613 | # if @REPLACE_VDPRINTF@ | 1842 | # if @REPLACE_VDPRINTF@ |
| 1614 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1843 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1615 | # define vdprintf rpl_vdprintf | 1844 | # define vdprintf rpl_vdprintf |
| 1616 | # endif | 1845 | # endif |
| 1617 | _GL_FUNCDECL_RPL (vdprintf, int, | 1846 | _GL_FUNCDECL_RPL (vdprintf, int, |
| 1618 | (int fd, const char *restrict format, va_list args) | 1847 | (int fd, const char *restrict format, va_list args), |
| 1619 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 1848 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1620 | _GL_ARG_NONNULL ((2))); | 1849 | _GL_ARG_NONNULL ((2))); |
| 1621 | _GL_CXXALIAS_RPL (vdprintf, int, | 1850 | _GL_CXXALIAS_RPL (vdprintf, int, |
| @@ -1623,7 +1852,7 @@ _GL_CXXALIAS_RPL (vdprintf, int, | |||
| 1623 | # else | 1852 | # else |
| 1624 | # if !@HAVE_VDPRINTF@ | 1853 | # if !@HAVE_VDPRINTF@ |
| 1625 | _GL_FUNCDECL_SYS (vdprintf, int, | 1854 | _GL_FUNCDECL_SYS (vdprintf, int, |
| 1626 | (int fd, const char *restrict format, va_list args) | 1855 | (int fd, const char *restrict format, va_list args), |
| 1627 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 1856 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1628 | _GL_ARG_NONNULL ((2))); | 1857 | _GL_ARG_NONNULL ((2))); |
| 1629 | # endif | 1858 | # endif |
| @@ -1643,7 +1872,28 @@ _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " | |||
| 1643 | # endif | 1872 | # endif |
| 1644 | #endif | 1873 | #endif |
| 1645 | 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 | |||
| 1646 | #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. */ | ||
| 1647 | # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \ | 1897 | # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \ |
| 1648 | || (@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@)) |
| 1649 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1899 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| @@ -1653,13 +1903,13 @@ _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " | |||
| 1653 | # if @GNULIB_VFPRINTF_POSIX@ | 1903 | # if @GNULIB_VFPRINTF_POSIX@ |
| 1654 | _GL_FUNCDECL_RPL (vfprintf, int, | 1904 | _GL_FUNCDECL_RPL (vfprintf, int, |
| 1655 | (FILE *restrict fp, | 1905 | (FILE *restrict fp, |
| 1656 | const char *restrict format, va_list args) | 1906 | const char *restrict format, va_list args), |
| 1657 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 1907 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1658 | _GL_ARG_NONNULL ((1, 2))); | 1908 | _GL_ARG_NONNULL ((1, 2))); |
| 1659 | # else | 1909 | # else |
| 1660 | _GL_FUNCDECL_RPL (vfprintf, int, | 1910 | _GL_FUNCDECL_RPL (vfprintf, int, |
| 1661 | (FILE *restrict fp, | 1911 | (FILE *restrict fp, |
| 1662 | const char *restrict format, va_list args) | 1912 | const char *restrict format, va_list args), |
| 1663 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0) | 1913 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0) |
| 1664 | _GL_ARG_NONNULL ((1, 2))); | 1914 | _GL_ARG_NONNULL ((1, 2))); |
| 1665 | # endif | 1915 | # endif |
| @@ -1677,6 +1927,11 @@ _GL_CXXALIAS_SYS_CAST (vfprintf, int, | |||
| 1677 | # if __GLIBC__ >= 2 | 1927 | # if __GLIBC__ >= 2 |
| 1678 | _GL_CXXALIASWARN (vfprintf); | 1928 | _GL_CXXALIASWARN (vfprintf); |
| 1679 | # 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 | ||
| 1680 | #endif | 1935 | #endif |
| 1681 | #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK | 1936 | #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK |
| 1682 | # if !GNULIB_overrides_vfprintf | 1937 | # if !GNULIB_overrides_vfprintf |
| @@ -1696,9 +1951,9 @@ _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - " | |||
| 1696 | # endif | 1951 | # endif |
| 1697 | _GL_FUNCDECL_RPL (vfscanf, int, | 1952 | _GL_FUNCDECL_RPL (vfscanf, int, |
| 1698 | (FILE *restrict stream, | 1953 | (FILE *restrict stream, |
| 1699 | const char *restrict format, va_list args) | 1954 | const char *restrict format, va_list args), |
| 1700 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0) | 1955 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0) |
| 1701 | _GL_ARG_NONNULL ((1, 2))); | 1956 | _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD); |
| 1702 | _GL_CXXALIAS_RPL (vfscanf, int, | 1957 | _GL_CXXALIAS_RPL (vfscanf, int, |
| 1703 | (FILE *restrict stream, | 1958 | (FILE *restrict stream, |
| 1704 | const char *restrict format, va_list args)); | 1959 | const char *restrict format, va_list args)); |
| @@ -1712,7 +1967,26 @@ _GL_CXXALIASWARN (vfscanf); | |||
| 1712 | # endif | 1967 | # endif |
| 1713 | #endif | 1968 | #endif |
| 1714 | 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 | |||
| 1715 | #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. */ | ||
| 1716 | # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \ | 1990 | # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \ |
| 1717 | || (@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@)) |
| 1718 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 1992 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| @@ -1720,11 +1994,11 @@ _GL_CXXALIASWARN (vfscanf); | |||
| 1720 | # endif | 1994 | # endif |
| 1721 | # define GNULIB_overrides_vprintf 1 | 1995 | # define GNULIB_overrides_vprintf 1 |
| 1722 | # if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ | 1996 | # if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ |
| 1723 | _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), |
| 1724 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0) | 1998 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0) |
| 1725 | _GL_ARG_NONNULL ((1))); | 1999 | _GL_ARG_NONNULL ((1))); |
| 1726 | # else | 2000 | # else |
| 1727 | _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), |
| 1728 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0) | 2002 | _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0) |
| 1729 | _GL_ARG_NONNULL ((1))); | 2003 | _GL_ARG_NONNULL ((1))); |
| 1730 | # endif | 2004 | # endif |
| @@ -1739,6 +2013,11 @@ _GL_CXXALIAS_SYS_CAST (vprintf, int, | |||
| 1739 | # if __GLIBC__ >= 2 | 2013 | # if __GLIBC__ >= 2 |
| 1740 | _GL_CXXALIASWARN (vprintf); | 2014 | _GL_CXXALIASWARN (vprintf); |
| 1741 | # 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 | ||
| 1742 | #endif | 2021 | #endif |
| 1743 | #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK | 2022 | #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK |
| 1744 | # if !GNULIB_overrides_vprintf | 2023 | # if !GNULIB_overrides_vprintf |
| @@ -1756,9 +2035,9 @@ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - " | |||
| 1756 | # undef vscanf | 2035 | # undef vscanf |
| 1757 | # define vscanf rpl_vscanf | 2036 | # define vscanf rpl_vscanf |
| 1758 | # endif | 2037 | # endif |
| 1759 | _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), |
| 1760 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0) | 2039 | _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0) |
| 1761 | _GL_ARG_NONNULL ((1))); | 2040 | _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD); |
| 1762 | _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)); |
| 1763 | # else | 2042 | # else |
| 1764 | _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)); |
| @@ -1768,7 +2047,31 @@ _GL_CXXALIASWARN (vscanf); | |||
| 1768 | # endif | 2047 | # endif |
| 1769 | #endif | 2048 | #endif |
| 1770 | 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 | |||
| 1771 | #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. */ | ||
| 1772 | # if @REPLACE_VSNPRINTF@ | 2075 | # if @REPLACE_VSNPRINTF@ |
| 1773 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 2076 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1774 | # define vsnprintf rpl_vsnprintf | 2077 | # define vsnprintf rpl_vsnprintf |
| @@ -1776,7 +2079,7 @@ _GL_CXXALIASWARN (vscanf); | |||
| 1776 | # define GNULIB_overrides_vsnprintf 1 | 2079 | # define GNULIB_overrides_vsnprintf 1 |
| 1777 | _GL_FUNCDECL_RPL (vsnprintf, int, | 2080 | _GL_FUNCDECL_RPL (vsnprintf, int, |
| 1778 | (char *restrict str, size_t size, | 2081 | (char *restrict str, size_t size, |
| 1779 | const char *restrict format, va_list args) | 2082 | const char *restrict format, va_list args), |
| 1780 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) | 2083 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) |
| 1781 | _GL_ARG_NONNULL ((3))); | 2084 | _GL_ARG_NONNULL ((3))); |
| 1782 | _GL_CXXALIAS_RPL (vsnprintf, int, | 2085 | _GL_CXXALIAS_RPL (vsnprintf, int, |
| @@ -1786,7 +2089,7 @@ _GL_CXXALIAS_RPL (vsnprintf, int, | |||
| 1786 | # if !@HAVE_DECL_VSNPRINTF@ | 2089 | # if !@HAVE_DECL_VSNPRINTF@ |
| 1787 | _GL_FUNCDECL_SYS (vsnprintf, int, | 2090 | _GL_FUNCDECL_SYS (vsnprintf, int, |
| 1788 | (char *restrict str, size_t size, | 2091 | (char *restrict str, size_t size, |
| 1789 | const char *restrict format, va_list args) | 2092 | const char *restrict format, va_list args), |
| 1790 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) | 2093 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) |
| 1791 | _GL_ARG_NONNULL ((3))); | 2094 | _GL_ARG_NONNULL ((3))); |
| 1792 | # endif | 2095 | # endif |
| @@ -1805,7 +2108,27 @@ _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " | |||
| 1805 | # endif | 2108 | # endif |
| 1806 | #endif | 2109 | #endif |
| 1807 | 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 | |||
| 1808 | #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. */ | ||
| 1809 | # if @REPLACE_VSPRINTF@ | 2132 | # if @REPLACE_VSPRINTF@ |
| 1810 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 2133 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1811 | # define vsprintf rpl_vsprintf | 2134 | # define vsprintf rpl_vsprintf |
| @@ -1813,7 +2136,7 @@ _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " | |||
| 1813 | # define GNULIB_overrides_vsprintf 1 | 2136 | # define GNULIB_overrides_vsprintf 1 |
| 1814 | _GL_FUNCDECL_RPL (vsprintf, int, | 2137 | _GL_FUNCDECL_RPL (vsprintf, int, |
| 1815 | (char *restrict str, | 2138 | (char *restrict str, |
| 1816 | const char *restrict format, va_list args) | 2139 | const char *restrict format, va_list args), |
| 1817 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) | 2140 | _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) |
| 1818 | _GL_ARG_NONNULL ((1, 2))); | 2141 | _GL_ARG_NONNULL ((1, 2))); |
| 1819 | _GL_CXXALIAS_RPL (vsprintf, int, | 2142 | _GL_CXXALIAS_RPL (vsprintf, int, |
