mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
Issue #5793: rationalize isdigit / isalpha / tolower, etc. Will port to py3k. Should fix Windows buildbot errors.
This commit is contained in:
parent
ec047e0725
commit
cac7af6863
15 changed files with 338 additions and 303 deletions
|
@ -134,6 +134,7 @@
|
|||
#include "compile.h"
|
||||
#include "eval.h"
|
||||
|
||||
#include "pyctype.h"
|
||||
#include "pystrtod.h"
|
||||
#include "pystrcmp.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)
|
||||
|
|
28
Include/pyctype.h
Normal file
28
Include/pyctype.h
Normal file
|
@ -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 */
|
Loading…
Add table
Add a link
Reference in a new issue