summaryrefslogtreecommitdiffstats
path: root/battlestar
diff options
context:
space:
mode:
authorjsm <jsm@NetBSD.org>2000-09-24 15:51:40 +0000
committerjsm <jsm@NetBSD.org>2000-09-24 15:51:40 +0000
commit7bb2eac314ceddc83e22713cde57c69b6230f916 (patch)
treea347e2b90e07f1cb40b204490c6caeefab10a09d /battlestar
parent520ce860c38b79913e06c3fd240c968228e4c4ae (diff)
downloadbsdgames-darwin-7bb2eac314ceddc83e22713cde57c69b6230f916.tar.gz
bsdgames-darwin-7bb2eac314ceddc83e22713cde57c69b6230f916.tar.zst
bsdgames-darwin-7bb2eac314ceddc83e22713cde57c69b6230f916.zip
Discard any part of a line of input that goes beyond our buffer rather
than treating it as our next line of input. From OpenBSD.
Diffstat (limited to 'battlestar')
-rw-r--r--battlestar/getcom.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/battlestar/getcom.c b/battlestar/getcom.c
index 5d68738c..85cee2e5 100644
--- a/battlestar/getcom.c
+++ b/battlestar/getcom.c
@@ -1,4 +1,4 @@
-/* $NetBSD: getcom.c,v 1.9 2000/09/21 17:44:34 jsm Exp $ */
+/* $NetBSD: getcom.c,v 1.10 2000/09/24 15:51:40 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)getcom.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: getcom.c,v 1.9 2000/09/21 17:44:34 jsm Exp $");
+__RCSID("$NetBSD: getcom.c,v 1.10 2000/09/24 15:51:40 jsm Exp $");
#endif
#endif /* not lint */
@@ -65,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 = getchar()) != '\n' && i != EOF)
+ continue;
+ }
return (buf);
}