Fix bug that made YES() case-sensitive.

Also fix a related memory leak.
This commit is contained in:
Jason S. Ninneman 2017-06-18 14:14:13 -07:00
parent 550734fd3f
commit 65e2e472dd

10
misc.c
View file

@ -271,10 +271,12 @@ bool YES(vocab_t question, vocab_t yes_response, vocab_t no_response)
for (int i = 0; i < strlen(firstword); ++i)
firstword[i] = tolower(firstword[i]);
int yes = strncmp("yes", reply, sizeof("yes") - 1);
int y = strncmp("y", reply, sizeof("y") - 1);
int no = strncmp("no", reply, sizeof("no") - 1);
int n = strncmp("n", reply, sizeof("n") - 1);
int yes = strncmp("yes", firstword, sizeof("yes") - 1);
int y = strncmp("y", firstword, sizeof("y") - 1);
int no = strncmp("no", firstword, sizeof("no") - 1);
int n = strncmp("n", firstword, sizeof("n") - 1);
free(firstword);
if (yes == 0 || y == 0) {
RSPEAK(yes_response);