1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24: #ifndef _CTYPE_H
25: #define _CTYPE_H 1
26:
27: #include <features.h>
28: #include <bits/types.h>
29:
30: __BEGIN_DECLS
31:
32: #ifndef _ISbit
33:
34:
35:
36:
37:
38:
39:
40:
41: # include <endian.h>
42: # if __BYTE_ORDER == __BIG_ENDIAN
43: # define _ISbit(bit) (1 << (bit))
44: # else
45: # define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))
46: # endif
47:
48: enum
49: {
50: _ISupper = _ISbit (0),
51: _ISlower = _ISbit (1),
52: _ISalpha = _ISbit (2),
53: _ISdigit = _ISbit (3),
54: _ISxdigit = _ISbit (4),
55: _ISspace = _ISbit (5),
56: _ISprint = _ISbit (6),
57: _ISgraph = _ISbit (7),
58: _ISblank = _ISbit (8),
59: _IScntrl = _ISbit (9),
60: _ISpunct = _ISbit (10),
61: _ISalnum = _ISbit (11)
62: };
63: #endif
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81: extern __const unsigned short int **__ctype_b_loc (void)
82: __attribute__ ((__const));
83: extern __const __int32_t **__ctype_tolower_loc (void)
84: __attribute__ ((__const));
85: extern __const __int32_t **__ctype_toupper_loc (void)
86: __attribute__ ((__const));
87:
88: #define __isctype(c, type) \
89: ((*__ctype_b_loc ())[(int) (c)] & (unsigned short int) type)
90:
91: #define __isascii(c) (((c) & ~0x7f) == 0)
92: #define __toascii(c) ((c) & 0x7f)
93:
94: #define __exctype(name) extern int name (int) __THROW
95:
96: __BEGIN_NAMESPACE_STD
97:
98:
99:
100:
101:
102: __exctype (isalnum);
103: __exctype (isalpha);
104: __exctype (iscntrl);
105: __exctype (isdigit);
106: __exctype (islower);
107: __exctype (isgraph);
108: __exctype (isprint);
109: __exctype (ispunct);
110: __exctype (isspace);
111: __exctype (isupper);
112: __exctype (isxdigit);
113:
114:
115:
116: extern int tolower (int __c) __THROW;
117:
118:
119: extern int toupper (int __c) __THROW;
120:
121: __END_NAMESPACE_STD
122:
123:
124:
125: #ifdef __USE_ISOC99
126: __BEGIN_NAMESPACE_C99
127:
128: __exctype (isblank);
129:
130: __END_NAMESPACE_C99
131: #endif
132:
133: #ifdef __USE_GNU
134:
135: extern int isctype (int __c, int __mask) __THROW;
136: #endif
137:
138: #if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
139:
140:
141:
142: extern int isascii (int __c) __THROW;
143:
144:
145:
146: extern int toascii (int __c) __THROW;
147:
148:
149:
150: __exctype (_toupper);
151: __exctype (_tolower);
152: #endif
153:
154:
155: #define __tobody(c, f, a, args) \
156: (__extension__ \
157: ({ int __res; \
158: if (sizeof (c) > 1) \
159: { \
160: if (__builtin_constant_p (c)) \
161: { \
162: int __c = (c); \
163: __res = __c < -128 || __c > 255 ? __c : (a)[__c]; \
164: } \
165: else \
166: __res = f args; \
167: } \
168: else \
169: __res = (a)[(int) (c)]; \
170: __res; }))
171:
172: #if !defined __NO_CTYPE && !defined __cplusplus
173: # define isalnum(c) __isctype((c), _ISalnum)
174: # define isalpha(c) __isctype((c), _ISalpha)
175: # define iscntrl(c) __isctype((c), _IScntrl)
176: # define isdigit(c) __isctype((c), _ISdigit)
177: # define islower(c) __isctype((c), _ISlower)
178: # define isgraph(c) __isctype((c), _ISgraph)
179: # define isprint(c) __isctype((c), _ISprint)
180: # define ispunct(c) __isctype((c), _ISpunct)
181: # define isspace(c) __isctype((c), _ISspace)
182: # define isupper(c) __isctype((c), _ISupper)
183: # define isxdigit(c) __isctype((c), _ISxdigit)
184:
185: # ifdef __USE_ISOC99
186: # define isblank(c) __isctype((c), _ISblank)
187: # endif
188:
189: # ifdef __USE_EXTERN_INLINES
190: __extern_inline int
191: __NTH (tolower (int __c))
192: {
193: return __c >= -128 && __c < 256 ? (*__ctype_tolower_loc ())[__c] : __c;
194: }
195:
196: __extern_inline int
197: __NTH (toupper (int __c))
198: {
199: return __c >= -128 && __c < 256 ? (*__ctype_toupper_loc ())[__c] : __c;
200: }
201: # endif
202:
203: # if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
204: # define tolower(c) __tobody (c, tolower, *__ctype_tolower_loc (), (c))
205: # define toupper(c) __tobody (c, toupper, *__ctype_toupper_loc (), (c))
206: # endif
207:
208: # if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
209: # define isascii(c) __isascii (c)
210: # define toascii(c) __toascii (c)
211:
212: # define _tolower(c) ((int) (*__ctype_tolower_loc ())[(int) (c)])
213: # define _toupper(c) ((int) (*__ctype_toupper_loc ())[(int) (c)])
214: # endif
215:
216: #endif
217:
218:
219: #ifdef __USE_GNU
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233: # include <xlocale.h>
234:
235:
236:
237: # define __isctype_l(c, type, locale) \
238: ((locale)->__ctype_b[(int) (c)] & (unsigned short int) type)
239:
240: # define __exctype_l(name) \
241: extern int name (int, __locale_t) __THROW
242:
243:
244:
245:
246:
247: __exctype_l (isalnum_l);
248: __exctype_l (isalpha_l);
249: __exctype_l (iscntrl_l);
250: __exctype_l (isdigit_l);
251: __exctype_l (islower_l);
252: __exctype_l (isgraph_l);
253: __exctype_l (isprint_l);
254: __exctype_l (ispunct_l);
255: __exctype_l (isspace_l);
256: __exctype_l (isupper_l);
257: __exctype_l (isxdigit_l);
258:
259: __exctype_l (isblank_l);
260:
261:
262:
263: extern int __tolower_l (int __c, __locale_t __l) __THROW;
264: extern int tolower_l (int __c, __locale_t __l) __THROW;
265:
266:
267: extern int __toupper_l (int __c, __locale_t __l) __THROW;
268: extern int toupper_l (int __c, __locale_t __l) __THROW;
269:
270: # if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
271: # define __tolower_l(c, locale) \
272: __tobody (c, __tolower_l, (locale)->__ctype_tolower, (c, locale))
273: # define __toupper_l(c, locale) \
274: __tobody (c, __toupper_l, (locale)->__ctype_toupper, (c, locale))
275: # define tolower_l(c, locale) __tolower_l ((c), (locale))
276: # define toupper_l(c, locale) __toupper_l ((c), (locale))
277: # endif
278:
279:
280: # ifndef __NO_CTYPE
281: # define __isalnum_l(c,l) __isctype_l((c), _ISalnum, (l))
282: # define __isalpha_l(c,l) __isctype_l((c), _ISalpha, (l))
283: # define __iscntrl_l(c,l) __isctype_l((c), _IScntrl, (l))
284: # define __isdigit_l(c,l) __isctype_l((c), _ISdigit, (l))
285: # define __islower_l(c,l) __isctype_l((c), _ISlower, (l))
286: # define __isgraph_l(c,l) __isctype_l((c), _ISgraph, (l))
287: # define __isprint_l(c,l) __isctype_l((c), _ISprint, (l))
288: # define __ispunct_l(c,l) __isctype_l((c), _ISpunct, (l))
289: # define __isspace_l(c,l) __isctype_l((c), _ISspace, (l))
290: # define __isupper_l(c,l) __isctype_l((c), _ISupper, (l))
291: # define __isxdigit_l(c,l) __isctype_l((c), _ISxdigit, (l))
292:
293: # define __isblank_l(c,l) __isctype_l((c), _ISblank, (l))
294:
295: # if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
296: # define __isascii_l(c,l) ((l), __isascii (c))
297: # define __toascii_l(c,l) ((l), __toascii (c))
298: # endif
299:
300: # define isalnum_l(c,l) __isalnum_l ((c), (l))
301: # define isalpha_l(c,l) __isalpha_l ((c), (l))
302: # define iscntrl_l(c,l) __iscntrl_l ((c), (l))
303: # define isdigit_l(c,l) __isdigit_l ((c), (l))
304: # define islower_l(c,l) __islower_l ((c), (l))
305: # define isgraph_l(c,l) __isgraph_l ((c), (l))
306: # define isprint_l(c,l) __isprint_l ((c), (l))
307: # define ispunct_l(c,l) __ispunct_l ((c), (l))
308: # define isspace_l(c,l) __isspace_l ((c), (l))
309: # define isupper_l(c,l) __isupper_l ((c), (l))
310: # define isxdigit_l(c,l) __isxdigit_l ((c), (l))
311:
312: # define isblank_l(c,l) __isblank_l ((c), (l))
313:
314: # if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
315: # define isascii_l(c,l) __isascii_l ((c), (l))
316: # define toascii_l(c,l) __toascii_l ((c), (l))
317: # endif
318:
319: # endif
320:
321: #endif
322:
323: __END_DECLS
324:
325: #endif