summaryrefslogtreecommitdiffstats
path: root/src/include/ctype.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/ctype.h')
-rw-r--r--src/include/ctype.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/include/ctype.h b/src/include/ctype.h
new file mode 100644
index 0000000..7acf55d
--- /dev/null
+++ b/src/include/ctype.h
@@ -0,0 +1,34 @@
1#ifndef _CTYPE_H
2#define _CTYPE_H
3
4#define _U 0x01 /* upper */
5#define _L 0x02 /* lower */
6#define _D 0x04 /* digit */
7#define _C 0x08 /* cntrl */
8#define _P 0x10 /* punct */
9#define _S 0x20 /* white space (space/lf/tab) */
10#define _X 0x40 /* hex digit */
11#define _SP 0x80 /* hard space (0x20) */
12
13extern unsigned char _ctype[];
14extern char _ctmp;
15
16#define isalnum(c) ((_ctype+1)[c]&(_U|_L|_D))
17#define isalpha(c) ((_ctype+1)[c]&(_U|_L))
18#define iscntrl(c) ((_ctype+1)[c]&(_C))
19#define isdigit(c) ((_ctype+1)[c]&(_D))
20#define isgraph(c) ((_ctype+1)[c]&(_P|_U|_L|_D))
21#define islower(c) ((_ctype+1)[c]&(_L))
22#define isprint(c) ((_ctype+1)[c]&(_P|_U|_L|_D|_SP))
23#define ispunct(c) ((_ctype+1)[c]&(_P))
24#define isspace(c) ((_ctype+1)[c]&(_S))
25#define isupper(c) ((_ctype+1)[c]&(_U))
26#define isxdigit(c) ((_ctype+1)[c]&(_D|_X))
27
28#define isascii(c) (((unsigned) c)<=0x7f)
29#define toascii(c) (((unsigned) c)&0x7f)
30
31#define tolower(c) (_ctmp=c,isupper(_ctmp)?_ctmp-('A'-'a'):_ctmp)
32#define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp)
33
34#endif