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 definition of GL_LINK_WARNING is copied here. */
82 /* The definition of _GL_ARG_NONNULL is copied here. */
89 /* Define wint_t. (Also done in wctype.in.h.) */
90 #if !@HAVE_WINT_T@ && !defined wint_t
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;
104 # define mbstate_t rpl_mbstate_t
105 # define GNULIB_defined_mbstate_t 1
109 /* Convert a single-byte character to a wide character. */
113 # define btowc rpl_btowc
115 # if !@HAVE_BTOWC@ || @REPLACE_BTOWC@
116 extern wint_t btowc (int c);
118 #elif defined GNULIB_POSIXCHECK
121 (GL_LINK_WARNING ("btowc is unportable - " \
122 "use gnulib module btowc for portability"), \
127 /* Convert a wide character to a single-byte character. */
131 # define wctob rpl_wctob
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);
137 #elif defined GNULIB_POSIXCHECK
140 (GL_LINK_WARNING ("wctob is unportable - " \
141 "use gnulib module wctob for portability"), \
146 /* Test whether *PS is in the initial state. */
148 # if @REPLACE_MBSINIT@
150 # define mbsinit rpl_mbsinit
152 # if !@HAVE_MBSINIT@ || @REPLACE_MBSINIT@
153 extern int mbsinit (const mbstate_t *ps);
155 #elif defined GNULIB_POSIXCHECK
157 # define mbsinit(p) \
158 (GL_LINK_WARNING ("mbsinit is unportable - " \
159 "use gnulib module mbsinit for portability"), \
164 /* Convert a multibyte character to a wide character. */
166 # if @REPLACE_MBRTOWC@
168 # define mbrtowc rpl_mbrtowc
170 # if !@HAVE_MBRTOWC@ || @REPLACE_MBRTOWC@
171 extern size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
173 #elif defined GNULIB_POSIXCHECK
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))
182 /* Recognize a multibyte character. */
184 # if @REPLACE_MBRLEN@
186 # define mbrlen rpl_mbrlen
188 # if !@HAVE_MBRLEN@ || @REPLACE_MBRLEN@
189 extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps);
191 #elif defined GNULIB_POSIXCHECK
193 # define mbrlen(s,n,p) \
194 (GL_LINK_WARNING ("mbrlen is unportable - " \
195 "use gnulib module mbrlen for portability"), \
200 /* Convert a string to a wide string. */
201 #if @GNULIB_MBSRTOWCS@
202 # if @REPLACE_MBSRTOWCS@
204 # define mbsrtowcs rpl_mbsrtowcs
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));
210 #elif defined GNULIB_POSIXCHECK
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))
219 /* Convert a string to a wide string. */
220 #if @GNULIB_MBSNRTOWCS@
221 # if @REPLACE_MBSNRTOWCS@
223 # define mbsnrtowcs rpl_mbsnrtowcs
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));
229 #elif defined GNULIB_POSIXCHECK
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))
238 /* Convert a wide character to a multibyte character. */
240 # if @REPLACE_WCRTOMB@
242 # define wcrtomb rpl_wcrtomb
244 # if !@HAVE_WCRTOMB@ || @REPLACE_WCRTOMB@
245 extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
247 #elif defined GNULIB_POSIXCHECK
249 # define wcrtomb(s,w,p) \
250 (GL_LINK_WARNING ("wcrtomb is unportable - " \
251 "use gnulib module wcrtomb for portability"), \
256 /* Convert a wide string to a string. */
257 #if @GNULIB_WCSRTOMBS@
258 # if @REPLACE_WCSRTOMBS@
260 # define wcsrtombs rpl_wcsrtombs
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));
266 #elif defined GNULIB_POSIXCHECK
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))
275 /* Convert a wide string to a string. */
276 #if @GNULIB_WCSNRTOMBS@
277 # if @REPLACE_WCSNRTOMBS@
279 # define wcsnrtombs rpl_wcsnrtombs
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));
285 #elif defined GNULIB_POSIXCHECK
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))
294 /* Return the number of screen columns needed for WC. */
296 # if @REPLACE_WCWIDTH@
298 # define wcwidth rpl_wcwidth
299 extern int wcwidth (wchar_t);
301 # if !defined wcwidth && !@HAVE_DECL_WCWIDTH@
302 /* wcwidth exists but is not declared. */
303 extern int wcwidth (int /* actually wchar_t */);
306 #elif defined GNULIB_POSIXCHECK
308 # define wcwidth(w) \
309 (GL_LINK_WARNING ("wcwidth is unportable - " \
310 "use gnulib module wcwidth for portability"), \
319 #endif /* _GL_WCHAR_H */
320 #endif /* _GL_WCHAR_H */