ctype.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * ctype.h Character classification and conversion
  3. */
  4. #ifndef __CTYPE_H
  5. #define __CTYPE_H
  6. extern unsigned char __ctype[];
  7. #define __CT_d 0x01 /* numeric digit */
  8. #define __CT_u 0x02 /* upper case */
  9. #define __CT_l 0x04 /* lower case */
  10. #define __CT_c 0x08 /* control character */
  11. #define __CT_s 0x10 /* whitespace */
  12. #define __CT_p 0x20 /* punctuation */
  13. #define __CT_x 0x40 /* hexadecimal */
  14. #define toupper(c) (islower(c) ? (c)^0x20 : (c))
  15. #define tolower(c) (isupper(c) ? (c)^0x20 : (c))
  16. #define _toupper(c) ((c)^0x20)
  17. #define _tolower(c) ((c)^0x20)
  18. #define toascii(c) ((c)&0x7F)
  19. /* Note the '!!' is a cast to 'bool' and even BCC deletes it in an if() */
  20. #define isalnum(c) (!!(__ctype[(int) c]&(__CT_u|__CT_l|__CT_d)))
  21. #define isalpha(c) (!!(__ctype[(int) c]&(__CT_u|__CT_l)))
  22. #define isascii(c) (!((c)&~0x7F))
  23. #define iscntrl(c) (!!(__ctype[(int) c]&__CT_c))
  24. #define isdigit(c) (!!(__ctype[(int) c]&__CT_d))
  25. #define isgraph(c) (!(__ctype[(int) c]&(__CT_c|__CT_s)))
  26. #define islower(c) (!!(__ctype[(int) c]&__CT_l))
  27. #define isprint(c) (!(__ctype[(int) c]&__CT_c))
  28. #define ispunct(c) (!!(__ctype[(int) c]&__CT_p))
  29. #define isspace(c) (!!(__ctype[(int) c]&__CT_s))
  30. #define isupper(c) (!!(__ctype[(int) c]&__CT_u))
  31. #define isxdigit(c) (!!(__ctype[(int) c]&__CT_x))
  32. #endif /* __CTYPE_H */