wchar.h 31 KB

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