X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=blobdiff_plain;f=misc.c;h=59c33bdf847819e8562ca040cb9866ff61196c7f;hp=0d2311c945318805be770491ae9890b035d535ce;hb=94ea37d2bceffd4842a1af8d12c1c43f7e9c9fe8;hpb=e10637c419573aaa3df0d3fb54834adb9ae40b92 diff --git a/misc.c b/misc.c index 0d2311c..59c33bd 100644 --- a/misc.c +++ b/misc.c @@ -351,9 +351,10 @@ char* get_input() if (input == NULL) // Got EOF; return with it. return (input); - else if (input[0] == '#') // Ignore comments. + else if (input[0] == '#') { // Ignore comments. + linenoiseFree(input); continue; - else // We have a 'normal' line; leave the loop. + } else // We have a 'normal' line; leave the loop. break; } @@ -389,6 +390,8 @@ bool silent_yes() char* firstword = (char*) xmalloc(strlen(reply) + 1); sscanf(reply, "%s", firstword); + linenoiseFree(reply); + for (int i = 0; i < (int)strlen(firstword); ++i) firstword[i] = tolower(firstword[i]); @@ -408,7 +411,6 @@ bool silent_yes() } else rspeak(PLEASE_ANSWER); } - linenoiseFree(reply); return (outcome); } @@ -435,6 +437,8 @@ bool yes(const char* question, const char* yes_response, const char* no_response char* firstword = (char*) xmalloc(strlen(reply) + 1); sscanf(reply, "%s", firstword); + linenoiseFree(reply); + for (int i = 0; i < (int)strlen(firstword); ++i) firstword[i] = tolower(firstword[i]); @@ -455,8 +459,9 @@ bool yes(const char* question, const char* yes_response, const char* no_response break; } else rspeak(PLEASE_ANSWER); + } - linenoiseFree(reply); + return (outcome); }