*** Objects/stringobject.c.old Tue Aug 26 22:08:19 2003 --- Objects/stringobject.c Thu Oct 16 22:36:18 2003 *************** *** 2732,2745 **** return (PyObject*) s; } - PyDoc_STRVAR(isspace__doc__, - "S.isspace() -> bool\n" - "\n" - "Return True if there are only whitespace characters in S,\n" - "False otherwise."); - static PyObject* ! string_isspace(PyStringObject *self) { register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); --- 2732,2739 ---- return (PyObject*) s; } static PyObject* ! is_helper(PyStringObject *self, int (*func)(int)) { register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); *************** *** 2747,2753 **** /* Shortcut for single character strings */ if (PyString_GET_SIZE(self) == 1 && ! isspace(*p)) return PyBool_FromLong(1); /* Special case for empty strings */ --- 2741,2747 ---- /* Shortcut for single character strings */ if (PyString_GET_SIZE(self) == 1 && ! func(*p)) return PyBool_FromLong(1); /* Special case for empty strings */ *************** *** 2756,2767 **** e = p + PyString_GET_SIZE(self); for (; p < e; p++) { ! if (!isspace(*p)) return PyBool_FromLong(0); } return PyBool_FromLong(1); } PyDoc_STRVAR(isalpha__doc__, "S.isalpha() -> bool\n\ --- 2750,2773 ---- e = p + PyString_GET_SIZE(self); for (; p < e; p++) { ! if (!func(*p)) return PyBool_FromLong(0); } return PyBool_FromLong(1); } + PyDoc_STRVAR(isspace__doc__, + "S.isspace() -> bool\n" + "\n" + "Return True if there are only whitespace characters in S,\n" + "False otherwise."); + + static PyObject* + string_isspace(PyStringObject *self) + { + return is_helper(self, isspace); + } + PyDoc_STRVAR(isalpha__doc__, "S.isalpha() -> bool\n\ *************** *** 2772,2796 **** static PyObject* string_isalpha(PyStringObject *self) { ! register const unsigned char *p ! = (unsigned char *) PyString_AS_STRING(self); ! register const unsigned char *e; ! ! /* Shortcut for single character strings */ ! if (PyString_GET_SIZE(self) == 1 && ! isalpha(*p)) ! return PyBool_FromLong(1); ! ! /* Special case for empty strings */ ! if (PyString_GET_SIZE(self) == 0) ! return PyBool_FromLong(0); ! ! e = p + PyString_GET_SIZE(self); ! for (; p < e; p++) { ! if (!isalpha(*p)) ! return PyBool_FromLong(0); ! } ! return PyBool_FromLong(1); } --- 2778,2784 ---- static PyObject* string_isalpha(PyStringObject *self) { ! return is_helper(self, isalpha); } *************** *** 2803,2827 **** static PyObject* string_isalnum(PyStringObject *self) { ! register const unsigned char *p ! = (unsigned char *) PyString_AS_STRING(self); ! register const unsigned char *e; ! ! /* Shortcut for single character strings */ ! if (PyString_GET_SIZE(self) == 1 && ! isalnum(*p)) ! return PyBool_FromLong(1); ! ! /* Special case for empty strings */ ! if (PyString_GET_SIZE(self) == 0) ! return PyBool_FromLong(0); ! ! e = p + PyString_GET_SIZE(self); ! for (; p < e; p++) { ! if (!isalnum(*p)) ! return PyBool_FromLong(0); ! } ! return PyBool_FromLong(1); } --- 2791,2797 ---- static PyObject* string_isalnum(PyStringObject *self) { ! return is_helper(self, isalnum); } *************** *** 2834,2860 **** static PyObject* string_isdigit(PyStringObject *self) { ! register const unsigned char *p ! = (unsigned char *) PyString_AS_STRING(self); ! register const unsigned char *e; ! /* Shortcut for single character strings */ ! if (PyString_GET_SIZE(self) == 1 && ! isdigit(*p)) ! return PyBool_FromLong(1); ! /* Special case for empty strings */ ! if (PyString_GET_SIZE(self) == 0) ! return PyBool_FromLong(0); ! e = p + PyString_GET_SIZE(self); ! for (; p < e; p++) { ! if (!isdigit(*p)) ! return PyBool_FromLong(0); ! } ! return PyBool_FromLong(1); } PyDoc_STRVAR(islower__doc__, "S.islower() -> bool\n\ --- 2804,2871 ---- static PyObject* string_isdigit(PyStringObject *self) { ! return is_helper(self, isdigit); ! } ! PyDoc_STRVAR(iscntrl__doc__, ! "S.iscntrl() -> bool\n\ ! \n\ ! Return True if there are only characters in S,\n\ ! False otherwise."); ! static PyObject* ! string_iscntrl(PyStringObject *self) ! { ! return is_helper(self, iscntrl); ! } ! PyDoc_STRVAR(isgraph__doc__, ! "S.isgraph() -> bool\n\ ! \n\ ! Return True if there are only characters in S,\n\ ! False otherwise."); ! ! static PyObject* ! string_isgraph(PyStringObject *self) ! { ! return is_helper(self, isgraph); ! } ! ! PyDoc_STRVAR(isprint__doc__, ! "S.isprint() -> bool\n\ ! \n\ ! Return True if there are only characters in S,\n\ ! False otherwise."); ! ! static PyObject* ! string_isprint(PyStringObject *self) ! { ! return is_helper(self, isprint); ! } ! ! PyDoc_STRVAR(ispunct__doc__, ! "S.ispunct() -> bool\n\ ! \n\ ! Return True if there are only characters in S,\n\ ! False otherwise."); ! ! static PyObject* ! string_ispunct(PyStringObject *self) ! { ! return is_helper(self, ispunct); } + PyDoc_STRVAR(isxdigit__doc__, + "S.isxdigit() -> bool\n\ + \n\ + Return True if there are only characters in S,\n\ + False otherwise."); + + static PyObject* + string_isxdigit(PyStringObject *self) + { + return is_helper(self, isxdigit); + } PyDoc_STRVAR(islower__doc__, "S.islower() -> bool\n\ *************** *** 3067,3072 **** --- 3078,3088 ---- {"istitle", (PyCFunction)string_istitle, METH_NOARGS, istitle__doc__}, {"isalpha", (PyCFunction)string_isalpha, METH_NOARGS, isalpha__doc__}, {"isalnum", (PyCFunction)string_isalnum, METH_NOARGS, isalnum__doc__}, + {"iscntrl", (PyCFunction)string_iscntrl, METH_NOARGS, iscntrl__doc__}, + {"isgraph", (PyCFunction)string_isgraph, METH_NOARGS, isgraph__doc__}, + {"isprint", (PyCFunction)string_isprint, METH_NOARGS, isprint__doc__}, + {"ispunct", (PyCFunction)string_ispunct, METH_NOARGS, ispunct__doc__}, + {"isxdigit", (PyCFunction)string_isxdigit, METH_NOARGS, isxdigit__doc__}, {"capitalize", (PyCFunction)string_capitalize, METH_NOARGS, capitalize__doc__}, {"count", (PyCFunction)string_count, METH_VARARGS, count__doc__},