Eric Smith | cac7af6 | 2009-04-27 19:04:37 +0000 | [diff] [blame] | 1 | #ifndef PYCTYPE_H |
| 2 | #define PYCTYPE_H |
| 3 | |
| 4 | #define PY_CTF_LOWER 0x01 |
| 5 | #define PY_CTF_UPPER 0x02 |
| 6 | #define PY_CTF_ALPHA (PY_CTF_LOWER|PY_CTF_UPPER) |
| 7 | #define PY_CTF_DIGIT 0x04 |
| 8 | #define PY_CTF_ALNUM (PY_CTF_ALPHA|PY_CTF_DIGIT) |
| 9 | #define PY_CTF_SPACE 0x08 |
| 10 | #define PY_CTF_XDIGIT 0x10 |
| 11 | |
Antoine Pitrou | 5a75355 | 2011-10-04 14:45:32 +0200 | [diff] [blame] | 12 | PyAPI_DATA(const unsigned int) _Py_ctype_table[256]; |
Eric Smith | cac7af6 | 2009-04-27 19:04:37 +0000 | [diff] [blame] | 13 | |
Stefan Krah | 3db4161 | 2010-06-24 09:33:05 +0000 | [diff] [blame] | 14 | /* Unlike their C counterparts, the following macros are not meant to |
| 15 | * handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument |
| 16 | * must be a signed/unsigned char. */ |
Eric Smith | cac7af6 | 2009-04-27 19:04:37 +0000 | [diff] [blame] | 17 | #define Py_ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER) |
| 18 | #define Py_ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER) |
| 19 | #define Py_ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA) |
| 20 | #define Py_ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_DIGIT) |
| 21 | #define Py_ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_XDIGIT) |
| 22 | #define Py_ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM) |
| 23 | #define Py_ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE) |
| 24 | |
Antoine Pitrou | 5a75355 | 2011-10-04 14:45:32 +0200 | [diff] [blame] | 25 | PyAPI_DATA(const unsigned char) _Py_ctype_tolower[256]; |
| 26 | PyAPI_DATA(const unsigned char) _Py_ctype_toupper[256]; |
Eric Smith | cac7af6 | 2009-04-27 19:04:37 +0000 | [diff] [blame] | 27 | |
| 28 | #define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)]) |
| 29 | #define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)]) |
| 30 | |
| 31 | #endif /* !PYCTYPE_H */ |