ia64/xen-unstable

annotate extras/mini-os/include/ctype.h @ 16838:945820bfedb6

minios: POSIX fixes
Fixes some functions which are POSIX. Also make them ifndef HAVE_LIBC.

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