diff Objects/longobject.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 38c831b47dc5
line wrap: on
line diff
--- a/Objects/longobject.c	Fri Mar 28 04:53:10 2008 +0000
+++ b/Objects/longobject.c	Fri Mar 28 04:58:51 2008 +0000
@@ -1397,7 +1397,7 @@
 		n >>= 1;
 	/* n <- total # of bits needed, while setting p to end-of-string */
 	n = 0;
-	while (_PyLong_DigitValue[(unsigned)Py_CHARMASK(*p)] < base)
+	while (_PyLong_DigitValue[Py_CHARMASK(*p)] < base)
 		++p;
 	*str = p;
 	/* n <- # of Python digits needed, = ceiling(n/PyLong_SHIFT). */
@@ -1418,7 +1418,7 @@
 	bits_in_accum = 0;
 	pdigit = z->ob_digit;
 	while (--p >= start) {
-		int k = _PyLong_DigitValue[(unsigned)Py_CHARMASK(*p)];
+		int k = _PyLong_DigitValue[Py_CHARMASK(*p)];
 		assert(k >= 0 && k < base);
 		accum |= (twodigits)(k << bits_in_accum);
 		bits_in_accum += bits_per_char;
@@ -1609,7 +1609,7 @@
 
 		/* Find length of the string of numeric characters. */
 		scan = str;
-		while (_PyLong_DigitValue[(unsigned)Py_CHARMASK(*scan)] < base)
+		while (_PyLong_DigitValue[Py_CHARMASK(*scan)] < base)
 			++scan;
 
 		/* Create a long object that can contain the largest possible
@@ -1635,10 +1635,10 @@
 		/* Work ;-) */
 		while (str < scan) {
 			/* grab up to convwidth digits from the input string */
-			c = (digit)_PyLong_DigitValue[(unsigned)Py_CHARMASK(*str++)];
+			c = (digit)_PyLong_DigitValue[Py_CHARMASK(*str++)];
 			for (i = 1; i < convwidth && str != scan; ++i, ++str) {
 				c = (twodigits)(c *  base +
-					_PyLong_DigitValue[(unsigned)Py_CHARMASK(*str)]);
+					_PyLong_DigitValue[Py_CHARMASK(*str)]);
 				assert(c < PyLong_BASE);
 			}