Code

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