]>
Commit | Line | Data |
---|---|---|
19bc17a9 | 1 | /* Copyright (C) 1996 Free Software Foundation, Inc. |
ba1ffaa1 | 2 | This file is part of the GNU C Library. |
19bc17a9 | 3 | |
ba1ffaa1 UD |
4 | The GNU C Library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public License as | |
6 | published by the Free Software Foundation; either version 2 of the | |
7 | License, or (at your option) any later version. | |
19bc17a9 | 8 | |
ba1ffaa1 UD |
9 | The GNU C Library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | Library General Public License for more details. | |
19bc17a9 | 13 | |
ba1ffaa1 UD |
14 | You should have received a copy of the GNU Library General Public |
15 | License along with the GNU C Library; see the file COPYING.LIB. If not, | |
16 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
17 | Boston, MA 02111-1307, USA. */ | |
19bc17a9 RM |
18 | |
19 | /* | |
b5791037 | 20 | * ISO C Standard, Amendment 1, 7.15: |
19bc17a9 RM |
21 | * Wide-character classification and mapping utilities <wctype.h> |
22 | */ | |
23 | ||
24 | #ifndef _WCTYPE_H | |
25 | ||
26 | #define _WCTYPE_H 1 | |
27 | #include <features.h> | |
28 | ||
19bc17a9 RM |
29 | __BEGIN_DECLS |
30 | ||
71a40c74 RM |
31 | /* We try to get wint_t from <stddef.h>, but not all GCC versions define it |
32 | there. So define it ourselves if it remains undefined. */ | |
19bc17a9 RM |
33 | #define __need_wint_t |
34 | #include <stddef.h> | |
71a40c74 | 35 | #ifndef _WINT_T |
19bc17a9 RM |
36 | /* Integral type unchanged by default argument promotions that can |
37 | hold any value corresponding to members of the extended character | |
38 | set, as well as at least one value that does not correspond to any | |
39 | member of the extended character set. */ | |
71a40c74 | 40 | #define _WINT_T |
19bc17a9 RM |
41 | typedef unsigned int wint_t; |
42 | #endif | |
43 | ||
44 | /* Scalar type that can hold values which represent locale-specific | |
45 | character mappings. */ | |
ba1ffaa1 | 46 | typedef __const unsigned int *wctrans_t; |
19bc17a9 RM |
47 | |
48 | /* Scalar type that can hold values which represent locale-specific | |
49 | character classifications. */ | |
19bc17a9 | 50 | typedef unsigned long int wctype_t; |
19bc17a9 RM |
51 | |
52 | /* Constant expression of type `wint_t' whose value does not correspond | |
53 | to any member of the extended character set. */ | |
54 | #ifndef WEOF | |
55 | #define WEOF (0xffffffffu) | |
56 | #endif | |
57 | ||
58 | #ifndef _ISbit | |
59 | /* These are all the characteristics of characters. | |
60 | If there get to be more than 16 distinct characteristics, | |
61 | many things must be changed that use `unsigned short int's. | |
62 | ||
63 | The characteristics are stored always in network byte order (big | |
64 | endian). We define the bit value interpretations here dependent on the | |
65 | machine's byte order. */ | |
66 | ||
67 | #include <endian.h> | |
68 | #if __BYTE_ORDER == __BIG_ENDIAN | |
69 | #define _ISbit(bit) (1 << bit) | |
70 | #else /* __BYTE_ORDER == __LITTLE_ENDIAN */ | |
71 | #define _ISbit(bit) (bit < 8 ? ((1 << bit) << 8) : ((1 << bit) >> 8)) | |
72 | #endif | |
73 | ||
74 | enum | |
75 | { | |
76 | _ISupper = _ISbit (0), /* UPPERCASE. */ | |
77 | _ISlower = _ISbit (1), /* lowercase. */ | |
78 | _ISalpha = _ISbit (2), /* Alphabetic. */ | |
79 | _ISdigit = _ISbit (3), /* Numeric. */ | |
80 | _ISxdigit = _ISbit (4), /* Hexadecimal numeric. */ | |
81 | _ISspace = _ISbit (5), /* Whitespace. */ | |
82 | _ISprint = _ISbit (6), /* Printing. */ | |
83 | _ISgraph = _ISbit (7), /* Graphical. */ | |
84 | _ISblank = _ISbit (8), /* Blank (usually SPC and TAB). */ | |
85 | _IScntrl = _ISbit (9), /* Control character. */ | |
86 | _ISpunct = _ISbit (10), /* Punctuation. */ | |
87 | _ISalnum = _ISbit (11) /* Alphanumeric. */ | |
88 | }; | |
89 | #endif /* Not _ISbit */ | |
90 | ||
91 | ||
92 | /* | |
93 | * Wide-character classification functions: 7.15.2.1. | |
94 | */ | |
95 | ||
96 | /* Test for any wide character for which `iswalpha' or `iswdigit' is | |
97 | true. */ | |
ba1ffaa1 | 98 | extern int iswalnum __P ((wint_t __wc)); |
19bc17a9 RM |
99 | |
100 | /* Test for any wide character for which `iswupper' or 'iswlower' is | |
101 | true, or any wide character that is one of a locale-specific set of | |
102 | wide-characters for which none of `iswcntrl', `iswdigit', | |
103 | `iswpunct', or `iswspace' is true. */ | |
ba1ffaa1 | 104 | extern int iswalpha __P ((wint_t __wc)); |
19bc17a9 RM |
105 | |
106 | /* Test for any control wide character. */ | |
ba1ffaa1 | 107 | extern int iswcntrl __P ((wint_t __wc)); |
19bc17a9 RM |
108 | |
109 | /* Test for any wide character that corresponds to a decimal-digit | |
110 | character. */ | |
ba1ffaa1 | 111 | extern int iswdigit __P ((wint_t __wc)); |
19bc17a9 RM |
112 | |
113 | /* Test for any wide character for which `iswprint' is true and | |
114 | `iswspace' is false. */ | |
ba1ffaa1 | 115 | extern int iswgraph __P ((wint_t __wc)); |
19bc17a9 RM |
116 | |
117 | /* Test for any wide character that corresponds to a lowercase letter | |
118 | or is one of a locale-specific set of wide characters for which | |
119 | none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
ba1ffaa1 | 120 | extern int iswlower __P ((wint_t __wc)); |
19bc17a9 RM |
121 | |
122 | /* Test for any printing wide character. */ | |
ba1ffaa1 | 123 | extern int iswprint __P ((wint_t __wc)); |
19bc17a9 RM |
124 | |
125 | /* Test for any printing wide character that is one of a | |
126 | locale-specific et of wide characters for which neither `iswspace' | |
127 | nor `iswalnum' is true. */ | |
ba1ffaa1 | 128 | extern int iswpunct __P ((wint_t __wc)); |
19bc17a9 RM |
129 | |
130 | /* Test for any wide character that corresponds to a locale-specific | |
131 | set of wide characters for which none of `iswalnum', `iswgraph', or | |
132 | `iswpunct' is true. */ | |
ba1ffaa1 | 133 | extern int iswspace __P ((wint_t __wc)); |
19bc17a9 RM |
134 | |
135 | /* Test for any wide character that corresponds to an uppercase letter | |
136 | or is one of a locale-specific set of wide character for which none | |
137 | of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ | |
ba1ffaa1 | 138 | extern int iswupper __P ((wint_t __wc)); |
19bc17a9 RM |
139 | |
140 | /* Test for any wide character that corresponds to a hexadecimal-digit | |
141 | character equivalent to that performed be the functions described | |
142 | in the previous subclause. */ | |
ba1ffaa1 | 143 | extern int iswxdigit __P ((wint_t __wc)); |
19bc17a9 RM |
144 | |
145 | /* | |
146 | * Extensible wide-character classification functions: 7.15.2.2. | |
147 | */ | |
148 | ||
149 | /* Construct value that describes a class of wide characters identified | |
150 | by the string argument PROPERTY. */ | |
ba1ffaa1 | 151 | extern wctype_t wctype __P ((__const char *__property)); |
19bc17a9 RM |
152 | |
153 | /* Determine whether the wide-character WC has the property described by | |
154 | DESC. */ | |
ba1ffaa1 | 155 | extern int iswctype __P ((wint_t __wc, wctype_t __desc)); |
19bc17a9 RM |
156 | |
157 | ||
158 | /* | |
159 | * Wide-character case-mapping functions: 7.15.3.1. | |
160 | */ | |
161 | ||
162 | /* Converts an uppercase letter to the corresponding lowercase letter. */ | |
ba1ffaa1 | 163 | extern wint_t towlower __P ((wint_t __wc)); |
19bc17a9 RM |
164 | |
165 | /* Converts an lowercase letter to the corresponding uppercase letter. */ | |
ba1ffaa1 | 166 | extern wint_t towupper __P ((wint_t __wc)); |
19bc17a9 RM |
167 | |
168 | /* | |
169 | * Extensible wide-character mapping functions: 7.15.3.2. | |
170 | */ | |
171 | ||
172 | /* Construct value that describes a mapping between wide characters | |
173 | identified by the string argument PROPERTY. */ | |
ba1ffaa1 | 174 | extern wctrans_t wctrans __P ((__const char *__property)); |
19bc17a9 RM |
175 | |
176 | /* Map the wide character WC using the mapping described by DESC. */ | |
ba1ffaa1 | 177 | extern wint_t towctrans __P ((wint_t __wc, wctrans_t __desc)); |
19bc17a9 RM |
178 | |
179 | ||
180 | ||
181 | #ifndef __NO_WCTYPE | |
182 | #define iswalnum(wc) iswctype ((wc), _ISalnum) | |
183 | #define iswalpha(wc) iswctype ((wc), _ISalpha) | |
184 | #define iswcntrl(wc) iswctype ((wc), _IScntrl) | |
185 | #define iswdigit(wc) iswctype ((wc), _ISdigit) | |
186 | #define iswlower(wc) iswctype ((wc), _ISlower) | |
187 | #define iswgraph(wc) iswctype ((wc), _ISgraph) | |
188 | #define iswprint(wc) iswctype ((wc), _ISprint) | |
189 | #define iswpunct(wc) iswctype ((wc), _ISpunct) | |
190 | #define iswspace(wc) iswctype ((wc), _ISspace) | |
191 | #define iswupper(wc) iswctype ((wc), _ISupper) | |
192 | #define iswxdigit(wc) iswctype ((wc), _ISxdigit) | |
193 | ||
194 | #ifdef __USE_GNU | |
195 | #define iswblank(wc) iswctype ((wc), _ISblank) | |
196 | #endif | |
197 | ||
198 | /* Pointer to conversion tables. */ | |
199 | extern __const int *__ctype_tolower; /* Case conversions. */ | |
200 | extern __const int *__ctype_toupper; /* Case conversions. */ | |
201 | ||
202 | #define towlower(wc) towctrans (wc, __ctype_tolower) | |
203 | #define towupper(wc) towctrans (wc, __ctype_toupper) | |
204 | ||
205 | #endif /* Not __NO_WCTYPE. */ | |
206 | ||
207 | __END_DECLS | |
208 | ||
209 | #endif /* wctype.h */ |