]>
Commit | Line | Data |
---|---|---|
3d9156a7 A |
1 | /* |
2 | * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | ||
24 | #ifndef _XLOCALE__CTYPE_H_ | |
25 | #define _XLOCALE__CTYPE_H_ | |
26 | ||
224c7076 A |
27 | /* |
28 | * Use inline functions if we are allowed to and the compiler supports them. | |
29 | */ | |
30 | #if !defined(_DONT_USE_CTYPE_INLINE_) && \ | |
31 | (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus)) | |
3d9156a7 A |
32 | |
33 | /* See comments in <machine/_type.h> about __darwin_ct_rune_t. */ | |
34 | __BEGIN_DECLS | |
35 | unsigned long ___runetype_l(__darwin_ct_rune_t, locale_t); | |
36 | __darwin_ct_rune_t ___tolower_l(__darwin_ct_rune_t, locale_t); | |
37 | __darwin_ct_rune_t ___toupper_l(__darwin_ct_rune_t, locale_t); | |
38 | __END_DECLS | |
39 | ||
3d9156a7 A |
40 | //Begin-Libc |
41 | #ifdef __LIBC__ | |
23e20b00 | 42 | __DARWIN_CTYPE_inline int |
3d9156a7 A |
43 | __maskrune_l(__darwin_ct_rune_t _c, unsigned long _f, locale_t _l) |
44 | { | |
23e20b00 A |
45 | /* _CurrentRuneLocale.__runetype is __uint32_t |
46 | * _f is unsigned long | |
47 | * ___runetype_l(_c, _l) is unsigned long | |
48 | * retval is int | |
49 | */ | |
50 | return (int)((_c < 0 || _c >= _CACHED_RUNES) ? (__uint32_t)___runetype_l(_c, _l) : | |
51 | __locale_ptr(_l)->__lc_ctype->_CurrentRuneLocale.__runetype[_c]) & (__uint32_t)_f; | |
3d9156a7 A |
52 | } |
53 | #else /* !__LIBC__ */ | |
54 | //End-Libc | |
55 | __BEGIN_DECLS | |
56 | int __maskrune_l(__darwin_ct_rune_t, unsigned long, locale_t); | |
57 | __END_DECLS | |
58 | //Begin-Libc | |
59 | #endif /* __LIBC__ */ | |
60 | //End-Libc | |
61 | ||
6465356a | 62 | __DARWIN_CTYPE_inline int |
3d9156a7 A |
63 | __istype_l(__darwin_ct_rune_t _c, unsigned long _f, locale_t _l) |
64 | { | |
65 | return !!(isascii(_c) ? (_DefaultRuneLocale.__runetype[_c] & _f) | |
66 | : __maskrune_l(_c, _f, _l)); | |
67 | } | |
68 | ||
6465356a | 69 | __DARWIN_CTYPE_inline __darwin_ct_rune_t |
3d9156a7 A |
70 | __toupper_l(__darwin_ct_rune_t _c, locale_t _l) |
71 | { | |
72 | return isascii(_c) ? _DefaultRuneLocale.__mapupper[_c] | |
73 | : ___toupper_l(_c, _l); | |
74 | } | |
75 | ||
6465356a | 76 | __DARWIN_CTYPE_inline __darwin_ct_rune_t |
3d9156a7 A |
77 | __tolower_l(__darwin_ct_rune_t _c, locale_t _l) |
78 | { | |
79 | return isascii(_c) ? _DefaultRuneLocale.__maplower[_c] | |
80 | : ___tolower_l(_c, _l); | |
81 | } | |
82 | ||
6465356a | 83 | __DARWIN_CTYPE_inline int |
3d9156a7 A |
84 | __wcwidth_l(__darwin_ct_rune_t _c, locale_t _l) |
85 | { | |
86 | unsigned int _x; | |
87 | ||
88 | if (_c == 0) | |
89 | return (0); | |
90 | _x = (unsigned int)__maskrune_l(_c, _CTYPE_SWM|_CTYPE_R, _l); | |
91 | if ((_x & _CTYPE_SWM) != 0) | |
92 | return ((_x & _CTYPE_SWM) >> _CTYPE_SWS); | |
93 | return ((_x & _CTYPE_R) != 0 ? 1 : -1); | |
94 | } | |
95 | ||
224c7076 A |
96 | #ifndef _EXTERNALIZE_CTYPE_INLINES_ |
97 | ||
6465356a | 98 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
99 | digittoint_l(int c, locale_t l) |
100 | { | |
101 | return (__maskrune_l(c, 0x0F, l)); | |
102 | } | |
103 | ||
6465356a | 104 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
105 | isalnum_l(int c, locale_t l) |
106 | { | |
107 | return (__istype_l(c, _CTYPE_A|_CTYPE_D, l)); | |
108 | } | |
109 | ||
6465356a | 110 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
111 | isalpha_l(int c, locale_t l) |
112 | { | |
113 | return (__istype_l(c, _CTYPE_A, l)); | |
114 | } | |
115 | ||
6465356a | 116 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
117 | isblank_l(int c, locale_t l) |
118 | { | |
119 | return (__istype_l(c, _CTYPE_B, l)); | |
120 | } | |
121 | ||
6465356a | 122 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
123 | iscntrl_l(int c, locale_t l) |
124 | { | |
125 | return (__istype_l(c, _CTYPE_C, l)); | |
126 | } | |
127 | ||
6465356a | 128 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
129 | isdigit_l(int c, locale_t l) |
130 | { | |
131 | return (__istype_l(c, _CTYPE_D, l)); | |
132 | } | |
133 | ||
6465356a | 134 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
135 | isgraph_l(int c, locale_t l) |
136 | { | |
137 | return (__istype_l(c, _CTYPE_G, l)); | |
138 | } | |
139 | ||
6465356a | 140 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
141 | ishexnumber_l(int c, locale_t l) |
142 | { | |
143 | return (__istype_l(c, _CTYPE_X, l)); | |
144 | } | |
145 | ||
6465356a | 146 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
147 | isideogram_l(int c, locale_t l) |
148 | { | |
149 | return (__istype_l(c, _CTYPE_I, l)); | |
150 | } | |
151 | ||
6465356a | 152 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
153 | islower_l(int c, locale_t l) |
154 | { | |
155 | return (__istype_l(c, _CTYPE_L, l)); | |
156 | } | |
157 | ||
6465356a | 158 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
159 | isnumber_l(int c, locale_t l) |
160 | { | |
161 | return (__istype_l(c, _CTYPE_D, l)); | |
162 | } | |
163 | ||
6465356a | 164 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
165 | isphonogram_l(int c, locale_t l) |
166 | { | |
167 | return (__istype_l(c, _CTYPE_Q, l)); | |
168 | } | |
169 | ||
6465356a | 170 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
171 | isprint_l(int c, locale_t l) |
172 | { | |
173 | return (__istype_l(c, _CTYPE_R, l)); | |
174 | } | |
175 | ||
6465356a | 176 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
177 | ispunct_l(int c, locale_t l) |
178 | { | |
179 | return (__istype_l(c, _CTYPE_P, l)); | |
180 | } | |
181 | ||
6465356a | 182 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
183 | isrune_l(int c, locale_t l) |
184 | { | |
185 | return (__istype_l(c, 0xFFFFFFF0L, l)); | |
186 | } | |
187 | ||
6465356a | 188 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
189 | isspace_l(int c, locale_t l) |
190 | { | |
191 | return (__istype_l(c, _CTYPE_S, l)); | |
192 | } | |
193 | ||
6465356a | 194 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
195 | isspecial_l(int c, locale_t l) |
196 | { | |
197 | return (__istype_l(c, _CTYPE_T, l)); | |
198 | } | |
199 | ||
6465356a | 200 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
201 | isupper_l(int c, locale_t l) |
202 | { | |
203 | return (__istype_l(c, _CTYPE_U, l)); | |
204 | } | |
205 | ||
6465356a | 206 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
207 | isxdigit_l(int c, locale_t l) |
208 | { | |
209 | return (__istype_l(c, _CTYPE_X, l)); | |
210 | } | |
211 | ||
6465356a | 212 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
213 | tolower_l(int c, locale_t l) |
214 | { | |
215 | return (__tolower_l(c, l)); | |
216 | } | |
217 | ||
6465356a | 218 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
219 | toupper_l(int c, locale_t l) |
220 | { | |
221 | return (__toupper_l(c, l)); | |
222 | } | |
223 | #endif /* _EXTERNALIZE_CTYPE_INLINES_ */ | |
224 | ||
3d9156a7 A |
225 | #else /* not using inlines */ |
226 | ||
227 | __BEGIN_DECLS | |
224c7076 A |
228 | int digittoint_l(int, locale_t); |
229 | int isalnum_l(int, locale_t); | |
230 | int isalpha_l(int, locale_t); | |
231 | int isblank_l(int, locale_t); | |
232 | int iscntrl_l(int, locale_t); | |
233 | int isdigit_l(int, locale_t); | |
234 | int isgraph_l(int, locale_t); | |
235 | int ishexnumber_l(int, locale_t); | |
236 | int isideogram_l(int, locale_t); | |
237 | int islower_l(int, locale_t); | |
238 | int isnumber_l(int, locale_t); | |
239 | int isphonogram_l(int, locale_t); | |
240 | int isprint_l(int, locale_t); | |
241 | int ispunct_l(int, locale_t); | |
242 | int isrune_l(int, locale_t); | |
243 | int isspace_l(int, locale_t); | |
244 | int isspecial_l(int, locale_t); | |
245 | int isupper_l(int, locale_t); | |
246 | int isxdigit_l(int, locale_t); | |
247 | int tolower_l(int, locale_t); | |
248 | int toupper_l(int, locale_t); | |
3d9156a7 A |
249 | __END_DECLS |
250 | #endif /* using inlines */ | |
251 | ||
252 | #endif /* _XLOCALE__CTYPE_H_ */ |