diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2014-06-21 10:45:17 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2014-06-21 10:45:17 +0000 |
commit | fe16637d6e50258433ab63b341bca68894ac265f (patch) | |
tree | 9eacc020eb4de89ee9b9a3a34a7ad29c7628edf2 | |
parent | 4e850024741afa0c993d267a6d2c1ff0af2f6609 (diff) |
ttf2pk2: Avoid undefined behaviour when char is signed
git-svn-id: svn://tug.org/texlive/trunk@34345 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Build/source/texk/ttf2pk2/ChangeLog | 5 | ||||
-rw-r--r-- | Build/source/texk/ttf2pk2/ligkern.c | 8 | ||||
-rw-r--r-- | Build/source/texk/ttf2pk2/parse.c | 12 | ||||
-rw-r--r-- | Build/source/texk/ttf2pk2/subfont.c | 16 | ||||
-rw-r--r-- | Build/source/texk/ttf2pk2/ttf2pk.c | 32 | ||||
-rw-r--r-- | Build/source/texk/ttf2pk2/vplaux.c | 4 |
6 files changed, 41 insertions, 36 deletions
diff --git a/Build/source/texk/ttf2pk2/ChangeLog b/Build/source/texk/ttf2pk2/ChangeLog index bac8f59a47d..98b0fafe29e 100644 --- a/Build/source/texk/ttf2pk2/ChangeLog +++ b/Build/source/texk/ttf2pk2/ChangeLog @@ -1,3 +1,8 @@ +2014-06-20 Peter Breitenlohner <peb@mppmu.mpg.de> + + * ligkern.c, parse.c, subfont.c, ttf2pk.c, vplaux.c: Avoid + undefined behaviour when char is signed. + 2014-06-16 Peter Breitenlohner <peb@mppmu.mpg.de> * Makefile.am: Drop the obsolete ACLOCAL_AMFLAGS. diff --git a/Build/source/texk/ttf2pk2/ligkern.c b/Build/source/texk/ttf2pk2/ligkern.c index 788552e1855..c3317109086 100644 --- a/Build/source/texk/ttf2pk2/ligkern.c +++ b/Build/source/texk/ttf2pk2/ligkern.c @@ -32,12 +32,12 @@ paramstring(char **curp) p = *curp; - while (*p && !isspace(*p)) + while (*p && !isspace((unsigned char)*p)) p++; q = *curp; if (*p != '\0') *p++ = '\0'; - while (isspace(*p)) + while (isspace((unsigned char)*p)) p++; *curp = p; return q; @@ -146,13 +146,13 @@ checkligkern(char *s, Font *fnt) orig_s = s; s++; - while (isspace(*s)) + while (isspace((unsigned char)*s)) s++; if (strncmp(s, "LIGKERN", 7) == 0) { fnt->sawligkern = True; s += 7; - while (isspace(*s)) + while (isspace((unsigned char)*s)) s++; pos = s; while (*pos) diff --git a/Build/source/texk/ttf2pk2/parse.c b/Build/source/texk/ttf2pk2/parse.c index 5ecfd307d81..b2320c9d408 100644 --- a/Build/source/texk/ttf2pk2/parse.c +++ b/Build/source/texk/ttf2pk2/parse.c @@ -82,7 +82,7 @@ gettoken(char **bufferp, size_t *offsetp, FILE *f, Font *fnt, } } - while (isspace(*curp)) + while (isspace((unsigned char)*curp)) curp++; *offsetp = curp - *bufferp; @@ -265,31 +265,31 @@ get_replacements(Font *fnt) p = buffer; - while (isspace(*p)) + while (isspace((unsigned char)*p)) p++; if (!*p) continue; old_name = p; - while (*p && !isspace(*p)) + while (*p && !isspace((unsigned char)*p)) p++; if (*p) *p++ = '\0'; - while (*p && isspace(*p)) + while (*p && isspace((unsigned char)*p)) p++; if (!*p) boops(oldbuffer, old_name - oldbuffer, "Replacement glyph missing."); new_name = p; - while (*p && !isspace(*p)) + while (*p && !isspace((unsigned char)*p)) p++; if (*p) *p++ = '\0'; - while (*p && isspace(*p)) + while (*p && isspace((unsigned char)*p)) p++; if (*p) boops(oldbuffer, p - oldbuffer, "Invalid replacement syntax."); diff --git a/Build/source/texk/ttf2pk2/subfont.c b/Build/source/texk/ttf2pk2/subfont.c index 9569d9f8bdc..1fe703b7142 100644 --- a/Build/source/texk/ttf2pk2/subfont.c +++ b/Build/source/texk/ttf2pk2/subfont.c @@ -212,7 +212,7 @@ again: bufp = buffer; - while (isspace(*bufp)) + while (isspace((unsigned char)*bufp)) bufp++; if (*bufp == '\0') /* empty line? */ @@ -222,12 +222,12 @@ again: goto again; } - while (*bufp && !isspace(*bufp)) /* subfont name */ + while (*bufp && !isspace((unsigned char)*bufp)) /* subfont name */ bufp++; if (*bufp) *(bufp++) = '\0'; - while (isspace(*bufp)) + while (isspace((unsigned char)*bufp)) bufp++; if (*bufp == '\0') @@ -263,7 +263,7 @@ again: bufp = bufp2 + 1; - while (isspace(*bufp)) + while (isspace((unsigned char)*bufp)) bufp++; continue; @@ -271,14 +271,14 @@ again: else if (*bufp2 == '_') /* range */ { bufp = bufp2 + 1; - if (!isdigit(*bufp)) + if (!isdigit((unsigned char)*bufp)) boops(oldbuffer, bufp - buffer, "Invalid subfont range entry."); end = strtol(bufp, &bufp2, 0); if (bufp == bufp2 || end < 0 || end > 0x16FFFFL) boops(oldbuffer, bufp - buffer, "Invalid subfont range entry."); - if (*bufp2 && !isspace(*bufp2)) + if (*bufp2 && !isspace((unsigned char)*bufp2)) boops(oldbuffer, bufp2 - buffer, "Invalid subfont range entry."); if (end < begin) boops(oldbuffer, bufp - buffer, "End of subfont range too small."); @@ -286,7 +286,7 @@ again: boops(oldbuffer, bufp3 - buffer, "Subfont range too large for current offset (%i).", offset); } - else if (isspace(*bufp2) || !*bufp2) /* single value */ + else if (isspace((unsigned char)*bufp2) || !*bufp2) /* single value */ end = begin; else boops(oldbuffer, bufp2 - buffer, "Invalid subfont range entry."); @@ -301,7 +301,7 @@ again: bufp = bufp2; - while (isspace(*bufp)) + while (isspace((unsigned char)*bufp)) bufp++; if (!*bufp) diff --git a/Build/source/texk/ttf2pk2/ttf2pk.c b/Build/source/texk/ttf2pk2/ttf2pk.c index 2224ca275f2..f1e14f980ba 100644 --- a/Build/source/texk/ttf2pk2/ttf2pk.c +++ b/Build/source/texk/ttf2pk2/ttf2pk.c @@ -55,12 +55,12 @@ Boolean have_eid = False; static char * strip_equal(char *s, char *os, char *p) { - while (isspace(*p)) + while (isspace((unsigned char)*p)) p++; if (*p != '=') boops(os, p - s, "Missing `='."); p++; - while (isspace(*p)) + while (isspace((unsigned char)*p)) p++; return p; } @@ -129,11 +129,11 @@ compare(Font *fnt, char *s, char *key) * We isolate the fontname. */ - while (isspace(*s)) + while (isspace((unsigned char)*s)) s++; p = s; - while (*p && !isspace(*p)) + while (*p && !isspace((unsigned char)*p)) p++; c = *p; @@ -225,9 +225,9 @@ add_mapfile(char *p) } } else - while (isspace(*++p)) + while (isspace((unsigned char)*++p)) ; - for (q = p; *q != 0 && !isspace(*q); q++) + for (q = p; *q != 0 && !isspace((unsigned char)*q); q++) ; *q = '\n'; /* '\n' is the splitting character */ if (mapfiles == NULL) @@ -263,7 +263,7 @@ read_config_file(Boolean quiet) if (!*configline) break; p = configline; - while (isspace(*p)) + while (isspace((unsigned char)*p)) p++; /* ignore comments */ if (*p == '*' || *p == '#' || *p == ';' || *p == '%') @@ -271,7 +271,7 @@ read_config_file(Boolean quiet) if (strlen(p) > 4 && strncmp(p, "map", 3) == 0) { p += 3; /* move by the size of "map" */ - while (isspace(*p)) + while (isspace((unsigned char)*p)) p++; if (*p) add_mapfile(p); @@ -451,28 +451,28 @@ font_found: oldconfigline = newstring(configline); p = configline; - while (isspace(*p)) + while (isspace((unsigned char)*p)) p++; - while (*p && !isspace(*p)) + while (*p && !isspace((unsigned char)*p)) p++; q = p; - while (*p && isspace(*p)) + while (*p && isspace((unsigned char)*p)) p++; if (!*p) boops(oldconfigline, q - configline, "TTF file missing."); font.ttfname = p; - while (*p && !isspace(*p)) + while (*p && !isspace((unsigned char)*p)) p++; if (*p) *p++ = '\0'; for (; *p; p++) { - if (isspace(*p)) + if (isspace((unsigned char)*p)) continue; if (!strncmp(p, "Slant", 5)) @@ -591,7 +591,7 @@ font_found: old_name = p; - while (*p && !isspace(*p) && *p != '=') + while (*p && !isspace((unsigned char)*p) && *p != '=') p++; q = p; @@ -599,7 +599,7 @@ font_found: *q = '\0'; new_name = p; - while (*p && !isspace(*p)) + while (*p && !isspace((unsigned char)*p)) p++; if (*p) *p++ = '\0'; @@ -613,7 +613,7 @@ font_found: p--; /* to make the next while loop work */ } - while (*p && !isspace(*p)) + while (*p && !isspace((unsigned char)*p)) p++; if (*p) *p = '\0'; diff --git a/Build/source/texk/ttf2pk2/vplaux.c b/Build/source/texk/ttf2pk2/vplaux.c index 18a21081d2d..5a900015bce 100644 --- a/Build/source/texk/ttf2pk2/vplaux.c +++ b/Build/source/texk/ttf2pk2/vplaux.c @@ -152,11 +152,11 @@ upmap(Font *fnt) for (Ti = fnt->charlist; Ti; Ti = Ti->next) { p = Ti->adobename; - if (isupper(*p)) + if (isupper((unsigned char)*p)) { q = lwr; for (; *p; p++) - *q++ = tolower(*p); + *q++ = tolower((unsigned char)*p); *q = '\0'; if (NULL != (ti = findmappedadobe(lwr, fnt->inencptrs))) |