From 30b5c5d0116f8e670a6ca74dcb6bd076a919d681 Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Mon, 19 Dec 2005 06:05:18 +0000 Subject: Fix SF bug #1072182, problems with signed characters. Most of these can be backported. --- Modules/_hotshot.c | 2 +- Modules/_tkinter.c | 2 +- Modules/posixmodule.c | 2 +- Modules/pyexpat.c | 2 +- Modules/socketmodule.c | 3 ++- Modules/stropmodule.c | 2 +- Parser/grammar.c | 3 ++- Parser/tokenizer.c | 2 +- Python/ast.c | 2 +- Python/dynload_aix.c | 2 +- Python/getargs.c | 8 ++++---- 11 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Modules/_hotshot.c b/Modules/_hotshot.c index 5e4a9f7..758c4ee 100644 --- a/Modules/_hotshot.c +++ b/Modules/_hotshot.c @@ -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; diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index dd1620a..b898249 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -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); diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index a08058f..b783573 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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) */ } diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index ca2a850..c827581 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -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; diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 3391405..038bd1f 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -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'; } diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c index ce19a05..ed72a71 100644 --- a/Modules/stropmodule.c +++ b/Modules/stropmodule.c @@ -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++; diff --git a/Parser/grammar.c b/Parser/grammar.c index c0613df..d8e3897 100644 --- a/Parser/grammar.c +++ b/Parser/grammar.c @@ -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; diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index a79ea81..3b1d6a6 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -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++; diff --git a/Python/ast.c b/Python/ast.c index dde0d04..93334dc 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -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; diff --git a/Python/dynload_aix.c b/Python/dynload_aix.c index 03ecc07..7a604f2 100644 --- a/Python/dynload_aix.c +++ b/Python/dynload_aix.c @@ -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"); } diff --git a/Python/getargs.c b/Python/getargs.c index 16f156f..23b91fd 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -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, -- cgit v0.12