Commits

Anonymous committed 07913fb

use Py_CHARMASK

Comments (0)

Files changed (5)

Modules/regexmodule.c

 #include "modsupport.h"
 
 #include "regexpr.h"
-#include "ctype.h"
+#include <ctype.h>
 
 static object *RegexError;	/* Exception */	
 
 					++o; /* eat the '>' */
 					break;
 				}
-				if (!isalnum(*o) && *o != '_') {
+				if (!isalnum(Py_CHARMASK(*o)) && *o != '_') {
 					o = backtrack;
 					break;
 				}

Modules/stropmodule.c

 {
 	int len, i, j, err;
 	char *s;
-	char c;
 	object *list, *item;
 
 	if (!getargs(args, "s#", &s, &len))
 
 	i = 0;
 	while (i < len) {
-		while (i < len &&
-		       ((c = s[i]), isspace(c))) {
+		while (i < len && isspace(Py_CHARMASK(s[i]))) {
 			i = i+1;
 		}
 		j = i;
-		while (i < len &&
-		       !((c = s[i]), isspace(c))) {
+		while (i < len && isspace(Py_CHARMASK(s[i]))) {
 			i = i+1;
 		}
 		if (j < i) {
 {
 	char *s;
 	int len, i, j;
-	char c;
 
 	if (!getargs(args, "s#", &s, &len))
 		return NULL;
 
 	i = 0;
-	while (i < len && ((c = s[i]), isspace(c))) {
+	while (i < len && isspace(Py_CHARMASK(s[i]))) {
 		i++;
 	}
 
 	j = len;
 	do {
 		j--;
-	} while (j >= i &&  ((c = s[j]), isspace(c)));
+	} while (j >= i && isspace(Py_CHARMASK(s[i])));
 	j++;
 
 	if (i == 0 && j == len) {
 	s_new = getstringvalue(new);
 	changed = 0;
 	for (i = 0; i < n; i++) {
-		char c = *s++;
+		int c = Py_CHARMASK(*s++);
 		if (isupper(c)) {
 			changed = 1;
 			*s_new = tolower(c);
 	s_new = getstringvalue(new);
 	changed = 0;
 	for (i = 0; i < n; i++) {
-		char c = *s++;
+		int c = Py_CHARMASK(*s++);
 		if (islower(c)) {
 			changed = 1;
 			*s_new = toupper(c);
 	s_new = getstringvalue(new);
 	changed = 0;
 	for (i = 0; i < n; i++) {
-		char c = *s++;
+		int c = Py_CHARMASK(*s++);
 		if (islower(c)) {
 			changed = 1;
 			*s_new = toupper(c);
 
 	/* Create 'whitespace' object */
 	n = 0;
-	for (c = 1; c < 256; c++) {
+	for (c = 0; c < 256; c++) {
 		if (isspace(c))
 			buf[n++] = c;
 	}
 	}
 	/* Create 'lowercase' object */
 	n = 0;
-	for (c = 1; c < 256; c++) {
+	for (c = 0; c < 256; c++) {
 		if (islower(c))
 			buf[n++] = c;
 	}
 
 	/* Create 'uppercase' object */
 	n = 0;
-	for (c = 1; c < 256; c++) {
+	for (c = 0; c < 256; c++) {
 		if (isupper(c))
 			buf[n++] = c;
 	}
 				/* XXX move into writeobject() ? */
 				char *s = getstringvalue(v);
 				int len = getstringsize(v);
-				if (len > 0 && isspace(s[len-1]) &&
+				if (len > 0 &&
+				    isspace(Py_CHARMASK(s[len-1])) &&
 				    s[len-1] != ' ')
 					softspace(w, 0);
 			}
 			*p++ = c;
 			break;
 		case 'x':
-			if (isxdigit(*s)) {
+			if (isxdigit(Py_CHARMASK(*s))) {
 				sscanf(s, "%x", &c);
 				*p++ = c;
 				do {
 					s++;
-				} while (isxdigit(*s));
+				} while (isxdigit(Py_CHARMASK(*s)));
 				break;
 			}
 		/* FALLTHROUGH */

Python/mystrtoul.c

 #include "config.h"
 #endif
 
+/* Convert a possibly signed character to a nonnegative int */
+/* XXX This assumes characters are 8 bits wide */
+#ifdef __CHAR_UNSIGNED__
+#define Py_CHARMASK(c)		(c)
+#else
+#define Py_CHARMASK(c)		((c) & 0xff)
+#endif
+
 #include "rename2.h"
 
 /* strtol and strtoul, renamed to avoid conflicts */
     }
 
 /* skip leading white space */
-    while (*str && isspace(*str))
+    while (*str && isspace(Py_CHARMASK(*str)))
 	str++;
 
 /* check for leading 0 or 0x for auto-base or base 16 */
     }
 
 /* do the conversion */
-    while (c = *str)
+    while (c = Py_CHARMASK(*str))
     {
 	if (isdigit(c) && c - '0' < base)
 	    c -= '0';
 	long result;
 	char sign;
 	
-	while (*str && isspace(*str))
+	while (*str && isspace(Py_CHARMASK(*str)))
 		str++;
 	
 	sign = *str;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.