1 | /* Copyright (C) 1995-2015 Free Software Foundation, Inc. |
2 | This file is part of the GNU C Library. |
3 | |
4 | The GNU C Library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2.1 of the License, or (at your option) any later version. |
8 | |
9 | The GNU C Library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Lesser General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Lesser General Public |
15 | License along with the GNU C Library; if not, see |
16 | <http://www.gnu.org/licenses/>. */ |
17 | |
18 | /* |
19 | * ISO C99 Standard: 7.24 |
20 | * Extended multibyte and wide character utilities <wchar.h> |
21 | */ |
22 | |
23 | #ifndef _WCHAR_H |
24 | |
25 | #if !defined __need_mbstate_t && !defined __need_wint_t |
26 | # define _WCHAR_H 1 |
27 | # include <features.h> |
28 | #endif |
29 | |
30 | #ifdef _WCHAR_H |
31 | /* Get FILE definition. */ |
32 | # define __need___FILE |
33 | # if defined __USE_UNIX98 || defined __USE_XOPEN2K |
34 | # define __need_FILE |
35 | # endif |
36 | # include <stdio.h> |
37 | /* Get va_list definition. */ |
38 | # define __need___va_list |
39 | # include <stdarg.h> |
40 | |
41 | # include <bits/wchar.h> |
42 | |
43 | /* Get size_t, wchar_t, wint_t and NULL from <stddef.h>. */ |
44 | # define __need_size_t |
45 | # define __need_wchar_t |
46 | # define __need_NULL |
47 | #endif |
48 | #if defined _WCHAR_H || defined __need_wint_t || !defined __WINT_TYPE__ |
49 | # undef __need_wint_t |
50 | # define __need_wint_t |
51 | # include <stddef.h> |
52 | |
53 | /* We try to get wint_t from <stddef.h>, but not all GCC versions define it |
54 | there. So define it ourselves if it remains undefined. */ |
55 | # ifndef _WINT_T |
56 | /* Integral type unchanged by default argument promotions that can |
57 | hold any value corresponding to members of the extended character |
58 | set, as well as at least one value that does not correspond to any |
59 | member of the extended character set. */ |
60 | # define _WINT_T |
61 | typedef unsigned int wint_t; |
62 | # else |
63 | /* Work around problems with the <stddef.h> file which doesn't put |
64 | wint_t in the std namespace. */ |
65 | # if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES \ |
66 | && defined __WINT_TYPE__ |
67 | __BEGIN_NAMESPACE_STD |
68 | typedef __WINT_TYPE__ wint_t; |
69 | __END_NAMESPACE_STD |
70 | # endif |
71 | # endif |
72 | |
73 | /* Tell the caller that we provide correct C++ prototypes. */ |
74 | # if defined __cplusplus && __GNUC_PREREQ (4, 4) |
75 | # define __CORRECT_ISO_CPP_WCHAR_H_PROTO |
76 | # endif |
77 | #endif |
78 | |
79 | #if (defined _WCHAR_H || defined __need_mbstate_t) && !defined ____mbstate_t_defined |
80 | # define ____mbstate_t_defined 1 |
81 | /* Conversion state information. */ |
82 | typedef struct |
83 | { |
84 | int __count; |
85 | union |
86 | { |
87 | # ifdef __WINT_TYPE__ |
88 | __WINT_TYPE__ __wch; |
89 | # else |
90 | wint_t __wch; |
91 | # endif |
92 | char __wchb[4]; |
93 | } __value; /* Value so far. */ |
94 | } __mbstate_t; |
95 | #endif |
96 | #undef __need_mbstate_t |
97 | |
98 | |
99 | /* The rest of the file is only used if used if __need_mbstate_t is not |
100 | defined. */ |
101 | #ifdef _WCHAR_H |
102 | |
103 | # ifndef __mbstate_t_defined |
104 | __BEGIN_NAMESPACE_C99 |
105 | /* Public type. */ |
106 | typedef __mbstate_t mbstate_t; |
107 | __END_NAMESPACE_C99 |
108 | # define __mbstate_t_defined 1 |
109 | # endif |
110 | |
111 | #ifdef __USE_GNU |
112 | __USING_NAMESPACE_C99(mbstate_t) |
113 | #endif |
114 | |
115 | #ifndef WCHAR_MIN |
116 | /* These constants might also be defined in <inttypes.h>. */ |
117 | # define WCHAR_MIN __WCHAR_MIN |
118 | # define WCHAR_MAX __WCHAR_MAX |
119 | #endif |
120 | |
121 | #ifndef WEOF |
122 | # define WEOF (0xffffffffu) |
123 | #endif |
124 | |
125 | /* For XPG4 compliance we have to define the stuff from <wctype.h> here |
126 | as well. */ |
127 | #if defined __USE_XOPEN && !defined __USE_UNIX98 |
128 | # include <wctype.h> |
129 | #endif |
130 | |
131 | |
132 | __BEGIN_DECLS |
133 | |
134 | __BEGIN_NAMESPACE_STD |
135 | /* This incomplete type is defined in <time.h> but needed here because |
136 | of `wcsftime'. */ |
137 | struct tm; |
138 | __END_NAMESPACE_STD |
139 | /* XXX We have to clean this up at some point. Since tm is in the std |
140 | namespace but wcsftime is in __c99 the type wouldn't be found |
141 | without inserting it in the global namespace. */ |
142 | __USING_NAMESPACE_STD(tm) |
143 | |
144 | |
145 | __BEGIN_NAMESPACE_STD |
146 | /* Copy SRC to DEST. */ |
147 | extern wchar_t *wcscpy (wchar_t *__restrict __dest, |
148 | const wchar_t *__restrict __src) |
149 | __THROW __nonnull ((1, 2)); |
150 | |
151 | /* Copy no more than N wide-characters of SRC to DEST. */ |
152 | extern wchar_t *wcsncpy (wchar_t *__restrict __dest, |
153 | const wchar_t *__restrict __src, size_t __n) |
154 | __THROW __nonnull ((1, 2)); |
155 | |
156 | /* Append SRC onto DEST. */ |
157 | extern wchar_t *wcscat (wchar_t *__restrict __dest, |
158 | const wchar_t *__restrict __src) __THROW; |
159 | /* Append no more than N wide-characters of SRC onto DEST. */ |
160 | extern wchar_t *wcsncat (wchar_t *__restrict __dest, |
161 | const wchar_t *__restrict __src, size_t __n) |
162 | __THROW; |
163 | |
164 | /* Compare S1 and S2. */ |
165 | extern int wcscmp (const wchar_t *__s1, const wchar_t *__s2) |
166 | __THROW __attribute_pure__; |
167 | /* Compare N wide-characters of S1 and S2. */ |
168 | extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n) |
169 | __THROW __attribute_pure__; |
170 | __END_NAMESPACE_STD |
171 | |
172 | #ifdef __USE_XOPEN2K8 |
173 | /* Compare S1 and S2, ignoring case. */ |
174 | extern int wcscasecmp (const wchar_t *__s1, const wchar_t *__s2) __THROW; |
175 | |
176 | /* Compare no more than N chars of S1 and S2, ignoring case. */ |
177 | extern int wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2, |
178 | size_t __n) __THROW; |
179 | |
180 | /* Similar to the two functions above but take the information from |
181 | the provided locale and not the global locale. */ |
182 | # include <xlocale.h> |
183 | |
184 | extern int wcscasecmp_l (const wchar_t *__s1, const wchar_t *__s2, |
185 | __locale_t __loc) __THROW; |
186 | |
187 | extern int wcsncasecmp_l (const wchar_t *__s1, const wchar_t *__s2, |
188 | size_t __n, __locale_t __loc) __THROW; |
189 | #endif |
190 | |
191 | __BEGIN_NAMESPACE_STD |
192 | /* Compare S1 and S2, both interpreted as appropriate to the |
193 | LC_COLLATE category of the current locale. */ |
194 | extern int wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW; |
195 | /* Transform S2 into array pointed to by S1 such that if wcscmp is |
196 | applied to two transformed strings the result is the as applying |
197 | `wcscoll' to the original strings. */ |
198 | extern size_t wcsxfrm (wchar_t *__restrict __s1, |
199 | const wchar_t *__restrict __s2, size_t __n) __THROW; |
200 | __END_NAMESPACE_STD |
201 | |
202 | #ifdef __USE_XOPEN2K8 |
203 | /* Similar to the two functions above but take the information from |
204 | the provided locale and not the global locale. */ |
205 | |
206 | /* Compare S1 and S2, both interpreted as appropriate to the |
207 | LC_COLLATE category of the given locale. */ |
208 | extern int wcscoll_l (const wchar_t *__s1, const wchar_t *__s2, |
209 | __locale_t __loc) __THROW; |
210 | |
211 | /* Transform S2 into array pointed to by S1 such that if wcscmp is |
212 | applied to two transformed strings the result is the as applying |
213 | `wcscoll' to the original strings. */ |
214 | extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2, |
215 | size_t __n, __locale_t __loc) __THROW; |
216 | |
217 | /* Duplicate S, returning an identical malloc'd string. */ |
218 | extern wchar_t *wcsdup (const wchar_t *__s) __THROW __attribute_malloc__; |
219 | #endif |
220 | |
221 | __BEGIN_NAMESPACE_STD |
222 | /* Find the first occurrence of WC in WCS. */ |
223 | #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO |
224 | extern "C++" wchar_t *wcschr (wchar_t *__wcs, wchar_t __wc) |
225 | __THROW __asm ("wcschr" ) __attribute_pure__; |
226 | extern "C++" const wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc) |
227 | __THROW __asm ("wcschr" ) __attribute_pure__; |
228 | #else |
229 | extern wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc) |
230 | __THROW __attribute_pure__; |
231 | #endif |
232 | /* Find the last occurrence of WC in WCS. */ |
233 | #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO |
234 | extern "C++" wchar_t *wcsrchr (wchar_t *__wcs, wchar_t __wc) |
235 | __THROW __asm ("wcsrchr" ) __attribute_pure__; |
236 | extern "C++" const wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc) |
237 | __THROW __asm ("wcsrchr" ) __attribute_pure__; |
238 | #else |
239 | extern wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc) |
240 | __THROW __attribute_pure__; |
241 | #endif |
242 | __END_NAMESPACE_STD |
243 | |
244 | #ifdef __USE_GNU |
245 | /* This function is similar to `wcschr'. But it returns a pointer to |
246 | the closing NUL wide character in case C is not found in S. */ |
247 | extern wchar_t *wcschrnul (const wchar_t *__s, wchar_t __wc) |
248 | __THROW __attribute_pure__; |
249 | #endif |
250 | |
251 | __BEGIN_NAMESPACE_STD |
252 | /* Return the length of the initial segmet of WCS which |
253 | consists entirely of wide characters not in REJECT. */ |
254 | extern size_t wcscspn (const wchar_t *__wcs, const wchar_t *__reject) |
255 | __THROW __attribute_pure__; |
256 | /* Return the length of the initial segmet of WCS which |
257 | consists entirely of wide characters in ACCEPT. */ |
258 | extern size_t wcsspn (const wchar_t *__wcs, const wchar_t *__accept) |
259 | __THROW __attribute_pure__; |
260 | /* Find the first occurrence in WCS of any character in ACCEPT. */ |
261 | #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO |
262 | extern "C++" wchar_t *wcspbrk (wchar_t *__wcs, const wchar_t *__accept) |
263 | __THROW __asm ("wcspbrk" ) __attribute_pure__; |
264 | extern "C++" const wchar_t *wcspbrk (const wchar_t *__wcs, |
265 | const wchar_t *__accept) |
266 | __THROW __asm ("wcspbrk" ) __attribute_pure__; |
267 | #else |
268 | extern wchar_t *wcspbrk (const wchar_t *__wcs, const wchar_t *__accept) |
269 | __THROW __attribute_pure__; |
270 | #endif |
271 | /* Find the first occurrence of NEEDLE in HAYSTACK. */ |
272 | #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO |
273 | extern "C++" wchar_t *wcsstr (wchar_t *__haystack, const wchar_t *__needle) |
274 | __THROW __asm ("wcsstr" ) __attribute_pure__; |
275 | extern "C++" const wchar_t *wcsstr (const wchar_t *__haystack, |
276 | const wchar_t *__needle) |
277 | __THROW __asm ("wcsstr" ) __attribute_pure__; |
278 | #else |
279 | extern wchar_t *wcsstr (const wchar_t *__haystack, const wchar_t *__needle) |
280 | __THROW __attribute_pure__; |
281 | #endif |
282 | |
283 | /* Divide WCS into tokens separated by characters in DELIM. */ |
284 | extern wchar_t *wcstok (wchar_t *__restrict __s, |
285 | const wchar_t *__restrict __delim, |
286 | wchar_t **__restrict __ptr) __THROW; |
287 | |
288 | /* Return the number of wide characters in S. */ |
289 | extern size_t wcslen (const wchar_t *__s) __THROW __attribute_pure__; |
290 | __END_NAMESPACE_STD |
291 | |
292 | #ifdef __USE_XOPEN |
293 | /* Another name for `wcsstr' from XPG4. */ |
294 | # ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO |
295 | extern "C++" wchar_t *wcswcs (wchar_t *__haystack, const wchar_t *__needle) |
296 | __THROW __asm ("wcswcs" ) __attribute_pure__; |
297 | extern "C++" const wchar_t *wcswcs (const wchar_t *__haystack, |
298 | const wchar_t *__needle) |
299 | __THROW __asm ("wcswcs" ) __attribute_pure__; |
300 | # else |
301 | extern wchar_t *wcswcs (const wchar_t *__haystack, const wchar_t *__needle) |
302 | __THROW __attribute_pure__; |
303 | # endif |
304 | #endif |
305 | |
306 | #ifdef __USE_XOPEN2K8 |
307 | /* Return the number of wide characters in S, but at most MAXLEN. */ |
308 | extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen) |
309 | __THROW __attribute_pure__; |
310 | #endif |
311 | |
312 | |
313 | __BEGIN_NAMESPACE_STD |
314 | /* Search N wide characters of S for C. */ |
315 | #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO |
316 | extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n) |
317 | __THROW __asm ("wmemchr" ) __attribute_pure__; |
318 | extern "C++" const wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, |
319 | size_t __n) |
320 | __THROW __asm ("wmemchr" ) __attribute_pure__; |
321 | #else |
322 | extern wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, size_t __n) |
323 | __THROW __attribute_pure__; |
324 | #endif |
325 | |
326 | /* Compare N wide characters of S1 and S2. */ |
327 | extern int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n) |
328 | __THROW __attribute_pure__; |
329 | |
330 | /* Copy N wide characters of SRC to DEST. */ |
331 | extern wchar_t *wmemcpy (wchar_t *__restrict __s1, |
332 | const wchar_t *__restrict __s2, size_t __n) __THROW; |
333 | |
334 | /* Copy N wide characters of SRC to DEST, guaranteeing |
335 | correct behavior for overlapping strings. */ |
336 | extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n) |
337 | __THROW; |
338 | |
339 | /* Set N wide characters of S to C. */ |
340 | extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW; |
341 | __END_NAMESPACE_STD |
342 | |
343 | #ifdef __USE_GNU |
344 | /* Copy N wide characters of SRC to DEST and return pointer to following |
345 | wide character. */ |
346 | extern wchar_t *wmempcpy (wchar_t *__restrict __s1, |
347 | const wchar_t *__restrict __s2, size_t __n) |
348 | __THROW; |
349 | #endif |
350 | |
351 | |
352 | __BEGIN_NAMESPACE_STD |
353 | /* Determine whether C constitutes a valid (one-byte) multibyte |
354 | character. */ |
355 | extern wint_t btowc (int __c) __THROW; |
356 | |
357 | /* Determine whether C corresponds to a member of the extended |
358 | character set whose multibyte representation is a single byte. */ |
359 | extern int wctob (wint_t __c) __THROW; |
360 | |
361 | /* Determine whether PS points to an object representing the initial |
362 | state. */ |
363 | extern int mbsinit (const mbstate_t *__ps) __THROW __attribute_pure__; |
364 | |
365 | /* Write wide character representation of multibyte character pointed |
366 | to by S to PWC. */ |
367 | extern size_t mbrtowc (wchar_t *__restrict __pwc, |
368 | const char *__restrict __s, size_t __n, |
369 | mbstate_t *__restrict __p) __THROW; |
370 | |
371 | /* Write multibyte representation of wide character WC to S. */ |
372 | extern size_t wcrtomb (char *__restrict __s, wchar_t __wc, |
373 | mbstate_t *__restrict __ps) __THROW; |
374 | |
375 | /* Return number of bytes in multibyte character pointed to by S. */ |
376 | extern size_t __mbrlen (const char *__restrict __s, size_t __n, |
377 | mbstate_t *__restrict __ps) __THROW; |
378 | extern size_t mbrlen (const char *__restrict __s, size_t __n, |
379 | mbstate_t *__restrict __ps) __THROW; |
380 | __END_NAMESPACE_STD |
381 | |
382 | #ifdef __USE_EXTERN_INLINES |
383 | /* Define inline function as optimization. */ |
384 | |
385 | /* We can use the BTOWC and WCTOB optimizations since we know that all |
386 | locales must use ASCII encoding for the values in the ASCII range |
387 | and because the wchar_t encoding is always ISO 10646. */ |
388 | extern wint_t __btowc_alias (int __c) __asm ("btowc" ); |
389 | __extern_inline wint_t |
390 | __NTH (btowc (int __c)) |
391 | { return (__builtin_constant_p (__c) && __c >= '\0' && __c <= '\x7f' |
392 | ? (wint_t) __c : __btowc_alias (__c)); } |
393 | |
394 | extern int __wctob_alias (wint_t __c) __asm ("wctob" ); |
395 | __extern_inline int |
396 | __NTH (wctob (wint_t __wc)) |
397 | { return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <= L'\x7f' |
398 | ? (int) __wc : __wctob_alias (__wc)); } |
399 | |
400 | __extern_inline size_t |
401 | __NTH (mbrlen (const char *__restrict __s, size_t __n, |
402 | mbstate_t *__restrict __ps)) |
403 | { return (__ps != NULL |
404 | ? mbrtowc (NULL, __s, __n, __ps) : __mbrlen (__s, __n, NULL)); } |
405 | #endif |
406 | |
407 | __BEGIN_NAMESPACE_STD |
408 | /* Write wide character representation of multibyte character string |
409 | SRC to DST. */ |
410 | extern size_t mbsrtowcs (wchar_t *__restrict __dst, |
411 | const char **__restrict __src, size_t __len, |
412 | mbstate_t *__restrict __ps) __THROW; |
413 | |
414 | /* Write multibyte character representation of wide character string |
415 | SRC to DST. */ |
416 | extern size_t wcsrtombs (char *__restrict __dst, |
417 | const wchar_t **__restrict __src, size_t __len, |
418 | mbstate_t *__restrict __ps) __THROW; |
419 | __END_NAMESPACE_STD |
420 | |
421 | |
422 | #ifdef __USE_XOPEN2K8 |
423 | /* Write wide character representation of at most NMC bytes of the |
424 | multibyte character string SRC to DST. */ |
425 | extern size_t mbsnrtowcs (wchar_t *__restrict __dst, |
426 | const char **__restrict __src, size_t __nmc, |
427 | size_t __len, mbstate_t *__restrict __ps) __THROW; |
428 | |
429 | /* Write multibyte character representation of at most NWC characters |
430 | from the wide character string SRC to DST. */ |
431 | extern size_t wcsnrtombs (char *__restrict __dst, |
432 | const wchar_t **__restrict __src, |
433 | size_t __nwc, size_t __len, |
434 | mbstate_t *__restrict __ps) __THROW; |
435 | #endif /* use POSIX 2008 */ |
436 | |
437 | |
438 | /* The following functions are extensions found in X/Open CAE. */ |
439 | #ifdef __USE_XOPEN |
440 | /* Determine number of column positions required for C. */ |
441 | extern int wcwidth (wchar_t __c) __THROW; |
442 | |
443 | /* Determine number of column positions required for first N wide |
444 | characters (or fewer if S ends before this) in S. */ |
445 | extern int wcswidth (const wchar_t *__s, size_t __n) __THROW; |
446 | #endif /* Use X/Open. */ |
447 | |
448 | |
449 | __BEGIN_NAMESPACE_STD |
450 | /* Convert initial portion of the wide string NPTR to `double' |
451 | representation. */ |
452 | extern double wcstod (const wchar_t *__restrict __nptr, |
453 | wchar_t **__restrict __endptr) __THROW; |
454 | __END_NAMESPACE_STD |
455 | |
456 | #ifdef __USE_ISOC99 |
457 | __BEGIN_NAMESPACE_C99 |
458 | /* Likewise for `float' and `long double' sizes of floating-point numbers. */ |
459 | extern float wcstof (const wchar_t *__restrict __nptr, |
460 | wchar_t **__restrict __endptr) __THROW; |
461 | extern long double wcstold (const wchar_t *__restrict __nptr, |
462 | wchar_t **__restrict __endptr) __THROW; |
463 | __END_NAMESPACE_C99 |
464 | #endif /* C99 */ |
465 | |
466 | |
467 | __BEGIN_NAMESPACE_STD |
468 | /* Convert initial portion of wide string NPTR to `long int' |
469 | representation. */ |
470 | extern long int wcstol (const wchar_t *__restrict __nptr, |
471 | wchar_t **__restrict __endptr, int __base) __THROW; |
472 | |
473 | /* Convert initial portion of wide string NPTR to `unsigned long int' |
474 | representation. */ |
475 | extern unsigned long int wcstoul (const wchar_t *__restrict __nptr, |
476 | wchar_t **__restrict __endptr, int __base) |
477 | __THROW; |
478 | __END_NAMESPACE_STD |
479 | |
480 | #ifdef __USE_ISOC99 |
481 | __BEGIN_NAMESPACE_C99 |
482 | /* Convert initial portion of wide string NPTR to `long long int' |
483 | representation. */ |
484 | __extension__ |
485 | extern long long int wcstoll (const wchar_t *__restrict __nptr, |
486 | wchar_t **__restrict __endptr, int __base) |
487 | __THROW; |
488 | |
489 | /* Convert initial portion of wide string NPTR to `unsigned long long int' |
490 | representation. */ |
491 | __extension__ |
492 | extern unsigned long long int wcstoull (const wchar_t *__restrict __nptr, |
493 | wchar_t **__restrict __endptr, |
494 | int __base) __THROW; |
495 | __END_NAMESPACE_C99 |
496 | #endif /* ISO C99. */ |
497 | |
498 | #ifdef __USE_GNU |
499 | /* Convert initial portion of wide string NPTR to `long long int' |
500 | representation. */ |
501 | __extension__ |
502 | extern long long int wcstoq (const wchar_t *__restrict __nptr, |
503 | wchar_t **__restrict __endptr, int __base) |
504 | __THROW; |
505 | |
506 | /* Convert initial portion of wide string NPTR to `unsigned long long int' |
507 | representation. */ |
508 | __extension__ |
509 | extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr, |
510 | wchar_t **__restrict __endptr, |
511 | int __base) __THROW; |
512 | #endif /* Use GNU. */ |
513 | |
514 | #ifdef __USE_GNU |
515 | /* The concept of one static locale per category is not very well |
516 | thought out. Many applications will need to process its data using |
517 | information from several different locales. Another application is |
518 | the implementation of the internationalization handling in the |
519 | upcoming ISO C++ standard library. To support this another set of |
520 | the functions using locale data exist which have an additional |
521 | argument. |
522 | |
523 | Attention: all these functions are *not* standardized in any form. |
524 | This is a proof-of-concept implementation. */ |
525 | |
526 | /* Structure for reentrant locale using functions. This is an |
527 | (almost) opaque type for the user level programs. */ |
528 | # include <xlocale.h> |
529 | |
530 | /* Special versions of the functions above which take the locale to |
531 | use as an additional parameter. */ |
532 | extern long int wcstol_l (const wchar_t *__restrict __nptr, |
533 | wchar_t **__restrict __endptr, int __base, |
534 | __locale_t __loc) __THROW; |
535 | |
536 | extern unsigned long int wcstoul_l (const wchar_t *__restrict __nptr, |
537 | wchar_t **__restrict __endptr, |
538 | int __base, __locale_t __loc) __THROW; |
539 | |
540 | __extension__ |
541 | extern long long int wcstoll_l (const wchar_t *__restrict __nptr, |
542 | wchar_t **__restrict __endptr, |
543 | int __base, __locale_t __loc) __THROW; |
544 | |
545 | __extension__ |
546 | extern unsigned long long int wcstoull_l (const wchar_t *__restrict __nptr, |
547 | wchar_t **__restrict __endptr, |
548 | int __base, __locale_t __loc) |
549 | __THROW; |
550 | |
551 | extern double wcstod_l (const wchar_t *__restrict __nptr, |
552 | wchar_t **__restrict __endptr, __locale_t __loc) |
553 | __THROW; |
554 | |
555 | extern float wcstof_l (const wchar_t *__restrict __nptr, |
556 | wchar_t **__restrict __endptr, __locale_t __loc) |
557 | __THROW; |
558 | |
559 | extern long double wcstold_l (const wchar_t *__restrict __nptr, |
560 | wchar_t **__restrict __endptr, |
561 | __locale_t __loc) __THROW; |
562 | #endif /* use GNU */ |
563 | |
564 | |
565 | #ifdef __USE_XOPEN2K8 |
566 | /* Copy SRC to DEST, returning the address of the terminating L'\0' in |
567 | DEST. */ |
568 | extern wchar_t *wcpcpy (wchar_t *__restrict __dest, |
569 | const wchar_t *__restrict __src) __THROW; |
570 | |
571 | /* Copy no more than N characters of SRC to DEST, returning the address of |
572 | the last character written into DEST. */ |
573 | extern wchar_t *wcpncpy (wchar_t *__restrict __dest, |
574 | const wchar_t *__restrict __src, size_t __n) |
575 | __THROW; |
576 | |
577 | |
578 | /* Wide character I/O functions. */ |
579 | |
580 | /* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces |
581 | a wide character string. */ |
582 | extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW; |
583 | #endif |
584 | |
585 | #if defined __USE_ISOC95 || defined __USE_UNIX98 |
586 | __BEGIN_NAMESPACE_STD |
587 | |
588 | /* Select orientation for stream. */ |
589 | extern int fwide (__FILE *__fp, int __mode) __THROW; |
590 | |
591 | |
592 | /* Write formatted output to STREAM. |
593 | |
594 | This function is a possible cancellation point and therefore not |
595 | marked with __THROW. */ |
596 | extern int fwprintf (__FILE *__restrict __stream, |
597 | const wchar_t *__restrict __format, ...) |
598 | /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */; |
599 | /* Write formatted output to stdout. |
600 | |
601 | This function is a possible cancellation point and therefore not |
602 | marked with __THROW. */ |
603 | extern int wprintf (const wchar_t *__restrict __format, ...) |
604 | /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */; |
605 | /* Write formatted output of at most N characters to S. */ |
606 | extern int swprintf (wchar_t *__restrict __s, size_t __n, |
607 | const wchar_t *__restrict __format, ...) |
608 | __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */; |
609 | |
610 | /* Write formatted output to S from argument list ARG. |
611 | |
612 | This function is a possible cancellation point and therefore not |
613 | marked with __THROW. */ |
614 | extern int vfwprintf (__FILE *__restrict __s, |
615 | const wchar_t *__restrict __format, |
616 | __gnuc_va_list __arg) |
617 | /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */; |
618 | /* Write formatted output to stdout from argument list ARG. |
619 | |
620 | This function is a possible cancellation point and therefore not |
621 | marked with __THROW. */ |
622 | extern int vwprintf (const wchar_t *__restrict __format, |
623 | __gnuc_va_list __arg) |
624 | /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */; |
625 | /* Write formatted output of at most N character to S from argument |
626 | list ARG. */ |
627 | extern int vswprintf (wchar_t *__restrict __s, size_t __n, |
628 | const wchar_t *__restrict __format, |
629 | __gnuc_va_list __arg) |
630 | __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */; |
631 | |
632 | |
633 | /* Read formatted input from STREAM. |
634 | |
635 | This function is a possible cancellation point and therefore not |
636 | marked with __THROW. */ |
637 | extern int fwscanf (__FILE *__restrict __stream, |
638 | const wchar_t *__restrict __format, ...) |
639 | /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; |
640 | /* Read formatted input from stdin. |
641 | |
642 | This function is a possible cancellation point and therefore not |
643 | marked with __THROW. */ |
644 | extern int wscanf (const wchar_t *__restrict __format, ...) |
645 | /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */; |
646 | /* Read formatted input from S. */ |
647 | extern int swscanf (const wchar_t *__restrict __s, |
648 | const wchar_t *__restrict __format, ...) |
649 | __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; |
650 | |
651 | # if defined __USE_ISOC99 && !defined __USE_GNU \ |
652 | && (!defined __LDBL_COMPAT || !defined __REDIRECT) \ |
653 | && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) |
654 | # ifdef __REDIRECT |
655 | /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[ |
656 | GNU extension which conflicts with valid %a followed by letter |
657 | s, S or [. */ |
658 | extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream, |
659 | const wchar_t *__restrict __format, ...), |
660 | __isoc99_fwscanf) |
661 | /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; |
662 | extern int __REDIRECT (wscanf, (const wchar_t *__restrict __format, ...), |
663 | __isoc99_wscanf) |
664 | /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */; |
665 | extern int __REDIRECT_NTH (swscanf, (const wchar_t *__restrict __s, |
666 | const wchar_t *__restrict __format, |
667 | ...), __isoc99_swscanf) |
668 | /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; |
669 | # else |
670 | extern int __isoc99_fwscanf (__FILE *__restrict __stream, |
671 | const wchar_t *__restrict __format, ...); |
672 | extern int __isoc99_wscanf (const wchar_t *__restrict __format, ...); |
673 | extern int __isoc99_swscanf (const wchar_t *__restrict __s, |
674 | const wchar_t *__restrict __format, ...) |
675 | __THROW; |
676 | # define fwscanf __isoc99_fwscanf |
677 | # define wscanf __isoc99_wscanf |
678 | # define swscanf __isoc99_swscanf |
679 | # endif |
680 | # endif |
681 | |
682 | __END_NAMESPACE_STD |
683 | #endif /* Use ISO C95, C99 and Unix98. */ |
684 | |
685 | #ifdef __USE_ISOC99 |
686 | __BEGIN_NAMESPACE_C99 |
687 | /* Read formatted input from S into argument list ARG. |
688 | |
689 | This function is a possible cancellation point and therefore not |
690 | marked with __THROW. */ |
691 | extern int vfwscanf (__FILE *__restrict __s, |
692 | const wchar_t *__restrict __format, |
693 | __gnuc_va_list __arg) |
694 | /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; |
695 | /* Read formatted input from stdin into argument list ARG. |
696 | |
697 | This function is a possible cancellation point and therefore not |
698 | marked with __THROW. */ |
699 | extern int vwscanf (const wchar_t *__restrict __format, |
700 | __gnuc_va_list __arg) |
701 | /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */; |
702 | /* Read formatted input from S into argument list ARG. */ |
703 | extern int vswscanf (const wchar_t *__restrict __s, |
704 | const wchar_t *__restrict __format, |
705 | __gnuc_va_list __arg) |
706 | __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; |
707 | |
708 | # if !defined __USE_GNU \ |
709 | && (!defined __LDBL_COMPAT || !defined __REDIRECT) \ |
710 | && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) |
711 | # ifdef __REDIRECT |
712 | extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s, |
713 | const wchar_t *__restrict __format, |
714 | __gnuc_va_list __arg), __isoc99_vfwscanf) |
715 | /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; |
716 | extern int __REDIRECT (vwscanf, (const wchar_t *__restrict __format, |
717 | __gnuc_va_list __arg), __isoc99_vwscanf) |
718 | /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */; |
719 | extern int __REDIRECT_NTH (vswscanf, (const wchar_t *__restrict __s, |
720 | const wchar_t *__restrict __format, |
721 | __gnuc_va_list __arg), __isoc99_vswscanf) |
722 | /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; |
723 | # else |
724 | extern int __isoc99_vfwscanf (__FILE *__restrict __s, |
725 | const wchar_t *__restrict __format, |
726 | __gnuc_va_list __arg); |
727 | extern int __isoc99_vwscanf (const wchar_t *__restrict __format, |
728 | __gnuc_va_list __arg); |
729 | extern int __isoc99_vswscanf (const wchar_t *__restrict __s, |
730 | const wchar_t *__restrict __format, |
731 | __gnuc_va_list __arg) __THROW; |
732 | # define vfwscanf __isoc99_vfwscanf |
733 | # define vwscanf __isoc99_vwscanf |
734 | # define vswscanf __isoc99_vswscanf |
735 | # endif |
736 | # endif |
737 | |
738 | __END_NAMESPACE_C99 |
739 | #endif /* Use ISO C99. */ |
740 | |
741 | |
742 | __BEGIN_NAMESPACE_STD |
743 | /* Read a character from STREAM. |
744 | |
745 | These functions are possible cancellation points and therefore not |
746 | marked with __THROW. */ |
747 | extern wint_t fgetwc (__FILE *__stream); |
748 | extern wint_t getwc (__FILE *__stream); |
749 | |
750 | /* Read a character from stdin. |
751 | |
752 | This function is a possible cancellation point and therefore not |
753 | marked with __THROW. */ |
754 | extern wint_t getwchar (void); |
755 | |
756 | |
757 | /* Write a character to STREAM. |
758 | |
759 | These functions are possible cancellation points and therefore not |
760 | marked with __THROW. */ |
761 | extern wint_t fputwc (wchar_t __wc, __FILE *__stream); |
762 | extern wint_t putwc (wchar_t __wc, __FILE *__stream); |
763 | |
764 | /* Write a character to stdout. |
765 | |
766 | This function is a possible cancellation point and therefore not |
767 | marked with __THROW. */ |
768 | extern wint_t putwchar (wchar_t __wc); |
769 | |
770 | |
771 | /* Get a newline-terminated wide character string of finite length |
772 | from STREAM. |
773 | |
774 | This function is a possible cancellation point and therefore not |
775 | marked with __THROW. */ |
776 | extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n, |
777 | __FILE *__restrict __stream); |
778 | |
779 | /* Write a string to STREAM. |
780 | |
781 | This function is a possible cancellation point and therefore not |
782 | marked with __THROW. */ |
783 | extern int fputws (const wchar_t *__restrict __ws, |
784 | __FILE *__restrict __stream); |
785 | |
786 | |
787 | /* Push a character back onto the input buffer of STREAM. |
788 | |
789 | This function is a possible cancellation point and therefore not |
790 | marked with __THROW. */ |
791 | extern wint_t ungetwc (wint_t __wc, __FILE *__stream); |
792 | __END_NAMESPACE_STD |
793 | |
794 | |
795 | #ifdef __USE_GNU |
796 | /* These are defined to be equivalent to the `char' functions defined |
797 | in POSIX.1:1996. |
798 | |
799 | These functions are not part of POSIX and therefore no official |
800 | cancellation point. But due to similarity with an POSIX interface |
801 | or due to the implementation they are cancellation points and |
802 | therefore not marked with __THROW. */ |
803 | extern wint_t getwc_unlocked (__FILE *__stream); |
804 | extern wint_t getwchar_unlocked (void); |
805 | |
806 | /* This is the wide character version of a GNU extension. |
807 | |
808 | This function is not part of POSIX and therefore no official |
809 | cancellation point. But due to similarity with an POSIX interface |
810 | or due to the implementation it is a cancellation point and |
811 | therefore not marked with __THROW. */ |
812 | extern wint_t fgetwc_unlocked (__FILE *__stream); |
813 | |
814 | /* Faster version when locking is not necessary. |
815 | |
816 | This function is not part of POSIX and therefore no official |
817 | cancellation point. But due to similarity with an POSIX interface |
818 | or due to the implementation it is a cancellation point and |
819 | therefore not marked with __THROW. */ |
820 | extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream); |
821 | |
822 | /* These are defined to be equivalent to the `char' functions defined |
823 | in POSIX.1:1996. |
824 | |
825 | These functions are not part of POSIX and therefore no official |
826 | cancellation point. But due to similarity with an POSIX interface |
827 | or due to the implementation they are cancellation points and |
828 | therefore not marked with __THROW. */ |
829 | extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream); |
830 | extern wint_t putwchar_unlocked (wchar_t __wc); |
831 | |
832 | |
833 | /* This function does the same as `fgetws' but does not lock the stream. |
834 | |
835 | This function is not part of POSIX and therefore no official |
836 | cancellation point. But due to similarity with an POSIX interface |
837 | or due to the implementation it is a cancellation point and |
838 | therefore not marked with __THROW. */ |
839 | extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n, |
840 | __FILE *__restrict __stream); |
841 | |
842 | /* This function does the same as `fputws' but does not lock the stream. |
843 | |
844 | This function is not part of POSIX and therefore no official |
845 | cancellation point. But due to similarity with an POSIX interface |
846 | or due to the implementation it is a cancellation point and |
847 | therefore not marked with __THROW. */ |
848 | extern int fputws_unlocked (const wchar_t *__restrict __ws, |
849 | __FILE *__restrict __stream); |
850 | #endif |
851 | |
852 | |
853 | __BEGIN_NAMESPACE_C99 |
854 | /* Format TP into S according to FORMAT. |
855 | Write no more than MAXSIZE wide characters and return the number |
856 | of wide characters written, or 0 if it would exceed MAXSIZE. */ |
857 | extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize, |
858 | const wchar_t *__restrict __format, |
859 | const struct tm *__restrict __tp) __THROW; |
860 | __END_NAMESPACE_C99 |
861 | |
862 | # ifdef __USE_GNU |
863 | # include <xlocale.h> |
864 | |
865 | /* Similar to `wcsftime' but takes the information from |
866 | the provided locale and not the global locale. */ |
867 | extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize, |
868 | const wchar_t *__restrict __format, |
869 | const struct tm *__restrict __tp, |
870 | __locale_t __loc) __THROW; |
871 | # endif |
872 | |
873 | /* The X/Open standard demands that most of the functions defined in |
874 | the <wctype.h> header must also appear here. This is probably |
875 | because some X/Open members wrote their implementation before the |
876 | ISO C standard was published and introduced the better solution. |
877 | We have to provide these definitions for compliance reasons but we |
878 | do this nonsense only if really necessary. */ |
879 | #if defined __USE_UNIX98 && !defined __USE_GNU |
880 | # define __need_iswxxx |
881 | # include <wctype.h> |
882 | #endif |
883 | |
884 | /* Define some macros helping to catch buffer overflows. */ |
885 | #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function |
886 | # include <bits/wchar2.h> |
887 | #endif |
888 | |
889 | #ifdef __LDBL_COMPAT |
890 | # include <bits/wchar-ldbl.h> |
891 | #endif |
892 | |
893 | __END_DECLS |
894 | |
895 | #endif /* _WCHAR_H defined */ |
896 | |
897 | #endif /* wchar.h */ |
898 | |
899 | /* Undefine all __need_* constants in case we are included to get those |
900 | constants but the whole file was already read. */ |
901 | #undef __need_mbstate_t |
902 | #undef __need_wint_t |
903 | |