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.
5 Copyright (C) 2007-2010 Free Software Foundation, Inc.
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)
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.
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. */
21 /* Written by Eric Blake. */
24 * ISO C 99 <wchar.h> for platforms that have issues.
25 * <http://www.opengroup.org/susv3xbd/wchar.h.html>
27 * For now, this just ensures proper prerequisite inclusion order and
28 * the declaration of wcwidth().
32 @PRAGMA_SYSTEM_HEADER@
36 #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
37 /* Special invocation convention:
38 - Inside glibc and uClibc header files.
39 - On HP-UX 11.00 we have a sequence of nested includes
40 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
41 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
42 and once directly. In both situations 'wint_t' is not yet defined,
43 therefore we cannot provide the function overrides; instead include only
44 the system's <wchar.h>.
45 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
46 the latter includes <wchar.h>. But here, we have no way to detect whether
47 <wctype.h> is completely included or is still being included. */
49 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
52 /* Normal invocation convention. */
56 #define _GL_ALREADY_INCLUDING_WCHAR_H
58 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
60 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
61 included before <wchar.h>.
62 But avoid namespace pollution on glibc systems. */
69 /* Include the original <wchar.h> if it exists.
70 Some builds of uClibc lack it. */
71 /* The include_next requires a split double-inclusion guard. */
73 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
76 #undef _GL_ALREADY_INCLUDING_WCHAR_H
81 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
83 /* The definition of _GL_ARG_NONNULL is copied here. */
85 /* The definition of _GL_WARN_ON_USE is copied here. */
88 /* Define wint_t and WEOF. (Also done in wctype.in.h.) */
89 #if !@HAVE_WINT_T@ && !defined wint_t
96 # define WEOF ((wint_t) -1)
101 /* Override mbstate_t if it is too small.
102 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
103 implementing mbrtowc for encodings like UTF-8. */
104 #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
105 typedef int rpl_mbstate_t;
107 # define mbstate_t rpl_mbstate_t
108 # define GNULIB_defined_mbstate_t 1
112 /* Convert a single-byte character to a wide character. */
115 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
117 # define btowc rpl_btowc
119 _GL_FUNCDECL_RPL (btowc, wint_t, (int c));
120 _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
123 _GL_FUNCDECL_SYS (btowc, wint_t, (int c));
125 _GL_CXXALIAS_SYS (btowc, wint_t, (int c));
127 _GL_CXXALIASWARN (btowc);
128 #elif defined GNULIB_POSIXCHECK
130 # if HAVE_RAW_DECL_BTOWC
131 _GL_WARN_ON_USE (btowc, "btowc is unportable - "
132 "use gnulib module btowc for portability");
137 /* Convert a wide character to a single-byte character. */
140 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
142 # define wctob rpl_wctob
144 _GL_FUNCDECL_RPL (wctob, int, (wint_t wc));
145 _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
147 # if !defined wctob && !@HAVE_DECL_WCTOB@
148 /* wctob is provided by gnulib, or wctob exists but is not declared. */
149 _GL_FUNCDECL_SYS (wctob, int, (wint_t wc));
151 _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
153 _GL_CXXALIASWARN (wctob);
154 #elif defined GNULIB_POSIXCHECK
156 # if HAVE_RAW_DECL_WCTOB
157 _GL_WARN_ON_USE (wctob, "wctob is unportable - "
158 "use gnulib module wctob for portability");
163 /* Test whether *PS is in the initial state. */
165 # if @REPLACE_MBSINIT@
166 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
168 # define mbsinit rpl_mbsinit
170 _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
171 _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
174 _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
176 _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
178 _GL_CXXALIASWARN (mbsinit);
179 #elif defined GNULIB_POSIXCHECK
181 # if HAVE_RAW_DECL_MBSINIT
182 _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
183 "use gnulib module mbsinit for portability");
188 /* Convert a multibyte character to a wide character. */
190 # if @REPLACE_MBRTOWC@
191 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
193 # define mbrtowc rpl_mbrtowc
195 _GL_FUNCDECL_RPL (mbrtowc, size_t,
196 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
197 _GL_CXXALIAS_RPL (mbrtowc, size_t,
198 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
201 _GL_FUNCDECL_SYS (mbrtowc, size_t,
202 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
204 _GL_CXXALIAS_SYS (mbrtowc, size_t,
205 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
207 _GL_CXXALIASWARN (mbrtowc);
208 #elif defined GNULIB_POSIXCHECK
210 # if HAVE_RAW_DECL_MBRTOWC
211 _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
212 "use gnulib module mbrtowc for portability");
217 /* Recognize a multibyte character. */
219 # if @REPLACE_MBRLEN@
220 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
222 # define mbrlen rpl_mbrlen
224 _GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
225 _GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
228 _GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
230 _GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
232 _GL_CXXALIASWARN (mbrlen);
233 #elif defined GNULIB_POSIXCHECK
235 # if HAVE_RAW_DECL_MBRLEN
236 _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
237 "use gnulib module mbrlen for portability");
242 /* Convert a string to a wide string. */
243 #if @GNULIB_MBSRTOWCS@
244 # if @REPLACE_MBSRTOWCS@
245 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
247 # define mbsrtowcs rpl_mbsrtowcs
249 _GL_FUNCDECL_RPL (mbsrtowcs, size_t,
250 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
251 _GL_ARG_NONNULL ((2)));
252 _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
253 (wchar_t *dest, const char **srcp, size_t len,
256 # if !@HAVE_MBSRTOWCS@
257 _GL_FUNCDECL_SYS (mbsrtowcs, size_t,
258 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
259 _GL_ARG_NONNULL ((2)));
261 _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
262 (wchar_t *dest, const char **srcp, size_t len,
265 _GL_CXXALIASWARN (mbsrtowcs);
266 #elif defined GNULIB_POSIXCHECK
268 # if HAVE_RAW_DECL_MBSRTOWCS
269 _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
270 "use gnulib module mbsrtowcs for portability");
275 /* Convert a string to a wide string. */
276 #if @GNULIB_MBSNRTOWCS@
277 # if @REPLACE_MBSNRTOWCS@
278 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
280 # define mbsnrtowcs rpl_mbsnrtowcs
282 _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
283 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
285 _GL_ARG_NONNULL ((2)));
286 _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
287 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
290 # if !@HAVE_MBSNRTOWCS@
291 _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
292 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
294 _GL_ARG_NONNULL ((2)));
296 _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
297 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
300 _GL_CXXALIASWARN (mbsnrtowcs);
301 #elif defined GNULIB_POSIXCHECK
303 # if HAVE_RAW_DECL_MBSNRTOWCS
304 _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
305 "use gnulib module mbsnrtowcs for portability");
310 /* Convert a wide character to a multibyte character. */
312 # if @REPLACE_WCRTOMB@
313 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
315 # define wcrtomb rpl_wcrtomb
317 _GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
318 _GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
321 _GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
323 _GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
325 _GL_CXXALIASWARN (wcrtomb);
326 #elif defined GNULIB_POSIXCHECK
328 # if HAVE_RAW_DECL_WCRTOMB
329 _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
330 "use gnulib module wcrtomb for portability");
335 /* Convert a wide string to a string. */
336 #if @GNULIB_WCSRTOMBS@
337 # if @REPLACE_WCSRTOMBS@
338 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
340 # define wcsrtombs rpl_wcsrtombs
342 _GL_FUNCDECL_RPL (wcsrtombs, size_t,
343 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
344 _GL_ARG_NONNULL ((2)));
345 _GL_CXXALIAS_RPL (wcsrtombs, size_t,
346 (char *dest, const wchar_t **srcp, size_t len,
349 # if !@HAVE_WCSRTOMBS@
350 _GL_FUNCDECL_SYS (wcsrtombs, size_t,
351 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
352 _GL_ARG_NONNULL ((2)));
354 _GL_CXXALIAS_SYS (wcsrtombs, size_t,
355 (char *dest, const wchar_t **srcp, size_t len,
358 _GL_CXXALIASWARN (wcsrtombs);
359 #elif defined GNULIB_POSIXCHECK
361 # if HAVE_RAW_DECL_WCSRTOMBS
362 _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
363 "use gnulib module wcsrtombs for portability");
368 /* Convert a wide string to a string. */
369 #if @GNULIB_WCSNRTOMBS@
370 # if @REPLACE_WCSNRTOMBS@
371 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
373 # define wcsnrtombs rpl_wcsnrtombs
375 _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
376 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
378 _GL_ARG_NONNULL ((2)));
379 _GL_CXXALIAS_RPL (wcsnrtombs, size_t,
380 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
383 # if !@HAVE_WCSNRTOMBS@
384 _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
385 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
387 _GL_ARG_NONNULL ((2)));
389 _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
390 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
393 _GL_CXXALIASWARN (wcsnrtombs);
394 #elif defined GNULIB_POSIXCHECK
396 # if HAVE_RAW_DECL_WCSNRTOMBS
397 _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
398 "use gnulib module wcsnrtombs for portability");
403 /* Return the number of screen columns needed for WC. */
405 # if @REPLACE_WCWIDTH@
406 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
408 # define wcwidth rpl_wcwidth
410 _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t));
411 _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
413 # if !@HAVE_DECL_WCWIDTH@
414 /* wcwidth exists but is not declared. */
415 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t));
417 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
419 _GL_CXXALIASWARN (wcwidth);
420 #elif defined GNULIB_POSIXCHECK
422 # if HAVE_RAW_DECL_WCWIDTH
423 _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
424 "use gnulib module wcwidth for portability");
429 #endif /* _GL_WCHAR_H */
430 #endif /* _GL_WCHAR_H */