From 9cda8ad2e2f4f3bcf51983b3f165023f0bd0e518 Mon Sep 17 00:00:00 2001 From: "Jason S. Ninneman" Date: Tue, 20 Jun 2017 09:02:34 -0700 Subject: [PATCH] Don't exit on EOF from get_input(). --- misc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/misc.c b/misc.c index 6042f76..0924462 100644 --- a/misc.c +++ b/misc.c @@ -257,8 +257,8 @@ char* get_input() IGNORE(getline(&input, &n, stdin)); } - if (input == NULL) // Got EOF; quit. - exit(EXIT_SUCCESS); + if (input == NULL) // Got EOF; return with it. + return(input); else if (input[0] == '#') // Ignore comments. continue; else // We have a 'normal' line; leave the loop. @@ -290,6 +290,10 @@ bool YES(const char* question, const char* yes_response, const char* no_response speak(question); reply = get_input(); + if (reply == NULL) { + linenoiseFree(reply); + exit(EXIT_SUCCESS); + } char* firstword = (char*) xmalloc(strlen(reply)+1); sscanf(reply, "%s", firstword); -- 2.31.1