Fix SF bug #1072182, problems with signed characters.

Most of these can be backported.
This commit is contained in:
Neal Norwitz 2005-12-19 06:05:18 +00:00
parent 5d0ad50f5a
commit 30b5c5d011
11 changed files with 16 additions and 14 deletions

View 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;

View 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);

View 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) */
}

View 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;

View 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';
}

View 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++;

View 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;

View 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++;

View 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;

View 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");
}

View 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,