]> git.cworth.org Git - tar/blob - gnu/wchar.in.h
cc464ae3b76a88da4dc7f826c620eb74f708fead
[tar] / gnu / 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 definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
81
82 /* The definition of _GL_ARG_NONNULL is copied here.  */
83
84 /* The definition of _GL_WARN_ON_USE is copied here.  */
85
86
87 /* Define wint_t.  (Also done in wctype.in.h.)  */
88 #if !@HAVE_WINT_T@ && !defined wint_t
89 # define wint_t int
90 # ifndef WEOF
91 #  define WEOF -1
92 # endif
93 #endif
94
95
96 /* Override mbstate_t if it is too small.
97    On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
98    implementing mbrtowc for encodings like UTF-8.  */
99 #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
100 typedef int rpl_mbstate_t;
101 # undef mbstate_t
102 # define mbstate_t rpl_mbstate_t
103 # define GNULIB_defined_mbstate_t 1
104 #endif
105
106
107 /* Convert a single-byte character to a wide character.  */
108 #if @GNULIB_BTOWC@
109 # if @REPLACE_BTOWC@
110 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
111 #   undef btowc
112 #   define btowc rpl_btowc
113 #  endif
114 _GL_FUNCDECL_RPL (btowc, wint_t, (int c));
115 _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
116 # else
117 #  if !@HAVE_BTOWC@
118 _GL_FUNCDECL_SYS (btowc, wint_t, (int c));
119 #  endif
120 _GL_CXXALIAS_SYS (btowc, wint_t, (int c));
121 # endif
122 _GL_CXXALIASWARN (btowc);
123 #elif defined GNULIB_POSIXCHECK
124 # undef btowc
125 # if HAVE_RAW_DECL_BTOWC
126 _GL_WARN_ON_USE (btowc, "btowc is unportable - "
127                  "use gnulib module btowc for portability");
128 # endif
129 #endif
130
131
132 /* Convert a wide character to a single-byte character.  */
133 #if @GNULIB_WCTOB@
134 # if @REPLACE_WCTOB@
135 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
136 #   undef wctob
137 #   define wctob rpl_wctob
138 #  endif
139 _GL_FUNCDECL_RPL (wctob, int, (wint_t wc));
140 _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
141 # else
142 #  if !defined wctob && !@HAVE_DECL_WCTOB@
143 /* wctob is provided by gnulib, or wctob exists but is not declared.  */
144 _GL_FUNCDECL_SYS (wctob, int, (wint_t wc));
145 #  endif
146 _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
147 # endif
148 _GL_CXXALIASWARN (wctob);
149 #elif defined GNULIB_POSIXCHECK
150 # undef wctob
151 # if HAVE_RAW_DECL_WCTOB
152 _GL_WARN_ON_USE (wctob, "wctob is unportable - "
153                  "use gnulib module wctob for portability");
154 # endif
155 #endif
156
157
158 /* Test whether *PS is in the initial state.  */
159 #if @GNULIB_MBSINIT@
160 # if @REPLACE_MBSINIT@
161 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
162 #   undef mbsinit
163 #   define mbsinit rpl_mbsinit
164 #  endif
165 _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
166 _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
167 # else
168 #  if !@HAVE_MBSINIT@
169 _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
170 #  endif
171 _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
172 # endif
173 _GL_CXXALIASWARN (mbsinit);
174 #elif defined GNULIB_POSIXCHECK
175 # undef mbsinit
176 # if HAVE_RAW_DECL_MBSINIT
177 _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
178                  "use gnulib module mbsinit for portability");
179 # endif
180 #endif
181
182
183 /* Convert a multibyte character to a wide character.  */
184 #if @GNULIB_MBRTOWC@
185 # if @REPLACE_MBRTOWC@
186 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
187 #   undef mbrtowc
188 #   define mbrtowc rpl_mbrtowc
189 #  endif
190 _GL_FUNCDECL_RPL (mbrtowc, size_t,
191                   (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
192 _GL_CXXALIAS_RPL (mbrtowc, size_t,
193                   (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
194 # else
195 #  if !@HAVE_MBRTOWC@
196 _GL_FUNCDECL_SYS (mbrtowc, size_t,
197                   (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
198 #  endif
199 _GL_CXXALIAS_SYS (mbrtowc, size_t,
200                   (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
201 # endif
202 _GL_CXXALIASWARN (mbrtowc);
203 #elif defined GNULIB_POSIXCHECK
204 # undef mbrtowc
205 # if HAVE_RAW_DECL_MBRTOWC
206 _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
207                  "use gnulib module mbrtowc for portability");
208 # endif
209 #endif
210
211
212 /* Recognize a multibyte character.  */
213 #if @GNULIB_MBRLEN@
214 # if @REPLACE_MBRLEN@
215 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
216 #   undef mbrlen
217 #   define mbrlen rpl_mbrlen
218 #  endif
219 _GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
220 _GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
221 # else
222 #  if !@HAVE_MBRLEN@
223 _GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
224 #  endif
225 _GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
226 # endif
227 _GL_CXXALIASWARN (mbrlen);
228 #elif defined GNULIB_POSIXCHECK
229 # undef mbrlen
230 # if HAVE_RAW_DECL_MBRLEN
231 _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
232                  "use gnulib module mbrlen for portability");
233 # endif
234 #endif
235
236
237 /* Convert a string to a wide string.  */
238 #if @GNULIB_MBSRTOWCS@
239 # if @REPLACE_MBSRTOWCS@
240 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
241 #   undef mbsrtowcs
242 #   define mbsrtowcs rpl_mbsrtowcs
243 #  endif
244 _GL_FUNCDECL_RPL (mbsrtowcs, size_t,
245                   (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
246                   _GL_ARG_NONNULL ((2)));
247 _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
248                   (wchar_t *dest, const char **srcp, size_t len,
249                    mbstate_t *ps));
250 # else
251 #  if !@HAVE_MBSRTOWCS@
252 _GL_FUNCDECL_SYS (mbsrtowcs, size_t,
253                   (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
254                   _GL_ARG_NONNULL ((2)));
255 #  endif
256 _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
257                   (wchar_t *dest, const char **srcp, size_t len,
258                    mbstate_t *ps));
259 # endif
260 _GL_CXXALIASWARN (mbsrtowcs);
261 #elif defined GNULIB_POSIXCHECK
262 # undef mbsrtowcs
263 # if HAVE_RAW_DECL_MBSRTOWCS
264 _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
265                  "use gnulib module mbsrtowcs for portability");
266 # endif
267 #endif
268
269
270 /* Convert a string to a wide string.  */
271 #if @GNULIB_MBSNRTOWCS@
272 # if @REPLACE_MBSNRTOWCS@
273 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
274 #   undef mbsnrtowcs
275 #   define mbsnrtowcs rpl_mbsnrtowcs
276 #  endif
277 _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
278                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
279                    mbstate_t *ps)
280                   _GL_ARG_NONNULL ((2)));
281 _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
282                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
283                    mbstate_t *ps));
284 # else
285 #  if !@HAVE_MBSNRTOWCS@
286 _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
287                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
288                    mbstate_t *ps)
289                   _GL_ARG_NONNULL ((2)));
290 #  endif
291 _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
292                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
293                    mbstate_t *ps));
294 # endif
295 _GL_CXXALIASWARN (mbsnrtowcs);
296 #elif defined GNULIB_POSIXCHECK
297 # undef mbsnrtowcs
298 # if HAVE_RAW_DECL_MBSNRTOWCS
299 _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
300                  "use gnulib module mbsnrtowcs for portability");
301 # endif
302 #endif
303
304
305 /* Convert a wide character to a multibyte character.  */
306 #if @GNULIB_WCRTOMB@
307 # if @REPLACE_WCRTOMB@
308 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
309 #   undef wcrtomb
310 #   define wcrtomb rpl_wcrtomb
311 #  endif
312 _GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
313 _GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
314 # else
315 #  if !@HAVE_WCRTOMB@
316 _GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
317 #  endif
318 _GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
319 # endif
320 _GL_CXXALIASWARN (wcrtomb);
321 #elif defined GNULIB_POSIXCHECK
322 # undef wcrtomb
323 # if HAVE_RAW_DECL_WCRTOMB
324 _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
325                  "use gnulib module wcrtomb for portability");
326 # endif
327 #endif
328
329
330 /* Convert a wide string to a string.  */
331 #if @GNULIB_WCSRTOMBS@
332 # if @REPLACE_WCSRTOMBS@
333 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
334 #   undef wcsrtombs
335 #   define wcsrtombs rpl_wcsrtombs
336 #  endif
337 _GL_FUNCDECL_RPL (wcsrtombs, size_t,
338                   (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
339                   _GL_ARG_NONNULL ((2)));
340 _GL_CXXALIAS_RPL (wcsrtombs, size_t,
341                   (char *dest, const wchar_t **srcp, size_t len,
342                    mbstate_t *ps));
343 # else
344 #  if !@HAVE_WCSRTOMBS@
345 _GL_FUNCDECL_SYS (wcsrtombs, size_t,
346                   (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
347                   _GL_ARG_NONNULL ((2)));
348 #  endif
349 _GL_CXXALIAS_SYS (wcsrtombs, size_t,
350                   (char *dest, const wchar_t **srcp, size_t len,
351                    mbstate_t *ps));
352 # endif
353 _GL_CXXALIASWARN (wcsrtombs);
354 #elif defined GNULIB_POSIXCHECK
355 # undef wcsrtombs
356 # if HAVE_RAW_DECL_WCSRTOMBS
357 _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
358                  "use gnulib module wcsrtombs for portability");
359 # endif
360 #endif
361
362
363 /* Convert a wide string to a string.  */
364 #if @GNULIB_WCSNRTOMBS@
365 # if @REPLACE_WCSNRTOMBS@
366 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
367 #   undef wcsnrtombs
368 #   define wcsnrtombs rpl_wcsnrtombs
369 #  endif
370 _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
371                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
372                    mbstate_t *ps)
373                   _GL_ARG_NONNULL ((2)));
374 _GL_CXXALIAS_RPL (wcsnrtombs, size_t,
375                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
376                    mbstate_t *ps));
377 # else
378 #  if !@HAVE_WCSNRTOMBS@
379 _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
380                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
381                    mbstate_t *ps)
382                   _GL_ARG_NONNULL ((2)));
383 #  endif
384 _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
385                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
386                    mbstate_t *ps));
387 # endif
388 _GL_CXXALIASWARN (wcsnrtombs);
389 #elif defined GNULIB_POSIXCHECK
390 # undef wcsnrtombs
391 # if HAVE_RAW_DECL_WCSNRTOMBS
392 _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
393                  "use gnulib module wcsnrtombs for portability");
394 # endif
395 #endif
396
397
398 /* Return the number of screen columns needed for WC.  */
399 #if @GNULIB_WCWIDTH@
400 # if @REPLACE_WCWIDTH@
401 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
402 #   undef wcwidth
403 #   define wcwidth rpl_wcwidth
404 #  endif
405 _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t));
406 _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
407 # else
408 #  if !defined wcwidth && !@HAVE_DECL_WCWIDTH@
409 /* wcwidth exists but is not declared.  */
410 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t));
411 #  endif
412 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
413 # endif
414 _GL_CXXALIASWARN (wcwidth);
415 #elif defined GNULIB_POSIXCHECK
416 # undef wcwidth
417 # if HAVE_RAW_DECL_WCWIDTH
418 _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
419                  "use gnulib module wcwidth for portability");
420 # endif
421 #endif
422
423
424 #endif /* _GL_WCHAR_H */
425 #endif /* _GL_WCHAR_H */
426 #endif