Don't exit on EOF from get_input().

This commit is contained in:
Jason S. Ninneman 2017-06-20 09:02:34 -07:00 committed by Eric S. Raymond
parent 53fd6348b9
commit 9cda8ad2e2

8
misc.c
View file

@ -257,8 +257,8 @@ char* get_input()
IGNORE(getline(&input, &n, stdin)); IGNORE(getline(&input, &n, stdin));
} }
if (input == NULL) // Got EOF; quit. if (input == NULL) // Got EOF; return with it.
exit(EXIT_SUCCESS); return(input);
else if (input[0] == '#') // Ignore comments. else if (input[0] == '#') // Ignore comments.
continue; continue;
else // We have a 'normal' line; leave the loop. 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); speak(question);
reply = get_input(); reply = get_input();
if (reply == NULL) {
linenoiseFree(reply);
exit(EXIT_SUCCESS);
}
char* firstword = (char*) xmalloc(strlen(reply)+1); char* firstword = (char*) xmalloc(strlen(reply)+1);
sscanf(reply, "%s", firstword); sscanf(reply, "%s", firstword);