From a064ff97a0ba8b1b280d8afb5d14640824ec67c9 Mon Sep 17 00:00:00 2001 From: Charlie Gordon Date: Thu, 6 Dec 2007 17:59:23 +0000 Subject: [PATCH] more ctype unsigned char fixes --- cptoqe.c | 6 +++--- cutils.c | 12 ++++-------- libqhtml/xmlparse.c | 2 +- ligtoqe.c | 8 ++++---- xml.c | 2 +- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/cptoqe.c b/cptoqe.c index 105937e..7312456 100644 --- a/cptoqe.c +++ b/cptoqe.c @@ -143,7 +143,7 @@ static void handle_cp(FILE *f0, const char *name, const char *fname) continue; } - if (p[0] != '0' || tolower(p[1]) != 'x') { + if (p[0] != '0' || tolower((unsigned char)p[1]) != 'x') { if (!has_iso_name) { strcpy(iso_name, p); has_iso_name = 1; @@ -157,14 +157,14 @@ static void handle_cp(FILE *f0, const char *name, const char *fname) if (!strcmp(iso_name, p) || !strcmp(alias_list, p)) continue; - if (!isdigit(*p)) { + if (!isdigit((unsigned char)*p)) { fprintf(stderr, "%s: ignoring line: %s\n", filename, p); continue; } } c1 = strtol(p, (char **)&p, 16); - if (!isspace(*p)) { + if (!isspace((unsigned char)*p)) { /* ignore ranges such as "0x20-0x7e idem" */ continue; } diff --git a/cutils.c b/cutils.c index 439b26d..6cf2e53 100644 --- a/cutils.c +++ b/cutils.c @@ -84,9 +84,7 @@ int stristart(const char *str, const char *val, const char **ptr) p = str; q = val; while (*q != '\0') { - if (toupper(*(const unsigned char *)p) != - toupper(*(const unsigned char *)q)) - { + if (toupper((unsigned char)*p) != toupper((unsigned char)*q)) { if (*p == '-' || *p == '_' || *p == ' ') { p++; continue; @@ -119,9 +117,7 @@ int stricmp(const char *str1, const char *str2) p = str1; q = str2; for (;;) { - if (toupper(*(const unsigned char *)p) != - toupper(*(const unsigned char *)q)) - { + if (toupper((unsigned char)*p) != toupper((unsigned char)*q)) { if (*p == '-' || *p == '_' || *p == ' ') { p++; continue; @@ -130,8 +126,8 @@ int stricmp(const char *str1, const char *str2) q++; continue; } - return (toupper(*(const unsigned char *)p) < - toupper(*(const unsigned char *)q)) ? -1 : +1; + return (toupper((unsigned char)*p) < + toupper((unsigned char)*q)) ? -1 : +1; } if (!*p) break; diff --git a/libqhtml/xmlparse.c b/libqhtml/xmlparse.c index 1031944..fb1b237 100644 --- a/libqhtml/xmlparse.c +++ b/libqhtml/xmlparse.c @@ -1048,7 +1048,7 @@ static int xml_tagcmp(const char *s1, const char *s2) int d; while (*s2) { - d = *(const unsigned char *)s2 - tolower(*(const unsigned char *)s1); + d = (unsigned char)*s2 - tolower((unsigned char)*s1); if (d) return d; s2++; diff --git a/ligtoqe.c b/ligtoqe.c index 1ca3078..3c254be 100644 --- a/ligtoqe.c +++ b/ligtoqe.c @@ -143,8 +143,8 @@ int main(int argc, char **argv) *p = '\0'; p = buf; - while (isspace(*p)) - p++; + while (isspace((unsigned char)*p)) + p++; if (*p == '#' || *p == '\0') { if (to_utf8) { @@ -157,7 +157,7 @@ int main(int argc, char **argv) l->buf_in_size = 0; for (;;) { - while (isspace(*p)) + while (isspace((unsigned char)*p)) p++; if (*p == '=') break; @@ -171,7 +171,7 @@ int main(int argc, char **argv) l->buf_out_size = 0; for (;;) { - while (isspace(*p)) + while (isspace((unsigned char)*p)) p++; /* stop at the first comment */ if (*p == '\0' || *p == '/') diff --git a/xml.c b/xml.c index 894782f..cc59804 100644 --- a/xml.c +++ b/xml.c @@ -171,7 +171,7 @@ int xml_mode_probe(ModeProbeData *p1) return 0; p++; if (*p != '!' && *p != '?' && *p != '/' && - !isalpha(*p)) + !isalpha((unsigned char)*p)) return 0; return 90; /* leave some room for more specific XML parser */ }