[Python-checkins] r72253 - in python/trunk: Objects/complexobject.c Objects/floatobject.c Python/pystrtod.c

mark.dickinson python-checkins at python.org
Sun May 3 22:59:49 CEST 2009


Author: mark.dickinson
Date: Sun May 3 22:59:48 2009
New Revision: 72253
Log:
Eliminate some locale-dependent calls to isspace and tolower.
Modified:
 python/trunk/Objects/complexobject.c
 python/trunk/Objects/floatobject.c
 python/trunk/Python/pystrtod.c
Modified: python/trunk/Objects/complexobject.c
==============================================================================
--- python/trunk/Objects/complexobject.c	(original)
+++ python/trunk/Objects/complexobject.c	Sun May 3 22:59:48 2009
@@ -950,13 +950,13 @@
 
 	/* 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 @@
 	}
 
 	/* 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 @@
 		if (*s != ')')
 			goto parse_error;
 		s++;
-		while (*s && isspace(Py_CHARMASK(*s)))
+		while (Py_ISSPACE(*s))
 			s++;
 	}
 
Modified: python/trunk/Objects/floatobject.c
==============================================================================
--- python/trunk/Objects/floatobject.c	(original)
+++ python/trunk/Objects/floatobject.c	Sun May 3 22:59:48 2009
@@ -214,7 +214,7 @@
 	}
 	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 @@
 	}
 	/* 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 @@
 	 ********************/
 
 	/* leading whitespace and optional sign */
-	while (isspace(*s))
+	while (Py_ISSPACE(*s))
 		s++;
 	if (*s == '-') {
 		s++;
@@ -1244,7 +1244,7 @@
 	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 @@
 		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 @@
 		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;
Modified: python/trunk/Python/pystrtod.c
==============================================================================
--- python/trunk/Python/pystrtod.c	(original)
+++ python/trunk/Python/pystrtod.c	Sun May 3 22:59:48 2009
@@ -718,7 +718,7 @@
 		/* Convert to upper case. */
 		char *p;
 		for (p = buf; *p; p++)
-			*p = toupper(*p);
+			*p = Py_TOUPPER(*p);
 	}
 
 	if (ptype)


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /