diff options
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/floatobject.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index b7b5220..f78f7df 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -15,6 +15,11 @@ #define MAX(x, y) ((x) < (y) ? (y) : (x)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) +/* ascii character tests (as opposed to locale tests) */ +#define ISSPACE(c) ((c) == ' ' || (c) == '\f' || (c) == '\n' || \ + (c) == '\r' || (c) == '\t' || (c) == '\v') +#define ISDIGIT(c) ((c) >= '0' && (c) <= '9') + #ifdef HAVE_IEEEFP_H #include <ieeefp.h> #endif @@ -188,7 +193,7 @@ PyFloat_FromString(PyObject *v) } last = s + len; - while (*s && isspace(Py_CHARMASK(*s))) + while (*s && ISSPACE(Py_CHARMASK(*s))) s++; if (*s == '\0') { PyErr_SetString(PyExc_ValueError, "empty string for float()"); @@ -245,7 +250,7 @@ PyFloat_FromString(PyObject *v) } /* Since end != s, the platform made *some* kind of sense out of the input. Trust it. */ - while (*end && isspace(Py_CHARMASK(*end))) + while (*end && ISSPACE(Py_CHARMASK(*end))) end++; if (*end != '\0') { PyOS_snprintf(buffer, sizeof(buffer), @@ -1275,7 +1280,7 @@ float_fromhex(PyObject *cls, PyObject *arg) ********************/ /* leading whitespace and optional sign */ - while (isspace(Py_CHARMASK(*s))) + while (ISSPACE(Py_CHARMASK(*s))) s++; if (*s == '-') { s++; @@ -1299,6 +1304,7 @@ float_fromhex(PyObject *cls, PyObject *arg) s_store = s; if (*s == '0') { s++; + if (*s == 'x' || *s == 'X') if (tolower(*s) == (int)'x') s++; else @@ -1345,7 +1351,7 @@ float_fromhex(PyObject *cls, PyObject *arg) exp = 0; /* optional trailing whitespace leading to the end of the string */ - while (isspace(Py_CHARMASK(*s))) + while (ISSPACE(Py_CHARMASK(*s))) s++; if (s != s_end) goto parse_error; |