1 /* Copyright (C) 1995-2017 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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/>. */
19 * ISO C99 Standard: 7.24
20 * Extended multibyte and wide character utilities <wchar.h>
25 #if !defined __need_mbstate_t && !defined __need_wint_t
27 # define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
28 # include <bits/libc-header-start.h>
32 /* Get FILE definition. */
33 # define __need___FILE
34 # if defined __USE_UNIX98 || defined __USE_XOPEN2K
38 /* Get va_list definition. */
39 # define __need___va_list
42 # include <bits/wchar.h>
44 /* Get size_t, wchar_t, wint_t and NULL from <stddef.h>. */
45 # define __need_size_t
46 # define __need_wchar_t
49 #if defined _WCHAR_H || defined __need_wint_t || !defined __WINT_TYPE__
51 # define __need_wint_t
54 /* We try to get wint_t from <stddef.h>, but not all GCC versions define it
55 there. So define it ourselves if it remains undefined. */
57 /* Integral type unchanged by default argument promotions that can
58 hold any value corresponding to members of the extended character
59 set, as well as at least one value that does not correspond to any
60 member of the extended character set. */
62 typedef unsigned int wint_t;
65 /* Tell the caller that we provide correct C++ prototypes. */
66 # if defined __cplusplus && __GNUC_PREREQ (4, 4)
67 # define __CORRECT_ISO_CPP_WCHAR_H_PROTO
71 #if (defined _WCHAR_H || defined __need_mbstate_t) && !defined ____mbstate_t_defined
72 # define ____mbstate_t_defined 1
73 /* Conversion state information. */
85 } __value
; /* Value so far. */
88 #undef __need_mbstate_t
91 /* The rest of the file is only used if used if __need_mbstate_t is not
95 # ifndef __mbstate_t_defined
97 typedef __mbstate_t
mbstate_t;
98 # define __mbstate_t_defined 1
102 /* These constants might also be defined in <inttypes.h>. */
103 # define WCHAR_MIN __WCHAR_MIN
104 # define WCHAR_MAX __WCHAR_MAX
108 # define WEOF (0xffffffffu)
111 /* For XPG4 compliance we have to define the stuff from <wctype.h> here
113 #if defined __USE_XOPEN && !defined __USE_UNIX98
120 /* This incomplete type is defined in <time.h> but needed here because
125 /* Copy SRC to DEST. */
126 extern wchar_t *wcscpy (wchar_t *__restrict __dest
,
127 const wchar_t *__restrict __src
)
128 __THROW
__nonnull ((1, 2));
130 /* Copy no more than N wide-characters of SRC to DEST. */
131 extern wchar_t *wcsncpy (wchar_t *__restrict __dest
,
132 const wchar_t *__restrict __src
, size_t __n
)
133 __THROW
__nonnull ((1, 2));
135 /* Append SRC onto DEST. */
136 extern wchar_t *wcscat (wchar_t *__restrict __dest
,
137 const wchar_t *__restrict __src
)
138 __THROW
__nonnull ((1, 2));
139 /* Append no more than N wide-characters of SRC onto DEST. */
140 extern wchar_t *wcsncat (wchar_t *__restrict __dest
,
141 const wchar_t *__restrict __src
, size_t __n
)
142 __THROW
__nonnull ((1, 2));
144 /* Compare S1 and S2. */
145 extern int wcscmp (const wchar_t *__s1
, const wchar_t *__s2
)
146 __THROW __attribute_pure__
__nonnull ((1, 2));
147 /* Compare N wide-characters of S1 and S2. */
148 extern int wcsncmp (const wchar_t *__s1
, const wchar_t *__s2
, size_t __n
)
149 __THROW __attribute_pure__
__nonnull ((1, 2));
151 #ifdef __USE_XOPEN2K8
152 /* Compare S1 and S2, ignoring case. */
153 extern int wcscasecmp (const wchar_t *__s1
, const wchar_t *__s2
) __THROW
;
155 /* Compare no more than N chars of S1 and S2, ignoring case. */
156 extern int wcsncasecmp (const wchar_t *__s1
, const wchar_t *__s2
,
159 /* Similar to the two functions above but take the information from
160 the provided locale and not the global locale. */
161 # include <xlocale.h>
163 extern int wcscasecmp_l (const wchar_t *__s1
, const wchar_t *__s2
,
164 __locale_t __loc
) __THROW
;
166 extern int wcsncasecmp_l (const wchar_t *__s1
, const wchar_t *__s2
,
167 size_t __n
, __locale_t __loc
) __THROW
;
170 /* Compare S1 and S2, both interpreted as appropriate to the
171 LC_COLLATE category of the current locale. */
172 extern int wcscoll (const wchar_t *__s1
, const wchar_t *__s2
) __THROW
;
173 /* Transform S2 into array pointed to by S1 such that if wcscmp is
174 applied to two transformed strings the result is the as applying
175 `wcscoll' to the original strings. */
176 extern size_t wcsxfrm (wchar_t *__restrict __s1
,
177 const wchar_t *__restrict __s2
, size_t __n
) __THROW
;
179 #ifdef __USE_XOPEN2K8
180 /* Similar to the two functions above but take the information from
181 the provided locale and not the global locale. */
183 /* Compare S1 and S2, both interpreted as appropriate to the
184 LC_COLLATE category of the given locale. */
185 extern int wcscoll_l (const wchar_t *__s1
, const wchar_t *__s2
,
186 __locale_t __loc
) __THROW
;
188 /* Transform S2 into array pointed to by S1 such that if wcscmp is
189 applied to two transformed strings the result is the as applying
190 `wcscoll' to the original strings. */
191 extern size_t wcsxfrm_l (wchar_t *__s1
, const wchar_t *__s2
,
192 size_t __n
, __locale_t __loc
) __THROW
;
194 /* Duplicate S, returning an identical malloc'd string. */
195 extern wchar_t *wcsdup (const wchar_t *__s
) __THROW __attribute_malloc__
;
198 /* Find the first occurrence of WC in WCS. */
199 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
200 extern "C++" wchar_t *wcschr (wchar_t *__wcs
, wchar_t __wc
)
201 __THROW
__asm ("wcschr") __attribute_pure__
;
202 extern "C++" const wchar_t *wcschr (const wchar_t *__wcs
, wchar_t __wc
)
203 __THROW
__asm ("wcschr") __attribute_pure__
;
205 extern wchar_t *wcschr (const wchar_t *__wcs
, wchar_t __wc
)
206 __THROW __attribute_pure__
;
208 /* Find the last occurrence of WC in WCS. */
209 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
210 extern "C++" wchar_t *wcsrchr (wchar_t *__wcs
, wchar_t __wc
)
211 __THROW
__asm ("wcsrchr") __attribute_pure__
;
212 extern "C++" const wchar_t *wcsrchr (const wchar_t *__wcs
, wchar_t __wc
)
213 __THROW
__asm ("wcsrchr") __attribute_pure__
;
215 extern wchar_t *wcsrchr (const wchar_t *__wcs
, wchar_t __wc
)
216 __THROW __attribute_pure__
;
220 /* This function is similar to `wcschr'. But it returns a pointer to
221 the closing NUL wide character in case C is not found in S. */
222 extern wchar_t *wcschrnul (const wchar_t *__s
, wchar_t __wc
)
223 __THROW __attribute_pure__
;
226 /* Return the length of the initial segmet of WCS which
227 consists entirely of wide characters not in REJECT. */
228 extern size_t wcscspn (const wchar_t *__wcs
, const wchar_t *__reject
)
229 __THROW __attribute_pure__
;
230 /* Return the length of the initial segmet of WCS which
231 consists entirely of wide characters in ACCEPT. */
232 extern size_t wcsspn (const wchar_t *__wcs
, const wchar_t *__accept
)
233 __THROW __attribute_pure__
;
234 /* Find the first occurrence in WCS of any character in ACCEPT. */
235 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
236 extern "C++" wchar_t *wcspbrk (wchar_t *__wcs
, const wchar_t *__accept
)
237 __THROW
__asm ("wcspbrk") __attribute_pure__
;
238 extern "C++" const wchar_t *wcspbrk (const wchar_t *__wcs
,
239 const wchar_t *__accept
)
240 __THROW
__asm ("wcspbrk") __attribute_pure__
;
242 extern wchar_t *wcspbrk (const wchar_t *__wcs
, const wchar_t *__accept
)
243 __THROW __attribute_pure__
;
245 /* Find the first occurrence of NEEDLE in HAYSTACK. */
246 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
247 extern "C++" wchar_t *wcsstr (wchar_t *__haystack
, const wchar_t *__needle
)
248 __THROW
__asm ("wcsstr") __attribute_pure__
;
249 extern "C++" const wchar_t *wcsstr (const wchar_t *__haystack
,
250 const wchar_t *__needle
)
251 __THROW
__asm ("wcsstr") __attribute_pure__
;
253 extern wchar_t *wcsstr (const wchar_t *__haystack
, const wchar_t *__needle
)
254 __THROW __attribute_pure__
;
257 /* Divide WCS into tokens separated by characters in DELIM. */
258 extern wchar_t *wcstok (wchar_t *__restrict __s
,
259 const wchar_t *__restrict __delim
,
260 wchar_t **__restrict __ptr
) __THROW
;
262 /* Return the number of wide characters in S. */
263 extern size_t wcslen (const wchar_t *__s
) __THROW __attribute_pure__
;
266 /* Another name for `wcsstr' from XPG4. */
267 # ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
268 extern "C++" wchar_t *wcswcs (wchar_t *__haystack
, const wchar_t *__needle
)
269 __THROW
__asm ("wcswcs") __attribute_pure__
;
270 extern "C++" const wchar_t *wcswcs (const wchar_t *__haystack
,
271 const wchar_t *__needle
)
272 __THROW
__asm ("wcswcs") __attribute_pure__
;
274 extern wchar_t *wcswcs (const wchar_t *__haystack
, const wchar_t *__needle
)
275 __THROW __attribute_pure__
;
279 #ifdef __USE_XOPEN2K8
280 /* Return the number of wide characters in S, but at most MAXLEN. */
281 extern size_t wcsnlen (const wchar_t *__s
, size_t __maxlen
)
282 __THROW __attribute_pure__
;
286 /* Search N wide characters of S for C. */
287 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
288 extern "C++" wchar_t *wmemchr (wchar_t *__s
, wchar_t __c
, size_t __n
)
289 __THROW
__asm ("wmemchr") __attribute_pure__
;
290 extern "C++" const wchar_t *wmemchr (const wchar_t *__s
, wchar_t __c
,
292 __THROW
__asm ("wmemchr") __attribute_pure__
;
294 extern wchar_t *wmemchr (const wchar_t *__s
, wchar_t __c
, size_t __n
)
295 __THROW __attribute_pure__
;
298 /* Compare N wide characters of S1 and S2. */
299 extern int wmemcmp (const wchar_t *__s1
, const wchar_t *__s2
, size_t __n
)
300 __THROW __attribute_pure__
;
302 /* Copy N wide characters of SRC to DEST. */
303 extern wchar_t *wmemcpy (wchar_t *__restrict __s1
,
304 const wchar_t *__restrict __s2
, size_t __n
) __THROW
;
306 /* Copy N wide characters of SRC to DEST, guaranteeing
307 correct behavior for overlapping strings. */
308 extern wchar_t *wmemmove (wchar_t *__s1
, const wchar_t *__s2
, size_t __n
)
311 /* Set N wide characters of S to C. */
312 extern wchar_t *wmemset (wchar_t *__s
, wchar_t __c
, size_t __n
) __THROW
;
315 /* Copy N wide characters of SRC to DEST and return pointer to following
317 extern wchar_t *wmempcpy (wchar_t *__restrict __s1
,
318 const wchar_t *__restrict __s2
, size_t __n
)
323 /* Determine whether C constitutes a valid (one-byte) multibyte
325 extern wint_t btowc (int __c
) __THROW
;
327 /* Determine whether C corresponds to a member of the extended
328 character set whose multibyte representation is a single byte. */
329 extern int wctob (wint_t __c
) __THROW
;
331 /* Determine whether PS points to an object representing the initial
333 extern int mbsinit (const mbstate_t *__ps
) __THROW __attribute_pure__
;
335 /* Write wide character representation of multibyte character pointed
337 extern size_t mbrtowc (wchar_t *__restrict __pwc
,
338 const char *__restrict __s
, size_t __n
,
339 mbstate_t *__restrict __p
) __THROW
;
341 /* Write multibyte representation of wide character WC to S. */
342 extern size_t wcrtomb (char *__restrict __s
, wchar_t __wc
,
343 mbstate_t *__restrict __ps
) __THROW
;
345 /* Return number of bytes in multibyte character pointed to by S. */
346 extern size_t __mbrlen (const char *__restrict __s
, size_t __n
,
347 mbstate_t *__restrict __ps
) __THROW
;
348 extern size_t mbrlen (const char *__restrict __s
, size_t __n
,
349 mbstate_t *__restrict __ps
) __THROW
;
351 #ifdef __USE_EXTERN_INLINES
352 /* Define inline function as optimization. */
354 /* We can use the BTOWC and WCTOB optimizations since we know that all
355 locales must use ASCII encoding for the values in the ASCII range
356 and because the wchar_t encoding is always ISO 10646. */
357 extern wint_t __btowc_alias (int __c
) __asm ("btowc");
358 __extern_inline
wint_t
359 __NTH (btowc (int __c
))
360 { return (__builtin_constant_p (__c
) && __c
>= '\0' && __c
<= '\x7f'
361 ? (wint_t) __c
: __btowc_alias (__c
)); }
363 extern int __wctob_alias (wint_t __c
) __asm ("wctob");
365 __NTH (wctob (wint_t __wc
))
366 { return (__builtin_constant_p (__wc
) && __wc
>= L
'\0' && __wc
<= L
'\x7f'
367 ? (int) __wc
: __wctob_alias (__wc
)); }
369 __extern_inline
size_t
370 __NTH (mbrlen (const char *__restrict __s
, size_t __n
,
371 mbstate_t *__restrict __ps
))
372 { return (__ps
!= NULL
373 ? mbrtowc (NULL
, __s
, __n
, __ps
) : __mbrlen (__s
, __n
, NULL
)); }
376 /* Write wide character representation of multibyte character string
378 extern size_t mbsrtowcs (wchar_t *__restrict __dst
,
379 const char **__restrict __src
, size_t __len
,
380 mbstate_t *__restrict __ps
) __THROW
;
382 /* Write multibyte character representation of wide character string
384 extern size_t wcsrtombs (char *__restrict __dst
,
385 const wchar_t **__restrict __src
, size_t __len
,
386 mbstate_t *__restrict __ps
) __THROW
;
389 #ifdef __USE_XOPEN2K8
390 /* Write wide character representation of at most NMC bytes of the
391 multibyte character string SRC to DST. */
392 extern size_t mbsnrtowcs (wchar_t *__restrict __dst
,
393 const char **__restrict __src
, size_t __nmc
,
394 size_t __len
, mbstate_t *__restrict __ps
) __THROW
;
396 /* Write multibyte character representation of at most NWC characters
397 from the wide character string SRC to DST. */
398 extern size_t wcsnrtombs (char *__restrict __dst
,
399 const wchar_t **__restrict __src
,
400 size_t __nwc
, size_t __len
,
401 mbstate_t *__restrict __ps
) __THROW
;
402 #endif /* use POSIX 2008 */
405 /* The following functions are extensions found in X/Open CAE. */
407 /* Determine number of column positions required for C. */
408 extern int wcwidth (wchar_t __c
) __THROW
;
410 /* Determine number of column positions required for first N wide
411 characters (or fewer if S ends before this) in S. */
412 extern int wcswidth (const wchar_t *__s
, size_t __n
) __THROW
;
413 #endif /* Use X/Open. */
416 /* Convert initial portion of the wide string NPTR to `double'
418 extern double wcstod (const wchar_t *__restrict __nptr
,
419 wchar_t **__restrict __endptr
) __THROW
;
422 /* Likewise for `float' and `long double' sizes of floating-point numbers. */
423 extern float wcstof (const wchar_t *__restrict __nptr
,
424 wchar_t **__restrict __endptr
) __THROW
;
425 extern long double wcstold (const wchar_t *__restrict __nptr
,
426 wchar_t **__restrict __endptr
) __THROW
;
430 /* Convert initial portion of wide string NPTR to `long int'
432 extern long int wcstol (const wchar_t *__restrict __nptr
,
433 wchar_t **__restrict __endptr
, int __base
) __THROW
;
435 /* Convert initial portion of wide string NPTR to `unsigned long int'
437 extern unsigned long int wcstoul (const wchar_t *__restrict __nptr
,
438 wchar_t **__restrict __endptr
, int __base
)
442 /* Convert initial portion of wide string NPTR to `long long int'
445 extern long long int wcstoll (const wchar_t *__restrict __nptr
,
446 wchar_t **__restrict __endptr
, int __base
)
449 /* Convert initial portion of wide string NPTR to `unsigned long long int'
452 extern unsigned long long int wcstoull (const wchar_t *__restrict __nptr
,
453 wchar_t **__restrict __endptr
,
455 #endif /* ISO C99. */
458 /* Convert initial portion of wide string NPTR to `long long int'
461 extern long long int wcstoq (const wchar_t *__restrict __nptr
,
462 wchar_t **__restrict __endptr
, int __base
)
465 /* Convert initial portion of wide string NPTR to `unsigned long long int'
468 extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr
,
469 wchar_t **__restrict __endptr
,
471 #endif /* Use GNU. */
474 /* The concept of one static locale per category is not very well
475 thought out. Many applications will need to process its data using
476 information from several different locales. Another application is
477 the implementation of the internationalization handling in the
478 upcoming ISO C++ standard library. To support this another set of
479 the functions using locale data exist which have an additional
482 Attention: all these functions are *not* standardized in any form.
483 This is a proof-of-concept implementation. */
485 /* Structure for reentrant locale using functions. This is an
486 (almost) opaque type for the user level programs. */
487 # include <xlocale.h>
489 /* Special versions of the functions above which take the locale to
490 use as an additional parameter. */
491 extern long int wcstol_l (const wchar_t *__restrict __nptr
,
492 wchar_t **__restrict __endptr
, int __base
,
493 __locale_t __loc
) __THROW
;
495 extern unsigned long int wcstoul_l (const wchar_t *__restrict __nptr
,
496 wchar_t **__restrict __endptr
,
497 int __base
, __locale_t __loc
) __THROW
;
500 extern long long int wcstoll_l (const wchar_t *__restrict __nptr
,
501 wchar_t **__restrict __endptr
,
502 int __base
, __locale_t __loc
) __THROW
;
505 extern unsigned long long int wcstoull_l (const wchar_t *__restrict __nptr
,
506 wchar_t **__restrict __endptr
,
507 int __base
, __locale_t __loc
)
510 extern double wcstod_l (const wchar_t *__restrict __nptr
,
511 wchar_t **__restrict __endptr
, __locale_t __loc
)
514 extern float wcstof_l (const wchar_t *__restrict __nptr
,
515 wchar_t **__restrict __endptr
, __locale_t __loc
)
518 extern long double wcstold_l (const wchar_t *__restrict __nptr
,
519 wchar_t **__restrict __endptr
,
520 __locale_t __loc
) __THROW
;
524 #ifdef __USE_XOPEN2K8
525 /* Copy SRC to DEST, returning the address of the terminating L'\0' in
527 extern wchar_t *wcpcpy (wchar_t *__restrict __dest
,
528 const wchar_t *__restrict __src
) __THROW
;
530 /* Copy no more than N characters of SRC to DEST, returning the address of
531 the last character written into DEST. */
532 extern wchar_t *wcpncpy (wchar_t *__restrict __dest
,
533 const wchar_t *__restrict __src
, size_t __n
)
538 /* Wide character I/O functions. */
540 #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
541 /* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces
542 a wide character string. */
543 extern __FILE
*open_wmemstream (wchar_t **__bufloc
, size_t *__sizeloc
) __THROW
;
546 #if defined __USE_ISOC95 || defined __USE_UNIX98
548 /* Select orientation for stream. */
549 extern int fwide (__FILE
*__fp
, int __mode
) __THROW
;
552 /* Write formatted output to STREAM.
554 This function is a possible cancellation point and therefore not
555 marked with __THROW. */
556 extern int fwprintf (__FILE
*__restrict __stream
,
557 const wchar_t *__restrict __format
, ...)
558 /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
559 /* Write formatted output to stdout.
561 This function is a possible cancellation point and therefore not
562 marked with __THROW. */
563 extern int wprintf (const wchar_t *__restrict __format
, ...)
564 /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */;
565 /* Write formatted output of at most N characters to S. */
566 extern int swprintf (wchar_t *__restrict __s
, size_t __n
,
567 const wchar_t *__restrict __format
, ...)
568 __THROW
/* __attribute__ ((__format__ (__wprintf__, 3, 4))) */;
570 /* Write formatted output to S from argument list ARG.
572 This function is a possible cancellation point and therefore not
573 marked with __THROW. */
574 extern int vfwprintf (__FILE
*__restrict __s
,
575 const wchar_t *__restrict __format
,
576 __gnuc_va_list __arg
)
577 /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
578 /* Write formatted output to stdout from argument list ARG.
580 This function is a possible cancellation point and therefore not
581 marked with __THROW. */
582 extern int vwprintf (const wchar_t *__restrict __format
,
583 __gnuc_va_list __arg
)
584 /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */;
585 /* Write formatted output of at most N character to S from argument
587 extern int vswprintf (wchar_t *__restrict __s
, size_t __n
,
588 const wchar_t *__restrict __format
,
589 __gnuc_va_list __arg
)
590 __THROW
/* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
593 /* Read formatted input from STREAM.
595 This function is a possible cancellation point and therefore not
596 marked with __THROW. */
597 extern int fwscanf (__FILE
*__restrict __stream
,
598 const wchar_t *__restrict __format
, ...)
599 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
600 /* Read formatted input from stdin.
602 This function is a possible cancellation point and therefore not
603 marked with __THROW. */
604 extern int wscanf (const wchar_t *__restrict __format
, ...)
605 /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
606 /* Read formatted input from S. */
607 extern int swscanf (const wchar_t *__restrict __s
,
608 const wchar_t *__restrict __format
, ...)
609 __THROW
/* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
611 # if defined __USE_ISOC99 && !defined __USE_GNU \
612 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
613 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
615 /* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
616 GNU extension which conflicts with valid %a followed by letter
618 extern int __REDIRECT (fwscanf
, (__FILE
*__restrict __stream
,
619 const wchar_t *__restrict __format
, ...),
621 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
622 extern int __REDIRECT (wscanf
, (const wchar_t *__restrict __format
, ...),
624 /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
625 extern int __REDIRECT_NTH (swscanf
, (const wchar_t *__restrict __s
,
626 const wchar_t *__restrict __format
,
627 ...), __isoc99_swscanf
)
628 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
630 extern int __isoc99_fwscanf (__FILE
*__restrict __stream
,
631 const wchar_t *__restrict __format
, ...);
632 extern int __isoc99_wscanf (const wchar_t *__restrict __format
, ...);
633 extern int __isoc99_swscanf (const wchar_t *__restrict __s
,
634 const wchar_t *__restrict __format
, ...)
636 # define fwscanf __isoc99_fwscanf
637 # define wscanf __isoc99_wscanf
638 # define swscanf __isoc99_swscanf
642 #endif /* Use ISO C95, C99 and Unix98. */
645 /* Read formatted input from S into argument list ARG.
647 This function is a possible cancellation point and therefore not
648 marked with __THROW. */
649 extern int vfwscanf (__FILE
*__restrict __s
,
650 const wchar_t *__restrict __format
,
651 __gnuc_va_list __arg
)
652 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
653 /* Read formatted input from stdin into argument list ARG.
655 This function is a possible cancellation point and therefore not
656 marked with __THROW. */
657 extern int vwscanf (const wchar_t *__restrict __format
,
658 __gnuc_va_list __arg
)
659 /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
660 /* Read formatted input from S into argument list ARG. */
661 extern int vswscanf (const wchar_t *__restrict __s
,
662 const wchar_t *__restrict __format
,
663 __gnuc_va_list __arg
)
664 __THROW
/* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
666 # if !defined __USE_GNU \
667 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
668 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
670 extern int __REDIRECT (vfwscanf
, (__FILE
*__restrict __s
,
671 const wchar_t *__restrict __format
,
672 __gnuc_va_list __arg
), __isoc99_vfwscanf
)
673 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
674 extern int __REDIRECT (vwscanf
, (const wchar_t *__restrict __format
,
675 __gnuc_va_list __arg
), __isoc99_vwscanf
)
676 /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
677 extern int __REDIRECT_NTH (vswscanf
, (const wchar_t *__restrict __s
,
678 const wchar_t *__restrict __format
,
679 __gnuc_va_list __arg
), __isoc99_vswscanf
)
680 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
682 extern int __isoc99_vfwscanf (__FILE
*__restrict __s
,
683 const wchar_t *__restrict __format
,
684 __gnuc_va_list __arg
);
685 extern int __isoc99_vwscanf (const wchar_t *__restrict __format
,
686 __gnuc_va_list __arg
);
687 extern int __isoc99_vswscanf (const wchar_t *__restrict __s
,
688 const wchar_t *__restrict __format
,
689 __gnuc_va_list __arg
) __THROW
;
690 # define vfwscanf __isoc99_vfwscanf
691 # define vwscanf __isoc99_vwscanf
692 # define vswscanf __isoc99_vswscanf
696 #endif /* Use ISO C99. */
699 /* Read a character from STREAM.
701 These functions are possible cancellation points and therefore not
702 marked with __THROW. */
703 extern wint_t fgetwc (__FILE
*__stream
);
704 extern wint_t getwc (__FILE
*__stream
);
706 /* Read a character from stdin.
708 This function is a possible cancellation point and therefore not
709 marked with __THROW. */
710 extern wint_t getwchar (void);
713 /* Write a character to STREAM.
715 These functions are possible cancellation points and therefore not
716 marked with __THROW. */
717 extern wint_t fputwc (wchar_t __wc
, __FILE
*__stream
);
718 extern wint_t putwc (wchar_t __wc
, __FILE
*__stream
);
720 /* Write a character to stdout.
722 This function is a possible cancellation point and therefore not
723 marked with __THROW. */
724 extern wint_t putwchar (wchar_t __wc
);
727 /* Get a newline-terminated wide character string of finite length
730 This function is a possible cancellation point and therefore not
731 marked with __THROW. */
732 extern wchar_t *fgetws (wchar_t *__restrict __ws
, int __n
,
733 __FILE
*__restrict __stream
);
735 /* Write a string to STREAM.
737 This function is a possible cancellation point and therefore not
738 marked with __THROW. */
739 extern int fputws (const wchar_t *__restrict __ws
,
740 __FILE
*__restrict __stream
);
743 /* Push a character back onto the input buffer of STREAM.
745 This function is a possible cancellation point and therefore not
746 marked with __THROW. */
747 extern wint_t ungetwc (wint_t __wc
, __FILE
*__stream
);
751 /* These are defined to be equivalent to the `char' functions defined
754 These functions are not part of POSIX and therefore no official
755 cancellation point. But due to similarity with an POSIX interface
756 or due to the implementation they are cancellation points and
757 therefore not marked with __THROW. */
758 extern wint_t getwc_unlocked (__FILE
*__stream
);
759 extern wint_t getwchar_unlocked (void);
761 /* This is the wide character version of a GNU extension.
763 This function is not part of POSIX and therefore no official
764 cancellation point. But due to similarity with an POSIX interface
765 or due to the implementation it is a cancellation point and
766 therefore not marked with __THROW. */
767 extern wint_t fgetwc_unlocked (__FILE
*__stream
);
769 /* Faster version when locking is not necessary.
771 This function is not part of POSIX and therefore no official
772 cancellation point. But due to similarity with an POSIX interface
773 or due to the implementation it is a cancellation point and
774 therefore not marked with __THROW. */
775 extern wint_t fputwc_unlocked (wchar_t __wc
, __FILE
*__stream
);
777 /* These are defined to be equivalent to the `char' functions defined
780 These functions are not part of POSIX and therefore no official
781 cancellation point. But due to similarity with an POSIX interface
782 or due to the implementation they are cancellation points and
783 therefore not marked with __THROW. */
784 extern wint_t putwc_unlocked (wchar_t __wc
, __FILE
*__stream
);
785 extern wint_t putwchar_unlocked (wchar_t __wc
);
788 /* This function does the same as `fgetws' but does not lock the stream.
790 This function is not part of POSIX and therefore no official
791 cancellation point. But due to similarity with an POSIX interface
792 or due to the implementation it is a cancellation point and
793 therefore not marked with __THROW. */
794 extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws
, int __n
,
795 __FILE
*__restrict __stream
);
797 /* This function does the same as `fputws' but does not lock the stream.
799 This function is 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 it is a cancellation point and
802 therefore not marked with __THROW. */
803 extern int fputws_unlocked (const wchar_t *__restrict __ws
,
804 __FILE
*__restrict __stream
);
808 /* Format TP into S according to FORMAT.
809 Write no more than MAXSIZE wide characters and return the number
810 of wide characters written, or 0 if it would exceed MAXSIZE. */
811 extern size_t wcsftime (wchar_t *__restrict __s
, size_t __maxsize
,
812 const wchar_t *__restrict __format
,
813 const struct tm
*__restrict __tp
) __THROW
;
816 # include <xlocale.h>
818 /* Similar to `wcsftime' but takes the information from
819 the provided locale and not the global locale. */
820 extern size_t wcsftime_l (wchar_t *__restrict __s
, size_t __maxsize
,
821 const wchar_t *__restrict __format
,
822 const struct tm
*__restrict __tp
,
823 __locale_t __loc
) __THROW
;
826 /* The X/Open standard demands that most of the functions defined in
827 the <wctype.h> header must also appear here. This is probably
828 because some X/Open members wrote their implementation before the
829 ISO C standard was published and introduced the better solution.
830 We have to provide these definitions for compliance reasons but we
831 do this nonsense only if really necessary. */
832 #if defined __USE_UNIX98 && !defined __USE_GNU
833 # define __need_iswxxx
837 /* Define some macros helping to catch buffer overflows. */
838 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
839 # include <bits/wchar2.h>
843 # include <bits/wchar-ldbl.h>
848 #endif /* _WCHAR_H defined */
852 /* Undefine all __need_* constants in case we are included to get those
853 constants but the whole file was already read. */
854 #undef __need_mbstate_t