X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=misc.c;h=0b28f00a2411e4b1673e9836b604c9c24f22be31;hb=60847652aa39476bd21e7ec0a339b99abd73845d;hp=81f8e2b2bd4f0212d258495fb0bed42403a7501b;hpb=6521d49c0752da0bf65769a1d38b583d3a2a1854;p=open-adventure.git diff --git a/misc.c b/misc.c index 81f8e2b..0b28f00 100644 --- a/misc.c +++ b/misc.c @@ -252,7 +252,10 @@ char* get_input() input = NULL; size_t n = 0; if (isatty(0)) + // LCOV_EXCL_START + // Should be unreachable in tests, as they will use a non-interactive shell. printf("%s", input_prompt); + // LCOV_EXCL_STOP IGNORE(getline(&input, &n, stdin)); } @@ -289,10 +292,13 @@ 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); - } + if (reply == NULL) { + // LCOV_EXCL_START + // Should be unreachable. Reply should never be NULL + linenoiseFree(reply); + exit(EXIT_SUCCESS); + // LCOV_EXCL_STOP + } char* firstword = (char*) xmalloc(strlen(reply)+1); sscanf(reply, "%s", firstword);