annotate lib/stdio.in.h @ 12879:037f6bf7ec72

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