Mercurial > hg-old > index.cgi
comparison lib/wchar.in.h @ 265:68fbca173508 2.6
Added generated files for release
author | lost |
---|---|
date | Tue, 22 Dec 2009 05:31:23 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
264:61d1db1dfe2a | 265:68fbca173508 |
---|---|
1 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues. | |
2 | |
3 Copyright (C) 2007-2009 Free Software Foundation, Inc. | |
4 | |
5 This program is free software; you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation; either version 2, or (at your option) | |
8 any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16 along with this program; if not, write to the Free Software Foundation, | |
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | |
18 | |
19 /* Written by Eric Blake. */ | |
20 | |
21 /* | |
22 * ISO C 99 <wchar.h> for platforms that have issues. | |
23 * <http://www.opengroup.org/susv3xbd/wchar.h.html> | |
24 * | |
25 * For now, this just ensures proper prerequisite inclusion order and | |
26 * the declaration of wcwidth(). | |
27 */ | |
28 | |
29 #if __GNUC__ >= 3 | |
30 @PRAGMA_SYSTEM_HEADER@ | |
31 #endif | |
32 | |
33 #if defined __need_mbstate_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H | |
34 /* Special invocation convention: | |
35 - Inside uClibc header files. | |
36 - On HP-UX 11.00 we have a sequence of nested includes | |
37 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>, | |
38 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h> | |
39 and once directly. In both situations 'wint_t' is not yet defined, | |
40 therefore we cannot provide the function overrides; instead include only | |
41 the system's <wchar.h>. | |
42 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and | |
43 the latter includes <wchar.h>. But here, we have no way to detect whether | |
44 <wctype.h> is completely included or is still being included. */ | |
45 | |
46 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@ | |
47 | |
48 #else | |
49 /* Normal invocation convention. */ | |
50 | |
51 #ifndef _GL_WCHAR_H | |
52 | |
53 #define _GL_ALREADY_INCLUDING_WCHAR_H | |
54 | |
55 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | |
56 <wchar.h>. | |
57 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | |
58 included before <wchar.h>. */ | |
59 #include <stddef.h> | |
60 #include <stdio.h> | |
61 #include <time.h> | |
62 | |
63 /* Include the original <wchar.h> if it exists. | |
64 Some builds of uClibc lack it. */ | |
65 /* The include_next requires a split double-inclusion guard. */ | |
66 #if @HAVE_WCHAR_H@ | |
67 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@ | |
68 #endif | |
69 | |
70 #undef _GL_ALREADY_INCLUDING_WCHAR_H | |
71 | |
72 #ifndef _GL_WCHAR_H | |
73 #define _GL_WCHAR_H | |
74 | |
75 /* The definition of GL_LINK_WARNING is copied here. */ | |
76 | |
77 #ifdef __cplusplus | |
78 extern "C" { | |
79 #endif | |
80 | |
81 | |
82 /* Define wint_t. (Also done in wctype.in.h.) */ | |
83 #if !@HAVE_WINT_T@ && !defined wint_t | |
84 # define wint_t int | |
85 # ifndef WEOF | |
86 # define WEOF -1 | |
87 # endif | |
88 #endif | |
89 | |
90 | |
91 /* Override mbstate_t if it is too small. | |
92 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for | |
93 implementing mbrtowc for encodings like UTF-8. */ | |
94 #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@ | |
95 typedef int rpl_mbstate_t; | |
96 # undef mbstate_t | |
97 # define mbstate_t rpl_mbstate_t | |
98 # define GNULIB_defined_mbstate_t 1 | |
99 #endif | |
100 | |
101 | |
102 /* Convert a single-byte character to a wide character. */ | |
103 #if @GNULIB_BTOWC@ | |
104 # if @REPLACE_BTOWC@ | |
105 # undef btowc | |
106 # define btowc rpl_btowc | |
107 # endif | |
108 # if !@HAVE_BTOWC@ || @REPLACE_BTOWC@ | |
109 extern wint_t btowc (int c); | |
110 # endif | |
111 #elif defined GNULIB_POSIXCHECK | |
112 # undef btowc | |
113 # define btowc(c) \ | |
114 (GL_LINK_WARNING ("btowc is unportable - " \ | |
115 "use gnulib module btowc for portability"), \ | |
116 btowc (c)) | |
117 #endif | |
118 | |
119 | |
120 /* Convert a wide character to a single-byte character. */ | |
121 #if @GNULIB_WCTOB@ | |
122 # if @REPLACE_WCTOB@ | |
123 # undef wctob | |
124 # define wctob rpl_wctob | |
125 # endif | |
126 # if (!defined wctob && !@HAVE_DECL_WCTOB@) || @REPLACE_WCTOB@ | |
127 /* wctob is provided by gnulib, or wctob exists but is not declared. */ | |
128 extern int wctob (wint_t wc); | |
129 # endif | |
130 #elif defined GNULIB_POSIXCHECK | |
131 # undef wctob | |
132 # define wctob(w) \ | |
133 (GL_LINK_WARNING ("wctob is unportable - " \ | |
134 "use gnulib module wctob for portability"), \ | |
135 wctob (w)) | |
136 #endif | |
137 | |
138 | |
139 /* Test whether *PS is in the initial state. */ | |
140 #if @GNULIB_MBSINIT@ | |
141 # if @REPLACE_MBSINIT@ | |
142 # undef mbsinit | |
143 # define mbsinit rpl_mbsinit | |
144 # endif | |
145 # if !@HAVE_MBSINIT@ || @REPLACE_MBSINIT@ | |
146 extern int mbsinit (const mbstate_t *ps); | |
147 # endif | |
148 #elif defined GNULIB_POSIXCHECK | |
149 # undef mbsinit | |
150 # define mbsinit(p) \ | |
151 (GL_LINK_WARNING ("mbsinit is unportable - " \ | |
152 "use gnulib module mbsinit for portability"), \ | |
153 mbsinit (p)) | |
154 #endif | |
155 | |
156 | |
157 /* Convert a multibyte character to a wide character. */ | |
158 #if @GNULIB_MBRTOWC@ | |
159 # if @REPLACE_MBRTOWC@ | |
160 # undef mbrtowc | |
161 # define mbrtowc rpl_mbrtowc | |
162 # endif | |
163 # if !@HAVE_MBRTOWC@ || @REPLACE_MBRTOWC@ | |
164 extern size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps); | |
165 # endif | |
166 #elif defined GNULIB_POSIXCHECK | |
167 # undef mbrtowc | |
168 # define mbrtowc(w,s,n,p) \ | |
169 (GL_LINK_WARNING ("mbrtowc is unportable - " \ | |
170 "use gnulib module mbrtowc for portability"), \ | |
171 mbrtowc (w, s, n, p)) | |
172 #endif | |
173 | |
174 | |
175 /* Recognize a multibyte character. */ | |
176 #if @GNULIB_MBRLEN@ | |
177 # if @REPLACE_MBRLEN@ | |
178 # undef mbrlen | |
179 # define mbrlen rpl_mbrlen | |
180 # endif | |
181 # if !@HAVE_MBRLEN@ || @REPLACE_MBRLEN@ | |
182 extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps); | |
183 # endif | |
184 #elif defined GNULIB_POSIXCHECK | |
185 # undef mbrlen | |
186 # define mbrlen(s,n,p) \ | |
187 (GL_LINK_WARNING ("mbrlen is unportable - " \ | |
188 "use gnulib module mbrlen for portability"), \ | |
189 mbrlen (s, n, p)) | |
190 #endif | |
191 | |
192 | |
193 /* Convert a string to a wide string. */ | |
194 #if @GNULIB_MBSRTOWCS@ | |
195 # if @REPLACE_MBSRTOWCS@ | |
196 # undef mbsrtowcs | |
197 # define mbsrtowcs rpl_mbsrtowcs | |
198 # endif | |
199 # if !@HAVE_MBSRTOWCS@ || @REPLACE_MBSRTOWCS@ | |
200 extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps); | |
201 # endif | |
202 #elif defined GNULIB_POSIXCHECK | |
203 # undef mbsrtowcs | |
204 # define mbsrtowcs(d,s,l,p) \ | |
205 (GL_LINK_WARNING ("mbsrtowcs is unportable - " \ | |
206 "use gnulib module mbsrtowcs for portability"), \ | |
207 mbsrtowcs (d, s, l, p)) | |
208 #endif | |
209 | |
210 | |
211 /* Convert a string to a wide string. */ | |
212 #if @GNULIB_MBSNRTOWCS@ | |
213 # if @REPLACE_MBSNRTOWCS@ | |
214 # undef mbsnrtowcs | |
215 # define mbsnrtowcs rpl_mbsnrtowcs | |
216 # endif | |
217 # if !@HAVE_MBSNRTOWCS@ || @REPLACE_MBSNRTOWCS@ | |
218 extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps); | |
219 # endif | |
220 #elif defined GNULIB_POSIXCHECK | |
221 # undef mbsnrtowcs | |
222 # define mbsnrtowcs(d,s,n,l,p) \ | |
223 (GL_LINK_WARNING ("mbsnrtowcs is unportable - " \ | |
224 "use gnulib module mbsnrtowcs for portability"), \ | |
225 mbsnrtowcs (d, s, n, l, p)) | |
226 #endif | |
227 | |
228 | |
229 /* Convert a wide character to a multibyte character. */ | |
230 #if @GNULIB_WCRTOMB@ | |
231 # if @REPLACE_WCRTOMB@ | |
232 # undef wcrtomb | |
233 # define wcrtomb rpl_wcrtomb | |
234 # endif | |
235 # if !@HAVE_WCRTOMB@ || @REPLACE_WCRTOMB@ | |
236 extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps); | |
237 # endif | |
238 #elif defined GNULIB_POSIXCHECK | |
239 # undef wcrtomb | |
240 # define wcrtomb(s,w,p) \ | |
241 (GL_LINK_WARNING ("wcrtomb is unportable - " \ | |
242 "use gnulib module wcrtomb for portability"), \ | |
243 wcrtomb (s, w, p)) | |
244 #endif | |
245 | |
246 | |
247 /* Convert a wide string to a string. */ | |
248 #if @GNULIB_WCSRTOMBS@ | |
249 # if @REPLACE_WCSRTOMBS@ | |
250 # undef wcsrtombs | |
251 # define wcsrtombs rpl_wcsrtombs | |
252 # endif | |
253 # if !@HAVE_WCSRTOMBS@ || @REPLACE_WCSRTOMBS@ | |
254 extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps); | |
255 # endif | |
256 #elif defined GNULIB_POSIXCHECK | |
257 # undef wcsrtombs | |
258 # define wcsrtombs(d,s,l,p) \ | |
259 (GL_LINK_WARNING ("wcsrtombs is unportable - " \ | |
260 "use gnulib module wcsrtombs for portability"), \ | |
261 wcsrtombs (d, s, l, p)) | |
262 #endif | |
263 | |
264 | |
265 /* Convert a wide string to a string. */ | |
266 #if @GNULIB_WCSNRTOMBS@ | |
267 # if !@HAVE_WCSNRTOMBS@ | |
268 extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps); | |
269 # endif | |
270 #elif defined GNULIB_POSIXCHECK | |
271 # undef wcsnrtombs | |
272 # define wcsnrtombs(d,s,n,l,p) \ | |
273 (GL_LINK_WARNING ("wcsnrtombs is unportable - " \ | |
274 "use gnulib module wcsnrtombs for portability"), \ | |
275 wcsnrtombs (d, s, n, l, p)) | |
276 #endif | |
277 | |
278 | |
279 /* Return the number of screen columns needed for WC. */ | |
280 #if @GNULIB_WCWIDTH@ | |
281 # if @REPLACE_WCWIDTH@ | |
282 # undef wcwidth | |
283 # define wcwidth rpl_wcwidth | |
284 extern int wcwidth (wchar_t); | |
285 # else | |
286 # if !defined wcwidth && !@HAVE_DECL_WCWIDTH@ | |
287 /* wcwidth exists but is not declared. */ | |
288 extern int wcwidth (int /* actually wchar_t */); | |
289 # endif | |
290 # endif | |
291 #elif defined GNULIB_POSIXCHECK | |
292 # undef wcwidth | |
293 # define wcwidth(w) \ | |
294 (GL_LINK_WARNING ("wcwidth is unportable - " \ | |
295 "use gnulib module wcwidth for portability"), \ | |
296 wcwidth (w)) | |
297 #endif | |
298 | |
299 | |
300 #ifdef __cplusplus | |
301 } | |
302 #endif | |
303 | |
304 #endif /* _GL_WCHAR_H */ | |
305 #endif /* _GL_WCHAR_H */ | |
306 #endif |