diff options
author | 2015-02-07 03:30:08 +0000 | |
---|---|---|
committer | 2015-02-07 03:30:08 +0000 | |
commit | 24a46d3d9b3743a9b62a6b904fa964ca815079a4 (patch) | |
tree | 6c3f5bf84e6421b11997e9ce95b1119742ac6690 | |
parent | Document a non-obvious aspect of identifycpu() use on i386 (diff) | |
download | wireguard-openbsd-24a46d3d9b3743a9b62a6b904fa964ca815079a4.tar.xz wireguard-openbsd-24a46d3d9b3743a9b62a6b904fa964ca815079a4.zip |
use unsigned char type to avoid many casts
-rw-r--r-- | games/hangman/getguess.c | 18 | ||||
-rw-r--r-- | games/hangman/hangman.h | 4 |
2 files changed, 11 insertions, 11 deletions
diff --git a/games/hangman/getguess.c b/games/hangman/getguess.c index 3e895a693f0..97295eeb338 100644 --- a/games/hangman/getguess.c +++ b/games/hangman/getguess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getguess.c,v 1.12 2015/02/07 03:26:20 tedu Exp $ */ +/* $OpenBSD: getguess.c,v 1.13 2015/02/07 03:30:08 tedu Exp $ */ /* $NetBSD: getguess.c,v 1.5 1995/03/23 08:32:43 cgd Exp $ */ /* @@ -41,7 +41,7 @@ void getguess(void) { int i; - int ch, uch; + unsigned char ch, uch; bool correct; leaveok(stdscr, FALSE); @@ -49,9 +49,9 @@ getguess(void) move(PROMPTY, PROMPTX + sizeof "Guess: "); refresh(); ch = readch(); - if (isalpha((unsigned char)ch)) { - if (isupper((unsigned char)ch)) - ch = tolower((unsigned char)ch); + if (isalpha(ch)) { + if (isupper(ch)) + ch = tolower(ch); if (Guessed[ch - 'a']) { move(MESGY, MESGX); clrtoeol(); @@ -59,7 +59,7 @@ getguess(void) ch); } else break; - } else if (isdigit((unsigned char)ch)) { + } else if (isdigit(ch)) { if (Guessed[ch - '0' + 26]) { move(MESGY, MESGX); clrtoeol(); @@ -81,12 +81,12 @@ getguess(void) move(MESGY, MESGX); clrtoeol(); - if (isalpha((unsigned char)ch)) + if (isalpha(ch)) Guessed[ch - 'a'] = TRUE; else Guessed[ch - '0' + 26] = TRUE; correct = FALSE; - uch = toupper((unsigned char)ch); + uch = toupper(ch); for (i = 0; Word[i] != '\0'; i++) if (Word[i] == ch) { Known[i] = ch; @@ -103,7 +103,7 @@ getguess(void) * readch; * Read a character from the input */ -int +unsigned char readch(void) { int cnt; diff --git a/games/hangman/hangman.h b/games/hangman/hangman.h index e51099c475b..a11ad75371a 100644 --- a/games/hangman/hangman.h +++ b/games/hangman/hangman.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hangman.h,v 1.8 2015/02/07 01:37:30 miod Exp $ */ +/* $OpenBSD: hangman.h,v 1.9 2015/02/07 03:30:08 tedu Exp $ */ /* $NetBSD: hangman.h,v 1.5 1995/04/24 12:23:44 cgd Exp $ */ /* @@ -99,5 +99,5 @@ void playgame(void); void prdata(void); void prman(void); void prword(void); -int readch(void); +unsigned char readch(void); void setup(void); |