From f9863c47b3e6dd0f2e4725c921ec290f52e61611 Mon Sep 17 00:00:00 2001 From: itohy Date: Tue, 11 Jul 2000 06:07:25 +0000 Subject: [PATCH] Correct ctype(3) usage. Passing "char" value is wrong. Use "unsigned char" instead. --- lib/libcompat/regexp/regexp.c | 9 +++++---- lib/libmenu/driver.c | 8 ++++---- lib/libmenu/internals.c | 4 ++-- lib/libmenu/internals.h | 4 ++-- lib/libmenu/menu.c | 4 ++-- lib/libskey/skeylogin.c | 14 +++++++------- lib/libskey/skeysubr.c | 6 +++--- lib/libutil/passwd.c | 8 ++++---- 8 files changed, 29 insertions(+), 28 deletions(-) diff --git a/lib/libcompat/regexp/regexp.c b/lib/libcompat/regexp/regexp.c index 06471b5597e9..9602a6cbc14b 100644 --- a/lib/libcompat/regexp/regexp.c +++ b/lib/libcompat/regexp/regexp.c @@ -35,7 +35,7 @@ #include #ifndef lint -__RCSID("$NetBSD: regexp.c,v 1.12 1999/09/16 09:57:06 lukem Exp $"); +__RCSID("$NetBSD: regexp.c,v 1.13 2000/07/11 06:07:25 itohy Exp $"); #endif /* not lint */ #include @@ -924,16 +924,17 @@ char *prog; break; case WORDA: /* Must be looking at a letter, digit, or _ */ - if ((!isalnum(*reginput)) && *reginput != '_') + if ((!isalnum(UCHARAT(reginput))) && *reginput != '_') return(0); /* Prev must be BOL or nonword */ if (reginput > regbol && - (isalnum(reginput[-1]) || reginput[-1] == '_')) + (isalnum(UCHARAT(reginput - 1)) + || reginput[-1] == '_')) return(0); break; case WORDZ: /* Must be looking at non letter, digit, or _ */ - if (isalnum(*reginput) || *reginput == '_') + if (isalnum(UCHARAT(reginput)) || *reginput == '_') return(0); /* We don't care what the previous char was */ break; diff --git a/lib/libmenu/driver.c b/lib/libmenu/driver.c index f17646afdd2b..5bd67cea515c 100644 --- a/lib/libmenu/driver.c +++ b/lib/libmenu/driver.c @@ -1,4 +1,4 @@ -/* $NetBSD: driver.c,v 1.5 2000/04/20 12:17:57 blymn Exp $ */ +/* $NetBSD: driver.c,v 1.6 2000/07/11 06:07:26 itohy Exp $ */ /*- * Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au) @@ -216,10 +216,10 @@ menu_driver(MENU *menu, int c) } else if (c > MAX_COMMAND) { /* must be a user command */ return E_UNKNOWN_COMMAND; - } else if (isprint((char) c)) { + } else if (isprint((unsigned char) c)) { /* otherwise search items for the character. */ - status = _menui_match_pattern(menu, c, MATCH_FORWARD, - &it); + status = _menui_match_pattern(menu, (unsigned char) c, + MATCH_FORWARD, &it); drv_new_item = menu->items[it]; /* update the position of the cursor if we are doing diff --git a/lib/libmenu/internals.c b/lib/libmenu/internals.c index c8eccaebbcbf..01204b91423b 100644 --- a/lib/libmenu/internals.c +++ b/lib/libmenu/internals.c @@ -1,4 +1,4 @@ -/* $NetBSD: internals.c,v 1.6 2000/04/20 12:17:57 blymn Exp $ */ +/* $NetBSD: internals.c,v 1.7 2000/07/11 06:07:26 itohy Exp $ */ /*- * Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au) @@ -331,7 +331,7 @@ _menui_match_items(MENU *menu, int direction, int *item_matched) * index of the item that matched the pattern. */ int -_menui_match_pattern(MENU *menu, char c, int direction, int *item_matched) +_menui_match_pattern(MENU *menu, int c, int direction, int *item_matched) { if (menu == NULL) return E_BAD_ARGUMENT; diff --git a/lib/libmenu/internals.h b/lib/libmenu/internals.h index f944574df107..128e9becbb8a 100644 --- a/lib/libmenu/internals.h +++ b/lib/libmenu/internals.h @@ -1,4 +1,4 @@ -/* $NetBSD: internals.h,v 1.6 2000/04/20 12:17:57 blymn Exp $ */ +/* $NetBSD: internals.h,v 1.7 2000/07/11 06:07:26 itohy Exp $ */ /*- * Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au) @@ -44,7 +44,7 @@ void _menui_draw_item(MENU *menu, int item); int _menui_draw_menu(MENU *menu); int _menui_goto_item(MENU *menu, ITEM *item, int new_top_row); -int _menui_match_pattern(MENU *menu, char c, int direction , +int _menui_match_pattern(MENU *menu, int c, int direction , int *item_matched); int _menui_match_items(MENU *menu, int direction, int *item_matched); void _menui_max_item_size(MENU *menu); diff --git a/lib/libmenu/menu.c b/lib/libmenu/menu.c index 2c0ff38e3ae2..c4274afc7063 100644 --- a/lib/libmenu/menu.c +++ b/lib/libmenu/menu.c @@ -1,4 +1,4 @@ -/* $NetBSD: menu.c,v 1.8 2000/05/07 12:14:44 blymn Exp $ */ +/* $NetBSD: menu.c,v 1.9 2000/07/11 06:07:27 itohy Exp $ */ /*- * Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au) @@ -365,7 +365,7 @@ set_menu_pattern(MENU *param_menu, char *pat) /* check pattern is all printable characters */ while (*p) - if (!isprint(*p++)) return E_BAD_ARGUMENT; + if (!isprint((unsigned char) *p++)) return E_BAD_ARGUMENT; if ((menu->pattern = (char *) realloc(menu->pattern, sizeof(char) * strlen(pat))) == NULL) diff --git a/lib/libskey/skeylogin.c b/lib/libskey/skeylogin.c index dcc46bcfbbd7..6f5e95a9e251 100644 --- a/lib/libskey/skeylogin.c +++ b/lib/libskey/skeylogin.c @@ -1,4 +1,4 @@ -/* $NetBSD: skeylogin.c,v 1.14 2000/07/06 22:30:19 mjl Exp $ */ +/* $NetBSD: skeylogin.c,v 1.15 2000/07/11 06:07:27 itohy Exp $ */ /* S/KEY v1.1b (skeylogin.c) * @@ -146,7 +146,7 @@ int skeylookup(struct skey *mp, const char *name) if ((cp = strtok(NULL, " \t")) == NULL) continue; /* Save hash type if specified, else use md4 */ - if (isalpha(*cp)) { + if (isalpha((u_char) *cp)) { ht = cp; if ((cp = strtok(NULL, " \t")) == NULL) continue; @@ -208,7 +208,7 @@ int skeygetnext(struct skey *mp) if ((cp = strtok(NULL, " \t")) == NULL) continue; /* Save hash type if specified, else use md4 */ - if (isalpha(*cp)) { + if (isalpha((u_char) *cp)) { if ((cp = strtok(NULL, " \t")) == NULL) continue; } @@ -295,7 +295,7 @@ int skeyverify(struct skey *mp, char *response) rip(mp->buf); mp->logname = strtok(mp->buf, " \t"); cp = strtok(NULL, " \t") ; - if (isalpha(*cp)) + if (isalpha((u_char) *cp)) cp = strtok(NULL, " \t") ; mp->seed = strtok(NULL, " \t"); mp->val = strtok(NULL, " \t"); @@ -453,9 +453,9 @@ int skey_authenticate(const char *username) if (gethostname(pbuf, sizeof(pbuf)) == -1) *(p = pbuf) = '.'; else - for (p = pbuf; *p && isalnum(*p); p++) - if (isalpha(*p) && isupper(*p)) - *p = tolower(*p); + for (p = pbuf; *p && isalnum((u_char) *p); p++) + if (isalpha((u_char)*p) && isupper((u_char)*p)) + *p = tolower((u_char)*p); if (*p && pbuf - p < 4) (void)strncpy(p, "asjd", 4 - (pbuf - p)); pbuf[4] = '\0'; diff --git a/lib/libskey/skeysubr.c b/lib/libskey/skeysubr.c index 94cf8e5a9bd7..2f82040cf602 100644 --- a/lib/libskey/skeysubr.c +++ b/lib/libskey/skeysubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: skeysubr.c,v 1.17 2000/07/08 11:48:40 kleink Exp $ */ +/* $NetBSD: skeysubr.c,v 1.18 2000/07/11 06:07:27 itohy Exp $ */ /* S/KEY v1.1b (skeysubr.c) * @@ -510,9 +510,9 @@ static void skey_echo(int action) /* Convert string to lower case */ static void lowcase(char *s) { - char *p; + u_char *p; - for (p = s; *p; p++) + for (p = (u_char *) s; *p; p++) if (isupper(*p)) *p = tolower(*p); } diff --git a/lib/libutil/passwd.c b/lib/libutil/passwd.c index 1d4bd1661be4..a106732f5e8e 100644 --- a/lib/libutil/passwd.c +++ b/lib/libutil/passwd.c @@ -1,4 +1,4 @@ -/* $NetBSD: passwd.c,v 1.23 2000/07/07 10:32:48 ad Exp $ */ +/* $NetBSD: passwd.c,v 1.24 2000/07/11 06:07:27 itohy Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -35,7 +35,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: passwd.c,v 1.23 2000/07/07 10:32:48 ad Exp $"); +__RCSID("$NetBSD: passwd.c,v 1.24 2000/07/11 06:07:27 itohy Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -338,13 +338,13 @@ trim_whitespace(char *line) /* Remove leading spaces */ p = line; - while (isspace(*p)) + while (isspace((unsigned char) *p)) p++; memmove(line, p, strlen(p) + 1); /* Remove trailing spaces */ p = line + strlen(line) - 1; - while (isspace(*p)) + while (isspace((unsigned char) *p)) p--; *(p + 1) = '\0'; }