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.
........
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 @@
p = nptr;
/* Skip leading space */
- while (ISSPACE(*p))
+ while (Py_ISSPACE(*p))
p++;
/* Process leading sign, if present */
@@ -147,7 +141,7 @@
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 @@
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 @@
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 @@
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 @@
/* 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 @@
/* 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 */
}