diff options
author | Eric Smith <eric@trueblade.com> | 2009-04-27 19:04:37 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2009-04-27 19:04:37 (GMT) |
commit | cac7af6863a997376bffe00ecf07a62c5618a5d9 (patch) | |
tree | 625ae6ebde4f6027d49bb3d40b6955888527fb05 /Include | |
parent | ec047e0725cf31f24eb5ed3c43e6da843deea83a (diff) | |
download | cpython-cac7af6863a997376bffe00ecf07a62c5618a5d9.zip cpython-cac7af6863a997376bffe00ecf07a62c5618a5d9.tar.gz cpython-cac7af6863a997376bffe00ecf07a62c5618a5d9.tar.bz2 |
Issue #5793: rationalize isdigit / isalpha / tolower, etc. Will port to py3k. Should fix Windows buildbot errors.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/Python.h | 1 | ||||
-rw-r--r-- | Include/bytes_methods.h | 35 | ||||
-rw-r--r-- | Include/pyctype.h | 28 |
3 files changed, 42 insertions, 22 deletions
diff --git a/Include/Python.h b/Include/Python.h index 7af6b13..9e140a5 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -134,6 +134,7 @@ #include "compile.h" #include "eval.h" +#include "pyctype.h" #include "pystrtod.h" #include "pystrcmp.h" diff --git a/Include/bytes_methods.h b/Include/bytes_methods.h index 59873f2..4125666 100644 --- a/Include/bytes_methods.h +++ b/Include/bytes_methods.h @@ -34,23 +34,15 @@ extern const char _Py_title__doc__[]; extern const char _Py_capitalize__doc__[]; extern const char _Py_swapcase__doc__[]; -#define FLAG_LOWER 0x01 -#define FLAG_UPPER 0x02 -#define FLAG_ALPHA (FLAG_LOWER|FLAG_UPPER) -#define FLAG_DIGIT 0x04 -#define FLAG_ALNUM (FLAG_ALPHA|FLAG_DIGIT) -#define FLAG_SPACE 0x08 -#define FLAG_XDIGIT 0x10 - -extern const unsigned int _Py_ctype_table[256]; - -#define ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_LOWER) -#define ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_UPPER) -#define ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_ALPHA) -#define ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_DIGIT) -#define ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_XDIGIT) -#define ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_ALNUM) -#define ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_SPACE) +/* These are left in for backward compatibility and will be removed + in 2.8/3.2 */ +#define ISLOWER(c) Py_ISLOWER(c) +#define ISUPPER(c) Py_ISUPPER(c) +#define ISALPHA(c) Py_ISALPHA(c) +#define ISDIGIT(c) Py_ISDIGIT(c) +#define ISXDIGIT(c) Py_ISXDIGIT(c) +#define ISALNUM(c) Py_ISALNUM(c) +#define ISSPACE(c) Py_ISSPACE(c) #undef islower #define islower(c) undefined_islower(c) @@ -67,11 +59,10 @@ extern const unsigned int _Py_ctype_table[256]; #undef isspace #define isspace(c) undefined_isspace(c) -extern const unsigned char _Py_ctype_tolower[256]; -extern const unsigned char _Py_ctype_toupper[256]; - -#define TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)]) -#define TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)]) +/* These are left in for backward compatibility and will be removed + in 2.8/3.2 */ +#define TOLOWER(c) Py_TOLOWER(c) +#define TOUPPER(c) Py_TOUPPER(c) #undef tolower #define tolower(c) undefined_tolower(c) diff --git a/Include/pyctype.h b/Include/pyctype.h new file mode 100644 index 0000000..0d211ec --- /dev/null +++ b/Include/pyctype.h @@ -0,0 +1,28 @@ +#ifndef PYCTYPE_H +#define PYCTYPE_H + +#define PY_CTF_LOWER 0x01 +#define PY_CTF_UPPER 0x02 +#define PY_CTF_ALPHA (PY_CTF_LOWER|PY_CTF_UPPER) +#define PY_CTF_DIGIT 0x04 +#define PY_CTF_ALNUM (PY_CTF_ALPHA|PY_CTF_DIGIT) +#define PY_CTF_SPACE 0x08 +#define PY_CTF_XDIGIT 0x10 + +extern const unsigned int _Py_ctype_table[256]; + +#define Py_ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER) +#define Py_ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER) +#define Py_ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA) +#define Py_ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_DIGIT) +#define Py_ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_XDIGIT) +#define Py_ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM) +#define Py_ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE) + +extern const unsigned char _Py_ctype_tolower[256]; +extern const unsigned char _Py_ctype_toupper[256]; + +#define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)]) +#define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)]) + +#endif /* !PYCTYPE_H */ |