ia64/xen-unstable

view extras/mini-os/include/ctype.h @ 16437:c9c476a22036

[Mini-OS] Move _ctype into a module

Move the _ctype array into its own module, instead of having it
defined in a header.

Signed-off-by: Samuel Thibault <samuel.thibault@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Nov 23 16:41:54 2007 +0000 (2007-11-23)
parents 06d84bf87159
children 433d1b26fd51
line source
1 #ifndef _CTYPE_H
2 #define _CTYPE_H
4 /*
5 * NOTE! This ctype does not handle EOF like the standard C
6 * library is required to.
7 */
9 #define _U 0x01 /* upper */
10 #define _L 0x02 /* lower */
11 #define _D 0x04 /* digit */
12 #define _C 0x08 /* cntrl */
13 #define _P 0x10 /* punct */
14 #define _S 0x20 /* white space (space/lf/tab) */
15 #define _X 0x40 /* hex digit */
16 #define _SP 0x80 /* hard space (0x20) */
19 extern unsigned char _ctype[];
21 #define __ismask(x) (_ctype[(int)(unsigned char)(x)])
23 #define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0)
24 #define isalpha(c) ((__ismask(c)&(_U|_L)) != 0)
25 #define iscntrl(c) ((__ismask(c)&(_C)) != 0)
26 #define isdigit(c) ((__ismask(c)&(_D)) != 0)
27 #define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0)
28 #define islower(c) ((__ismask(c)&(_L)) != 0)
29 #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0)
30 #define ispunct(c) ((__ismask(c)&(_P)) != 0)
31 #define isspace(c) ((__ismask(c)&(_S)) != 0)
32 #define isupper(c) ((__ismask(c)&(_U)) != 0)
33 #define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0)
35 #define isascii(c) (((unsigned char)(c))<=0x7f)
36 #define toascii(c) (((unsigned char)(c))&0x7f)
38 static inline unsigned char __tolower(unsigned char c)
39 {
40 if (isupper(c))
41 c -= 'A'-'a';
42 return c;
43 }
45 static inline unsigned char __toupper(unsigned char c)
46 {
47 if (islower(c))
48 c -= 'a'-'A';
49 return c;
50 }
52 #define tolower(c) __tolower(c)
53 #define toupper(c) __toupper(c)
55 #endif