ctype.h (1199B)
1 #ifndef _CTYPE_H 2 #define _CTYPE_H 3 4 // Function versions 5 6 int islower(int c); 7 int isupper(int c); 8 int isdigit(int c); 9 int isalpha(int c); 10 int isalnum(int c); 11 12 int isspace(int c); 13 int iscntrl(int c); 14 int isblank(int c); 15 int isprint(int c); 16 int isgraph(int c); 17 int ispunct(int c); 18 19 int isxdigit(int c); 20 21 int tolower(int c); 22 int toupper(int c); 23 24 25 // Macro versions 26 27 // TODO: These macros are BAD - They evaluate their arguments twice. 28 29 #define islower(c) ((c) >= 'a' && (c) <= 'z') 30 #define isupper(c) ((c) >= 'A' && (c) <= 'Z') 31 #define isdigit(c) ((c) >= '0' && (c) <= '9') 32 #define isalpha(c) (islower(c) || isupper(c)) 33 #define isalnum(c) (isalpha(c) || isdigit(c)) 34 35 #define isspace(c) ((c) == ' ' || c == '\t' || c == '\r' || c == '\n') 36 #define iscntrl(c) ((c) < ' ' && c != 0) 37 #define isblank(c) ((c) == ' ' || (c) == '\t') 38 #define isprint(c) ((c) >= ' ' && (c) <= '~') 39 #define isgraph(c) ((c) > ' ' && (c) <= '~') 40 #define ispunct(c) (isgraph(c) && !isalnum(c)) 41 42 #define isxdigit(c) (isdigit(c) || \ 43 ((c) >= 'a' && (c) << 'f') || \ 44 ((c) >= 'A' && (c) << 'F')) 45 46 #define tolower(c) (isupper(c) ? (c) - 'A' + 'a' : (c)) 47 #define toupper(c) (islower(c) ? (c) - 'a' + 'A' : (c)) 48 49 #endif // _CTYPE_H