Mercurial > hg-old > index.cgi
comparison lib/wchar.in.h @ 272:d5392bb5da3c 2.5
Added generated files
author | lost |
---|---|
date | Sun, 16 Aug 2009 17:16:49 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
271:3b793ba7a6c6 | 272:d5392bb5da3c |
---|---|
1 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues. | |
2 | |
3 Copyright (C) 2007-2008 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 3, 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 #ifdef __need_mbstate_t | |
34 /* Special invocation convention inside uClibc header files. */ | |
35 | |
36 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@ | |
37 | |
38 #else | |
39 /* Normal invocation convention. */ | |
40 | |
41 #ifndef _GL_WCHAR_H | |
42 | |
43 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | |
44 <wchar.h>. | |
45 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | |
46 included before <wchar.h>. */ | |
47 #include <stddef.h> | |
48 #include <stdio.h> | |
49 #include <time.h> | |
50 | |
51 /* Include the original <wchar.h> if it exists. | |
52 Some builds of uClibc lack it. */ | |
53 /* The include_next requires a split double-inclusion guard. */ | |
54 #if @HAVE_WCHAR_H@ | |
55 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@ | |
56 #endif | |
57 | |
58 #ifndef _GL_WCHAR_H | |
59 #define _GL_WCHAR_H | |
60 | |
61 /* The definition of GL_LINK_WARNING is copied here. */ | |
62 | |
63 #ifdef __cplusplus | |
64 extern "C" { | |
65 #endif | |
66 | |
67 | |
68 /* Define wint_t. (Also done in wctype.in.h.) */ | |
69 #if !@HAVE_WINT_T@ && !defined wint_t | |
70 # define wint_t int | |
71 # ifndef WEOF | |
72 # define WEOF -1 | |
73 # endif | |
74 #endif | |
75 | |
76 | |
77 /* Override mbstate_t if it is too small. | |
78 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for | |
79 implementing mbrtowc for encodings like UTF-8. */ | |
80 #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@ | |
81 typedef int rpl_mbstate_t; | |
82 # undef mbstate_t | |
83 # define mbstate_t rpl_mbstate_t | |
84 # define GNULIB_defined_mbstate_t 1 | |
85 #endif | |
86 | |
87 | |
88 /* Convert a single-byte character to a wide character. */ | |
89 #if @GNULIB_BTOWC@ | |
90 # if @REPLACE_BTOWC@ | |
91 # undef btowc | |
92 # define btowc rpl_btowc | |
93 # endif | |
94 # if !@HAVE_BTOWC@ || @REPLACE_BTOWC@ | |
95 extern wint_t btowc (int c); | |
96 # endif | |
97 #elif defined GNULIB_POSIXCHECK | |
98 # undef btowc | |
99 # define btowc(c) \ | |
100 (GL_LINK_WARNING ("btowc is unportable - " \ | |
101 "use gnulib module btowc for portability"), \ | |
102 btowc (c)) | |
103 #endif | |
104 | |
105 | |
106 /* Convert a wide character to a single-byte character. */ | |
107 #if @GNULIB_WCTOB@ | |
108 # if @REPLACE_WCTOB@ | |
109 # undef wctob | |
110 # define wctob rpl_wctob | |
111 # endif | |
112 # if (!defined wctob && !@HAVE_DECL_WCTOB@) || @REPLACE_WCTOB@ | |
113 /* wctob is provided by gnulib, or wctob exists but is not declared. */ | |
114 extern int wctob (wint_t wc); | |
115 # endif | |
116 #elif defined GNULIB_POSIXCHECK | |
117 # undef wctob | |
118 # define wctob(w) \ | |
119 (GL_LINK_WARNING ("wctob is unportable - " \ | |
120 "use gnulib module wctob for portability"), \ | |
121 wctob (w)) | |
122 #endif | |
123 | |
124 | |
125 /* Test whether *PS is in the initial state. */ | |
126 #if @GNULIB_MBSINIT@ | |
127 # if @REPLACE_MBSINIT@ | |
128 # undef mbsinit | |
129 # define mbsinit rpl_mbsinit | |
130 # endif | |
131 # if !@HAVE_MBSINIT@ || @REPLACE_MBSINIT@ | |
132 extern int mbsinit (const mbstate_t *ps); | |
133 # endif | |
134 #elif defined GNULIB_POSIXCHECK | |
135 # undef mbsinit | |
136 # define mbsinit(p) \ | |
137 (GL_LINK_WARNING ("mbsinit is unportable - " \ | |
138 "use gnulib module mbsinit for portability"), \ | |
139 mbsinit (p)) | |
140 #endif | |
141 | |
142 | |
143 /* Convert a multibyte character to a wide character. */ | |
144 #if @GNULIB_MBRTOWC@ | |
145 # if @REPLACE_MBRTOWC@ | |
146 # undef mbrtowc | |
147 # define mbrtowc rpl_mbrtowc | |
148 # endif | |
149 # if !@HAVE_MBRTOWC@ || @REPLACE_MBRTOWC@ | |
150 extern size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps); | |
151 # endif | |
152 #elif defined GNULIB_POSIXCHECK | |
153 # undef mbrtowc | |
154 # define mbrtowc(w,s,n,p) \ | |
155 (GL_LINK_WARNING ("mbrtowc is unportable - " \ | |
156 "use gnulib module mbrtowc for portability"), \ | |
157 mbrtowc (w, s, n, p)) | |
158 #endif | |
159 | |
160 | |
161 /* Recognize a multibyte character. */ | |
162 #if @GNULIB_MBRLEN@ | |
163 # if @REPLACE_MBRLEN@ | |
164 # undef mbrlen | |
165 # define mbrlen rpl_mbrlen | |
166 # endif | |
167 # if !@HAVE_MBRLEN@ || @REPLACE_MBRLEN@ | |
168 extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps); | |
169 # endif | |
170 #elif defined GNULIB_POSIXCHECK | |
171 # undef mbrlen | |
172 # define mbrlen(s,n,p) \ | |
173 (GL_LINK_WARNING ("mbrlen is unportable - " \ | |
174 "use gnulib module mbrlen for portability"), \ | |
175 mbrlen (s, n, p)) | |
176 #endif | |
177 | |
178 | |
179 /* Convert a string to a wide string. */ | |
180 #if @GNULIB_MBSRTOWCS@ | |
181 # if @REPLACE_MBSRTOWCS@ | |
182 # undef mbsrtowcs | |
183 # define mbsrtowcs rpl_mbsrtowcs | |
184 # endif | |
185 # if !@HAVE_MBSRTOWCS@ || @REPLACE_MBSRTOWCS@ | |
186 extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps); | |
187 # endif | |
188 #elif defined GNULIB_POSIXCHECK | |
189 # undef mbsrtowcs | |
190 # define mbsrtowcs(d,s,l,p) \ | |
191 (GL_LINK_WARNING ("mbsrtowcs is unportable - " \ | |
192 "use gnulib module mbsrtowcs for portability"), \ | |
193 mbsrtowcs (d, s, l, p)) | |
194 #endif | |
195 | |
196 | |
197 /* Convert a string to a wide string. */ | |
198 #if @GNULIB_MBSNRTOWCS@ | |
199 # if @REPLACE_MBSNRTOWCS@ | |
200 # undef mbsnrtowcs | |
201 # define mbsnrtowcs rpl_mbsnrtowcs | |
202 # endif | |
203 # if !@HAVE_MBSNRTOWCS@ || @REPLACE_MBSNRTOWCS@ | |
204 extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps); | |
205 # endif | |
206 #elif defined GNULIB_POSIXCHECK | |
207 # undef mbsnrtowcs | |
208 # define mbsnrtowcs(d,s,n,l,p) \ | |
209 (GL_LINK_WARNING ("mbsnrtowcs is unportable - " \ | |
210 "use gnulib module mbsnrtowcs for portability"), \ | |
211 mbsnrtowcs (d, s, n, l, p)) | |
212 #endif | |
213 | |
214 | |
215 /* Convert a wide character to a multibyte character. */ | |
216 #if @GNULIB_WCRTOMB@ | |
217 # if @REPLACE_WCRTOMB@ | |
218 # undef wcrtomb | |
219 # define wcrtomb rpl_wcrtomb | |
220 # endif | |
221 # if !@HAVE_WCRTOMB@ || @REPLACE_WCRTOMB@ | |
222 extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps); | |
223 # endif | |
224 #elif defined GNULIB_POSIXCHECK | |
225 # undef wcrtomb | |
226 # define wcrtomb(s,w,p) \ | |
227 (GL_LINK_WARNING ("wcrtomb is unportable - " \ | |
228 "use gnulib module wcrtomb for portability"), \ | |
229 wcrtomb (s, w, p)) | |
230 #endif | |
231 | |
232 | |
233 /* Convert a wide string to a string. */ | |
234 #if @GNULIB_WCSRTOMBS@ | |
235 # if @REPLACE_WCSRTOMBS@ | |
236 # undef wcsrtombs | |
237 # define wcsrtombs rpl_wcsrtombs | |
238 # endif | |
239 # if !@HAVE_WCSRTOMBS@ || @REPLACE_WCSRTOMBS@ | |
240 extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps); | |
241 # endif | |
242 #elif defined GNULIB_POSIXCHECK | |
243 # undef wcsrtombs | |
244 # define wcsrtombs(d,s,l,p) \ | |
245 (GL_LINK_WARNING ("wcsrtombs is unportable - " \ | |
246 "use gnulib module wcsrtombs for portability"), \ | |
247 wcsrtombs (d, s, l, p)) | |
248 #endif | |
249 | |
250 | |
251 /* Convert a wide string to a string. */ | |
252 #if @GNULIB_WCSNRTOMBS@ | |
253 # if !@HAVE_WCSNRTOMBS@ | |
254 extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps); | |
255 # endif | |
256 #elif defined GNULIB_POSIXCHECK | |
257 # undef wcsnrtombs | |
258 # define wcsnrtombs(d,s,n,l,p) \ | |
259 (GL_LINK_WARNING ("wcsnrtombs is unportable - " \ | |
260 "use gnulib module wcsnrtombs for portability"), \ | |
261 wcsnrtombs (d, s, n, l, p)) | |
262 #endif | |
263 | |
264 | |
265 /* Return the number of screen columns needed for WC. */ | |
266 #if @GNULIB_WCWIDTH@ | |
267 # if @REPLACE_WCWIDTH@ | |
268 # undef wcwidth | |
269 # define wcwidth rpl_wcwidth | |
270 extern int wcwidth (wchar_t); | |
271 # else | |
272 # if !defined wcwidth && !@HAVE_DECL_WCWIDTH@ | |
273 /* wcwidth exists but is not declared. */ | |
274 extern int wcwidth (int /* actually wchar_t */); | |
275 # endif | |
276 # endif | |
277 #elif defined GNULIB_POSIXCHECK | |
278 # undef wcwidth | |
279 # define wcwidth(w) \ | |
280 (GL_LINK_WARNING ("wcwidth is unportable - " \ | |
281 "use gnulib module wcwidth for portability"), \ | |
282 wcwidth (w)) | |
283 #endif | |
284 | |
285 | |
286 #ifdef __cplusplus | |
287 } | |
288 #endif | |
289 | |
290 #endif /* _GL_WCHAR_H */ | |
291 #endif /* _GL_WCHAR_H */ | |
292 #endif |