fe3a058cb32e47055eadaa73c6d63e63be6e6682
[debian/gzip] / lib / wchar.in.h
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
4
5    Copyright (C) 2007-2010 Free Software Foundation, Inc.
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3, or (at your option)
10    any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software Foundation,
19    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
20
21 /* Written by Eric Blake.  */
22
23 /*
24  * ISO C 99 <wchar.h> for platforms that have issues.
25  * <http://www.opengroup.org/susv3xbd/wchar.h.html>
26  *
27  * For now, this just ensures proper prerequisite inclusion order and
28  * the declaration of wcwidth().
29  */
30
31 #if __GNUC__ >= 3
32 @PRAGMA_SYSTEM_HEADER@
33 #endif
34
35 #if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H
36 /* Special invocation convention:
37    - Inside glibc and uClibc header files.
38    - On HP-UX 11.00 we have a sequence of nested includes
39      <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
40      once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
41      and once directly.  In both situations 'wint_t' is not yet defined,
42      therefore we cannot provide the function overrides; instead include only
43      the system's <wchar.h>.
44    - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
45      the latter includes <wchar.h>.  But here, we have no way to detect whether
46      <wctype.h> is completely included or is still being included.  */
47
48 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
49
50 #else
51 /* Normal invocation convention.  */
52
53 #ifndef _GL_WCHAR_H
54
55 #define _GL_ALREADY_INCLUDING_WCHAR_H
56
57 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
58    <wchar.h>.
59    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
60    included before <wchar.h>.
61    But avoid namespace pollution on glibc systems.  */
62 #ifndef __GLIBC__
63 # include <stddef.h>
64 # include <stdio.h>
65 # include <time.h>
66 #endif
67
68 /* Include the original <wchar.h> if it exists.
69    Some builds of uClibc lack it.  */
70 /* The include_next requires a split double-inclusion guard.  */
71 #if @HAVE_WCHAR_H@
72 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
73 #endif
74
75 #undef _GL_ALREADY_INCLUDING_WCHAR_H
76
77 #ifndef _GL_WCHAR_H
78 #define _GL_WCHAR_H
79
80 /* The definition of GL_LINK_WARNING is copied here.  */
81
82 /* The definition of _GL_ARG_NONNULL is copied here.  */
83
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
87
88
89 /* Define wint_t.  (Also done in wctype.in.h.)  */
90 #if !@HAVE_WINT_T@ && !defined wint_t
91 # define wint_t int
92 # ifndef WEOF
93 #  define WEOF -1
94 # endif
95 #endif
96
97
98 /* Override mbstate_t if it is too small.
99    On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
100    implementing mbrtowc for encodings like UTF-8.  */
101 #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
102 typedef int rpl_mbstate_t;
103 # undef mbstate_t
104 # define mbstate_t rpl_mbstate_t
105 # define GNULIB_defined_mbstate_t 1
106 #endif
107
108
109 /* Convert a single-byte character to a wide character.  */
110 #if @GNULIB_BTOWC@
111 # if @REPLACE_BTOWC@
112 #  undef btowc
113 #  define btowc rpl_btowc
114 # endif
115 # if !@HAVE_BTOWC@ || @REPLACE_BTOWC@
116 extern wint_t btowc (int c);
117 # endif
118 #elif defined GNULIB_POSIXCHECK
119 # undef btowc
120 # define btowc(c) \
121     (GL_LINK_WARNING ("btowc is unportable - " \
122                       "use gnulib module btowc for portability"), \
123      btowc (c))
124 #endif
125
126
127 /* Convert a wide character to a single-byte character.  */
128 #if @GNULIB_WCTOB@
129 # if @REPLACE_WCTOB@
130 #  undef wctob
131 #  define wctob rpl_wctob
132 # endif
133 # if (!defined wctob && !@HAVE_DECL_WCTOB@) || @REPLACE_WCTOB@
134 /* wctob is provided by gnulib, or wctob exists but is not declared.  */
135 extern int wctob (wint_t wc);
136 # endif
137 #elif defined GNULIB_POSIXCHECK
138 # undef wctob
139 # define wctob(w) \
140     (GL_LINK_WARNING ("wctob is unportable - " \
141                       "use gnulib module wctob for portability"), \
142      wctob (w))
143 #endif
144
145
146 /* Test whether *PS is in the initial state.  */
147 #if @GNULIB_MBSINIT@
148 # if @REPLACE_MBSINIT@
149 #  undef mbsinit
150 #  define mbsinit rpl_mbsinit
151 # endif
152 # if !@HAVE_MBSINIT@ || @REPLACE_MBSINIT@
153 extern int mbsinit (const mbstate_t *ps);
154 # endif
155 #elif defined GNULIB_POSIXCHECK
156 # undef mbsinit
157 # define mbsinit(p) \
158     (GL_LINK_WARNING ("mbsinit is unportable - " \
159                       "use gnulib module mbsinit for portability"), \
160      mbsinit (p))
161 #endif
162
163
164 /* Convert a multibyte character to a wide character.  */
165 #if @GNULIB_MBRTOWC@
166 # if @REPLACE_MBRTOWC@
167 #  undef mbrtowc
168 #  define mbrtowc rpl_mbrtowc
169 # endif
170 # if !@HAVE_MBRTOWC@ || @REPLACE_MBRTOWC@
171 extern size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
172 # endif
173 #elif defined GNULIB_POSIXCHECK
174 # undef mbrtowc
175 # define mbrtowc(w,s,n,p) \
176     (GL_LINK_WARNING ("mbrtowc is unportable - " \
177                       "use gnulib module mbrtowc for portability"), \
178      mbrtowc (w, s, n, p))
179 #endif
180
181
182 /* Recognize a multibyte character.  */
183 #if @GNULIB_MBRLEN@
184 # if @REPLACE_MBRLEN@
185 #  undef mbrlen
186 #  define mbrlen rpl_mbrlen
187 # endif
188 # if !@HAVE_MBRLEN@ || @REPLACE_MBRLEN@
189 extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps);
190 # endif
191 #elif defined GNULIB_POSIXCHECK
192 # undef mbrlen
193 # define mbrlen(s,n,p) \
194     (GL_LINK_WARNING ("mbrlen is unportable - " \
195                       "use gnulib module mbrlen for portability"), \
196      mbrlen (s, n, p))
197 #endif
198
199
200 /* Convert a string to a wide string.  */
201 #if @GNULIB_MBSRTOWCS@
202 # if @REPLACE_MBSRTOWCS@
203 #  undef mbsrtowcs
204 #  define mbsrtowcs rpl_mbsrtowcs
205 # endif
206 # if !@HAVE_MBSRTOWCS@ || @REPLACE_MBSRTOWCS@
207 extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
208      _GL_ARG_NONNULL ((2));
209 # endif
210 #elif defined GNULIB_POSIXCHECK
211 # undef mbsrtowcs
212 # define mbsrtowcs(d,s,l,p) \
213     (GL_LINK_WARNING ("mbsrtowcs is unportable - " \
214                       "use gnulib module mbsrtowcs for portability"), \
215      mbsrtowcs (d, s, l, p))
216 #endif
217
218
219 /* Convert a string to a wide string.  */
220 #if @GNULIB_MBSNRTOWCS@
221 # if @REPLACE_MBSNRTOWCS@
222 #  undef mbsnrtowcs
223 #  define mbsnrtowcs rpl_mbsnrtowcs
224 # endif
225 # if !@HAVE_MBSNRTOWCS@ || @REPLACE_MBSNRTOWCS@
226 extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps)
227      _GL_ARG_NONNULL ((2));
228 # endif
229 #elif defined GNULIB_POSIXCHECK
230 # undef mbsnrtowcs
231 # define mbsnrtowcs(d,s,n,l,p) \
232     (GL_LINK_WARNING ("mbsnrtowcs is unportable - " \
233                       "use gnulib module mbsnrtowcs for portability"), \
234      mbsnrtowcs (d, s, n, l, p))
235 #endif
236
237
238 /* Convert a wide character to a multibyte character.  */
239 #if @GNULIB_WCRTOMB@
240 # if @REPLACE_WCRTOMB@
241 #  undef wcrtomb
242 #  define wcrtomb rpl_wcrtomb
243 # endif
244 # if !@HAVE_WCRTOMB@ || @REPLACE_WCRTOMB@
245 extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
246 # endif
247 #elif defined GNULIB_POSIXCHECK
248 # undef wcrtomb
249 # define wcrtomb(s,w,p) \
250     (GL_LINK_WARNING ("wcrtomb is unportable - " \
251                       "use gnulib module wcrtomb for portability"), \
252      wcrtomb (s, w, p))
253 #endif
254
255
256 /* Convert a wide string to a string.  */
257 #if @GNULIB_WCSRTOMBS@
258 # if @REPLACE_WCSRTOMBS@
259 #  undef wcsrtombs
260 #  define wcsrtombs rpl_wcsrtombs
261 # endif
262 # if !@HAVE_WCSRTOMBS@ || @REPLACE_WCSRTOMBS@
263 extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
264      _GL_ARG_NONNULL ((2));
265 # endif
266 #elif defined GNULIB_POSIXCHECK
267 # undef wcsrtombs
268 # define wcsrtombs(d,s,l,p) \
269     (GL_LINK_WARNING ("wcsrtombs is unportable - " \
270                       "use gnulib module wcsrtombs for portability"), \
271      wcsrtombs (d, s, l, p))
272 #endif
273
274
275 /* Convert a wide string to a string.  */
276 #if @GNULIB_WCSNRTOMBS@
277 # if @REPLACE_WCSNRTOMBS@
278 #  undef wcsnrtombs
279 #  define wcsnrtombs rpl_wcsnrtombs
280 # endif
281 # if !@HAVE_WCSNRTOMBS@ || @REPLACE_WCSNRTOMBS@
282 extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps)
283      _GL_ARG_NONNULL ((2));
284 # endif
285 #elif defined GNULIB_POSIXCHECK
286 # undef wcsnrtombs
287 # define wcsnrtombs(d,s,n,l,p) \
288     (GL_LINK_WARNING ("wcsnrtombs is unportable - " \
289                       "use gnulib module wcsnrtombs for portability"), \
290      wcsnrtombs (d, s, n, l, p))
291 #endif
292
293
294 /* Return the number of screen columns needed for WC.  */
295 #if @GNULIB_WCWIDTH@
296 # if @REPLACE_WCWIDTH@
297 #  undef wcwidth
298 #  define wcwidth rpl_wcwidth
299 extern int wcwidth (wchar_t);
300 # else
301 #  if !defined wcwidth && !@HAVE_DECL_WCWIDTH@
302 /* wcwidth exists but is not declared.  */
303 extern int wcwidth (int /* actually wchar_t */);
304 #  endif
305 # endif
306 #elif defined GNULIB_POSIXCHECK
307 # undef wcwidth
308 # define wcwidth(w) \
309     (GL_LINK_WARNING ("wcwidth is unportable - " \
310                       "use gnulib module wcwidth for portability"), \
311      wcwidth (w))
312 #endif
313
314
315 #ifdef __cplusplus
316 }
317 #endif
318
319 #endif /* _GL_WCHAR_H */
320 #endif /* _GL_WCHAR_H */
321 #endif