wctype.h 11 KB

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