Commit | Line | Data |
---|---|---|
8690e634 JK |
1 | /* A substitute for ISO C99 <wchar.h>, for platforms that have issues. |
2 | ||
5df4cba6 | 3 | Copyright (C) 2007-2020 Free Software Foundation, Inc. |
8690e634 JK |
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 | |
c0c3707f | 16 | along with this program; if not, see <https://www.gnu.org/licenses/>. */ |
8690e634 JK |
17 | |
18 | /* Written by Eric Blake. */ | |
19 | ||
20 | /* | |
21 | * ISO C 99 <wchar.h> for platforms that have issues. | |
c0c3707f | 22 | * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wchar.h.html> |
8690e634 JK |
23 | * |
24 | * For now, this just ensures proper prerequisite inclusion order and | |
25 | * the declaration of wcwidth(). | |
26 | */ | |
27 | ||
28 | #if __GNUC__ >= 3 | |
29 | @PRAGMA_SYSTEM_HEADER@ | |
30 | #endif | |
31 | @PRAGMA_COLUMNS@ | |
32 | ||
4a626d0a | 33 | #if (((defined __need_mbstate_t || defined __need_wint_t) \ |
c0c3707f | 34 | && !defined __MINGW32__) \ |
4a626d0a | 35 | || (defined __hpux \ |
5df4cba6 SM |
36 | && ((defined _INTTYPES_INCLUDED \ |
37 | && !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \ | |
4a626d0a | 38 | || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \ |
49e4877c | 39 | || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \ |
4a626d0a | 40 | || defined _GL_ALREADY_INCLUDING_WCHAR_H) |
8690e634 | 41 | /* Special invocation convention: |
4a626d0a | 42 | - Inside glibc and uClibc header files, but not MinGW. |
8690e634 JK |
43 | - On HP-UX 11.00 we have a sequence of nested includes |
44 | <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>, | |
45 | once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h> | |
46 | and once directly. In both situations 'wint_t' is not yet defined, | |
47 | therefore we cannot provide the function overrides; instead include only | |
48 | the system's <wchar.h>. | |
49e4877c PA |
49 | - With MinGW 3.22, when <string.h> includes <wchar.h>, only some part of |
50 | <wchar.h> is actually processed, and that doesn't include 'mbstate_t'. | |
8690e634 JK |
51 | - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and |
52 | the latter includes <wchar.h>. But here, we have no way to detect whether | |
53 | <wctype.h> is completely included or is still being included. */ | |
54 | ||
55 | #@INCLUDE_NEXT@ @NEXT_WCHAR_H@ | |
56 | ||
57 | #else | |
58 | /* Normal invocation convention. */ | |
59 | ||
60 | #ifndef _@GUARD_PREFIX@_WCHAR_H | |
61 | ||
62 | #define _GL_ALREADY_INCLUDING_WCHAR_H | |
63 | ||
64 | #if @HAVE_FEATURES_H@ | |
65 | # include <features.h> /* for __GLIBC__ */ | |
66 | #endif | |
67 | ||
68 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | |
69 | <wchar.h>. | |
70 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | |
71 | included before <wchar.h>. | |
72 | In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined | |
73 | by <stddef.h>. | |
74 | But avoid namespace pollution on glibc systems. */ | |
75 | #if !(defined __GLIBC__ && !defined __UCLIBC__) | |
76 | # include <stddef.h> | |
77 | #endif | |
78 | #ifndef __GLIBC__ | |
79 | # include <stdio.h> | |
80 | # include <time.h> | |
81 | #endif | |
82 | ||
83 | /* Include the original <wchar.h> if it exists. | |
84 | Some builds of uClibc lack it. */ | |
85 | /* The include_next requires a split double-inclusion guard. */ | |
86 | #if @HAVE_WCHAR_H@ | |
87 | # @INCLUDE_NEXT@ @NEXT_WCHAR_H@ | |
88 | #endif | |
89 | ||
90 | #undef _GL_ALREADY_INCLUDING_WCHAR_H | |
91 | ||
92 | #ifndef _@GUARD_PREFIX@_WCHAR_H | |
93 | #define _@GUARD_PREFIX@_WCHAR_H | |
94 | ||
95 | /* The __attribute__ feature is available in gcc versions 2.5 and later. | |
96 | The attribute __pure__ was added in gcc 2.96. */ | |
97 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) | |
98 | # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) | |
99 | #else | |
100 | # define _GL_ATTRIBUTE_PURE /* empty */ | |
101 | #endif | |
102 | ||
103 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ | |
104 | ||
105 | /* The definition of _GL_ARG_NONNULL is copied here. */ | |
106 | ||
107 | /* The definition of _GL_WARN_ON_USE is copied here. */ | |
108 | ||
109 | ||
110 | /* Define wint_t and WEOF. (Also done in wctype.in.h.) */ | |
111 | #if !@HAVE_WINT_T@ && !defined wint_t | |
112 | # define wint_t int | |
113 | # ifndef WEOF | |
114 | # define WEOF -1 | |
115 | # endif | |
116 | #else | |
c0c3707f CB |
117 | /* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or |
118 | <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that | |
119 | wint_t must be "unchanged by default argument promotions". Override it. */ | |
120 | # if @GNULIB_OVERRIDES_WINT_T@ | |
8690e634 | 121 | # if !GNULIB_defined_wint_t |
c0c3707f CB |
122 | # if @HAVE_CRTDEFS_H@ |
123 | # include <crtdefs.h> | |
124 | # else | |
125 | # include <stddef.h> | |
126 | # endif | |
8690e634 JK |
127 | typedef unsigned int rpl_wint_t; |
128 | # undef wint_t | |
129 | # define wint_t rpl_wint_t | |
130 | # define GNULIB_defined_wint_t 1 | |
131 | # endif | |
132 | # endif | |
133 | # ifndef WEOF | |
134 | # define WEOF ((wint_t) -1) | |
135 | # endif | |
136 | #endif | |
137 | ||
138 | ||
139 | /* Override mbstate_t if it is too small. | |
140 | On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for | |
c0c3707f CB |
141 | implementing mbrtowc for encodings like UTF-8. |
142 | On AIX and MSVC, mbrtowc needs to be overridden, but mbstate_t exists and is | |
143 | large enough and overriding it would cause problems in C++ mode. */ | |
5df4cba6 | 144 | #if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@ |
8690e634 | 145 | # if !GNULIB_defined_mbstate_t |
5df4cba6 | 146 | # if !(defined _AIX || defined _MSC_VER) |
8690e634 | 147 | typedef int rpl_mbstate_t; |
5df4cba6 SM |
148 | # undef mbstate_t |
149 | # define mbstate_t rpl_mbstate_t | |
150 | # endif | |
8690e634 JK |
151 | # define GNULIB_defined_mbstate_t 1 |
152 | # endif | |
153 | #endif | |
154 | ||
155 | ||
156 | /* Convert a single-byte character to a wide character. */ | |
157 | #if @GNULIB_BTOWC@ | |
158 | # if @REPLACE_BTOWC@ | |
159 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
160 | # undef btowc | |
161 | # define btowc rpl_btowc | |
162 | # endif | |
163 | _GL_FUNCDECL_RPL (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); | |
164 | _GL_CXXALIAS_RPL (btowc, wint_t, (int c)); | |
165 | # else | |
166 | # if !@HAVE_BTOWC@ | |
167 | _GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); | |
168 | # endif | |
c0c3707f CB |
169 | /* Need to cast, because on mingw, the return type is 'unsigned short'. */ |
170 | _GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c)); | |
8690e634 | 171 | # endif |
c0c3707f | 172 | # if __GLIBC__ >= 2 |
8690e634 | 173 | _GL_CXXALIASWARN (btowc); |
c0c3707f | 174 | # endif |
8690e634 JK |
175 | #elif defined GNULIB_POSIXCHECK |
176 | # undef btowc | |
177 | # if HAVE_RAW_DECL_BTOWC | |
178 | _GL_WARN_ON_USE (btowc, "btowc is unportable - " | |
179 | "use gnulib module btowc for portability"); | |
180 | # endif | |
181 | #endif | |
182 | ||
183 | ||
184 | /* Convert a wide character to a single-byte character. */ | |
185 | #if @GNULIB_WCTOB@ | |
186 | # if @REPLACE_WCTOB@ | |
187 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
188 | # undef wctob | |
189 | # define wctob rpl_wctob | |
190 | # endif | |
191 | _GL_FUNCDECL_RPL (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE); | |
192 | _GL_CXXALIAS_RPL (wctob, int, (wint_t wc)); | |
193 | # else | |
194 | # if !defined wctob && !@HAVE_DECL_WCTOB@ | |
195 | /* wctob is provided by gnulib, or wctob exists but is not declared. */ | |
196 | _GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE); | |
197 | # endif | |
198 | _GL_CXXALIAS_SYS (wctob, int, (wint_t wc)); | |
199 | # endif | |
c0c3707f | 200 | # if __GLIBC__ >= 2 |
8690e634 | 201 | _GL_CXXALIASWARN (wctob); |
c0c3707f | 202 | # endif |
8690e634 JK |
203 | #elif defined GNULIB_POSIXCHECK |
204 | # undef wctob | |
205 | # if HAVE_RAW_DECL_WCTOB | |
206 | _GL_WARN_ON_USE (wctob, "wctob is unportable - " | |
207 | "use gnulib module wctob for portability"); | |
208 | # endif | |
209 | #endif | |
210 | ||
211 | ||
212 | /* Test whether *PS is in the initial state. */ | |
213 | #if @GNULIB_MBSINIT@ | |
214 | # if @REPLACE_MBSINIT@ | |
215 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
216 | # undef mbsinit | |
217 | # define mbsinit rpl_mbsinit | |
218 | # endif | |
219 | _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps)); | |
220 | _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps)); | |
221 | # else | |
222 | # if !@HAVE_MBSINIT@ | |
223 | _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps)); | |
224 | # endif | |
225 | _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps)); | |
226 | # endif | |
c0c3707f | 227 | # if __GLIBC__ >= 2 |
8690e634 | 228 | _GL_CXXALIASWARN (mbsinit); |
c0c3707f | 229 | # endif |
8690e634 JK |
230 | #elif defined GNULIB_POSIXCHECK |
231 | # undef mbsinit | |
232 | # if HAVE_RAW_DECL_MBSINIT | |
233 | _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - " | |
234 | "use gnulib module mbsinit for portability"); | |
235 | # endif | |
236 | #endif | |
237 | ||
238 | ||
239 | /* Convert a multibyte character to a wide character. */ | |
240 | #if @GNULIB_MBRTOWC@ | |
241 | # if @REPLACE_MBRTOWC@ | |
242 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
243 | # undef mbrtowc | |
244 | # define mbrtowc rpl_mbrtowc | |
245 | # endif | |
246 | _GL_FUNCDECL_RPL (mbrtowc, size_t, | |
247 | (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); | |
248 | _GL_CXXALIAS_RPL (mbrtowc, size_t, | |
249 | (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); | |
250 | # else | |
251 | # if !@HAVE_MBRTOWC@ | |
252 | _GL_FUNCDECL_SYS (mbrtowc, size_t, | |
253 | (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); | |
254 | # endif | |
255 | _GL_CXXALIAS_SYS (mbrtowc, size_t, | |
256 | (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); | |
257 | # endif | |
c0c3707f | 258 | # if __GLIBC__ >= 2 |
8690e634 | 259 | _GL_CXXALIASWARN (mbrtowc); |
c0c3707f | 260 | # endif |
8690e634 JK |
261 | #elif defined GNULIB_POSIXCHECK |
262 | # undef mbrtowc | |
263 | # if HAVE_RAW_DECL_MBRTOWC | |
264 | _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - " | |
265 | "use gnulib module mbrtowc for portability"); | |
266 | # endif | |
267 | #endif | |
268 | ||
269 | ||
270 | /* Recognize a multibyte character. */ | |
271 | #if @GNULIB_MBRLEN@ | |
272 | # if @REPLACE_MBRLEN@ | |
273 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
274 | # undef mbrlen | |
275 | # define mbrlen rpl_mbrlen | |
276 | # endif | |
277 | _GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); | |
278 | _GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); | |
279 | # else | |
280 | # if !@HAVE_MBRLEN@ | |
281 | _GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); | |
282 | # endif | |
283 | _GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); | |
284 | # endif | |
c0c3707f | 285 | # if __GLIBC__ >= 2 |
8690e634 | 286 | _GL_CXXALIASWARN (mbrlen); |
c0c3707f | 287 | # endif |
8690e634 JK |
288 | #elif defined GNULIB_POSIXCHECK |
289 | # undef mbrlen | |
290 | # if HAVE_RAW_DECL_MBRLEN | |
291 | _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - " | |
292 | "use gnulib module mbrlen for portability"); | |
293 | # endif | |
294 | #endif | |
295 | ||
296 | ||
297 | /* Convert a string to a wide string. */ | |
298 | #if @GNULIB_MBSRTOWCS@ | |
299 | # if @REPLACE_MBSRTOWCS@ | |
300 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
301 | # undef mbsrtowcs | |
302 | # define mbsrtowcs rpl_mbsrtowcs | |
303 | # endif | |
304 | _GL_FUNCDECL_RPL (mbsrtowcs, size_t, | |
305 | (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) | |
306 | _GL_ARG_NONNULL ((2))); | |
307 | _GL_CXXALIAS_RPL (mbsrtowcs, size_t, | |
308 | (wchar_t *dest, const char **srcp, size_t len, | |
309 | mbstate_t *ps)); | |
310 | # else | |
311 | # if !@HAVE_MBSRTOWCS@ | |
312 | _GL_FUNCDECL_SYS (mbsrtowcs, size_t, | |
313 | (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) | |
314 | _GL_ARG_NONNULL ((2))); | |
315 | # endif | |
316 | _GL_CXXALIAS_SYS (mbsrtowcs, size_t, | |
317 | (wchar_t *dest, const char **srcp, size_t len, | |
318 | mbstate_t *ps)); | |
319 | # endif | |
c0c3707f | 320 | # if __GLIBC__ >= 2 |
8690e634 | 321 | _GL_CXXALIASWARN (mbsrtowcs); |
c0c3707f | 322 | # endif |
8690e634 JK |
323 | #elif defined GNULIB_POSIXCHECK |
324 | # undef mbsrtowcs | |
325 | # if HAVE_RAW_DECL_MBSRTOWCS | |
326 | _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - " | |
327 | "use gnulib module mbsrtowcs for portability"); | |
328 | # endif | |
329 | #endif | |
330 | ||
331 | ||
332 | /* Convert a string to a wide string. */ | |
333 | #if @GNULIB_MBSNRTOWCS@ | |
334 | # if @REPLACE_MBSNRTOWCS@ | |
335 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
336 | # undef mbsnrtowcs | |
337 | # define mbsnrtowcs rpl_mbsnrtowcs | |
338 | # endif | |
339 | _GL_FUNCDECL_RPL (mbsnrtowcs, size_t, | |
340 | (wchar_t *dest, const char **srcp, size_t srclen, size_t len, | |
341 | mbstate_t *ps) | |
342 | _GL_ARG_NONNULL ((2))); | |
343 | _GL_CXXALIAS_RPL (mbsnrtowcs, size_t, | |
344 | (wchar_t *dest, const char **srcp, size_t srclen, size_t len, | |
345 | mbstate_t *ps)); | |
346 | # else | |
347 | # if !@HAVE_MBSNRTOWCS@ | |
348 | _GL_FUNCDECL_SYS (mbsnrtowcs, size_t, | |
349 | (wchar_t *dest, const char **srcp, size_t srclen, size_t len, | |
350 | mbstate_t *ps) | |
351 | _GL_ARG_NONNULL ((2))); | |
352 | # endif | |
353 | _GL_CXXALIAS_SYS (mbsnrtowcs, size_t, | |
354 | (wchar_t *dest, const char **srcp, size_t srclen, size_t len, | |
355 | mbstate_t *ps)); | |
356 | # endif | |
357 | _GL_CXXALIASWARN (mbsnrtowcs); | |
358 | #elif defined GNULIB_POSIXCHECK | |
359 | # undef mbsnrtowcs | |
360 | # if HAVE_RAW_DECL_MBSNRTOWCS | |
361 | _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - " | |
362 | "use gnulib module mbsnrtowcs for portability"); | |
363 | # endif | |
364 | #endif | |
365 | ||
366 | ||
367 | /* Convert a wide character to a multibyte character. */ | |
368 | #if @GNULIB_WCRTOMB@ | |
369 | # if @REPLACE_WCRTOMB@ | |
370 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
371 | # undef wcrtomb | |
372 | # define wcrtomb rpl_wcrtomb | |
373 | # endif | |
374 | _GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); | |
375 | _GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); | |
376 | # else | |
377 | # if !@HAVE_WCRTOMB@ | |
378 | _GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); | |
379 | # endif | |
380 | _GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); | |
381 | # endif | |
c0c3707f | 382 | # if __GLIBC__ >= 2 |
8690e634 | 383 | _GL_CXXALIASWARN (wcrtomb); |
c0c3707f | 384 | # endif |
8690e634 JK |
385 | #elif defined GNULIB_POSIXCHECK |
386 | # undef wcrtomb | |
387 | # if HAVE_RAW_DECL_WCRTOMB | |
388 | _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - " | |
389 | "use gnulib module wcrtomb for portability"); | |
390 | # endif | |
391 | #endif | |
392 | ||
393 | ||
394 | /* Convert a wide string to a string. */ | |
395 | #if @GNULIB_WCSRTOMBS@ | |
396 | # if @REPLACE_WCSRTOMBS@ | |
397 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
398 | # undef wcsrtombs | |
399 | # define wcsrtombs rpl_wcsrtombs | |
400 | # endif | |
401 | _GL_FUNCDECL_RPL (wcsrtombs, size_t, | |
402 | (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) | |
403 | _GL_ARG_NONNULL ((2))); | |
404 | _GL_CXXALIAS_RPL (wcsrtombs, size_t, | |
405 | (char *dest, const wchar_t **srcp, size_t len, | |
406 | mbstate_t *ps)); | |
407 | # else | |
408 | # if !@HAVE_WCSRTOMBS@ | |
409 | _GL_FUNCDECL_SYS (wcsrtombs, size_t, | |
410 | (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) | |
411 | _GL_ARG_NONNULL ((2))); | |
412 | # endif | |
413 | _GL_CXXALIAS_SYS (wcsrtombs, size_t, | |
414 | (char *dest, const wchar_t **srcp, size_t len, | |
415 | mbstate_t *ps)); | |
416 | # endif | |
c0c3707f | 417 | # if __GLIBC__ >= 2 |
8690e634 | 418 | _GL_CXXALIASWARN (wcsrtombs); |
c0c3707f | 419 | # endif |
8690e634 JK |
420 | #elif defined GNULIB_POSIXCHECK |
421 | # undef wcsrtombs | |
422 | # if HAVE_RAW_DECL_WCSRTOMBS | |
423 | _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - " | |
424 | "use gnulib module wcsrtombs for portability"); | |
425 | # endif | |
426 | #endif | |
427 | ||
428 | ||
429 | /* Convert a wide string to a string. */ | |
430 | #if @GNULIB_WCSNRTOMBS@ | |
431 | # if @REPLACE_WCSNRTOMBS@ | |
432 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
433 | # undef wcsnrtombs | |
434 | # define wcsnrtombs rpl_wcsnrtombs | |
435 | # endif | |
436 | _GL_FUNCDECL_RPL (wcsnrtombs, size_t, | |
437 | (char *dest, const wchar_t **srcp, size_t srclen, size_t len, | |
438 | mbstate_t *ps) | |
439 | _GL_ARG_NONNULL ((2))); | |
440 | _GL_CXXALIAS_RPL (wcsnrtombs, size_t, | |
441 | (char *dest, const wchar_t **srcp, size_t srclen, size_t len, | |
442 | mbstate_t *ps)); | |
443 | # else | |
c0c3707f | 444 | # if !@HAVE_WCSNRTOMBS@ || (defined __cplusplus && defined __sun) |
8690e634 JK |
445 | _GL_FUNCDECL_SYS (wcsnrtombs, size_t, |
446 | (char *dest, const wchar_t **srcp, size_t srclen, size_t len, | |
447 | mbstate_t *ps) | |
448 | _GL_ARG_NONNULL ((2))); | |
449 | # endif | |
450 | _GL_CXXALIAS_SYS (wcsnrtombs, size_t, | |
451 | (char *dest, const wchar_t **srcp, size_t srclen, size_t len, | |
452 | mbstate_t *ps)); | |
453 | # endif | |
c0c3707f | 454 | # if __GLIBC__ >= 2 |
8690e634 | 455 | _GL_CXXALIASWARN (wcsnrtombs); |
c0c3707f | 456 | # endif |
8690e634 JK |
457 | #elif defined GNULIB_POSIXCHECK |
458 | # undef wcsnrtombs | |
459 | # if HAVE_RAW_DECL_WCSNRTOMBS | |
460 | _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - " | |
461 | "use gnulib module wcsnrtombs for portability"); | |
462 | # endif | |
463 | #endif | |
464 | ||
465 | ||
466 | /* Return the number of screen columns needed for WC. */ | |
467 | #if @GNULIB_WCWIDTH@ | |
468 | # if @REPLACE_WCWIDTH@ | |
469 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
470 | # undef wcwidth | |
471 | # define wcwidth rpl_wcwidth | |
472 | # endif | |
473 | _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE); | |
474 | _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t)); | |
475 | # else | |
476 | # if !@HAVE_DECL_WCWIDTH@ | |
477 | /* wcwidth exists but is not declared. */ | |
478 | _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE); | |
479 | # endif | |
480 | _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t)); | |
481 | # endif | |
c0c3707f | 482 | # if __GLIBC__ >= 2 |
8690e634 | 483 | _GL_CXXALIASWARN (wcwidth); |
c0c3707f | 484 | # endif |
8690e634 JK |
485 | #elif defined GNULIB_POSIXCHECK |
486 | # undef wcwidth | |
487 | # if HAVE_RAW_DECL_WCWIDTH | |
488 | _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - " | |
489 | "use gnulib module wcwidth for portability"); | |
490 | # endif | |
491 | #endif | |
492 | ||
493 | ||
494 | /* Search N wide characters of S for C. */ | |
495 | #if @GNULIB_WMEMCHR@ | |
496 | # if !@HAVE_WMEMCHR@ | |
497 | _GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n) | |
498 | _GL_ATTRIBUTE_PURE); | |
499 | # endif | |
500 | /* On some systems, this function is defined as an overloaded function: | |
501 | extern "C++" { | |
502 | const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t); | |
503 | wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t); | |
504 | } */ | |
505 | _GL_CXXALIAS_SYS_CAST2 (wmemchr, | |
506 | wchar_t *, (const wchar_t *, wchar_t, size_t), | |
507 | const wchar_t *, (const wchar_t *, wchar_t, size_t)); | |
508 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ | |
509 | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | |
510 | _GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); | |
511 | _GL_CXXALIASWARN1 (wmemchr, const wchar_t *, | |
512 | (const wchar_t *s, wchar_t c, size_t n)); | |
c0c3707f | 513 | # elif __GLIBC__ >= 2 |
8690e634 JK |
514 | _GL_CXXALIASWARN (wmemchr); |
515 | # endif | |
516 | #elif defined GNULIB_POSIXCHECK | |
517 | # undef wmemchr | |
518 | # if HAVE_RAW_DECL_WMEMCHR | |
519 | _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - " | |
520 | "use gnulib module wmemchr for portability"); | |
521 | # endif | |
522 | #endif | |
523 | ||
524 | ||
525 | /* Compare N wide characters of S1 and S2. */ | |
526 | #if @GNULIB_WMEMCMP@ | |
527 | # if !@HAVE_WMEMCMP@ | |
528 | _GL_FUNCDECL_SYS (wmemcmp, int, | |
529 | (const wchar_t *s1, const wchar_t *s2, size_t n) | |
530 | _GL_ATTRIBUTE_PURE); | |
531 | # endif | |
532 | _GL_CXXALIAS_SYS (wmemcmp, int, | |
533 | (const wchar_t *s1, const wchar_t *s2, size_t n)); | |
c0c3707f | 534 | # if __GLIBC__ >= 2 |
8690e634 | 535 | _GL_CXXALIASWARN (wmemcmp); |
c0c3707f | 536 | # endif |
8690e634 JK |
537 | #elif defined GNULIB_POSIXCHECK |
538 | # undef wmemcmp | |
539 | # if HAVE_RAW_DECL_WMEMCMP | |
540 | _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - " | |
541 | "use gnulib module wmemcmp for portability"); | |
542 | # endif | |
543 | #endif | |
544 | ||
545 | ||
546 | /* Copy N wide characters of SRC to DEST. */ | |
547 | #if @GNULIB_WMEMCPY@ | |
548 | # if !@HAVE_WMEMCPY@ | |
549 | _GL_FUNCDECL_SYS (wmemcpy, wchar_t *, | |
550 | (wchar_t *dest, const wchar_t *src, size_t n)); | |
551 | # endif | |
552 | _GL_CXXALIAS_SYS (wmemcpy, wchar_t *, | |
553 | (wchar_t *dest, const wchar_t *src, size_t n)); | |
c0c3707f | 554 | # if __GLIBC__ >= 2 |
8690e634 | 555 | _GL_CXXALIASWARN (wmemcpy); |
c0c3707f | 556 | # endif |
8690e634 JK |
557 | #elif defined GNULIB_POSIXCHECK |
558 | # undef wmemcpy | |
559 | # if HAVE_RAW_DECL_WMEMCPY | |
560 | _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - " | |
561 | "use gnulib module wmemcpy for portability"); | |
562 | # endif | |
563 | #endif | |
564 | ||
565 | ||
566 | /* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for | |
567 | overlapping memory areas. */ | |
568 | #if @GNULIB_WMEMMOVE@ | |
569 | # if !@HAVE_WMEMMOVE@ | |
570 | _GL_FUNCDECL_SYS (wmemmove, wchar_t *, | |
571 | (wchar_t *dest, const wchar_t *src, size_t n)); | |
572 | # endif | |
573 | _GL_CXXALIAS_SYS (wmemmove, wchar_t *, | |
574 | (wchar_t *dest, const wchar_t *src, size_t n)); | |
c0c3707f | 575 | # if __GLIBC__ >= 2 |
8690e634 | 576 | _GL_CXXALIASWARN (wmemmove); |
c0c3707f | 577 | # endif |
8690e634 JK |
578 | #elif defined GNULIB_POSIXCHECK |
579 | # undef wmemmove | |
580 | # if HAVE_RAW_DECL_WMEMMOVE | |
581 | _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - " | |
582 | "use gnulib module wmemmove for portability"); | |
583 | # endif | |
584 | #endif | |
585 | ||
586 | ||
587 | /* Set N wide characters of S to C. */ | |
588 | #if @GNULIB_WMEMSET@ | |
589 | # if !@HAVE_WMEMSET@ | |
590 | _GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); | |
591 | # endif | |
592 | _GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); | |
c0c3707f | 593 | # if __GLIBC__ >= 2 |
8690e634 | 594 | _GL_CXXALIASWARN (wmemset); |
c0c3707f | 595 | # endif |
8690e634 JK |
596 | #elif defined GNULIB_POSIXCHECK |
597 | # undef wmemset | |
598 | # if HAVE_RAW_DECL_WMEMSET | |
599 | _GL_WARN_ON_USE (wmemset, "wmemset is unportable - " | |
600 | "use gnulib module wmemset for portability"); | |
601 | # endif | |
602 | #endif | |
603 | ||
604 | ||
605 | /* Return the number of wide characters in S. */ | |
606 | #if @GNULIB_WCSLEN@ | |
607 | # if !@HAVE_WCSLEN@ | |
608 | _GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE); | |
609 | # endif | |
610 | _GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s)); | |
c0c3707f | 611 | # if __GLIBC__ >= 2 |
8690e634 | 612 | _GL_CXXALIASWARN (wcslen); |
c0c3707f | 613 | # endif |
8690e634 JK |
614 | #elif defined GNULIB_POSIXCHECK |
615 | # undef wcslen | |
616 | # if HAVE_RAW_DECL_WCSLEN | |
617 | _GL_WARN_ON_USE (wcslen, "wcslen is unportable - " | |
618 | "use gnulib module wcslen for portability"); | |
619 | # endif | |
620 | #endif | |
621 | ||
622 | ||
623 | /* Return the number of wide characters in S, but at most MAXLEN. */ | |
624 | #if @GNULIB_WCSNLEN@ | |
625 | # if !@HAVE_WCSNLEN@ | |
626 | _GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen) | |
627 | _GL_ATTRIBUTE_PURE); | |
628 | # endif | |
629 | _GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)); | |
630 | _GL_CXXALIASWARN (wcsnlen); | |
631 | #elif defined GNULIB_POSIXCHECK | |
632 | # undef wcsnlen | |
633 | # if HAVE_RAW_DECL_WCSNLEN | |
634 | _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - " | |
635 | "use gnulib module wcsnlen for portability"); | |
636 | # endif | |
637 | #endif | |
638 | ||
639 | ||
640 | /* Copy SRC to DEST. */ | |
641 | #if @GNULIB_WCSCPY@ | |
642 | # if !@HAVE_WCSCPY@ | |
643 | _GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); | |
644 | # endif | |
645 | _GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); | |
c0c3707f | 646 | # if __GLIBC__ >= 2 |
8690e634 | 647 | _GL_CXXALIASWARN (wcscpy); |
c0c3707f | 648 | # endif |
8690e634 JK |
649 | #elif defined GNULIB_POSIXCHECK |
650 | # undef wcscpy | |
651 | # if HAVE_RAW_DECL_WCSCPY | |
652 | _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - " | |
653 | "use gnulib module wcscpy for portability"); | |
654 | # endif | |
655 | #endif | |
656 | ||
657 | ||
658 | /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */ | |
659 | #if @GNULIB_WCPCPY@ | |
660 | # if !@HAVE_WCPCPY@ | |
661 | _GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); | |
662 | # endif | |
663 | _GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); | |
664 | _GL_CXXALIASWARN (wcpcpy); | |
665 | #elif defined GNULIB_POSIXCHECK | |
666 | # undef wcpcpy | |
667 | # if HAVE_RAW_DECL_WCPCPY | |
668 | _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - " | |
669 | "use gnulib module wcpcpy for portability"); | |
670 | # endif | |
671 | #endif | |
672 | ||
673 | ||
674 | /* Copy no more than N wide characters of SRC to DEST. */ | |
675 | #if @GNULIB_WCSNCPY@ | |
676 | # if !@HAVE_WCSNCPY@ | |
677 | _GL_FUNCDECL_SYS (wcsncpy, wchar_t *, | |
678 | (wchar_t *dest, const wchar_t *src, size_t n)); | |
679 | # endif | |
680 | _GL_CXXALIAS_SYS (wcsncpy, wchar_t *, | |
681 | (wchar_t *dest, const wchar_t *src, size_t n)); | |
c0c3707f | 682 | # if __GLIBC__ >= 2 |
8690e634 | 683 | _GL_CXXALIASWARN (wcsncpy); |
c0c3707f | 684 | # endif |
8690e634 JK |
685 | #elif defined GNULIB_POSIXCHECK |
686 | # undef wcsncpy | |
687 | # if HAVE_RAW_DECL_WCSNCPY | |
688 | _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - " | |
689 | "use gnulib module wcsncpy for portability"); | |
690 | # endif | |
691 | #endif | |
692 | ||
693 | ||
694 | /* Copy no more than N characters of SRC to DEST, returning the address of | |
695 | the last character written into DEST. */ | |
696 | #if @GNULIB_WCPNCPY@ | |
697 | # if !@HAVE_WCPNCPY@ | |
698 | _GL_FUNCDECL_SYS (wcpncpy, wchar_t *, | |
699 | (wchar_t *dest, const wchar_t *src, size_t n)); | |
700 | # endif | |
701 | _GL_CXXALIAS_SYS (wcpncpy, wchar_t *, | |
702 | (wchar_t *dest, const wchar_t *src, size_t n)); | |
703 | _GL_CXXALIASWARN (wcpncpy); | |
704 | #elif defined GNULIB_POSIXCHECK | |
705 | # undef wcpncpy | |
706 | # if HAVE_RAW_DECL_WCPNCPY | |
707 | _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - " | |
708 | "use gnulib module wcpncpy for portability"); | |
709 | # endif | |
710 | #endif | |
711 | ||
712 | ||
713 | /* Append SRC onto DEST. */ | |
714 | #if @GNULIB_WCSCAT@ | |
715 | # if !@HAVE_WCSCAT@ | |
716 | _GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src)); | |
717 | # endif | |
718 | _GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src)); | |
c0c3707f | 719 | # if __GLIBC__ >= 2 |
8690e634 | 720 | _GL_CXXALIASWARN (wcscat); |
c0c3707f | 721 | # endif |
8690e634 JK |
722 | #elif defined GNULIB_POSIXCHECK |
723 | # undef wcscat | |
724 | # if HAVE_RAW_DECL_WCSCAT | |
725 | _GL_WARN_ON_USE (wcscat, "wcscat is unportable - " | |
726 | "use gnulib module wcscat for portability"); | |
727 | # endif | |
728 | #endif | |
729 | ||
730 | ||
731 | /* Append no more than N wide characters of SRC onto DEST. */ | |
732 | #if @GNULIB_WCSNCAT@ | |
733 | # if !@HAVE_WCSNCAT@ | |
734 | _GL_FUNCDECL_SYS (wcsncat, wchar_t *, | |
735 | (wchar_t *dest, const wchar_t *src, size_t n)); | |
736 | # endif | |
737 | _GL_CXXALIAS_SYS (wcsncat, wchar_t *, | |
738 | (wchar_t *dest, const wchar_t *src, size_t n)); | |
c0c3707f | 739 | # if __GLIBC__ >= 2 |
8690e634 | 740 | _GL_CXXALIASWARN (wcsncat); |
c0c3707f | 741 | # endif |
8690e634 JK |
742 | #elif defined GNULIB_POSIXCHECK |
743 | # undef wcsncat | |
744 | # if HAVE_RAW_DECL_WCSNCAT | |
745 | _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - " | |
746 | "use gnulib module wcsncat for portability"); | |
747 | # endif | |
748 | #endif | |
749 | ||
750 | ||
751 | /* Compare S1 and S2. */ | |
752 | #if @GNULIB_WCSCMP@ | |
753 | # if !@HAVE_WCSCMP@ | |
754 | _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2) | |
755 | _GL_ATTRIBUTE_PURE); | |
756 | # endif | |
757 | _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); | |
c0c3707f | 758 | # if __GLIBC__ >= 2 |
8690e634 | 759 | _GL_CXXALIASWARN (wcscmp); |
c0c3707f | 760 | # endif |
8690e634 JK |
761 | #elif defined GNULIB_POSIXCHECK |
762 | # undef wcscmp | |
763 | # if HAVE_RAW_DECL_WCSCMP | |
764 | _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - " | |
765 | "use gnulib module wcscmp for portability"); | |
766 | # endif | |
767 | #endif | |
768 | ||
769 | ||
770 | /* Compare no more than N wide characters of S1 and S2. */ | |
771 | #if @GNULIB_WCSNCMP@ | |
772 | # if !@HAVE_WCSNCMP@ | |
773 | _GL_FUNCDECL_SYS (wcsncmp, int, | |
774 | (const wchar_t *s1, const wchar_t *s2, size_t n) | |
775 | _GL_ATTRIBUTE_PURE); | |
776 | # endif | |
777 | _GL_CXXALIAS_SYS (wcsncmp, int, | |
778 | (const wchar_t *s1, const wchar_t *s2, size_t n)); | |
c0c3707f | 779 | # if __GLIBC__ >= 2 |
8690e634 | 780 | _GL_CXXALIASWARN (wcsncmp); |
c0c3707f | 781 | # endif |
8690e634 JK |
782 | #elif defined GNULIB_POSIXCHECK |
783 | # undef wcsncmp | |
784 | # if HAVE_RAW_DECL_WCSNCMP | |
785 | _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - " | |
786 | "use gnulib module wcsncmp for portability"); | |
787 | # endif | |
788 | #endif | |
789 | ||
790 | ||
791 | /* Compare S1 and S2, ignoring case. */ | |
792 | #if @GNULIB_WCSCASECMP@ | |
793 | # if !@HAVE_WCSCASECMP@ | |
794 | _GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2) | |
795 | _GL_ATTRIBUTE_PURE); | |
796 | # endif | |
797 | _GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)); | |
798 | _GL_CXXALIASWARN (wcscasecmp); | |
799 | #elif defined GNULIB_POSIXCHECK | |
800 | # undef wcscasecmp | |
801 | # if HAVE_RAW_DECL_WCSCASECMP | |
802 | _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - " | |
803 | "use gnulib module wcscasecmp for portability"); | |
804 | # endif | |
805 | #endif | |
806 | ||
807 | ||
808 | /* Compare no more than N chars of S1 and S2, ignoring case. */ | |
809 | #if @GNULIB_WCSNCASECMP@ | |
810 | # if !@HAVE_WCSNCASECMP@ | |
811 | _GL_FUNCDECL_SYS (wcsncasecmp, int, | |
812 | (const wchar_t *s1, const wchar_t *s2, size_t n) | |
813 | _GL_ATTRIBUTE_PURE); | |
814 | # endif | |
815 | _GL_CXXALIAS_SYS (wcsncasecmp, int, | |
816 | (const wchar_t *s1, const wchar_t *s2, size_t n)); | |
817 | _GL_CXXALIASWARN (wcsncasecmp); | |
818 | #elif defined GNULIB_POSIXCHECK | |
819 | # undef wcsncasecmp | |
820 | # if HAVE_RAW_DECL_WCSNCASECMP | |
821 | _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - " | |
822 | "use gnulib module wcsncasecmp for portability"); | |
823 | # endif | |
824 | #endif | |
825 | ||
826 | ||
827 | /* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE | |
828 | category of the current locale. */ | |
829 | #if @GNULIB_WCSCOLL@ | |
830 | # if !@HAVE_WCSCOLL@ | |
831 | _GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); | |
832 | # endif | |
833 | _GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); | |
c0c3707f | 834 | # if __GLIBC__ >= 2 |
8690e634 | 835 | _GL_CXXALIASWARN (wcscoll); |
c0c3707f | 836 | # endif |
8690e634 JK |
837 | #elif defined GNULIB_POSIXCHECK |
838 | # undef wcscoll | |
839 | # if HAVE_RAW_DECL_WCSCOLL | |
840 | _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - " | |
841 | "use gnulib module wcscoll for portability"); | |
842 | # endif | |
843 | #endif | |
844 | ||
845 | ||
846 | /* Transform S2 into array pointed to by S1 such that if wcscmp is applied | |
847 | to two transformed strings the result is the as applying 'wcscoll' to the | |
848 | original strings. */ | |
849 | #if @GNULIB_WCSXFRM@ | |
850 | # if !@HAVE_WCSXFRM@ | |
851 | _GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n)); | |
852 | # endif | |
853 | _GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n)); | |
c0c3707f | 854 | # if __GLIBC__ >= 2 |
8690e634 | 855 | _GL_CXXALIASWARN (wcsxfrm); |
c0c3707f | 856 | # endif |
8690e634 JK |
857 | #elif defined GNULIB_POSIXCHECK |
858 | # undef wcsxfrm | |
859 | # if HAVE_RAW_DECL_WCSXFRM | |
860 | _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - " | |
861 | "use gnulib module wcsxfrm for portability"); | |
862 | # endif | |
863 | #endif | |
864 | ||
865 | ||
866 | /* Duplicate S, returning an identical malloc'd string. */ | |
867 | #if @GNULIB_WCSDUP@ | |
868 | # if !@HAVE_WCSDUP@ | |
869 | _GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s)); | |
870 | # endif | |
871 | _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); | |
872 | _GL_CXXALIASWARN (wcsdup); | |
873 | #elif defined GNULIB_POSIXCHECK | |
874 | # undef wcsdup | |
875 | # if HAVE_RAW_DECL_WCSDUP | |
876 | _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - " | |
877 | "use gnulib module wcsdup for portability"); | |
878 | # endif | |
879 | #endif | |
880 | ||
881 | ||
882 | /* Find the first occurrence of WC in WCS. */ | |
883 | #if @GNULIB_WCSCHR@ | |
884 | # if !@HAVE_WCSCHR@ | |
885 | _GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc) | |
886 | _GL_ATTRIBUTE_PURE); | |
887 | # endif | |
888 | /* On some systems, this function is defined as an overloaded function: | |
889 | extern "C++" { | |
890 | const wchar_t * std::wcschr (const wchar_t *, wchar_t); | |
891 | wchar_t * std::wcschr (wchar_t *, wchar_t); | |
892 | } */ | |
893 | _GL_CXXALIAS_SYS_CAST2 (wcschr, | |
894 | wchar_t *, (const wchar_t *, wchar_t), | |
895 | const wchar_t *, (const wchar_t *, wchar_t)); | |
896 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ | |
897 | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | |
898 | _GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc)); | |
899 | _GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); | |
c0c3707f | 900 | # elif __GLIBC__ >= 2 |
8690e634 JK |
901 | _GL_CXXALIASWARN (wcschr); |
902 | # endif | |
903 | #elif defined GNULIB_POSIXCHECK | |
904 | # undef wcschr | |
905 | # if HAVE_RAW_DECL_WCSCHR | |
906 | _GL_WARN_ON_USE (wcschr, "wcschr is unportable - " | |
907 | "use gnulib module wcschr for portability"); | |
908 | # endif | |
909 | #endif | |
910 | ||
911 | ||
912 | /* Find the last occurrence of WC in WCS. */ | |
913 | #if @GNULIB_WCSRCHR@ | |
914 | # if !@HAVE_WCSRCHR@ | |
915 | _GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc) | |
916 | _GL_ATTRIBUTE_PURE); | |
917 | # endif | |
918 | /* On some systems, this function is defined as an overloaded function: | |
919 | extern "C++" { | |
920 | const wchar_t * std::wcsrchr (const wchar_t *, wchar_t); | |
921 | wchar_t * std::wcsrchr (wchar_t *, wchar_t); | |
922 | } */ | |
923 | _GL_CXXALIAS_SYS_CAST2 (wcsrchr, | |
924 | wchar_t *, (const wchar_t *, wchar_t), | |
925 | const wchar_t *, (const wchar_t *, wchar_t)); | |
926 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ | |
927 | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | |
928 | _GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc)); | |
929 | _GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); | |
c0c3707f | 930 | # elif __GLIBC__ >= 2 |
8690e634 JK |
931 | _GL_CXXALIASWARN (wcsrchr); |
932 | # endif | |
933 | #elif defined GNULIB_POSIXCHECK | |
934 | # undef wcsrchr | |
935 | # if HAVE_RAW_DECL_WCSRCHR | |
936 | _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - " | |
937 | "use gnulib module wcsrchr for portability"); | |
938 | # endif | |
939 | #endif | |
940 | ||
941 | ||
942 | /* Return the length of the initial segmet of WCS which consists entirely | |
943 | of wide characters not in REJECT. */ | |
944 | #if @GNULIB_WCSCSPN@ | |
945 | # if !@HAVE_WCSCSPN@ | |
946 | _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject) | |
947 | _GL_ATTRIBUTE_PURE); | |
948 | # endif | |
949 | _GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)); | |
c0c3707f | 950 | # if __GLIBC__ >= 2 |
8690e634 | 951 | _GL_CXXALIASWARN (wcscspn); |
c0c3707f | 952 | # endif |
8690e634 JK |
953 | #elif defined GNULIB_POSIXCHECK |
954 | # undef wcscspn | |
955 | # if HAVE_RAW_DECL_WCSCSPN | |
956 | _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - " | |
957 | "use gnulib module wcscspn for portability"); | |
958 | # endif | |
959 | #endif | |
960 | ||
961 | ||
962 | /* Return the length of the initial segmet of WCS which consists entirely | |
963 | of wide characters in ACCEPT. */ | |
964 | #if @GNULIB_WCSSPN@ | |
965 | # if !@HAVE_WCSSPN@ | |
966 | _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept) | |
967 | _GL_ATTRIBUTE_PURE); | |
968 | # endif | |
969 | _GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)); | |
c0c3707f | 970 | # if __GLIBC__ >= 2 |
8690e634 | 971 | _GL_CXXALIASWARN (wcsspn); |
c0c3707f | 972 | # endif |
8690e634 JK |
973 | #elif defined GNULIB_POSIXCHECK |
974 | # undef wcsspn | |
975 | # if HAVE_RAW_DECL_WCSSPN | |
976 | _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - " | |
977 | "use gnulib module wcsspn for portability"); | |
978 | # endif | |
979 | #endif | |
980 | ||
981 | ||
982 | /* Find the first occurrence in WCS of any character in ACCEPT. */ | |
983 | #if @GNULIB_WCSPBRK@ | |
984 | # if !@HAVE_WCSPBRK@ | |
985 | _GL_FUNCDECL_SYS (wcspbrk, wchar_t *, | |
986 | (const wchar_t *wcs, const wchar_t *accept) | |
987 | _GL_ATTRIBUTE_PURE); | |
988 | # endif | |
989 | /* On some systems, this function is defined as an overloaded function: | |
990 | extern "C++" { | |
991 | const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *); | |
992 | wchar_t * std::wcspbrk (wchar_t *, const wchar_t *); | |
993 | } */ | |
994 | _GL_CXXALIAS_SYS_CAST2 (wcspbrk, | |
995 | wchar_t *, (const wchar_t *, const wchar_t *), | |
996 | const wchar_t *, (const wchar_t *, const wchar_t *)); | |
997 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ | |
998 | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | |
999 | _GL_CXXALIASWARN1 (wcspbrk, wchar_t *, | |
1000 | (wchar_t *wcs, const wchar_t *accept)); | |
1001 | _GL_CXXALIASWARN1 (wcspbrk, const wchar_t *, | |
1002 | (const wchar_t *wcs, const wchar_t *accept)); | |
c0c3707f | 1003 | # elif __GLIBC__ >= 2 |
8690e634 JK |
1004 | _GL_CXXALIASWARN (wcspbrk); |
1005 | # endif | |
1006 | #elif defined GNULIB_POSIXCHECK | |
1007 | # undef wcspbrk | |
1008 | # if HAVE_RAW_DECL_WCSPBRK | |
1009 | _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - " | |
1010 | "use gnulib module wcspbrk for portability"); | |
1011 | # endif | |
1012 | #endif | |
1013 | ||
1014 | ||
1015 | /* Find the first occurrence of NEEDLE in HAYSTACK. */ | |
1016 | #if @GNULIB_WCSSTR@ | |
1017 | # if !@HAVE_WCSSTR@ | |
1018 | _GL_FUNCDECL_SYS (wcsstr, wchar_t *, | |
1019 | (const wchar_t *haystack, const wchar_t *needle) | |
1020 | _GL_ATTRIBUTE_PURE); | |
1021 | # endif | |
1022 | /* On some systems, this function is defined as an overloaded function: | |
1023 | extern "C++" { | |
1024 | const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *); | |
1025 | wchar_t * std::wcsstr (wchar_t *, const wchar_t *); | |
1026 | } */ | |
1027 | _GL_CXXALIAS_SYS_CAST2 (wcsstr, | |
1028 | wchar_t *, (const wchar_t *, const wchar_t *), | |
1029 | const wchar_t *, (const wchar_t *, const wchar_t *)); | |
1030 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ | |
1031 | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | |
1032 | _GL_CXXALIASWARN1 (wcsstr, wchar_t *, | |
1033 | (wchar_t *haystack, const wchar_t *needle)); | |
1034 | _GL_CXXALIASWARN1 (wcsstr, const wchar_t *, | |
1035 | (const wchar_t *haystack, const wchar_t *needle)); | |
c0c3707f | 1036 | # elif __GLIBC__ >= 2 |
8690e634 JK |
1037 | _GL_CXXALIASWARN (wcsstr); |
1038 | # endif | |
1039 | #elif defined GNULIB_POSIXCHECK | |
1040 | # undef wcsstr | |
1041 | # if HAVE_RAW_DECL_WCSSTR | |
1042 | _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - " | |
1043 | "use gnulib module wcsstr for portability"); | |
1044 | # endif | |
1045 | #endif | |
1046 | ||
1047 | ||
1048 | /* Divide WCS into tokens separated by characters in DELIM. */ | |
1049 | #if @GNULIB_WCSTOK@ | |
c0c3707f CB |
1050 | # if @REPLACE_WCSTOK@ |
1051 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
1052 | # undef wcstok | |
1053 | # define wcstok rpl_wcstok | |
1054 | # endif | |
1055 | _GL_FUNCDECL_RPL (wcstok, wchar_t *, | |
1056 | (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)); | |
1057 | _GL_CXXALIAS_RPL (wcstok, wchar_t *, | |
1058 | (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)); | |
1059 | # else | |
1060 | # if !@HAVE_WCSTOK@ | |
8690e634 JK |
1061 | _GL_FUNCDECL_SYS (wcstok, wchar_t *, |
1062 | (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)); | |
c0c3707f | 1063 | # endif |
8690e634 JK |
1064 | _GL_CXXALIAS_SYS (wcstok, wchar_t *, |
1065 | (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)); | |
c0c3707f CB |
1066 | # endif |
1067 | # if __GLIBC__ >= 2 | |
8690e634 | 1068 | _GL_CXXALIASWARN (wcstok); |
c0c3707f | 1069 | # endif |
8690e634 JK |
1070 | #elif defined GNULIB_POSIXCHECK |
1071 | # undef wcstok | |
1072 | # if HAVE_RAW_DECL_WCSTOK | |
1073 | _GL_WARN_ON_USE (wcstok, "wcstok is unportable - " | |
1074 | "use gnulib module wcstok for portability"); | |
1075 | # endif | |
1076 | #endif | |
1077 | ||
1078 | ||
1079 | /* Determine number of column positions required for first N wide | |
1080 | characters (or fewer if S ends before this) in S. */ | |
1081 | #if @GNULIB_WCSWIDTH@ | |
1082 | # if @REPLACE_WCSWIDTH@ | |
1083 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
1084 | # undef wcswidth | |
1085 | # define wcswidth rpl_wcswidth | |
1086 | # endif | |
1087 | _GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n) | |
1088 | _GL_ATTRIBUTE_PURE); | |
1089 | _GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n)); | |
1090 | # else | |
1091 | # if !@HAVE_WCSWIDTH@ | |
1092 | _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n) | |
1093 | _GL_ATTRIBUTE_PURE); | |
1094 | # endif | |
1095 | _GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n)); | |
1096 | # endif | |
c0c3707f | 1097 | # if __GLIBC__ >= 2 |
8690e634 | 1098 | _GL_CXXALIASWARN (wcswidth); |
c0c3707f | 1099 | # endif |
8690e634 JK |
1100 | #elif defined GNULIB_POSIXCHECK |
1101 | # undef wcswidth | |
1102 | # if HAVE_RAW_DECL_WCSWIDTH | |
1103 | _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - " | |
1104 | "use gnulib module wcswidth for portability"); | |
1105 | # endif | |
1106 | #endif | |
1107 | ||
1108 | ||
c0c3707f CB |
1109 | /* Convert *TP to a date and time wide string. See |
1110 | <https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */ | |
1111 | #if @GNULIB_WCSFTIME@ | |
1112 | # if @REPLACE_WCSFTIME@ | |
1113 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
1114 | # undef wcsftime | |
1115 | # define wcsftime rpl_wcsftime | |
1116 | # endif | |
1117 | _GL_FUNCDECL_RPL (wcsftime, size_t, (wchar_t *__buf, size_t __bufsize, | |
1118 | const wchar_t *__fmt, const struct tm *__tp) | |
1119 | _GL_ARG_NONNULL ((1, 3, 4))); | |
1120 | _GL_CXXALIAS_RPL (wcsftime, size_t, (wchar_t *__buf, size_t __bufsize, | |
1121 | const wchar_t *__fmt, const struct tm *__tp)); | |
1122 | # else | |
1123 | # if !@HAVE_WCSFTIME@ | |
1124 | _GL_FUNCDECL_SYS (wcsftime, size_t, (wchar_t *__buf, size_t __bufsize, | |
1125 | const wchar_t *__fmt, const struct tm *__tp) | |
1126 | _GL_ARG_NONNULL ((1, 3, 4))); | |
1127 | # endif | |
1128 | _GL_CXXALIAS_SYS (wcsftime, size_t, (wchar_t *__buf, size_t __bufsize, | |
1129 | const wchar_t *__fmt, const struct tm *__tp)); | |
1130 | # endif | |
1131 | # if __GLIBC__ >= 2 | |
1132 | _GL_CXXALIASWARN (wcsftime); | |
1133 | # endif | |
1134 | #elif defined GNULIB_POSIXCHECK | |
1135 | # undef wcsftime | |
1136 | # if HAVE_RAW_DECL_WCSFTIME | |
1137 | _GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - " | |
1138 | "use gnulib module wcsftime for portability"); | |
1139 | # endif | |
1140 | #endif | |
1141 | ||
1142 | ||
8690e634 JK |
1143 | #endif /* _@GUARD_PREFIX@_WCHAR_H */ |
1144 | #endif /* _@GUARD_PREFIX@_WCHAR_H */ | |
1145 | #endif |