Skip to content
Permalink
Browse files

fix issue with sub commands reusing command state

  • Loading branch information
samdoshi committed Apr 20, 2017
1 parent 68adf2d commit cbf26ed0b259ffac3ab1f04ad6ab5d5501f86a4d
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/teletype.c
@@ -169,7 +169,6 @@ process_result_t run_command(scene_state_t *ss, const tele_command_t *cmd) {
process_result_t process_command(scene_state_t *ss, exec_state_t *es,
const tele_command_t *c) {
command_state_t cs;
cs_init(&cs);

// 1. Do we have a PRE seperator?
// ------------------------------
@@ -214,6 +213,11 @@ process_result_t process_command(scene_state_t *ss, exec_state_t *es,
const ssize_t sub_start = subs[sub_idx].start;
const ssize_t sub_end = subs[sub_idx].end;

// initialise the command state for each sub, otherwise a value left on
// the stack for the previous sub, can cause the set fn to trigger when
// it shouldn't
cs_init(&cs);

// as we are using a stack based language, we must process commands from
// right to left
for (ssize_t idx = sub_end; idx >= sub_start; idx--) {

0 comments on commit cbf26ed

Please sign in to comment.