diff options
author | Guido van Rossum <guido@python.org> | 2000-05-05 20:44:24 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-05-05 20:44:24 (GMT) |
commit | b8f820c5a98a10c5ad94cfec1569b7b80829c55d (patch) | |
tree | 6a42b705c71becf4ff14f796c5a3c2c88cc3e811 /Objects | |
parent | 3a03d4c4c7beeecdc4678ac3ce2f817fd0b1aa39 (diff) | |
download | cpython-b8f820c5a98a10c5ad94cfec1569b7b80829c55d.zip cpython-b8f820c5a98a10c5ad94cfec1569b7b80829c55d.tar.gz cpython-b8f820c5a98a10c5ad94cfec1569b7b80829c55d.tar.bz2 |
The methods islower(), isupper(), isspace(), isdigit() and istitle()
gave bogus results for chars in the range 128-255, because their
implementation was using signed characters. Fixed this by using
unsigned character pointers (as opposed to using Py_CHARMASK()).
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/stringobject.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 288f26e..c94ee88 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -1910,8 +1910,8 @@ Return 1 if there are only whitespace characters in S,\n\ static PyObject* string_isspace(PyStringObject *self, PyObject *args) { - register const char *p = PyString_AS_STRING(self); - register const char *e; + register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); + register const unsigned char *e; if (!PyArg_NoArgs(args)) return NULL; @@ -1939,8 +1939,8 @@ Return 1 if there are only digit characters in S,\n\ static PyObject* string_isdigit(PyStringObject *self, PyObject *args) { - register const char *p = PyString_AS_STRING(self); - register const char *e; + register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); + register const unsigned char *e; if (!PyArg_NoArgs(args)) return NULL; @@ -1968,8 +1968,8 @@ at least one cased character in S, 0 otherwise."; static PyObject* string_islower(PyStringObject *self, PyObject *args) { - register const char *p = PyString_AS_STRING(self); - register const char *e; + register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); + register const unsigned char *e; int cased; if (!PyArg_NoArgs(args)) @@ -2000,8 +2000,8 @@ at least one cased character in S, 0 otherwise."; static PyObject* string_isupper(PyStringObject *self, PyObject *args) { - register const char *p = PyString_AS_STRING(self); - register const char *e; + register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); + register const unsigned char *e; int cased; if (!PyArg_NoArgs(args)) @@ -2033,8 +2033,8 @@ ones. Return 0 otherwise."; static PyObject* string_istitle(PyStringObject *self, PyObject *args) { - register const char *p = PyString_AS_STRING(self); - register const char *e; + register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); + register const unsigned char *e; int cased, previous_is_cased; if (!PyArg_NoArgs(args)) @@ -2048,7 +2048,7 @@ string_istitle(PyStringObject *self, PyObject *args) cased = 0; previous_is_cased = 0; for (; p < e; p++) { - register const char ch = *p; + register const unsigned char ch = *p; if (isupper(ch)) { if (previous_is_cased) |