summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--games/battlestar/getcom.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/games/battlestar/getcom.c b/games/battlestar/getcom.c
index badd560e799..113b3906442 100644
--- a/games/battlestar/getcom.c
+++ b/games/battlestar/getcom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getcom.c,v 1.7 2000/09/17 21:28:33 pjanzen Exp $ */
+/* $OpenBSD: getcom.c,v 1.8 2000/09/23 02:58:40 pjanzen Exp $ */
/* $NetBSD: getcom.c,v 1.3 1995/03/21 15:07:30 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)getcom.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: getcom.c,v 1.7 2000/09/17 21:28:33 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: getcom.c,v 1.8 2000/09/23 02:58:40 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -53,10 +53,8 @@ getcom(buf, size, prompt, error)
for (;;) {
fputs(prompt, stdout);
if (fgets(buf, size, stdin) == 0) {
- if (feof(stdin)) {
- printf("user closed input stream, quitting...\n");
- exit(0);
- }
+ if (feof(stdin))
+ die(0);
clearerr(stdin);
continue;
}
@@ -67,6 +65,12 @@ getcom(buf, size, prompt, error)
if (error)
puts(error);
}
+ /* If we didn't get to the end of the line, don't read it in next time */
+ if (buf[strlen(buf) - 1] != '\n') {
+ int i;
+ while ((i = fgetc(stdin)) != '\n' && i != EOF)
+ ;
+ }
return (buf);
}