wctype.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. /* Copyright (C) 1996,97,98,99,2000,01,02 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.25
  16. * Wide character classification and mapping utilities <wctype.h>
  17. */
  18. #ifndef _WCTYPE_H
  19. #include <features.h>
  20. #include <bits/types.h>
  21. #ifndef __UCLIBC_HAS_WCHAR__
  22. #error Attempted to include wctype.h when uClibc built without wide char support.
  23. #endif
  24. #ifndef __need_iswxxx
  25. # define _WCTYPE_H 1
  26. /* We try to get wint_t from <stddef.h>, but not all GCC versions define it
  27. there. So define it ourselves if it remains undefined. */
  28. # define __need_wint_t
  29. # include <stddef.h>
  30. # ifndef _WINT_T
  31. /* Integral type unchanged by default argument promotions that can
  32. hold any value corresponding to members of the extended character
  33. set, as well as at least one value that does not correspond to any
  34. member of the extended character set. */
  35. # define _WINT_T
  36. typedef unsigned int wint_t;
  37. # else
  38. # ifdef __USE_ISOC99
  39. __USING_NAMESPACE_C99(wint_t)
  40. # endif
  41. # endif
  42. /* Constant expression of type `wint_t' whose value does not correspond
  43. to any member of the extended character set. */
  44. # ifndef WEOF
  45. # define WEOF (0xffffffffu)
  46. # endif
  47. #endif
  48. #undef __need_iswxxx
  49. /* The following part is also used in the <wcsmbs.h> header when compiled
  50. in the Unix98 compatibility mode. */
  51. #ifndef __iswxxx_defined
  52. # define __iswxxx_defined 1
  53. __BEGIN_NAMESPACE_C99
  54. /* Scalar type that can hold values which represent locale-specific
  55. character classifications. */
  56. /* uClibc note: glibc uses - typedef unsigned long int wctype_t; */
  57. typedef unsigned int wctype_t;
  58. __END_NAMESPACE_C99
  59. # ifndef _ISwbit
  60. # define _ISwbit(bit) (1 << (bit))
  61. enum
  62. {
  63. __ISwupper = 0, /* UPPERCASE. */
  64. __ISwlower = 1, /* lowercase. */
  65. __ISwalpha = 2, /* Alphabetic. */
  66. __ISwdigit = 3, /* Numeric. */
  67. __ISwxdigit = 4, /* Hexadecimal numeric. */
  68. __ISwspace = 5, /* Whitespace. */
  69. __ISwprint = 6, /* Printing. */
  70. __ISwgraph = 7, /* Graphical. */
  71. __ISwblank = 8, /* Blank (usually SPC and TAB). */
  72. __ISwcntrl = 9, /* Control character. */
  73. __ISwpunct = 10, /* Punctuation. */
  74. __ISwalnum = 11, /* Alphanumeric. */
  75. _ISwupper = _ISwbit (__ISwupper), /* UPPERCASE. */
  76. _ISwlower = _ISwbit (__ISwlower), /* lowercase. */
  77. _ISwalpha = _ISwbit (__ISwalpha), /* Alphabetic. */
  78. _ISwdigit = _ISwbit (__ISwdigit), /* Numeric. */
  79. _ISwxdigit = _ISwbit (__ISwxdigit), /* Hexadecimal numeric. */
  80. _ISwspace = _ISwbit (__ISwspace), /* Whitespace. */
  81. _ISwprint = _ISwbit (__ISwprint), /* Printing. */
  82. _ISwgraph = _ISwbit (__ISwgraph), /* Graphical. */
  83. _ISwblank = _ISwbit (__ISwblank), /* Blank (usually SPC and TAB). */
  84. _ISwcntrl = _ISwbit (__ISwcntrl), /* Control character. */
  85. _ISwpunct = _ISwbit (__ISwpunct), /* Punctuation. */
  86. _ISwalnum = _ISwbit (__ISwalnum) /* Alphanumeric. */
  87. };
  88. # else
  89. # if defined(__UCLIBC_MJN3_ONLY__) && defined(L_iswctype)
  90. #warning remove _ISwbit already defined check?
  91. #error _ISwbit already defined!
  92. # endif
  93. # endif /* Not _ISwbit */
  94. __BEGIN_DECLS
  95. __BEGIN_NAMESPACE_C99
  96. /*
  97. * Wide-character classification functions: 7.15.2.1.
  98. */
  99. /* Test for any wide character for which `iswalpha' or `iswdigit' is
  100. true. */
  101. extern int iswalnum (wint_t __wc) __THROW;
  102. libc_hidden_proto(iswalnum)
  103. /* Test for any wide character for which `iswupper' or 'iswlower' is
  104. true, or any wide character that is one of a locale-specific set of
  105. wide-characters for which none of `iswcntrl', `iswdigit',
  106. `iswpunct', or `iswspace' is true. */
  107. extern int iswalpha (wint_t __wc) __THROW;
  108. /* Test for any control wide character. */
  109. extern int iswcntrl (wint_t __wc) __THROW;
  110. /* Test for any wide character that corresponds to a decimal-digit
  111. character. */
  112. extern int iswdigit (wint_t __wc) __THROW;
  113. /* Test for any wide character for which `iswprint' is true and
  114. `iswspace' is false. */
  115. extern int iswgraph (wint_t __wc) __THROW;
  116. /* Test for any wide character that corresponds to a lowercase letter
  117. or is one of a locale-specific set of wide characters for which
  118. none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
  119. extern int iswlower (wint_t __wc) __THROW;
  120. libc_hidden_proto(iswlower)
  121. /* Test for any printing wide character. */
  122. extern int iswprint (wint_t __wc) __THROW;
  123. /* Test for any printing wide character that is one of a
  124. locale-specific et of wide characters for which neither `iswspace'
  125. nor `iswalnum' is true. */
  126. extern int iswpunct (wint_t __wc) __THROW;
  127. /* Test for any wide character that corresponds to a locale-specific
  128. set of wide characters for which none of `iswalnum', `iswgraph', or
  129. `iswpunct' is true. */
  130. extern int iswspace (wint_t __wc) __THROW;
  131. libc_hidden_proto(iswspace)
  132. /* Test for any wide character that corresponds to an uppercase letter
  133. or is one of a locale-specific set of wide character for which none
  134. of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
  135. extern int iswupper (wint_t __wc) __THROW;
  136. libc_hidden_proto(iswupper)
  137. /* Test for any wide character that corresponds to a hexadecimal-digit
  138. character equivalent to that performed be the functions described
  139. in the previous subclause. */
  140. extern int iswxdigit (wint_t __wc) __THROW;
  141. /* Test for any wide character that corresponds to a standard blank
  142. wide character or a locale-specific set of wide characters for
  143. which `iswalnum' is false. */
  144. # ifdef __USE_ISOC99
  145. extern int iswblank (wint_t __wc) __THROW;
  146. # endif
  147. /*
  148. * Extensible wide-character classification functions: 7.15.2.2.
  149. */
  150. /* Construct value that describes a class of wide characters identified
  151. by the string argument PROPERTY. */
  152. extern wctype_t wctype (const char *__property) __THROW;
  153. libc_hidden_proto(wctype)
  154. /* Determine whether the wide-character WC has the property described by
  155. DESC. */
  156. extern int iswctype (wint_t __wc, wctype_t __desc) __THROW;
  157. libc_hidden_proto(iswctype)
  158. __END_NAMESPACE_C99
  159. /*
  160. * Wide-character case-mapping functions: 7.15.3.1.
  161. */
  162. __BEGIN_NAMESPACE_C99
  163. /* Scalar type that can hold values which represent locale-specific
  164. character mappings. */
  165. /* uClibc note: glibc uses - typedef const __int32_t *wctrans_t; */
  166. typedef unsigned int wctrans_t;
  167. __END_NAMESPACE_C99
  168. #ifdef __USE_GNU
  169. __USING_NAMESPACE_C99(wctrans_t)
  170. #endif
  171. __BEGIN_NAMESPACE_C99
  172. /* Converts an uppercase letter to the corresponding lowercase letter. */
  173. extern wint_t towlower (wint_t __wc) __THROW;
  174. libc_hidden_proto(towlower)
  175. /* Converts an lowercase letter to the corresponding uppercase letter. */
  176. extern wint_t towupper (wint_t __wc) __THROW;
  177. libc_hidden_proto(towupper)
  178. __END_NAMESPACE_C99
  179. __END_DECLS
  180. #endif /* need iswxxx. */
  181. /* The remaining definitions and declarations must not appear in the
  182. <wcsmbs.h> header. */
  183. #ifdef _WCTYPE_H
  184. /*
  185. * Extensible wide-character mapping functions: 7.15.3.2.
  186. */
  187. __BEGIN_DECLS
  188. __BEGIN_NAMESPACE_C99
  189. /* Construct value that describes a mapping between wide characters
  190. identified by the string argument PROPERTY. */
  191. extern wctrans_t wctrans (const char *__property) __THROW;
  192. libc_hidden_proto(wctrans)
  193. /* Map the wide character WC using the mapping described by DESC. */
  194. extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW;
  195. libc_hidden_proto(towctrans)
  196. __END_NAMESPACE_C99
  197. #if defined(__USE_GNU) && defined(__UCLIBC_HAS_XLOCALE__)
  198. /* Declare the interface to extended locale model. */
  199. # include <xlocale.h>
  200. /* Test for any wide character for which `iswalpha' or `iswdigit' is
  201. true. */
  202. extern int iswalnum_l (wint_t __wc, __locale_t __locale) __THROW;
  203. /* Test for any wide character for which `iswupper' or 'iswlower' is
  204. true, or any wide character that is one of a locale-specific set of
  205. wide-characters for which none of `iswcntrl', `iswdigit',
  206. `iswpunct', or `iswspace' is true. */
  207. extern int iswalpha_l (wint_t __wc, __locale_t __locale) __THROW;
  208. /* Test for any control wide character. */
  209. extern int iswcntrl_l (wint_t __wc, __locale_t __locale) __THROW;
  210. /* Test for any wide character that corresponds to a decimal-digit
  211. character. */
  212. extern int iswdigit_l (wint_t __wc, __locale_t __locale) __THROW;
  213. /* Test for any wide character for which `iswprint' is true and
  214. `iswspace' is false. */
  215. extern int iswgraph_l (wint_t __wc, __locale_t __locale) __THROW;
  216. /* Test for any wide character that corresponds to a lowercase letter
  217. or is one of a locale-specific set of wide characters for which
  218. none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
  219. extern int iswlower_l (wint_t __wc, __locale_t __locale) __THROW;
  220. /* Test for any printing wide character. */
  221. extern int iswprint_l (wint_t __wc, __locale_t __locale) __THROW;
  222. /* Test for any printing wide character that is one of a
  223. locale-specific et of wide characters for which neither `iswspace'
  224. nor `iswalnum' is true. */
  225. extern int iswpunct_l (wint_t __wc, __locale_t __locale) __THROW;
  226. /* Test for any wide character that corresponds to a locale-specific
  227. set of wide characters for which none of `iswalnum', `iswgraph', or
  228. `iswpunct' is true. */
  229. extern int iswspace_l (wint_t __wc, __locale_t __locale) __THROW;
  230. libc_hidden_proto(iswspace_l)
  231. /* Test for any wide character that corresponds to an uppercase letter
  232. or is one of a locale-specific set of wide character for which none
  233. of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
  234. extern int iswupper_l (wint_t __wc, __locale_t __locale) __THROW;
  235. /* Test for any wide character that corresponds to a hexadecimal-digit
  236. character equivalent to that performed be the functions described
  237. in the previous subclause. */
  238. extern int iswxdigit_l (wint_t __wc, __locale_t __locale) __THROW;
  239. /* Test for any wide character that corresponds to a standard blank
  240. wide character or a locale-specific set of wide characters for
  241. which `iswalnum' is false. */
  242. extern int iswblank_l (wint_t __wc, __locale_t __locale) __THROW;
  243. /* Construct value that describes a class of wide characters identified
  244. by the string argument PROPERTY. */
  245. extern wctype_t wctype_l (const char *__property, __locale_t __locale)
  246. __THROW;
  247. /* Determine whether the wide-character WC has the property described by
  248. DESC. */
  249. extern int iswctype_l (wint_t __wc, wctype_t __desc, __locale_t __locale)
  250. __THROW;
  251. libc_hidden_proto(iswctype_l)
  252. /*
  253. * Wide-character case-mapping functions.
  254. */
  255. /* Converts an uppercase letter to the corresponding lowercase letter. */
  256. extern wint_t towlower_l (wint_t __wc, __locale_t __locale) __THROW;
  257. libc_hidden_proto(towlower_l)
  258. /* Converts an lowercase letter to the corresponding uppercase letter. */
  259. extern wint_t towupper_l (wint_t __wc, __locale_t __locale) __THROW;
  260. libc_hidden_proto(towupper_l)
  261. /* Construct value that describes a mapping between wide characters
  262. identified by the string argument PROPERTY. */
  263. extern wctrans_t wctrans_l (const char *__property, __locale_t __locale)
  264. __THROW;
  265. /* Map the wide character WC using the mapping described by DESC. */
  266. extern wint_t towctrans_l (wint_t __wc, wctrans_t __desc,
  267. __locale_t __locale) __THROW;
  268. libc_hidden_proto(towctrans_l)
  269. # endif /* Use GNU. */
  270. __END_DECLS
  271. #endif /* __WCTYPE_H defined. */
  272. #endif /* wctype.h */