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>.
This commit is contained in:
parent
efa00c6291
commit
08ab0f321a
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: hdr.h,v 1.5 1998/08/29 20:19:56 hubertf Exp $ */
|
||||
/* $NetBSD: hdr.h,v 1.6 1999/02/10 00:11:28 hubertf Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
|
@ -64,7 +64,7 @@ extern char data_file[]; /* Virtual data file */
|
|||
|
||||
#define TAB 011
|
||||
#define LF 012
|
||||
#define FLUSHLINE while (getchar()!='\n')
|
||||
#define FLUSHLINE do { int flushline_ch; while ((flushline_ch = getchar()) != EOF && flushline_ch != '\n'); } while (0)
|
||||
#define FLUSHLF while (next()!=LF)
|
||||
|
||||
int loc, newloc, oldloc, oldlc2, wzdark, gaveup, kq, k, k2;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue