summaryrefslogtreecommitdiffstats
path: root/adventure/io.c
diff options
context:
space:
mode:
authorhubertf <hubertf@NetBSD.org>1999-02-10 00:11:28 +0000
committerhubertf <hubertf@NetBSD.org>1999-02-10 00:11:28 +0000
commit638c095d5cf47282d99189e1425435a0763a369b (patch)
tree6ec34cf92762fed9680f134cb5ab74869cf60f56 /adventure/io.c
parentf8df8c0281a2b93b58f947c4bc167c998f05e804 (diff)
downloadbsdgames-darwin-638c095d5cf47282d99189e1425435a0763a369b.tar.gz
bsdgames-darwin-638c095d5cf47282d99189e1425435a0763a369b.tar.zst
bsdgames-darwin-638c095d5cf47282d99189e1425435a0763a369b.zip
The game adventure(6) handles EOF on standard input rather
ungracefully. The patch, derived from OpenBSD, improves this handling. Sent in in PR 6556 by Joseph Myers <jsm28@cam.ac.uk>.
Diffstat (limited to 'adventure/io.c')
-rw-r--r--adventure/io.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/adventure/io.c b/adventure/io.c
index 97987009..bbe54d92 100644
--- a/adventure/io.c
+++ b/adventure/io.c
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.10 1998/09/14 09:29:08 hubertf Exp $ */
+/* $NetBSD: io.c,v 1.11 1999/02/10 00:11:28 hubertf Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: io.c,v 1.10 1998/09/14 09:29:08 hubertf Exp $");
+__RCSID("$NetBSD: io.c,v 1.11 1999/02/10 00:11:28 hubertf Exp $");
#endif
#endif /* not lint */
@@ -89,6 +89,9 @@ getin(wrd1, wrd2) /* get command from user */
*s = 0;
return;
}
+ case EOF:
+ printf("user closed input stream, quitting...\n");
+ exit(0);
default:
if (++numch >= MAXSTR) { /* string too long */
printf("Give me a break!!\n");
@@ -106,14 +109,17 @@ yes(x, y, z) /* confirm with rspeak */
int x, y, z;
{
int result = TRUE; /* pacify gcc */
- char ch;
+ int ch;
for (;;) {
rspeak(x); /* tell him what we want */
if ((ch = getchar()) == 'y')
result = TRUE;
- else
- if (ch == 'n')
- result = FALSE;
+ else if (ch == 'n')
+ result = FALSE;
+ else if (ch == EOF) {
+ printf("user closed input stream, quitting...\n");
+ exit(0);
+ }
FLUSHLINE;
if (ch == 'y' || ch == 'n')
break;
@@ -131,14 +137,17 @@ yesm(x, y, z) /* confirm with mspeak */
int x, y, z;
{
int result = TRUE; /* pacify gcc */
- char ch;
+ int ch;
for (;;) {
mspeak(x); /* tell him what we want */
if ((ch = getchar()) == 'y')
result = TRUE;
- else
- if (ch == 'n')
- result = FALSE;
+ else if (ch == 'n')
+ result = FALSE;
+ else if (ch == EOF) {
+ printf("user closed input stream, quitting...\n");
+ exit(0);
+ }
FLUSHLINE;
if (ch == 'y' || ch == 'n')
break;