From c6d27cf21c2735b2a978cc82deae64f013fcb8d1 Mon Sep 17 00:00:00 2001 From: jwise Date: Mon, 21 Mar 2005 18:45:18 +0000 Subject: 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). --- wump/wump.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'wump') 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(); -- cgit v1.2.3-56-ge451