]>
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__ | |
6465356a | 42 | __DARWIN_CTYPE_inline int |
3d9156a7 A |
43 | __maskrune_l(__darwin_ct_rune_t _c, unsigned long _f, locale_t _l) |
44 | { | |
45 | return ((_c < 0 || _c >= _CACHED_RUNES) ? ___runetype_l(_c, _l) : | |
46 | __locale_ptr(_l)->__lc_ctype->_CurrentRuneLocale.__runetype[_c]) & _f; | |
47 | } | |
48 | #else /* !__LIBC__ */ | |
49 | //End-Libc | |
50 | __BEGIN_DECLS | |
51 | int __maskrune_l(__darwin_ct_rune_t, unsigned long, locale_t); | |
52 | __END_DECLS | |
53 | //Begin-Libc | |
54 | #endif /* __LIBC__ */ | |
55 | //End-Libc | |
56 | ||
6465356a | 57 | __DARWIN_CTYPE_inline int |
3d9156a7 A |
58 | __istype_l(__darwin_ct_rune_t _c, unsigned long _f, locale_t _l) |
59 | { | |
60 | return !!(isascii(_c) ? (_DefaultRuneLocale.__runetype[_c] & _f) | |
61 | : __maskrune_l(_c, _f, _l)); | |
62 | } | |
63 | ||
6465356a | 64 | __DARWIN_CTYPE_inline __darwin_ct_rune_t |
3d9156a7 A |
65 | __toupper_l(__darwin_ct_rune_t _c, locale_t _l) |
66 | { | |
67 | return isascii(_c) ? _DefaultRuneLocale.__mapupper[_c] | |
68 | : ___toupper_l(_c, _l); | |
69 | } | |
70 | ||
6465356a | 71 | __DARWIN_CTYPE_inline __darwin_ct_rune_t |
3d9156a7 A |
72 | __tolower_l(__darwin_ct_rune_t _c, locale_t _l) |
73 | { | |
74 | return isascii(_c) ? _DefaultRuneLocale.__maplower[_c] | |
75 | : ___tolower_l(_c, _l); | |
76 | } | |
77 | ||
6465356a | 78 | __DARWIN_CTYPE_inline int |
3d9156a7 A |
79 | __wcwidth_l(__darwin_ct_rune_t _c, locale_t _l) |
80 | { | |
81 | unsigned int _x; | |
82 | ||
83 | if (_c == 0) | |
84 | return (0); | |
85 | _x = (unsigned int)__maskrune_l(_c, _CTYPE_SWM|_CTYPE_R, _l); | |
86 | if ((_x & _CTYPE_SWM) != 0) | |
87 | return ((_x & _CTYPE_SWM) >> _CTYPE_SWS); | |
88 | return ((_x & _CTYPE_R) != 0 ? 1 : -1); | |
89 | } | |
90 | ||
224c7076 A |
91 | #ifndef _EXTERNALIZE_CTYPE_INLINES_ |
92 | ||
6465356a | 93 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
94 | digittoint_l(int c, locale_t l) |
95 | { | |
96 | return (__maskrune_l(c, 0x0F, l)); | |
97 | } | |
98 | ||
6465356a | 99 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
100 | isalnum_l(int c, locale_t l) |
101 | { | |
102 | return (__istype_l(c, _CTYPE_A|_CTYPE_D, l)); | |
103 | } | |
104 | ||
6465356a | 105 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
106 | isalpha_l(int c, locale_t l) |
107 | { | |
108 | return (__istype_l(c, _CTYPE_A, l)); | |
109 | } | |
110 | ||
6465356a | 111 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
112 | isblank_l(int c, locale_t l) |
113 | { | |
114 | return (__istype_l(c, _CTYPE_B, l)); | |
115 | } | |
116 | ||
6465356a | 117 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
118 | iscntrl_l(int c, locale_t l) |
119 | { | |
120 | return (__istype_l(c, _CTYPE_C, l)); | |
121 | } | |
122 | ||
6465356a | 123 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
124 | isdigit_l(int c, locale_t l) |
125 | { | |
126 | return (__istype_l(c, _CTYPE_D, l)); | |
127 | } | |
128 | ||
6465356a | 129 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
130 | isgraph_l(int c, locale_t l) |
131 | { | |
132 | return (__istype_l(c, _CTYPE_G, l)); | |
133 | } | |
134 | ||
6465356a | 135 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
136 | ishexnumber_l(int c, locale_t l) |
137 | { | |
138 | return (__istype_l(c, _CTYPE_X, l)); | |
139 | } | |
140 | ||
6465356a | 141 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
142 | isideogram_l(int c, locale_t l) |
143 | { | |
144 | return (__istype_l(c, _CTYPE_I, l)); | |
145 | } | |
146 | ||
6465356a | 147 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
148 | islower_l(int c, locale_t l) |
149 | { | |
150 | return (__istype_l(c, _CTYPE_L, l)); | |
151 | } | |
152 | ||
6465356a | 153 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
154 | isnumber_l(int c, locale_t l) |
155 | { | |
156 | return (__istype_l(c, _CTYPE_D, l)); | |
157 | } | |
158 | ||
6465356a | 159 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
160 | isphonogram_l(int c, locale_t l) |
161 | { | |
162 | return (__istype_l(c, _CTYPE_Q, l)); | |
163 | } | |
164 | ||
6465356a | 165 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
166 | isprint_l(int c, locale_t l) |
167 | { | |
168 | return (__istype_l(c, _CTYPE_R, l)); | |
169 | } | |
170 | ||
6465356a | 171 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
172 | ispunct_l(int c, locale_t l) |
173 | { | |
174 | return (__istype_l(c, _CTYPE_P, l)); | |
175 | } | |
176 | ||
6465356a | 177 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
178 | isrune_l(int c, locale_t l) |
179 | { | |
180 | return (__istype_l(c, 0xFFFFFFF0L, l)); | |
181 | } | |
182 | ||
6465356a | 183 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
184 | isspace_l(int c, locale_t l) |
185 | { | |
186 | return (__istype_l(c, _CTYPE_S, l)); | |
187 | } | |
188 | ||
6465356a | 189 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
190 | isspecial_l(int c, locale_t l) |
191 | { | |
192 | return (__istype_l(c, _CTYPE_T, l)); | |
193 | } | |
194 | ||
6465356a | 195 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
196 | isupper_l(int c, locale_t l) |
197 | { | |
198 | return (__istype_l(c, _CTYPE_U, l)); | |
199 | } | |
200 | ||
6465356a | 201 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
202 | isxdigit_l(int c, locale_t l) |
203 | { | |
204 | return (__istype_l(c, _CTYPE_X, l)); | |
205 | } | |
206 | ||
6465356a | 207 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
208 | tolower_l(int c, locale_t l) |
209 | { | |
210 | return (__tolower_l(c, l)); | |
211 | } | |
212 | ||
6465356a | 213 | __DARWIN_CTYPE_TOP_inline int |
224c7076 A |
214 | toupper_l(int c, locale_t l) |
215 | { | |
216 | return (__toupper_l(c, l)); | |
217 | } | |
218 | #endif /* _EXTERNALIZE_CTYPE_INLINES_ */ | |
219 | ||
3d9156a7 A |
220 | #else /* not using inlines */ |
221 | ||
222 | __BEGIN_DECLS | |
224c7076 A |
223 | int digittoint_l(int, locale_t); |
224 | int isalnum_l(int, locale_t); | |
225 | int isalpha_l(int, locale_t); | |
226 | int isblank_l(int, locale_t); | |
227 | int iscntrl_l(int, locale_t); | |
228 | int isdigit_l(int, locale_t); | |
229 | int isgraph_l(int, locale_t); | |
230 | int ishexnumber_l(int, locale_t); | |
231 | int isideogram_l(int, locale_t); | |
232 | int islower_l(int, locale_t); | |
233 | int isnumber_l(int, locale_t); | |
234 | int isphonogram_l(int, locale_t); | |
235 | int isprint_l(int, locale_t); | |
236 | int ispunct_l(int, locale_t); | |
237 | int isrune_l(int, locale_t); | |
238 | int isspace_l(int, locale_t); | |
239 | int isspecial_l(int, locale_t); | |
240 | int isupper_l(int, locale_t); | |
241 | int isxdigit_l(int, locale_t); | |
242 | int tolower_l(int, locale_t); | |
243 | int toupper_l(int, locale_t); | |
3d9156a7 A |
244 | __END_DECLS |
245 | #endif /* using inlines */ | |
246 | ||
247 | #endif /* _XLOCALE__CTYPE_H_ */ |