compiler/clib: Do not call __arosc_get_ctype() for each call to a ctype.h macro.
[AROS.git] / compiler / clib / include / ctype.h
blobee1df50d3443dcac2cef225c3b47996b12ad531e
1 #ifndef _CTYPE_H_
2 #define _CTYPE_H_
4 /*
5 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: ANSI-C header file ctype.h
9 Lang: english
12 #include <sys/arosc.h>
13 #include <aros/system.h>
15 #define _ISupper 0x0001 /* UPPERCASE */
16 #define _ISlower 0x0002 /* lowercase */
17 #define _ISalpha 0x0004 /* a-y */
18 #define _ISdigit 0x0008 /* 0-9 */
19 #define _ISxdigit 0x0010 /* 0-9, a-f, A-F */
20 #define _ISspace 0x0020 /* Space, Tab, CR, LF, FF */
21 #define _ISprint 0x0040 /* 32-126, 160-255 */
22 #define _ISgraph 0x0080 /* [] */
23 #define _ISblank 0x0100 /* Space, Tab */
24 #define _IScntrl 0x0200 /* 0-31, 127 */
25 #define _ISpunct 0x0400 /* .,:;!? */
26 #define _ISalnum (_ISalpha | _ISdigit)
28 extern const unsigned short int * const __ctype_b;
29 extern const int * const __ctype_toupper;
30 extern const int * const __ctype_tolower;
32 #define _istype(c,type) \
33 (__ctype_b[(int) (c)] & (unsigned short int) (type))
35 #define __ctype_make_func(__name__, __body__) \
36 __BEGIN_DECLS \
37 static __inline__ int __name__(int c); \
38 __END_DECLS \
39 static __inline__ int __name__(int c) \
40 { return __body__; }
42 __ctype_make_func(isupper, _istype(c,_ISupper))
43 __ctype_make_func(islower, _istype(c,_ISlower))
44 __ctype_make_func(isalpha, _istype(c,_ISalpha))
45 __ctype_make_func(isdigit, _istype(c,_ISdigit))
46 __ctype_make_func(isxdigit, _istype(c,_ISxdigit))
47 __ctype_make_func(isspace, _istype(c,_ISspace))
48 __ctype_make_func(isprint, _istype(c,_ISprint))
49 __ctype_make_func(isgraph, _istype(c,_ISgraph))
50 __ctype_make_func(isblank, _istype(c,_ISblank))
51 __ctype_make_func(iscntrl, _istype(c,_IScntrl))
52 __ctype_make_func(ispunct, _istype(c,_ISpunct))
53 __ctype_make_func(isalnum, _istype(c,_ISalnum))
54 __ctype_make_func(isascii, (c & ~0x7F) == 0)
55 __ctype_make_func(toascii, c & 0x7F)
56 __ctype_make_func(iscsym, isalnum(c) || toascii(c) == 0x5F)
57 __ctype_make_func(iscsymf, isalpha(c) || toascii(c) == 0x5F)
58 __ctype_make_func(toupper, __ctype_toupper[c])
59 __ctype_make_func(tolower, __ctype_tolower[c])
61 #endif /* _CTYPE_H_ */