projects
/
open-adventure.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
ef97d57
)
Deal around newline-only lines pruned to zero-lenght
author
NHOrus
<jy6x2b32pie9@yahoo.com>
Fri, 7 Jul 2017 08:21:37 +0000
(11:21 +0300)
committer
NHOrus
<jy6x2b32pie9@yahoo.com>
Fri, 7 Jul 2017 08:21:37 +0000
(11:21 +0300)
Test for that, too
misc.c
patch
|
blob
|
history
tests/barehands.chk
patch
|
blob
|
history
tests/barehands.log
patch
|
blob
|
history
tests/illformed.chk
patch
|
blob
|
history
tests/illformed.log
patch
|
blob
|
history
diff --git
a/misc.c
b/misc.c
index 784eb7310f063ee3a700055a17590e4d83a13786..cef36519e82e5d9d250da92e4784373b234f8461 100644
(file)
--- a/
misc.c
+++ b/
misc.c
@@
-352,7
+352,7
@@
char* get_input()
bool silent_yes()
{
bool silent_yes()
{
- bool outcome;
+ bool outcome
= false
;
for (;;) {
char* reply = get_input();
for (;;) {
char* reply = get_input();
@@
-363,6
+363,11
@@
bool silent_yes()
exit(EXIT_SUCCESS);
// LCOV_EXCL_STOP
}
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);
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. */
{
/* 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);
for (;;) {
speak(question);
@@
-412,6
+417,12
@@
bool yes(const char* question, const char* yes_response, const char* no_response
// LCOV_EXCL_STOP
}
// LCOV_EXCL_STOP
}
+ if (strlen(reply) == 0) {
+ free(reply);
+ rspeak(PLEASE_ANSWER);
+ continue;
+ }
+
char* firstword = (char*) xmalloc(strlen(reply) + 1);
sscanf(reply, "%s", firstword);
char* firstword = (char*) xmalloc(strlen(reply) + 1);
sscanf(reply, "%s", firstword);
diff --git
a/tests/barehands.chk
b/tests/barehands.chk
index 09ddeda1c982f642b5ca26b60bd5ac224a502b9d..1c94758952a21cba8017a8be02db9ecddb3134d1 100644
(file)
--- a/
tests/barehands.chk
+++ b/
tests/barehands.chk
@@
-273,6
+273,10
@@
With what? Your bare hands?
Please answer the question.
Please answer the question.
+> green
+
+Please answer the question.
+
> n
The dragon looks rather nasty. You'd best not try to get by.
> n
The dragon looks rather nasty. You'd best not try to get by.
diff --git
a/tests/barehands.log
b/tests/barehands.log
index 9f9c40813c62f2c9cb1ebb0a06ff7c11c87b20a2..72fc3de16de063e963ecc1d42646295646d19ce3 100644
(file)
--- a/
tests/barehands.log
+++ b/
tests/barehands.log
@@
-50,7
+50,8
@@
drop bird
extinguish dragon
kill dragon
extinguish dragon
kill dragon
+green
n
kill dragon
y
n
kill dragon
y
-kill dragon
\ No newline at end of file
+kill dragon
diff --git
a/tests/illformed.chk
b/tests/illformed.chk
index 1a118f28b3968f62623376fdd07e41064e757144..73ca685774901b68e10d15657fa0af61768fdc5d 100644
(file)
--- a/
tests/illformed.chk
+++ b/
tests/illformed.chk
@@
-7,6
+7,12
@@
Please answer the question.
Welcome to Adventure!! Would you like instructions?
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
> y
Somewhere nearby is Colossal Cave, where others have found fortunes in
diff --git
a/tests/illformed.log
b/tests/illformed.log
index 5e56b4a23d50dca303e19b5f98733ad0eab17f7e..13821c48a0518d2c86d23c14f5ca6b14dbdede66 100644
(file)
--- a/
tests/illformed.log
+++ b/
tests/illformed.log
@@
-1,5
+1,6
@@
## Test for various cases not found in walkthroughs.
foo
## Test for various cases not found in walkthroughs.
foo
+
y
seed 1801426495
version
y
seed 1801426495
version