Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mike@mikegerwitz.com>2011-08-25 18:39:48 -0400
committerMike Gerwitz <mike@mikegerwitz.com>2011-08-25 18:39:48 -0400
commit10e2ff438c34c178afe3ec7f8e896f7f09f7df2b (patch)
tree6678db822b70588d0af6efeace99b88cf14b1e8f
parent23f3a04ef79b2ec90bdd00bab44a17a33e25f0e9 (diff)
downloadgsgp-10e2ff438c34c178afe3ec7f8e896f7f09f7df2b.tar.gz
gsgp-10e2ff438c34c178afe3ec7f8e896f7f09f7df2b.tar.bz2
gsgp-10e2ff438c34c178afe3ec7f8e896f7f09f7df2b.zip
process-input no longer falls through to other objects
-rwxr-xr-xtest/test-process-input20
-rwxr-xr-xutil/process-input7
2 files changed, 25 insertions, 2 deletions
diff --git a/test/test-process-input b/test/test-process-input
index 2e54150..dafec75 100755
--- a/test/test-process-input
+++ b/test/test-process-input
@@ -48,6 +48,13 @@ OBJECT door
ACTION multi
$multiactions
+OBJECT foo
+ ACTION bar
+ MSG Foo bar
+OBJECT cow
+ ACTION moo
+ MSG MOOOOOOOOOOOOOOOOOO!
+
STORY
This is a test scene.
"
@@ -69,7 +76,7 @@ assert-equal "$( tryinput "open door" )" "GO $scene_opendoor" || {
# actions on unknown objects should simply output an empty string
assert-equal "$( tryinput "open idkwhat" )" "" || {
- simplefail "Should not be able to perform actions on unknown objects"
+ fail "Should not be able to perform actions on unknown objects"
}
# unknown actions on known objects should simply output an empty string
@@ -83,3 +90,14 @@ assert-equal "$( tryinput "multi door" )" "$expected" || {
fail "All commands for a multi-line action should be returned"
}
+# should not fall through to another object (action exists in object below the
+# first)
+assert-equal "$( tryinput "bar door" )" "" || {
+ fail "Actions should not fall through to other objects"
+}
+
+# fallthrough shouldn't occur if no newline separates objects
+assert-equal "$( tryinput "moo foo" )" "" || {
+ fail "Actions should not fall through to other objects (missing nl)"
+}
+
diff --git a/util/process-input b/util/process-input
index 4a2689f..c2dde11 100755
--- a/util/process-input
+++ b/util/process-input
@@ -45,9 +45,14 @@ object=$( cut -d' ' -f2 <<< "$words" )
# check for am action on a known object and output the associated commands, left
# trimmed
awk "
- /OBJECT $object/,/^$/ {
+ /OBJECT $object/ {
found = 1
+ getline
}
+ found && /^[ \\t]*$|^[A-Z]/ {
+ found = 0
+ }
+
/^( |\\t)ACTION $action$/ {
if ( found ) {
getline