]> granicus.if.org Git - python/commitdiff
Fix SF bug #1072182, problems with signed characters.
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 19 Dec 2005 06:05:18 +0000 (06:05 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 19 Dec 2005 06:05:18 +0000 (06:05 +0000)
Most of these can be backported.

Modules/_hotshot.c
Modules/_tkinter.c
Modules/posixmodule.c
Modules/pyexpat.c
Modules/socketmodule.c
Modules/stropmodule.c
Parser/grammar.c
Parser/tokenizer.c
Python/ast.c
Python/dynload_aix.c
Python/getargs.c

index 5e4a9f774792ed0c14e83ad0f52c182d5a5e15ec..758c4ee04c92f17027d0e03e5588a8b28b901ff5 100644 (file)
@@ -1396,7 +1396,7 @@ get_version_string(void)
     char *buffer;
     int i = 0;
 
-    while (*rev && !isdigit((int)*rev))
+    while (*rev && !isdigit(Py_CHARMASK(*rev)))
         ++rev;
     while (rev[i] != ' ' && rev[i] != '\0')
         ++i;
index dd1620aec1cf90bbd147c9151379f40ec76ba2fc..b898249a2f9d7f1b2e8d34df475c979065acd9d1 100644 (file)
@@ -636,7 +636,7 @@ Tkapp_New(char *screenName, char *baseName, char *className,
        }
 
        strcpy(argv0, className);
-       if (isupper((int)(argv0[0])))
+       if (isupper(Py_CHARMASK((argv0[0]))))
                argv0[0] = tolower(argv0[0]);
        Tcl_SetVar(v->interp, "argv0", argv0, TCL_GLOBAL_ONLY);
        ckfree(argv0);
index a08058f6f1f58c5646c4cf134e1eb2faf7425cfc..b7835736856c2c76e4fc7db246a41c2fb44e47bf 100644 (file)
@@ -463,7 +463,7 @@ os2_formatmsg(char *msgbuf, int msglen, char *reason)
     if (strlen(msgbuf) > 0) { /* If Non-Empty Msg, Trim CRLF */
         char *lastc = &msgbuf[ strlen(msgbuf)-1 ];
 
-        while (lastc > msgbuf && isspace(*lastc))
+        while (lastc > msgbuf && isspace(Py_CHARMASK(*lastc)))
             *lastc-- = '\0'; /* Trim Trailing Whitespace (CRLF) */
     }
 
index ca2a850478c86f4cc41fa9e88184b7dbdffec6fa..c827581b1d198663e8d598174b748ff14d376a2b 100644 (file)
@@ -1803,7 +1803,7 @@ get_version_string(void)
     char *rev = rcsid;
     int i = 0;
 
-    while (!isdigit((int)*rev))
+    while (!isdigit(Py_CHARMASK(*rev)))
         ++rev;
     while (rev[i] != ' ' && rev[i] != '\0')
         ++i;
index 33914052a6d8f06ac33633fae3041cdd1fd054df..038bd1fa881a355afc50851f21e754d45ea9b842 100644 (file)
@@ -506,7 +506,8 @@ set_error(void)
                        if (strlen(outbuf) > 0) {
                                /* If non-empty msg, trim CRLF */
                                char *lastc = &outbuf[ strlen(outbuf)-1 ];
-                               while (lastc > outbuf && isspace(*lastc)) {
+                               while (lastc > outbuf &&
+                                      isspace(Py_CHARMASK(*lastc))) {
                                        /* Trim trailing whitespace (CRLF) */
                                        *lastc-- = '\0';
                                }
index ce19a053a09856dcdc2fae033f8cc7e27b1957c2..ed72a7163b231a715cd566d4a41f777d897057eb 100644 (file)
@@ -757,7 +757,7 @@ strop_atoi(PyObject *self, PyObject *args)
                x = (long) PyOS_strtoul(s, &end, base);
        else
                x = PyOS_strtol(s, &end, base);
-       if (end == s || !isalnum((int)end[-1]))
+       if (end == s || !isalnum(Py_CHARMASK(end[-1])))
                goto bad;
        while (*end && isspace(Py_CHARMASK(*end)))
                end++;
index c0613dfcfe1b1cfab4eafb8da9654087e16d8ff6..d8e38973dbfa3e07010b084739fea1e41f2661ca 100644 (file)
@@ -180,7 +180,8 @@ translabel(grammar *g, label *lb)
        }
        
        if (lb->lb_type == STRING) {
-               if (isalpha((int)(lb->lb_str[1])) || lb->lb_str[1] == '_') {
+               if (isalpha(Py_CHARMASK(lb->lb_str[1])) ||
+                   lb->lb_str[1] == '_') {
                        char *p;
                        char *src;
                        char *dest;
index a79ea811294f36b6846e6ab820ef33fad7ffed16..3b1d6a63aca759ffa7bad4149e55d7b7c5bcc935 100644 (file)
@@ -229,7 +229,7 @@ get_coding_spec(const char *s, int size)
                        } while (t[0] == '\x20' || t[0] == '\t');
 
                        begin = t;
-                       while (isalnum((int)t[0]) ||
+                       while (isalnum(Py_CHARMASK(t[0])) ||
                               t[0] == '-' || t[0] == '_' || t[0] == '.')
                                t++;
 
index dde0d04f87365642044b0689362e8030d1e8d176..93334dc18ecdecbfd28d5198670a29c6b6ba954b 100644 (file)
@@ -2879,7 +2879,7 @@ static PyObject *
 parsestr(const char *s, const char *encoding)
 {
        size_t len;
-       int quote = *s;
+       int quote = Py_CHARMASK(*s);
        int rawmode = 0;
        int need_encoding;
        int unicode = 0;
index 03ecc0724ae39bd9a696e291efc4b1615aa7c43c..7a604f2238d613abe62502b3388ec2d51b2833c5 100644 (file)
@@ -144,7 +144,7 @@ aix_loaderror(const char *pathname)
                    if (nerr == load_errtab[j].errNo && load_errtab[j].errstr)
                        ERRBUF_APPEND(load_errtab[j].errstr);
                }
-               while (isdigit(*message[i])) message[i]++ ; 
+               while (isdigit(Py_CHARMASK(*message[i]))) message[i]++ ; 
                ERRBUF_APPEND(message[i]);
                ERRBUF_APPEND("\n");
        }
index 16f156f229905bde547fe48e7a8882fa0eade5de..23b91fdbd5cf52146f5ed32644d5752b5694e85c 100644 (file)
@@ -166,7 +166,7 @@ vgetargs1(PyObject *args, const char *format, va_list *p_va, int compat)
                        if (level == 0) {
                                if (c == 'O')
                                        max++;
-                               else if (isalpha(c)) {
+                               else if (isalpha(Py_CHARMASK(c))) {
                                        if (c != 'e') /* skip encoded */
                                                max++;
                                } else if (c == '|')
@@ -255,7 +255,7 @@ vgetargs1(PyObject *args, const char *format, va_list *p_va, int compat)
                }
        }
 
-       if (*format != '\0' && !isalpha((int)(*format)) &&
+       if (*format != '\0' && !isalpha(Py_CHARMASK((*format))) &&
            *format != '(' &&
            *format != '|' && *format != ':' && *format != ';') {
                PyErr_Format(PyExc_SystemError,
@@ -347,7 +347,7 @@ converttuple(PyObject *arg, const char **p_format, va_list *p_va, int *levels,
                }
                else if (c == ':' || c == ';' || c == '\0')
                        break;
-               else if (level == 0 && isalpha(c))
+               else if (level == 0 && isalpha(Py_CHARMASK(c)))
                        n++;
        }
        
@@ -1223,7 +1223,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
        min = -1;
        max = 0;
        while ((i = *format++) != '\0') {
-               if (isalpha(i) && i != 'e') {
+               if (isalpha(Py_CHARMASK(i)) && i != 'e') {
                        max++;
                        if (*p == NULL) {
                                PyErr_SetString(PyExc_RuntimeError,