scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

ctype.h (1476B)


      1 #ifndef _CTYPE_H
      2 #define _CTYPE_H
      3 
      4 extern int isalnum(int c);
      5 extern int isalpha(int c);
      6 extern int islower(int c);
      7 extern int isupper(int c);
      8 extern int isdigit(int c);
      9 extern int isxdigit(int c);
     10 extern int iscntrl(int c);
     11 extern int isgraph(int c);
     12 extern int isspace(int c);
     13 extern int isblank(int c);
     14 extern int isprint(int c);
     15 extern int ispunct(int c);
     16 extern int tolower(int c);
     17 extern int toupper(int c);
     18 
     19 #ifdef __USE_MACROS
     20 
     21 #define _U	0x01	/* upper */
     22 #define _L	0x02	/* lower */
     23 #define _D	0x04	/* digit */
     24 #define _C	0x08	/* cntrl */
     25 #define _P	0x10	/* punct */
     26 #define _S	0x20	/* white space (space/lf/tab) */
     27 #define _X	0x40	/* hex char */
     28 #define _SP	0x80	/* hard space (0x20) */
     29 
     30 extern unsigned char __ctype[];
     31 extern int __ctmp;
     32 
     33 #define isalnum(c)  ((__ctype+1)[c] & (_U|_L|_D))
     34 #define isalpha(c)  ((__ctype+1)[c] & (_U|_L))
     35 #define iscntrl(c)  ((__ctype+1)[c] & (_C))
     36 #define isdigit(c)  ((__ctype+1)[c] & (_D))
     37 #define isgraph(c)  ((__ctype+1)[c] & (_P|_U|_L|_D))
     38 #define islower(c)  ((__ctype+1)[c] & (_L))
     39 #define isprint(c)  ((__ctype+1)[c] & (_P|_U|_L|_D|_SP))
     40 #define ispunct(c)  ((__ctype+1)[c] & (_P))
     41 #define isspace(c)  ((__ctype+1)[c] & (_S))
     42 #define isupper(c)  ((__ctype+1)[c] & (_U))
     43 #define isxdigit(c) ((__ctype+1)[c] & (_D|_X))
     44 
     45 #define tolower(c) ((__ctmp=c, isupper(__ctmp) ? __ctmp | 0x20 : __ctmp))
     46 #define toupper(c) ((__ctmp=c, islower(__ctmp) ? __ctmp & ~0x20 : __ctmp))
     47 
     48 #define isascii(c) ((unsigned)(c)<=0x7f)
     49 
     50 #endif
     51 
     52 #endif