From 221001ddc1305a77f748914f30b2f03ffb37e74a Mon Sep 17 00:00:00 2001 From: rread Date: Tue, 30 Jul 2002 01:50:29 +0000 Subject: [PATCH] fix readline --- lustre/utils/parser.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lustre/utils/parser.c b/lustre/utils/parser.c index 3049daf..0118e68 100644 --- a/lustre/utils/parser.c +++ b/lustre/utils/parser.c @@ -308,19 +308,15 @@ int init_input() char * readline(char * prompt) { char line[2048]; - int n; - char * ret = NULL; + int n = 0; if (prompt) printf ("%s", prompt); - fgets(line, sizeof(line), stdin); + if (fgets(line, sizeof(line), stdin) == NULL) + return (NULL); n = strlen(line); if (n && line[n-1] == '\n') - line[--n] = '\0'; - if (n == 0 && feof(stdin)) { - ret = NULL; - } else - ret = strdup(line); - return ret; + line[n-1] = '\0'; + return strdup(line); } #endif -- 1.8.3.1