[Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.67,2.68
M.-A. Lemburg
python-dev@python.org
Wed, 14 Jun 2000 02:18:11 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory slayer.i.sourceforge.net:/tmp/cvs-serv3664/Objects
Modified Files:
stringobject.c
Log Message:
Marc-Andre Lemburg <mal@lemburg.com>:
Added code so that .isXXX() testing returns 0 for emtpy strings.
Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.67
retrieving revision 2.68
diff -C2 -r2.67 -r2.68
*** stringobject.c 2000/06/09 14:04:53 2.67
--- stringobject.c 2000/06/14 09:18:09 2.68
***************
*** 1928,1931 ****
--- 1928,1935 ----
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++) {
***************
*** 1957,1960 ****
--- 1961,1968 ----
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++) {
***************
*** 1986,1989 ****
--- 1994,2001 ----
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;
***************
*** 2018,2021 ****
--- 2030,2037 ----
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;
***************
*** 2050,2053 ****
--- 2066,2073 ----
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);