summaryrefslogtreecommitdiffstats
path: root/wump
diff options
context:
space:
mode:
authorjwise <jwise@NetBSD.org>2005-03-21 18:45:18 +0000
committerjwise <jwise@NetBSD.org>2005-03-21 18:45:18 +0000
commitc6d27cf21c2735b2a978cc82deae64f013fcb8d1 (patch)
tree68aab36e68f0a25319eb288c7f322a9a68040f4b /wump
parent40182c475daed2ec42e48662560cbbe39ecf807a (diff)
downloadbsdgames-darwin-c6d27cf21c2735b2a978cc82deae64f013fcb8d1.tar.gz
bsdgames-darwin-c6d27cf21c2735b2a978cc82deae64f013fcb8d1.tar.zst
bsdgames-darwin-c6d27cf21c2735b2a978cc82deae64f013fcb8d1.zip
Fix a long-standing bug in wump(6) whereby hitting ^d to exit would first
print ``Care to play another game? (y-n)'' (but then exit anyway without waiting for an answer).
Diffstat (limited to 'wump')
-rw-r--r--wump/wump.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/wump/wump.c b/wump/wump.c
index 6c4b0e94..904b682c 100644
--- a/wump/wump.c
+++ b/wump/wump.c
@@ -1,4 +1,4 @@
-/* $NetBSD: wump.c,v 1.17 2005/02/15 12:56:20 jsm Exp $ */
+/* $NetBSD: wump.c,v 1.18 2005/03/21 18:45:18 jwise Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
#if 0
static char sccsid[] = "@(#)wump.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: wump.c,v 1.17 2005/02/15 12:56:20 jsm Exp $");
+__RCSID("$NetBSD: wump.c,v 1.18 2005/03/21 18:45:18 jwise Exp $");
#endif
#endif /* not lint */
@@ -142,7 +142,7 @@ main(argc, argv)
int argc;
char **argv;
{
- int c;
+ int c, e=0;
/* Revoke setgid privileges */
setgid(getgid());
@@ -238,11 +238,13 @@ quiver holds %d custom super anti-evil Wumpus arrows. Good luck.\n",
display_room_stats();
(void)printf("Move or shoot? (m-s) ");
(void)fflush(stdout);
- if (!fgets(answer, sizeof(answer), stdin))
+ if (!fgets(answer, sizeof(answer), stdin)) {
+ e=1;
break;
- } while (!take_action());
+ }
+ } while (!(e = take_action()));
- if (!getans("\nCare to play another game? (y-n) "))
+ if (e || !getans("\nCare to play another game? (y-n) "))
exit(0);
if (getans("In the same cave? (y-n) "))
clear_things_in_cave();