Deal around newline-only lines pruned to zero-lenght
Test for that, too
This commit is contained in:
parent
ef97d579ea
commit
551838cea2
5 changed files with 26 additions and 3 deletions
15
misc.c
15
misc.c
|
@ -352,7 +352,7 @@ char* get_input()
|
|||
|
||||
bool silent_yes()
|
||||
{
|
||||
bool outcome;
|
||||
bool outcome = false;
|
||||
|
||||
for (;;) {
|
||||
char* reply = get_input();
|
||||
|
@ -363,6 +363,11 @@ bool silent_yes()
|
|||
exit(EXIT_SUCCESS);
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
if (strlen(reply) == 0) {
|
||||
free(reply);
|
||||
rspeak(PLEASE_ANSWER);
|
||||
continue;
|
||||
}
|
||||
|
||||
char* firstword = (char*) xmalloc(strlen(reply) + 1);
|
||||
sscanf(reply, "%s", firstword);
|
||||
|
@ -398,7 +403,7 @@ bool yes(const char* question, const char* yes_response, const char* no_response
|
|||
/* Print message X, wait for yes/no answer. If yes, print Y and return true;
|
||||
* if no, print Z and return false. */
|
||||
{
|
||||
bool outcome;
|
||||
bool outcome = false;
|
||||
|
||||
for (;;) {
|
||||
speak(question);
|
||||
|
@ -412,6 +417,12 @@ bool yes(const char* question, const char* yes_response, const char* no_response
|
|||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
if (strlen(reply) == 0) {
|
||||
free(reply);
|
||||
rspeak(PLEASE_ANSWER);
|
||||
continue;
|
||||
}
|
||||
|
||||
char* firstword = (char*) xmalloc(strlen(reply) + 1);
|
||||
sscanf(reply, "%s", firstword);
|
||||
|
||||
|
|
|
@ -273,6 +273,10 @@ With what? Your bare hands?
|
|||
|
||||
Please answer the question.
|
||||
|
||||
> green
|
||||
|
||||
Please answer the question.
|
||||
|
||||
> n
|
||||
|
||||
The dragon looks rather nasty. You'd best not try to get by.
|
||||
|
|
|
@ -50,6 +50,7 @@ drop bird
|
|||
extinguish dragon
|
||||
kill dragon
|
||||
|
||||
green
|
||||
n
|
||||
kill dragon
|
||||
y
|
||||
|
|
|
@ -7,6 +7,12 @@ Please answer the question.
|
|||
|
||||
Welcome to Adventure!! Would you like instructions?
|
||||
|
||||
>
|
||||
|
||||
Please answer the question.
|
||||
|
||||
Welcome to Adventure!! Would you like instructions?
|
||||
|
||||
> y
|
||||
|
||||
Somewhere nearby is Colossal Cave, where others have found fortunes in
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
## Test for various cases not found in walkthroughs.
|
||||
foo
|
||||
|
||||
y
|
||||
seed 1801426495
|
||||
version
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue