1 /* Copyright (C) 1995-2023 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 <https://www.gnu.org/licenses/>. */
19 * ISO C99 Standard: 7.24
20 * Extended multibyte and wide character utilities <wchar.h>
26 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
27 #include <bits/libc-header-start.h>
29 /* Gather machine dependent type support. */
30 #include <bits/floatn.h>
33 #define __need_wchar_t
37 #define __need___va_list
40 #if defined __USE_XOPEN2K || defined __USE_XOPEN2K8
42 # ifndef _VA_LIST_DEFINED
43 typedef __gnuc_va_list
va_list;
44 # define _VA_LIST_DEFINED
51 #include <bits/wchar.h>
52 #include <bits/types/wint_t.h>
53 #include <bits/types/mbstate_t.h>
54 #include <bits/types/__FILE.h>
56 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
57 # include <bits/types/FILE.h>
60 # include <bits/types/locale_t.h>
63 /* Tell the caller that we provide correct C++ prototypes. */
64 #if defined __cplusplus && __GNUC_PREREQ (4, 4)
65 # define __CORRECT_ISO_CPP_WCHAR_H_PROTO
69 /* These constants might also be defined in <inttypes.h>. */
70 # define WCHAR_MIN __WCHAR_MIN
71 # define WCHAR_MAX __WCHAR_MAX
75 # define WEOF (0xffffffffu)
78 /* All versions of XPG prior to the publication of ISO C99 required
79 the bulk of <wctype.h>'s declarations to appear in this header
80 (because <wctype.h> did not exist prior to C99). In POSIX.1-2001
81 those declarations were marked as XSI extensions; in -2008 they
82 were additionally marked as obsolescent. _GNU_SOURCE mode
83 anticipates the removal of these declarations in the next revision
85 #if (defined __USE_XOPEN && !defined __USE_GNU \
86 && !(defined __USE_XOPEN2K && !defined __USE_XOPEN2KXSI))
87 # include <bits/wctype-wchar.h>
92 /* This incomplete type is defined in <time.h> but needed here because
97 /* Copy SRC to DEST. */
98 extern wchar_t *wcscpy (wchar_t *__restrict __dest
,
99 const wchar_t *__restrict __src
)
100 __THROW
__nonnull ((1, 2));
102 /* Copy no more than N wide-characters of SRC to DEST. */
103 extern wchar_t *wcsncpy (wchar_t *__restrict __dest
,
104 const wchar_t *__restrict __src
, size_t __n
)
105 __THROW
__nonnull ((1, 2));
108 /* Copy at most N - 1 characters from SRC to DEST. */
109 extern size_t wcslcpy (wchar_t *__restrict __dest
,
110 const wchar_t *__restrict __src
, size_t __n
)
111 __THROW
__nonnull ((1, 2)) __attr_access ((__write_only__
, 1, 3));
113 /* Append SRC to DEST, possibly with truncation to keep the total size
115 extern size_t wcslcat (wchar_t *__restrict __dest
,
116 const wchar_t *__restrict __src
, size_t __n
)
117 __THROW
__nonnull ((1, 2)) __attr_access ((__read_write__
, 1, 3));
120 /* Append SRC onto DEST. */
121 extern wchar_t *wcscat (wchar_t *__restrict __dest
,
122 const wchar_t *__restrict __src
)
123 __THROW
__nonnull ((1, 2));
124 /* Append no more than N wide-characters of SRC onto DEST. */
125 extern wchar_t *wcsncat (wchar_t *__restrict __dest
,
126 const wchar_t *__restrict __src
, size_t __n
)
127 __THROW
__nonnull ((1, 2));
129 /* Compare S1 and S2. */
130 extern int wcscmp (const wchar_t *__s1
, const wchar_t *__s2
)
131 __THROW __attribute_pure__
__nonnull ((1, 2));
132 /* Compare N wide-characters of S1 and S2. */
133 extern int wcsncmp (const wchar_t *__s1
, const wchar_t *__s2
, size_t __n
)
134 __THROW __attribute_pure__
__nonnull ((1, 2));
136 #ifdef __USE_XOPEN2K8
137 /* Compare S1 and S2, ignoring case. */
138 extern int wcscasecmp (const wchar_t *__s1
, const wchar_t *__s2
) __THROW
;
140 /* Compare no more than N chars of S1 and S2, ignoring case. */
141 extern int wcsncasecmp (const wchar_t *__s1
, const wchar_t *__s2
,
144 /* Similar to the two functions above but take the information from
145 the provided locale and not the global locale. */
146 extern int wcscasecmp_l (const wchar_t *__s1
, const wchar_t *__s2
,
147 locale_t __loc
) __THROW
;
149 extern int wcsncasecmp_l (const wchar_t *__s1
, const wchar_t *__s2
,
150 size_t __n
, locale_t __loc
) __THROW
;
153 /* Compare S1 and S2, both interpreted as appropriate to the
154 LC_COLLATE category of the current locale. */
155 extern int wcscoll (const wchar_t *__s1
, const wchar_t *__s2
) __THROW
;
156 /* Transform S2 into array pointed to by S1 such that if wcscmp is
157 applied to two transformed strings the result is the as applying
158 `wcscoll' to the original strings. */
159 extern size_t wcsxfrm (wchar_t *__restrict __s1
,
160 const wchar_t *__restrict __s2
, size_t __n
) __THROW
;
162 #ifdef __USE_XOPEN2K8
163 /* Similar to the two functions above but take the information from
164 the provided locale and not the global locale. */
166 /* Compare S1 and S2, both interpreted as appropriate to the
167 LC_COLLATE category of the given locale. */
168 extern int wcscoll_l (const wchar_t *__s1
, const wchar_t *__s2
,
169 locale_t __loc
) __THROW
;
171 /* Transform S2 into array pointed to by S1 such that if wcscmp is
172 applied to two transformed strings the result is the as applying
173 `wcscoll' to the original strings. */
174 extern size_t wcsxfrm_l (wchar_t *__s1
, const wchar_t *__s2
,
175 size_t __n
, locale_t __loc
) __THROW
;
177 /* Duplicate S, returning an identical malloc'd string. */
178 extern wchar_t *wcsdup (const wchar_t *__s
) __THROW
179 __attribute_malloc__ __attr_dealloc_free
;
182 /* Find the first occurrence of WC in WCS. */
183 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
184 extern "C++" wchar_t *wcschr (wchar_t *__wcs
, wchar_t __wc
)
185 __THROW
__asm ("wcschr") __attribute_pure__
;
186 extern "C++" const wchar_t *wcschr (const wchar_t *__wcs
, wchar_t __wc
)
187 __THROW
__asm ("wcschr") __attribute_pure__
;
189 extern wchar_t *wcschr (const wchar_t *__wcs
, wchar_t __wc
)
190 __THROW __attribute_pure__
;
192 /* Find the last occurrence of WC in WCS. */
193 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
194 extern "C++" wchar_t *wcsrchr (wchar_t *__wcs
, wchar_t __wc
)
195 __THROW
__asm ("wcsrchr") __attribute_pure__
;
196 extern "C++" const wchar_t *wcsrchr (const wchar_t *__wcs
, wchar_t __wc
)
197 __THROW
__asm ("wcsrchr") __attribute_pure__
;
199 extern wchar_t *wcsrchr (const wchar_t *__wcs
, wchar_t __wc
)
200 __THROW __attribute_pure__
;
204 /* This function is similar to `wcschr'. But it returns a pointer to
205 the closing NUL wide character in case C is not found in S. */
206 extern wchar_t *wcschrnul (const wchar_t *__s
, wchar_t __wc
)
207 __THROW __attribute_pure__
;
210 /* Return the length of the initial segmet of WCS which
211 consists entirely of wide characters not in REJECT. */
212 extern size_t wcscspn (const wchar_t *__wcs
, const wchar_t *__reject
)
213 __THROW __attribute_pure__
;
214 /* Return the length of the initial segmet of WCS which
215 consists entirely of wide characters in ACCEPT. */
216 extern size_t wcsspn (const wchar_t *__wcs
, const wchar_t *__accept
)
217 __THROW __attribute_pure__
;
218 /* Find the first occurrence in WCS of any character in ACCEPT. */
219 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
220 extern "C++" wchar_t *wcspbrk (wchar_t *__wcs
, const wchar_t *__accept
)
221 __THROW
__asm ("wcspbrk") __attribute_pure__
;
222 extern "C++" const wchar_t *wcspbrk (const wchar_t *__wcs
,
223 const wchar_t *__accept
)
224 __THROW
__asm ("wcspbrk") __attribute_pure__
;
226 extern wchar_t *wcspbrk (const wchar_t *__wcs
, const wchar_t *__accept
)
227 __THROW __attribute_pure__
;
229 /* Find the first occurrence of NEEDLE in HAYSTACK. */
230 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
231 extern "C++" wchar_t *wcsstr (wchar_t *__haystack
, const wchar_t *__needle
)
232 __THROW
__asm ("wcsstr") __attribute_pure__
;
233 extern "C++" const wchar_t *wcsstr (const wchar_t *__haystack
,
234 const wchar_t *__needle
)
235 __THROW
__asm ("wcsstr") __attribute_pure__
;
237 extern wchar_t *wcsstr (const wchar_t *__haystack
, const wchar_t *__needle
)
238 __THROW __attribute_pure__
;
241 /* Divide WCS into tokens separated by characters in DELIM. */
242 extern wchar_t *wcstok (wchar_t *__restrict __s
,
243 const wchar_t *__restrict __delim
,
244 wchar_t **__restrict __ptr
) __THROW
;
246 /* Return the number of wide characters in S. */
247 extern size_t wcslen (const wchar_t *__s
) __THROW __attribute_pure__
;
250 /* Another name for `wcsstr' from XPG4. */
251 # ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
252 extern "C++" wchar_t *wcswcs (wchar_t *__haystack
, const wchar_t *__needle
)
253 __THROW
__asm ("wcswcs") __attribute_pure__
;
254 extern "C++" const wchar_t *wcswcs (const wchar_t *__haystack
,
255 const wchar_t *__needle
)
256 __THROW
__asm ("wcswcs") __attribute_pure__
;
258 extern wchar_t *wcswcs (const wchar_t *__haystack
, const wchar_t *__needle
)
259 __THROW __attribute_pure__
;
263 #ifdef __USE_XOPEN2K8
264 /* Return the number of wide characters in S, but at most MAXLEN. */
265 extern size_t wcsnlen (const wchar_t *__s
, size_t __maxlen
)
266 __THROW __attribute_pure__
;
270 /* Search N wide characters of S for C. */
271 #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
272 extern "C++" wchar_t *wmemchr (wchar_t *__s
, wchar_t __c
, size_t __n
)
273 __THROW
__asm ("wmemchr") __attribute_pure__
;
274 extern "C++" const wchar_t *wmemchr (const wchar_t *__s
, wchar_t __c
,
276 __THROW
__asm ("wmemchr") __attribute_pure__
;
278 extern wchar_t *wmemchr (const wchar_t *__s
, wchar_t __c
, size_t __n
)
279 __THROW __attribute_pure__
;
282 /* Compare N wide characters of S1 and S2. */
283 extern int wmemcmp (const wchar_t *__s1
, const wchar_t *__s2
, size_t __n
)
284 __THROW __attribute_pure__
;
286 /* Copy N wide characters of SRC to DEST. */
287 extern wchar_t *wmemcpy (wchar_t *__restrict __s1
,
288 const wchar_t *__restrict __s2
, size_t __n
) __THROW
;
290 /* Copy N wide characters of SRC to DEST, guaranteeing
291 correct behavior for overlapping strings. */
292 extern wchar_t *wmemmove (wchar_t *__s1
, const wchar_t *__s2
, size_t __n
)
295 /* Set N wide characters of S to C. */
296 extern wchar_t *wmemset (wchar_t *__s
, wchar_t __c
, size_t __n
) __THROW
;
299 /* Copy N wide characters of SRC to DEST and return pointer to following
301 extern wchar_t *wmempcpy (wchar_t *__restrict __s1
,
302 const wchar_t *__restrict __s2
, size_t __n
)
307 /* Determine whether C constitutes a valid (one-byte) multibyte
309 extern wint_t btowc (int __c
) __THROW
;
311 /* Determine whether C corresponds to a member of the extended
312 character set whose multibyte representation is a single byte. */
313 extern int wctob (wint_t __c
) __THROW
;
315 /* Determine whether PS points to an object representing the initial
317 extern int mbsinit (const mbstate_t *__ps
) __THROW __attribute_pure__
;
319 /* Write wide character representation of multibyte character pointed
321 extern size_t mbrtowc (wchar_t *__restrict __pwc
,
322 const char *__restrict __s
, size_t __n
,
323 mbstate_t *__restrict __p
) __THROW
;
325 /* Write multibyte representation of wide character WC to S. */
326 extern size_t wcrtomb (char *__restrict __s
, wchar_t __wc
,
327 mbstate_t *__restrict __ps
) __THROW
;
329 /* Return number of bytes in multibyte character pointed to by S. */
330 extern size_t __mbrlen (const char *__restrict __s
, size_t __n
,
331 mbstate_t *__restrict __ps
) __THROW
;
332 extern size_t mbrlen (const char *__restrict __s
, size_t __n
,
333 mbstate_t *__restrict __ps
) __THROW
;
335 #ifdef __USE_EXTERN_INLINES
336 /* Define inline function as optimization. */
338 /* We can use the BTOWC and WCTOB optimizations since we know that all
339 locales must use ASCII encoding for the values in the ASCII range
340 and because the wchar_t encoding is always ISO 10646. */
341 extern wint_t __btowc_alias (int __c
) __asm ("btowc");
342 __extern_inline
wint_t
343 __NTH (btowc (int __c
))
344 { return (__builtin_constant_p (__c
) && __c
>= '\0' && __c
<= '\x7f'
345 ? (wint_t) __c
: __btowc_alias (__c
)); }
347 extern int __wctob_alias (wint_t __c
) __asm ("wctob");
349 __NTH (wctob (wint_t __wc
))
350 { return (__builtin_constant_p (__wc
) && __wc
>= L
'\0' && __wc
<= L
'\x7f'
351 ? (int) __wc
: __wctob_alias (__wc
)); }
353 __extern_inline
size_t
354 __NTH (mbrlen (const char *__restrict __s
, size_t __n
,
355 mbstate_t *__restrict __ps
))
356 { return (__ps
!= NULL
357 ? mbrtowc (NULL
, __s
, __n
, __ps
) : __mbrlen (__s
, __n
, NULL
)); }
360 /* Write wide character representation of multibyte character string
362 extern size_t mbsrtowcs (wchar_t *__restrict __dst
,
363 const char **__restrict __src
, size_t __len
,
364 mbstate_t *__restrict __ps
) __THROW
;
366 /* Write multibyte character representation of wide character string
368 extern size_t wcsrtombs (char *__restrict __dst
,
369 const wchar_t **__restrict __src
, size_t __len
,
370 mbstate_t *__restrict __ps
) __THROW
;
373 #ifdef __USE_XOPEN2K8
374 /* Write wide character representation of at most NMC bytes of the
375 multibyte character string SRC to DST. */
376 extern size_t mbsnrtowcs (wchar_t *__restrict __dst
,
377 const char **__restrict __src
, size_t __nmc
,
378 size_t __len
, mbstate_t *__restrict __ps
) __THROW
;
380 /* Write multibyte character representation of at most NWC characters
381 from the wide character string SRC to DST. */
382 extern size_t wcsnrtombs (char *__restrict __dst
,
383 const wchar_t **__restrict __src
,
384 size_t __nwc
, size_t __len
,
385 mbstate_t *__restrict __ps
) __THROW
;
386 #endif /* use POSIX 2008 */
389 /* The following functions are extensions found in X/Open CAE. */
391 /* Determine number of column positions required for C. */
392 extern int wcwidth (wchar_t __c
) __THROW
;
394 /* Determine number of column positions required for first N wide
395 characters (or fewer if S ends before this) in S. */
396 extern int wcswidth (const wchar_t *__s
, size_t __n
) __THROW
;
397 #endif /* Use X/Open. */
400 /* Convert initial portion of the wide string NPTR to `double'
402 extern double wcstod (const wchar_t *__restrict __nptr
,
403 wchar_t **__restrict __endptr
) __THROW
;
406 /* Likewise for `float' and `long double' sizes of floating-point numbers. */
407 extern float wcstof (const wchar_t *__restrict __nptr
,
408 wchar_t **__restrict __endptr
) __THROW
;
409 extern long double wcstold (const wchar_t *__restrict __nptr
,
410 wchar_t **__restrict __endptr
) __THROW
;
413 #if __GLIBC_USE (IEC_60559_TYPES_EXT) && __GLIBC_USE (ISOC2X)
414 /* Likewise for `_FloatN' and `_FloatNx' when support is enabled. */
417 extern _Float16
wcstof16 (const wchar_t *__restrict __nptr
,
418 wchar_t **__restrict __endptr
) __THROW
;
422 extern _Float32
wcstof32 (const wchar_t *__restrict __nptr
,
423 wchar_t **__restrict __endptr
) __THROW
;
427 extern _Float64
wcstof64 (const wchar_t *__restrict __nptr
,
428 wchar_t **__restrict __endptr
) __THROW
;
432 extern _Float128
wcstof128 (const wchar_t *__restrict __nptr
,
433 wchar_t **__restrict __endptr
) __THROW
;
437 extern _Float32x
wcstof32x (const wchar_t *__restrict __nptr
,
438 wchar_t **__restrict __endptr
) __THROW
;
442 extern _Float64x
wcstof64x (const wchar_t *__restrict __nptr
,
443 wchar_t **__restrict __endptr
) __THROW
;
446 # if __HAVE_FLOAT128X
447 extern _Float128x
wcstof128x (const wchar_t *__restrict __nptr
,
448 wchar_t **__restrict __endptr
) __THROW
;
450 #endif /* __GLIBC_USE (IEC_60559_TYPES_EXT) && __GLIBC_USE (ISOC2X) */
453 /* Convert initial portion of wide string NPTR to `long int'
455 extern long int wcstol (const wchar_t *__restrict __nptr
,
456 wchar_t **__restrict __endptr
, int __base
) __THROW
;
458 /* Convert initial portion of wide string NPTR to `unsigned long int'
460 extern unsigned long int wcstoul (const wchar_t *__restrict __nptr
,
461 wchar_t **__restrict __endptr
, int __base
)
465 /* Convert initial portion of wide string NPTR to `long long int'
468 extern long long int wcstoll (const wchar_t *__restrict __nptr
,
469 wchar_t **__restrict __endptr
, int __base
)
472 /* Convert initial portion of wide string NPTR to `unsigned long long int'
475 extern unsigned long long int wcstoull (const wchar_t *__restrict __nptr
,
476 wchar_t **__restrict __endptr
,
478 #endif /* ISO C99. */
481 /* Convert initial portion of wide string NPTR to `long long int'
484 extern long long int wcstoq (const wchar_t *__restrict __nptr
,
485 wchar_t **__restrict __endptr
, int __base
)
488 /* Convert initial portion of wide string NPTR to `unsigned long long int'
491 extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr
,
492 wchar_t **__restrict __endptr
,
494 #endif /* Use GNU. */
496 /* Versions of the above functions that handle '0b' and '0B' prefixes
498 #if __GLIBC_USE (C2X_STRTOL)
500 extern long int __REDIRECT_NTH (wcstol
, (const wchar_t *__restrict __nptr
,
501 wchar_t **__restrict __endptr
,
502 int __base
), __isoc23_wcstol
);
503 extern unsigned long int __REDIRECT_NTH (wcstoul
,
504 (const wchar_t *__restrict __nptr
,
505 wchar_t **__restrict __endptr
,
506 int __base
), __isoc23_wcstoul
);
508 extern long long int __REDIRECT_NTH (wcstoll
,
509 (const wchar_t *__restrict __nptr
,
510 wchar_t **__restrict __endptr
,
511 int __base
), __isoc23_wcstoll
);
513 extern unsigned long long int __REDIRECT_NTH (wcstoull
,
514 (const wchar_t *__restrict __nptr
,
515 wchar_t **__restrict __endptr
,
516 int __base
), __isoc23_wcstoull
);
519 extern long long int __REDIRECT_NTH (wcstoq
, (const wchar_t *__restrict __nptr
,
520 wchar_t **__restrict __endptr
,
521 int __base
), __isoc23_wcstoll
);
523 extern unsigned long long int __REDIRECT_NTH (wcstouq
,
524 (const wchar_t *__restrict __nptr
,
525 wchar_t **__restrict __endptr
,
526 int __base
), __isoc23_wcstoull
);
529 extern long int __isoc23_wcstol (const wchar_t *__restrict __nptr
,
530 wchar_t **__restrict __endptr
, int __base
)
532 extern unsigned long int __isoc23_wcstoul (const wchar_t *__restrict __nptr
,
533 wchar_t **__restrict __endptr
,
537 extern long long int __isoc23_wcstoll (const wchar_t *__restrict __nptr
,
538 wchar_t **__restrict __endptr
,
542 extern unsigned long long int __isoc23_wcstoull (const wchar_t *__restrict __nptr
,
543 wchar_t **__restrict __endptr
,
546 # define wcstol __isoc23_wcstol
547 # define wcstoul __isoc23_wcstoul
548 # define wcstoll __isoc23_wcstoll
549 # define wcstoull __isoc23_wcstoull
551 # define wcstoq __isoc23_wcstoll
552 # define wcstouq __isoc23_wcstoull
558 /* Parallel versions of the functions above which take the locale to
559 use as an additional parameter. These are GNU extensions inspired
560 by the POSIX.1-2008 extended locale API. */
561 extern long int wcstol_l (const wchar_t *__restrict __nptr
,
562 wchar_t **__restrict __endptr
, int __base
,
563 locale_t __loc
) __THROW
;
565 extern unsigned long int wcstoul_l (const wchar_t *__restrict __nptr
,
566 wchar_t **__restrict __endptr
,
567 int __base
, locale_t __loc
) __THROW
;
570 extern long long int wcstoll_l (const wchar_t *__restrict __nptr
,
571 wchar_t **__restrict __endptr
,
572 int __base
, locale_t __loc
) __THROW
;
575 extern unsigned long long int wcstoull_l (const wchar_t *__restrict __nptr
,
576 wchar_t **__restrict __endptr
,
577 int __base
, locale_t __loc
)
580 /* Versions of the above functions that handle '0b' and '0B' prefixes
582 # if __GLIBC_USE (C2X_STRTOL)
584 extern long int __REDIRECT_NTH (wcstol_l
, (const wchar_t *__restrict __nptr
,
585 wchar_t **__restrict __endptr
,
586 int __base
, locale_t __loc
),
588 extern unsigned long int __REDIRECT_NTH (wcstoul_l
,
589 (const wchar_t *__restrict __nptr
,
590 wchar_t **__restrict __endptr
,
591 int __base
, locale_t __loc
),
594 extern long long int __REDIRECT_NTH (wcstoll_l
,
595 (const wchar_t *__restrict __nptr
,
596 wchar_t **__restrict __endptr
,
597 int __base
, locale_t __loc
),
600 extern unsigned long long int __REDIRECT_NTH (wcstoull_l
,
601 (const wchar_t *__restrict __nptr
,
602 wchar_t **__restrict __endptr
,
603 int __base
, locale_t __loc
),
604 __isoc23_wcstoull_l
);
606 extern long int __isoc23_wcstol_l (const wchar_t *__restrict __nptr
,
607 wchar_t **__restrict __endptr
, int __base
,
608 locale_t __loc
) __THROW
;
609 extern unsigned long int __isoc23_wcstoul_l (const wchar_t *__restrict __nptr
,
610 wchar_t **__restrict __endptr
,
611 int __base
, locale_t __loc
)
614 extern long long int __isoc23_wcstoll_l (const wchar_t *__restrict __nptr
,
615 wchar_t **__restrict __endptr
,
616 int __base
, locale_t __loc
)
619 extern unsigned long long int __isoc23_wcstoull_l (const wchar_t *__restrict __nptr
,
620 wchar_t **__restrict __endptr
,
621 int __base
, locale_t __loc
)
623 # define wcstol_l __isoc23_wcstol_l
624 # define wcstoul_l __isoc23_wcstoul_l
625 # define wcstoll_l __isoc23_wcstoll_l
626 # define wcstoull_l __isoc23_wcstoull_l
630 extern double wcstod_l (const wchar_t *__restrict __nptr
,
631 wchar_t **__restrict __endptr
, locale_t __loc
)
634 extern float wcstof_l (const wchar_t *__restrict __nptr
,
635 wchar_t **__restrict __endptr
, locale_t __loc
)
638 extern long double wcstold_l (const wchar_t *__restrict __nptr
,
639 wchar_t **__restrict __endptr
,
640 locale_t __loc
) __THROW
;
643 extern _Float16
wcstof16_l (const wchar_t *__restrict __nptr
,
644 wchar_t **__restrict __endptr
,
645 locale_t __loc
) __THROW
;
649 extern _Float32
wcstof32_l (const wchar_t *__restrict __nptr
,
650 wchar_t **__restrict __endptr
,
651 locale_t __loc
) __THROW
;
655 extern _Float64
wcstof64_l (const wchar_t *__restrict __nptr
,
656 wchar_t **__restrict __endptr
,
657 locale_t __loc
) __THROW
;
661 extern _Float128
wcstof128_l (const wchar_t *__restrict __nptr
,
662 wchar_t **__restrict __endptr
,
663 locale_t __loc
) __THROW
;
667 extern _Float32x
wcstof32x_l (const wchar_t *__restrict __nptr
,
668 wchar_t **__restrict __endptr
,
669 locale_t __loc
) __THROW
;
673 extern _Float64x
wcstof64x_l (const wchar_t *__restrict __nptr
,
674 wchar_t **__restrict __endptr
,
675 locale_t __loc
) __THROW
;
678 # if __HAVE_FLOAT128X
679 extern _Float128x
wcstof128x_l (const wchar_t *__restrict __nptr
,
680 wchar_t **__restrict __endptr
,
681 locale_t __loc
) __THROW
;
686 #ifdef __USE_XOPEN2K8
687 /* Copy SRC to DEST, returning the address of the terminating L'\0' in
689 extern wchar_t *wcpcpy (wchar_t *__restrict __dest
,
690 const wchar_t *__restrict __src
) __THROW
;
692 /* Copy no more than N characters of SRC to DEST, returning the address of
693 the last character written into DEST. */
694 extern wchar_t *wcpncpy (wchar_t *__restrict __dest
,
695 const wchar_t *__restrict __src
, size_t __n
)
700 /* Wide character I/O functions. */
702 #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
703 # ifndef __attr_dealloc_fclose
704 # if defined __has_builtin
705 # if __has_builtin (__builtin_fclose)
706 /* If the attribute macro hasn't been defined yet (by <stdio.h>) and
707 fclose is a built-in, use it. */
708 # define __attr_dealloc_fclose __attr_dealloc (__builtin_fclose, 1)
712 # ifndef __attr_dealloc_fclose
713 # define __attr_dealloc_fclose /* empty */
716 /* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces
717 a wide character string. */
718 extern __FILE
*open_wmemstream (wchar_t **__bufloc
, size_t *__sizeloc
) __THROW
719 __attribute_malloc__ __attr_dealloc_fclose
;
722 #if defined __USE_ISOC95 || defined __USE_UNIX98
724 /* Select orientation for stream. */
725 extern int fwide (__FILE
*__fp
, int __mode
) __THROW
;
728 /* Write formatted output to STREAM.
730 This function is a possible cancellation point and therefore not
731 marked with __THROW. */
732 extern int fwprintf (__FILE
*__restrict __stream
,
733 const wchar_t *__restrict __format
, ...)
734 /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
735 /* Write formatted output to stdout.
737 This function is a possible cancellation point and therefore not
738 marked with __THROW. */
739 extern int wprintf (const wchar_t *__restrict __format
, ...)
740 /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */;
741 /* Write formatted output of at most N characters to S. */
742 extern int swprintf (wchar_t *__restrict __s
, size_t __n
,
743 const wchar_t *__restrict __format
, ...)
744 __THROW
/* __attribute__ ((__format__ (__wprintf__, 3, 4))) */;
746 /* Write formatted output to S from argument list ARG.
748 This function is a possible cancellation point and therefore not
749 marked with __THROW. */
750 extern int vfwprintf (__FILE
*__restrict __s
,
751 const wchar_t *__restrict __format
,
752 __gnuc_va_list __arg
)
753 /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
754 /* Write formatted output to stdout from argument list ARG.
756 This function is a possible cancellation point and therefore not
757 marked with __THROW. */
758 extern int vwprintf (const wchar_t *__restrict __format
,
759 __gnuc_va_list __arg
)
760 /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */;
761 /* Write formatted output of at most N character to S from argument
763 extern int vswprintf (wchar_t *__restrict __s
, size_t __n
,
764 const wchar_t *__restrict __format
,
765 __gnuc_va_list __arg
)
766 __THROW
/* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
769 /* Read formatted input from STREAM.
771 This function is a possible cancellation point and therefore not
772 marked with __THROW. */
773 extern int fwscanf (__FILE
*__restrict __stream
,
774 const wchar_t *__restrict __format
, ...)
775 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
776 /* Read formatted input from stdin.
778 This function is a possible cancellation point and therefore not
779 marked with __THROW. */
780 extern int wscanf (const wchar_t *__restrict __format
, ...)
781 /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
782 /* Read formatted input from S. */
783 extern int swscanf (const wchar_t *__restrict __s
,
784 const wchar_t *__restrict __format
, ...)
785 __THROW
/* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
787 /* For historical reasons, the C99-compliant versions of the scanf
788 functions are at alternative names. When __LDBL_COMPAT or
789 __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI are in effect, this is handled in
790 bits/wchar-ldbl.h. */
791 # if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
792 && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
793 # if __GLIBC_USE (C2X_STRTOL)
795 extern int __REDIRECT (fwscanf
, (__FILE
*__restrict __stream
,
796 const wchar_t *__restrict __format
, ...),
798 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
799 extern int __REDIRECT (wscanf
, (const wchar_t *__restrict __format
, ...),
801 /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
802 extern int __REDIRECT_NTH (swscanf
, (const wchar_t *__restrict __s
,
803 const wchar_t *__restrict __format
,
804 ...), __isoc23_swscanf
)
805 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
807 extern int __isoc23_fwscanf (__FILE
*__restrict __stream
,
808 const wchar_t *__restrict __format
, ...);
809 extern int __isoc23_wscanf (const wchar_t *__restrict __format
, ...);
810 extern int __isoc23_swscanf (const wchar_t *__restrict __s
,
811 const wchar_t *__restrict __format
, ...)
813 # define fwscanf __isoc23_fwscanf
814 # define wscanf __isoc23_wscanf
815 # define swscanf __isoc23_swscanf
819 extern int __REDIRECT (fwscanf
, (__FILE
*__restrict __stream
,
820 const wchar_t *__restrict __format
, ...),
822 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
823 extern int __REDIRECT (wscanf
, (const wchar_t *__restrict __format
, ...),
825 /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
826 extern int __REDIRECT_NTH (swscanf
, (const wchar_t *__restrict __s
,
827 const wchar_t *__restrict __format
,
828 ...), __isoc99_swscanf
)
829 /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
831 extern int __isoc99_fwscanf (__FILE
*__restrict __stream
,
832 const wchar_t *__restrict __format
, ...);
833 extern int __isoc99_wscanf (const wchar_t *__restrict __format
, ...);
834 extern int __isoc99_swscanf (const wchar_t *__restrict __s
,
835 const wchar_t *__restrict __format
, ...)
837 # define fwscanf __isoc99_fwscanf
838 # define wscanf __isoc99_wscanf
839 # define swscanf __isoc99_swscanf
844 #endif /* Use ISO C95, C99 and Unix98. */
847 /* Read formatted input from S into argument list ARG.
849 This function is a possible cancellation point and therefore not
850 marked with __THROW. */
851 extern int vfwscanf (__FILE
*__restrict __s
,
852 const wchar_t *__restrict __format
,
853 __gnuc_va_list __arg
)
854 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
855 /* Read formatted input from stdin into argument list ARG.
857 This function is a possible cancellation point and therefore not
858 marked with __THROW. */
859 extern int vwscanf (const wchar_t *__restrict __format
,
860 __gnuc_va_list __arg
)
861 /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
862 /* Read formatted input from S into argument list ARG. */
863 extern int vswscanf (const wchar_t *__restrict __s
,
864 const wchar_t *__restrict __format
,
865 __gnuc_va_list __arg
)
866 __THROW
/* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
868 /* Same redirection as above for the v*wscanf family. */
869 # if !__GLIBC_USE (DEPRECATED_SCANF) \
870 && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
871 && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) \
872 && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
873 # if __GLIBC_USE (C2X_STRTOL)
875 extern int __REDIRECT (vfwscanf
, (__FILE
*__restrict __s
,
876 const wchar_t *__restrict __format
,
877 __gnuc_va_list __arg
), __isoc23_vfwscanf
)
878 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
879 extern int __REDIRECT (vwscanf
, (const wchar_t *__restrict __format
,
880 __gnuc_va_list __arg
), __isoc23_vwscanf
)
881 /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
882 extern int __REDIRECT_NTH (vswscanf
, (const wchar_t *__restrict __s
,
883 const wchar_t *__restrict __format
,
884 __gnuc_va_list __arg
), __isoc23_vswscanf
)
885 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
887 extern int __isoc23_vfwscanf (__FILE
*__restrict __s
,
888 const wchar_t *__restrict __format
,
889 __gnuc_va_list __arg
);
890 extern int __isoc23_vwscanf (const wchar_t *__restrict __format
,
891 __gnuc_va_list __arg
);
892 extern int __isoc23_vswscanf (const wchar_t *__restrict __s
,
893 const wchar_t *__restrict __format
,
894 __gnuc_va_list __arg
) __THROW
;
895 # define vfwscanf __isoc23_vfwscanf
896 # define vwscanf __isoc23_vwscanf
897 # define vswscanf __isoc23_vswscanf
901 extern int __REDIRECT (vfwscanf
, (__FILE
*__restrict __s
,
902 const wchar_t *__restrict __format
,
903 __gnuc_va_list __arg
), __isoc99_vfwscanf
)
904 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
905 extern int __REDIRECT (vwscanf
, (const wchar_t *__restrict __format
,
906 __gnuc_va_list __arg
), __isoc99_vwscanf
)
907 /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
908 extern int __REDIRECT_NTH (vswscanf
, (const wchar_t *__restrict __s
,
909 const wchar_t *__restrict __format
,
910 __gnuc_va_list __arg
), __isoc99_vswscanf
)
911 /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
913 extern int __isoc99_vfwscanf (__FILE
*__restrict __s
,
914 const wchar_t *__restrict __format
,
915 __gnuc_va_list __arg
);
916 extern int __isoc99_vwscanf (const wchar_t *__restrict __format
,
917 __gnuc_va_list __arg
);
918 extern int __isoc99_vswscanf (const wchar_t *__restrict __s
,
919 const wchar_t *__restrict __format
,
920 __gnuc_va_list __arg
) __THROW
;
921 # define vfwscanf __isoc99_vfwscanf
922 # define vwscanf __isoc99_vwscanf
923 # define vswscanf __isoc99_vswscanf
928 #endif /* Use ISO C99. */
931 /* Read a character from STREAM.
933 These functions are possible cancellation points and therefore not
934 marked with __THROW. */
935 extern wint_t fgetwc (__FILE
*__stream
);
936 extern wint_t getwc (__FILE
*__stream
);
938 /* Read a character from stdin.
940 This function is a possible cancellation point and therefore not
941 marked with __THROW. */
942 extern wint_t getwchar (void);
945 /* Write a character to STREAM.
947 These functions are possible cancellation points and therefore not
948 marked with __THROW. */
949 extern wint_t fputwc (wchar_t __wc
, __FILE
*__stream
);
950 extern wint_t putwc (wchar_t __wc
, __FILE
*__stream
);
952 /* Write a character to stdout.
954 This function is a possible cancellation point and therefore not
955 marked with __THROW. */
956 extern wint_t putwchar (wchar_t __wc
);
959 /* Get a newline-terminated wide character string of finite length
962 This function is a possible cancellation point and therefore not
963 marked with __THROW. */
964 extern wchar_t *fgetws (wchar_t *__restrict __ws
, int __n
,
965 __FILE
*__restrict __stream
);
967 /* Write a string to STREAM.
969 This function is a possible cancellation point and therefore not
970 marked with __THROW. */
971 extern int fputws (const wchar_t *__restrict __ws
,
972 __FILE
*__restrict __stream
);
975 /* Push a character back onto the input buffer of STREAM.
977 This function is a possible cancellation point and therefore not
978 marked with __THROW. */
979 extern wint_t ungetwc (wint_t __wc
, __FILE
*__stream
);
983 /* These are defined to be equivalent to the `char' functions defined
986 These functions are not part of POSIX and therefore no official
987 cancellation point. But due to similarity with an POSIX interface
988 or due to the implementation they are cancellation points and
989 therefore not marked with __THROW. */
990 extern wint_t getwc_unlocked (__FILE
*__stream
);
991 extern wint_t getwchar_unlocked (void);
993 /* This is the wide character version of a GNU extension.
995 This function is not part of POSIX and therefore no official
996 cancellation point. But due to similarity with an POSIX interface
997 or due to the implementation it is a cancellation point and
998 therefore not marked with __THROW. */
999 extern wint_t fgetwc_unlocked (__FILE
*__stream
);
1001 /* Faster version when locking is not necessary.
1003 This function is not part of POSIX and therefore no official
1004 cancellation point. But due to similarity with an POSIX interface
1005 or due to the implementation it is a cancellation point and
1006 therefore not marked with __THROW. */
1007 extern wint_t fputwc_unlocked (wchar_t __wc
, __FILE
*__stream
);
1009 /* These are defined to be equivalent to the `char' functions defined
1012 These functions are not part of POSIX and therefore no official
1013 cancellation point. But due to similarity with an POSIX interface
1014 or due to the implementation they are cancellation points and
1015 therefore not marked with __THROW. */
1016 extern wint_t putwc_unlocked (wchar_t __wc
, __FILE
*__stream
);
1017 extern wint_t putwchar_unlocked (wchar_t __wc
);
1020 /* This function does the same as `fgetws' but does not lock the stream.
1022 This function is not part of POSIX and therefore no official
1023 cancellation point. But due to similarity with an POSIX interface
1024 or due to the implementation it is a cancellation point and
1025 therefore not marked with __THROW. */
1026 extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws
, int __n
,
1027 __FILE
*__restrict __stream
);
1029 /* This function does the same as `fputws' but does not lock the stream.
1031 This function is not part of POSIX and therefore no official
1032 cancellation point. But due to similarity with an POSIX interface
1033 or due to the implementation it is a cancellation point and
1034 therefore not marked with __THROW. */
1035 extern int fputws_unlocked (const wchar_t *__restrict __ws
,
1036 __FILE
*__restrict __stream
);
1040 /* Format TP into S according to FORMAT.
1041 Write no more than MAXSIZE wide characters and return the number
1042 of wide characters written, or 0 if it would exceed MAXSIZE. */
1043 extern size_t wcsftime (wchar_t *__restrict __s
, size_t __maxsize
,
1044 const wchar_t *__restrict __format
,
1045 const struct tm
*__restrict __tp
) __THROW
;
1048 /* Similar to `wcsftime' but takes the information from
1049 the provided locale and not the global locale. */
1050 extern size_t wcsftime_l (wchar_t *__restrict __s
, size_t __maxsize
,
1051 const wchar_t *__restrict __format
,
1052 const struct tm
*__restrict __tp
,
1053 locale_t __loc
) __THROW
;
1056 /* Define some macros helping to catch buffer overflows. */
1057 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
1058 /* Declare all functions from bits/wchar2-decl.h first. */
1059 # include <bits/wchar2-decl.h>
1062 /* The following headers provide asm redirections. These redirections must
1063 appear before the first usage of these functions, e.g. in bits/wchar.h. */
1064 #if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
1065 # include <bits/wchar-ldbl.h>
1068 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
1069 /* Now include the function definitions and redirects too. */
1070 # include <bits/wchar2.h>
1075 #endif /* wchar.h */