[Python-checkins] r65964 - python/trunk/Objects/floatobject.c
mark.dickinson
python-checkins at python.org
Thu Aug 21 23:38:39 CEST 2008
Author: mark.dickinson
Date: Thu Aug 21 23:38:38 2008
New Revision: 65964
Log:
issue 3633: Solaris allows fullwidth Unicode digits in isxdigit, so
rewrite float.fromhex to only allow ASCII hex digits on all platforms.
(Tests for this are already present, but the test_float failures
on Solaris hadn't been noticed before.)
Reviewed by Antoine Pitrou.
Modified:
python/trunk/Objects/floatobject.c
Modified: python/trunk/Objects/floatobject.c
==============================================================================
--- python/trunk/Objects/floatobject.c (original)
+++ python/trunk/Objects/floatobject.c Thu Aug 21 23:38:38 2008
@@ -1126,7 +1126,6 @@
static int
hex_from_char(char c) {
int x;
- assert(isxdigit(c));
switch(c) {
case '0':
x = 0;
@@ -1355,12 +1354,12 @@
/* coefficient: <integer> [. <fraction>] */
coeff_start = s;
- while (isxdigit(*s))
+ while (hex_from_char(*s) >= 0)
s++;
s_store = s;
if (*s == '.') {
s++;
- while (isxdigit(*s))
+ while (hex_from_char(*s) >= 0)
s++;
coeff_end = s-1;
}
@@ -1382,10 +1381,10 @@
exp_start = s;
if (*s == '-' || *s == '+')
s++;
- if (!isdigit(*s))
+ if (!('0' <= *s && *s <= '9'))
goto parse_error;
s++;
- while (isdigit(*s))
+ while ('0' <= *s && *s <= '9')
s++;
exp = strtol(exp_start, NULL, 10);
}
More information about the Python-checkins
mailing list