summaryrefslogtreecommitdiffstats
path: root/gl/stdio.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/stdio.in.h')
-rw-r--r--gl/stdio.in.h667
1 files changed, 485 insertions, 182 deletions
diff --git a/gl/stdio.in.h b/gl/stdio.in.h
index 35b9f748..33b0b8e4 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-2026 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,14 +20,9 @@
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
27 <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
28 <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
29 In this situation, the functions are not yet declared, therefore we cannot
30 provide the C++ aliases. */
31 26
32#@INCLUDE_NEXT@ @NEXT_STDIO_H@ 27#@INCLUDE_NEXT@ @NEXT_STDIO_H@
33 28
@@ -48,12 +43,12 @@
48# endif 43# endif
49#endif 44#endif
50 45
51#define _GL_ALREADY_INCLUDING_STDIO_H 46#define _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H
52 47
53/* The include_next requires a split double-inclusion guard. */ 48/* The include_next requires a split double-inclusion guard. */
54#@INCLUDE_NEXT@ @NEXT_STDIO_H@ 49#@INCLUDE_NEXT@ @NEXT_STDIO_H@
55 50
56#undef _GL_ALREADY_INCLUDING_STDIO_H 51#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H
57 52
58#ifdef _GL_DEFINED__POSIX_C_SOURCE 53#ifdef _GL_DEFINED__POSIX_C_SOURCE
59# undef _GL_DEFINED__POSIX_C_SOURCE 54# undef _GL_DEFINED__POSIX_C_SOURCE
@@ -64,8 +59,8 @@
64#define _@GUARD_PREFIX@_STDIO_H 59#define _@GUARD_PREFIX@_STDIO_H
65 60
66/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT, 61/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT,
67 _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK, 62 _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW,
68 HAVE_RAW_DECL_*. */ 63 GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
69#if !_GL_CONFIG_H_INCLUDED 64#if !_GL_CONFIG_H_INCLUDED
70 #error "Please include config.h first." 65 #error "Please include config.h first."
71#endif 66#endif
@@ -77,7 +72,8 @@
77 72
78/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8 73/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8
79 and eglibc 2.11.2. 74 and eglibc 2.11.2.
80 May also define off_t to a 64-bit type on native Windows. */ 75 May also define off_t to a 64-bit type on native Windows.
76 Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */
81#include <sys/types.h> 77#include <sys/types.h>
82 78
83/* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */ 79/* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */
@@ -119,7 +115,7 @@
119 that can be freed by passing them as the Ith argument to the 115 that can be freed by passing them as the Ith argument to the
120 function F. */ 116 function F. */
121#ifndef _GL_ATTRIBUTE_DEALLOC 117#ifndef _GL_ATTRIBUTE_DEALLOC
122# if __GNUC__ >= 11 118# if __GNUC__ >= 11 && !defined __clang__
123# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) 119# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
124# else 120# else
125# define _GL_ATTRIBUTE_DEALLOC(f, i) 121# define _GL_ATTRIBUTE_DEALLOC(f, i)
@@ -154,7 +150,7 @@
154 */ 150 */
155#ifndef _GL_ATTRIBUTE_NOTHROW 151#ifndef _GL_ATTRIBUTE_NOTHROW
156# if defined __cplusplus 152# if defined __cplusplus
157# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 153# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
158# if __cplusplus >= 201103L 154# if __cplusplus >= 201103L
159# define _GL_ATTRIBUTE_NOTHROW noexcept (true) 155# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
160# else 156# else
@@ -177,7 +173,7 @@
177 standardized by ISO C99 and POSIX. 173 standardized by ISO C99 and POSIX.
178 _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */ 174 _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */
179/* __gnu_printf__ is supported in GCC >= 4.4. */ 175/* __gnu_printf__ is supported in GCC >= 4.4. */
180#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) 176#if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4) && !defined __clang__
181# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__ 177# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__
182#else 178#else
183# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__ 179# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__
@@ -268,10 +264,6 @@
268 - with MSVC ucrt: "[-]nan" or "[-]nan(ind)" or "[-]nan(snan)", 264 - with MSVC ucrt: "[-]nan" or "[-]nan(ind)" or "[-]nan(snan)",
269 - with mingw: "[-]1.#IND" or "[-]1.#QNAN". */ 265 - with mingw: "[-]1.#IND" or "[-]1.#QNAN". */
270# define _PRINTF_NAN_LEN_MAX 10 266# define _PRINTF_NAN_LEN_MAX 10
271# elif defined __sgi
272/* On IRIX, the output typically is "[-]nan0xNNNNNNNN" with 8 hexadecimal
273 digits. */
274# define _PRINTF_NAN_LEN_MAX 14
275# else 267# else
276/* We don't know, but 32 should be a safe maximum. */ 268/* We don't know, but 32 should be a safe maximum. */
277# define _PRINTF_NAN_LEN_MAX 32 269# define _PRINTF_NAN_LEN_MAX 32
@@ -279,18 +271,64 @@
279#endif 271#endif
280 272
281 273
274#if (defined _WIN32 && !defined __CYGWIN__) && !defined _UCRT
275/* Workarounds against msvcrt bugs. */
276_GL_FUNCDECL_SYS (gl_consolesafe_fwrite, size_t,
277 (const void *ptr, size_t size, size_t nmemb, FILE *fp),
278 _GL_ARG_NONNULL ((1, 4)));
279# if defined __MINGW32__
280_GL_FUNCDECL_SYS (gl_consolesafe_fprintf, int,
281 (FILE *restrict fp, const char *restrict format, ...),
282 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
283 _GL_ARG_NONNULL ((1, 2)));
284_GL_FUNCDECL_SYS (gl_consolesafe_printf, int,
285 (const char *restrict format, ...),
286 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
287 _GL_ARG_NONNULL ((1)));
288_GL_FUNCDECL_SYS (gl_consolesafe_vfprintf, int,
289 (FILE *restrict fp,
290 const char *restrict format, va_list args),
291 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
292 _GL_ARG_NONNULL ((1, 2)));
293_GL_FUNCDECL_SYS (gl_consolesafe_vprintf, int,
294 (const char *restrict format, va_list args),
295 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
296 _GL_ARG_NONNULL ((1)));
297# endif
298#endif
299
300
301#if @GNULIB_DZPRINTF@
302/* Prints formatted output to file descriptor FD.
303 Returns the number of bytes written to the file descriptor. Upon
304 failure, returns -1 with errno set.
305 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
306 Therefore, if the format string is valid and does not use %ls/%lc
307 directives nor widths, the only possible failure codes are ENOMEM
308 and the possible failure codes from write(), excluding EINTR. */
309_GL_FUNCDECL_SYS (dzprintf, off64_t,
310 (int fd, const char *restrict format, ...),
311 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
312 _GL_ARG_NONNULL ((2)));
313_GL_CXXALIAS_SYS (dzprintf, off64_t,
314 (int fd, const char *restrict format, ...));
315#endif
316
282#if @GNULIB_DPRINTF@ 317#if @GNULIB_DPRINTF@
318/* Prints formatted output to file descriptor FD.
319 Returns the number of bytes written to the file descriptor. Upon
320 failure, returns a negative value. */
283# if @REPLACE_DPRINTF@ 321# if @REPLACE_DPRINTF@
284# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 322# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
285# define dprintf rpl_dprintf 323# define dprintf rpl_dprintf
286# endif 324# endif
287_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...) 325_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...),
288 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 326 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
289 _GL_ARG_NONNULL ((2))); 327 _GL_ARG_NONNULL ((2)));
290_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...)); 328_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...));
291# else 329# else
292# if !@HAVE_DPRINTF@ 330# if !@HAVE_DPRINTF@
293_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...) 331_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...),
294 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 332 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
295 _GL_ARG_NONNULL ((2))); 333 _GL_ARG_NONNULL ((2)));
296# endif 334# endif
@@ -300,7 +338,7 @@ _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...));
300_GL_CXXALIASWARN (dprintf); 338_GL_CXXALIASWARN (dprintf);
301# endif 339# endif
302#elif defined GNULIB_POSIXCHECK 340#elif defined GNULIB_POSIXCHECK
303# undef dprintf 341# undef dprintf /* https://lists.gnu.org/r/bug-gnulib/2025-11/msg00254.html */
304# if HAVE_RAW_DECL_DPRINTF 342# if HAVE_RAW_DECL_DPRINTF
305_GL_WARN_ON_USE (dprintf, "dprintf is unportable - " 343_GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
306 "use gnulib module dprintf for portability"); 344 "use gnulib module dprintf for portability");
@@ -313,7 +351,7 @@ _GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
313# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 351# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
314# define fclose rpl_fclose 352# define fclose rpl_fclose
315# endif 353# endif
316_GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); 354_GL_FUNCDECL_RPL (fclose, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
317_GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); 355_GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
318# else 356# else
319_GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); 357_GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
@@ -322,7 +360,6 @@ _GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
322_GL_CXXALIASWARN (fclose); 360_GL_CXXALIASWARN (fclose);
323# endif 361# endif
324#elif defined GNULIB_POSIXCHECK 362#elif defined GNULIB_POSIXCHECK
325# undef fclose
326/* Assume fclose is always declared. */ 363/* Assume fclose is always declared. */
327_GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - " 364_GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
328 "use gnulib module fclose for portable POSIX compliance"); 365 "use gnulib module fclose for portable POSIX compliance");
@@ -360,9 +397,10 @@ _GL_CXXALIASWARN (fcloseall);
360# define fdopen rpl_fdopen 397# define fdopen rpl_fdopen
361# endif 398# endif
362_GL_FUNCDECL_RPL (fdopen, FILE *, 399_GL_FUNCDECL_RPL (fdopen, FILE *,
363 (int fd, const char *mode) 400 (int fd, const char *mode),
364 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) 401 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
365 _GL_ATTRIBUTE_MALLOC); 402 _GL_ATTRIBUTE_MALLOC
403 _GL_ATTRIBUTE_NODISCARD);
366_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); 404_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
367# elif defined _WIN32 && !defined __CYGWIN__ 405# elif defined _WIN32 && !defined __CYGWIN__
368# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 406# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -371,42 +409,43 @@ _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
371# endif 409# endif
372_GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode)); 410_GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
373# else 411# else
374# if __GNUC__ >= 11 412# if __GNUC__ >= 11 && !defined __clang__
375/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ 413/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
376# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 414# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
377_GL_FUNCDECL_SYS (fdopen, FILE *, 415_GL_FUNCDECL_SYS (fdopen, FILE *,
378 (int fd, const char *mode) 416 (int fd, const char *mode),
379 _GL_ATTRIBUTE_NOTHROW
380 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) 417 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
381 _GL_ATTRIBUTE_MALLOC); 418 _GL_ATTRIBUTE_MALLOC
419 _GL_ATTRIBUTE_NODISCARD)
420 _GL_ATTRIBUTE_NOTHROW;
382# else 421# else
383_GL_FUNCDECL_SYS (fdopen, FILE *, 422_GL_FUNCDECL_SYS (fdopen, FILE *,
384 (int fd, const char *mode) 423 (int fd, const char *mode),
385 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) 424 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
386 _GL_ATTRIBUTE_MALLOC); 425 _GL_ATTRIBUTE_MALLOC
426 _GL_ATTRIBUTE_NODISCARD);
387# endif 427# endif
388# endif 428# endif
389_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); 429_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
390# endif 430# endif
391_GL_CXXALIASWARN (fdopen); 431_GL_CXXALIASWARN (fdopen);
392#else 432#else
393# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen 433# if @GNULIB_FCLOSE@ && (__GNUC__ >= 11 && !defined __clang__) && !defined fdopen
394/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ 434/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
395# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 435# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
396_GL_FUNCDECL_SYS (fdopen, FILE *, 436_GL_FUNCDECL_SYS (fdopen, FILE *,
397 (int fd, const char *mode) 437 (int fd, const char *mode),
398 _GL_ATTRIBUTE_NOTHROW
399 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) 438 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
400 _GL_ATTRIBUTE_MALLOC); 439 _GL_ATTRIBUTE_MALLOC)
440 _GL_ATTRIBUTE_NOTHROW;
401# else 441# else
402_GL_FUNCDECL_SYS (fdopen, FILE *, 442_GL_FUNCDECL_SYS (fdopen, FILE *,
403 (int fd, const char *mode) 443 (int fd, const char *mode),
404 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) 444 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
405 _GL_ATTRIBUTE_MALLOC); 445 _GL_ATTRIBUTE_MALLOC);
406# endif 446# endif
407# endif 447# endif
408# if defined GNULIB_POSIXCHECK 448# if defined GNULIB_POSIXCHECK
409# undef fdopen
410/* Assume fdopen is always declared. */ 449/* Assume fdopen is always declared. */
411_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - " 450_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
412 "use gnulib module fdopen for portability"); 451 "use gnulib module fdopen for portability");
@@ -438,7 +477,7 @@ _GL_CXXALIASWARN (fdopen);
438# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 477# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
439# define fflush rpl_fflush 478# define fflush rpl_fflush
440# endif 479# endif
441_GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream)); 480_GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream), );
442_GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream)); 481_GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
443# else 482# else
444_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); 483_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
@@ -447,7 +486,6 @@ _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
447_GL_CXXALIASWARN (fflush); 486_GL_CXXALIASWARN (fflush);
448# endif 487# endif
449#elif defined GNULIB_POSIXCHECK 488#elif defined GNULIB_POSIXCHECK
450# undef fflush
451/* Assume fflush is always declared. */ 489/* Assume fflush is always declared. */
452_GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " 490_GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
453 "use gnulib module fflush for portable POSIX compliance"); 491 "use gnulib module fflush for portable POSIX compliance");
@@ -459,7 +497,7 @@ _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
459# undef fgetc 497# undef fgetc
460# define fgetc rpl_fgetc 498# define fgetc rpl_fgetc
461# endif 499# endif
462_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); 500_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
463_GL_CXXALIAS_RPL (fgetc, int, (FILE *stream)); 501_GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
464# else 502# else
465_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream)); 503_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
@@ -476,8 +514,8 @@ _GL_CXXALIASWARN (fgetc);
476# define fgets rpl_fgets 514# define fgets rpl_fgets
477# endif 515# endif
478_GL_FUNCDECL_RPL (fgets, char *, 516_GL_FUNCDECL_RPL (fgets, char *,
479 (char *restrict s, int n, FILE *restrict stream) 517 (char *restrict s, int n, FILE *restrict stream),
480 _GL_ARG_NONNULL ((1, 3))); 518 _GL_ARG_NONNULL ((1, 3)) _GL_ATTRIBUTE_NODISCARD);
481_GL_CXXALIAS_RPL (fgets, char *, 519_GL_CXXALIAS_RPL (fgets, char *,
482 (char *restrict s, int n, FILE *restrict stream)); 520 (char *restrict s, int n, FILE *restrict stream));
483# else 521# else
@@ -513,17 +551,18 @@ _GL_CXXALIASWARN (fileno);
513# define fopen rpl_fopen 551# define fopen rpl_fopen
514# endif 552# endif
515_GL_FUNCDECL_RPL (fopen, FILE *, 553_GL_FUNCDECL_RPL (fopen, FILE *,
516 (const char *restrict filename, const char *restrict mode) 554 (const char *restrict filename, const char *restrict mode),
517 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1) 555 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
518 _GL_ATTRIBUTE_MALLOC); 556 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD);
519_GL_CXXALIAS_RPL (fopen, FILE *, 557_GL_CXXALIAS_RPL (fopen, FILE *,
520 (const char *restrict filename, const char *restrict mode)); 558 (const char *restrict filename, const char *restrict mode));
521# else 559# else
522# if __GNUC__ >= 11 560# if __GNUC__ >= 11 && !defined __clang__
523/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ 561/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
524_GL_FUNCDECL_SYS (fopen, FILE *, 562_GL_FUNCDECL_SYS (fopen, FILE *,
525 (const char *restrict filename, const char *restrict mode) 563 (const char *restrict filename, const char *restrict mode),
526 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 564 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
565 _GL_ATTRIBUTE_NODISCARD);
527# endif 566# endif
528_GL_CXXALIAS_SYS (fopen, FILE *, 567_GL_CXXALIAS_SYS (fopen, FILE *,
529 (const char *restrict filename, const char *restrict mode)); 568 (const char *restrict filename, const char *restrict mode));
@@ -532,21 +571,39 @@ _GL_CXXALIAS_SYS (fopen, FILE *,
532_GL_CXXALIASWARN (fopen); 571_GL_CXXALIASWARN (fopen);
533# endif 572# endif
534#else 573#else
535# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fopen 574# if @GNULIB_FCLOSE@ && (__GNUC__ >= 11 && !defined __clang__) && !defined fopen
536/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ 575/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
537_GL_FUNCDECL_SYS (fopen, FILE *, 576_GL_FUNCDECL_SYS (fopen, FILE *,
538 (const char *restrict filename, const char *restrict mode) 577 (const char *restrict filename, const char *restrict mode),
539 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 578 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
540# endif 579# endif
541# if defined GNULIB_POSIXCHECK 580# if defined GNULIB_POSIXCHECK
542# undef fopen
543/* Assume fopen is always declared. */ 581/* Assume fopen is always declared. */
544_GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - " 582_GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - "
545 "use gnulib module fopen for portability"); 583 "use gnulib module fopen for portability");
546# endif 584# endif
547#endif 585#endif
548 586
587#if @GNULIB_FZPRINTF@
588/* Prints formatted output to stream FP.
589 Returns the number of bytes written to the stream. Upon failure,
590 returns -1 with the stream's error indicator set.
591 Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
592 Therefore, if the format string is valid and does not use %ls/%lc
593 directives nor widths, the only possible failure causes are ENOMEM
594 and the possible failure causes from fwrite(). */
595_GL_FUNCDECL_SYS (fzprintf, off64_t,
596 (FILE *restrict fp, const char *restrict format, ...),
597 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
598 _GL_ARG_NONNULL ((1, 2)));
599_GL_CXXALIAS_SYS (fzprintf, off64_t,
600 (FILE *restrict fp, const char *restrict format, ...));
601#endif
602
549#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@ 603#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
604/* Prints formatted output to stream FP.
605 Returns the number of bytes written to the stream. Upon failure,
606 returns a negative value with the stream's error indicator set. */
550# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \ 607# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
551 || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) 608 || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
552# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 609# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -555,12 +612,12 @@ _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX complian
555# define GNULIB_overrides_fprintf 1 612# define GNULIB_overrides_fprintf 1
556# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ 613# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
557_GL_FUNCDECL_RPL (fprintf, int, 614_GL_FUNCDECL_RPL (fprintf, int,
558 (FILE *restrict fp, const char *restrict format, ...) 615 (FILE *restrict fp, const char *restrict format, ...),
559 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 616 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
560 _GL_ARG_NONNULL ((1, 2))); 617 _GL_ARG_NONNULL ((1, 2)));
561# else 618# else
562_GL_FUNCDECL_RPL (fprintf, int, 619_GL_FUNCDECL_RPL (fprintf, int,
563 (FILE *restrict fp, const char *restrict format, ...) 620 (FILE *restrict fp, const char *restrict format, ...),
564 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3) 621 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
565 _GL_ARG_NONNULL ((1, 2))); 622 _GL_ARG_NONNULL ((1, 2)));
566# endif 623# endif
@@ -573,11 +630,13 @@ _GL_CXXALIAS_SYS (fprintf, int,
573# if __GLIBC__ >= 2 630# if __GLIBC__ >= 2
574_GL_CXXALIASWARN (fprintf); 631_GL_CXXALIASWARN (fprintf);
575# endif 632# endif
576#endif 633#elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO
577#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK 634# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
578# if !GNULIB_overrides_fprintf
579# undef fprintf 635# undef fprintf
636# define fprintf gl_consolesafe_fprintf
580# endif 637# endif
638#endif
639#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
581/* Assume fprintf is always declared. */ 640/* Assume fprintf is always declared. */
582_GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - " 641_GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
583 "use gnulib module fprintf-posix for portable " 642 "use gnulib module fprintf-posix for portable "
@@ -595,17 +654,18 @@ _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
595# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 654# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
596# define fpurge rpl_fpurge 655# define fpurge rpl_fpurge
597# endif 656# endif
598_GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); 657_GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream), _GL_ARG_NONNULL ((1)));
599_GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream)); 658_GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
600# else 659# else
601# if !@HAVE_DECL_FPURGE@ 660# if !@HAVE_DECL_FPURGE@
602_GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); 661_GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream), _GL_ARG_NONNULL ((1)));
603# endif 662# endif
604_GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); 663_GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
605# endif 664# endif
665# if __GLIBC__ >= 2
606_GL_CXXALIASWARN (fpurge); 666_GL_CXXALIASWARN (fpurge);
667# endif
607#elif defined GNULIB_POSIXCHECK 668#elif defined GNULIB_POSIXCHECK
608# undef fpurge
609# if HAVE_RAW_DECL_FPURGE 669# if HAVE_RAW_DECL_FPURGE
610_GL_WARN_ON_USE (fpurge, "fpurge is not always present - " 670_GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
611 "use gnulib module fpurge for portability"); 671 "use gnulib module fpurge for portability");
@@ -618,7 +678,7 @@ _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
618# undef fputc 678# undef fputc
619# define fputc rpl_fputc 679# define fputc rpl_fputc
620# endif 680# endif
621_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); 681_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream), _GL_ARG_NONNULL ((2)));
622_GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); 682_GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
623# else 683# else
624_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); 684_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
@@ -635,7 +695,7 @@ _GL_CXXALIASWARN (fputc);
635# define fputs rpl_fputs 695# define fputs rpl_fputs
636# endif 696# endif
637_GL_FUNCDECL_RPL (fputs, int, 697_GL_FUNCDECL_RPL (fputs, int,
638 (const char *restrict string, FILE *restrict stream) 698 (const char *restrict string, FILE *restrict stream),
639 _GL_ARG_NONNULL ((1, 2))); 699 _GL_ARG_NONNULL ((1, 2)));
640_GL_CXXALIAS_RPL (fputs, int, 700_GL_CXXALIAS_RPL (fputs, int,
641 (const char *restrict string, FILE *restrict stream)); 701 (const char *restrict string, FILE *restrict stream));
@@ -656,8 +716,8 @@ _GL_CXXALIASWARN (fputs);
656# endif 716# endif
657_GL_FUNCDECL_RPL (fread, size_t, 717_GL_FUNCDECL_RPL (fread, size_t,
658 (void *restrict ptr, size_t s, size_t n, 718 (void *restrict ptr, size_t s, size_t n,
659 FILE *restrict stream) 719 FILE *restrict stream),
660 _GL_ARG_NONNULL ((4))); 720 _GL_ARG_NONNULL ((4)) _GL_ATTRIBUTE_NODISCARD);
661_GL_CXXALIAS_RPL (fread, size_t, 721_GL_CXXALIAS_RPL (fread, size_t,
662 (void *restrict ptr, size_t s, size_t n, 722 (void *restrict ptr, size_t s, size_t n,
663 FILE *restrict stream)); 723 FILE *restrict stream));
@@ -679,8 +739,8 @@ _GL_CXXALIASWARN (fread);
679# endif 739# endif
680_GL_FUNCDECL_RPL (freopen, FILE *, 740_GL_FUNCDECL_RPL (freopen, FILE *,
681 (const char *restrict filename, const char *restrict mode, 741 (const char *restrict filename, const char *restrict mode,
682 FILE *restrict stream) 742 FILE *restrict stream),
683 _GL_ARG_NONNULL ((2, 3))); 743 _GL_ARG_NONNULL ((2, 3)) _GL_ATTRIBUTE_NODISCARD);
684_GL_CXXALIAS_RPL (freopen, FILE *, 744_GL_CXXALIAS_RPL (freopen, FILE *,
685 (const char *restrict filename, const char *restrict mode, 745 (const char *restrict filename, const char *restrict mode,
686 FILE *restrict stream)); 746 FILE *restrict stream));
@@ -693,7 +753,6 @@ _GL_CXXALIAS_SYS (freopen, FILE *,
693_GL_CXXALIASWARN (freopen); 753_GL_CXXALIASWARN (freopen);
694# endif 754# endif
695#elif defined GNULIB_POSIXCHECK 755#elif defined GNULIB_POSIXCHECK
696# undef freopen
697/* Assume freopen is always declared. */ 756/* Assume freopen is always declared. */
698_GL_WARN_ON_USE (freopen, 757_GL_WARN_ON_USE (freopen,
699 "freopen on native Windows platforms is not POSIX compliant - " 758 "freopen on native Windows platforms is not POSIX compliant - "
@@ -707,9 +766,9 @@ _GL_WARN_ON_USE (freopen,
707# define fscanf rpl_fscanf 766# define fscanf rpl_fscanf
708# endif 767# endif
709_GL_FUNCDECL_RPL (fscanf, int, 768_GL_FUNCDECL_RPL (fscanf, int,
710 (FILE *restrict stream, const char *restrict format, ...) 769 (FILE *restrict stream, const char *restrict format, ...),
711 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3) 770 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
712 _GL_ARG_NONNULL ((1, 2))); 771 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
713_GL_CXXALIAS_RPL (fscanf, int, 772_GL_CXXALIAS_RPL (fscanf, int,
714 (FILE *restrict stream, const char *restrict format, ...)); 773 (FILE *restrict stream, const char *restrict format, ...));
715# else 774# else
@@ -763,7 +822,7 @@ _GL_CXXALIASWARN (fscanf);
763# undef fseek 822# undef fseek
764# define fseek rpl_fseek 823# define fseek rpl_fseek
765# endif 824# endif
766_GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence) 825_GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence),
767 _GL_ARG_NONNULL ((1))); 826 _GL_ARG_NONNULL ((1)));
768_GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); 827_GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
769# else 828# else
@@ -786,12 +845,12 @@ _GL_CXXALIASWARN (fseek);
786# undef fseeko 845# undef fseeko
787# define fseeko rpl_fseeko 846# define fseeko rpl_fseeko
788# endif 847# endif
789_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence) 848_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence),
790 _GL_ARG_NONNULL ((1))); 849 _GL_ARG_NONNULL ((1)));
791_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); 850_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
792# else 851# else
793# if ! @HAVE_DECL_FSEEKO@ 852# if ! @HAVE_DECL_FSEEKO@
794_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence) 853_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence),
795 _GL_ARG_NONNULL ((1))); 854 _GL_ARG_NONNULL ((1)));
796# endif 855# endif
797_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); 856_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
@@ -800,7 +859,6 @@ _GL_CXXALIASWARN (fseeko);
800#elif defined GNULIB_POSIXCHECK 859#elif defined GNULIB_POSIXCHECK
801# define _GL_FSEEK_WARN /* Category 1, above. */ 860# define _GL_FSEEK_WARN /* Category 1, above. */
802# undef fseek 861# undef fseek
803# undef fseeko
804# if HAVE_RAW_DECL_FSEEKO 862# if HAVE_RAW_DECL_FSEEKO
805_GL_WARN_ON_USE (fseeko, "fseeko is unportable - " 863_GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
806 "use gnulib module fseeko for portability"); 864 "use gnulib module fseeko for portability");
@@ -829,7 +887,8 @@ _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
829# undef ftell 887# undef ftell
830# define ftell rpl_ftell 888# define ftell rpl_ftell
831# endif 889# endif
832_GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1))); 890_GL_FUNCDECL_RPL (ftell, long, (FILE *fp),
891 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
833_GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); 892_GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
834# else 893# else
835_GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); 894_GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
@@ -849,11 +908,13 @@ _GL_CXXALIASWARN (ftell);
849# undef ftello 908# undef ftello
850# define ftello rpl_ftello 909# define ftello rpl_ftello
851# endif 910# endif
852_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); 911_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp),
912 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
853_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); 913_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
854# else 914# else
855# if ! @HAVE_DECL_FTELLO@ 915# if ! @HAVE_DECL_FTELLO@
856_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); 916_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp),
917 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
857# endif 918# endif
858_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); 919_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
859# endif 920# endif
@@ -861,7 +922,6 @@ _GL_CXXALIASWARN (ftello);
861#elif defined GNULIB_POSIXCHECK 922#elif defined GNULIB_POSIXCHECK
862# define _GL_FTELL_WARN /* Category 1, above. */ 923# define _GL_FTELL_WARN /* Category 1, above. */
863# undef ftell 924# undef ftell
864# undef ftello
865# if HAVE_RAW_DECL_FTELLO 925# if HAVE_RAW_DECL_FTELLO
866_GL_WARN_ON_USE (ftello, "ftello is unportable - " 926_GL_WARN_ON_USE (ftello, "ftello is unportable - "
867 "use gnulib module ftello for portability"); 927 "use gnulib module ftello for portability");
@@ -886,7 +946,7 @@ _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
886# endif 946# endif
887_GL_FUNCDECL_RPL (fwrite, size_t, 947_GL_FUNCDECL_RPL (fwrite, size_t,
888 (const void *restrict ptr, size_t s, size_t n, 948 (const void *restrict ptr, size_t s, size_t n,
889 FILE *restrict stream) 949 FILE *restrict stream),
890 _GL_ARG_NONNULL ((1, 4))); 950 _GL_ARG_NONNULL ((1, 4)));
891_GL_CXXALIAS_RPL (fwrite, size_t, 951_GL_CXXALIAS_RPL (fwrite, size_t,
892 (const void *restrict ptr, size_t s, size_t n, 952 (const void *restrict ptr, size_t s, size_t n,
@@ -897,13 +957,13 @@ _GL_CXXALIAS_SYS (fwrite, size_t,
897 FILE *restrict stream)); 957 FILE *restrict stream));
898 958
899/* Work around bug 11959 when fortifying glibc 2.4 through 2.15 959/* Work around bug 11959 when fortifying glibc 2.4 through 2.15
900 <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>, 960 <https://sourceware.org/PR11959>,
901 which sometimes causes an unwanted diagnostic for fwrite calls. 961 which sometimes causes an unwanted diagnostic for fwrite calls.
902 This affects only function declaration attributes under certain 962 This affects only function declaration attributes under certain
903 versions of gcc and clang, and is not needed for C++. */ 963 versions of gcc and clang, and is not needed for C++. */
904# if (0 < __USE_FORTIFY_LEVEL \ 964# if (0 < __USE_FORTIFY_LEVEL \
905 && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \ 965 && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
906 && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \ 966 && (3 < __GNUC__ + (4 <= __GNUC_MINOR__) || defined __clang__) \
907 && !defined __cplusplus) 967 && !defined __cplusplus)
908# undef fwrite 968# undef fwrite
909# undef fwrite_unlocked 969# undef fwrite_unlocked
@@ -922,6 +982,11 @@ _GL_EXTERN_C size_t __REDIRECT (rpl_fwrite_unlocked,
922# if __GLIBC__ >= 2 982# if __GLIBC__ >= 2
923_GL_CXXALIASWARN (fwrite); 983_GL_CXXALIASWARN (fwrite);
924# endif 984# endif
985#elif (defined _WIN32 && !defined __CYGWIN__) && !defined _UCRT
986# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
987# undef fwrite
988# define fwrite gl_consolesafe_fwrite
989# endif
925#endif 990#endif
926 991
927#if @GNULIB_GETC@ 992#if @GNULIB_GETC@
@@ -930,7 +995,7 @@ _GL_CXXALIASWARN (fwrite);
930# undef getc 995# undef getc
931# define getc rpl_fgetc 996# define getc rpl_fgetc
932# endif 997# endif
933_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); 998_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
934_GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream)); 999_GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
935# else 1000# else
936_GL_CXXALIAS_SYS (getc, int, (FILE *stream)); 1001_GL_CXXALIAS_SYS (getc, int, (FILE *stream));
@@ -946,7 +1011,7 @@ _GL_CXXALIASWARN (getc);
946# undef getchar 1011# undef getchar
947# define getchar rpl_getchar 1012# define getchar rpl_getchar
948# endif 1013# endif
949_GL_FUNCDECL_RPL (getchar, int, (void)); 1014_GL_FUNCDECL_RPL (getchar, int, (void), );
950_GL_CXXALIAS_RPL (getchar, int, (void)); 1015_GL_CXXALIAS_RPL (getchar, int, (void));
951# else 1016# else
952_GL_CXXALIAS_SYS (getchar, int, (void)); 1017_GL_CXXALIAS_SYS (getchar, int, (void));
@@ -968,11 +1033,22 @@ _GL_CXXALIASWARN (getchar);
968# undef getdelim 1033# undef getdelim
969# define getdelim rpl_getdelim 1034# define getdelim rpl_getdelim
970# endif 1035# endif
1036# ifndef __has_feature
1037# define __has_feature(a) 0
1038# endif
1039# if __GLIBC__ >= 2 && !(defined __SANITIZE_ADDRESS__ \
1040 || __has_feature (address_sanitizer))
1041/* Arrange for the inline definition of getline() in <bits/stdio.h>
1042 to call our getdelim() override. Do not use the __getdelim symbol
1043 if address sanitizer is in use, otherwise it may be overridden by
1044 __interceptor_trampoline___getdelim. */
1045# define rpl_getdelim __getdelim
1046# endif
971_GL_FUNCDECL_RPL (getdelim, ssize_t, 1047_GL_FUNCDECL_RPL (getdelim, ssize_t,
972 (char **restrict lineptr, size_t *restrict linesize, 1048 (char **restrict lineptr, size_t *restrict linesize,
973 int delimiter, 1049 int delimiter,
974 FILE *restrict stream) 1050 FILE *restrict stream),
975 _GL_ARG_NONNULL ((1, 2, 4))); 1051 _GL_ARG_NONNULL ((1, 2, 4)) _GL_ATTRIBUTE_NODISCARD);
976_GL_CXXALIAS_RPL (getdelim, ssize_t, 1052_GL_CXXALIAS_RPL (getdelim, ssize_t,
977 (char **restrict lineptr, size_t *restrict linesize, 1053 (char **restrict lineptr, size_t *restrict linesize,
978 int delimiter, 1054 int delimiter,
@@ -982,8 +1058,8 @@ _GL_CXXALIAS_RPL (getdelim, ssize_t,
982_GL_FUNCDECL_SYS (getdelim, ssize_t, 1058_GL_FUNCDECL_SYS (getdelim, ssize_t,
983 (char **restrict lineptr, size_t *restrict linesize, 1059 (char **restrict lineptr, size_t *restrict linesize,
984 int delimiter, 1060 int delimiter,
985 FILE *restrict stream) 1061 FILE *restrict stream),
986 _GL_ARG_NONNULL ((1, 2, 4))); 1062 _GL_ARG_NONNULL ((1, 2, 4)) _GL_ATTRIBUTE_NODISCARD);
987# endif 1063# endif
988_GL_CXXALIAS_SYS (getdelim, ssize_t, 1064_GL_CXXALIAS_SYS (getdelim, ssize_t,
989 (char **restrict lineptr, size_t *restrict linesize, 1065 (char **restrict lineptr, size_t *restrict linesize,
@@ -994,7 +1070,6 @@ _GL_CXXALIAS_SYS (getdelim, ssize_t,
994_GL_CXXALIASWARN (getdelim); 1070_GL_CXXALIASWARN (getdelim);
995# endif 1071# endif
996#elif defined GNULIB_POSIXCHECK 1072#elif defined GNULIB_POSIXCHECK
997# undef getdelim
998# if HAVE_RAW_DECL_GETDELIM 1073# if HAVE_RAW_DECL_GETDELIM
999_GL_WARN_ON_USE (getdelim, "getdelim is unportable - " 1074_GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
1000 "use gnulib module getdelim for portability"); 1075 "use gnulib module getdelim for portability");
@@ -1009,14 +1084,27 @@ _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
1009 Return the number of bytes read and stored at *LINEPTR (not including the 1084 Return the number of bytes read and stored at *LINEPTR (not including the
1010 NUL terminator), or -1 on error or EOF. */ 1085 NUL terminator), or -1 on error or EOF. */
1011# if @REPLACE_GETLINE@ 1086# if @REPLACE_GETLINE@
1012# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1087_GL_FUNCDECL_RPL (getline, ssize_t,
1088 (char **restrict lineptr, size_t *restrict linesize,
1089 FILE *restrict stream),
1090 _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
1091# if defined __cplusplus
1092/* The C++ standard library defines std::basic_istream::getline in <istream>
1093 or <string>. */
1094# if !(__GLIBC__ >= 2)
1095extern "C" {
1096inline ssize_t
1097getline (char **restrict lineptr, size_t *restrict linesize,
1098 FILE *restrict stream)
1099{
1100 return rpl_getline (lineptr, linesize, stream);
1101}
1102}
1103# endif
1104# else
1013# undef getline 1105# undef getline
1014# define getline rpl_getline 1106# define getline rpl_getline
1015# endif 1107# endif
1016_GL_FUNCDECL_RPL (getline, ssize_t,
1017 (char **restrict lineptr, size_t *restrict linesize,
1018 FILE *restrict stream)
1019 _GL_ARG_NONNULL ((1, 2, 3)));
1020_GL_CXXALIAS_RPL (getline, ssize_t, 1108_GL_CXXALIAS_RPL (getline, ssize_t,
1021 (char **restrict lineptr, size_t *restrict linesize, 1109 (char **restrict lineptr, size_t *restrict linesize,
1022 FILE *restrict stream)); 1110 FILE *restrict stream));
@@ -1024,8 +1112,8 @@ _GL_CXXALIAS_RPL (getline, ssize_t,
1024# if !@HAVE_DECL_GETLINE@ 1112# if !@HAVE_DECL_GETLINE@
1025_GL_FUNCDECL_SYS (getline, ssize_t, 1113_GL_FUNCDECL_SYS (getline, ssize_t,
1026 (char **restrict lineptr, size_t *restrict linesize, 1114 (char **restrict lineptr, size_t *restrict linesize,
1027 FILE *restrict stream) 1115 FILE *restrict stream),
1028 _GL_ARG_NONNULL ((1, 2, 3))); 1116 _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
1029# endif 1117# endif
1030_GL_CXXALIAS_SYS (getline, ssize_t, 1118_GL_CXXALIAS_SYS (getline, ssize_t,
1031 (char **restrict lineptr, size_t *restrict linesize, 1119 (char **restrict lineptr, size_t *restrict linesize,
@@ -1035,7 +1123,6 @@ _GL_CXXALIAS_SYS (getline, ssize_t,
1035_GL_CXXALIASWARN (getline); 1123_GL_CXXALIASWARN (getline);
1036# endif 1124# endif
1037#elif defined GNULIB_POSIXCHECK 1125#elif defined GNULIB_POSIXCHECK
1038# undef getline
1039# if HAVE_RAW_DECL_GETLINE 1126# if HAVE_RAW_DECL_GETLINE
1040_GL_WARN_ON_USE (getline, "getline is unportable - " 1127_GL_WARN_ON_USE (getline, "getline is unportable - "
1041 "use gnulib module getline for portability"); 1128 "use gnulib module getline for portability");
@@ -1045,7 +1132,6 @@ _GL_WARN_ON_USE (getline, "getline is unportable - "
1045/* It is very rare that the developer ever has full control of stdin, 1132/* It is very rare that the developer ever has full control of stdin,
1046 so any use of gets warrants an unconditional warning; besides, C11 1133 so any use of gets warrants an unconditional warning; besides, C11
1047 removed it. */ 1134 removed it. */
1048#undef gets
1049#if HAVE_RAW_DECL_GETS && !defined __cplusplus 1135#if HAVE_RAW_DECL_GETS && !defined __cplusplus
1050_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); 1136_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
1051#endif 1137#endif
@@ -1064,7 +1150,7 @@ _GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream));
1064# if @HAVE_DECL_GETW@ 1150# if @HAVE_DECL_GETW@
1065# if defined __APPLE__ && defined __MACH__ 1151# if defined __APPLE__ && defined __MACH__
1066/* The presence of the declaration depends on _POSIX_C_SOURCE. */ 1152/* The presence of the declaration depends on _POSIX_C_SOURCE. */
1067_GL_FUNCDECL_SYS (getw, int, (FILE *restrict stream)); 1153_GL_FUNCDECL_SYS (getw, int, (FILE *restrict stream), );
1068# endif 1154# endif
1069_GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream)); 1155_GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream));
1070# endif 1156# endif
@@ -1074,19 +1160,45 @@ _GL_CXXALIASWARN (getw);
1074# endif 1160# endif
1075#endif 1161#endif
1076 1162
1163#if @GNULIB_OBSTACK_ZPRINTF@
1164struct obstack;
1165/* Grows an obstack with formatted output. Returns the number of
1166 bytes added to OBS. No trailing nul byte is added, and the
1167 object should be closed with obstack_finish before use.
1168 Upon memory allocation error, calls obstack_alloc_failed_handler.
1169 Upon other error, returns -1 with errno set.
1170
1171 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
1172 Therefore, if the format string is valid and does not use %ls/%lc
1173 directives nor widths, the only possible failure code is through
1174 obstack_alloc_failed_handler. */
1175_GL_FUNCDECL_SYS (obstack_zprintf, ptrdiff_t,
1176 (struct obstack *obs, const char *format, ...),
1177 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1178 _GL_ARG_NONNULL ((1, 2)));
1179_GL_CXXALIAS_SYS (obstack_zprintf, ptrdiff_t,
1180 (struct obstack *obs, const char *format, ...));
1181_GL_FUNCDECL_SYS (obstack_vzprintf, ptrdiff_t,
1182 (struct obstack *obs, const char *format, va_list args),
1183 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1184 _GL_ARG_NONNULL ((1, 2)));
1185_GL_CXXALIAS_SYS (obstack_vzprintf, ptrdiff_t,
1186 (struct obstack *obs, const char *format, va_list args));
1187#endif
1188
1077#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ 1189#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
1078struct obstack; 1190struct obstack;
1079/* Grow an obstack with formatted output. Return the number of 1191/* Grows an obstack with formatted output. Returns the number of
1080 bytes added to OBS. No trailing nul byte is added, and the 1192 bytes added to OBS. No trailing nul byte is added, and the
1081 object should be closed with obstack_finish before use. Upon 1193 object should be closed with obstack_finish before use.
1082 memory allocation error, call obstack_alloc_failed_handler. Upon 1194 Upon memory allocation error, calls obstack_alloc_failed_handler.
1083 other error, return -1. */ 1195 Upon other error, returns -1. */
1084# if @REPLACE_OBSTACK_PRINTF@ 1196# if @REPLACE_OBSTACK_PRINTF@
1085# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1197# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1086# define obstack_printf rpl_obstack_printf 1198# define obstack_printf rpl_obstack_printf
1087# endif 1199# endif
1088_GL_FUNCDECL_RPL (obstack_printf, int, 1200_GL_FUNCDECL_RPL (obstack_printf, int,
1089 (struct obstack *obs, const char *format, ...) 1201 (struct obstack *obs, const char *format, ...),
1090 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 1202 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1091 _GL_ARG_NONNULL ((1, 2))); 1203 _GL_ARG_NONNULL ((1, 2)));
1092_GL_CXXALIAS_RPL (obstack_printf, int, 1204_GL_CXXALIAS_RPL (obstack_printf, int,
@@ -1094,7 +1206,7 @@ _GL_CXXALIAS_RPL (obstack_printf, int,
1094# else 1206# else
1095# if !@HAVE_DECL_OBSTACK_PRINTF@ 1207# if !@HAVE_DECL_OBSTACK_PRINTF@
1096_GL_FUNCDECL_SYS (obstack_printf, int, 1208_GL_FUNCDECL_SYS (obstack_printf, int,
1097 (struct obstack *obs, const char *format, ...) 1209 (struct obstack *obs, const char *format, ...),
1098 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 1210 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1099 _GL_ARG_NONNULL ((1, 2))); 1211 _GL_ARG_NONNULL ((1, 2)));
1100# endif 1212# endif
@@ -1107,7 +1219,7 @@ _GL_CXXALIASWARN (obstack_printf);
1107# define obstack_vprintf rpl_obstack_vprintf 1219# define obstack_vprintf rpl_obstack_vprintf
1108# endif 1220# endif
1109_GL_FUNCDECL_RPL (obstack_vprintf, int, 1221_GL_FUNCDECL_RPL (obstack_vprintf, int,
1110 (struct obstack *obs, const char *format, va_list args) 1222 (struct obstack *obs, const char *format, va_list args),
1111 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 1223 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1112 _GL_ARG_NONNULL ((1, 2))); 1224 _GL_ARG_NONNULL ((1, 2)));
1113_GL_CXXALIAS_RPL (obstack_vprintf, int, 1225_GL_CXXALIAS_RPL (obstack_vprintf, int,
@@ -1115,7 +1227,7 @@ _GL_CXXALIAS_RPL (obstack_vprintf, int,
1115# else 1227# else
1116# if !@HAVE_DECL_OBSTACK_PRINTF@ 1228# if !@HAVE_DECL_OBSTACK_PRINTF@
1117_GL_FUNCDECL_SYS (obstack_vprintf, int, 1229_GL_FUNCDECL_SYS (obstack_vprintf, int,
1118 (struct obstack *obs, const char *format, va_list args) 1230 (struct obstack *obs, const char *format, va_list args),
1119 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 1231 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1120 _GL_ARG_NONNULL ((1, 2))); 1232 _GL_ARG_NONNULL ((1, 2)));
1121# endif 1233# endif
@@ -1127,12 +1239,11 @@ _GL_CXXALIASWARN (obstack_vprintf);
1127 1239
1128#if @GNULIB_PCLOSE@ 1240#if @GNULIB_PCLOSE@
1129# if !@HAVE_PCLOSE@ 1241# if !@HAVE_PCLOSE@
1130_GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); 1242_GL_FUNCDECL_SYS (pclose, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
1131# endif 1243# endif
1132_GL_CXXALIAS_SYS (pclose, int, (FILE *stream)); 1244_GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
1133_GL_CXXALIASWARN (pclose); 1245_GL_CXXALIASWARN (pclose);
1134#elif defined GNULIB_POSIXCHECK 1246#elif defined GNULIB_POSIXCHECK
1135# undef pclose
1136# if HAVE_RAW_DECL_PCLOSE 1247# if HAVE_RAW_DECL_PCLOSE
1137_GL_WARN_ON_USE (pclose, "pclose is unportable - " 1248_GL_WARN_ON_USE (pclose, "pclose is unportable - "
1138 "use gnulib module pclose for more portability"); 1249 "use gnulib module pclose for more portability");
@@ -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));
@@ -1156,7 +1267,6 @@ _GL_CXXALIAS_SYS (perror, void, (const char *string));
1156_GL_CXXALIASWARN (perror); 1267_GL_CXXALIASWARN (perror);
1157# endif 1268# endif
1158#elif defined GNULIB_POSIXCHECK 1269#elif defined GNULIB_POSIXCHECK
1159# undef perror
1160/* Assume perror is always declared. */ 1270/* Assume perror is always declared. */
1161_GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " 1271_GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
1162 "use gnulib module perror for portability"); 1272 "use gnulib module perror for portability");
@@ -1169,30 +1279,30 @@ _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
1169# define popen rpl_popen 1279# define popen rpl_popen
1170# endif 1280# endif
1171_GL_FUNCDECL_RPL (popen, FILE *, 1281_GL_FUNCDECL_RPL (popen, FILE *,
1172 (const char *cmd, const char *mode) 1282 (const char *cmd, const char *mode),
1173 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) 1283 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
1174 _GL_ATTRIBUTE_MALLOC); 1284 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD);
1175_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); 1285_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
1176# else 1286# else
1177# if !@HAVE_POPEN@ || __GNUC__ >= 11 1287# if !@HAVE_POPEN@ || (__GNUC__ >= 11 && !defined __clang__)
1178_GL_FUNCDECL_SYS (popen, FILE *, 1288_GL_FUNCDECL_SYS (popen, FILE *,
1179 (const char *cmd, const char *mode) 1289 (const char *cmd, const char *mode),
1180 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) 1290 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
1181 _GL_ATTRIBUTE_MALLOC); 1291 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD);
1182# endif 1292# endif
1183_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); 1293_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
1184# endif 1294# endif
1185_GL_CXXALIASWARN (popen); 1295_GL_CXXALIASWARN (popen);
1186#else 1296#else
1187# if @GNULIB_PCLOSE@ && __GNUC__ >= 11 && !defined popen 1297# if @GNULIB_PCLOSE@ \
1298 && (__GNUC__ >= 11 && !defined __clang__) && !defined popen
1188/* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */ 1299/* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */
1189_GL_FUNCDECL_SYS (popen, FILE *, 1300_GL_FUNCDECL_SYS (popen, FILE *,
1190 (const char *cmd, const char *mode) 1301 (const char *cmd, const char *mode),
1191 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1) 1302 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
1192 _GL_ATTRIBUTE_MALLOC); 1303 _GL_ATTRIBUTE_MALLOC);
1193# endif 1304# endif
1194# if defined GNULIB_POSIXCHECK 1305# if defined GNULIB_POSIXCHECK
1195# undef popen
1196# if HAVE_RAW_DECL_POPEN 1306# if HAVE_RAW_DECL_POPEN
1197_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " 1307_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
1198 "use gnulib module popen or pipe for more portability"); 1308 "use gnulib module popen or pipe for more portability");
@@ -1200,7 +1310,24 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
1200# endif 1310# endif
1201#endif 1311#endif
1202 1312
1313#if @GNULIB_ZPRINTF@
1314/* Prints formatted output to standard output.
1315 Returns the number of bytes written to standard output. Upon failure,
1316 returns -1 with stdout's error indicator set.
1317 Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
1318 Therefore, if the format string is valid and does not use %ls/%lc
1319 directives nor widths, the only possible failure causes are ENOMEM
1320 and the possible failure causes from fwrite(). */
1321_GL_FUNCDECL_SYS (zprintf, off64_t, (const char *restrict format, ...),
1322 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
1323 _GL_ARG_NONNULL ((1)));
1324_GL_CXXALIAS_SYS (zprintf, off64_t, (const char *restrict format, ...));
1325#endif
1326
1203#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ 1327#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
1328/* Prints formatted output to standard output.
1329 Returns the number of bytes written to standard output. Upon failure,
1330 returns a negative value with stdout's error indicator set. */
1204# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ 1331# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
1205 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) 1332 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1206# if defined __GNUC__ || defined __clang__ 1333# if defined __GNUC__ || defined __clang__
@@ -1212,14 +1339,14 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
1212_GL_FUNCDECL_RPL_1 (__printf__, int, 1339_GL_FUNCDECL_RPL_1 (__printf__, int,
1213 (const char *restrict format, ...) 1340 (const char *restrict format, ...)
1214 __asm__ (@ASM_SYMBOL_PREFIX@ 1341 __asm__ (@ASM_SYMBOL_PREFIX@
1215 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) 1342 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)),
1216 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) 1343 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
1217 _GL_ARG_NONNULL ((1))); 1344 _GL_ARG_NONNULL ((1)));
1218# else 1345# else
1219_GL_FUNCDECL_RPL_1 (__printf__, int, 1346_GL_FUNCDECL_RPL_1 (__printf__, int,
1220 (const char *restrict format, ...) 1347 (const char *restrict format, ...)
1221 __asm__ (@ASM_SYMBOL_PREFIX@ 1348 __asm__ (@ASM_SYMBOL_PREFIX@
1222 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) 1349 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)),
1223 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2) 1350 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
1224 _GL_ARG_NONNULL ((1))); 1351 _GL_ARG_NONNULL ((1)));
1225# endif 1352# endif
@@ -1229,7 +1356,7 @@ _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
1229# define printf rpl_printf 1356# define printf rpl_printf
1230# endif 1357# endif
1231_GL_FUNCDECL_RPL (printf, int, 1358_GL_FUNCDECL_RPL (printf, int,
1232 (const char *restrict format, ...) 1359 (const char *restrict format, ...),
1233 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) 1360 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
1234 _GL_ARG_NONNULL ((1))); 1361 _GL_ARG_NONNULL ((1)));
1235_GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...)); 1362_GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...));
@@ -1241,11 +1368,13 @@ _GL_CXXALIAS_SYS (printf, int, (const char *restrict format, ...));
1241# if __GLIBC__ >= 2 1368# if __GLIBC__ >= 2
1242_GL_CXXALIASWARN (printf); 1369_GL_CXXALIASWARN (printf);
1243# endif 1370# endif
1244#endif 1371#elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO
1245#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK 1372# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1246# if !GNULIB_overrides_printf
1247# undef printf 1373# undef printf
1374# define printf gl_consolesafe_printf
1248# endif 1375# endif
1376#endif
1377#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1249/* Assume printf is always declared. */ 1378/* Assume printf is always declared. */
1250_GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - " 1379_GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
1251 "use gnulib module printf-posix for portable " 1380 "use gnulib module printf-posix for portable "
@@ -1258,7 +1387,7 @@ _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
1258# undef putc 1387# undef putc
1259# define putc rpl_fputc 1388# define putc rpl_fputc
1260# endif 1389# endif
1261_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); 1390_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)); 1391_GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
1263# else 1392# else
1264_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); 1393_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
@@ -1274,7 +1403,7 @@ _GL_CXXALIASWARN (putc);
1274# undef putchar 1403# undef putchar
1275# define putchar rpl_putchar 1404# define putchar rpl_putchar
1276# endif 1405# endif
1277_GL_FUNCDECL_RPL (putchar, int, (int c)); 1406_GL_FUNCDECL_RPL (putchar, int, (int c), );
1278_GL_CXXALIAS_RPL (putchar, int, (int c)); 1407_GL_CXXALIAS_RPL (putchar, int, (int c));
1279# else 1408# else
1280_GL_CXXALIAS_SYS (putchar, int, (int c)); 1409_GL_CXXALIAS_SYS (putchar, int, (int c));
@@ -1290,7 +1419,7 @@ _GL_CXXALIASWARN (putchar);
1290# undef puts 1419# undef puts
1291# define puts rpl_puts 1420# define puts rpl_puts
1292# endif 1421# endif
1293_GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1))); 1422_GL_FUNCDECL_RPL (puts, int, (const char *string), _GL_ARG_NONNULL ((1)));
1294_GL_CXXALIAS_RPL (puts, int, (const char *string)); 1423_GL_CXXALIAS_RPL (puts, int, (const char *string));
1295# else 1424# else
1296_GL_CXXALIAS_SYS (puts, int, (const char *string)); 1425_GL_CXXALIAS_SYS (puts, int, (const char *string));
@@ -1314,7 +1443,7 @@ _GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream));
1314# if @HAVE_DECL_PUTW@ 1443# if @HAVE_DECL_PUTW@
1315# if defined __APPLE__ && defined __MACH__ 1444# if defined __APPLE__ && defined __MACH__
1316/* The presence of the declaration depends on _POSIX_C_SOURCE. */ 1445/* The presence of the declaration depends on _POSIX_C_SOURCE. */
1317_GL_FUNCDECL_SYS (putw, int, (int w, FILE *restrict stream)); 1446_GL_FUNCDECL_SYS (putw, int, (int w, FILE *restrict stream), );
1318# endif 1447# endif
1319_GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream)); 1448_GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream));
1320# endif 1449# endif
@@ -1330,7 +1459,7 @@ _GL_CXXALIASWARN (putw);
1330# undef remove 1459# undef remove
1331# define remove rpl_remove 1460# define remove rpl_remove
1332# endif 1461# endif
1333_GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1))); 1462_GL_FUNCDECL_RPL (remove, int, (const char *name), _GL_ARG_NONNULL ((1)));
1334_GL_CXXALIAS_RPL (remove, int, (const char *name)); 1463_GL_CXXALIAS_RPL (remove, int, (const char *name));
1335# else 1464# else
1336_GL_CXXALIAS_SYS (remove, int, (const char *name)); 1465_GL_CXXALIAS_SYS (remove, int, (const char *name));
@@ -1339,7 +1468,6 @@ _GL_CXXALIAS_SYS (remove, int, (const char *name));
1339_GL_CXXALIASWARN (remove); 1468_GL_CXXALIASWARN (remove);
1340# endif 1469# endif
1341#elif defined GNULIB_POSIXCHECK 1470#elif defined GNULIB_POSIXCHECK
1342# undef remove
1343/* Assume remove is always declared. */ 1471/* Assume remove is always declared. */
1344_GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - " 1472_GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
1345 "use gnulib module remove for more portability"); 1473 "use gnulib module remove for more portability");
@@ -1352,7 +1480,7 @@ _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
1352# define rename rpl_rename 1480# define rename rpl_rename
1353# endif 1481# endif
1354_GL_FUNCDECL_RPL (rename, int, 1482_GL_FUNCDECL_RPL (rename, int,
1355 (const char *old_filename, const char *new_filename) 1483 (const char *old_filename, const char *new_filename),
1356 _GL_ARG_NONNULL ((1, 2))); 1484 _GL_ARG_NONNULL ((1, 2)));
1357_GL_CXXALIAS_RPL (rename, int, 1485_GL_CXXALIAS_RPL (rename, int,
1358 (const char *old_filename, const char *new_filename)); 1486 (const char *old_filename, const char *new_filename));
@@ -1364,7 +1492,6 @@ _GL_CXXALIAS_SYS (rename, int,
1364_GL_CXXALIASWARN (rename); 1492_GL_CXXALIASWARN (rename);
1365# endif 1493# endif
1366#elif defined GNULIB_POSIXCHECK 1494#elif defined GNULIB_POSIXCHECK
1367# undef rename
1368/* Assume rename is always declared. */ 1495/* Assume rename is always declared. */
1369_GL_WARN_ON_USE (rename, "rename is buggy on some platforms - " 1496_GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
1370 "use gnulib module rename for more portability"); 1497 "use gnulib module rename for more portability");
@@ -1377,14 +1504,14 @@ _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
1377# define renameat rpl_renameat 1504# define renameat rpl_renameat
1378# endif 1505# endif
1379_GL_FUNCDECL_RPL (renameat, int, 1506_GL_FUNCDECL_RPL (renameat, int,
1380 (int fd1, char const *file1, int fd2, char const *file2) 1507 (int fd1, char const *file1, int fd2, char const *file2),
1381 _GL_ARG_NONNULL ((2, 4))); 1508 _GL_ARG_NONNULL ((2, 4)));
1382_GL_CXXALIAS_RPL (renameat, int, 1509_GL_CXXALIAS_RPL (renameat, int,
1383 (int fd1, char const *file1, int fd2, char const *file2)); 1510 (int fd1, char const *file1, int fd2, char const *file2));
1384# else 1511# else
1385# if !@HAVE_RENAMEAT@ 1512# if !@HAVE_RENAMEAT@
1386_GL_FUNCDECL_SYS (renameat, int, 1513_GL_FUNCDECL_SYS (renameat, int,
1387 (int fd1, char const *file1, int fd2, char const *file2) 1514 (int fd1, char const *file1, int fd2, char const *file2),
1388 _GL_ARG_NONNULL ((2, 4))); 1515 _GL_ARG_NONNULL ((2, 4)));
1389# endif 1516# endif
1390_GL_CXXALIAS_SYS (renameat, int, 1517_GL_CXXALIAS_SYS (renameat, int,
@@ -1392,7 +1519,6 @@ _GL_CXXALIAS_SYS (renameat, int,
1392# endif 1519# endif
1393_GL_CXXALIASWARN (renameat); 1520_GL_CXXALIASWARN (renameat);
1394#elif defined GNULIB_POSIXCHECK 1521#elif defined GNULIB_POSIXCHECK
1395# undef renameat
1396# if HAVE_RAW_DECL_RENAMEAT 1522# if HAVE_RAW_DECL_RENAMEAT
1397_GL_WARN_ON_USE (renameat, "renameat is not portable - " 1523_GL_WARN_ON_USE (renameat, "renameat is not portable - "
1398 "use gnulib module renameat for portability"); 1524 "use gnulib module renameat for portability");
@@ -1410,18 +1536,18 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - "
1410_GL_FUNCDECL_RPL_1 (__scanf__, int, 1536_GL_FUNCDECL_RPL_1 (__scanf__, int,
1411 (const char *restrict format, ...) 1537 (const char *restrict format, ...)
1412 __asm__ (@ASM_SYMBOL_PREFIX@ 1538 __asm__ (@ASM_SYMBOL_PREFIX@
1413 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)) 1539 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)),
1414 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) 1540 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1415 _GL_ARG_NONNULL ((1))); 1541 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1416_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...)); 1542_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...));
1417# else 1543# else
1418# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1544# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1419# undef scanf 1545# undef scanf
1420# define scanf rpl_scanf 1546# define scanf rpl_scanf
1421# endif 1547# endif
1422_GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...) 1548_GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...),
1423 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) 1549 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1424 _GL_ARG_NONNULL ((1))); 1550 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1425_GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...)); 1551_GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...));
1426# endif 1552# endif
1427# else 1553# else
@@ -1432,7 +1558,31 @@ _GL_CXXALIASWARN (scanf);
1432# endif 1558# endif
1433#endif 1559#endif
1434 1560
1561#if @GNULIB_SNZPRINTF@
1562/* Prints formatted output to string STR. Similar to sprintf, but the
1563 additional parameter SIZE limits how much is written into STR.
1564 STR may be NULL, in which case nothing will be written.
1565 Returns the string length of the formatted string (which may be larger
1566 than SIZE). Upon failure, returns -1 with errno set.
1567 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
1568 Therefore, if the format string is valid and does not use %ls/%lc
1569 directives nor widths, the only possible failure code is ENOMEM. */
1570_GL_FUNCDECL_SYS (snzprintf, ptrdiff_t,
1571 (char *restrict str, size_t size,
1572 const char *restrict format, ...),
1573 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
1574 _GL_ARG_NONNULL ((3)));
1575_GL_CXXALIAS_SYS (snzprintf, ptrdiff_t,
1576 (char *restrict str, size_t size,
1577 const char *restrict format, ...));
1578#endif
1579
1435#if @GNULIB_SNPRINTF@ 1580#if @GNULIB_SNPRINTF@
1581/* Prints formatted output to string STR. Similar to sprintf, but the
1582 additional parameter SIZE limits how much is written into STR.
1583 STR may be NULL, in which case nothing will be written.
1584 Returns the string length of the formatted string (which may be larger
1585 than SIZE). Upon failure, returns a negative value. */
1436# if @REPLACE_SNPRINTF@ 1586# if @REPLACE_SNPRINTF@
1437# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1587# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1438# define snprintf rpl_snprintf 1588# define snprintf rpl_snprintf
@@ -1440,7 +1590,7 @@ _GL_CXXALIASWARN (scanf);
1440# define GNULIB_overrides_snprintf 1 1590# define GNULIB_overrides_snprintf 1
1441_GL_FUNCDECL_RPL (snprintf, int, 1591_GL_FUNCDECL_RPL (snprintf, int,
1442 (char *restrict str, size_t size, 1592 (char *restrict str, size_t size,
1443 const char *restrict format, ...) 1593 const char *restrict format, ...),
1444 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) 1594 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
1445 _GL_ARG_NONNULL ((3))); 1595 _GL_ARG_NONNULL ((3)));
1446_GL_CXXALIAS_RPL (snprintf, int, 1596_GL_CXXALIAS_RPL (snprintf, int,
@@ -1450,7 +1600,7 @@ _GL_CXXALIAS_RPL (snprintf, int,
1450# if !@HAVE_DECL_SNPRINTF@ 1600# if !@HAVE_DECL_SNPRINTF@
1451_GL_FUNCDECL_SYS (snprintf, int, 1601_GL_FUNCDECL_SYS (snprintf, int,
1452 (char *restrict str, size_t size, 1602 (char *restrict str, size_t size,
1453 const char *restrict format, ...) 1603 const char *restrict format, ...),
1454 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) 1604 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
1455 _GL_ARG_NONNULL ((3))); 1605 _GL_ARG_NONNULL ((3)));
1456# endif 1606# endif
@@ -1462,13 +1612,29 @@ _GL_CXXALIAS_SYS (snprintf, int,
1462_GL_CXXALIASWARN (snprintf); 1612_GL_CXXALIASWARN (snprintf);
1463# endif 1613# endif
1464#elif defined GNULIB_POSIXCHECK 1614#elif defined GNULIB_POSIXCHECK
1465# undef snprintf
1466# if HAVE_RAW_DECL_SNPRINTF 1615# if HAVE_RAW_DECL_SNPRINTF
1467_GL_WARN_ON_USE (snprintf, "snprintf is unportable - " 1616_GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
1468 "use gnulib module snprintf for portability"); 1617 "use gnulib module snprintf for portability");
1469# endif 1618# endif
1470#endif 1619#endif
1471 1620
1621#if @GNULIB_SZPRINTF@
1622/* Prints formatted output to string STR.
1623 Returns the string length of the formatted string. Upon failure,
1624 returns -1 with errno set.
1625 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
1626 Therefore, if the format string is valid and does not use %ls/%lc
1627 directives nor widths, the only possible failure code is ENOMEM. */
1628_GL_FUNCDECL_SYS (szprintf, ptrdiff_t,
1629 (char *restrict str,
1630 const char *restrict format, ...),
1631 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1632 _GL_ARG_NONNULL ((1, 2)));
1633_GL_CXXALIAS_SYS (szprintf, ptrdiff_t,
1634 (char *restrict str,
1635 const char *restrict format, ...));
1636#endif
1637
1472/* Some people would argue that all sprintf uses should be warned about 1638/* Some people would argue that all sprintf uses should be warned about
1473 (for example, OpenBSD issues a link warning for it), 1639 (for example, OpenBSD issues a link warning for it),
1474 since it can cause security holes due to buffer overruns. 1640 since it can cause security holes due to buffer overruns.
@@ -1479,13 +1645,16 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
1479 GNULIB_POSIXCHECK is defined. */ 1645 GNULIB_POSIXCHECK is defined. */
1480 1646
1481#if @GNULIB_SPRINTF_POSIX@ 1647#if @GNULIB_SPRINTF_POSIX@
1648/* Prints formatted output to string STR.
1649 Returns the string length of the formatted string. Upon failure,
1650 returns a negative value. */
1482# if @REPLACE_SPRINTF@ 1651# if @REPLACE_SPRINTF@
1483# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1652# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1484# define sprintf rpl_sprintf 1653# define sprintf rpl_sprintf
1485# endif 1654# endif
1486# define GNULIB_overrides_sprintf 1 1655# define GNULIB_overrides_sprintf 1
1487_GL_FUNCDECL_RPL (sprintf, int, 1656_GL_FUNCDECL_RPL (sprintf, int,
1488 (char *restrict str, const char *restrict format, ...) 1657 (char *restrict str, const char *restrict format, ...),
1489 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 1658 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1490 _GL_ARG_NONNULL ((1, 2))); 1659 _GL_ARG_NONNULL ((1, 2)));
1491_GL_CXXALIAS_RPL (sprintf, int, 1660_GL_CXXALIAS_RPL (sprintf, int,
@@ -1498,7 +1667,6 @@ _GL_CXXALIAS_SYS (sprintf, int,
1498_GL_CXXALIASWARN (sprintf); 1667_GL_CXXALIASWARN (sprintf);
1499# endif 1668# endif
1500#elif defined GNULIB_POSIXCHECK 1669#elif defined GNULIB_POSIXCHECK
1501# undef sprintf
1502/* Assume sprintf is always declared. */ 1670/* Assume sprintf is always declared. */
1503_GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - " 1671_GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
1504 "use gnulib module sprintf-posix for portable " 1672 "use gnulib module sprintf-posix for portable "
@@ -1526,16 +1694,18 @@ _GL_CXXALIASWARN (tempnam);
1526# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1694# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1527# define tmpfile rpl_tmpfile 1695# define tmpfile rpl_tmpfile
1528# endif 1696# endif
1529_GL_FUNCDECL_RPL (tmpfile, FILE *, (void) 1697_GL_FUNCDECL_RPL (tmpfile, FILE *, (void),
1530 _GL_ATTRIBUTE_DEALLOC (fclose, 1) 1698 _GL_ATTRIBUTE_DEALLOC (fclose, 1)
1531 _GL_ATTRIBUTE_MALLOC); 1699 _GL_ATTRIBUTE_MALLOC
1700 _GL_ATTRIBUTE_NODISCARD);
1532_GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); 1701_GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
1533# else 1702# else
1534# if __GNUC__ >= 11 1703# if __GNUC__ >= 11 && !defined __clang__
1535/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ 1704/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
1536_GL_FUNCDECL_SYS (tmpfile, FILE *, (void) 1705_GL_FUNCDECL_SYS (tmpfile, FILE *, (void),
1537 _GL_ATTRIBUTE_DEALLOC (fclose, 1) 1706 _GL_ATTRIBUTE_DEALLOC (fclose, 1)
1538 _GL_ATTRIBUTE_MALLOC); 1707 _GL_ATTRIBUTE_MALLOC
1708 _GL_ATTRIBUTE_NODISCARD);
1539# endif 1709# endif
1540_GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); 1710_GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
1541# endif 1711# endif
@@ -1543,14 +1713,14 @@ _GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
1543_GL_CXXALIASWARN (tmpfile); 1713_GL_CXXALIASWARN (tmpfile);
1544# endif 1714# endif
1545#else 1715#else
1546# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile 1716# if @GNULIB_FCLOSE@ \
1717 && (__GNUC__ >= 11 && !defined __clang__) && !defined tmpfile
1547/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ 1718/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
1548_GL_FUNCDECL_SYS (tmpfile, FILE *, (void) 1719_GL_FUNCDECL_SYS (tmpfile, FILE *, (void),
1549 _GL_ATTRIBUTE_DEALLOC (fclose, 1) 1720 _GL_ATTRIBUTE_DEALLOC (fclose, 1)
1550 _GL_ATTRIBUTE_MALLOC); 1721 _GL_ATTRIBUTE_MALLOC);
1551# endif 1722# endif
1552# if defined GNULIB_POSIXCHECK 1723# if defined GNULIB_POSIXCHECK
1553# undef tmpfile
1554# if HAVE_RAW_DECL_TMPFILE 1724# if HAVE_RAW_DECL_TMPFILE
1555_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " 1725_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
1556 "use gnulib module tmpfile for portability"); 1726 "use gnulib module tmpfile for portability");
@@ -1558,6 +1728,31 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
1558# endif 1728# endif
1559#endif 1729#endif
1560 1730
1731#if @GNULIB_VASZPRINTF@
1732/* Prints formatted output to a string dynamically allocated with malloc().
1733 If the memory allocation succeeds, it stores the address of the string in
1734 *RESULT and returns the number of resulting bytes, excluding the trailing
1735 NUL. Upon memory allocation error, or some other error, it returns -1
1736 with errno set.
1737 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
1738 Therefore, if the format string is valid and does not use %ls/%lc
1739 directives nor widths, the only possible failure code is ENOMEM. */
1740_GL_FUNCDECL_SYS (aszprintf, ptrdiff_t,
1741 (char **result, const char *format, ...),
1742 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1743 _GL_ARG_NONNULL ((1, 2))
1744 _GL_ATTRIBUTE_NODISCARD);
1745_GL_CXXALIAS_SYS (aszprintf, ptrdiff_t,
1746 (char **result, const char *format, ...));
1747_GL_FUNCDECL_SYS (vaszprintf, ptrdiff_t,
1748 (char **result, const char *format, va_list args),
1749 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1750 _GL_ARG_NONNULL ((1, 2))
1751 _GL_ATTRIBUTE_NODISCARD);
1752_GL_CXXALIAS_SYS (vaszprintf, ptrdiff_t,
1753 (char **result, const char *format, va_list args));
1754#endif
1755
1561#if @GNULIB_VASPRINTF@ 1756#if @GNULIB_VASPRINTF@
1562/* Write formatted output to a string dynamically allocated with malloc(). 1757/* Write formatted output to a string dynamically allocated with malloc().
1563 If the memory allocation succeeds, store the address of the string in 1758 If the memory allocation succeeds, store the address of the string in
@@ -1569,17 +1764,19 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
1569# endif 1764# endif
1570# define GNULIB_overrides_asprintf 1765# define GNULIB_overrides_asprintf
1571_GL_FUNCDECL_RPL (asprintf, int, 1766_GL_FUNCDECL_RPL (asprintf, int,
1572 (char **result, const char *format, ...) 1767 (char **result, const char *format, ...),
1573 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 1768 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1574 _GL_ARG_NONNULL ((1, 2))); 1769 _GL_ARG_NONNULL ((1, 2))
1770 _GL_ATTRIBUTE_NODISCARD);
1575_GL_CXXALIAS_RPL (asprintf, int, 1771_GL_CXXALIAS_RPL (asprintf, int,
1576 (char **result, const char *format, ...)); 1772 (char **result, const char *format, ...));
1577# else 1773# else
1578# if !@HAVE_VASPRINTF@ 1774# if !@HAVE_VASPRINTF@
1579_GL_FUNCDECL_SYS (asprintf, int, 1775_GL_FUNCDECL_SYS (asprintf, int,
1580 (char **result, const char *format, ...) 1776 (char **result, const char *format, ...),
1581 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 1777 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1582 _GL_ARG_NONNULL ((1, 2))); 1778 _GL_ARG_NONNULL ((1, 2))
1779 _GL_ATTRIBUTE_NODISCARD);
1583# endif 1780# endif
1584_GL_CXXALIAS_SYS (asprintf, int, 1781_GL_CXXALIAS_SYS (asprintf, int,
1585 (char **result, const char *format, ...)); 1782 (char **result, const char *format, ...));
@@ -1591,17 +1788,19 @@ _GL_CXXALIASWARN (asprintf);
1591# endif 1788# endif
1592# define GNULIB_overrides_vasprintf 1 1789# define GNULIB_overrides_vasprintf 1
1593_GL_FUNCDECL_RPL (vasprintf, int, 1790_GL_FUNCDECL_RPL (vasprintf, int,
1594 (char **result, const char *format, va_list args) 1791 (char **result, const char *format, va_list args),
1595 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 1792 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1596 _GL_ARG_NONNULL ((1, 2))); 1793 _GL_ARG_NONNULL ((1, 2))
1794 _GL_ATTRIBUTE_NODISCARD);
1597_GL_CXXALIAS_RPL (vasprintf, int, 1795_GL_CXXALIAS_RPL (vasprintf, int,
1598 (char **result, const char *format, va_list args)); 1796 (char **result, const char *format, va_list args));
1599# else 1797# else
1600# if !@HAVE_VASPRINTF@ 1798# if !@HAVE_VASPRINTF@
1601_GL_FUNCDECL_SYS (vasprintf, int, 1799_GL_FUNCDECL_SYS (vasprintf, int,
1602 (char **result, const char *format, va_list args) 1800 (char **result, const char *format, va_list args),
1603 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 1801 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1604 _GL_ARG_NONNULL ((1, 2))); 1802 _GL_ARG_NONNULL ((1, 2))
1803 _GL_ATTRIBUTE_NODISCARD);
1605# endif 1804# endif
1606_GL_CXXALIAS_SYS (vasprintf, int, 1805_GL_CXXALIAS_SYS (vasprintf, int,
1607 (char **result, const char *format, va_list args)); 1806 (char **result, const char *format, va_list args));
@@ -1609,13 +1808,32 @@ _GL_CXXALIAS_SYS (vasprintf, int,
1609_GL_CXXALIASWARN (vasprintf); 1808_GL_CXXALIASWARN (vasprintf);
1610#endif 1809#endif
1611 1810
1811#if @GNULIB_VDZPRINTF@
1812/* Prints formatted output to file descriptor FD.
1813 Returns the number of bytes written to the file descriptor. Upon
1814 failure, returns -1 with errno set.
1815 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
1816 Therefore, if the format string is valid and does not use %ls/%lc
1817 directives nor widths, the only possible failure codes are ENOMEM
1818 and the possible failure codes from write(), excluding EINTR. */
1819_GL_FUNCDECL_SYS (vdzprintf, off64_t,
1820 (int fd, const char *restrict format, va_list args),
1821 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1822 _GL_ARG_NONNULL ((2)));
1823_GL_CXXALIAS_SYS (vdzprintf, off64_t,
1824 (int fd, const char *restrict format, va_list args));
1825#endif
1826
1612#if @GNULIB_VDPRINTF@ 1827#if @GNULIB_VDPRINTF@
1828/* Prints formatted output to file descriptor FD.
1829 Returns the number of bytes written to the file descriptor. Upon
1830 failure, returns a negative value. */
1613# if @REPLACE_VDPRINTF@ 1831# if @REPLACE_VDPRINTF@
1614# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1832# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1615# define vdprintf rpl_vdprintf 1833# define vdprintf rpl_vdprintf
1616# endif 1834# endif
1617_GL_FUNCDECL_RPL (vdprintf, int, 1835_GL_FUNCDECL_RPL (vdprintf, int,
1618 (int fd, const char *restrict format, va_list args) 1836 (int fd, const char *restrict format, va_list args),
1619 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 1837 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1620 _GL_ARG_NONNULL ((2))); 1838 _GL_ARG_NONNULL ((2)));
1621_GL_CXXALIAS_RPL (vdprintf, int, 1839_GL_CXXALIAS_RPL (vdprintf, int,
@@ -1623,7 +1841,7 @@ _GL_CXXALIAS_RPL (vdprintf, int,
1623# else 1841# else
1624# if !@HAVE_VDPRINTF@ 1842# if !@HAVE_VDPRINTF@
1625_GL_FUNCDECL_SYS (vdprintf, int, 1843_GL_FUNCDECL_SYS (vdprintf, int,
1626 (int fd, const char *restrict format, va_list args) 1844 (int fd, const char *restrict format, va_list args),
1627 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 1845 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1628 _GL_ARG_NONNULL ((2))); 1846 _GL_ARG_NONNULL ((2)));
1629# endif 1847# endif
@@ -1636,14 +1854,34 @@ _GL_CXXALIAS_SYS_CAST (vdprintf, int,
1636_GL_CXXALIASWARN (vdprintf); 1854_GL_CXXALIASWARN (vdprintf);
1637# endif 1855# endif
1638#elif defined GNULIB_POSIXCHECK 1856#elif defined GNULIB_POSIXCHECK
1639# undef vdprintf
1640# if HAVE_RAW_DECL_VDPRINTF 1857# if HAVE_RAW_DECL_VDPRINTF
1641_GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " 1858_GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
1642 "use gnulib module vdprintf for portability"); 1859 "use gnulib module vdprintf for portability");
1643# endif 1860# endif
1644#endif 1861#endif
1645 1862
1863#if @GNULIB_VFZPRINTF@
1864/* Prints formatted output to stream FP.
1865 Returns the number of bytes written to the stream. Upon failure,
1866 returns -1 with the stream's error indicator set.
1867 Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
1868 Therefore, if the format string is valid and does not use %ls/%lc
1869 directives nor widths, the only possible failure causes are ENOMEM
1870 and the possible failure causes from fwrite(). */
1871_GL_FUNCDECL_SYS (vfzprintf, off64_t,
1872 (FILE *restrict fp,
1873 const char *restrict format, va_list args),
1874 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1875 _GL_ARG_NONNULL ((1, 2)));
1876_GL_CXXALIAS_SYS (vfzprintf, off64_t,
1877 (FILE *restrict fp,
1878 const char *restrict format, va_list args));
1879#endif
1880
1646#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@ 1881#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
1882/* Prints formatted output to stream FP.
1883 Returns the number of bytes written to the stream. Upon failure,
1884 returns a negative value with the stream's error indicator set. */
1647# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \ 1885# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
1648 || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) 1886 || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1649# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1887# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1653,13 +1891,13 @@ _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
1653# if @GNULIB_VFPRINTF_POSIX@ 1891# if @GNULIB_VFPRINTF_POSIX@
1654_GL_FUNCDECL_RPL (vfprintf, int, 1892_GL_FUNCDECL_RPL (vfprintf, int,
1655 (FILE *restrict fp, 1893 (FILE *restrict fp,
1656 const char *restrict format, va_list args) 1894 const char *restrict format, va_list args),
1657 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 1895 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1658 _GL_ARG_NONNULL ((1, 2))); 1896 _GL_ARG_NONNULL ((1, 2)));
1659# else 1897# else
1660_GL_FUNCDECL_RPL (vfprintf, int, 1898_GL_FUNCDECL_RPL (vfprintf, int,
1661 (FILE *restrict fp, 1899 (FILE *restrict fp,
1662 const char *restrict format, va_list args) 1900 const char *restrict format, va_list args),
1663 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0) 1901 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
1664 _GL_ARG_NONNULL ((1, 2))); 1902 _GL_ARG_NONNULL ((1, 2)));
1665# endif 1903# endif
@@ -1677,11 +1915,13 @@ _GL_CXXALIAS_SYS_CAST (vfprintf, int,
1677# if __GLIBC__ >= 2 1915# if __GLIBC__ >= 2
1678_GL_CXXALIASWARN (vfprintf); 1916_GL_CXXALIASWARN (vfprintf);
1679# endif 1917# endif
1680#endif 1918#elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO
1681#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK 1919# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1682# if !GNULIB_overrides_vfprintf
1683# undef vfprintf 1920# undef vfprintf
1921# define vfprintf gl_consolesafe_vfprintf
1684# endif 1922# endif
1923#endif
1924#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1685/* Assume vfprintf is always declared. */ 1925/* Assume vfprintf is always declared. */
1686_GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - " 1926_GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
1687 "use gnulib module vfprintf-posix for portable " 1927 "use gnulib module vfprintf-posix for portable "
@@ -1696,9 +1936,9 @@ _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
1696# endif 1936# endif
1697_GL_FUNCDECL_RPL (vfscanf, int, 1937_GL_FUNCDECL_RPL (vfscanf, int,
1698 (FILE *restrict stream, 1938 (FILE *restrict stream,
1699 const char *restrict format, va_list args) 1939 const char *restrict format, va_list args),
1700 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0) 1940 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
1701 _GL_ARG_NONNULL ((1, 2))); 1941 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
1702_GL_CXXALIAS_RPL (vfscanf, int, 1942_GL_CXXALIAS_RPL (vfscanf, int,
1703 (FILE *restrict stream, 1943 (FILE *restrict stream,
1704 const char *restrict format, va_list args)); 1944 const char *restrict format, va_list args));
@@ -1712,7 +1952,26 @@ _GL_CXXALIASWARN (vfscanf);
1712# endif 1952# endif
1713#endif 1953#endif
1714 1954
1955#if @GNULIB_VZPRINTF@
1956/* Prints formatted output to standard output.
1957 Returns the number of bytes written to standard output. Upon failure,
1958 returns -1 with stdout's error indicator set.
1959 Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
1960 Therefore, if the format string is valid and does not use %ls/%lc
1961 directives nor widths, the only possible failure causes are ENOMEM
1962 and the possible failure causes from fwrite(). */
1963_GL_FUNCDECL_SYS (vzprintf, off64_t,
1964 (const char *restrict format, va_list args),
1965 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
1966 _GL_ARG_NONNULL ((1)));
1967_GL_CXXALIAS_SYS (vzprintf, off64_t,
1968 (const char *restrict format, va_list args));
1969#endif
1970
1715#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ 1971#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
1972/* Prints formatted output to standard output.
1973 Returns the number of bytes written to standard output. Upon failure,
1974 returns a negative value with stdout's error indicator set. */
1716# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \ 1975# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
1717 || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) 1976 || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1718# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1977# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1720,11 +1979,11 @@ _GL_CXXALIASWARN (vfscanf);
1720# endif 1979# endif
1721# define GNULIB_overrides_vprintf 1 1980# define GNULIB_overrides_vprintf 1
1722# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ 1981# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
1723_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args) 1982_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args),
1724 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0) 1983 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
1725 _GL_ARG_NONNULL ((1))); 1984 _GL_ARG_NONNULL ((1)));
1726# else 1985# else
1727_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args) 1986_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args),
1728 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0) 1987 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
1729 _GL_ARG_NONNULL ((1))); 1988 _GL_ARG_NONNULL ((1)));
1730# endif 1989# endif
@@ -1739,11 +1998,13 @@ _GL_CXXALIAS_SYS_CAST (vprintf, int,
1739# if __GLIBC__ >= 2 1998# if __GLIBC__ >= 2
1740_GL_CXXALIASWARN (vprintf); 1999_GL_CXXALIASWARN (vprintf);
1741# endif 2000# endif
1742#endif 2001#elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO
1743#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK 2002# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1744# if !GNULIB_overrides_vprintf
1745# undef vprintf 2003# undef vprintf
2004# define vprintf gl_consolesafe_vprintf
1746# endif 2005# endif
2006#endif
2007#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1747/* Assume vprintf is always declared. */ 2008/* Assume vprintf is always declared. */
1748_GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - " 2009_GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1749 "use gnulib module vprintf-posix for portable " 2010 "use gnulib module vprintf-posix for portable "
@@ -1756,9 +2017,9 @@ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1756# undef vscanf 2017# undef vscanf
1757# define vscanf rpl_vscanf 2018# define vscanf rpl_vscanf
1758# endif 2019# endif
1759_GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args) 2020_GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args),
1760 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0) 2021 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
1761 _GL_ARG_NONNULL ((1))); 2022 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1762_GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args)); 2023_GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args));
1763# else 2024# else
1764_GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args)); 2025_GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args));
@@ -1768,7 +2029,31 @@ _GL_CXXALIASWARN (vscanf);
1768# endif 2029# endif
1769#endif 2030#endif
1770 2031
2032#if @GNULIB_VSNZPRINTF@
2033/* Prints formatted output to string STR. Similar to sprintf, but the
2034 additional parameter SIZE limits how much is written into STR.
2035 STR may be NULL, in which case nothing will be written.
2036 Returns the string length of the formatted string (which may be larger
2037 than SIZE). Upon failure, returns -1 with errno set.
2038 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
2039 Therefore, if the format string is valid and does not use %ls/%lc
2040 directives nor widths, the only possible failure code is ENOMEM. */
2041_GL_FUNCDECL_SYS (vsnzprintf, ptrdiff_t,
2042 (char *restrict str, size_t size,
2043 const char *restrict format, va_list args),
2044 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
2045 _GL_ARG_NONNULL ((3)));
2046_GL_CXXALIAS_SYS (vsnzprintf, ptrdiff_t,
2047 (char *restrict str, size_t size,
2048 const char *restrict format, va_list args));
2049#endif
2050
1771#if @GNULIB_VSNPRINTF@ 2051#if @GNULIB_VSNPRINTF@
2052/* Prints formatted output to string STR. Similar to vsprintf, but the
2053 additional parameter SIZE limits how much is written into STR.
2054 STR may be NULL, in which case nothing will be written.
2055 Returns the string length of the formatted string (which may be larger
2056 than SIZE). Upon failure, returns a negative value. */
1772# if @REPLACE_VSNPRINTF@ 2057# if @REPLACE_VSNPRINTF@
1773# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2058# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1774# define vsnprintf rpl_vsnprintf 2059# define vsnprintf rpl_vsnprintf
@@ -1776,7 +2061,7 @@ _GL_CXXALIASWARN (vscanf);
1776# define GNULIB_overrides_vsnprintf 1 2061# define GNULIB_overrides_vsnprintf 1
1777_GL_FUNCDECL_RPL (vsnprintf, int, 2062_GL_FUNCDECL_RPL (vsnprintf, int,
1778 (char *restrict str, size_t size, 2063 (char *restrict str, size_t size,
1779 const char *restrict format, va_list args) 2064 const char *restrict format, va_list args),
1780 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) 2065 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
1781 _GL_ARG_NONNULL ((3))); 2066 _GL_ARG_NONNULL ((3)));
1782_GL_CXXALIAS_RPL (vsnprintf, int, 2067_GL_CXXALIAS_RPL (vsnprintf, int,
@@ -1786,7 +2071,7 @@ _GL_CXXALIAS_RPL (vsnprintf, int,
1786# if !@HAVE_DECL_VSNPRINTF@ 2071# if !@HAVE_DECL_VSNPRINTF@
1787_GL_FUNCDECL_SYS (vsnprintf, int, 2072_GL_FUNCDECL_SYS (vsnprintf, int,
1788 (char *restrict str, size_t size, 2073 (char *restrict str, size_t size,
1789 const char *restrict format, va_list args) 2074 const char *restrict format, va_list args),
1790 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) 2075 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
1791 _GL_ARG_NONNULL ((3))); 2076 _GL_ARG_NONNULL ((3)));
1792# endif 2077# endif
@@ -1798,14 +2083,33 @@ _GL_CXXALIAS_SYS (vsnprintf, int,
1798_GL_CXXALIASWARN (vsnprintf); 2083_GL_CXXALIASWARN (vsnprintf);
1799# endif 2084# endif
1800#elif defined GNULIB_POSIXCHECK 2085#elif defined GNULIB_POSIXCHECK
1801# undef vsnprintf
1802# if HAVE_RAW_DECL_VSNPRINTF 2086# if HAVE_RAW_DECL_VSNPRINTF
1803_GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " 2087_GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
1804 "use gnulib module vsnprintf for portability"); 2088 "use gnulib module vsnprintf for portability");
1805# endif 2089# endif
1806#endif 2090#endif
1807 2091
2092#if @GNULIB_VSZPRINTF@
2093/* Prints formatted output to string STR.
2094 Returns the string length of the formatted string. Upon failure,
2095 returns -1 with errno set.
2096 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
2097 Therefore, if the format string is valid and does not use %ls/%lc
2098 directives nor widths, the only possible failure code is ENOMEM. */
2099_GL_FUNCDECL_SYS (vszprintf, ptrdiff_t,
2100 (char *restrict str,
2101 const char *restrict format, va_list args),
2102 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
2103 _GL_ARG_NONNULL ((1, 2)));
2104_GL_CXXALIAS_SYS (vszprintf, ptrdiff_t,
2105 (char *restrict str,
2106 const char *restrict format, va_list args));
2107#endif
2108
1808#if @GNULIB_VSPRINTF_POSIX@ 2109#if @GNULIB_VSPRINTF_POSIX@
2110/* Prints formatted output to string STR.
2111 Returns the string length of the formatted string. Upon failure,
2112 returns a negative value. */
1809# if @REPLACE_VSPRINTF@ 2113# if @REPLACE_VSPRINTF@
1810# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2114# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1811# define vsprintf rpl_vsprintf 2115# define vsprintf rpl_vsprintf
@@ -1813,7 +2117,7 @@ _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
1813# define GNULIB_overrides_vsprintf 1 2117# define GNULIB_overrides_vsprintf 1
1814_GL_FUNCDECL_RPL (vsprintf, int, 2118_GL_FUNCDECL_RPL (vsprintf, int,
1815 (char *restrict str, 2119 (char *restrict str,
1816 const char *restrict format, va_list args) 2120 const char *restrict format, va_list args),
1817 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 2121 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1818 _GL_ARG_NONNULL ((1, 2))); 2122 _GL_ARG_NONNULL ((1, 2)));
1819_GL_CXXALIAS_RPL (vsprintf, int, 2123_GL_CXXALIAS_RPL (vsprintf, int,
@@ -1831,7 +2135,6 @@ _GL_CXXALIAS_SYS_CAST (vsprintf, int,
1831_GL_CXXALIASWARN (vsprintf); 2135_GL_CXXALIASWARN (vsprintf);
1832# endif 2136# endif
1833#elif defined GNULIB_POSIXCHECK 2137#elif defined GNULIB_POSIXCHECK
1834# undef vsprintf
1835/* Assume vsprintf is always declared. */ 2138/* Assume vsprintf is always declared. */
1836_GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - " 2139_GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
1837 "use gnulib module vsprintf-posix for portable " 2140 "use gnulib module vsprintf-posix for portable "