summaryrefslogtreecommitdiffstats
path: root/adventure/wizard.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/wizard.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/wizard.c')
-rw-r--r--adventure/wizard.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/adventure/wizard.c b/adventure/wizard.c
index 5df1b08d..94de0530 100644
--- a/adventure/wizard.c
+++ b/adventure/wizard.c
@@ -1,4 +1,4 @@
-/* $NetBSD: wizard.c,v 1.8 1998/08/24 22:07:37 hubertf Exp $ */
+/* $NetBSD: wizard.c,v 1.9 1999/02/10 00:11:28 hubertf Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)wizard.c 8.1 (Berkeley) 6/2/93";
#else
-__RCSID("$NetBSD: wizard.c,v 1.8 1998/08/24 22:07:37 hubertf Exp $");
+__RCSID("$NetBSD: wizard.c,v 1.9 1999/02/10 00:11:28 hubertf Exp $");
#endif
#endif /* not lint */
@@ -136,9 +136,14 @@ ciao()
char fname[80];
printf("What would you like to call the saved version?\n");
- for (c = fname;; c++)
- if ((*c = getchar()) == '\n')
+ /* XXX - should use fgetln to avoid arbitrary limit */
+ for (c = fname; c < fname + sizeof fname - 1; c++) {
+ int ch;
+ ch = getchar();
+ if (ch == '\n' || ch == EOF)
break;
+ *c = ch;
+ }
*c = 0;
if (save(fname) != 0)
return; /* Save failed */