diff Python/mystrtoul.c @ 46149:7fdff02e6f45 legacy-trunk

Revert r61969 which added casts to Py_CHARMASK to avoid compiler warnings. Rather than sprinkle casts throughout the code, change Py_CHARMASK to always cast it's result to an unsigned char. This should ensure we do the right thing when accessing an array with the result.
author Neal Norwitz <nnorwitz@gmail.com>
date Fri, 28 Mar 2008 04:58:51 +0000
parents 5078b7ee16dc
children fd25030223b0
line wrap: on
line diff
--- a/Python/mystrtoul.c	Fri Mar 28 04:53:10 2008 +0000
+++ b/Python/mystrtoul.c	Fri Mar 28 04:58:51 2008 +0000
@@ -109,7 +109,7 @@
 			++str;
 			if (*str == 'x' || *str == 'X') {
 				/* there must be at least one digit after 0x */
-				if (_PyLong_DigitValue[(unsigned)Py_CHARMASK(str[1])] >= 16) {
+				if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 16) {
 					if (ptr)
 						*ptr = str;
 					return 0;
@@ -118,7 +118,7 @@
 				base = 16;
 			} else if (*str == 'o' || *str == 'O') {
 				/* there must be at least one digit after 0o */
-				if (_PyLong_DigitValue[(unsigned)Py_CHARMASK(str[1])] >= 8) {
+				if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 8) {
 					if (ptr)
 						*ptr = str;
 					return 0;
@@ -127,7 +127,7 @@
 				base = 8;
 			} else if (*str == 'b' || *str == 'B') {
 				/* there must be at least one digit after 0b */
-				if (_PyLong_DigitValue[(unsigned)Py_CHARMASK(str[1])] >= 2) {
+				if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 2) {
 					if (ptr)
 						*ptr = str;
 					return 0;
@@ -147,7 +147,7 @@
 			++str;
 			if (*str == 'b' || *str == 'B') {
 				/* there must be at least one digit after 0b */
-				if (_PyLong_DigitValue[(unsigned)Py_CHARMASK(str[1])] >= 2) {
+				if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 2) {
 					if (ptr)
 						*ptr = str;
 					return 0;
@@ -162,7 +162,7 @@
 			++str;
 			if (*str == 'o' || *str == 'O') {
 				/* there must be at least one digit after 0o */
-				if (_PyLong_DigitValue[(unsigned)Py_CHARMASK(str[1])] >= 8) {
+				if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 8) {
 					if (ptr)
 						*ptr = str;
 					return 0;
@@ -177,7 +177,7 @@
 			++str;
 			if (*str == 'x' || *str == 'X') {
 				/* there must be at least one digit after 0x */
-				if (_PyLong_DigitValue[(unsigned)Py_CHARMASK(str[1])] >= 16) {
+				if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 16) {
 					if (ptr)
 						*ptr = str;
 					return 0;
@@ -203,7 +203,7 @@
 	ovlimit = digitlimit[base];
 
 	/* do the conversion until non-digit character encountered */
-	while ((c = _PyLong_DigitValue[(unsigned)Py_CHARMASK(*str)]) < base) {
+	while ((c = _PyLong_DigitValue[Py_CHARMASK(*str)]) < base) {
 		if (ovlimit > 0) /* no overflow check required */
 			result = result * base + c;
 		else { /* requires overflow check */
@@ -240,7 +240,7 @@
 overflowed:
 	if (ptr) {
 		/* spool through remaining digit characters */
-		while (_PyLong_DigitValue[(unsigned)Py_CHARMASK(*str)] < base)
+		while (_PyLong_DigitValue[Py_CHARMASK(*str)] < base)
 			++str;
 		*ptr = str;
 	}