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.h461
1 files changed, 367 insertions, 94 deletions
diff --git a/gl/stdio.in.h b/gl/stdio.in.h
index 80b9dbf..06cbad0 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-2010 Free Software Foundation, Inc. 3 Copyright (C) 2004, 2007-2013 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -13,47 +13,104 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#if __GNUC__ >= 3 18#if __GNUC__ >= 3
20@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
21#endif 20#endif
21@PRAGMA_COLUMNS@
22 22
23#if defined __need_FILE || defined __need___FILE 23#if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
24/* Special invocation convention inside glibc header files. */ 24/* Special invocation convention:
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. */
25 31
26#@INCLUDE_NEXT@ @NEXT_STDIO_H@ 32#@INCLUDE_NEXT@ @NEXT_STDIO_H@
27 33
28#else 34#else
29/* Normal invocation convention. */ 35/* Normal invocation convention. */
30 36
31#ifndef _GL_STDIO_H 37#ifndef _@GUARD_PREFIX@_STDIO_H
38
39#define _GL_ALREADY_INCLUDING_STDIO_H
32 40
33/* The include_next requires a split double-inclusion guard. */ 41/* The include_next requires a split double-inclusion guard. */
34#@INCLUDE_NEXT@ @NEXT_STDIO_H@ 42#@INCLUDE_NEXT@ @NEXT_STDIO_H@
35 43
36#ifndef _GL_STDIO_H 44#undef _GL_ALREADY_INCLUDING_STDIO_H
37#define _GL_STDIO_H 45
46#ifndef _@GUARD_PREFIX@_STDIO_H
47#define _@GUARD_PREFIX@_STDIO_H
38 48
39/* Get va_list. Needed on many systems, including glibc 2.8. */ 49/* Get va_list. Needed on many systems, including glibc 2.8. */
40#include <stdarg.h> 50#include <stdarg.h>
41 51
42#include <stddef.h> 52#include <stddef.h>
43 53
44/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8. */ 54/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8
55 and eglibc 2.11.2.
56 May also define off_t to a 64-bit type on native Windows. */
45#include <sys/types.h> 57#include <sys/types.h>
46 58
47#ifndef __attribute__
48/* The __attribute__ feature is available in gcc versions 2.5 and later. 59/* The __attribute__ feature is available in gcc versions 2.5 and later.
49 The __-protected variants of the attributes 'format' and 'printf' are 60 The __-protected variants of the attributes 'format' and 'printf' are
50 accepted by gcc versions 2.6.4 (effectively 2.7) and later. 61 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
51 We enable __attribute__ only if these are supported too, because 62 We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
52 gnulib and libintl do '#define printf __printf__' when they override 63 gnulib and libintl do '#define printf __printf__' when they override
53 the 'printf' function. */ 64 the 'printf' function. */
54# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) 65#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
55# define __attribute__(Spec) /* empty */ 66# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
56# endif 67#else
68# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
69#endif
70
71/* _GL_ATTRIBUTE_FORMAT_PRINTF
72 indicates to GCC that the function takes a format string and arguments,
73 where the format string directives are the ones standardized by ISO C99
74 and POSIX. */
75#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
76# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
77 _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument))
78#else
79# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
80 _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
81#endif
82
83/* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF,
84 except that it indicates to GCC that the supported format string directives
85 are the ones of the system printf(), rather than the ones standardized by
86 ISO C99 and POSIX. */
87#define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
88 _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
89
90/* _GL_ATTRIBUTE_FORMAT_SCANF
91 indicates to GCC that the function takes a format string and arguments,
92 where the format string directives are the ones standardized by ISO C99
93 and POSIX. */
94#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
95# define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
96 _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument))
97#else
98# define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
99 _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
100#endif
101
102/* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF,
103 except that it indicates to GCC that the supported format string directives
104 are the ones of the system scanf(), rather than the ones standardized by
105 ISO C99 and POSIX. */
106#define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
107 _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
108
109/* Solaris 10 declares renameat in <unistd.h>, not in <stdio.h>. */
110/* But in any case avoid namespace pollution on glibc systems. */
111#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \
112 && ! defined __GLIBC__
113# include <unistd.h>
57#endif 114#endif
58 115
59 116
@@ -74,13 +131,13 @@
74# define dprintf rpl_dprintf 131# define dprintf rpl_dprintf
75# endif 132# endif
76_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...) 133_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...)
77 __attribute__ ((__format__ (__printf__, 2, 3))) 134 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
78 _GL_ARG_NONNULL ((2))); 135 _GL_ARG_NONNULL ((2)));
79_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...)); 136_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...));
80# else 137# else
81# if !@HAVE_DPRINTF@ 138# if !@HAVE_DPRINTF@
82_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...) 139_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...)
83 __attribute__ ((__format__ (__printf__, 2, 3))) 140 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
84 _GL_ARG_NONNULL ((2))); 141 _GL_ARG_NONNULL ((2)));
85# endif 142# endif
86_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...)); 143_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...));
@@ -113,6 +170,26 @@ _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
113 "use gnulib module fclose for portable POSIX compliance"); 170 "use gnulib module fclose for portable POSIX compliance");
114#endif 171#endif
115 172
173#if @GNULIB_FDOPEN@
174# if @REPLACE_FDOPEN@
175# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
176# undef fdopen
177# define fdopen rpl_fdopen
178# endif
179_GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode)
180 _GL_ARG_NONNULL ((2)));
181_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
182# else
183_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
184# endif
185_GL_CXXALIASWARN (fdopen);
186#elif defined GNULIB_POSIXCHECK
187# undef fdopen
188/* Assume fdopen is always declared. */
189_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
190 "use gnulib module fdopen for portability");
191#endif
192
116#if @GNULIB_FFLUSH@ 193#if @GNULIB_FFLUSH@
117/* Flush all pending data on STREAM according to POSIX rules. Both 194/* Flush all pending data on STREAM according to POSIX rules. Both
118 output and seekable input streams are supported. 195 output and seekable input streams are supported.
@@ -137,11 +214,34 @@ _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
137 "use gnulib module fflush for portable POSIX compliance"); 214 "use gnulib module fflush for portable POSIX compliance");
138#endif 215#endif
139 216
140/* It is very rare that the developer ever has full control of stdin, 217#if @GNULIB_FGETC@
141 so any use of gets warrants an unconditional warning. Assume it is 218# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
142 always declared, since it is required by C89. */ 219# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
143#undef gets 220# undef fgetc
144_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); 221# define fgetc rpl_fgetc
222# endif
223_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
224_GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
225# else
226_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
227# endif
228_GL_CXXALIASWARN (fgetc);
229#endif
230
231#if @GNULIB_FGETS@
232# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
233# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
234# undef fgets
235# define fgets rpl_fgets
236# endif
237_GL_FUNCDECL_RPL (fgets, char *, (char *s, int n, FILE *stream)
238 _GL_ARG_NONNULL ((1, 3)));
239_GL_CXXALIAS_RPL (fgets, char *, (char *s, int n, FILE *stream));
240# else
241_GL_CXXALIAS_SYS (fgets, char *, (char *s, int n, FILE *stream));
242# endif
243_GL_CXXALIASWARN (fgets);
244#endif
145 245
146#if @GNULIB_FOPEN@ 246#if @GNULIB_FOPEN@
147# if @REPLACE_FOPEN@ 247# if @REPLACE_FOPEN@
@@ -159,20 +259,26 @@ _GL_CXXALIASWARN (fopen);
159#elif defined GNULIB_POSIXCHECK 259#elif defined GNULIB_POSIXCHECK
160# undef fopen 260# undef fopen
161/* Assume fopen is always declared. */ 261/* Assume fopen is always declared. */
162_GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - " 262_GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - "
163 "use gnulib module fopen for portability"); 263 "use gnulib module fopen for portability");
164#endif 264#endif
165 265
166#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@ 266#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
167# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \ 267# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
168 || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) 268 || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
169# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 269# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
170# define fprintf rpl_fprintf 270# define fprintf rpl_fprintf
171# endif 271# endif
172# define GNULIB_overrides_fprintf 1 272# define GNULIB_overrides_fprintf 1
273# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
173_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) 274_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
174 __attribute__ ((__format__ (__printf__, 2, 3))) 275 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
175 _GL_ARG_NONNULL ((1, 2))); 276 _GL_ARG_NONNULL ((1, 2)));
277# else
278_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
279 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
280 _GL_ARG_NONNULL ((1, 2)));
281# endif
176_GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...)); 282_GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...));
177# else 283# else
178_GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...)); 284_GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...));
@@ -218,7 +324,7 @@ _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
218#endif 324#endif
219 325
220#if @GNULIB_FPUTC@ 326#if @GNULIB_FPUTC@
221# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ 327# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
222# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 328# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
223# undef fputc 329# undef fputc
224# define fputc rpl_fputc 330# define fputc rpl_fputc
@@ -232,7 +338,7 @@ _GL_CXXALIASWARN (fputc);
232#endif 338#endif
233 339
234#if @GNULIB_FPUTS@ 340#if @GNULIB_FPUTS@
235# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ 341# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
236# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 342# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
237# undef fputs 343# undef fputs
238# define fputs rpl_fputs 344# define fputs rpl_fputs
@@ -246,6 +352,21 @@ _GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream));
246_GL_CXXALIASWARN (fputs); 352_GL_CXXALIASWARN (fputs);
247#endif 353#endif
248 354
355#if @GNULIB_FREAD@
356# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
357# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
358# undef fread
359# define fread rpl_fread
360# endif
361_GL_FUNCDECL_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)
362 _GL_ARG_NONNULL ((4)));
363_GL_CXXALIAS_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream));
364# else
365_GL_CXXALIAS_SYS (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream));
366# endif
367_GL_CXXALIASWARN (fread);
368#endif
369
249#if @GNULIB_FREOPEN@ 370#if @GNULIB_FREOPEN@
250# if @REPLACE_FREOPEN@ 371# if @REPLACE_FREOPEN@
251# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 372# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -265,10 +386,27 @@ _GL_CXXALIASWARN (freopen);
265#elif defined GNULIB_POSIXCHECK 386#elif defined GNULIB_POSIXCHECK
266# undef freopen 387# undef freopen
267/* Assume freopen is always declared. */ 388/* Assume freopen is always declared. */
268_GL_WARN_ON_USE (freopen, "freopen on Win32 platforms is not POSIX compatible - " 389_GL_WARN_ON_USE (freopen,
390 "freopen on native Windows platforms is not POSIX compliant - "
269 "use gnulib module freopen for portability"); 391 "use gnulib module freopen for portability");
270#endif 392#endif
271 393
394#if @GNULIB_FSCANF@
395# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
396# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
397# undef fscanf
398# define fscanf rpl_fscanf
399# endif
400_GL_FUNCDECL_RPL (fscanf, int, (FILE *stream, const char *format, ...)
401 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
402 _GL_ARG_NONNULL ((1, 2)));
403_GL_CXXALIAS_RPL (fscanf, int, (FILE *stream, const char *format, ...));
404# else
405_GL_CXXALIAS_SYS (fscanf, int, (FILE *stream, const char *format, ...));
406# endif
407_GL_CXXALIASWARN (fscanf);
408#endif
409
272 410
273/* Set up the following warnings, based on which modules are in use. 411/* Set up the following warnings, based on which modules are in use.
274 GNU Coding Standards discourage the use of fseek, since it imposes 412 GNU Coding Standards discourage the use of fseek, since it imposes
@@ -336,29 +474,13 @@ _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
336 _GL_ARG_NONNULL ((1))); 474 _GL_ARG_NONNULL ((1)));
337_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); 475_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
338# else 476# else
339# if ! @HAVE_FSEEKO@ 477# if ! @HAVE_DECL_FSEEKO@
340_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence) 478_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
341 _GL_ARG_NONNULL ((1))); 479 _GL_ARG_NONNULL ((1)));
342# endif 480# endif
343_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); 481_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
344# endif 482# endif
345_GL_CXXALIASWARN (fseeko); 483_GL_CXXALIASWARN (fseeko);
346# if (@REPLACE_FSEEKO@ || !@HAVE_FSEEKO@) && !@GNULIB_FSEEK@
347 /* Provide an fseek function that is consistent with fseeko. */
348 /* In order to avoid that fseek gets defined as a macro here, the
349 developer can request the 'fseek' module. */
350# undef fseek
351# define fseek rpl_fseek
352static inline int _GL_ARG_NONNULL ((1))
353rpl_fseek (FILE *fp, long offset, int whence)
354{
355# if @REPLACE_FSEEKO@
356 return rpl_fseeko (fp, offset, whence);
357# else
358 return fseeko (fp, offset, whence);
359# endif
360}
361# endif
362#elif defined GNULIB_POSIXCHECK 484#elif defined GNULIB_POSIXCHECK
363# define _GL_FSEEK_WARN /* Category 1, above. */ 485# define _GL_FSEEK_WARN /* Category 1, above. */
364# undef fseek 486# undef fseek
@@ -412,28 +534,12 @@ _GL_CXXALIASWARN (ftell);
412_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); 534_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
413_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); 535_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
414# else 536# else
415# if ! @HAVE_FTELLO@ 537# if ! @HAVE_DECL_FTELLO@
416_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); 538_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
417# endif 539# endif
418_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); 540_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
419# endif 541# endif
420_GL_CXXALIASWARN (ftello); 542_GL_CXXALIASWARN (ftello);
421# if (@REPLACE_FTELLO@ || !@HAVE_FTELLO@) && !@GNULIB_FTELL@
422 /* Provide an ftell function that is consistent with ftello. */
423 /* In order to avoid that ftell gets defined as a macro here, the
424 developer can request the 'ftell' module. */
425# undef ftell
426# define ftell rpl_ftell
427static inline long _GL_ARG_NONNULL ((1))
428rpl_ftell (FILE *f)
429{
430# if @REPLACE_FTELLO@
431 return rpl_ftello (f);
432# else
433 return ftello (f);
434# endif
435}
436# endif
437#elif defined GNULIB_POSIXCHECK 543#elif defined GNULIB_POSIXCHECK
438# define _GL_FTELL_WARN /* Category 1, above. */ 544# define _GL_FTELL_WARN /* Category 1, above. */
439# undef ftell 545# undef ftell
@@ -455,7 +561,7 @@ _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
455 561
456 562
457#if @GNULIB_FWRITE@ 563#if @GNULIB_FWRITE@
458# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ 564# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
459# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 565# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
460# undef fwrite 566# undef fwrite
461# define fwrite rpl_fwrite 567# define fwrite rpl_fwrite
@@ -468,10 +574,61 @@ _GL_CXXALIAS_RPL (fwrite, size_t,
468# else 574# else
469_GL_CXXALIAS_SYS (fwrite, size_t, 575_GL_CXXALIAS_SYS (fwrite, size_t,
470 (const void *ptr, size_t s, size_t n, FILE *stream)); 576 (const void *ptr, size_t s, size_t n, FILE *stream));
577
578/* Work around bug 11959 when fortifying glibc 2.4 through 2.15
579 <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>,
580 which sometimes causes an unwanted diagnostic for fwrite calls.
581 This affects only function declaration attributes under certain
582 versions of gcc and clang, and is not needed for C++. */
583# if (0 < __USE_FORTIFY_LEVEL \
584 && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
585 && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \
586 && !defined __cplusplus)
587# undef fwrite
588# undef fwrite_unlocked
589extern size_t __REDIRECT (rpl_fwrite,
590 (const void *__restrict, size_t, size_t,
591 FILE *__restrict),
592 fwrite);
593extern size_t __REDIRECT (rpl_fwrite_unlocked,
594 (const void *__restrict, size_t, size_t,
595 FILE *__restrict),
596 fwrite_unlocked);
597# define fwrite rpl_fwrite
598# define fwrite_unlocked rpl_fwrite_unlocked
599# endif
471# endif 600# endif
472_GL_CXXALIASWARN (fwrite); 601_GL_CXXALIASWARN (fwrite);
473#endif 602#endif
474 603
604#if @GNULIB_GETC@
605# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
606# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
607# undef getc
608# define getc rpl_fgetc
609# endif
610_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
611_GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
612# else
613_GL_CXXALIAS_SYS (getc, int, (FILE *stream));
614# endif
615_GL_CXXALIASWARN (getc);
616#endif
617
618#if @GNULIB_GETCHAR@
619# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
620# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
621# undef getchar
622# define getchar rpl_getchar
623# endif
624_GL_FUNCDECL_RPL (getchar, int, (void));
625_GL_CXXALIAS_RPL (getchar, int, (void));
626# else
627_GL_CXXALIAS_SYS (getchar, int, (void));
628# endif
629_GL_CXXALIASWARN (getchar);
630#endif
631
475#if @GNULIB_GETDELIM@ 632#if @GNULIB_GETDELIM@
476/* Read input, up to (and including) the next occurrence of DELIMITER, from 633/* Read input, up to (and including) the next occurrence of DELIMITER, from
477 STREAM, store it in *LINEPTR (and NUL-terminate it). 634 STREAM, store it in *LINEPTR (and NUL-terminate it).
@@ -548,6 +705,15 @@ _GL_WARN_ON_USE (getline, "getline is unportable - "
548# endif 705# endif
549#endif 706#endif
550 707
708/* It is very rare that the developer ever has full control of stdin,
709 so any use of gets warrants an unconditional warning; besides, C11
710 removed it. */
711#undef gets
712#if HAVE_RAW_DECL_GETS
713_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
714#endif
715
716
551#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ 717#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
552struct obstack; 718struct obstack;
553/* Grow an obstack with formatted output. Return the number of 719/* Grow an obstack with formatted output. Return the number of
@@ -561,7 +727,7 @@ struct obstack;
561# endif 727# endif
562_GL_FUNCDECL_RPL (obstack_printf, int, 728_GL_FUNCDECL_RPL (obstack_printf, int,
563 (struct obstack *obs, const char *format, ...) 729 (struct obstack *obs, const char *format, ...)
564 __attribute__ ((__format__ (__printf__, 2, 3))) 730 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
565 _GL_ARG_NONNULL ((1, 2))); 731 _GL_ARG_NONNULL ((1, 2)));
566_GL_CXXALIAS_RPL (obstack_printf, int, 732_GL_CXXALIAS_RPL (obstack_printf, int,
567 (struct obstack *obs, const char *format, ...)); 733 (struct obstack *obs, const char *format, ...));
@@ -569,7 +735,7 @@ _GL_CXXALIAS_RPL (obstack_printf, int,
569# if !@HAVE_DECL_OBSTACK_PRINTF@ 735# if !@HAVE_DECL_OBSTACK_PRINTF@
570_GL_FUNCDECL_SYS (obstack_printf, int, 736_GL_FUNCDECL_SYS (obstack_printf, int,
571 (struct obstack *obs, const char *format, ...) 737 (struct obstack *obs, const char *format, ...)
572 __attribute__ ((__format__ (__printf__, 2, 3))) 738 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
573 _GL_ARG_NONNULL ((1, 2))); 739 _GL_ARG_NONNULL ((1, 2)));
574# endif 740# endif
575_GL_CXXALIAS_SYS (obstack_printf, int, 741_GL_CXXALIAS_SYS (obstack_printf, int,
@@ -582,7 +748,7 @@ _GL_CXXALIASWARN (obstack_printf);
582# endif 748# endif
583_GL_FUNCDECL_RPL (obstack_vprintf, int, 749_GL_FUNCDECL_RPL (obstack_vprintf, int,
584 (struct obstack *obs, const char *format, va_list args) 750 (struct obstack *obs, const char *format, va_list args)
585 __attribute__ ((__format__ (__printf__, 2, 0))) 751 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
586 _GL_ARG_NONNULL ((1, 2))); 752 _GL_ARG_NONNULL ((1, 2)));
587_GL_CXXALIAS_RPL (obstack_vprintf, int, 753_GL_CXXALIAS_RPL (obstack_vprintf, int,
588 (struct obstack *obs, const char *format, va_list args)); 754 (struct obstack *obs, const char *format, va_list args));
@@ -590,7 +756,7 @@ _GL_CXXALIAS_RPL (obstack_vprintf, int,
590# if !@HAVE_DECL_OBSTACK_PRINTF@ 756# if !@HAVE_DECL_OBSTACK_PRINTF@
591_GL_FUNCDECL_SYS (obstack_vprintf, int, 757_GL_FUNCDECL_SYS (obstack_vprintf, int,
592 (struct obstack *obs, const char *format, va_list args) 758 (struct obstack *obs, const char *format, va_list args)
593 __attribute__ ((__format__ (__printf__, 2, 0))) 759 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
594 _GL_ARG_NONNULL ((1, 2))); 760 _GL_ARG_NONNULL ((1, 2)));
595# endif 761# endif
596_GL_CXXALIAS_SYS (obstack_vprintf, int, 762_GL_CXXALIAS_SYS (obstack_vprintf, int,
@@ -599,6 +765,20 @@ _GL_CXXALIAS_SYS (obstack_vprintf, int,
599_GL_CXXALIASWARN (obstack_vprintf); 765_GL_CXXALIASWARN (obstack_vprintf);
600#endif 766#endif
601 767
768#if @GNULIB_PCLOSE@
769# if !@HAVE_PCLOSE@
770_GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
771# endif
772_GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
773_GL_CXXALIASWARN (pclose);
774#elif defined GNULIB_POSIXCHECK
775# undef pclose
776# if HAVE_RAW_DECL_PCLOSE
777_GL_WARN_ON_USE (pclose, "pclose is unportable - "
778 "use gnulib module pclose for more portability");
779# endif
780#endif
781
602#if @GNULIB_PERROR@ 782#if @GNULIB_PERROR@
603/* Print a message to standard error, describing the value of ERRNO, 783/* Print a message to standard error, describing the value of ERRNO,
604 (if STRING is not NULL and not empty) prefixed with STRING and ": ", 784 (if STRING is not NULL and not empty) prefixed with STRING and ": ",
@@ -630,6 +810,10 @@ _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode)
630 _GL_ARG_NONNULL ((1, 2))); 810 _GL_ARG_NONNULL ((1, 2)));
631_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); 811_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
632# else 812# else
813# if !@HAVE_POPEN@
814_GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode)
815 _GL_ARG_NONNULL ((1, 2)));
816# endif
633_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); 817_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
634# endif 818# endif
635_GL_CXXALIASWARN (popen); 819_GL_CXXALIASWARN (popen);
@@ -643,23 +827,35 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
643 827
644#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ 828#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
645# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ 829# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
646 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) 830 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
647# if defined __GNUC__ 831# if defined __GNUC__
648# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 832# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
649/* Don't break __attribute__((format(printf,M,N))). */ 833/* Don't break __attribute__((format(printf,M,N))). */
650# define printf __printf__ 834# define printf __printf__
651# endif 835# endif
836# if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
837_GL_FUNCDECL_RPL_1 (__printf__, int,
838 (const char *format, ...)
839 __asm__ (@ASM_SYMBOL_PREFIX@
840 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
841 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
842 _GL_ARG_NONNULL ((1)));
843# else
652_GL_FUNCDECL_RPL_1 (__printf__, int, 844_GL_FUNCDECL_RPL_1 (__printf__, int,
653 (const char *format, ...) 845 (const char *format, ...)
654 __asm__ (@ASM_SYMBOL_PREFIX@ 846 __asm__ (@ASM_SYMBOL_PREFIX@
655 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) 847 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
656 __attribute__ ((__format__ (__printf__, 1, 2))) 848 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
657 _GL_ARG_NONNULL ((1))); 849 _GL_ARG_NONNULL ((1)));
850# endif
658_GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); 851_GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
659# else 852# else
853# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
854# define printf rpl_printf
855# endif
660_GL_FUNCDECL_RPL (printf, int, 856_GL_FUNCDECL_RPL (printf, int,
661 (const char *format, ...) 857 (const char *format, ...)
662 __attribute__ ((__format__ (__printf__, 1, 2))) 858 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
663 _GL_ARG_NONNULL ((1))); 859 _GL_ARG_NONNULL ((1)));
664_GL_CXXALIAS_RPL (printf, int, (const char *format, ...)); 860_GL_CXXALIAS_RPL (printf, int, (const char *format, ...));
665# endif 861# endif
@@ -680,7 +876,7 @@ _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
680#endif 876#endif
681 877
682#if @GNULIB_PUTC@ 878#if @GNULIB_PUTC@
683# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ 879# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
684# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 880# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
685# undef putc 881# undef putc
686# define putc rpl_fputc 882# define putc rpl_fputc
@@ -694,7 +890,7 @@ _GL_CXXALIASWARN (putc);
694#endif 890#endif
695 891
696#if @GNULIB_PUTCHAR@ 892#if @GNULIB_PUTCHAR@
697# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ 893# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
698# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 894# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
699# undef putchar 895# undef putchar
700# define putchar rpl_putchar 896# define putchar rpl_putchar
@@ -708,7 +904,7 @@ _GL_CXXALIASWARN (putchar);
708#endif 904#endif
709 905
710#if @GNULIB_PUTS@ 906#if @GNULIB_PUTS@
711# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ 907# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
712# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 908# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
713# undef puts 909# undef puts
714# define puts rpl_puts 910# define puts rpl_puts
@@ -792,6 +988,37 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - "
792# endif 988# endif
793#endif 989#endif
794 990
991#if @GNULIB_SCANF@
992# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
993# if defined __GNUC__
994# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
995# undef scanf
996/* Don't break __attribute__((format(scanf,M,N))). */
997# define scanf __scanf__
998# endif
999_GL_FUNCDECL_RPL_1 (__scanf__, int,
1000 (const char *format, ...)
1001 __asm__ (@ASM_SYMBOL_PREFIX@
1002 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf))
1003 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1004 _GL_ARG_NONNULL ((1)));
1005_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *format, ...));
1006# else
1007# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1008# undef scanf
1009# define scanf rpl_scanf
1010# endif
1011_GL_FUNCDECL_RPL (scanf, int, (const char *format, ...)
1012 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1013 _GL_ARG_NONNULL ((1)));
1014_GL_CXXALIAS_RPL (scanf, int, (const char *format, ...));
1015# endif
1016# else
1017_GL_CXXALIAS_SYS (scanf, int, (const char *format, ...));
1018# endif
1019_GL_CXXALIASWARN (scanf);
1020#endif
1021
795#if @GNULIB_SNPRINTF@ 1022#if @GNULIB_SNPRINTF@
796# if @REPLACE_SNPRINTF@ 1023# if @REPLACE_SNPRINTF@
797# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1024# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -799,7 +1026,7 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - "
799# endif 1026# endif
800_GL_FUNCDECL_RPL (snprintf, int, 1027_GL_FUNCDECL_RPL (snprintf, int,
801 (char *str, size_t size, const char *format, ...) 1028 (char *str, size_t size, const char *format, ...)
802 __attribute__ ((__format__ (__printf__, 3, 4))) 1029 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
803 _GL_ARG_NONNULL ((3))); 1030 _GL_ARG_NONNULL ((3)));
804_GL_CXXALIAS_RPL (snprintf, int, 1031_GL_CXXALIAS_RPL (snprintf, int,
805 (char *str, size_t size, const char *format, ...)); 1032 (char *str, size_t size, const char *format, ...));
@@ -807,7 +1034,7 @@ _GL_CXXALIAS_RPL (snprintf, int,
807# if !@HAVE_DECL_SNPRINTF@ 1034# if !@HAVE_DECL_SNPRINTF@
808_GL_FUNCDECL_SYS (snprintf, int, 1035_GL_FUNCDECL_SYS (snprintf, int,
809 (char *str, size_t size, const char *format, ...) 1036 (char *str, size_t size, const char *format, ...)
810 __attribute__ ((__format__ (__printf__, 3, 4))) 1037 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
811 _GL_ARG_NONNULL ((3))); 1038 _GL_ARG_NONNULL ((3)));
812# endif 1039# endif
813_GL_CXXALIAS_SYS (snprintf, int, 1040_GL_CXXALIAS_SYS (snprintf, int,
@@ -822,9 +1049,9 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
822# endif 1049# endif
823#endif 1050#endif
824 1051
825/* Some people would argue that sprintf should be handled like gets 1052/* Some people would argue that all sprintf uses should be warned about
826 (for example, OpenBSD issues a link warning for both functions), 1053 (for example, OpenBSD issues a link warning for it),
827 since both can cause security holes due to buffer overruns. 1054 since it can cause security holes due to buffer overruns.
828 However, we believe that sprintf can be used safely, and is more 1055 However, we believe that sprintf can be used safely, and is more
829 efficient than snprintf in those safe cases; and as proof of our 1056 efficient than snprintf in those safe cases; and as proof of our
830 belief, we use sprintf in several gnulib modules. So this header 1057 belief, we use sprintf in several gnulib modules. So this header
@@ -837,7 +1064,7 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
837# define sprintf rpl_sprintf 1064# define sprintf rpl_sprintf
838# endif 1065# endif
839_GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...) 1066_GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...)
840 __attribute__ ((__format__ (__printf__, 2, 3))) 1067 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
841 _GL_ARG_NONNULL ((1, 2))); 1068 _GL_ARG_NONNULL ((1, 2)));
842_GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...)); 1069_GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...));
843# else 1070# else
@@ -882,7 +1109,7 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
882# endif 1109# endif
883_GL_FUNCDECL_RPL (asprintf, int, 1110_GL_FUNCDECL_RPL (asprintf, int,
884 (char **result, const char *format, ...) 1111 (char **result, const char *format, ...)
885 __attribute__ ((__format__ (__printf__, 2, 3))) 1112 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
886 _GL_ARG_NONNULL ((1, 2))); 1113 _GL_ARG_NONNULL ((1, 2)));
887_GL_CXXALIAS_RPL (asprintf, int, 1114_GL_CXXALIAS_RPL (asprintf, int,
888 (char **result, const char *format, ...)); 1115 (char **result, const char *format, ...));
@@ -890,7 +1117,7 @@ _GL_CXXALIAS_RPL (asprintf, int,
890# if !@HAVE_VASPRINTF@ 1117# if !@HAVE_VASPRINTF@
891_GL_FUNCDECL_SYS (asprintf, int, 1118_GL_FUNCDECL_SYS (asprintf, int,
892 (char **result, const char *format, ...) 1119 (char **result, const char *format, ...)
893 __attribute__ ((__format__ (__printf__, 2, 3))) 1120 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
894 _GL_ARG_NONNULL ((1, 2))); 1121 _GL_ARG_NONNULL ((1, 2)));
895# endif 1122# endif
896_GL_CXXALIAS_SYS (asprintf, int, 1123_GL_CXXALIAS_SYS (asprintf, int,
@@ -903,7 +1130,7 @@ _GL_CXXALIASWARN (asprintf);
903# endif 1130# endif
904_GL_FUNCDECL_RPL (vasprintf, int, 1131_GL_FUNCDECL_RPL (vasprintf, int,
905 (char **result, const char *format, va_list args) 1132 (char **result, const char *format, va_list args)
906 __attribute__ ((__format__ (__printf__, 2, 0))) 1133 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
907 _GL_ARG_NONNULL ((1, 2))); 1134 _GL_ARG_NONNULL ((1, 2)));
908_GL_CXXALIAS_RPL (vasprintf, int, 1135_GL_CXXALIAS_RPL (vasprintf, int,
909 (char **result, const char *format, va_list args)); 1136 (char **result, const char *format, va_list args));
@@ -911,7 +1138,7 @@ _GL_CXXALIAS_RPL (vasprintf, int,
911# if !@HAVE_VASPRINTF@ 1138# if !@HAVE_VASPRINTF@
912_GL_FUNCDECL_SYS (vasprintf, int, 1139_GL_FUNCDECL_SYS (vasprintf, int,
913 (char **result, const char *format, va_list args) 1140 (char **result, const char *format, va_list args)
914 __attribute__ ((__format__ (__printf__, 2, 0))) 1141 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
915 _GL_ARG_NONNULL ((1, 2))); 1142 _GL_ARG_NONNULL ((1, 2)));
916# endif 1143# endif
917_GL_CXXALIAS_SYS (vasprintf, int, 1144_GL_CXXALIAS_SYS (vasprintf, int,
@@ -926,13 +1153,13 @@ _GL_CXXALIASWARN (vasprintf);
926# define vdprintf rpl_vdprintf 1153# define vdprintf rpl_vdprintf
927# endif 1154# endif
928_GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args) 1155_GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args)
929 __attribute__ ((__format__ (__printf__, 2, 0))) 1156 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
930 _GL_ARG_NONNULL ((2))); 1157 _GL_ARG_NONNULL ((2)));
931_GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args)); 1158_GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args));
932# else 1159# else
933# if !@HAVE_VDPRINTF@ 1160# if !@HAVE_VDPRINTF@
934_GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args) 1161_GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args)
935 __attribute__ ((__format__ (__printf__, 2, 0))) 1162 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
936 _GL_ARG_NONNULL ((2))); 1163 _GL_ARG_NONNULL ((2)));
937# endif 1164# endif
938/* Need to cast, because on Solaris, the third parameter will likely be 1165/* Need to cast, because on Solaris, the third parameter will likely be
@@ -951,14 +1178,20 @@ _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
951 1178
952#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@ 1179#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
953# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \ 1180# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
954 || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) 1181 || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
955# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1182# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
956# define vfprintf rpl_vfprintf 1183# define vfprintf rpl_vfprintf
957# endif 1184# endif
958# define GNULIB_overrides_vfprintf 1 1185# define GNULIB_overrides_vfprintf 1
1186# if @GNULIB_VFPRINTF_POSIX@
1187_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
1188 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1189 _GL_ARG_NONNULL ((1, 2)));
1190# else
959_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) 1191_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
960 __attribute__ ((__format__ (__printf__, 2, 0))) 1192 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
961 _GL_ARG_NONNULL ((1, 2))); 1193 _GL_ARG_NONNULL ((1, 2)));
1194# endif
962_GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)); 1195_GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
963# else 1196# else
964/* Need to cast, because on Solaris, the third parameter is 1197/* Need to cast, because on Solaris, the third parameter is
@@ -979,16 +1212,41 @@ _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
979 "POSIX compliance"); 1212 "POSIX compliance");
980#endif 1213#endif
981 1214
1215#if @GNULIB_VFSCANF@
1216# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
1217# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1218# undef vfscanf
1219# define vfscanf rpl_vfscanf
1220# endif
1221_GL_FUNCDECL_RPL (vfscanf, int,
1222 (FILE *stream, const char *format, va_list args)
1223 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
1224 _GL_ARG_NONNULL ((1, 2)));
1225_GL_CXXALIAS_RPL (vfscanf, int,
1226 (FILE *stream, const char *format, va_list args));
1227# else
1228_GL_CXXALIAS_SYS (vfscanf, int,
1229 (FILE *stream, const char *format, va_list args));
1230# endif
1231_GL_CXXALIASWARN (vfscanf);
1232#endif
1233
982#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ 1234#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
983# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \ 1235# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
984 || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) 1236 || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
985# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1237# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
986# define vprintf rpl_vprintf 1238# define vprintf rpl_vprintf
987# endif 1239# endif
988# define GNULIB_overrides_vprintf 1 1240# define GNULIB_overrides_vprintf 1
1241# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
989_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) 1242_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
990 __attribute__ ((__format__ (__printf__, 1, 0))) 1243 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0)
991 _GL_ARG_NONNULL ((1))); 1244 _GL_ARG_NONNULL ((1)));
1245# else
1246_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
1247 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
1248 _GL_ARG_NONNULL ((1)));
1249# endif
992_GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args)); 1250_GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
993# else 1251# else
994/* Need to cast, because on Solaris, the second parameter is 1252/* Need to cast, because on Solaris, the second parameter is
@@ -1008,6 +1266,22 @@ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1008 "POSIX compliance"); 1266 "POSIX compliance");
1009#endif 1267#endif
1010 1268
1269#if @GNULIB_VSCANF@
1270# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
1271# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1272# undef vscanf
1273# define vscanf rpl_vscanf
1274# endif
1275_GL_FUNCDECL_RPL (vscanf, int, (const char *format, va_list args)
1276 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
1277 _GL_ARG_NONNULL ((1)));
1278_GL_CXXALIAS_RPL (vscanf, int, (const char *format, va_list args));
1279# else
1280_GL_CXXALIAS_SYS (vscanf, int, (const char *format, va_list args));
1281# endif
1282_GL_CXXALIASWARN (vscanf);
1283#endif
1284
1011#if @GNULIB_VSNPRINTF@ 1285#if @GNULIB_VSNPRINTF@
1012# if @REPLACE_VSNPRINTF@ 1286# if @REPLACE_VSNPRINTF@
1013# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1287# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1015,7 +1289,7 @@ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1015# endif 1289# endif
1016_GL_FUNCDECL_RPL (vsnprintf, int, 1290_GL_FUNCDECL_RPL (vsnprintf, int,
1017 (char *str, size_t size, const char *format, va_list args) 1291 (char *str, size_t size, const char *format, va_list args)
1018 __attribute__ ((__format__ (__printf__, 3, 0))) 1292 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
1019 _GL_ARG_NONNULL ((3))); 1293 _GL_ARG_NONNULL ((3)));
1020_GL_CXXALIAS_RPL (vsnprintf, int, 1294_GL_CXXALIAS_RPL (vsnprintf, int,
1021 (char *str, size_t size, const char *format, va_list args)); 1295 (char *str, size_t size, const char *format, va_list args));
@@ -1023,7 +1297,7 @@ _GL_CXXALIAS_RPL (vsnprintf, int,
1023# if !@HAVE_DECL_VSNPRINTF@ 1297# if !@HAVE_DECL_VSNPRINTF@
1024_GL_FUNCDECL_SYS (vsnprintf, int, 1298_GL_FUNCDECL_SYS (vsnprintf, int,
1025 (char *str, size_t size, const char *format, va_list args) 1299 (char *str, size_t size, const char *format, va_list args)
1026 __attribute__ ((__format__ (__printf__, 3, 0))) 1300 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
1027 _GL_ARG_NONNULL ((3))); 1301 _GL_ARG_NONNULL ((3)));
1028# endif 1302# endif
1029_GL_CXXALIAS_SYS (vsnprintf, int, 1303_GL_CXXALIAS_SYS (vsnprintf, int,
@@ -1045,7 +1319,7 @@ _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
1045# endif 1319# endif
1046_GL_FUNCDECL_RPL (vsprintf, int, 1320_GL_FUNCDECL_RPL (vsprintf, int,
1047 (char *str, const char *format, va_list args) 1321 (char *str, const char *format, va_list args)
1048 __attribute__ ((__format__ (__printf__, 2, 0))) 1322 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1049 _GL_ARG_NONNULL ((1, 2))); 1323 _GL_ARG_NONNULL ((1, 2)));
1050_GL_CXXALIAS_RPL (vsprintf, int, 1324_GL_CXXALIAS_RPL (vsprintf, int,
1051 (char *str, const char *format, va_list args)); 1325 (char *str, const char *format, va_list args));
@@ -1065,7 +1339,6 @@ _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
1065 "POSIX compliance"); 1339 "POSIX compliance");
1066#endif 1340#endif
1067 1341
1068 1342#endif /* _@GUARD_PREFIX@_STDIO_H */
1069#endif /* _GL_STDIO_H */ 1343#endif /* _@GUARD_PREFIX@_STDIO_H */
1070#endif /* _GL_STDIO_H */
1071#endif 1344#endif