diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 1999-06-13 16:43:13 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 1999-06-13 16:43:13 +0000 |
commit | acd1aa80a42e434ca230af542d8b65241673bcf2 (patch) | |
tree | cb7d7a5e823e02d371e65a6cb00112c5596b7b1c | |
parent | 7a0bed0dda52bd167f7baf9393dd2769225fa0e2 (diff) |
Don't barf on ^D during initial questions
-rw-r--r-- | games/sail/pl_main.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/games/sail/pl_main.c b/games/sail/pl_main.c index b9e958a7599..63f2b8fc63d 100644 --- a/games/sail/pl_main.c +++ b/games/sail/pl_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pl_main.c,v 1.5 1999/03/27 05:07:07 pjanzen Exp $ */ +/* $OpenBSD: pl_main.c,v 1.6 1999/06/13 16:43:12 pjanzen Exp $ */ /* $NetBSD: pl_main.c,v 1.5 1995/04/24 12:25:25 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)pl_main.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: pl_main.c,v 1.5 1999/03/27 05:07:07 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: pl_main.c,v 1.6 1999/06/13 16:43:12 pjanzen Exp $"; #endif #endif /* not lint */ @@ -84,7 +84,7 @@ reprint: printf("\nScenario number? "); (void) fflush(stdout); (void) scanf("%d", &game); - while (getchar() != '\n') + while (getchar() != '\n' && !feof(stdin)) ; } if (game < 0 || game >= NSCENE) @@ -148,12 +148,16 @@ reprint: (void) fflush(stdout); if (scanf("%d", &player) != 1 || player < 0 || player >= cc->vessels) { - while (getchar() != '\n') + while (getchar() != '\n' && !feof(stdin)) ; + if (feof(stdin)) { + printf("\nExiting...\n"); + leave(LEAVE_QUIT); + } (void) puts("Say what?"); player = -1; } else - while (getchar() != '\n') + while (getchar() != '\n' && !feof(stdin)) ; } if (player < 0) @@ -236,6 +240,8 @@ reprint: } } + printf("\n"); + (void) fflush(stdout); initscreen(); draw_board(); (void) snprintf(message, sizeof message, "Captain %s assuming command", |