]> granicus.if.org Git - python/commitdiff
Eliminate some locale-dependent calls to isspace and tolower.
authorMark Dickinson <dickinsm@gmail.com>
Sun, 3 May 2009 20:59:48 +0000 (20:59 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Sun, 3 May 2009 20:59:48 +0000 (20:59 +0000)
Objects/complexobject.c
Objects/floatobject.c
Python/pystrtod.c

index 2ae8056ac611f1aab530bfd28b65fdf6cabaea2d..f0f25415a78d36f1bcfba0e76393a97a90aecc4b 100644 (file)
@@ -950,13 +950,13 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
 
        /* position on first nonblank */
        start = s;
-       while (*s && isspace(Py_CHARMASK(*s)))
+       while (Py_ISSPACE(*s))
                s++;
        if (*s == '(') {
                /* Skip over possible bracket from repr(). */
                got_bracket = 1;
                s++;
-               while (*s && isspace(Py_CHARMASK(*s)))
+               while (Py_ISSPACE(*s))
                        s++;
        }
 
@@ -1038,7 +1038,7 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
        }
 
        /* trailing whitespace and closing bracket */
-       while (*s && isspace(Py_CHARMASK(*s)))
+       while (Py_ISSPACE(*s))
                s++;
        if (got_bracket) {
                /* if there was an opening parenthesis, then the corresponding
@@ -1046,7 +1046,7 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
                if (*s != ')')
                        goto parse_error;
                s++;
-               while (*s && isspace(Py_CHARMASK(*s)))
+               while (Py_ISSPACE(*s))
                        s++;
        }
 
index 58f27e68ce981bb38326f55faaa96142a396c4d8..9a0dbb33c210cc6e5f0602b34da5d98719ab94a1 100644 (file)
@@ -214,7 +214,7 @@ PyFloat_FromString(PyObject *v, char **pend)
        }
        last = s + len;
 
-       while (*s && isspace(Py_CHARMASK(*s)))
+       while (Py_ISSPACE(*s))
                s++;
        /* We don't care about overflow or underflow.  If the platform
         * supports them, infinities and signed zeroes (on underflow) are
@@ -235,7 +235,7 @@ PyFloat_FromString(PyObject *v, char **pend)
        }
        /* Since end != s, the platform made *some* kind of sense out
           of the input.  Trust it. */
-       while (*end && isspace(Py_CHARMASK(*end)))
+       while (Py_ISSPACE(*end))
                end++;
        if (end != last) {
                if (*end == '\0')
@@ -1220,7 +1220,7 @@ float_fromhex(PyObject *cls, PyObject *arg)
         ********************/
 
        /* leading whitespace and optional sign */
-       while (isspace(*s))
+       while (Py_ISSPACE(*s))
                s++;
        if (*s == '-') {
                s++;
@@ -1244,7 +1244,7 @@ float_fromhex(PyObject *cls, PyObject *arg)
        s_store = s;
        if (*s == '0') {
                s++;
-               if (tolower(*s) == (int)'x')
+               if (*s == 'x' || *s == 'X')
                        s++;
                else
                        s = s_store;
@@ -1274,7 +1274,7 @@ float_fromhex(PyObject *cls, PyObject *arg)
                goto insane_length_error;
 
        /* [p <exponent>] */
-       if (tolower(*s) == (int)'p') {
+       if (*s == 'p' || *s == 'P') {
                s++;
                exp_start = s;
                if (*s == '-' || *s == '+')
@@ -1290,7 +1290,7 @@ float_fromhex(PyObject *cls, PyObject *arg)
                exp = 0;
 
        /* optional trailing whitespace leading to the end of the string */
-       while (isspace(*s))
+       while (Py_ISSPACE(*s))
                s++;
        if (s != s_end)
                goto parse_error;
index 30dd4e539418a0e3085923a99d3897a1629e5f56..9aeef2805fbfcc4233fd3ae6f8f6860316004cba 100644 (file)
@@ -718,7 +718,7 @@ _PyOS_double_to_string(char *buf, size_t buf_len, double val,
                /* Convert to upper case. */
                char *p;
                for (p = buf; *p; p++)
-                       *p = toupper(*p);
+                       *p = Py_TOUPPER(*p);
        }
 
        if (ptype)