Mercurial > hg > octave-kai > gnulib-hg
annotate lib/stdio.in.h @ 12839:c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 31 Jan 2010 17:43:25 +0100 |
parents | 2c14f1e449e5 |
children | 1825e6a0ff37 |
rev | line source |
---|---|
9262 | 1 /* A GNU-like <stdio.h>. |
2 | |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
12488
diff
changeset
|
3 Copyright (C) 2004, 2007-2010 Free Software Foundation, Inc. |
9262 | 4 |
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 | |
7 the Free Software Foundation; either version 2, or (at your option) | |
8 any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
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, | |
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | |
18 | |
10655
8668b19a7032
Avoid gcc warnings because of #pragma GCC system_header on older gcc.
Bruno Haible <bruno@clisp.org>
parents:
10622
diff
changeset
|
19 #if __GNUC__ >= 3 |
10375
f96e845fc36d
Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents:
10205
diff
changeset
|
20 @PRAGMA_SYSTEM_HEADER@ |
10655
8668b19a7032
Avoid gcc warnings because of #pragma GCC system_header on older gcc.
Bruno Haible <bruno@clisp.org>
parents:
10622
diff
changeset
|
21 #endif |
10375
f96e845fc36d
Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents:
10205
diff
changeset
|
22 |
9262 | 23 #if defined __need_FILE || defined __need___FILE |
24 /* Special invocation convention inside glibc header files. */ | |
25 | |
26 #@INCLUDE_NEXT@ @NEXT_STDIO_H@ | |
27 | |
28 #else | |
29 /* Normal invocation convention. */ | |
30 | |
31 #ifndef _GL_STDIO_H | |
32 | |
33 /* The include_next requires a split double-inclusion guard. */ | |
34 #@INCLUDE_NEXT@ @NEXT_STDIO_H@ | |
35 | |
36 #ifndef _GL_STDIO_H | |
37 #define _GL_STDIO_H | |
38 | |
12600
742a202062e7
stdio: Ensure <stdio.h> defines off_t, ssize_t, va_list.
Bruno Haible <bruno@clisp.org>
parents:
12584
diff
changeset
|
39 /* Get va_list. Needed on many systems, including glibc 2.8. */ |
9262 | 40 #include <stdarg.h> |
12600
742a202062e7
stdio: Ensure <stdio.h> defines off_t, ssize_t, va_list.
Bruno Haible <bruno@clisp.org>
parents:
12584
diff
changeset
|
41 |
9262 | 42 #include <stddef.h> |
43 | |
12600
742a202062e7
stdio: Ensure <stdio.h> defines off_t, ssize_t, va_list.
Bruno Haible <bruno@clisp.org>
parents:
12584
diff
changeset
|
44 /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8. */ |
742a202062e7
stdio: Ensure <stdio.h> defines off_t, ssize_t, va_list.
Bruno Haible <bruno@clisp.org>
parents:
12584
diff
changeset
|
45 #include <sys/types.h> |
9262 | 46 |
47 #ifndef __attribute__ | |
12762
410eaa89fb57
Avoid a link error due to the __printf__ symbol.
Bruno Haible <bruno@clisp.org>
parents:
12734
diff
changeset
|
48 /* The __attribute__ feature is available in gcc versions 2.5 and later. |
410eaa89fb57
Avoid a link error due to the __printf__ symbol.
Bruno Haible <bruno@clisp.org>
parents:
12734
diff
changeset
|
49 The __-protected variants of the attributes 'format' and 'printf' are |
410eaa89fb57
Avoid a link error due to the __printf__ symbol.
Bruno Haible <bruno@clisp.org>
parents:
12734
diff
changeset
|
50 accepted by gcc versions 2.6.4 (effectively 2.7) and later. |
410eaa89fb57
Avoid a link error due to the __printf__ symbol.
Bruno Haible <bruno@clisp.org>
parents:
12734
diff
changeset
|
51 We enable __attribute__ only if these are supported too, because |
410eaa89fb57
Avoid a link error due to the __printf__ symbol.
Bruno Haible <bruno@clisp.org>
parents:
12734
diff
changeset
|
52 gnulib and libintl do '#define printf __printf__' when they override |
410eaa89fb57
Avoid a link error due to the __printf__ symbol.
Bruno Haible <bruno@clisp.org>
parents:
12734
diff
changeset
|
53 the 'printf' function. */ |
9262 | 54 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) |
12762
410eaa89fb57
Avoid a link error due to the __printf__ symbol.
Bruno Haible <bruno@clisp.org>
parents:
12734
diff
changeset
|
55 # define __attribute__(Spec) /* empty */ |
9262 | 56 # endif |
57 #endif | |
58 | |
59 | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
60 /* The definition of _GL_ARG_NONNULL is copied here. */ |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
61 |
12724 | 62 /* The definition of _GL_WARN_ON_USE is copied here. */ |
63 | |
9262 | 64 |
65 #ifdef __cplusplus | |
66 extern "C" { | |
67 #endif | |
68 | |
11971 | 69 #if @GNULIB_DPRINTF@ |
70 # if @REPLACE_DPRINTF@ | |
71 # define dprintf rpl_dprintf | |
72 # endif | |
73 # if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@ | |
74 extern int dprintf (int fd, const char *format, ...) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
75 __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((2)); |
11971 | 76 # endif |
77 #elif defined GNULIB_POSIXCHECK | |
78 # undef dprintf | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
79 # if HAVE_RAW_DECL_DPRINTF |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
80 _GL_WARN_ON_USE (dprintf, "dprintf is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
81 "use gnulib module dprintf for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
82 # endif |
11971 | 83 #endif |
84 | |
85 #if @GNULIB_FCLOSE@ | |
86 # if @REPLACE_FCLOSE@ | |
87 # define fclose rpl_fclose | |
88 /* Close STREAM and its underlying file descriptor. */ | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
89 extern int fclose (FILE *stream) _GL_ARG_NONNULL ((1)); |
11971 | 90 # endif |
91 #elif defined GNULIB_POSIXCHECK | |
92 # undef fclose | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
93 /* Assume fclose is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
94 _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
95 "use gnulib module fclose for portable POSIX compliance"); |
11971 | 96 #endif |
97 | |
98 #if @GNULIB_FFLUSH@ | |
99 # if @REPLACE_FFLUSH@ | |
100 # define fflush rpl_fflush | |
101 /* Flush all pending data on STREAM according to POSIX rules. Both | |
102 output and seekable input streams are supported. | |
103 Note! LOSS OF DATA can occur if fflush is applied on an input stream | |
104 that is _not_seekable_ or on an update stream that is _not_seekable_ | |
105 and in which the most recent operation was input. Seekability can | |
106 be tested with lseek(fileno(fp),0,SEEK_CUR). */ | |
107 extern int fflush (FILE *gl_stream); | |
108 # endif | |
109 #elif defined GNULIB_POSIXCHECK | |
110 # undef fflush | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
111 /* Assume fflush is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
112 _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
113 "use gnulib module fflush for portable POSIX compliance"); |
11971 | 114 #endif |
115 | |
12724 | 116 /* It is very rare that the developer ever has full control of stdin, |
117 so any use of gets warrants an unconditional warning. Assume it is | |
118 always declared, since it is required by C89. */ | |
119 #undef gets | |
120 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); | |
121 | |
11971 | 122 #if @GNULIB_FOPEN@ |
123 # if @REPLACE_FOPEN@ | |
124 # undef fopen | |
125 # define fopen rpl_fopen | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
126 extern FILE * fopen (const char *filename, const char *mode) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
127 _GL_ARG_NONNULL ((1, 2)); |
11971 | 128 # endif |
129 #elif defined GNULIB_POSIXCHECK | |
130 # undef fopen | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
131 /* Assume fopen is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
132 _GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
133 "use gnulib module fopen for portability"); |
11971 | 134 #endif |
9262 | 135 |
136 #if @GNULIB_FPRINTF_POSIX@ | |
137 # if @REPLACE_FPRINTF@ | |
138 # define fprintf rpl_fprintf | |
139 extern int fprintf (FILE *fp, const char *format, ...) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
140 __attribute__ ((__format__ (__printf__, 2, 3))) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
141 _GL_ARG_NONNULL ((1, 2)); |
9262 | 142 # endif |
10487
953f72c1ffcc
Support SIGPIPE in stdio functions for writing.
Bruno Haible <bruno@clisp.org>
parents:
10433
diff
changeset
|
143 #elif @GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ |
953f72c1ffcc
Support SIGPIPE in stdio functions for writing.
Bruno Haible <bruno@clisp.org>
parents:
10433
diff
changeset
|
144 # define fprintf rpl_fprintf |
953f72c1ffcc
Support SIGPIPE in stdio functions for writing.
Bruno Haible <bruno@clisp.org>
parents:
10433
diff
changeset
|
145 extern int fprintf (FILE *fp, const char *format, ...) |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
146 __attribute__ ((__format__ (__printf__, 2, 3))) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
147 _GL_ARG_NONNULL ((1, 2)); |
9262 | 148 #elif defined GNULIB_POSIXCHECK |
149 # undef fprintf | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
150 /* Assume fprintf is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
151 _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
152 "use gnulib module fprintf-posix for portable " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
153 "POSIX compliance"); |
9262 | 154 #endif |
155 | |
11971 | 156 #if @GNULIB_FPURGE@ |
157 # if @REPLACE_FPURGE@ | |
158 # define fpurge rpl_fpurge | |
9262 | 159 # endif |
11971 | 160 # if @REPLACE_FPURGE@ || !@HAVE_DECL_FPURGE@ |
161 /* Discard all pending buffered I/O data on STREAM. | |
162 STREAM must not be wide-character oriented. | |
163 When discarding pending output, the file position is set back to where it | |
164 was before the write calls. When discarding pending input, the file | |
165 position is advanced to match the end of the previously read input. | |
166 Return 0 if successful. Upon error, return -1 and set errno. */ | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
167 extern int fpurge (FILE *gl_stream) _GL_ARG_NONNULL ((1)); |
9262 | 168 # endif |
169 #elif defined GNULIB_POSIXCHECK | |
11971 | 170 # undef fpurge |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
171 # if HAVE_RAW_DECL_FPURGE |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
172 _GL_WARN_ON_USE (fpurge, "fpurge is not always present - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
173 "use gnulib module fpurge for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
174 # endif |
11035
bf21f4597784
New modules 'dprintf', 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
11033
diff
changeset
|
175 #endif |
bf21f4597784
New modules 'dprintf', 'dprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
11033
diff
changeset
|
176 |
11971 | 177 #if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ |
178 # undef fputc | |
179 # define fputc rpl_fputc | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
180 extern int fputc (int c, FILE *stream) _GL_ARG_NONNULL ((2)); |
9262 | 181 #endif |
182 | |
11971 | 183 #if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ |
184 # undef fputs | |
185 # define fputs rpl_fputs | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
186 extern int fputs (const char *string, FILE *stream) _GL_ARG_NONNULL ((1, 2)); |
9301
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
9262
diff
changeset
|
187 #endif |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
9262
diff
changeset
|
188 |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
9262
diff
changeset
|
189 #if @GNULIB_FREOPEN@ |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
9262
diff
changeset
|
190 # if @REPLACE_FREOPEN@ |
10528
97cab1215a7c
Tweak patch that overrides open() and fopen().
Bruno Haible <bruno@clisp.org>
parents:
10487
diff
changeset
|
191 # undef freopen |
9301
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
9262
diff
changeset
|
192 # define freopen rpl_freopen |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
193 extern FILE * freopen (const char *filename, const char *mode, FILE *stream) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
194 _GL_ARG_NONNULL ((2, 3)); |
9301
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
9262
diff
changeset
|
195 # endif |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
9262
diff
changeset
|
196 #elif defined GNULIB_POSIXCHECK |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
9262
diff
changeset
|
197 # undef freopen |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
198 /* Assume freopen is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
199 _GL_WARN_ON_USE (freopen, "freopen on Win32 platforms is not POSIX compatible - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
200 "use gnulib module freopen for portability"); |
9301
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
9262
diff
changeset
|
201 #endif |
98e1721b4e40
New modules 'fopen' and 'freopen'.
Bruno Haible <bruno@clisp.org>
parents:
9262
diff
changeset
|
202 |
12724 | 203 /* Set up the following warnings, based on which modules are in use. |
204 GNU Coding Standards discourage the use of fseek, since it imposes | |
205 an arbitrary limitation on some 32-bit hosts. Remember that the | |
206 fseek module depends on the fseeko module, so we only have three | |
207 cases to consider: | |
208 | |
209 1. The developer is not using either module. Issue a warning under | |
210 GNULIB_POSIXCHECK for both functions, to remind them that both | |
211 functions have bugs on some systems. _GL_NO_LARGE_FILES has no | |
212 impact on this warning. | |
213 | |
214 2. The developer is using both modules. They may be unaware of the | |
215 arbitrary limitations of fseek, so issue a warning under | |
216 GNULIB_POSIXCHECK. On the other hand, they may be using both | |
217 modules intentionally, so the developer can define | |
218 _GL_NO_LARGE_FILES in the compilation units where the use of fseek | |
219 is safe, to silence the warning. | |
220 | |
221 3. The developer is using the fseeko module, but not fseek. Gnulib | |
222 guarantees that fseek will still work around platform bugs in that | |
223 case, but we presume that the developer is aware of the pitfalls of | |
224 fseek and was trying to avoid it, so issue a warning even when | |
225 GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be | |
226 defined to silence the warning in particular compilation units. | |
227 | |
228 Most gnulib clients that perform stream operations should fall into | |
229 category three. */ | |
230 | |
231 #if @GNULIB_FSEEK@ | |
232 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES | |
233 # define _GL_FSEEK_WARN /* Category 2, above. */ | |
234 # undef fseek | |
235 # endif | |
236 # if @REPLACE_FSEEK@ | |
237 # undef fseek | |
9262 | 238 # define fseek rpl_fseek |
12724 | 239 extern int fseek (FILE *fp, long offset, int whence) _GL_ARG_NONNULL ((1)); |
9262 | 240 # endif |
241 #endif | |
242 | |
11971 | 243 #if @GNULIB_FSEEKO@ |
12724 | 244 # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES |
245 # define _GL_FSEEK_WARN /* Category 3, above. */ | |
246 # undef fseek | |
247 # endif | |
11971 | 248 # if @REPLACE_FSEEKO@ |
249 /* Provide fseek, fseeko functions that are aware of a preceding | |
250 fflush(), and which detect pipes. */ | |
12724 | 251 # undef fseeko |
11971 | 252 # define fseeko rpl_fseeko |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
253 extern int fseeko (FILE *fp, off_t offset, int whence) _GL_ARG_NONNULL ((1)); |
12202
a0f033ee41af
fseek: avoid compilation failure when fflush is replaced
Eric Blake <ebb9@byu.net>
parents:
12100
diff
changeset
|
254 # if !@GNULIB_FSEEK@ |
a0f033ee41af
fseek: avoid compilation failure when fflush is replaced
Eric Blake <ebb9@byu.net>
parents:
12100
diff
changeset
|
255 # undef fseek |
12724 | 256 # define fseek rpl_fseek |
257 static inline int _GL_ARG_NONNULL ((1)) | |
258 rpl_fseek (FILE *fp, long offset, int whence) | |
259 { | |
260 return fseeko (fp, offset, whence); | |
261 } | |
12202
a0f033ee41af
fseek: avoid compilation failure when fflush is replaced
Eric Blake <ebb9@byu.net>
parents:
12100
diff
changeset
|
262 # endif |
9262 | 263 # endif |
264 #elif defined GNULIB_POSIXCHECK | |
12724 | 265 # define _GL_FSEEK_WARN /* Category 1, above. */ |
266 # undef fseek | |
11971 | 267 # undef fseeko |
12724 | 268 # if HAVE_RAW_DECL_FSEEKO |
269 _GL_WARN_ON_USE (fseeko, "fseeko is unportable - " | |
270 "use gnulib module fseeko for portability"); | |
271 # endif | |
9262 | 272 #endif |
273 | |
12724 | 274 #ifdef _GL_FSEEK_WARN |
275 # undef _GL_FSEEK_WARN | |
276 /* Here, either fseek is undefined (but C89 guarantees that it is | |
277 declared), or it is defined as rpl_fseek (declared above). */ | |
278 _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB " | |
279 "on 32-bit platforms - " | |
280 "use fseeko function for handling of large files"); | |
281 #endif | |
282 | |
283 /* See the comments on fseek/fseeko. */ | |
284 | |
285 #if @GNULIB_FTELL@ | |
286 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES | |
287 # define _GL_FTELL_WARN /* Category 2, above. */ | |
288 # undef ftell | |
289 # endif | |
12734
b31438706e9b
lib/stdio.in.h: Fix typo.
Simon Josefsson <simon@josefsson.org>
parents:
12724
diff
changeset
|
290 # if @REPLACE_FTELL@ |
12724 | 291 # undef ftell |
9262 | 292 # define ftell rpl_ftell |
12724 | 293 extern long ftell (FILE *fp) _GL_ARG_NONNULL ((1)); |
9262 | 294 # endif |
295 #endif | |
296 | |
11971 | 297 #if @GNULIB_FTELLO@ |
12724 | 298 # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES |
299 # define _GL_FTELL_WARN /* Category 3, above. */ | |
300 # undef ftell | |
301 # endif | |
11971 | 302 # if @REPLACE_FTELLO@ |
12724 | 303 # undef ftello |
11971 | 304 # define ftello rpl_ftello |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
305 extern off_t ftello (FILE *fp) _GL_ARG_NONNULL ((1)); |
12202
a0f033ee41af
fseek: avoid compilation failure when fflush is replaced
Eric Blake <ebb9@byu.net>
parents:
12100
diff
changeset
|
306 # if !@GNULIB_FTELL@ |
a0f033ee41af
fseek: avoid compilation failure when fflush is replaced
Eric Blake <ebb9@byu.net>
parents:
12100
diff
changeset
|
307 # undef ftell |
12724 | 308 # define ftell rpl_ftell |
309 static inline long _GL_ARG_NONNULL ((1)) | |
310 rpl_ftell (FILE *f) | |
311 { | |
312 return ftello (f); | |
313 } | |
12202
a0f033ee41af
fseek: avoid compilation failure when fflush is replaced
Eric Blake <ebb9@byu.net>
parents:
12100
diff
changeset
|
314 # endif |
11653 | 315 # endif |
316 #elif defined GNULIB_POSIXCHECK | |
12724 | 317 # define _GL_FTELL_WARN /* Category 1, above. */ |
318 # undef ftell | |
11971 | 319 # undef ftello |
12724 | 320 # if HAVE_RAW_DECL_FTELLO |
321 _GL_WARN_ON_USE (ftello, "ftello is unportable - " | |
322 "use gnulib module ftello for portability"); | |
323 # endif | |
324 #endif | |
325 | |
326 #ifdef _GL_FTELL_WARN | |
327 # undef _GL_FTELL_WARN | |
328 /* Here, either ftell is undefined (but C89 guarantees that it is | |
329 declared), or it is defined as rpl_ftell (declared above). */ | |
330 _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB " | |
331 "on 32-bit platforms - " | |
332 "use ftello function for handling of large files"); | |
10487
953f72c1ffcc
Support SIGPIPE in stdio functions for writing.
Bruno Haible <bruno@clisp.org>
parents:
10433
diff
changeset
|
333 #endif |
953f72c1ffcc
Support SIGPIPE in stdio functions for writing.
Bruno Haible <bruno@clisp.org>
parents:
10433
diff
changeset
|
334 |
953f72c1ffcc
Support SIGPIPE in stdio functions for writing.
Bruno Haible <bruno@clisp.org>
parents:
10433
diff
changeset
|
335 #if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ |
953f72c1ffcc
Support SIGPIPE in stdio functions for writing.
Bruno Haible <bruno@clisp.org>
parents:
10433
diff
changeset
|
336 # undef fwrite |
953f72c1ffcc
Support SIGPIPE in stdio functions for writing.
Bruno Haible <bruno@clisp.org>
parents:
10433
diff
changeset
|
337 # define fwrite rpl_fwrite |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
338 extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
339 _GL_ARG_NONNULL ((1, 4)); |
10487
953f72c1ffcc
Support SIGPIPE in stdio functions for writing.
Bruno Haible <bruno@clisp.org>
parents:
10433
diff
changeset
|
340 #endif |
953f72c1ffcc
Support SIGPIPE in stdio functions for writing.
Bruno Haible <bruno@clisp.org>
parents:
10433
diff
changeset
|
341 |
9262 | 342 #if @GNULIB_GETDELIM@ |
12839
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
343 # if @REPLACE_GETDELIM@ |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
344 # undef getdelim |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
345 # define getdelim rpl_getdelim |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
346 # endif |
c6d23570567d
Work around getdelim() bug on FreeBSD 8.0.
Bruno Haible <bruno@clisp.org>
parents:
12766
diff
changeset
|
347 # if !@HAVE_DECL_GETDELIM@ || @REPLACE_GETDELIM@ |
9262 | 348 /* Read input, up to (and including) the next occurrence of DELIMITER, from |
349 STREAM, store it in *LINEPTR (and NUL-terminate it). | |
350 *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE | |
351 bytes of space. It is realloc'd as necessary. | |
352 Return the number of bytes read and stored at *LINEPTR (not including the | |
353 NUL terminator), or -1 on error or EOF. */ | |
354 extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter, | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
355 FILE *stream) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
356 _GL_ARG_NONNULL ((1, 2, 4)); |
9262 | 357 # endif |
358 #elif defined GNULIB_POSIXCHECK | |
359 # undef getdelim | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
360 # if HAVE_RAW_DECL_GETDELIM |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
361 _GL_WARN_ON_USE (getdelim, "getdelim is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
362 "use gnulib module getdelim for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
363 # endif |
9262 | 364 #endif |
365 | |
366 #if @GNULIB_GETLINE@ | |
367 # if @REPLACE_GETLINE@ | |
368 # undef getline | |
369 # define getline rpl_getline | |
370 # endif | |
371 # if !@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@ | |
372 /* Read a line, up to (and including) the next newline, from STREAM, store it | |
373 in *LINEPTR (and NUL-terminate it). | |
374 *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE | |
375 bytes of space. It is realloc'd as necessary. | |
376 Return the number of bytes read and stored at *LINEPTR (not including the | |
377 NUL terminator), or -1 on error or EOF. */ | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
378 extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
379 _GL_ARG_NONNULL ((1, 2, 3)); |
9262 | 380 # endif |
381 #elif defined GNULIB_POSIXCHECK | |
382 # undef getline | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
383 # if HAVE_RAW_DECL_GETLINE |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
384 _GL_WARN_ON_USE (getline, "getline is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
385 "use gnulib module getline for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
386 # endif |
9262 | 387 #endif |
388 | |
11971 | 389 #if @GNULIB_OBSTACK_PRINTF@ |
390 # if @REPLACE_OBSTACK_PRINTF@ | |
391 # define obstack_printf rpl_osbtack_printf | |
392 # define obstack_vprintf rpl_obstack_vprintf | |
393 # endif | |
394 # if @REPLACE_OBSTACK_PRINTF@ || !@HAVE_DECL_OBSTACK_PRINTF@ | |
395 struct obstack; | |
396 /* Grow an obstack with formatted output. Return the number of | |
397 bytes added to OBS. No trailing nul byte is added, and the | |
398 object should be closed with obstack_finish before use. Upon | |
399 memory allocation error, call obstack_alloc_failed_handler. Upon | |
400 other error, return -1. */ | |
401 extern int obstack_printf (struct obstack *obs, const char *format, ...) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
402 __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2)); |
11971 | 403 extern int obstack_vprintf (struct obstack *obs, const char *format, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12418
diff
changeset
|
404 va_list args) |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
405 __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2)); |
11971 | 406 # endif |
407 #endif | |
408 | |
10433 | 409 #if @GNULIB_PERROR@ |
410 # if @REPLACE_PERROR@ | |
411 # define perror rpl_perror | |
412 /* Print a message to standard error, describing the value of ERRNO, | |
413 (if STRING is not NULL and not empty) prefixed with STRING and ": ", | |
414 and terminated with a newline. */ | |
415 extern void perror (const char *string); | |
416 # endif | |
417 #elif defined GNULIB_POSIXCHECK | |
418 # undef perror | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
419 /* Assume perror is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
420 _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
421 "use gnulib module perror for portability"); |
10433 | 422 #endif |
423 | |
11971 | 424 #if @GNULIB_POPEN@ |
425 # if @REPLACE_POPEN@ | |
426 # undef popen | |
427 # define popen rpl_popen | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
428 extern FILE *popen (const char *cmd, const char *mode) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
429 _GL_ARG_NONNULL ((1, 2)); |
11971 | 430 # endif |
431 #elif defined GNULIB_POSIXCHECK | |
432 # undef popen | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
433 # if HAVE_RAW_DECL_POPEN |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
434 _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
435 "use gnulib module popen or pipe for more portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
436 # endif |
11971 | 437 #endif |
438 | |
439 #if @GNULIB_PRINTF_POSIX@ | |
440 # if @REPLACE_PRINTF@ | |
441 /* Don't break __attribute__((format(printf,M,N))). */ | |
442 # define printf __printf__ | |
443 extern int printf (const char *format, ...) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
444 __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1)); |
11971 | 445 # endif |
446 #elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | |
447 /* Don't break __attribute__((format(printf,M,N))). */ | |
448 # define printf __printf__ | |
449 extern int printf (const char *format, ...) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
450 __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1)); |
11971 | 451 #elif defined GNULIB_POSIXCHECK |
452 # undef printf | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
453 /* Assume printf is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
454 _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
455 "use gnulib module printf-posix for portable " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
456 "POSIX compliance"); |
11971 | 457 #endif |
458 | |
459 #if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | |
460 # undef putc | |
461 # define putc rpl_fputc | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
462 extern int putc (int c, FILE *stream) _GL_ARG_NONNULL ((2)); |
11971 | 463 #endif |
464 | |
465 #if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | |
466 # undef putchar | |
467 # define putchar rpl_putchar | |
468 extern int putchar (int c); | |
469 #endif | |
470 | |
471 #if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | |
472 # undef puts | |
473 # define puts rpl_puts | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
474 extern int puts (const char *string) _GL_ARG_NONNULL ((1)); |
11971 | 475 #endif |
476 | |
12041
73e9ab6e2c90
remove: new module, for mingw and Solaris 9 bugs
Eric Blake <ebb9@byu.net>
parents:
11972
diff
changeset
|
477 #if @GNULIB_REMOVE@ |
73e9ab6e2c90
remove: new module, for mingw and Solaris 9 bugs
Eric Blake <ebb9@byu.net>
parents:
11972
diff
changeset
|
478 # if @REPLACE_REMOVE@ |
73e9ab6e2c90
remove: new module, for mingw and Solaris 9 bugs
Eric Blake <ebb9@byu.net>
parents:
11972
diff
changeset
|
479 # undef remove |
73e9ab6e2c90
remove: new module, for mingw and Solaris 9 bugs
Eric Blake <ebb9@byu.net>
parents:
11972
diff
changeset
|
480 # define remove rpl_remove |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
481 extern int remove (const char *name) _GL_ARG_NONNULL ((1)); |
12041
73e9ab6e2c90
remove: new module, for mingw and Solaris 9 bugs
Eric Blake <ebb9@byu.net>
parents:
11972
diff
changeset
|
482 # endif |
73e9ab6e2c90
remove: new module, for mingw and Solaris 9 bugs
Eric Blake <ebb9@byu.net>
parents:
11972
diff
changeset
|
483 #elif defined GNULIB_POSIXCHECK |
73e9ab6e2c90
remove: new module, for mingw and Solaris 9 bugs
Eric Blake <ebb9@byu.net>
parents:
11972
diff
changeset
|
484 # undef remove |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
485 /* Assume remove is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
486 _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
487 "use gnulib module remove for more portability"); |
12041
73e9ab6e2c90
remove: new module, for mingw and Solaris 9 bugs
Eric Blake <ebb9@byu.net>
parents:
11972
diff
changeset
|
488 #endif |
73e9ab6e2c90
remove: new module, for mingw and Solaris 9 bugs
Eric Blake <ebb9@byu.net>
parents:
11972
diff
changeset
|
489 |
11972 | 490 #if @GNULIB_RENAME@ |
491 # if @REPLACE_RENAME@ | |
492 # undef rename | |
493 # define rename rpl_rename | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
494 extern int rename (const char *old_filename, const char *new_filename) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
495 _GL_ARG_NONNULL ((1, 2)); |
11972 | 496 # endif |
497 #elif defined GNULIB_POSIXCHECK | |
498 # undef rename | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
499 /* Assume rename is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
500 _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
501 "use gnulib module rename for more portability"); |
11972 | 502 #endif |
503 | |
12099 | 504 #if @GNULIB_RENAMEAT@ |
12100 | 505 # if @REPLACE_RENAMEAT@ |
506 # undef renameat | |
507 # define renameat rpl_renameat | |
508 # endif | |
509 # if !@HAVE_RENAMEAT@ || @REPLACE_RENAMEAT@ | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
510 extern int renameat (int fd1, char const *file1, int fd2, char const *file2) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
511 _GL_ARG_NONNULL ((2, 4)); |
12099 | 512 # endif |
513 #elif defined GNULIB_POSIXCHECK | |
514 # undef renameat | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
515 # if HAVE_RAW_DECL_RENAMEAT |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
516 _GL_WARN_ON_USE (renameat, "renameat is not portable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
517 "use gnulib module renameat for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
518 # endif |
12099 | 519 #endif |
520 | |
11971 | 521 #if @GNULIB_SNPRINTF@ |
522 # if @REPLACE_SNPRINTF@ | |
523 # define snprintf rpl_snprintf | |
524 # endif | |
525 # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@ | |
526 extern int snprintf (char *str, size_t size, const char *format, ...) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
527 __attribute__ ((__format__ (__printf__, 3, 4))) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
528 _GL_ARG_NONNULL ((3)); |
11971 | 529 # endif |
530 #elif defined GNULIB_POSIXCHECK | |
531 # undef snprintf | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
532 # if HAVE_RAW_DECL_SNPRINTF |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
533 _GL_WARN_ON_USE (snprintf, "snprintf is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
534 "use gnulib module snprintf for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
535 # endif |
11971 | 536 #endif |
537 | |
12724 | 538 /* Some people would argue that sprintf should be handled like gets |
539 (for example, OpenBSD issues a link warning for both functions), | |
540 since both can cause security holes due to buffer overruns. | |
541 However, we believe that sprintf can be used safely, and is more | |
542 efficient than snprintf in those safe cases; and as proof of our | |
543 belief, we use sprintf in several gnulib modules. So this header | |
544 intentionally avoids adding a warning to sprintf except when | |
545 GNULIB_POSIXCHECK is defined. */ | |
546 | |
11971 | 547 #if @GNULIB_SPRINTF_POSIX@ |
548 # if @REPLACE_SPRINTF@ | |
549 # define sprintf rpl_sprintf | |
550 extern int sprintf (char *str, const char *format, ...) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
551 __attribute__ ((__format__ (__printf__, 2, 3))) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
552 _GL_ARG_NONNULL ((1, 2)); |
11971 | 553 # endif |
554 #elif defined GNULIB_POSIXCHECK | |
555 # undef sprintf | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
556 /* Assume sprintf is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
557 _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
558 "use gnulib module sprintf-posix for portable " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
559 "POSIX compliance"); |
11971 | 560 #endif |
561 | |
562 #if @GNULIB_VASPRINTF@ | |
563 # if @REPLACE_VASPRINTF@ | |
564 # define asprintf rpl_asprintf | |
565 # define vasprintf rpl_vasprintf | |
566 # endif | |
567 # if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@ | |
568 /* Write formatted output to a string dynamically allocated with malloc(). | |
569 If the memory allocation succeeds, store the address of the string in | |
570 *RESULT and return the number of resulting bytes, excluding the trailing | |
571 NUL. Upon memory allocation error, or some other error, return -1. */ | |
572 extern int asprintf (char **result, const char *format, ...) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
573 __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2)); |
11971 | 574 extern int vasprintf (char **result, const char *format, va_list args) |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
575 __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2)); |
11971 | 576 # endif |
577 #endif | |
578 | |
579 #if @GNULIB_VDPRINTF@ | |
580 # if @REPLACE_VDPRINTF@ | |
581 # define vdprintf rpl_vdprintf | |
582 # endif | |
583 # if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@ | |
584 extern int vdprintf (int fd, const char *format, va_list args) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
585 __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((2)); |
11971 | 586 # endif |
587 #elif defined GNULIB_POSIXCHECK | |
588 # undef vdprintf | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
589 # if HAVE_RAW_DECL_VDPRINTF |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
590 _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
591 "use gnulib module vdprintf for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
592 # endif |
11971 | 593 #endif |
594 | |
595 #if @GNULIB_VFPRINTF_POSIX@ | |
596 # if @REPLACE_VFPRINTF@ | |
597 # define vfprintf rpl_vfprintf | |
598 extern int vfprintf (FILE *fp, const char *format, va_list args) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
599 __attribute__ ((__format__ (__printf__, 2, 0))) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
600 _GL_ARG_NONNULL ((1, 2)); |
11971 | 601 # endif |
602 #elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | |
603 # define vfprintf rpl_vfprintf | |
604 extern int vfprintf (FILE *fp, const char *format, va_list args) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
605 __attribute__ ((__format__ (__printf__, 2, 0))) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
606 _GL_ARG_NONNULL ((1, 2)); |
11971 | 607 #elif defined GNULIB_POSIXCHECK |
608 # undef vfprintf | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
609 /* Assume vfprintf is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
610 _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
611 "use gnulib module vfprintf-posix for portable " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
612 "POSIX compliance"); |
11971 | 613 #endif |
614 | |
615 #if @GNULIB_VPRINTF_POSIX@ | |
616 # if @REPLACE_VPRINTF@ | |
617 # define vprintf rpl_vprintf | |
618 extern int vprintf (const char *format, va_list args) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
619 __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1)); |
11971 | 620 # endif |
621 #elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ | |
622 # define vprintf rpl_vprintf | |
623 extern int vprintf (const char *format, va_list args) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
624 __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1)); |
11971 | 625 #elif defined GNULIB_POSIXCHECK |
626 # undef vprintf | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
627 /* Assume vprintf is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
628 _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
629 "use gnulib module vprintf-posix for portable " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
630 "POSIX compliance"); |
11971 | 631 #endif |
632 | |
633 #if @GNULIB_VSNPRINTF@ | |
634 # if @REPLACE_VSNPRINTF@ | |
635 # define vsnprintf rpl_vsnprintf | |
636 # endif | |
637 # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@ | |
638 extern int vsnprintf (char *str, size_t size, const char *format, va_list args) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
639 __attribute__ ((__format__ (__printf__, 3, 0))) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
640 _GL_ARG_NONNULL ((3)); |
11971 | 641 # endif |
642 #elif defined GNULIB_POSIXCHECK | |
643 # undef vsnprintf | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
644 # if HAVE_RAW_DECL_VSNPRINTF |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
645 _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
646 "use gnulib module vsnprintf for portability"); |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
647 # endif |
11971 | 648 #endif |
649 | |
650 #if @GNULIB_VSPRINTF_POSIX@ | |
651 # if @REPLACE_VSPRINTF@ | |
652 # define vsprintf rpl_vsprintf | |
653 extern int vsprintf (char *str, const char *format, va_list args) | |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
654 __attribute__ ((__format__ (__printf__, 2, 0))) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
655 _GL_ARG_NONNULL ((1, 2)); |
11971 | 656 # endif |
657 #elif defined GNULIB_POSIXCHECK | |
658 # undef vsprintf | |
12766
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
659 /* Assume vsprintf is always declared. */ |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
660 _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
661 "use gnulib module vsprintf-posix for portable " |
2c14f1e449e5
warn-on-use: use instead of link-warning
Eric Blake <ebb9@byu.net>
parents:
12762
diff
changeset
|
662 "POSIX compliance"); |
11971 | 663 #endif |
664 | |
9262 | 665 #ifdef __cplusplus |
666 } | |
667 #endif | |
668 | |
669 #endif /* _GL_STDIO_H */ | |
670 #endif /* _GL_STDIO_H */ | |
671 #endif |