From 117d073a602490e284a22f09222a2504a5768b39 Mon Sep 17 00:00:00 2001 From: rillig Date: Tue, 19 Apr 2005 20:12:07 +0000 Subject: [PATCH] Fixed wrong use of datatypes. In wait_for(), a char was used together with getchar(), in readchar(), a char was used to read input, which in getuchar() is used as an argument to islower() and toupper(). Also removed a condition which terminated the process if the user typed in character 255. Approved by christos. --- games/cribbage/io.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/games/cribbage/io.c b/games/cribbage/io.c index 3d69257616bd..60e83d198782 100644 --- a/games/cribbage/io.c +++ b/games/cribbage/io.c @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.18 2004/11/05 21:30:31 dsl Exp $ */ +/* $NetBSD: io.c,v 1.19 2005/04/19 20:12:07 rillig Exp $ */ /*- * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: io.c,v 1.18 2004/11/05 21:30:31 dsl Exp $"); +__RCSID("$NetBSD: io.c,v 1.19 2005/04/19 20:12:07 rillig Exp $"); #endif #endif /* not lint */ @@ -490,7 +490,7 @@ void wait_for(ch) int ch; { - char c; + int c; if (ch == '\n') while ((c = readchar()) != '\n') @@ -508,11 +508,11 @@ int readchar() { int cnt; - char c; + unsigned char c; over: cnt = 0; - while (read(STDIN_FILENO, &c, sizeof(char)) <= 0) + while (read(STDIN_FILENO, &c, sizeof(unsigned char)) <= 0) if (cnt++ > 100) { /* if we are getting infinite EOFs */ bye(); /* quit the game */ exit(1); @@ -545,9 +545,6 @@ getline() refresh(); /* loop reading in the string, and put it in a temporary buffer */ for (sp = linebuf; (c = readchar()) != '\n'; clrtoeol(), refresh()) { - if (c == -1) - continue; - else if (c == erasechar()) { /* process erase character */ if (sp > linebuf) { int i;