]> git.cworth.org Git - tar/blob - gnu/wchar.in.h
Imported Upstream version 1.24
[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 @PRAGMA_COLUMNS@
35
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.  */
48
49 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
50
51 #else
52 /* Normal invocation convention.  */
53
54 #ifndef _GL_WCHAR_H
55
56 #define _GL_ALREADY_INCLUDING_WCHAR_H
57
58 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
59    <wchar.h>.
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.  */
63 #ifndef __GLIBC__
64 # include <stddef.h>
65 # include <stdio.h>
66 # include <time.h>
67 #endif
68
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.  */
72 #if @HAVE_WCHAR_H@
73 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
74 #endif
75
76 #undef _GL_ALREADY_INCLUDING_WCHAR_H
77
78 #ifndef _GL_WCHAR_H
79 #define _GL_WCHAR_H
80
81 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
82
83 /* The definition of _GL_ARG_NONNULL is copied here.  */
84
85 /* The definition of _GL_WARN_ON_USE is copied here.  */
86
87
88 /* Define wint_t and WEOF.  (Also done in wctype.in.h.)  */
89 #if !@HAVE_WINT_T@ && !defined wint_t
90 # define wint_t int
91 # ifndef WEOF
92 #  define WEOF -1
93 # endif
94 #else
95 # ifndef WEOF
96 #  define WEOF ((wint_t) -1)
97 # endif
98 #endif
99
100
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;
106 # undef mbstate_t
107 # define mbstate_t rpl_mbstate_t
108 # define GNULIB_defined_mbstate_t 1
109 #endif
110
111
112 /* Convert a single-byte character to a wide character.  */
113 #if @GNULIB_BTOWC@
114 # if @REPLACE_BTOWC@
115 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
116 #   undef btowc
117 #   define btowc rpl_btowc
118 #  endif
119 _GL_FUNCDECL_RPL (btowc, wint_t, (int c));
120 _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
121 # else
122 #  if !@HAVE_BTOWC@
123 _GL_FUNCDECL_SYS (btowc, wint_t, (int c));
124 #  endif
125 _GL_CXXALIAS_SYS (btowc, wint_t, (int c));
126 # endif
127 _GL_CXXALIASWARN (btowc);
128 #elif defined GNULIB_POSIXCHECK
129 # undef btowc
130 # if HAVE_RAW_DECL_BTOWC
131 _GL_WARN_ON_USE (btowc, "btowc is unportable - "
132                  "use gnulib module btowc for portability");
133 # endif
134 #endif
135
136
137 /* Convert a wide character to a single-byte character.  */
138 #if @GNULIB_WCTOB@
139 # if @REPLACE_WCTOB@
140 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
141 #   undef wctob
142 #   define wctob rpl_wctob
143 #  endif
144 _GL_FUNCDECL_RPL (wctob, int, (wint_t wc));
145 _GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
146 # else
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));
150 #  endif
151 _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
152 # endif
153 _GL_CXXALIASWARN (wctob);
154 #elif defined GNULIB_POSIXCHECK
155 # undef wctob
156 # if HAVE_RAW_DECL_WCTOB
157 _GL_WARN_ON_USE (wctob, "wctob is unportable - "
158                  "use gnulib module wctob for portability");
159 # endif
160 #endif
161
162
163 /* Test whether *PS is in the initial state.  */
164 #if @GNULIB_MBSINIT@
165 # if @REPLACE_MBSINIT@
166 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
167 #   undef mbsinit
168 #   define mbsinit rpl_mbsinit
169 #  endif
170 _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps));
171 _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
172 # else
173 #  if !@HAVE_MBSINIT@
174 _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
175 #  endif
176 _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
177 # endif
178 _GL_CXXALIASWARN (mbsinit);
179 #elif defined GNULIB_POSIXCHECK
180 # undef mbsinit
181 # if HAVE_RAW_DECL_MBSINIT
182 _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
183                  "use gnulib module mbsinit for portability");
184 # endif
185 #endif
186
187
188 /* Convert a multibyte character to a wide character.  */
189 #if @GNULIB_MBRTOWC@
190 # if @REPLACE_MBRTOWC@
191 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
192 #   undef mbrtowc
193 #   define mbrtowc rpl_mbrtowc
194 #  endif
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));
199 # else
200 #  if !@HAVE_MBRTOWC@
201 _GL_FUNCDECL_SYS (mbrtowc, size_t,
202                   (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
203 #  endif
204 _GL_CXXALIAS_SYS (mbrtowc, size_t,
205                   (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps));
206 # endif
207 _GL_CXXALIASWARN (mbrtowc);
208 #elif defined GNULIB_POSIXCHECK
209 # undef mbrtowc
210 # if HAVE_RAW_DECL_MBRTOWC
211 _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
212                  "use gnulib module mbrtowc for portability");
213 # endif
214 #endif
215
216
217 /* Recognize a multibyte character.  */
218 #if @GNULIB_MBRLEN@
219 # if @REPLACE_MBRLEN@
220 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
221 #   undef mbrlen
222 #   define mbrlen rpl_mbrlen
223 #  endif
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));
226 # else
227 #  if !@HAVE_MBRLEN@
228 _GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
229 #  endif
230 _GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps));
231 # endif
232 _GL_CXXALIASWARN (mbrlen);
233 #elif defined GNULIB_POSIXCHECK
234 # undef mbrlen
235 # if HAVE_RAW_DECL_MBRLEN
236 _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
237                  "use gnulib module mbrlen for portability");
238 # endif
239 #endif
240
241
242 /* Convert a string to a wide string.  */
243 #if @GNULIB_MBSRTOWCS@
244 # if @REPLACE_MBSRTOWCS@
245 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
246 #   undef mbsrtowcs
247 #   define mbsrtowcs rpl_mbsrtowcs
248 #  endif
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,
254                    mbstate_t *ps));
255 # else
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)));
260 #  endif
261 _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
262                   (wchar_t *dest, const char **srcp, size_t len,
263                    mbstate_t *ps));
264 # endif
265 _GL_CXXALIASWARN (mbsrtowcs);
266 #elif defined GNULIB_POSIXCHECK
267 # undef mbsrtowcs
268 # if HAVE_RAW_DECL_MBSRTOWCS
269 _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
270                  "use gnulib module mbsrtowcs for portability");
271 # endif
272 #endif
273
274
275 /* Convert a string to a wide string.  */
276 #if @GNULIB_MBSNRTOWCS@
277 # if @REPLACE_MBSNRTOWCS@
278 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
279 #   undef mbsnrtowcs
280 #   define mbsnrtowcs rpl_mbsnrtowcs
281 #  endif
282 _GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
283                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
284                    mbstate_t *ps)
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,
288                    mbstate_t *ps));
289 # else
290 #  if !@HAVE_MBSNRTOWCS@
291 _GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
292                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
293                    mbstate_t *ps)
294                   _GL_ARG_NONNULL ((2)));
295 #  endif
296 _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
297                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len,
298                    mbstate_t *ps));
299 # endif
300 _GL_CXXALIASWARN (mbsnrtowcs);
301 #elif defined GNULIB_POSIXCHECK
302 # undef mbsnrtowcs
303 # if HAVE_RAW_DECL_MBSNRTOWCS
304 _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
305                  "use gnulib module mbsnrtowcs for portability");
306 # endif
307 #endif
308
309
310 /* Convert a wide character to a multibyte character.  */
311 #if @GNULIB_WCRTOMB@
312 # if @REPLACE_WCRTOMB@
313 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
314 #   undef wcrtomb
315 #   define wcrtomb rpl_wcrtomb
316 #  endif
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));
319 # else
320 #  if !@HAVE_WCRTOMB@
321 _GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
322 #  endif
323 _GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps));
324 # endif
325 _GL_CXXALIASWARN (wcrtomb);
326 #elif defined GNULIB_POSIXCHECK
327 # undef wcrtomb
328 # if HAVE_RAW_DECL_WCRTOMB
329 _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
330                  "use gnulib module wcrtomb for portability");
331 # endif
332 #endif
333
334
335 /* Convert a wide string to a string.  */
336 #if @GNULIB_WCSRTOMBS@
337 # if @REPLACE_WCSRTOMBS@
338 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
339 #   undef wcsrtombs
340 #   define wcsrtombs rpl_wcsrtombs
341 #  endif
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,
347                    mbstate_t *ps));
348 # else
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)));
353 #  endif
354 _GL_CXXALIAS_SYS (wcsrtombs, size_t,
355                   (char *dest, const wchar_t **srcp, size_t len,
356                    mbstate_t *ps));
357 # endif
358 _GL_CXXALIASWARN (wcsrtombs);
359 #elif defined GNULIB_POSIXCHECK
360 # undef wcsrtombs
361 # if HAVE_RAW_DECL_WCSRTOMBS
362 _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
363                  "use gnulib module wcsrtombs for portability");
364 # endif
365 #endif
366
367
368 /* Convert a wide string to a string.  */
369 #if @GNULIB_WCSNRTOMBS@
370 # if @REPLACE_WCSNRTOMBS@
371 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
372 #   undef wcsnrtombs
373 #   define wcsnrtombs rpl_wcsnrtombs
374 #  endif
375 _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
376                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
377                    mbstate_t *ps)
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,
381                    mbstate_t *ps));
382 # else
383 #  if !@HAVE_WCSNRTOMBS@
384 _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
385                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
386                    mbstate_t *ps)
387                   _GL_ARG_NONNULL ((2)));
388 #  endif
389 _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
390                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
391                    mbstate_t *ps));
392 # endif
393 _GL_CXXALIASWARN (wcsnrtombs);
394 #elif defined GNULIB_POSIXCHECK
395 # undef wcsnrtombs
396 # if HAVE_RAW_DECL_WCSNRTOMBS
397 _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
398                  "use gnulib module wcsnrtombs for portability");
399 # endif
400 #endif
401
402
403 /* Return the number of screen columns needed for WC.  */
404 #if @GNULIB_WCWIDTH@
405 # if @REPLACE_WCWIDTH@
406 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
407 #   undef wcwidth
408 #   define wcwidth rpl_wcwidth
409 #  endif
410 _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t));
411 _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
412 # else
413 #  if !@HAVE_DECL_WCWIDTH@
414 /* wcwidth exists but is not declared.  */
415 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t));
416 #  endif
417 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
418 # endif
419 _GL_CXXALIASWARN (wcwidth);
420 #elif defined GNULIB_POSIXCHECK
421 # undef wcwidth
422 # if HAVE_RAW_DECL_WCWIDTH
423 _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
424                  "use gnulib module wcwidth for portability");
425 # endif
426 #endif
427
428
429 #endif /* _GL_WCHAR_H */
430 #endif /* _GL_WCHAR_H */
431 #endif