diff options
author | Eric Smith <eric@trueblade.com> | 2009-04-27 20:39:49 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2009-04-27 20:39:49 (GMT) |
commit | 6dc46f5eaa14c8aa33b8ae5b41642a00a1b25807 (patch) | |
tree | fc063968e5d131487c7418647e2cf4abf942cdff /Python | |
parent | 249b898ec7839cc022d5d0b7638284663a6edfb7 (diff) | |
download | cpython-6dc46f5eaa14c8aa33b8ae5b41642a00a1b25807.zip cpython-6dc46f5eaa14c8aa33b8ae5b41642a00a1b25807.tar.gz cpython-6dc46f5eaa14c8aa33b8ae5b41642a00a1b25807.tar.bz2 |
Merged revisions 72040 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r72040 | eric.smith | 2009-04-27 15:04:37 -0400 (Mon, 27 Apr 2009) | 1 line
Issue #5793: rationalize isdigit / isalpha / tolower, etc. Will port to py3k. Should fix Windows buildbot errors.
........
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pystrtod.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/Python/pystrtod.c b/Python/pystrtod.c index 872cc37..6d1e7ed 100644 --- a/Python/pystrtod.c +++ b/Python/pystrtod.c @@ -3,12 +3,6 @@ #include <Python.h> #include <locale.h> -/* 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') - - /** * PyOS_ascii_strtod: * @nptr: the string to convert to a numeric value. @@ -104,7 +98,7 @@ PyOS_ascii_strtod(const char *nptr, char **endptr) p = nptr; /* Skip leading space */ - while (ISSPACE(*p)) + while (Py_ISSPACE(*p)) p++; /* Process leading sign, if present */ @@ -147,7 +141,7 @@ PyOS_ascii_strtod(const char *nptr, char **endptr) goto invalid_string; /* Check that what's left begins with a digit or decimal point */ - if (!ISDIGIT(*p) && *p != '.') + if (!Py_ISDIGIT(*p) && *p != '.') goto invalid_string; digits_pos = p; @@ -158,7 +152,7 @@ PyOS_ascii_strtod(const char *nptr, char **endptr) swapped for the current locale's decimal point before we call strtod. On the other hand, if we find the current locale's decimal point then the input is invalid. */ - while (ISDIGIT(*p)) + while (Py_ISDIGIT(*p)) p++; if (*p == '.') @@ -166,14 +160,14 @@ PyOS_ascii_strtod(const char *nptr, char **endptr) decimal_point_pos = p++; /* locate end of number */ - while (ISDIGIT(*p)) + while (Py_ISDIGIT(*p)) p++; if (*p == 'e' || *p == 'E') p++; if (*p == '+' || *p == '-') p++; - while (ISDIGIT(*p)) + while (Py_ISDIGIT(*p)) p++; end = p; } @@ -269,7 +263,7 @@ change_decimal_from_locale_to_dot(char* buffer) if (*buffer == '+' || *buffer == '-') buffer++; - while (isdigit(Py_CHARMASK(*buffer))) + while (Py_ISDIGIT(*buffer)) buffer++; if (strncmp(buffer, decimal_point, decimal_point_len) == 0) { *buffer = '.'; @@ -312,7 +306,7 @@ ensure_minimum_exponent_length(char* buffer, size_t buf_size) /* Find the end of the exponent, keeping track of leading zeros. */ - while (*p && isdigit(Py_CHARMASK(*p))) { + while (*p && Py_ISDIGIT(*p)) { if (in_leading_zeros && *p == '0') ++leading_zero_cnt; if (*p != '0') @@ -375,11 +369,11 @@ ensure_decimal_point(char* buffer, size_t buf_size) /* Skip leading sign, if present. I think this could only ever be '-', but it can't hurt to check for both. */ ++p; - while (*p && isdigit(Py_CHARMASK(*p))) + while (*p && Py_ISDIGIT(*p)) ++p; if (*p == '.') { - if (isdigit(Py_CHARMASK(*(p+1)))) { + if (Py_ISDIGIT(*(p+1))) { /* Nothing to do, we already have a decimal point and a digit after it */ } |