diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-07 21:11:46 -0400 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-12 21:26:35 -0400 |
commit | 74da141e618ef99959d509cb2e7be35a348a39db (patch) | |
tree | 88ebc38b381a1021fc2d74864a71e230ae591c3d /gl/stdio.in.h | |
parent | c63a4f726a0b6ad8cf6040f947754a81fd4683bb (diff) | |
download | monitoring-plugins-74da141e618ef99959d509cb2e7be35a348a39db.tar.gz |
Sync with the latest Gnulib code (177f525)
Signed-off-by: Thomas Guyot-Sionnest <dermoth@aei.ca>
Diffstat (limited to 'gl/stdio.in.h')
-rw-r--r-- | gl/stdio.in.h | 1269 |
1 files changed, 901 insertions, 368 deletions
diff --git a/gl/stdio.in.h b/gl/stdio.in.h index cb273d76..dcb8ee57 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-2008 Free Software Foundation, Inc. | 3 | Copyright (C) 2004, 2007-2010 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 |
@@ -36,489 +36,1022 @@ | |||
36 | #ifndef _GL_STDIO_H | 36 | #ifndef _GL_STDIO_H |
37 | #define _GL_STDIO_H | 37 | #define _GL_STDIO_H |
38 | 38 | ||
39 | /* Get va_list. Needed on many systems, including glibc 2.8. */ | ||
39 | #include <stdarg.h> | 40 | #include <stdarg.h> |
41 | |||
40 | #include <stddef.h> | 42 | #include <stddef.h> |
41 | 43 | ||
42 | #if (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) \ | 44 | /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8. */ |
43 | || (@GNULIB_FTELLO@ && @REPLACE_FTELLO@) \ | 45 | #include <sys/types.h> |
44 | || (@GNULIB_GETDELIM@ && !@HAVE_DECL_GETDELIM@) \ | ||
45 | || (@GNULIB_GETLINE@ && (!@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@)) | ||
46 | /* Get off_t and ssize_t. */ | ||
47 | # include <sys/types.h> | ||
48 | #endif | ||
49 | 46 | ||
50 | #ifndef __attribute__ | 47 | #ifndef __attribute__ |
51 | /* This feature is available in gcc versions 2.5 and later. */ | 48 | /* The __attribute__ feature is available in gcc versions 2.5 and later. |
52 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) | 49 | The __-protected variants of the attributes 'format' and 'printf' are |
53 | # define __attribute__(Spec) /* empty */ | 50 | accepted by gcc versions 2.6.4 (effectively 2.7) and later. |
54 | # endif | 51 | We enable __attribute__ only if these are supported too, because |
55 | /* The __-protected variants of `format' and `printf' attributes | 52 | gnulib and libintl do '#define printf __printf__' when they override |
56 | are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ | 53 | the 'printf' function. */ |
57 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) | 54 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) |
58 | # define __format__ format | 55 | # define __attribute__(Spec) /* empty */ |
59 | # define __printf__ printf | ||
60 | # endif | 56 | # endif |
61 | #endif | 57 | #endif |
62 | 58 | ||
63 | 59 | ||
64 | /* The definition of GL_LINK_WARNING is copied here. */ | 60 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
65 | 61 | ||
62 | /* The definition of _GL_ARG_NONNULL is copied here. */ | ||
66 | 63 | ||
67 | #ifdef __cplusplus | 64 | /* The definition of _GL_WARN_ON_USE is copied here. */ |
68 | extern "C" { | ||
69 | #endif | ||
70 | 65 | ||
71 | 66 | ||
72 | #if @GNULIB_FPRINTF_POSIX@ | 67 | #if @GNULIB_DPRINTF@ |
73 | # if @REPLACE_FPRINTF@ | 68 | # if @REPLACE_DPRINTF@ |
74 | # define fprintf rpl_fprintf | 69 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
75 | extern int fprintf (FILE *fp, const char *format, ...) | 70 | # define dprintf rpl_dprintf |
76 | __attribute__ ((__format__ (__printf__, 2, 3))); | 71 | # endif |
72 | _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...) | ||
73 | __attribute__ ((__format__ (__printf__, 2, 3))) | ||
74 | _GL_ARG_NONNULL ((2))); | ||
75 | _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...)); | ||
76 | # else | ||
77 | # if !@HAVE_DPRINTF@ | ||
78 | _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...) | ||
79 | __attribute__ ((__format__ (__printf__, 2, 3))) | ||
80 | _GL_ARG_NONNULL ((2))); | ||
81 | # endif | ||
82 | _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...)); | ||
77 | # endif | 83 | # endif |
78 | #elif @GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | 84 | _GL_CXXALIASWARN (dprintf); |
79 | # define fprintf rpl_fprintf | ||
80 | extern int fprintf (FILE *fp, const char *format, ...) | ||
81 | __attribute__ ((__format__ (__printf__, 2, 3))); | ||
82 | #elif defined GNULIB_POSIXCHECK | 85 | #elif defined GNULIB_POSIXCHECK |
83 | # undef fprintf | 86 | # undef dprintf |
84 | # define fprintf \ | 87 | # if HAVE_RAW_DECL_DPRINTF |
85 | (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \ | 88 | _GL_WARN_ON_USE (dprintf, "dprintf is unportable - " |
86 | "use gnulib module fprintf-posix for portable " \ | 89 | "use gnulib module dprintf for portability"); |
87 | "POSIX compliance"), \ | 90 | # endif |
88 | fprintf) | 91 | #endif |
89 | #endif | 92 | |
90 | 93 | #if @GNULIB_FCLOSE@ | |
91 | #if @GNULIB_VFPRINTF_POSIX@ | 94 | /* Close STREAM and its underlying file descriptor. */ |
92 | # if @REPLACE_VFPRINTF@ | 95 | # if @REPLACE_FCLOSE@ |
93 | # define vfprintf rpl_vfprintf | 96 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
94 | extern int vfprintf (FILE *fp, const char *format, va_list args) | 97 | # define fclose rpl_fclose |
95 | __attribute__ ((__format__ (__printf__, 2, 0))); | 98 | # endif |
96 | # endif | 99 | _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); |
97 | #elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | 100 | _GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); |
98 | # define vfprintf rpl_vfprintf | 101 | # else |
99 | extern int vfprintf (FILE *fp, const char *format, va_list args) | 102 | _GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); |
100 | __attribute__ ((__format__ (__printf__, 2, 0))); | 103 | # endif |
104 | _GL_CXXALIASWARN (fclose); | ||
101 | #elif defined GNULIB_POSIXCHECK | 105 | #elif defined GNULIB_POSIXCHECK |
102 | # undef vfprintf | 106 | # undef fclose |
103 | # define vfprintf(s,f,a) \ | 107 | /* Assume fclose is always declared. */ |
104 | (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \ | 108 | _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - " |
105 | "use gnulib module vfprintf-posix for portable " \ | 109 | "use gnulib module fclose for portable POSIX compliance"); |
106 | "POSIX compliance"), \ | ||
107 | vfprintf (s, f, a)) | ||
108 | #endif | 110 | #endif |
109 | 111 | ||
110 | #if @GNULIB_PRINTF_POSIX@ | 112 | #if @GNULIB_FFLUSH@ |
111 | # if @REPLACE_PRINTF@ | 113 | /* Flush all pending data on STREAM according to POSIX rules. Both |
112 | /* Don't break __attribute__((format(printf,M,N))). */ | 114 | output and seekable input streams are supported. |
113 | # define printf __printf__ | 115 | Note! LOSS OF DATA can occur if fflush is applied on an input stream |
114 | extern int printf (const char *format, ...) | 116 | that is _not_seekable_ or on an update stream that is _not_seekable_ |
115 | __attribute__ ((__format__ (__printf__, 1, 2))); | 117 | and in which the most recent operation was input. Seekability can |
118 | be tested with lseek(fileno(fp),0,SEEK_CUR). */ | ||
119 | # if @REPLACE_FFLUSH@ | ||
120 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
121 | # define fflush rpl_fflush | ||
122 | # endif | ||
123 | _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream)); | ||
124 | _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream)); | ||
125 | # else | ||
126 | _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); | ||
116 | # endif | 127 | # endif |
117 | #elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | 128 | _GL_CXXALIASWARN (fflush); |
118 | /* Don't break __attribute__((format(printf,M,N))). */ | ||
119 | # define printf __printf__ | ||
120 | extern int printf (const char *format, ...) | ||
121 | __attribute__ ((__format__ (__printf__, 1, 2))); | ||
122 | #elif defined GNULIB_POSIXCHECK | 129 | #elif defined GNULIB_POSIXCHECK |
123 | # undef printf | 130 | # undef fflush |
124 | # define printf \ | 131 | /* Assume fflush is always declared. */ |
125 | (GL_LINK_WARNING ("printf is not always POSIX compliant - " \ | 132 | _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " |
126 | "use gnulib module printf-posix for portable " \ | 133 | "use gnulib module fflush for portable POSIX compliance"); |
127 | "POSIX compliance"), \ | 134 | #endif |
128 | printf) | 135 | |
129 | /* Don't break __attribute__((format(printf,M,N))). */ | 136 | /* It is very rare that the developer ever has full control of stdin, |
130 | # define format(kind,m,n) format (__##kind##__, m, n) | 137 | so any use of gets warrants an unconditional warning. Assume it is |
131 | # define __format__(kind,m,n) __format__ (__##kind##__, m, n) | 138 | always declared, since it is required by C89. */ |
132 | # define ____printf____ __printf__ | 139 | #undef gets |
133 | # define ____scanf____ __scanf__ | 140 | _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); |
134 | # define ____strftime____ __strftime__ | 141 | |
135 | # define ____strfmon____ __strfmon__ | 142 | #if @GNULIB_FOPEN@ |
136 | #endif | 143 | # if @REPLACE_FOPEN@ |
137 | 144 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
138 | #if @GNULIB_VPRINTF_POSIX@ | 145 | # undef fopen |
139 | # if @REPLACE_VPRINTF@ | 146 | # define fopen rpl_fopen |
140 | # define vprintf rpl_vprintf | 147 | # endif |
141 | extern int vprintf (const char *format, va_list args) | 148 | _GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode) |
142 | __attribute__ ((__format__ (__printf__, 1, 0))); | 149 | _GL_ARG_NONNULL ((1, 2))); |
143 | # endif | 150 | _GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode)); |
144 | #elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | 151 | # else |
145 | # define vprintf rpl_vprintf | 152 | _GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode)); |
146 | extern int vprintf (const char *format, va_list args) | 153 | # endif |
147 | __attribute__ ((__format__ (__printf__, 1, 0))); | 154 | _GL_CXXALIASWARN (fopen); |
148 | #elif defined GNULIB_POSIXCHECK | 155 | #elif defined GNULIB_POSIXCHECK |
149 | # undef vprintf | 156 | # undef fopen |
150 | # define vprintf(f,a) \ | 157 | /* Assume fopen is always declared. */ |
151 | (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \ | 158 | _GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - " |
152 | "use gnulib module vprintf-posix for portable " \ | 159 | "use gnulib module fopen for portability"); |
153 | "POSIX compliance"), \ | ||
154 | vprintf (f, a)) | ||
155 | #endif | 160 | #endif |
156 | 161 | ||
157 | #if @GNULIB_SNPRINTF@ | 162 | #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@ |
158 | # if @REPLACE_SNPRINTF@ | 163 | # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \ |
159 | # define snprintf rpl_snprintf | 164 | || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) |
165 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
166 | # define fprintf rpl_fprintf | ||
167 | # endif | ||
168 | # define GNULIB_overrides_fprintf 1 | ||
169 | _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) | ||
170 | __attribute__ ((__format__ (__printf__, 2, 3))) | ||
171 | _GL_ARG_NONNULL ((1, 2))); | ||
172 | _GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...)); | ||
173 | # else | ||
174 | _GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...)); | ||
175 | # endif | ||
176 | _GL_CXXALIASWARN (fprintf); | ||
177 | #endif | ||
178 | #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK | ||
179 | # if !GNULIB_overrides_fprintf | ||
180 | # undef fprintf | ||
160 | # endif | 181 | # endif |
161 | # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@ | 182 | /* Assume fprintf is always declared. */ |
162 | extern int snprintf (char *str, size_t size, const char *format, ...) | 183 | _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - " |
163 | __attribute__ ((__format__ (__printf__, 3, 4))); | 184 | "use gnulib module fprintf-posix for portable " |
185 | "POSIX compliance"); | ||
186 | #endif | ||
187 | |||
188 | #if @GNULIB_FPURGE@ | ||
189 | /* Discard all pending buffered I/O data on STREAM. | ||
190 | STREAM must not be wide-character oriented. | ||
191 | When discarding pending output, the file position is set back to where it | ||
192 | was before the write calls. When discarding pending input, the file | ||
193 | position is advanced to match the end of the previously read input. | ||
194 | Return 0 if successful. Upon error, return -1 and set errno. */ | ||
195 | # if @REPLACE_FPURGE@ | ||
196 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
197 | # define fpurge rpl_fpurge | ||
198 | # endif | ||
199 | _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); | ||
200 | _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream)); | ||
201 | # else | ||
202 | # if !@HAVE_DECL_FPURGE@ | ||
203 | _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); | ||
204 | # endif | ||
205 | _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); | ||
164 | # endif | 206 | # endif |
207 | _GL_CXXALIASWARN (fpurge); | ||
165 | #elif defined GNULIB_POSIXCHECK | 208 | #elif defined GNULIB_POSIXCHECK |
166 | # undef snprintf | 209 | # undef fpurge |
167 | # define snprintf \ | 210 | # if HAVE_RAW_DECL_FPURGE |
168 | (GL_LINK_WARNING ("snprintf is unportable - " \ | 211 | _GL_WARN_ON_USE (fpurge, "fpurge is not always present - " |
169 | "use gnulib module snprintf for portability"), \ | 212 | "use gnulib module fpurge for portability"); |
170 | snprintf) | 213 | # endif |
171 | #endif | 214 | #endif |
172 | 215 | ||
173 | #if @GNULIB_VSNPRINTF@ | 216 | #if @GNULIB_FPUTC@ |
174 | # if @REPLACE_VSNPRINTF@ | 217 | # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ |
175 | # define vsnprintf rpl_vsnprintf | 218 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
219 | # undef fputc | ||
220 | # define fputc rpl_fputc | ||
221 | # endif | ||
222 | _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); | ||
223 | _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); | ||
224 | # else | ||
225 | _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); | ||
176 | # endif | 226 | # endif |
177 | # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@ | 227 | _GL_CXXALIASWARN (fputc); |
178 | extern int vsnprintf (char *str, size_t size, const char *format, va_list args) | 228 | #endif |
179 | __attribute__ ((__format__ (__printf__, 3, 0))); | 229 | |
230 | #if @GNULIB_FPUTS@ | ||
231 | # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | ||
232 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
233 | # undef fputs | ||
234 | # define fputs rpl_fputs | ||
235 | # endif | ||
236 | _GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream) | ||
237 | _GL_ARG_NONNULL ((1, 2))); | ||
238 | _GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream)); | ||
239 | # else | ||
240 | _GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream)); | ||
180 | # endif | 241 | # endif |
181 | #elif defined GNULIB_POSIXCHECK | 242 | _GL_CXXALIASWARN (fputs); |
182 | # undef vsnprintf | ||
183 | # define vsnprintf(b,s,f,a) \ | ||
184 | (GL_LINK_WARNING ("vsnprintf is unportable - " \ | ||
185 | "use gnulib module vsnprintf for portability"), \ | ||
186 | vsnprintf (b, s, f, a)) | ||
187 | #endif | 243 | #endif |
188 | 244 | ||
189 | #if @GNULIB_SPRINTF_POSIX@ | 245 | #if @GNULIB_FREOPEN@ |
190 | # if @REPLACE_SPRINTF@ | 246 | # if @REPLACE_FREOPEN@ |
191 | # define sprintf rpl_sprintf | 247 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
192 | extern int sprintf (char *str, const char *format, ...) | 248 | # undef freopen |
193 | __attribute__ ((__format__ (__printf__, 2, 3))); | 249 | # define freopen rpl_freopen |
250 | # endif | ||
251 | _GL_FUNCDECL_RPL (freopen, FILE *, | ||
252 | (const char *filename, const char *mode, FILE *stream) | ||
253 | _GL_ARG_NONNULL ((2, 3))); | ||
254 | _GL_CXXALIAS_RPL (freopen, FILE *, | ||
255 | (const char *filename, const char *mode, FILE *stream)); | ||
256 | # else | ||
257 | _GL_CXXALIAS_SYS (freopen, FILE *, | ||
258 | (const char *filename, const char *mode, FILE *stream)); | ||
194 | # endif | 259 | # endif |
260 | _GL_CXXALIASWARN (freopen); | ||
195 | #elif defined GNULIB_POSIXCHECK | 261 | #elif defined GNULIB_POSIXCHECK |
196 | # undef sprintf | 262 | # undef freopen |
197 | # define sprintf \ | 263 | /* Assume freopen is always declared. */ |
198 | (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \ | 264 | _GL_WARN_ON_USE (freopen, "freopen on Win32 platforms is not POSIX compatible - " |
199 | "use gnulib module sprintf-posix for portable " \ | 265 | "use gnulib module freopen for portability"); |
200 | "POSIX compliance"), \ | ||
201 | sprintf) | ||
202 | #endif | 266 | #endif |
203 | 267 | ||
204 | #if @GNULIB_VSPRINTF_POSIX@ | 268 | |
205 | # if @REPLACE_VSPRINTF@ | 269 | /* Set up the following warnings, based on which modules are in use. |
206 | # define vsprintf rpl_vsprintf | 270 | GNU Coding Standards discourage the use of fseek, since it imposes |
207 | extern int vsprintf (char *str, const char *format, va_list args) | 271 | an arbitrary limitation on some 32-bit hosts. Remember that the |
208 | __attribute__ ((__format__ (__printf__, 2, 0))); | 272 | fseek module depends on the fseeko module, so we only have three |
273 | cases to consider: | ||
274 | |||
275 | 1. The developer is not using either module. Issue a warning under | ||
276 | GNULIB_POSIXCHECK for both functions, to remind them that both | ||
277 | functions have bugs on some systems. _GL_NO_LARGE_FILES has no | ||
278 | impact on this warning. | ||
279 | |||
280 | 2. The developer is using both modules. They may be unaware of the | ||
281 | arbitrary limitations of fseek, so issue a warning under | ||
282 | GNULIB_POSIXCHECK. On the other hand, they may be using both | ||
283 | modules intentionally, so the developer can define | ||
284 | _GL_NO_LARGE_FILES in the compilation units where the use of fseek | ||
285 | is safe, to silence the warning. | ||
286 | |||
287 | 3. The developer is using the fseeko module, but not fseek. Gnulib | ||
288 | guarantees that fseek will still work around platform bugs in that | ||
289 | case, but we presume that the developer is aware of the pitfalls of | ||
290 | fseek and was trying to avoid it, so issue a warning even when | ||
291 | GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be | ||
292 | defined to silence the warning in particular compilation units. | ||
293 | In C++ compilations with GNULIB_NAMESPACE, in order to avoid that | ||
294 | fseek gets defined as a macro, it is recommended that the developer | ||
295 | uses the fseek module, even if he is not calling the fseek function. | ||
296 | |||
297 | Most gnulib clients that perform stream operations should fall into | ||
298 | category 3. */ | ||
299 | |||
300 | #if @GNULIB_FSEEK@ | ||
301 | # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES | ||
302 | # define _GL_FSEEK_WARN /* Category 2, above. */ | ||
303 | # undef fseek | ||
304 | # endif | ||
305 | # if @REPLACE_FSEEK@ | ||
306 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
307 | # undef fseek | ||
308 | # define fseek rpl_fseek | ||
309 | # endif | ||
310 | _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence) | ||
311 | _GL_ARG_NONNULL ((1))); | ||
312 | _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); | ||
313 | # else | ||
314 | _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence)); | ||
315 | # endif | ||
316 | _GL_CXXALIASWARN (fseek); | ||
317 | #endif | ||
318 | |||
319 | #if @GNULIB_FSEEKO@ | ||
320 | # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES | ||
321 | # define _GL_FSEEK_WARN /* Category 3, above. */ | ||
322 | # undef fseek | ||
323 | # endif | ||
324 | # if @REPLACE_FSEEKO@ | ||
325 | /* Provide an fseeko function that is aware of a preceding fflush(), and which | ||
326 | detects pipes. */ | ||
327 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
328 | # undef fseeko | ||
329 | # define fseeko rpl_fseeko | ||
330 | # endif | ||
331 | _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence) | ||
332 | _GL_ARG_NONNULL ((1))); | ||
333 | _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); | ||
334 | # else | ||
335 | # if ! @HAVE_FSEEKO@ | ||
336 | _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence) | ||
337 | _GL_ARG_NONNULL ((1))); | ||
338 | # endif | ||
339 | _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); | ||
340 | # endif | ||
341 | _GL_CXXALIASWARN (fseeko); | ||
342 | # if (@REPLACE_FSEEKO@ || !@HAVE_FSEEKO@) && !@GNULIB_FSEEK@ | ||
343 | /* Provide an fseek function that is consistent with fseeko. */ | ||
344 | /* In order to avoid that fseek gets defined as a macro here, the | ||
345 | developer can request the 'fseek' module. */ | ||
346 | # undef fseek | ||
347 | # define fseek rpl_fseek | ||
348 | static inline int _GL_ARG_NONNULL ((1)) | ||
349 | rpl_fseek (FILE *fp, long offset, int whence) | ||
350 | { | ||
351 | # if @REPLACE_FSEEKO@ | ||
352 | return rpl_fseeko (fp, offset, whence); | ||
353 | # else | ||
354 | return fseeko (fp, offset, whence); | ||
355 | # endif | ||
356 | } | ||
209 | # endif | 357 | # endif |
210 | #elif defined GNULIB_POSIXCHECK | 358 | #elif defined GNULIB_POSIXCHECK |
211 | # undef vsprintf | 359 | # define _GL_FSEEK_WARN /* Category 1, above. */ |
212 | # define vsprintf(b,f,a) \ | 360 | # undef fseek |
213 | (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \ | 361 | # undef fseeko |
214 | "use gnulib module vsprintf-posix for portable " \ | 362 | # if HAVE_RAW_DECL_FSEEKO |
215 | "POSIX compliance"), \ | 363 | _GL_WARN_ON_USE (fseeko, "fseeko is unportable - " |
216 | vsprintf (b, f, a)) | 364 | "use gnulib module fseeko for portability"); |
365 | # endif | ||
217 | #endif | 366 | #endif |
218 | 367 | ||
219 | #if @GNULIB_DPRINTF@ | 368 | #ifdef _GL_FSEEK_WARN |
220 | # if @REPLACE_DPRINTF@ | 369 | # undef _GL_FSEEK_WARN |
221 | # define dprintf rpl_dprintf | 370 | /* Here, either fseek is undefined (but C89 guarantees that it is |
371 | declared), or it is defined as rpl_fseek (declared above). */ | ||
372 | _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB " | ||
373 | "on 32-bit platforms - " | ||
374 | "use fseeko function for handling of large files"); | ||
375 | #endif | ||
376 | |||
377 | |||
378 | /* ftell, ftello. See the comments on fseek/fseeko. */ | ||
379 | |||
380 | #if @GNULIB_FTELL@ | ||
381 | # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES | ||
382 | # define _GL_FTELL_WARN /* Category 2, above. */ | ||
383 | # undef ftell | ||
384 | # endif | ||
385 | # if @REPLACE_FTELL@ | ||
386 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
387 | # undef ftell | ||
388 | # define ftell rpl_ftell | ||
389 | # endif | ||
390 | _GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1))); | ||
391 | _GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); | ||
392 | # else | ||
393 | _GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); | ||
394 | # endif | ||
395 | _GL_CXXALIASWARN (ftell); | ||
396 | #endif | ||
397 | |||
398 | #if @GNULIB_FTELLO@ | ||
399 | # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES | ||
400 | # define _GL_FTELL_WARN /* Category 3, above. */ | ||
401 | # undef ftell | ||
402 | # endif | ||
403 | # if @REPLACE_FTELLO@ | ||
404 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
405 | # undef ftello | ||
406 | # define ftello rpl_ftello | ||
407 | # endif | ||
408 | _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); | ||
409 | _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); | ||
410 | # else | ||
411 | # if ! @HAVE_FTELLO@ | ||
412 | _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); | ||
413 | # endif | ||
414 | _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); | ||
222 | # endif | 415 | # endif |
223 | # if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@ | 416 | _GL_CXXALIASWARN (ftello); |
224 | extern int dprintf (int fd, const char *format, ...) | 417 | # if (@REPLACE_FTELLO@ || !@HAVE_FTELLO@) && !@GNULIB_FTELL@ |
225 | __attribute__ ((__format__ (__printf__, 2, 3))); | 418 | /* Provide an ftell function that is consistent with ftello. */ |
419 | /* In order to avoid that ftell gets defined as a macro here, the | ||
420 | developer can request the 'ftell' module. */ | ||
421 | # undef ftell | ||
422 | # define ftell rpl_ftell | ||
423 | static inline long _GL_ARG_NONNULL ((1)) | ||
424 | rpl_ftell (FILE *f) | ||
425 | { | ||
426 | # if @REPLACE_FTELLO@ | ||
427 | return rpl_ftello (f); | ||
428 | # else | ||
429 | return ftello (f); | ||
430 | # endif | ||
431 | } | ||
226 | # endif | 432 | # endif |
227 | #elif defined GNULIB_POSIXCHECK | 433 | #elif defined GNULIB_POSIXCHECK |
228 | # undef dprintf | 434 | # define _GL_FTELL_WARN /* Category 1, above. */ |
229 | # define dprintf(d,f,a) \ | 435 | # undef ftell |
230 | (GL_LINK_WARNING ("dprintf is unportable - " \ | 436 | # undef ftello |
231 | "use gnulib module dprintf for portability"), \ | 437 | # if HAVE_RAW_DECL_FTELLO |
232 | dprintf (d, f, a)) | 438 | _GL_WARN_ON_USE (ftello, "ftello is unportable - " |
439 | "use gnulib module ftello for portability"); | ||
440 | # endif | ||
233 | #endif | 441 | #endif |
234 | 442 | ||
235 | #if @GNULIB_VDPRINTF@ | 443 | #ifdef _GL_FTELL_WARN |
236 | # if @REPLACE_VDPRINTF@ | 444 | # undef _GL_FTELL_WARN |
237 | # define vdprintf rpl_vdprintf | 445 | /* Here, either ftell is undefined (but C89 guarantees that it is |
446 | declared), or it is defined as rpl_ftell (declared above). */ | ||
447 | _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB " | ||
448 | "on 32-bit platforms - " | ||
449 | "use ftello function for handling of large files"); | ||
450 | #endif | ||
451 | |||
452 | |||
453 | #if @GNULIB_FWRITE@ | ||
454 | # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | ||
455 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
456 | # undef fwrite | ||
457 | # define fwrite rpl_fwrite | ||
458 | # endif | ||
459 | _GL_FUNCDECL_RPL (fwrite, size_t, | ||
460 | (const void *ptr, size_t s, size_t n, FILE *stream) | ||
461 | _GL_ARG_NONNULL ((1, 4))); | ||
462 | _GL_CXXALIAS_RPL (fwrite, size_t, | ||
463 | (const void *ptr, size_t s, size_t n, FILE *stream)); | ||
464 | # else | ||
465 | _GL_CXXALIAS_SYS (fwrite, size_t, | ||
466 | (const void *ptr, size_t s, size_t n, FILE *stream)); | ||
238 | # endif | 467 | # endif |
239 | # if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@ | 468 | _GL_CXXALIASWARN (fwrite); |
240 | extern int vdprintf (int fd, const char *format, va_list args) | 469 | #endif |
241 | __attribute__ ((__format__ (__printf__, 2, 0))); | 470 | |
471 | #if @GNULIB_GETDELIM@ | ||
472 | /* Read input, up to (and including) the next occurrence of DELIMITER, from | ||
473 | STREAM, store it in *LINEPTR (and NUL-terminate it). | ||
474 | *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE | ||
475 | bytes of space. It is realloc'd as necessary. | ||
476 | Return the number of bytes read and stored at *LINEPTR (not including the | ||
477 | NUL terminator), or -1 on error or EOF. */ | ||
478 | # if @REPLACE_GETDELIM@ | ||
479 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
480 | # undef getdelim | ||
481 | # define getdelim rpl_getdelim | ||
482 | # endif | ||
483 | _GL_FUNCDECL_RPL (getdelim, ssize_t, | ||
484 | (char **lineptr, size_t *linesize, int delimiter, | ||
485 | FILE *stream) | ||
486 | _GL_ARG_NONNULL ((1, 2, 4))); | ||
487 | _GL_CXXALIAS_RPL (getdelim, ssize_t, | ||
488 | (char **lineptr, size_t *linesize, int delimiter, | ||
489 | FILE *stream)); | ||
490 | # else | ||
491 | # if !@HAVE_DECL_GETDELIM@ | ||
492 | _GL_FUNCDECL_SYS (getdelim, ssize_t, | ||
493 | (char **lineptr, size_t *linesize, int delimiter, | ||
494 | FILE *stream) | ||
495 | _GL_ARG_NONNULL ((1, 2, 4))); | ||
496 | # endif | ||
497 | _GL_CXXALIAS_SYS (getdelim, ssize_t, | ||
498 | (char **lineptr, size_t *linesize, int delimiter, | ||
499 | FILE *stream)); | ||
242 | # endif | 500 | # endif |
501 | _GL_CXXALIASWARN (getdelim); | ||
243 | #elif defined GNULIB_POSIXCHECK | 502 | #elif defined GNULIB_POSIXCHECK |
244 | # undef vdprintf | 503 | # undef getdelim |
245 | # define vdprintf(d,f,a) \ | 504 | # if HAVE_RAW_DECL_GETDELIM |
246 | (GL_LINK_WARNING ("vdprintf is unportable - " \ | 505 | _GL_WARN_ON_USE (getdelim, "getdelim is unportable - " |
247 | "use gnulib module vdprintf for portability"), \ | 506 | "use gnulib module getdelim for portability"); |
248 | vdprintf (d, f, a)) | 507 | # endif |
249 | #endif | 508 | #endif |
250 | 509 | ||
251 | #if @GNULIB_VASPRINTF@ | 510 | #if @GNULIB_GETLINE@ |
252 | # if @REPLACE_VASPRINTF@ | 511 | /* Read a line, up to (and including) the next newline, from STREAM, store it |
253 | # define asprintf rpl_asprintf | 512 | in *LINEPTR (and NUL-terminate it). |
254 | # define vasprintf rpl_vasprintf | 513 | *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE |
514 | bytes of space. It is realloc'd as necessary. | ||
515 | Return the number of bytes read and stored at *LINEPTR (not including the | ||
516 | NUL terminator), or -1 on error or EOF. */ | ||
517 | # if @REPLACE_GETLINE@ | ||
518 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
519 | # undef getline | ||
520 | # define getline rpl_getline | ||
521 | # endif | ||
522 | _GL_FUNCDECL_RPL (getline, ssize_t, | ||
523 | (char **lineptr, size_t *linesize, FILE *stream) | ||
524 | _GL_ARG_NONNULL ((1, 2, 3))); | ||
525 | _GL_CXXALIAS_RPL (getline, ssize_t, | ||
526 | (char **lineptr, size_t *linesize, FILE *stream)); | ||
527 | # else | ||
528 | # if !@HAVE_DECL_GETLINE@ | ||
529 | _GL_FUNCDECL_SYS (getline, ssize_t, | ||
530 | (char **lineptr, size_t *linesize, FILE *stream) | ||
531 | _GL_ARG_NONNULL ((1, 2, 3))); | ||
532 | # endif | ||
533 | _GL_CXXALIAS_SYS (getline, ssize_t, | ||
534 | (char **lineptr, size_t *linesize, FILE *stream)); | ||
535 | # endif | ||
536 | # if @HAVE_DECL_GETLINE@ | ||
537 | _GL_CXXALIASWARN (getline); | ||
255 | # endif | 538 | # endif |
256 | # if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@ | 539 | #elif defined GNULIB_POSIXCHECK |
257 | /* Write formatted output to a string dynamically allocated with malloc(). | 540 | # undef getline |
258 | If the memory allocation succeeds, store the address of the string in | 541 | # if HAVE_RAW_DECL_GETLINE |
259 | *RESULT and return the number of resulting bytes, excluding the trailing | 542 | _GL_WARN_ON_USE (getline, "getline is unportable - " |
260 | NUL. Upon memory allocation error, or some other error, return -1. */ | 543 | "use gnulib module getline for portability"); |
261 | extern int asprintf (char **result, const char *format, ...) | ||
262 | __attribute__ ((__format__ (__printf__, 2, 3))); | ||
263 | extern int vasprintf (char **result, const char *format, va_list args) | ||
264 | __attribute__ ((__format__ (__printf__, 2, 0))); | ||
265 | # endif | 544 | # endif |
266 | #endif | 545 | #endif |
267 | 546 | ||
268 | #if @GNULIB_OBSTACK_PRINTF@ | 547 | #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ |
548 | struct obstack; | ||
549 | /* Grow an obstack with formatted output. Return the number of | ||
550 | bytes added to OBS. No trailing nul byte is added, and the | ||
551 | object should be closed with obstack_finish before use. Upon | ||
552 | memory allocation error, call obstack_alloc_failed_handler. Upon | ||
553 | other error, return -1. */ | ||
269 | # if @REPLACE_OBSTACK_PRINTF@ | 554 | # if @REPLACE_OBSTACK_PRINTF@ |
270 | # define obstack_printf rpl_osbtack_printf | 555 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
271 | # define obstack_vprintf rpl_obstack_vprintf | 556 | # define obstack_printf rpl_obstack_printf |
557 | # endif | ||
558 | _GL_FUNCDECL_RPL (obstack_printf, int, | ||
559 | (struct obstack *obs, const char *format, ...) | ||
560 | __attribute__ ((__format__ (__printf__, 2, 3))) | ||
561 | _GL_ARG_NONNULL ((1, 2))); | ||
562 | _GL_CXXALIAS_RPL (obstack_printf, int, | ||
563 | (struct obstack *obs, const char *format, ...)); | ||
564 | # else | ||
565 | # if !@HAVE_DECL_OBSTACK_PRINTF@ | ||
566 | _GL_FUNCDECL_SYS (obstack_printf, int, | ||
567 | (struct obstack *obs, const char *format, ...) | ||
568 | __attribute__ ((__format__ (__printf__, 2, 3))) | ||
569 | _GL_ARG_NONNULL ((1, 2))); | ||
570 | # endif | ||
571 | _GL_CXXALIAS_SYS (obstack_printf, int, | ||
572 | (struct obstack *obs, const char *format, ...)); | ||
272 | # endif | 573 | # endif |
273 | # if @REPLACE_OBSTACK_PRINTF@ || !@HAVE_DECL_OBSTACK_PRINTF@ | 574 | _GL_CXXALIASWARN (obstack_printf); |
274 | struct obstack; | 575 | # if @REPLACE_OBSTACK_PRINTF@ |
275 | /* Grow an obstack with formatted output. Return the number of | 576 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
276 | bytes added to OBS. No trailing nul byte is added, and the | 577 | # define obstack_vprintf rpl_obstack_vprintf |
277 | object should be closed with obstack_finish before use. Upon | 578 | # endif |
278 | memory allocation error, call obstack_alloc_failed_handler. Upon | 579 | _GL_FUNCDECL_RPL (obstack_vprintf, int, |
279 | other error, return -1. */ | 580 | (struct obstack *obs, const char *format, va_list args) |
280 | extern int obstack_printf (struct obstack *obs, const char *format, ...) | 581 | __attribute__ ((__format__ (__printf__, 2, 0))) |
281 | __attribute__ ((__format__ (__printf__, 2, 3))); | 582 | _GL_ARG_NONNULL ((1, 2))); |
282 | extern int obstack_vprintf (struct obstack *obs, const char *format, | 583 | _GL_CXXALIAS_RPL (obstack_vprintf, int, |
283 | va_list args) | 584 | (struct obstack *obs, const char *format, va_list args)); |
284 | __attribute__ ((__format__ (__printf__, 2, 0))); | 585 | # else |
586 | # if !@HAVE_DECL_OBSTACK_PRINTF@ | ||
587 | _GL_FUNCDECL_SYS (obstack_vprintf, int, | ||
588 | (struct obstack *obs, const char *format, va_list args) | ||
589 | __attribute__ ((__format__ (__printf__, 2, 0))) | ||
590 | _GL_ARG_NONNULL ((1, 2))); | ||
591 | # endif | ||
592 | _GL_CXXALIAS_SYS (obstack_vprintf, int, | ||
593 | (struct obstack *obs, const char *format, va_list args)); | ||
285 | # endif | 594 | # endif |
595 | _GL_CXXALIASWARN (obstack_vprintf); | ||
286 | #endif | 596 | #endif |
287 | 597 | ||
288 | #if @GNULIB_FOPEN@ | 598 | #if @GNULIB_PERROR@ |
289 | # if @REPLACE_FOPEN@ | 599 | /* Print a message to standard error, describing the value of ERRNO, |
290 | # undef fopen | 600 | (if STRING is not NULL and not empty) prefixed with STRING and ": ", |
291 | # define fopen rpl_fopen | 601 | and terminated with a newline. */ |
292 | extern FILE * fopen (const char *filename, const char *mode); | 602 | # if @REPLACE_PERROR@ |
603 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
604 | # define perror rpl_perror | ||
605 | # endif | ||
606 | _GL_FUNCDECL_RPL (perror, void, (const char *string)); | ||
607 | _GL_CXXALIAS_RPL (perror, void, (const char *string)); | ||
608 | # else | ||
609 | _GL_CXXALIAS_SYS (perror, void, (const char *string)); | ||
293 | # endif | 610 | # endif |
611 | _GL_CXXALIASWARN (perror); | ||
294 | #elif defined GNULIB_POSIXCHECK | 612 | #elif defined GNULIB_POSIXCHECK |
295 | # undef fopen | 613 | # undef perror |
296 | # define fopen(f,m) \ | 614 | /* Assume perror is always declared. */ |
297 | (GL_LINK_WARNING ("fopen on Win32 platforms is not POSIX compatible - " \ | 615 | _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " |
298 | "use gnulib module fopen for portability"), \ | 616 | "use gnulib module perror for portability"); |
299 | fopen (f, m)) | ||
300 | #endif | 617 | #endif |
301 | 618 | ||
302 | #if @GNULIB_FREOPEN@ | 619 | #if @GNULIB_POPEN@ |
303 | # if @REPLACE_FREOPEN@ | 620 | # if @REPLACE_POPEN@ |
304 | # undef freopen | 621 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
305 | # define freopen rpl_freopen | 622 | # undef popen |
306 | extern FILE * freopen (const char *filename, const char *mode, FILE *stream); | 623 | # define popen rpl_popen |
624 | # endif | ||
625 | _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode) | ||
626 | _GL_ARG_NONNULL ((1, 2))); | ||
627 | _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); | ||
628 | # else | ||
629 | _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); | ||
307 | # endif | 630 | # endif |
631 | _GL_CXXALIASWARN (popen); | ||
308 | #elif defined GNULIB_POSIXCHECK | 632 | #elif defined GNULIB_POSIXCHECK |
309 | # undef freopen | 633 | # undef popen |
310 | # define freopen(f,m,s) \ | 634 | # if HAVE_RAW_DECL_POPEN |
311 | (GL_LINK_WARNING ("freopen on Win32 platforms is not POSIX compatible - " \ | 635 | _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " |
312 | "use gnulib module freopen for portability"), \ | 636 | "use gnulib module popen or pipe for more portability"); |
313 | freopen (f, m, s)) | 637 | # endif |
314 | #endif | 638 | #endif |
315 | 639 | ||
316 | #if @GNULIB_FSEEKO@ | 640 | #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ |
317 | # if @REPLACE_FSEEKO@ | 641 | # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ |
318 | /* Provide fseek, fseeko functions that are aware of a preceding | 642 | || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) |
319 | fflush(), and which detect pipes. */ | 643 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
320 | # define fseeko rpl_fseeko | 644 | /* Don't break __attribute__((format(printf,M,N))). */ |
321 | extern int fseeko (FILE *fp, off_t offset, int whence); | 645 | # define printf __printf__ |
322 | # define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence) | 646 | # endif |
647 | # define GNULIB_overrides_printf 1 | ||
648 | _GL_FUNCDECL_RPL_1 (__printf__, int, | ||
649 | (const char *format, ...) | ||
650 | __attribute__ ((__format__ (__printf__, 1, 2))) | ||
651 | _GL_ARG_NONNULL ((1))); | ||
652 | _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); | ||
653 | # else | ||
654 | _GL_CXXALIAS_SYS (printf, int, (const char *format, ...)); | ||
323 | # endif | 655 | # endif |
324 | #elif defined GNULIB_POSIXCHECK | 656 | _GL_CXXALIASWARN (printf); |
325 | # undef fseeko | 657 | #endif |
326 | # define fseeko(f,o,w) \ | 658 | #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK |
327 | (GL_LINK_WARNING ("fseeko is unportable - " \ | 659 | # if !GNULIB_overrides_printf |
328 | "use gnulib module fseeko for portability"), \ | 660 | # undef printf |
329 | fseeko (f, o, w)) | 661 | # endif |
662 | /* Assume printf is always declared. */ | ||
663 | _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - " | ||
664 | "use gnulib module printf-posix for portable " | ||
665 | "POSIX compliance"); | ||
330 | #endif | 666 | #endif |
331 | 667 | ||
332 | #if @GNULIB_FSEEK@ && @REPLACE_FSEEK@ | 668 | #if @GNULIB_PUTC@ |
333 | extern int rpl_fseek (FILE *fp, long offset, int whence); | 669 | # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ |
334 | # undef fseek | 670 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
335 | # if defined GNULIB_POSIXCHECK | 671 | # undef putc |
336 | # define fseek(f,o,w) \ | 672 | # define putc rpl_fputc |
337 | (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \ | 673 | # endif |
338 | "on 32-bit platforms - " \ | 674 | _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); |
339 | "use fseeko function for handling of large files"), \ | 675 | _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream)); |
340 | rpl_fseek (f, o, w)) | ||
341 | # else | 676 | # else |
342 | # define fseek rpl_fseek | 677 | _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); |
343 | # endif | 678 | # endif |
344 | #elif defined GNULIB_POSIXCHECK | 679 | _GL_CXXALIASWARN (putc); |
345 | # ifndef fseek | 680 | #endif |
346 | # define fseek(f,o,w) \ | 681 | |
347 | (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \ | 682 | #if @GNULIB_PUTCHAR@ |
348 | "on 32-bit platforms - " \ | 683 | # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ |
349 | "use fseeko function for handling of large files"), \ | 684 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
350 | fseek (f, o, w)) | 685 | # undef putchar |
686 | # define putchar rpl_putchar | ||
687 | # endif | ||
688 | _GL_FUNCDECL_RPL (putchar, int, (int c)); | ||
689 | _GL_CXXALIAS_RPL (putchar, int, (int c)); | ||
690 | # else | ||
691 | _GL_CXXALIAS_SYS (putchar, int, (int c)); | ||
351 | # endif | 692 | # endif |
693 | _GL_CXXALIASWARN (putchar); | ||
352 | #endif | 694 | #endif |
353 | 695 | ||
354 | #if @GNULIB_FTELLO@ | 696 | #if @GNULIB_PUTS@ |
355 | # if @REPLACE_FTELLO@ | 697 | # if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ |
356 | # define ftello rpl_ftello | 698 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
357 | extern off_t ftello (FILE *fp); | 699 | # undef puts |
358 | # define ftell(fp) ftello (fp) | 700 | # define puts rpl_puts |
701 | # endif | ||
702 | _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1))); | ||
703 | _GL_CXXALIAS_RPL (puts, int, (const char *string)); | ||
704 | # else | ||
705 | _GL_CXXALIAS_SYS (puts, int, (const char *string)); | ||
359 | # endif | 706 | # endif |
360 | #elif defined GNULIB_POSIXCHECK | 707 | _GL_CXXALIASWARN (puts); |
361 | # undef ftello | ||
362 | # define ftello(f) \ | ||
363 | (GL_LINK_WARNING ("ftello is unportable - " \ | ||
364 | "use gnulib module ftello for portability"), \ | ||
365 | ftello (f)) | ||
366 | #endif | 708 | #endif |
367 | 709 | ||
368 | #if @GNULIB_FTELL@ && @REPLACE_FTELL@ | 710 | #if @GNULIB_REMOVE@ |
369 | extern long rpl_ftell (FILE *fp); | 711 | # if @REPLACE_REMOVE@ |
370 | # undef ftell | 712 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
371 | # if GNULIB_POSIXCHECK | 713 | # undef remove |
372 | # define ftell(f) \ | 714 | # define remove rpl_remove |
373 | (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \ | 715 | # endif |
374 | "on 32-bit platforms - " \ | 716 | _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1))); |
375 | "use ftello function for handling of large files"), \ | 717 | _GL_CXXALIAS_RPL (remove, int, (const char *name)); |
376 | rpl_ftell (f)) | ||
377 | # else | 718 | # else |
378 | # define ftell rpl_ftell | 719 | _GL_CXXALIAS_SYS (remove, int, (const char *name)); |
379 | # endif | 720 | # endif |
721 | _GL_CXXALIASWARN (remove); | ||
380 | #elif defined GNULIB_POSIXCHECK | 722 | #elif defined GNULIB_POSIXCHECK |
381 | # ifndef ftell | 723 | # undef remove |
382 | # define ftell(f) \ | 724 | /* Assume remove is always declared. */ |
383 | (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \ | 725 | _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - " |
384 | "on 32-bit platforms - " \ | 726 | "use gnulib module remove for more portability"); |
385 | "use ftello function for handling of large files"), \ | ||
386 | ftell (f)) | ||
387 | # endif | ||
388 | #endif | 727 | #endif |
389 | 728 | ||
390 | #if @GNULIB_FFLUSH@ | 729 | #if @GNULIB_RENAME@ |
391 | # if @REPLACE_FFLUSH@ | 730 | # if @REPLACE_RENAME@ |
392 | # define fflush rpl_fflush | 731 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
393 | /* Flush all pending data on STREAM according to POSIX rules. Both | 732 | # undef rename |
394 | output and seekable input streams are supported. | 733 | # define rename rpl_rename |
395 | Note! LOSS OF DATA can occur if fflush is applied on an input stream | 734 | # endif |
396 | that is _not_seekable_ or on an update stream that is _not_seekable_ | 735 | _GL_FUNCDECL_RPL (rename, int, |
397 | and in which the most recent operation was input. Seekability can | 736 | (const char *old_filename, const char *new_filename) |
398 | be tested with lseek(fileno(fp),0,SEEK_CUR). */ | 737 | _GL_ARG_NONNULL ((1, 2))); |
399 | extern int fflush (FILE *gl_stream); | 738 | _GL_CXXALIAS_RPL (rename, int, |
739 | (const char *old_filename, const char *new_filename)); | ||
740 | # else | ||
741 | _GL_CXXALIAS_SYS (rename, int, | ||
742 | (const char *old_filename, const char *new_filename)); | ||
400 | # endif | 743 | # endif |
744 | _GL_CXXALIASWARN (rename); | ||
401 | #elif defined GNULIB_POSIXCHECK | 745 | #elif defined GNULIB_POSIXCHECK |
402 | # undef fflush | 746 | # undef rename |
403 | # define fflush(f) \ | 747 | /* Assume rename is always declared. */ |
404 | (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \ | 748 | _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - " |
405 | "use gnulib module fflush for portable " \ | 749 | "use gnulib module rename for more portability"); |
406 | "POSIX compliance"), \ | ||
407 | fflush (f)) | ||
408 | #endif | 750 | #endif |
409 | 751 | ||
410 | #if @GNULIB_FCLOSE@ | 752 | #if @GNULIB_RENAMEAT@ |
411 | # if @REPLACE_FCLOSE@ | 753 | # if @REPLACE_RENAMEAT@ |
412 | # define fclose rpl_fclose | 754 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
413 | /* Close STREAM and its underlying file descriptor. */ | 755 | # undef renameat |
414 | extern int fclose (FILE *stream); | 756 | # define renameat rpl_renameat |
757 | # endif | ||
758 | _GL_FUNCDECL_RPL (renameat, int, | ||
759 | (int fd1, char const *file1, int fd2, char const *file2) | ||
760 | _GL_ARG_NONNULL ((2, 4))); | ||
761 | _GL_CXXALIAS_RPL (renameat, int, | ||
762 | (int fd1, char const *file1, int fd2, char const *file2)); | ||
763 | # else | ||
764 | # if !@HAVE_RENAMEAT@ | ||
765 | _GL_FUNCDECL_SYS (renameat, int, | ||
766 | (int fd1, char const *file1, int fd2, char const *file2) | ||
767 | _GL_ARG_NONNULL ((2, 4))); | ||
768 | # endif | ||
769 | _GL_CXXALIAS_SYS (renameat, int, | ||
770 | (int fd1, char const *file1, int fd2, char const *file2)); | ||
415 | # endif | 771 | # endif |
772 | _GL_CXXALIASWARN (renameat); | ||
416 | #elif defined GNULIB_POSIXCHECK | 773 | #elif defined GNULIB_POSIXCHECK |
417 | # undef fclose | 774 | # undef renameat |
418 | # define fclose(f) \ | 775 | # if HAVE_RAW_DECL_RENAMEAT |
419 | (GL_LINK_WARNING ("fclose is not always POSIX compliant - " \ | 776 | _GL_WARN_ON_USE (renameat, "renameat is not portable - " |
420 | "use gnulib module fclose for portable " \ | 777 | "use gnulib module renameat for portability"); |
421 | "POSIX compliance"), \ | 778 | # endif |
422 | fclose (f)) | ||
423 | #endif | 779 | #endif |
424 | 780 | ||
425 | #if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | 781 | #if @GNULIB_SNPRINTF@ |
426 | # undef fputc | 782 | # if @REPLACE_SNPRINTF@ |
427 | # define fputc rpl_fputc | 783 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
428 | extern int fputc (int c, FILE *stream); | 784 | # define snprintf rpl_snprintf |
785 | # endif | ||
786 | _GL_FUNCDECL_RPL (snprintf, int, | ||
787 | (char *str, size_t size, const char *format, ...) | ||
788 | __attribute__ ((__format__ (__printf__, 3, 4))) | ||
789 | _GL_ARG_NONNULL ((3))); | ||
790 | _GL_CXXALIAS_RPL (snprintf, int, | ||
791 | (char *str, size_t size, const char *format, ...)); | ||
792 | # else | ||
793 | # if !@HAVE_DECL_SNPRINTF@ | ||
794 | _GL_FUNCDECL_SYS (snprintf, int, | ||
795 | (char *str, size_t size, const char *format, ...) | ||
796 | __attribute__ ((__format__ (__printf__, 3, 4))) | ||
797 | _GL_ARG_NONNULL ((3))); | ||
798 | # endif | ||
799 | _GL_CXXALIAS_SYS (snprintf, int, | ||
800 | (char *str, size_t size, const char *format, ...)); | ||
801 | # endif | ||
802 | _GL_CXXALIASWARN (snprintf); | ||
803 | #elif defined GNULIB_POSIXCHECK | ||
804 | # undef snprintf | ||
805 | # if HAVE_RAW_DECL_SNPRINTF | ||
806 | _GL_WARN_ON_USE (snprintf, "snprintf is unportable - " | ||
807 | "use gnulib module snprintf for portability"); | ||
808 | # endif | ||
429 | #endif | 809 | #endif |
430 | 810 | ||
431 | #if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | 811 | /* Some people would argue that sprintf should be handled like gets |
432 | # undef putc | 812 | (for example, OpenBSD issues a link warning for both functions), |
433 | # define putc rpl_fputc | 813 | since both can cause security holes due to buffer overruns. |
434 | extern int putc (int c, FILE *stream); | 814 | However, we believe that sprintf can be used safely, and is more |
435 | #endif | 815 | efficient than snprintf in those safe cases; and as proof of our |
816 | belief, we use sprintf in several gnulib modules. So this header | ||
817 | intentionally avoids adding a warning to sprintf except when | ||
818 | GNULIB_POSIXCHECK is defined. */ | ||
436 | 819 | ||
437 | #if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | 820 | #if @GNULIB_SPRINTF_POSIX@ |
438 | # undef putchar | 821 | # if @REPLACE_SPRINTF@ |
439 | # define putchar rpl_putchar | 822 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
440 | extern int putchar (int c); | 823 | # define sprintf rpl_sprintf |
824 | # endif | ||
825 | _GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...) | ||
826 | __attribute__ ((__format__ (__printf__, 2, 3))) | ||
827 | _GL_ARG_NONNULL ((1, 2))); | ||
828 | _GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...)); | ||
829 | # else | ||
830 | _GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...)); | ||
831 | # endif | ||
832 | _GL_CXXALIASWARN (sprintf); | ||
833 | #elif defined GNULIB_POSIXCHECK | ||
834 | # undef sprintf | ||
835 | /* Assume sprintf is always declared. */ | ||
836 | _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - " | ||
837 | "use gnulib module sprintf-posix for portable " | ||
838 | "POSIX compliance"); | ||
441 | #endif | 839 | #endif |
442 | 840 | ||
443 | #if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | 841 | #if @GNULIB_TMPFILE@ |
444 | # undef fputs | 842 | # if @REPLACE_TMPFILE@ |
445 | # define fputs rpl_fputs | 843 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
446 | extern int fputs (const char *string, FILE *stream); | 844 | # define tmpfile rpl_tmpfile |
845 | # endif | ||
846 | _GL_FUNCDECL_RPL (tmpfile, FILE *, (void)); | ||
847 | _GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); | ||
848 | # else | ||
849 | _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); | ||
850 | # endif | ||
851 | _GL_CXXALIASWARN (tmpfile); | ||
852 | #elif defined GNULIB_POSIXCHECK | ||
853 | # undef tmpfile | ||
854 | # if HAVE_RAW_DECL_TMPFILE | ||
855 | _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " | ||
856 | "use gnulib module tmpfile for portability"); | ||
857 | # endif | ||
447 | #endif | 858 | #endif |
448 | 859 | ||
449 | #if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | 860 | #if @GNULIB_VASPRINTF@ |
450 | # undef puts | 861 | /* Write formatted output to a string dynamically allocated with malloc(). |
451 | # define puts rpl_puts | 862 | If the memory allocation succeeds, store the address of the string in |
452 | extern int puts (const char *string); | 863 | *RESULT and return the number of resulting bytes, excluding the trailing |
864 | NUL. Upon memory allocation error, or some other error, return -1. */ | ||
865 | # if @REPLACE_VASPRINTF@ | ||
866 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
867 | # define asprintf rpl_asprintf | ||
868 | # endif | ||
869 | _GL_FUNCDECL_RPL (asprintf, int, | ||
870 | (char **result, const char *format, ...) | ||
871 | __attribute__ ((__format__ (__printf__, 2, 3))) | ||
872 | _GL_ARG_NONNULL ((1, 2))); | ||
873 | _GL_CXXALIAS_RPL (asprintf, int, | ||
874 | (char **result, const char *format, ...)); | ||
875 | # else | ||
876 | # if !@HAVE_VASPRINTF@ | ||
877 | _GL_FUNCDECL_SYS (asprintf, int, | ||
878 | (char **result, const char *format, ...) | ||
879 | __attribute__ ((__format__ (__printf__, 2, 3))) | ||
880 | _GL_ARG_NONNULL ((1, 2))); | ||
881 | # endif | ||
882 | _GL_CXXALIAS_SYS (asprintf, int, | ||
883 | (char **result, const char *format, ...)); | ||
884 | # endif | ||
885 | _GL_CXXALIASWARN (asprintf); | ||
886 | # if @REPLACE_VASPRINTF@ | ||
887 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
888 | # define vasprintf rpl_vasprintf | ||
889 | # endif | ||
890 | _GL_FUNCDECL_RPL (vasprintf, int, | ||
891 | (char **result, const char *format, va_list args) | ||
892 | __attribute__ ((__format__ (__printf__, 2, 0))) | ||
893 | _GL_ARG_NONNULL ((1, 2))); | ||
894 | _GL_CXXALIAS_RPL (vasprintf, int, | ||
895 | (char **result, const char *format, va_list args)); | ||
896 | # else | ||
897 | # if !@HAVE_VASPRINTF@ | ||
898 | _GL_FUNCDECL_SYS (vasprintf, int, | ||
899 | (char **result, const char *format, va_list args) | ||
900 | __attribute__ ((__format__ (__printf__, 2, 0))) | ||
901 | _GL_ARG_NONNULL ((1, 2))); | ||
902 | # endif | ||
903 | _GL_CXXALIAS_SYS (vasprintf, int, | ||
904 | (char **result, const char *format, va_list args)); | ||
905 | # endif | ||
906 | _GL_CXXALIASWARN (vasprintf); | ||
453 | #endif | 907 | #endif |
454 | 908 | ||
455 | #if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | 909 | #if @GNULIB_VDPRINTF@ |
456 | # undef fwrite | 910 | # if @REPLACE_VDPRINTF@ |
457 | # define fwrite rpl_fwrite | 911 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
458 | extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream); | 912 | # define vdprintf rpl_vdprintf |
913 | # endif | ||
914 | _GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args) | ||
915 | __attribute__ ((__format__ (__printf__, 2, 0))) | ||
916 | _GL_ARG_NONNULL ((2))); | ||
917 | _GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args)); | ||
918 | # else | ||
919 | # if !@HAVE_VDPRINTF@ | ||
920 | _GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args) | ||
921 | __attribute__ ((__format__ (__printf__, 2, 0))) | ||
922 | _GL_ARG_NONNULL ((2))); | ||
923 | # endif | ||
924 | /* Need to cast, because on Solaris, the third parameter will likely be | ||
925 | __va_list args. */ | ||
926 | _GL_CXXALIAS_SYS_CAST (vdprintf, int, | ||
927 | (int fd, const char *format, va_list args)); | ||
928 | # endif | ||
929 | _GL_CXXALIASWARN (vdprintf); | ||
930 | #elif defined GNULIB_POSIXCHECK | ||
931 | # undef vdprintf | ||
932 | # if HAVE_RAW_DECL_VDPRINTF | ||
933 | _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " | ||
934 | "use gnulib module vdprintf for portability"); | ||
935 | # endif | ||
459 | #endif | 936 | #endif |
460 | 937 | ||
461 | #if @GNULIB_GETDELIM@ | 938 | #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@ |
462 | # if !@HAVE_DECL_GETDELIM@ | 939 | # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \ |
463 | /* Read input, up to (and including) the next occurrence of DELIMITER, from | 940 | || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) |
464 | STREAM, store it in *LINEPTR (and NUL-terminate it). | 941 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
465 | *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE | 942 | # define vfprintf rpl_vfprintf |
466 | bytes of space. It is realloc'd as necessary. | 943 | # endif |
467 | Return the number of bytes read and stored at *LINEPTR (not including the | 944 | # define GNULIB_overrides_vfprintf 1 |
468 | NUL terminator), or -1 on error or EOF. */ | 945 | _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) |
469 | extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter, | 946 | __attribute__ ((__format__ (__printf__, 2, 0))) |
470 | FILE *stream); | 947 | _GL_ARG_NONNULL ((1, 2))); |
948 | _GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)); | ||
949 | # else | ||
950 | /* Need to cast, because on Solaris, the third parameter is | ||
951 | __va_list args | ||
952 | and GCC's fixincludes did not change this to __gnuc_va_list. */ | ||
953 | _GL_CXXALIAS_SYS_CAST (vfprintf, int, | ||
954 | (FILE *fp, const char *format, va_list args)); | ||
471 | # endif | 955 | # endif |
472 | #elif defined GNULIB_POSIXCHECK | 956 | _GL_CXXALIASWARN (vfprintf); |
473 | # undef getdelim | 957 | #endif |
474 | # define getdelim(l, s, d, f) \ | 958 | #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK |
475 | (GL_LINK_WARNING ("getdelim is unportable - " \ | 959 | # if !GNULIB_overrides_vfprintf |
476 | "use gnulib module getdelim for portability"), \ | 960 | # undef vfprintf |
477 | getdelim (l, s, d, f)) | 961 | # endif |
962 | /* Assume vfprintf is always declared. */ | ||
963 | _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - " | ||
964 | "use gnulib module vfprintf-posix for portable " | ||
965 | "POSIX compliance"); | ||
478 | #endif | 966 | #endif |
479 | 967 | ||
480 | #if @GNULIB_GETLINE@ | 968 | #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ |
481 | # if @REPLACE_GETLINE@ | 969 | # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \ |
482 | # undef getline | 970 | || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) |
483 | # define getline rpl_getline | 971 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
972 | # define vprintf rpl_vprintf | ||
973 | # endif | ||
974 | # define GNULIB_overrides_vprintf 1 | ||
975 | _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) | ||
976 | __attribute__ ((__format__ (__printf__, 1, 0))) | ||
977 | _GL_ARG_NONNULL ((1))); | ||
978 | _GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args)); | ||
979 | # else | ||
980 | /* Need to cast, because on Solaris, the second parameter is | ||
981 | __va_list args | ||
982 | and GCC's fixincludes did not change this to __gnuc_va_list. */ | ||
983 | _GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args)); | ||
484 | # endif | 984 | # endif |
485 | # if !@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@ | 985 | _GL_CXXALIASWARN (vprintf); |
486 | /* Read a line, up to (and including) the next newline, from STREAM, store it | 986 | #endif |
487 | in *LINEPTR (and NUL-terminate it). | 987 | #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK |
488 | *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE | 988 | # if !GNULIB_overrides_vprintf |
489 | bytes of space. It is realloc'd as necessary. | 989 | # undef vprintf |
490 | Return the number of bytes read and stored at *LINEPTR (not including the | ||
491 | NUL terminator), or -1 on error or EOF. */ | ||
492 | extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream); | ||
493 | # endif | 990 | # endif |
494 | #elif defined GNULIB_POSIXCHECK | 991 | /* Assume vprintf is always declared. */ |
495 | # undef getline | 992 | _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - " |
496 | # define getline(l, s, f) \ | 993 | "use gnulib module vprintf-posix for portable " |
497 | (GL_LINK_WARNING ("getline is unportable - " \ | 994 | "POSIX compliance"); |
498 | "use gnulib module getline for portability"), \ | ||
499 | getline (l, s, f)) | ||
500 | #endif | 995 | #endif |
501 | 996 | ||
502 | #if @GNULIB_PERROR@ | 997 | #if @GNULIB_VSNPRINTF@ |
503 | # if @REPLACE_PERROR@ | 998 | # if @REPLACE_VSNPRINTF@ |
504 | # define perror rpl_perror | 999 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
505 | /* Print a message to standard error, describing the value of ERRNO, | 1000 | # define vsnprintf rpl_vsnprintf |
506 | (if STRING is not NULL and not empty) prefixed with STRING and ": ", | 1001 | # endif |
507 | and terminated with a newline. */ | 1002 | _GL_FUNCDECL_RPL (vsnprintf, int, |
508 | extern void perror (const char *string); | 1003 | (char *str, size_t size, const char *format, va_list args) |
1004 | __attribute__ ((__format__ (__printf__, 3, 0))) | ||
1005 | _GL_ARG_NONNULL ((3))); | ||
1006 | _GL_CXXALIAS_RPL (vsnprintf, int, | ||
1007 | (char *str, size_t size, const char *format, va_list args)); | ||
1008 | # else | ||
1009 | # if !@HAVE_DECL_VSNPRINTF@ | ||
1010 | _GL_FUNCDECL_SYS (vsnprintf, int, | ||
1011 | (char *str, size_t size, const char *format, va_list args) | ||
1012 | __attribute__ ((__format__ (__printf__, 3, 0))) | ||
1013 | _GL_ARG_NONNULL ((3))); | ||
1014 | # endif | ||
1015 | _GL_CXXALIAS_SYS (vsnprintf, int, | ||
1016 | (char *str, size_t size, const char *format, va_list args)); | ||
509 | # endif | 1017 | # endif |
1018 | _GL_CXXALIASWARN (vsnprintf); | ||
510 | #elif defined GNULIB_POSIXCHECK | 1019 | #elif defined GNULIB_POSIXCHECK |
511 | # undef perror | 1020 | # undef vsnprintf |
512 | # define perror(s) \ | 1021 | # if HAVE_RAW_DECL_VSNPRINTF |
513 | (GL_LINK_WARNING ("perror is not always POSIX compliant - " \ | 1022 | _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " |
514 | "use gnulib module perror for portability"), \ | 1023 | "use gnulib module vsnprintf for portability"); |
515 | perror (s)) | 1024 | # endif |
516 | #endif | 1025 | #endif |
517 | 1026 | ||
518 | #ifdef __cplusplus | 1027 | #if @GNULIB_VSPRINTF_POSIX@ |
519 | } | 1028 | # if @REPLACE_VSPRINTF@ |
1029 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
1030 | # define vsprintf rpl_vsprintf | ||
1031 | # endif | ||
1032 | _GL_FUNCDECL_RPL (vsprintf, int, | ||
1033 | (char *str, const char *format, va_list args) | ||
1034 | __attribute__ ((__format__ (__printf__, 2, 0))) | ||
1035 | _GL_ARG_NONNULL ((1, 2))); | ||
1036 | _GL_CXXALIAS_RPL (vsprintf, int, | ||
1037 | (char *str, const char *format, va_list args)); | ||
1038 | # else | ||
1039 | /* Need to cast, because on Solaris, the third parameter is | ||
1040 | __va_list args | ||
1041 | and GCC's fixincludes did not change this to __gnuc_va_list. */ | ||
1042 | _GL_CXXALIAS_SYS_CAST (vsprintf, int, | ||
1043 | (char *str, const char *format, va_list args)); | ||
1044 | # endif | ||
1045 | _GL_CXXALIASWARN (vsprintf); | ||
1046 | #elif defined GNULIB_POSIXCHECK | ||
1047 | # undef vsprintf | ||
1048 | /* Assume vsprintf is always declared. */ | ||
1049 | _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - " | ||
1050 | "use gnulib module vsprintf-posix for portable " | ||
1051 | "POSIX compliance"); | ||
520 | #endif | 1052 | #endif |
521 | 1053 | ||
1054 | |||
522 | #endif /* _GL_STDIO_H */ | 1055 | #endif /* _GL_STDIO_H */ |
523 | #endif /* _GL_STDIO_H */ | 1056 | #endif /* _GL_STDIO_H */ |
524 | #endif | 1057 | #endif |