2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
24 #ifndef _XLOCALE__CTYPE_H_
25 #define _XLOCALE__CTYPE_H_
28 * Use inline functions if we are allowed to and the compiler supports them.
30 #if !defined(_DONT_USE_CTYPE_INLINE_) && \
31 (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
33 /* See comments in <machine/_type.h> about __darwin_ct_rune_t. */
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
);
42 __DARWIN_CTYPE_static_inline
int
43 __maskrune_l(__darwin_ct_rune_t _c
, unsigned long _f
, locale_t _l
)
45 return ((_c
< 0 || _c
>= _CACHED_RUNES
) ? ___runetype_l(_c
, _l
) :
46 __locale_ptr(_l
)->__lc_ctype
->_CurrentRuneLocale
.__runetype
[_c
]) & _f
;
51 int __maskrune_l(__darwin_ct_rune_t
, unsigned long, locale_t
);
57 __DARWIN_CTYPE_static_inline
int
58 __istype_l(__darwin_ct_rune_t _c
, unsigned long _f
, locale_t _l
)
60 return !!(isascii(_c
) ? (_DefaultRuneLocale
.__runetype
[_c
] & _f
)
61 : __maskrune_l(_c
, _f
, _l
));
64 __DARWIN_CTYPE_static_inline __darwin_ct_rune_t
65 __toupper_l(__darwin_ct_rune_t _c
, locale_t _l
)
67 return isascii(_c
) ? _DefaultRuneLocale
.__mapupper
[_c
]
68 : ___toupper_l(_c
, _l
);
71 __DARWIN_CTYPE_static_inline __darwin_ct_rune_t
72 __tolower_l(__darwin_ct_rune_t _c
, locale_t _l
)
74 return isascii(_c
) ? _DefaultRuneLocale
.__maplower
[_c
]
75 : ___tolower_l(_c
, _l
);
78 __DARWIN_CTYPE_static_inline
int
79 __wcwidth_l(__darwin_ct_rune_t _c
, locale_t _l
)
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);
91 #ifndef _EXTERNALIZE_CTYPE_INLINES_
93 __DARWIN_CTYPE_TOP_static_inline
int
94 digittoint_l(int c
, locale_t l
)
96 return (__maskrune_l(c
, 0x0F, l
));
99 __DARWIN_CTYPE_TOP_static_inline
int
100 isalnum_l(int c
, locale_t l
)
102 return (__istype_l(c
, _CTYPE_A
|_CTYPE_D
, l
));
105 __DARWIN_CTYPE_TOP_static_inline
int
106 isalpha_l(int c
, locale_t l
)
108 return (__istype_l(c
, _CTYPE_A
, l
));
111 __DARWIN_CTYPE_TOP_static_inline
int
112 isblank_l(int c
, locale_t l
)
114 return (__istype_l(c
, _CTYPE_B
, l
));
117 __DARWIN_CTYPE_TOP_static_inline
int
118 iscntrl_l(int c
, locale_t l
)
120 return (__istype_l(c
, _CTYPE_C
, l
));
123 __DARWIN_CTYPE_TOP_static_inline
int
124 isdigit_l(int c
, locale_t l
)
126 return (__istype_l(c
, _CTYPE_D
, l
));
129 __DARWIN_CTYPE_TOP_static_inline
int
130 isgraph_l(int c
, locale_t l
)
132 return (__istype_l(c
, _CTYPE_G
, l
));
135 __DARWIN_CTYPE_TOP_static_inline
int
136 ishexnumber_l(int c
, locale_t l
)
138 return (__istype_l(c
, _CTYPE_X
, l
));
141 __DARWIN_CTYPE_TOP_static_inline
int
142 isideogram_l(int c
, locale_t l
)
144 return (__istype_l(c
, _CTYPE_I
, l
));
147 __DARWIN_CTYPE_TOP_static_inline
int
148 islower_l(int c
, locale_t l
)
150 return (__istype_l(c
, _CTYPE_L
, l
));
153 __DARWIN_CTYPE_TOP_static_inline
int
154 isnumber_l(int c
, locale_t l
)
156 return (__istype_l(c
, _CTYPE_D
, l
));
159 __DARWIN_CTYPE_TOP_static_inline
int
160 isphonogram_l(int c
, locale_t l
)
162 return (__istype_l(c
, _CTYPE_Q
, l
));
165 __DARWIN_CTYPE_TOP_static_inline
int
166 isprint_l(int c
, locale_t l
)
168 return (__istype_l(c
, _CTYPE_R
, l
));
171 __DARWIN_CTYPE_TOP_static_inline
int
172 ispunct_l(int c
, locale_t l
)
174 return (__istype_l(c
, _CTYPE_P
, l
));
177 __DARWIN_CTYPE_TOP_static_inline
int
178 isrune_l(int c
, locale_t l
)
180 return (__istype_l(c
, 0xFFFFFFF0L
, l
));
183 __DARWIN_CTYPE_TOP_static_inline
int
184 isspace_l(int c
, locale_t l
)
186 return (__istype_l(c
, _CTYPE_S
, l
));
189 __DARWIN_CTYPE_TOP_static_inline
int
190 isspecial_l(int c
, locale_t l
)
192 return (__istype_l(c
, _CTYPE_T
, l
));
195 __DARWIN_CTYPE_TOP_static_inline
int
196 isupper_l(int c
, locale_t l
)
198 return (__istype_l(c
, _CTYPE_U
, l
));
201 __DARWIN_CTYPE_TOP_static_inline
int
202 isxdigit_l(int c
, locale_t l
)
204 return (__istype_l(c
, _CTYPE_X
, l
));
207 __DARWIN_CTYPE_TOP_static_inline
int
208 tolower_l(int c
, locale_t l
)
210 return (__tolower_l(c
, l
));
213 __DARWIN_CTYPE_TOP_static_inline
int
214 toupper_l(int c
, locale_t l
)
216 return (__toupper_l(c
, l
));
218 #endif /* _EXTERNALIZE_CTYPE_INLINES_ */
220 #else /* not using inlines */
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
);
245 #endif /* using inlines */
247 #endif /* _XLOCALE__CTYPE_H_ */