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