summaryrefslogtreecommitdiffstats
path: root/monop
diff options
context:
space:
mode:
Diffstat (limited to 'monop')
-rw-r--r--monop/getinp.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/monop/getinp.c b/monop/getinp.c
index 4e1c2881..92546ac6 100644
--- a/monop/getinp.c
+++ b/monop/getinp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: getinp.c,v 1.16 2008/02/19 09:45:02 dholland Exp $ */
+/* $NetBSD: getinp.c,v 1.17 2008/02/23 20:12:15 dholland Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)getinp.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: getinp.c,v 1.16 2008/02/19 09:45:02 dholland Exp $");
+__RCSID("$NetBSD: getinp.c,v 1.17 2008/02/23 20:12:15 dholland Exp $");
#endif
#endif /* not lint */
@@ -55,18 +55,13 @@ getinp(prompt, lst)
{
int i, n_match, match = 0;
char *sp;
- int c;
for (;;) {
printf("%s", prompt);
- for (sp = buf; (c = getchar()) != '\n'; ) {
- if (c == -1)
- return 0;
- *sp = c;
- if (sp != buf || *sp != ' ')
- sp++;
+ fgets(buf, sizeof(buf), stdin);
+ if (feof(stdin)) {
+ return 0;
}
- *sp = c;
if (buf[0] == '?' && buf[1] == '\n') {
printf("Valid inputs are: ");
for (i = 0, match = 18; lst[i]; i++) {
@@ -88,7 +83,8 @@ getinp(prompt, lst)
}
continue;
}
- *sp = '\0';
+ if ((sp = strchr(buf, '\n')) != NULL)
+ *sp = '\0';
for (sp = buf; *sp; sp++)
*sp = tolower((unsigned char)*sp);
for (i = n_match = 0; lst[i]; i++)