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