diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2013-11-28 18:24:56 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2013-11-28 18:24:56 +0000 |
commit | 9ded258538048c1f43dc85086860c61c35922e09 (patch) | |
tree | 32ddd5f4ef7b436807cb3baba9a4ac548a387c08 /usr.bin | |
parent | 5f9bbfc4c0ee0acd7c9daade1225c685ee6b5bdb (diff) |
unsigned char for ctype
ok krw okan
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/rpcgen/rpc_cout.c | 4 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_main.c | 6 | ||||
-rw-r--r-- | usr.bin/rpcgen/rpc_scan.c | 27 | ||||
-rw-r--r-- | usr.bin/sed/compile.c | 9 | ||||
-rw-r--r-- | usr.bin/sed/process.c | 7 | ||||
-rw-r--r-- | usr.bin/skeyinit/skeyinit.c | 36 | ||||
-rw-r--r-- | usr.bin/sort/init.c | 16 | ||||
-rw-r--r-- | usr.bin/spell/spellprog.c | 20 | ||||
-rw-r--r-- | usr.bin/talk/display.c | 5 | ||||
-rw-r--r-- | usr.bin/tic/tic.c | 6 | ||||
-rw-r--r-- | usr.bin/top/commands.c | 12 | ||||
-rw-r--r-- | usr.bin/top/display.c | 6 |
12 files changed, 81 insertions, 73 deletions
diff --git a/usr.bin/rpcgen/rpc_cout.c b/usr.bin/rpcgen/rpc_cout.c index 11b24c54448..ae13b1165c9 100644 --- a/usr.bin/rpcgen/rpc_cout.c +++ b/usr.bin/rpcgen/rpc_cout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_cout.c,v 1.23 2013/10/27 18:31:24 guenther Exp $ */ +/* $OpenBSD: rpc_cout.c,v 1.24 2013/11/28 18:24:54 deraadt Exp $ */ /* $NetBSD: rpc_cout.c,v 1.6 1996/10/01 04:13:53 cgd Exp $ */ /* @@ -739,7 +739,7 @@ upcase(str) hptr = ptr; while (*str != '\0') - *ptr++ = toupper(*str++); + *ptr++ = toupper((unsigned char)*str++); *ptr = '\0'; return (hptr); diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c index 122acfa70e0..ac76a8fab6e 100644 --- a/usr.bin/rpcgen/rpc_main.c +++ b/usr.bin/rpcgen/rpc_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_main.c,v 1.26 2013/10/27 18:31:24 guenther Exp $ */ +/* $OpenBSD: rpc_main.c,v 1.27 2013/11/28 18:24:54 deraadt Exp $ */ /* $NetBSD: rpc_main.c,v 1.9 1996/02/19 11:12:43 pk Exp $ */ /* @@ -445,8 +445,8 @@ generate_guard(char *pathname) /* convert to upper case */ tmp = guard; while (*tmp) { - if (islower(*tmp)) - *tmp = toupper(*tmp); + if (islower((unsigned char)*tmp)) + *tmp = toupper((unsigned char)*tmp); tmp++; } diff --git a/usr.bin/rpcgen/rpc_scan.c b/usr.bin/rpcgen/rpc_scan.c index ca8977f7253..d2e3f742417 100644 --- a/usr.bin/rpcgen/rpc_scan.c +++ b/usr.bin/rpcgen/rpc_scan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_scan.c,v 1.16 2012/12/05 23:20:26 deraadt Exp $ */ +/* $OpenBSD: rpc_scan.c,v 1.17 2013/11/28 18:24:54 deraadt Exp $ */ /* $NetBSD: rpc_scan.c,v 1.4 1995/06/11 21:50:02 pk Exp $ */ /* @@ -181,8 +181,8 @@ get_token(tokp) } } where = curline; - } else if (isspace(*where)) { - while (isspace(*where)) { + } else if (isspace((unsigned char)*where)) { + while (isspace((unsigned char)*where)) { where++; /* eat */ } } else if (commenting) { @@ -283,10 +283,10 @@ get_token(tokp) break; default: - if (!(isalpha(*where) || *where == '_')) { + if (!(isalpha((unsigned char)*where) || *where == '_')) { char buf[100], chs[20]; - if (isprint(*where)) { + if (isprint((unsigned char)*where)) { snprintf(chs, sizeof chs, "%c", *where); } else { snprintf(chs, sizeof chs, "%d", *where); @@ -375,11 +375,11 @@ findconst(str, val) p++; do { p++; - } while (isxdigit(*p)); + } while (isxdigit((unsigned char)*p)); } else { do { p++; - } while (isdigit(*p)); + } while (isdigit((unsigned char)*p)); } size = p - *str; *val = alloc(size + 1); @@ -428,7 +428,8 @@ findkind(mark, tokp) for (s = symbols; s->kind != TOK_EOF; s++) { len = strlen(s->str); if (strncmp(str, s->str, len) == 0) { - if (!isalnum(str[len]) && str[len] != '_') { + if (!isalnum((unsigned char)str[len]) && + str[len] != '_') { tokp->kind = s->kind; tokp->str = s->str; *mark = str + len; @@ -437,7 +438,9 @@ findkind(mark, tokp) } } tokp->kind = TOK_IDENT; - for (len = 0; isalnum(str[len]) || str[len] == '_'; len++); + for (len = 0; isalnum((unsigned char)str[len]) || str[len] == '_'; + len++) + ; tokp->str = alloc(len + 1); if (tokp->str == NULL) error("alloc failed"); @@ -478,14 +481,14 @@ docppline(line, lineno, fname) char *p; line++; - while (isspace(*line)) { + while (isspace((unsigned char)*line)) { line++; } num = atoi(line); - while (isdigit(*line)) { + while (isdigit((unsigned char)*line)) { line++; } - while (isspace(*line)) { + while (isspace((unsigned char)*line)) { line++; } if (*line != '"') { diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c index 012701d9064..6dffcc9c7ef 100644 --- a/usr.bin/sed/compile.c +++ b/usr.bin/sed/compile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: compile.c,v 1.34 2010/11/15 20:26:00 millert Exp $ */ +/* $OpenBSD: compile.c,v 1.35 2013/11/28 18:24:55 deraadt Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -134,7 +134,8 @@ compile(void) #define EATSPACE() do { \ if (p) \ - while (isascii(*p) && isspace(*p)) \ + while (isascii((unsigned char)*p) && \ + isspace((unsigned char)*p)) \ p++; \ } while (0) @@ -739,10 +740,10 @@ duptoeol(char *s, char *ctype, char **semi) ws = 0; if (semi) { for (start = s; *s != '\0' && *s != '\n' && *s != ';'; ++s) - ws = isspace(*s); + ws = isspace((unsigned char)*s); } else { for (start = s; *s != '\0' && *s != '\n'; ++s) - ws = isspace(*s); + ws = isspace((unsigned char)*s); *s = '\0'; } if (ws) diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c index bd8d8696740..dfe2a9e6e51 100644 --- a/usr.bin/sed/process.c +++ b/usr.bin/sed/process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: process.c,v 1.18 2011/09/17 15:29:19 schwarze Exp $ */ +/* $OpenBSD: process.c,v 1.19 2013/11/28 18:24:55 deraadt Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -468,7 +468,8 @@ lputs(char *s) (void)printf("\\\n"); count = 0; } - if (isascii(*s) && isprint(*s) && *s != '\\') { + if (isascii((unsigned char)*s) && isprint((unsigned char)*s) + && *s != '\\') { (void)putchar(*s); count++; } else if (*s != '\n') { @@ -541,7 +542,7 @@ regsub(SPACE *sp, char *string, char *src) while ((c = *src++) != '\0') { if (c == '&') no = 0; - else if (c == '\\' && isdigit(*src)) + else if (c == '\\' && isdigit((unsigned char)*src)) no = *src++ - '0'; else no = -1; diff --git a/usr.bin/skeyinit/skeyinit.c b/usr.bin/skeyinit/skeyinit.c index d35c8b3197a..af5a91db982 100644 --- a/usr.bin/skeyinit/skeyinit.c +++ b/usr.bin/skeyinit/skeyinit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: skeyinit.c,v 1.51 2005/07/06 22:15:11 jmc Exp $ */ +/* $OpenBSD: skeyinit.c,v 1.52 2013/11/28 18:24:55 deraadt Exp $ */ /* OpenBSD S/Key (skeyinit.c) * @@ -64,11 +64,11 @@ main(int argc, char **argv) if (gethostname(hostname, sizeof(hostname)) < 0) err(1, "gethostname"); for (i = 0, p = seed; hostname[i] && i < SKEY_NAMELEN; i++) { - if (isalpha(hostname[i])) { - if (isupper(hostname[i])) - hostname[i] = tolower(hostname[i]); + if (isalpha((unsigned char)hostname[i])) { + if (isupper((unsigned char)hostname[i])) + hostname[i] = tolower((unsigned char)hostname[i]); *p++ = hostname[i]; - } else if (isdigit(hostname[i])) + } else if (isdigit((unsigned char)hostname[i])) *p++ = hostname[i]; } noise = arc4random(); @@ -241,10 +241,10 @@ main(int argc, char **argv) */ l = strlen(skey.seed); for (p = skey.seed; *p; p++) { - if (isalpha(*p)) { - if (isupper(*p)) - *p = tolower(*p); - } else if (!isdigit(*p)) { + if (isalpha((unsigned char)*p)) { + if (isupper((unsigned char)*p)) + *p = tolower((unsigned char)*p); + } else if (!isdigit((unsigned char)*p)) { memmove(p, p + 1, l - (p - skey.seed)); l--; } @@ -253,12 +253,14 @@ main(int argc, char **argv) /* If the seed ends in 0-8 just add one. */ if (l > 0) { lastc = skey.seed[l - 1]; - if (isdigit(lastc) && lastc != '9') { + if (isdigit((unsigned char)lastc) && + lastc != '9') { (void)strlcpy(seed, skey.seed, sizeof seed); seed[l - 1] = lastc + 1; } - if (isdigit(lastc) && lastc == '9' && l < 16) { + if (isdigit((unsigned char)lastc) && + lastc == '9' && l < 16) { (void)strlcpy(seed, skey.seed, sizeof seed); seed[l - 1] = '0'; @@ -356,14 +358,14 @@ secure_mode(int *count, char *key, char *seed, size_t seedlen, continue; } for (p = newseed; *p; p++) { - if (isspace(*p)) { + if (isspace((unsigned char)*p)) { (void)fputs("ERROR: Seed must not contain " "any spaces\n", stderr); break; - } else if (isalpha(*p)) { - if (isupper(*p)) - *p = tolower(*p); - } else if (!isdigit(*p)) { + } else if (isalpha((unsigned char)*p)) { + if (isupper((unsigned char)*p)) + *p = tolower((unsigned char)*p); + } else if (!isdigit((unsigned char)*p)) { (void)fputs("ERROR: Seed must be purely " "alphanumeric\n", stderr); break; @@ -511,7 +513,7 @@ convert_db(void) continue; if ((cp = strtok(NULL, " \t")) == NULL) continue; - if (isalpha(*cp)) { + if (isalpha((unsigned char)*cp)) { hashtype = cp; if ((cp = strtok(NULL, " \t")) == NULL) continue; diff --git a/usr.bin/sort/init.c b/usr.bin/sort/init.c index 34ef4149e10..19350123e51 100644 --- a/usr.bin/sort/init.c +++ b/usr.bin/sort/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.12 2009/10/27 23:59:43 deraadt Exp $ */ +/* $OpenBSD: init.c,v 1.13 2013/11/28 18:24:55 deraadt Exp $ */ /*- * Copyright (c) 1993 @@ -110,7 +110,7 @@ setcolumn(char *pos, struct field *cur_fld, int gflag) if (sscanf(pos, "%d", &(col->num)) != 1) errx(2, "missing field number"); pos++; - while (isdigit(*pos)) + while (isdigit((u_char)*pos)) pos++; if (col->num <= 0 && !(col->num == 0 && col == &(cur_fld->tcol))) errx(2, "field numbers must be positive"); @@ -121,7 +121,7 @@ setcolumn(char *pos, struct field *cur_fld, int gflag) if (sscanf(pos, "%d", &(col->indent)) != 1) errx(2, "missing offset"); pos++; - while (isdigit(*pos)) + while (isdigit((u_char)*pos)) pos++; if (&cur_fld->icol == col) col->indent--; @@ -238,8 +238,8 @@ fixit(int *argc, char **argv) errx(2, "bad field specification"); bufp += n; - if (argv[i+1] && - argv[i+1][0] == '-' && isdigit(argv[i+1][1])) { + if (argv[i+1] && argv[i+1][0] == '-' && + isdigit((u_char)argv[i+1][1])) { p = argv[i+1] + 1; w = strtol(p, &ep, 10); if (ep == p || w < 0 || @@ -296,7 +296,7 @@ settables(int gflags) Rascii[i] = 255 - i + 1; else Rascii[i] = 255 - i; - if (islower(i)) { + if (islower((u_char)i)) { Ftable[i] = Ftable[i- ('a' -'A')]; RFtable[i] = RFtable[i - ('a' - 'A')]; } else if (REC_D>= 'A' && REC_D < 'Z' && i < 'a' && i > REC_D) { @@ -307,10 +307,10 @@ settables(int gflags) RFtable[i] = Rascii[i]; } alltable[i] = 1; - if (i == '\n' || isprint(i)) + if (i == '\n' || isprint((u_char)i)) itable[i] = 1; else itable[i] = 0; - if (i == '\n' || i == '\t' || i == ' ' || isalnum(i)) + if (i == '\n' || i == '\t' || i == ' ' || isalnum((u_char)i)) dtable[i] = 1; else dtable[i] = 0; } diff --git a/usr.bin/spell/spellprog.c b/usr.bin/spell/spellprog.c index d8ecb377633..d8c61b56bd6 100644 --- a/usr.bin/spell/spellprog.c +++ b/usr.bin/spell/spellprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spellprog.c,v 1.6 2009/10/27 23:59:43 deraadt Exp $ */ +/* $OpenBSD: spellprog.c,v 1.7 2013/11/28 18:24:55 deraadt Exp $ */ /* * Copyright (c) 1991, 1993 @@ -98,7 +98,7 @@ int s(char *, char *, char *, int); int strip(char *, char *, char *, int); int suffix(char *, int); int tion(char *, char *, char *, int); -int vowel(int); +int vowel(unsigned char); int y_to_e(char *, char *, char *, int); int CCe(char *, char *, char *, int); int VCe(char *, char *, char *, int); @@ -321,22 +321,22 @@ main(int argc, char **argv) *dp = '\0'; fold = 0; for (cp = word; cp < ep; cp++) - if (islower(*cp)) + if (islower((unsigned char)*cp)) goto lcase; if (trypref(ep, ".", 0)) continue; ++fold; for (cp = original + 1, dp = word + 1; dp < ep; dp++, cp++) - *dp = tolower(*cp); + *dp = tolower((unsigned char)*cp); lcase: if (trypref(ep, ".", 0) || suffix(ep, 0)) continue; - if (isupper(word[0])) { + if (isupper((unsigned char)word[0])) { for (cp = original, dp = word; (*dp = *cp++); dp++) { if (fold) - *dp = tolower(*dp); + *dp = tolower((unsigned char)*dp); } - word[0] = tolower(word[0]); + word[0] = tolower((unsigned char)word[0]); goto lcase; } file = stdout; @@ -420,7 +420,7 @@ int an(char *ep, char *d, char *a, int lev) { - if (!isupper(*word)) /* must be proper name */ + if (!isupper((unsigned char)*word)) /* must be proper name */ return (0); return (trypref(ep,a,lev)); } @@ -598,7 +598,7 @@ lookuppref(char **wp, char *ep) for (sp = preftab; *sp; sp++) { bp = *wp; for (cp = *sp; *cp; cp++, bp++) { - if (tolower(*bp) != *cp) + if (tolower((unsigned char)*bp) != *cp) goto next; } for (cp = bp; cp < ep; cp++) { @@ -703,7 +703,7 @@ skipv(char *s) } int -vowel(int c) +vowel(unsigned char c) { switch (tolower(c)) { diff --git a/usr.bin/talk/display.c b/usr.bin/talk/display.c index fe0e0aaeaa9..6b080952e81 100644 --- a/usr.bin/talk/display.c +++ b/usr.bin/talk/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.16 2010/08/12 23:31:29 tedu Exp $ */ +/* $OpenBSD: display.c,v 1.17 2013/11/28 18:24:55 deraadt Exp $ */ /* $NetBSD: display.c,v 1.3 1994/12/09 02:14:13 jtc Exp $ */ /* @@ -137,7 +137,8 @@ display(xwin_t *win, char *text, int size) xscroll(win, 0); } if (*text != '\t' && - ((!high_print && !isprint(*text)) || iscntrl(*text))) { + ((!high_print && !isprint((unsigned char)*text)) || + iscntrl((unsigned char)*text))) { waddch(win->x_win, '^'); getyx(win->x_win, win->x_line, win->x_col); if (win->x_col == COLS-1) /* check for wraparound */ diff --git a/usr.bin/tic/tic.c b/usr.bin/tic/tic.c index 2a7019fbe58..d55f609ee3f 100644 --- a/usr.bin/tic/tic.c +++ b/usr.bin/tic/tic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tic.c,v 1.30 2010/01/12 23:22:14 nicm Exp $ */ +/* $OpenBSD: tic.c,v 1.31 2013/11/28 18:24:55 deraadt Exp $ */ /**************************************************************************** * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * @@ -46,7 +46,7 @@ #include <dump_entry.h> #include <transform.h> -MODULE_ID("$Id: tic.c,v 1.30 2010/01/12 23:22:14 nicm Exp $") +MODULE_ID("$Id: tic.c,v 1.31 2013/11/28 18:24:55 deraadt Exp $") const char *_nc_progname = "tic"; @@ -1159,7 +1159,7 @@ check_params(TERMTYPE *tp, const char *name, char *value) _nc_warning("expected character after %% in %s", name); break; } else if (*s == 'p') { - if (*++s == '\0' || !isdigit((int) *s)) { + if (*++s == '\0' || !isdigit(UChar(*s))) { _nc_warning("expected digit after %%p in %s", name); return; } else { diff --git a/usr.bin/top/commands.c b/usr.bin/top/commands.c index 797d2a71927..5a4f5d91d10 100644 --- a/usr.bin/top/commands.c +++ b/usr.bin/top/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.30 2010/04/01 05:05:19 lum Exp $ */ +/* $OpenBSD: commands.c,v 1.31 2013/11/28 18:24:55 deraadt Exp $ */ /* * Top users/processes display for Unix @@ -100,9 +100,9 @@ scan_arg(char *str, int *intp, char *nptr) return (-1); while ((ch = *str++) != '\0') { - if (isspace(ch)) + if (isspace((unsigned char)ch)) break; - else if (!isdigit(ch)) + else if (!isdigit((unsigned char)ch)) bad_flag = 1; else val = val * 10 + (ch - '0'); @@ -284,7 +284,7 @@ kill_procs(char *str) uid = getuid(); /* skip over leading white space */ - while (isspace(*str)) + while (isspace((unsigned char)*str)) str++; if (*str == '-') { @@ -294,7 +294,7 @@ kill_procs(char *str) if ((nptr = next_field(str)) == NULL) return (" kill: no processes specified"); - if (isdigit(*str)) { + if (isdigit((unsigned char)*str)) { (void) scan_arg(str, &signum, tmp); if (signum <= 0 || signum >= NSIG) return (" invalid signal number"); @@ -352,7 +352,7 @@ renice_procs(char *str) uid = getuid(); /* skip over leading white space */ - while (isspace(*str)) + while (isspace((unsigned char)*str)) str++; /* allow for negative priority values */ diff --git a/usr.bin/top/display.c b/usr.bin/top/display.c index d994eb6a4c3..d91dc266077 100644 --- a/usr.bin/top/display.c +++ b/usr.bin/top/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.45 2013/01/14 21:35:08 guenther Exp $ */ +/* $OpenBSD: display.c,v 1.46 2013/11/28 18:24:55 deraadt Exp $ */ /* * Top users/processes display for Unix @@ -610,7 +610,7 @@ readlinedumb(char *buffer, int size) } } /* check for character validity and buffer overflow */ - else if (cnt == size || !isprint(ch)) { + else if (cnt == size || !isprint((unsigned char)ch)) { /* not legal */ if (putchar('\7') == EOF) exit(1); @@ -732,7 +732,7 @@ printable(char *str) ptr = str; while ((ch = *ptr) != '\0') { - if (!isprint(ch)) + if (!isprint((unsigned char)ch)) *ptr = '?'; ptr++; } |