pyctype.h 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. #ifndef PYCTYPE_H
  2. #define PYCTYPE_H
  3. #define PY_CTF_LOWER 0x01
  4. #define PY_CTF_UPPER 0x02
  5. #define PY_CTF_ALPHA (PY_CTF_LOWER|PY_CTF_UPPER)
  6. #define PY_CTF_DIGIT 0x04
  7. #define PY_CTF_ALNUM (PY_CTF_ALPHA|PY_CTF_DIGIT)
  8. #define PY_CTF_SPACE 0x08
  9. #define PY_CTF_XDIGIT 0x10
  10. PyAPI_DATA(const unsigned int) _Py_ctype_table[256];
  11. /* Unlike their C counterparts, the following macros are not meant to
  12. * handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument
  13. * must be a signed/unsigned char. */
  14. #define Py_ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER)
  15. #define Py_ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER)
  16. #define Py_ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA)
  17. #define Py_ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_DIGIT)
  18. #define Py_ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_XDIGIT)
  19. #define Py_ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM)
  20. #define Py_ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE)
  21. PyAPI_DATA(const unsigned char) _Py_ctype_tolower[256];
  22. PyAPI_DATA(const unsigned char) _Py_ctype_toupper[256];
  23. #define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)])
  24. #define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)])
  25. #endif /* !PYCTYPE_H */