7 #if __POSIX_VISIBLE >= 200809 || __MISC_VISIBLE || defined (_LIBC)
8 #include <sys/_locale.h>
13 int isalnum (int __c
);
14 int isalpha (int __c
);
15 int iscntrl (int __c
);
16 int isdigit (int __c
);
17 int isgraph (int __c
);
18 int islower (int __c
);
19 int isprint (int __c
);
20 int ispunct (int __c
);
21 int isspace (int __c
);
22 int isupper (int __c
);
23 int isxdigit (int __c
);
24 int tolower (int __c
);
25 int toupper (int __c
);
27 #if __ISO_C_VISIBLE >= 1999
28 int isblank (int __c
);
31 #if __MISC_VISIBLE || __XSI_VISIBLE
32 int isascii (int __c
);
33 int toascii (int __c
);
34 #define _tolower(__c) ((unsigned char)(__c) - 'A' + 'a')
35 #define _toupper(__c) ((unsigned char)(__c) - 'a' + 'A')
38 #if __POSIX_VISIBLE >= 200809
39 extern int isalnum_l (int __c
, locale_t __l
);
40 extern int isalpha_l (int __c
, locale_t __l
);
41 extern int isblank_l (int __c
, locale_t __l
);
42 extern int iscntrl_l (int __c
, locale_t __l
);
43 extern int isdigit_l (int __c
, locale_t __l
);
44 extern int isgraph_l (int __c
, locale_t __l
);
45 extern int islower_l (int __c
, locale_t __l
);
46 extern int isprint_l (int __c
, locale_t __l
);
47 extern int ispunct_l (int __c
, locale_t __l
);
48 extern int isspace_l (int __c
, locale_t __l
);
49 extern int isupper_l (int __c
, locale_t __l
);
50 extern int isxdigit_l(int __c
, locale_t __l
);
51 extern int tolower_l (int __c
, locale_t __l
);
52 extern int toupper_l (int __c
, locale_t __l
);
56 extern int isascii_l (int __c
, locale_t __l
);
57 extern int toascii_l (int __c
, locale_t __l
);
69 /* For C++ backward-compatibility only. */
70 extern __IMPORT
const char _ctype_
[];
72 #ifdef __HAVE_LOCALE_INFO__
73 const char *__locale_ctype_ptr (void);
75 #define __locale_ctype_ptr() _ctype_
78 # define __CTYPE_PTR (__locale_ctype_ptr ())
81 /* These macros are intentionally written in a manner that will trigger
82 a gcc -Wall warning if the user mistakenly passes a 'char' instead
83 of an int containing an 'unsigned char'. Note that the sizeof will
84 always be 1, which is what we want for mapping EOF to __CTYPE_PTR[0];
85 the use of a raw index inside the sizeof triggers the gcc warning if
86 __c was of type char, and sizeof masks side effects of the extra __c.
87 Meanwhile, the real index to __CTYPE_PTR+1 must be cast to int,
88 since isalpha(0x100000001LL) must equal isalpha(1), rather than being
89 an out-of-bounds reference on a 64-bit machine. */
90 #define __ctype_lookup(__c) ((__CTYPE_PTR+sizeof(""[__c]))[(int)(__c)])
92 #define isalpha(__c) (__ctype_lookup(__c)&(_U|_L))
93 #define isupper(__c) ((__ctype_lookup(__c)&(_U|_L))==_U)
94 #define islower(__c) ((__ctype_lookup(__c)&(_U|_L))==_L)
95 #define isdigit(__c) (__ctype_lookup(__c)&_N)
96 #define isxdigit(__c) (__ctype_lookup(__c)&(_X|_N))
97 #define isspace(__c) (__ctype_lookup(__c)&_S)
98 #define ispunct(__c) (__ctype_lookup(__c)&_P)
99 #define isalnum(__c) (__ctype_lookup(__c)&(_U|_L|_N))
100 #define isprint(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N|_B))
101 #define isgraph(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N))
102 #define iscntrl(__c) (__ctype_lookup(__c)&_C)
104 #if defined(__GNUC__) && __ISO_C_VISIBLE >= 1999
105 #define isblank(__c) \
106 __extension__ ({ __typeof__ (__c) __x = (__c); \
107 (__ctype_lookup(__x)&_B) || (int) (__x) == '\t';})
110 #if __POSIX_VISIBLE >= 200809
111 #ifdef __HAVE_LOCALE_INFO__
112 const char *__locale_ctype_ptr_l (locale_t
);
114 static __inline
const char *
115 __locale_ctype_ptr_l(locale_t _l
)
118 return __locale_ctype_ptr();
121 #define __ctype_lookup_l(__c,__l) ((__locale_ctype_ptr_l(__l)+sizeof(""[__c]))[(int)(__c)])
123 #define isalpha_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_U|_L))
124 #define isupper_l(__c,__l) ((__ctype_lookup_l(__c,__l)&(_U|_L))==_U)
125 #define islower_l(__c,__l) ((__ctype_lookup_l(__c,__l)&(_U|_L))==_L)
126 #define isdigit_l(__c,__l) (__ctype_lookup_l(__c,__l)&_N)
127 #define isxdigit_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_X|_N))
128 #define isspace_l(__c,__l) (__ctype_lookup_l(__c,__l)&_S)
129 #define ispunct_l(__c,__l) (__ctype_lookup_l(__c,__l)&_P)
130 #define isalnum_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_U|_L|_N))
131 #define isprint_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_P|_U|_L|_N|_B))
132 #define isgraph_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_P|_U|_L|_N))
133 #define iscntrl_l(__c,__l) (__ctype_lookup_l(__c,__l)&_C)
135 #if defined(__GNUC__)
136 #define isblank_l(__c, __l) \
137 __extension__ ({ __typeof__ (__c) __x = (__c); \
138 (__ctype_lookup_l(__x,__l)&_B) || (int) (__x) == '\t';})
141 #endif /* __POSIX_VISIBLE >= 200809 */
143 #if __MISC_VISIBLE || __XSI_VISIBLE
144 #define isascii(__c) ((unsigned)(__c)<=0177)
145 #define toascii(__c) ((__c)&0177)
149 #define isascii_l(__c,__l) ((__l),(unsigned)(__c)<=0177)
150 #define toascii_l(__c,__l) ((__l),(__c)&0177)
153 /* Non-gcc versions will get the library versions, and will be
154 slightly slower. These macros are not NLS-aware so they are
155 disabled if the system supports the extended character sets. */
156 # if defined(__GNUC__)
157 # if !defined (_MB_EXTENDED_CHARSETS_ISO) && !defined (_MB_EXTENDED_CHARSETS_WINDOWS)
158 # define toupper(__c) \
159 __extension__ ({ __typeof__ (__c) __x = (__c); \
160 islower (__x) ? (int) __x - 'a' + 'A' : (int) __x;})
161 # define tolower(__c) \
162 __extension__ ({ __typeof__ (__c) __x = (__c); \
163 isupper (__x) ? (int) __x - 'A' + 'a' : (int) __x;})
164 # else /* _MB_EXTENDED_CHARSETS* */
165 /* Allow a gcc warning if the user passed 'char', but defer to the
167 # define toupper(__c) \
168 __extension__ ({ __typeof__ (__c) __x = (__c); \
169 (void) __CTYPE_PTR[__x]; (toupper) (__x);})
170 # define tolower(__c) \
171 __extension__ ({ __typeof__ (__c) __x = (__c); \
172 (void) __CTYPE_PTR[__x]; (tolower) (__x);})
173 # endif /* _MB_EXTENDED_CHARSETS* */
174 # endif /* __GNUC__ */
176 #if __POSIX_VISIBLE >= 200809
177 #endif /* __POSIX_VISIBLE >= 200809 */
179 #endif /* !__cplusplus */
183 #endif /* _CTYPE_H_ */