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@
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. */
48 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
51 /* Normal invocation convention. */
55 #define _GL_ALREADY_INCLUDING_WCHAR_H
57 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
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. */
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. */
72 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
75 #undef _GL_ALREADY_INCLUDING_WCHAR_H
80 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
82 /* The definition of _GL_ARG_NONNULL is copied here. */
84 /* The definition of _GL_WARN_ON_USE is copied here. */
87 /* Define wint_t. (Also done in wctype.in.h.) */
88 #if !@HAVE_WINT_T@ && !defined wint_t
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;
102 # define mbstate_t rpl_mbstate_t
103 # define GNULIB_defined_mbstate_t 1
107 /* Convert a single-byte character to a wide character. */
110 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
112 # define btowc rpl_btowc
114 _GL_FUNCDECL_RPL (btowc, wint_t, (int c));
115 _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
118 _GL_FUNCDECL_SYS (btowc, wint_t, (int c));
120 _GL_CXXALIAS_SYS (btowc, wint_t, (int c));
122 _GL_CXXALIASWARN (btowc);
123 #elif defined GNULIB_POSIXCHECK
125 # if HAVE_RAW_DECL_BTOWC
126 _GL_WARN_ON_USE (btowc, "btowc is unportable - "
127 "use gnulib module btowc for portability");
132 /* Convert a wide character to a single-byte character. */
135 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
137 # define wctob rpl_wctob
139 _GL_FUNCDECL_RPL (wctob, int, (wint_t wc));
140 _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
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));
146 _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
148 _GL_CXXALIASWARN (wctob);
149 #elif defined GNULIB_POSIXCHECK
151 # if HAVE_RAW_DECL_WCTOB
152 _GL_WARN_ON_USE (wctob, "wctob is unportable - "
153 "use gnulib module wctob for portability");
158 /* Test whether *PS is in the initial state. */
160 # if @REPLACE_MBSINIT@
161 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
163 # define mbsinit rpl_mbsinit
165 _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
166 _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
169 _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
171 _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
173 _GL_CXXALIASWARN (mbsinit);
174 #elif defined GNULIB_POSIXCHECK
176 # if HAVE_RAW_DECL_MBSINIT
177 _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
178 "use gnulib module mbsinit for portability");
183 /* Convert a multibyte character to a wide character. */
185 # if @REPLACE_MBRTOWC@
186 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
188 # define mbrtowc rpl_mbrtowc
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));
196 _GL_FUNCDECL_SYS (mbrtowc, size_t,
197 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
199 _GL_CXXALIAS_SYS (mbrtowc, size_t,
200 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
202 _GL_CXXALIASWARN (mbrtowc);
203 #elif defined GNULIB_POSIXCHECK
205 # if HAVE_RAW_DECL_MBRTOWC
206 _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
207 "use gnulib module mbrtowc for portability");
212 /* Recognize a multibyte character. */
214 # if @REPLACE_MBRLEN@
215 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
217 # define mbrlen rpl_mbrlen
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));
223 _GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
225 _GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
227 _GL_CXXALIASWARN (mbrlen);
228 #elif defined GNULIB_POSIXCHECK
230 # if HAVE_RAW_DECL_MBRLEN
231 _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
232 "use gnulib module mbrlen for portability");
237 /* Convert a string to a wide string. */
238 #if @GNULIB_MBSRTOWCS@
239 # if @REPLACE_MBSRTOWCS@
240 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
242 # define mbsrtowcs rpl_mbsrtowcs
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,
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)));
256 _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
257 (wchar_t *dest, const char **srcp, size_t len,
260 _GL_CXXALIASWARN (mbsrtowcs);
261 #elif defined GNULIB_POSIXCHECK
263 # if HAVE_RAW_DECL_MBSRTOWCS
264 _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
265 "use gnulib module mbsrtowcs for portability");
270 /* Convert a string to a wide string. */
271 #if @GNULIB_MBSNRTOWCS@
272 # if @REPLACE_MBSNRTOWCS@
273 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
275 # define mbsnrtowcs rpl_mbsnrtowcs
277 _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
278 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
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,
285 # if !@HAVE_MBSNRTOWCS@
286 _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
287 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
289 _GL_ARG_NONNULL ((2)));
291 _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
292 (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
295 _GL_CXXALIASWARN (mbsnrtowcs);
296 #elif defined GNULIB_POSIXCHECK
298 # if HAVE_RAW_DECL_MBSNRTOWCS
299 _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
300 "use gnulib module mbsnrtowcs for portability");
305 /* Convert a wide character to a multibyte character. */
307 # if @REPLACE_WCRTOMB@
308 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
310 # define wcrtomb rpl_wcrtomb
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));
316 _GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
318 _GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
320 _GL_CXXALIASWARN (wcrtomb);
321 #elif defined GNULIB_POSIXCHECK
323 # if HAVE_RAW_DECL_WCRTOMB
324 _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
325 "use gnulib module wcrtomb for portability");
330 /* Convert a wide string to a string. */
331 #if @GNULIB_WCSRTOMBS@
332 # if @REPLACE_WCSRTOMBS@
333 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
335 # define wcsrtombs rpl_wcsrtombs
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,
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)));
349 _GL_CXXALIAS_SYS (wcsrtombs, size_t,
350 (char *dest, const wchar_t **srcp, size_t len,
353 _GL_CXXALIASWARN (wcsrtombs);
354 #elif defined GNULIB_POSIXCHECK
356 # if HAVE_RAW_DECL_WCSRTOMBS
357 _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
358 "use gnulib module wcsrtombs for portability");
363 /* Convert a wide string to a string. */
364 #if @GNULIB_WCSNRTOMBS@
365 # if @REPLACE_WCSNRTOMBS@
366 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
368 # define wcsnrtombs rpl_wcsnrtombs
370 _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
371 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
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,
378 # if !@HAVE_WCSNRTOMBS@
379 _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
380 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
382 _GL_ARG_NONNULL ((2)));
384 _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
385 (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
388 _GL_CXXALIASWARN (wcsnrtombs);
389 #elif defined GNULIB_POSIXCHECK
391 # if HAVE_RAW_DECL_WCSNRTOMBS
392 _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
393 "use gnulib module wcsnrtombs for portability");
398 /* Return the number of screen columns needed for WC. */
400 # if @REPLACE_WCWIDTH@
401 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
403 # define wcwidth rpl_wcwidth
405 _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t));
406 _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
408 # if !defined wcwidth && !@HAVE_DECL_WCWIDTH@
409 /* wcwidth exists but is not declared. */
410 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t));
412 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
414 _GL_CXXALIASWARN (wcwidth);
415 #elif defined GNULIB_POSIXCHECK
417 # if HAVE_RAW_DECL_WCWIDTH
418 _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
419 "use gnulib module wcwidth for portability");
424 #endif /* _GL_WCHAR_H */
425 #endif /* _GL_WCHAR_H */