wchar.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  1. /* Copyright (C) 1995-2021 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. /*
  15. * ISO C99 Standard: 7.24
  16. * Extended multibyte and wide character utilities <wchar.h>
  17. */
  18. #ifndef _WCHAR_H
  19. #define _WCHAR_H 1
  20. #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
  21. #include <bits/libc-header-start.h>
  22. /* Gather machine dependent type support. */
  23. #include <bits/floatn.h>
  24. #define __need_size_t
  25. #define __need_wchar_t
  26. #define __need_NULL
  27. #include <stddef.h>
  28. #define __need___va_list
  29. #include <stdarg.h>
  30. #include <bits/wchar.h>
  31. #include <bits/types/wint_t.h>
  32. #include <bits/types/mbstate_t.h>
  33. #include <bits/types/__FILE.h>
  34. #if defined __USE_UNIX98 || defined __USE_XOPEN2K
  35. # include <bits/types/FILE.h>
  36. #endif
  37. #ifdef __USE_XOPEN2K8
  38. # include <bits/types/locale_t.h>
  39. #endif
  40. /* Tell the caller that we provide correct C++ prototypes. */
  41. #if defined __cplusplus && __GNUC_PREREQ (4, 4)
  42. # define __CORRECT_ISO_CPP_WCHAR_H_PROTO
  43. #endif
  44. #ifndef WCHAR_MIN
  45. /* These constants might also be defined in <inttypes.h>. */
  46. # define WCHAR_MIN __WCHAR_MIN
  47. # define WCHAR_MAX __WCHAR_MAX
  48. #endif
  49. #ifndef WEOF
  50. # define WEOF (0xffffffffu)
  51. #endif
  52. /* All versions of XPG prior to the publication of ISO C99 required
  53. the bulk of <wctype.h>'s declarations to appear in this header
  54. (because <wctype.h> did not exist prior to C99). In POSIX.1-2001
  55. those declarations were marked as XSI extensions; in -2008 they
  56. were additionally marked as obsolescent. _GNU_SOURCE mode
  57. anticipates the removal of these declarations in the next revision
  58. of POSIX. */
  59. #if (defined __USE_XOPEN && !defined __USE_GNU \
  60. && !(defined __USE_XOPEN2K && !defined __USE_XOPEN2KXSI))
  61. # include <bits/wctype-wchar.h>
  62. #endif
  63. __BEGIN_DECLS
  64. /* This incomplete type is defined in <time.h> but needed here because
  65. of `wcsftime'. */
  66. struct tm;
  67. /* Copy SRC to DEST. */
  68. extern wchar_t *wcscpy (wchar_t *__restrict __dest,
  69. const wchar_t *__restrict __src)
  70. __THROW __nonnull ((1, 2));
  71. /* Copy no more than N wide-characters of SRC to DEST. */
  72. extern wchar_t *wcsncpy (wchar_t *__restrict __dest,
  73. const wchar_t *__restrict __src, size_t __n)
  74. __THROW __nonnull ((1, 2));
  75. /* Append SRC onto DEST. */
  76. extern wchar_t *wcscat (wchar_t *__restrict __dest,
  77. const wchar_t *__restrict __src)
  78. __THROW __nonnull ((1, 2));
  79. /* Append no more than N wide-characters of SRC onto DEST. */
  80. extern wchar_t *wcsncat (wchar_t *__restrict __dest,
  81. const wchar_t *__restrict __src, size_t __n)
  82. __THROW __nonnull ((1, 2));
  83. /* Compare S1 and S2. */
  84. extern int wcscmp (const wchar_t *__s1, const wchar_t *__s2)
  85. __THROW __attribute_pure__ __nonnull ((1, 2));
  86. /* Compare N wide-characters of S1 and S2. */
  87. extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
  88. __THROW __attribute_pure__ __nonnull ((1, 2));
  89. #ifdef __USE_XOPEN2K8
  90. /* Compare S1 and S2, ignoring case. */
  91. extern int wcscasecmp (const wchar_t *__s1, const wchar_t *__s2) __THROW;
  92. /* Compare no more than N chars of S1 and S2, ignoring case. */
  93. extern int wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2,
  94. size_t __n) __THROW;
  95. /* Similar to the two functions above but take the information from
  96. the provided locale and not the global locale. */
  97. extern int wcscasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
  98. locale_t __loc) __THROW;
  99. extern int wcsncasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
  100. size_t __n, locale_t __loc) __THROW;
  101. #endif
  102. /* Compare S1 and S2, both interpreted as appropriate to the
  103. LC_COLLATE category of the current locale. */
  104. extern int wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW;
  105. /* Transform S2 into array pointed to by S1 such that if wcscmp is
  106. applied to two transformed strings the result is the as applying
  107. `wcscoll' to the original strings. */
  108. extern size_t wcsxfrm (wchar_t *__restrict __s1,
  109. const wchar_t *__restrict __s2, size_t __n) __THROW;
  110. #ifdef __USE_XOPEN2K8
  111. /* Similar to the two functions above but take the information from
  112. the provided locale and not the global locale. */
  113. /* Compare S1 and S2, both interpreted as appropriate to the
  114. LC_COLLATE category of the given locale. */
  115. extern int wcscoll_l (const wchar_t *__s1, const wchar_t *__s2,
  116. locale_t __loc) __THROW;
  117. /* Transform S2 into array pointed to by S1 such that if wcscmp is
  118. applied to two transformed strings the result is the as applying
  119. `wcscoll' to the original strings. */
  120. extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2,
  121. size_t __n, locale_t __loc) __THROW;
  122. /* Duplicate S, returning an identical malloc'd string. */
  123. extern wchar_t *wcsdup (const wchar_t *__s) __THROW __attribute_malloc__;
  124. #endif
  125. /* Find the first occurrence of WC in WCS. */
  126. #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
  127. extern "C++" wchar_t *wcschr (wchar_t *__wcs, wchar_t __wc)
  128. __THROW __asm ("wcschr") __attribute_pure__;
  129. extern "C++" const wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc)
  130. __THROW __asm ("wcschr") __attribute_pure__;
  131. #else
  132. extern wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc)
  133. __THROW __attribute_pure__;
  134. #endif
  135. /* Find the last occurrence of WC in WCS. */
  136. #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
  137. extern "C++" wchar_t *wcsrchr (wchar_t *__wcs, wchar_t __wc)
  138. __THROW __asm ("wcsrchr") __attribute_pure__;
  139. extern "C++" const wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
  140. __THROW __asm ("wcsrchr") __attribute_pure__;
  141. #else
  142. extern wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
  143. __THROW __attribute_pure__;
  144. #endif
  145. #ifdef __USE_GNU
  146. /* This function is similar to `wcschr'. But it returns a pointer to
  147. the closing NUL wide character in case C is not found in S. */
  148. extern wchar_t *wcschrnul (const wchar_t *__s, wchar_t __wc)
  149. __THROW __attribute_pure__;
  150. #endif
  151. /* Return the length of the initial segmet of WCS which
  152. consists entirely of wide characters not in REJECT. */
  153. extern size_t wcscspn (const wchar_t *__wcs, const wchar_t *__reject)
  154. __THROW __attribute_pure__;
  155. /* Return the length of the initial segmet of WCS which
  156. consists entirely of wide characters in ACCEPT. */
  157. extern size_t wcsspn (const wchar_t *__wcs, const wchar_t *__accept)
  158. __THROW __attribute_pure__;
  159. /* Find the first occurrence in WCS of any character in ACCEPT. */
  160. #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
  161. extern "C++" wchar_t *wcspbrk (wchar_t *__wcs, const wchar_t *__accept)
  162. __THROW __asm ("wcspbrk") __attribute_pure__;
  163. extern "C++" const wchar_t *wcspbrk (const wchar_t *__wcs,
  164. const wchar_t *__accept)
  165. __THROW __asm ("wcspbrk") __attribute_pure__;
  166. #else
  167. extern wchar_t *wcspbrk (const wchar_t *__wcs, const wchar_t *__accept)
  168. __THROW __attribute_pure__;
  169. #endif
  170. /* Find the first occurrence of NEEDLE in HAYSTACK. */
  171. #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
  172. extern "C++" wchar_t *wcsstr (wchar_t *__haystack, const wchar_t *__needle)
  173. __THROW __asm ("wcsstr") __attribute_pure__;
  174. extern "C++" const wchar_t *wcsstr (const wchar_t *__haystack,
  175. const wchar_t *__needle)
  176. __THROW __asm ("wcsstr") __attribute_pure__;
  177. #else
  178. extern wchar_t *wcsstr (const wchar_t *__haystack, const wchar_t *__needle)
  179. __THROW __attribute_pure__;
  180. #endif
  181. /* Divide WCS into tokens separated by characters in DELIM. */
  182. extern wchar_t *wcstok (wchar_t *__restrict __s,
  183. const wchar_t *__restrict __delim,
  184. wchar_t **__restrict __ptr) __THROW;
  185. /* Return the number of wide characters in S. */
  186. extern size_t wcslen (const wchar_t *__s) __THROW __attribute_pure__;
  187. #ifdef __USE_XOPEN
  188. /* Another name for `wcsstr' from XPG4. */
  189. # ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
  190. extern "C++" wchar_t *wcswcs (wchar_t *__haystack, const wchar_t *__needle)
  191. __THROW __asm ("wcswcs") __attribute_pure__;
  192. extern "C++" const wchar_t *wcswcs (const wchar_t *__haystack,
  193. const wchar_t *__needle)
  194. __THROW __asm ("wcswcs") __attribute_pure__;
  195. # else
  196. extern wchar_t *wcswcs (const wchar_t *__haystack, const wchar_t *__needle)
  197. __THROW __attribute_pure__;
  198. # endif
  199. #endif
  200. #ifdef __USE_XOPEN2K8
  201. /* Return the number of wide characters in S, but at most MAXLEN. */
  202. extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen)
  203. __THROW __attribute_pure__;
  204. #endif
  205. /* Search N wide characters of S for C. */
  206. #ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
  207. extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n)
  208. __THROW __asm ("wmemchr") __attribute_pure__;
  209. extern "C++" const wchar_t *wmemchr (const wchar_t *__s, wchar_t __c,
  210. size_t __n)
  211. __THROW __asm ("wmemchr") __attribute_pure__;
  212. #else
  213. extern wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, size_t __n)
  214. __THROW __attribute_pure__;
  215. #endif
  216. /* Compare N wide characters of S1 and S2. */
  217. extern int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
  218. __THROW __attribute_pure__;
  219. /* Copy N wide characters of SRC to DEST. */
  220. extern wchar_t *wmemcpy (wchar_t *__restrict __s1,
  221. const wchar_t *__restrict __s2, size_t __n) __THROW;
  222. /* Copy N wide characters of SRC to DEST, guaranteeing
  223. correct behavior for overlapping strings. */
  224. extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)
  225. __THROW;
  226. /* Set N wide characters of S to C. */
  227. extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW;
  228. #ifdef __USE_GNU
  229. /* Copy N wide characters of SRC to DEST and return pointer to following
  230. wide character. */
  231. extern wchar_t *wmempcpy (wchar_t *__restrict __s1,
  232. const wchar_t *__restrict __s2, size_t __n)
  233. __THROW;
  234. #endif
  235. /* Determine whether C constitutes a valid (one-byte) multibyte
  236. character. */
  237. extern wint_t btowc (int __c) __THROW;
  238. /* Determine whether C corresponds to a member of the extended
  239. character set whose multibyte representation is a single byte. */
  240. extern int wctob (wint_t __c) __THROW;
  241. /* Determine whether PS points to an object representing the initial
  242. state. */
  243. extern int mbsinit (const mbstate_t *__ps) __THROW __attribute_pure__;
  244. /* Write wide character representation of multibyte character pointed
  245. to by S to PWC. */
  246. extern size_t mbrtowc (wchar_t *__restrict __pwc,
  247. const char *__restrict __s, size_t __n,
  248. mbstate_t *__restrict __p) __THROW;
  249. /* Write multibyte representation of wide character WC to S. */
  250. extern size_t wcrtomb (char *__restrict __s, wchar_t __wc,
  251. mbstate_t *__restrict __ps) __THROW;
  252. /* Return number of bytes in multibyte character pointed to by S. */
  253. extern size_t __mbrlen (const char *__restrict __s, size_t __n,
  254. mbstate_t *__restrict __ps) __THROW;
  255. extern size_t mbrlen (const char *__restrict __s, size_t __n,
  256. mbstate_t *__restrict __ps) __THROW;
  257. #ifdef __USE_EXTERN_INLINES
  258. /* Define inline function as optimization. */
  259. /* We can use the BTOWC and WCTOB optimizations since we know that all
  260. locales must use ASCII encoding for the values in the ASCII range
  261. and because the wchar_t encoding is always ISO 10646. */
  262. extern wint_t __btowc_alias (int __c) __asm ("btowc");
  263. __extern_inline wint_t
  264. __NTH (btowc (int __c))
  265. { return (__builtin_constant_p (__c) && __c >= '\0' && __c <= '\x7f'
  266. ? (wint_t) __c : __btowc_alias (__c)); }
  267. extern int __wctob_alias (wint_t __c) __asm ("wctob");
  268. __extern_inline int
  269. __NTH (wctob (wint_t __wc))
  270. { return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <= L'\x7f'
  271. ? (int) __wc : __wctob_alias (__wc)); }
  272. __extern_inline size_t
  273. __NTH (mbrlen (const char *__restrict __s, size_t __n,
  274. mbstate_t *__restrict __ps))
  275. { return (__ps != NULL
  276. ? mbrtowc (NULL, __s, __n, __ps) : __mbrlen (__s, __n, NULL)); }
  277. #endif
  278. /* Write wide character representation of multibyte character string
  279. SRC to DST. */
  280. extern size_t mbsrtowcs (wchar_t *__restrict __dst,
  281. const char **__restrict __src, size_t __len,
  282. mbstate_t *__restrict __ps) __THROW;
  283. /* Write multibyte character representation of wide character string
  284. SRC to DST. */
  285. extern size_t wcsrtombs (char *__restrict __dst,
  286. const wchar_t **__restrict __src, size_t __len,
  287. mbstate_t *__restrict __ps) __THROW;
  288. #ifdef __USE_XOPEN2K8
  289. /* Write wide character representation of at most NMC bytes of the
  290. multibyte character string SRC to DST. */
  291. extern size_t mbsnrtowcs (wchar_t *__restrict __dst,
  292. const char **__restrict __src, size_t __nmc,
  293. size_t __len, mbstate_t *__restrict __ps) __THROW;
  294. /* Write multibyte character representation of at most NWC characters
  295. from the wide character string SRC to DST. */
  296. extern size_t wcsnrtombs (char *__restrict __dst,
  297. const wchar_t **__restrict __src,
  298. size_t __nwc, size_t __len,
  299. mbstate_t *__restrict __ps) __THROW;
  300. #endif /* use POSIX 2008 */
  301. /* The following functions are extensions found in X/Open CAE. */
  302. #ifdef __USE_XOPEN
  303. /* Determine number of column positions required for C. */
  304. extern int wcwidth (wchar_t __c) __THROW;
  305. /* Determine number of column positions required for first N wide
  306. characters (or fewer if S ends before this) in S. */
  307. extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
  308. #endif /* Use X/Open. */
  309. /* Convert initial portion of the wide string NPTR to `double'
  310. representation. */
  311. extern double wcstod (const wchar_t *__restrict __nptr,
  312. wchar_t **__restrict __endptr) __THROW;
  313. #ifdef __USE_ISOC99
  314. /* Likewise for `float' and `long double' sizes of floating-point numbers. */
  315. extern float wcstof (const wchar_t *__restrict __nptr,
  316. wchar_t **__restrict __endptr) __THROW;
  317. extern long double wcstold (const wchar_t *__restrict __nptr,
  318. wchar_t **__restrict __endptr) __THROW;
  319. #endif /* C99 */
  320. /* Likewise for `_FloatN' and `_FloatNx' when support is enabled. */
  321. #if __HAVE_FLOAT16 && defined __USE_GNU
  322. extern _Float16 wcstof16 (const wchar_t *__restrict __nptr,
  323. wchar_t **__restrict __endptr) __THROW;
  324. #endif
  325. #if __HAVE_FLOAT32 && defined __USE_GNU
  326. extern _Float32 wcstof32 (const wchar_t *__restrict __nptr,
  327. wchar_t **__restrict __endptr) __THROW;
  328. #endif
  329. #if __HAVE_FLOAT64 && defined __USE_GNU
  330. extern _Float64 wcstof64 (const wchar_t *__restrict __nptr,
  331. wchar_t **__restrict __endptr) __THROW;
  332. #endif
  333. #if __HAVE_FLOAT128 && defined __USE_GNU
  334. extern _Float128 wcstof128 (const wchar_t *__restrict __nptr,
  335. wchar_t **__restrict __endptr) __THROW;
  336. #endif
  337. #if __HAVE_FLOAT32X && defined __USE_GNU
  338. extern _Float32x wcstof32x (const wchar_t *__restrict __nptr,
  339. wchar_t **__restrict __endptr) __THROW;
  340. #endif
  341. #if __HAVE_FLOAT64X && defined __USE_GNU
  342. extern _Float64x wcstof64x (const wchar_t *__restrict __nptr,
  343. wchar_t **__restrict __endptr) __THROW;
  344. #endif
  345. #if __HAVE_FLOAT128X && defined __USE_GNU
  346. extern _Float128x wcstof128x (const wchar_t *__restrict __nptr,
  347. wchar_t **__restrict __endptr) __THROW;
  348. #endif
  349. /* Convert initial portion of wide string NPTR to `long int'
  350. representation. */
  351. extern long int wcstol (const wchar_t *__restrict __nptr,
  352. wchar_t **__restrict __endptr, int __base) __THROW;
  353. /* Convert initial portion of wide string NPTR to `unsigned long int'
  354. representation. */
  355. extern unsigned long int wcstoul (const wchar_t *__restrict __nptr,
  356. wchar_t **__restrict __endptr, int __base)
  357. __THROW;
  358. #ifdef __USE_ISOC99
  359. /* Convert initial portion of wide string NPTR to `long long int'
  360. representation. */
  361. __extension__
  362. extern long long int wcstoll (const wchar_t *__restrict __nptr,
  363. wchar_t **__restrict __endptr, int __base)
  364. __THROW;
  365. /* Convert initial portion of wide string NPTR to `unsigned long long int'
  366. representation. */
  367. __extension__
  368. extern unsigned long long int wcstoull (const wchar_t *__restrict __nptr,
  369. wchar_t **__restrict __endptr,
  370. int __base) __THROW;
  371. #endif /* ISO C99. */
  372. #ifdef __USE_GNU
  373. /* Convert initial portion of wide string NPTR to `long long int'
  374. representation. */
  375. __extension__
  376. extern long long int wcstoq (const wchar_t *__restrict __nptr,
  377. wchar_t **__restrict __endptr, int __base)
  378. __THROW;
  379. /* Convert initial portion of wide string NPTR to `unsigned long long int'
  380. representation. */
  381. __extension__
  382. extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr,
  383. wchar_t **__restrict __endptr,
  384. int __base) __THROW;
  385. #endif /* Use GNU. */
  386. #ifdef __USE_GNU
  387. /* Parallel versions of the functions above which take the locale to
  388. use as an additional parameter. These are GNU extensions inspired
  389. by the POSIX.1-2008 extended locale API. */
  390. extern long int wcstol_l (const wchar_t *__restrict __nptr,
  391. wchar_t **__restrict __endptr, int __base,
  392. locale_t __loc) __THROW;
  393. extern unsigned long int wcstoul_l (const wchar_t *__restrict __nptr,
  394. wchar_t **__restrict __endptr,
  395. int __base, locale_t __loc) __THROW;
  396. __extension__
  397. extern long long int wcstoll_l (const wchar_t *__restrict __nptr,
  398. wchar_t **__restrict __endptr,
  399. int __base, locale_t __loc) __THROW;
  400. __extension__
  401. extern unsigned long long int wcstoull_l (const wchar_t *__restrict __nptr,
  402. wchar_t **__restrict __endptr,
  403. int __base, locale_t __loc)
  404. __THROW;
  405. extern double wcstod_l (const wchar_t *__restrict __nptr,
  406. wchar_t **__restrict __endptr, locale_t __loc)
  407. __THROW;
  408. extern float wcstof_l (const wchar_t *__restrict __nptr,
  409. wchar_t **__restrict __endptr, locale_t __loc)
  410. __THROW;
  411. extern long double wcstold_l (const wchar_t *__restrict __nptr,
  412. wchar_t **__restrict __endptr,
  413. locale_t __loc) __THROW;
  414. # if __HAVE_FLOAT16
  415. extern _Float16 wcstof16_l (const wchar_t *__restrict __nptr,
  416. wchar_t **__restrict __endptr,
  417. locale_t __loc) __THROW;
  418. # endif
  419. # if __HAVE_FLOAT32
  420. extern _Float32 wcstof32_l (const wchar_t *__restrict __nptr,
  421. wchar_t **__restrict __endptr,
  422. locale_t __loc) __THROW;
  423. # endif
  424. # if __HAVE_FLOAT64
  425. extern _Float64 wcstof64_l (const wchar_t *__restrict __nptr,
  426. wchar_t **__restrict __endptr,
  427. locale_t __loc) __THROW;
  428. # endif
  429. # if __HAVE_FLOAT128
  430. extern _Float128 wcstof128_l (const wchar_t *__restrict __nptr,
  431. wchar_t **__restrict __endptr,
  432. locale_t __loc) __THROW;
  433. # endif
  434. # if __HAVE_FLOAT32X
  435. extern _Float32x wcstof32x_l (const wchar_t *__restrict __nptr,
  436. wchar_t **__restrict __endptr,
  437. locale_t __loc) __THROW;
  438. # endif
  439. # if __HAVE_FLOAT64X
  440. extern _Float64x wcstof64x_l (const wchar_t *__restrict __nptr,
  441. wchar_t **__restrict __endptr,
  442. locale_t __loc) __THROW;
  443. # endif
  444. # if __HAVE_FLOAT128X
  445. extern _Float128x wcstof128x_l (const wchar_t *__restrict __nptr,
  446. wchar_t **__restrict __endptr,
  447. locale_t __loc) __THROW;
  448. # endif
  449. #endif /* use GNU */
  450. #ifdef __USE_XOPEN2K8
  451. /* Copy SRC to DEST, returning the address of the terminating L'\0' in
  452. DEST. */
  453. extern wchar_t *wcpcpy (wchar_t *__restrict __dest,
  454. const wchar_t *__restrict __src) __THROW;
  455. /* Copy no more than N characters of SRC to DEST, returning the address of
  456. the last character written into DEST. */
  457. extern wchar_t *wcpncpy (wchar_t *__restrict __dest,
  458. const wchar_t *__restrict __src, size_t __n)
  459. __THROW;
  460. #endif
  461. /* Wide character I/O functions. */
  462. #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
  463. /* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces
  464. a wide character string. */
  465. extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW;
  466. #endif
  467. #if defined __USE_ISOC95 || defined __USE_UNIX98
  468. /* Select orientation for stream. */
  469. extern int fwide (__FILE *__fp, int __mode) __THROW;
  470. /* Write formatted output to STREAM.
  471. This function is a possible cancellation point and therefore not
  472. marked with __THROW. */
  473. extern int fwprintf (__FILE *__restrict __stream,
  474. const wchar_t *__restrict __format, ...)
  475. /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
  476. /* Write formatted output to stdout.
  477. This function is a possible cancellation point and therefore not
  478. marked with __THROW. */
  479. extern int wprintf (const wchar_t *__restrict __format, ...)
  480. /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */;
  481. /* Write formatted output of at most N characters to S. */
  482. extern int swprintf (wchar_t *__restrict __s, size_t __n,
  483. const wchar_t *__restrict __format, ...)
  484. __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */;
  485. /* Write formatted output to S from argument list ARG.
  486. This function is a possible cancellation point and therefore not
  487. marked with __THROW. */
  488. extern int vfwprintf (__FILE *__restrict __s,
  489. const wchar_t *__restrict __format,
  490. __gnuc_va_list __arg)
  491. /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
  492. /* Write formatted output to stdout from argument list ARG.
  493. This function is a possible cancellation point and therefore not
  494. marked with __THROW. */
  495. extern int vwprintf (const wchar_t *__restrict __format,
  496. __gnuc_va_list __arg)
  497. /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */;
  498. /* Write formatted output of at most N character to S from argument
  499. list ARG. */
  500. extern int vswprintf (wchar_t *__restrict __s, size_t __n,
  501. const wchar_t *__restrict __format,
  502. __gnuc_va_list __arg)
  503. __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
  504. /* Read formatted input from STREAM.
  505. This function is a possible cancellation point and therefore not
  506. marked with __THROW. */
  507. extern int fwscanf (__FILE *__restrict __stream,
  508. const wchar_t *__restrict __format, ...)
  509. /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
  510. /* Read formatted input from stdin.
  511. This function is a possible cancellation point and therefore not
  512. marked with __THROW. */
  513. extern int wscanf (const wchar_t *__restrict __format, ...)
  514. /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
  515. /* Read formatted input from S. */
  516. extern int swscanf (const wchar_t *__restrict __s,
  517. const wchar_t *__restrict __format, ...)
  518. __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
  519. /* For historical reasons, the C99-compliant versions of the scanf
  520. functions are at alternative names. When __LDBL_COMPAT or
  521. __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI are in effect, this is handled in
  522. bits/wchar-ldbl.h. */
  523. #if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
  524. && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
  525. # ifdef __REDIRECT
  526. extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream,
  527. const wchar_t *__restrict __format, ...),
  528. __isoc99_fwscanf)
  529. /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
  530. extern int __REDIRECT (wscanf, (const wchar_t *__restrict __format, ...),
  531. __isoc99_wscanf)
  532. /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
  533. extern int __REDIRECT_NTH (swscanf, (const wchar_t *__restrict __s,
  534. const wchar_t *__restrict __format,
  535. ...), __isoc99_swscanf)
  536. /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
  537. # else
  538. extern int __isoc99_fwscanf (__FILE *__restrict __stream,
  539. const wchar_t *__restrict __format, ...);
  540. extern int __isoc99_wscanf (const wchar_t *__restrict __format, ...);
  541. extern int __isoc99_swscanf (const wchar_t *__restrict __s,
  542. const wchar_t *__restrict __format, ...)
  543. __THROW;
  544. # define fwscanf __isoc99_fwscanf
  545. # define wscanf __isoc99_wscanf
  546. # define swscanf __isoc99_swscanf
  547. # endif
  548. # endif
  549. #endif /* Use ISO C95, C99 and Unix98. */
  550. #ifdef __USE_ISOC99
  551. /* Read formatted input from S into argument list ARG.
  552. This function is a possible cancellation point and therefore not
  553. marked with __THROW. */
  554. extern int vfwscanf (__FILE *__restrict __s,
  555. const wchar_t *__restrict __format,
  556. __gnuc_va_list __arg)
  557. /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
  558. /* Read formatted input from stdin into argument list ARG.
  559. This function is a possible cancellation point and therefore not
  560. marked with __THROW. */
  561. extern int vwscanf (const wchar_t *__restrict __format,
  562. __gnuc_va_list __arg)
  563. /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
  564. /* Read formatted input from S into argument list ARG. */
  565. extern int vswscanf (const wchar_t *__restrict __s,
  566. const wchar_t *__restrict __format,
  567. __gnuc_va_list __arg)
  568. __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
  569. /* Same redirection as above for the v*wscanf family. */
  570. # if !__GLIBC_USE (DEPRECATED_SCANF) \
  571. && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
  572. && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) \
  573. && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
  574. # ifdef __REDIRECT
  575. extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
  576. const wchar_t *__restrict __format,
  577. __gnuc_va_list __arg), __isoc99_vfwscanf)
  578. /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
  579. extern int __REDIRECT (vwscanf, (const wchar_t *__restrict __format,
  580. __gnuc_va_list __arg), __isoc99_vwscanf)
  581. /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
  582. extern int __REDIRECT_NTH (vswscanf, (const wchar_t *__restrict __s,
  583. const wchar_t *__restrict __format,
  584. __gnuc_va_list __arg), __isoc99_vswscanf)
  585. /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
  586. # else
  587. extern int __isoc99_vfwscanf (__FILE *__restrict __s,
  588. const wchar_t *__restrict __format,
  589. __gnuc_va_list __arg);
  590. extern int __isoc99_vwscanf (const wchar_t *__restrict __format,
  591. __gnuc_va_list __arg);
  592. extern int __isoc99_vswscanf (const wchar_t *__restrict __s,
  593. const wchar_t *__restrict __format,
  594. __gnuc_va_list __arg) __THROW;
  595. # define vfwscanf __isoc99_vfwscanf
  596. # define vwscanf __isoc99_vwscanf
  597. # define vswscanf __isoc99_vswscanf
  598. # endif
  599. # endif
  600. #endif /* Use ISO C99. */
  601. /* Read a character from STREAM.
  602. These functions are possible cancellation points and therefore not
  603. marked with __THROW. */
  604. extern wint_t fgetwc (__FILE *__stream);
  605. extern wint_t getwc (__FILE *__stream);
  606. /* Read a character from stdin.
  607. This function is a possible cancellation point and therefore not
  608. marked with __THROW. */
  609. extern wint_t getwchar (void);
  610. /* Write a character to STREAM.
  611. These functions are possible cancellation points and therefore not
  612. marked with __THROW. */
  613. extern wint_t fputwc (wchar_t __wc, __FILE *__stream);
  614. extern wint_t putwc (wchar_t __wc, __FILE *__stream);
  615. /* Write a character to stdout.
  616. This function is a possible cancellation point and therefore not
  617. marked with __THROW. */
  618. extern wint_t putwchar (wchar_t __wc);
  619. /* Get a newline-terminated wide character string of finite length
  620. from STREAM.
  621. This function is a possible cancellation point and therefore not
  622. marked with __THROW. */
  623. extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,
  624. __FILE *__restrict __stream);
  625. /* Write a string to STREAM.
  626. This function is a possible cancellation point and therefore not
  627. marked with __THROW. */
  628. extern int fputws (const wchar_t *__restrict __ws,
  629. __FILE *__restrict __stream);
  630. /* Push a character back onto the input buffer of STREAM.
  631. This function is a possible cancellation point and therefore not
  632. marked with __THROW. */
  633. extern wint_t ungetwc (wint_t __wc, __FILE *__stream);
  634. #ifdef __USE_GNU
  635. /* These are defined to be equivalent to the `char' functions defined
  636. in POSIX.1:1996.
  637. These functions are not part of POSIX and therefore no official
  638. cancellation point. But due to similarity with an POSIX interface
  639. or due to the implementation they are cancellation points and
  640. therefore not marked with __THROW. */
  641. extern wint_t getwc_unlocked (__FILE *__stream);
  642. extern wint_t getwchar_unlocked (void);
  643. /* This is the wide character version of a GNU extension.
  644. This function is not part of POSIX and therefore no official
  645. cancellation point. But due to similarity with an POSIX interface
  646. or due to the implementation it is a cancellation point and
  647. therefore not marked with __THROW. */
  648. extern wint_t fgetwc_unlocked (__FILE *__stream);
  649. /* Faster version when locking is not necessary.
  650. This function is not part of POSIX and therefore no official
  651. cancellation point. But due to similarity with an POSIX interface
  652. or due to the implementation it is a cancellation point and
  653. therefore not marked with __THROW. */
  654. extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream);
  655. /* These are defined to be equivalent to the `char' functions defined
  656. in POSIX.1:1996.
  657. These functions are not part of POSIX and therefore no official
  658. cancellation point. But due to similarity with an POSIX interface
  659. or due to the implementation they are cancellation points and
  660. therefore not marked with __THROW. */
  661. extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream);
  662. extern wint_t putwchar_unlocked (wchar_t __wc);
  663. /* This function does the same as `fgetws' but does not lock the stream.
  664. This function is not part of POSIX and therefore no official
  665. cancellation point. But due to similarity with an POSIX interface
  666. or due to the implementation it is a cancellation point and
  667. therefore not marked with __THROW. */
  668. extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n,
  669. __FILE *__restrict __stream);
  670. /* This function does the same as `fputws' but does not lock the stream.
  671. This function is not part of POSIX and therefore no official
  672. cancellation point. But due to similarity with an POSIX interface
  673. or due to the implementation it is a cancellation point and
  674. therefore not marked with __THROW. */
  675. extern int fputws_unlocked (const wchar_t *__restrict __ws,
  676. __FILE *__restrict __stream);
  677. #endif
  678. /* Format TP into S according to FORMAT.
  679. Write no more than MAXSIZE wide characters and return the number
  680. of wide characters written, or 0 if it would exceed MAXSIZE. */
  681. extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
  682. const wchar_t *__restrict __format,
  683. const struct tm *__restrict __tp) __THROW;
  684. # ifdef __USE_GNU
  685. /* Similar to `wcsftime' but takes the information from
  686. the provided locale and not the global locale. */
  687. extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
  688. const wchar_t *__restrict __format,
  689. const struct tm *__restrict __tp,
  690. locale_t __loc) __THROW;
  691. # endif
  692. /* Define some macros helping to catch buffer overflows. */
  693. #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
  694. # include <bits/wchar2.h>
  695. #endif
  696. #include <bits/floatn.h>
  697. #if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
  698. # include <bits/wchar-ldbl.h>
  699. #endif
  700. __END_DECLS
  701. #endif /* wchar.h */