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 int digittoint_l(int, locale_t
);
29 int isalnum_l(int, locale_t
);
30 int isalpha_l(int, locale_t
);
31 int isblank_l(int, locale_t
);
32 int iscntrl_l(int, locale_t
);
33 int isdigit_l(int, locale_t
);
34 int isgraph_l(int, locale_t
);
35 int ishexnumber_l(int, locale_t
);
36 int isideogram_l(int, locale_t
);
37 int islower_l(int, locale_t
);
38 int isnumber_l(int, locale_t
);
39 int isphonogram_l(int, locale_t
);
40 int isprint_l(int, locale_t
);
41 int ispunct_l(int, locale_t
);
42 int isrune_l(int, locale_t
);
43 int isspace_l(int, locale_t
);
44 int isspecial_l(int, locale_t
);
45 int isupper_l(int, locale_t
);
46 int isxdigit_l(int, locale_t
);
47 int tolower_l(int, locale_t
);
48 int toupper_l(int, locale_t
);
51 #define digittoint_l(c, l) __maskrune_l((c), 0xFF, (l))
52 #define ishexnumber_l(c, l) __istype_l((c), _CTYPE_X, (l))
53 #define isideogram_l(c, l) __istype_l((c), _CTYPE_I, (l))
54 #define isnumber_l(c, l) __istype_l((c), _CTYPE_D, (l))
55 #define isphonogram_l(c, l) __istype_l((c), _CTYPE_Q, (l))
56 #define isrune_l(c, l) __istype_l((c), 0xFFFFFF00L, (l))
57 #define isspecial_l(c, l) __istype_l((c), _CTYPE_T, (l))
58 #define isalnum_l(c, l) __istype_l((c), (_CTYPE_A|_CTYPE_D), (l))
59 #define isalpha_l(c, l) __istype_l((c), _CTYPE_A, (l))
60 #define isblank_l(c, l) __istype_l((c), _CTYPE_B, (l))
61 #define iscntrl_l(c, l) __istype_l((c), _CTYPE_C, (l))
62 #define isdigit_l(c, l) __istype_l((c), _CTYPE_D, (l))
63 #define isgraph_l(c, l) __istype_l((c), _CTYPE_G, (l))
64 #define islower_l(c, l) __istype_l((c), _CTYPE_L, (l))
65 #define isprint_l(c, l) __istype_l((c), _CTYPE_R, (l))
66 #define ispunct_l(c, l) __istype_l((c), _CTYPE_P, (l))
67 #define isspace_l(c, l) __istype_l((c), _CTYPE_S, (l))
68 #define isupper_l(c, l) __istype_l((c), _CTYPE_U, (l))
69 #define isxdigit_l(c, l) __istype_l((c), _CTYPE_X, (l))
70 #define tolower_l(c, l) __tolower_l(c, (l))
71 #define toupper_l(c, l) __toupper_l(c, (l))
73 /* See comments in <machine/_type.h> about __darwin_ct_rune_t. */
75 unsigned long ___runetype_l(__darwin_ct_rune_t
, locale_t
);
76 __darwin_ct_rune_t
___tolower_l(__darwin_ct_rune_t
, locale_t
);
77 __darwin_ct_rune_t
___toupper_l(__darwin_ct_rune_t
, locale_t
);
81 * Use inline functions if we are allowed to and the compiler supports them.
83 #if !defined(_DONT_USE_CTYPE_INLINE_) && \
84 (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
89 __maskrune_l(__darwin_ct_rune_t _c
, unsigned long _f
, locale_t _l
)
91 return ((_c
< 0 || _c
>= _CACHED_RUNES
) ? ___runetype_l(_c
, _l
) :
92 __locale_ptr(_l
)->__lc_ctype
->_CurrentRuneLocale
.__runetype
[_c
]) & _f
;
97 int __maskrune_l(__darwin_ct_rune_t
, unsigned long, locale_t
);
100 #endif /* __LIBC__ */
104 __istype_l(__darwin_ct_rune_t _c
, unsigned long _f
, locale_t _l
)
106 return !!(isascii(_c
) ? (_DefaultRuneLocale
.__runetype
[_c
] & _f
)
107 : __maskrune_l(_c
, _f
, _l
));
110 static __inline __darwin_ct_rune_t
111 __toupper_l(__darwin_ct_rune_t _c
, locale_t _l
)
113 return isascii(_c
) ? _DefaultRuneLocale
.__mapupper
[_c
]
114 : ___toupper_l(_c
, _l
);
117 static __inline __darwin_ct_rune_t
118 __tolower_l(__darwin_ct_rune_t _c
, locale_t _l
)
120 return isascii(_c
) ? _DefaultRuneLocale
.__maplower
[_c
]
121 : ___tolower_l(_c
, _l
);
125 __wcwidth_l(__darwin_ct_rune_t _c
, locale_t _l
)
131 _x
= (unsigned int)__maskrune_l(_c
, _CTYPE_SWM
|_CTYPE_R
, _l
);
132 if ((_x
& _CTYPE_SWM
) != 0)
133 return ((_x
& _CTYPE_SWM
) >> _CTYPE_SWS
);
134 return ((_x
& _CTYPE_R
) != 0 ? 1 : -1);
137 #else /* not using inlines */
140 int __maskrune_l(__darwin_ct_rune_t
, unsigned long, locale_t
);
141 int __istype_l(__darwin_ct_rune_t
, unsigned long, locale_t
);
142 __darwin_ct_rune_t
__toupper_l(__darwin_ct_rune_t
, locale_t
);
143 __darwin_ct_rune_t
__tolower_l(__darwin_ct_rune_t
, locale_t
);
144 int __wcwidth_l(__darwin_ct_rune_t
, locale_t
);
146 #endif /* using inlines */
148 #endif /* _XLOCALE__CTYPE_H_ */