Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 12924:2d0b99778edf legacy-trunk
Marc-Andre Lemburg <mal@lemburg.com>:
Added code so that .isXXX() testing returns 0 for emtpy strings.
| author | Marc-André Lemburg <mal@egenix.com> |
|---|---|
| date | Wed, 14 Jun 2000 09:18:32 +0000 |
| parents | 98eb3059ae76 |
| children | 447efb64c72d |
line wrap: on
line diff
--- a/Objects/stringobject.c Wed Jun 14 09:17:25 2000 +0000 +++ b/Objects/stringobject.c Wed Jun 14 09:18:32 2000 +0000 @@ -1927,6 +1927,10 @@ isspace(*p)) return PyInt_FromLong(1); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyString_GET_SIZE(self); for (; p < e; p++) { if (!isspace(*p)) @@ -1956,6 +1960,10 @@ isdigit(*p)) return PyInt_FromLong(1); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyString_GET_SIZE(self); for (; p < e; p++) { if (!isdigit(*p)) @@ -1985,6 +1993,10 @@ if (PyString_GET_SIZE(self) == 1) return PyInt_FromLong(islower(*p) != 0); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyString_GET_SIZE(self); cased = 0; for (; p < e; p++) { @@ -2017,6 +2029,10 @@ if (PyString_GET_SIZE(self) == 1) return PyInt_FromLong(isupper(*p) != 0); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyString_GET_SIZE(self); cased = 0; for (; p < e; p++) { @@ -2050,6 +2066,10 @@ if (PyString_GET_SIZE(self) == 1) return PyInt_FromLong(isupper(*p) != 0); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyString_GET_SIZE(self); cased = 0; previous_is_cased = 0;
