aboutsummaryrefslogtreecommitdiffstats
path: root/interpret.h
diff options
context:
space:
mode:
Diffstat (limited to 'interpret.h')
-rw-r--r--interpret.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/interpret.h b/interpret.h
index df70bd09..3d9ba572 100644
--- a/interpret.h
+++ b/interpret.h
@@ -67,6 +67,7 @@ r_interpret(INSTRUCTION *code)
Regexp *rp;
NODE *set_array = NULL; /* array with a post-assignment routine */
NODE *set_idx = NULL; /* the index of the array element */
+ bool in_indirect_call = false;
/* array subscript */
@@ -1059,6 +1060,14 @@ arrayfor:
DEREF(t1);
}
free_api_string_copies();
+
+ if (in_indirect_call) {
+ // pop function name off the stack
+ NODE *fname = POP();
+ DEREF(fname);
+ in_indirect_call = false;
+ }
+
PUSH(r);
}
break;
@@ -1132,6 +1141,7 @@ match_re:
NODE *f = NULL;
int arg_count;
char save;
+ NODE *function_name;
arg_count = (pc + 1)->expr_count;
t1 = PEEK(arg_count); /* indirect var */
@@ -1174,6 +1184,12 @@ match_re:
r = the_func(arg_count);
str_restore(t1, save);
+ // Normally, setup_frame() handles getting rid of the
+ // function name. Since we have called the builtin directly,
+ // we have to manually do this here.
+ function_name = POP();
+ DEREF(function_name);
+
PUSH(r);
break;
} else if (f->type != Node_func) {
@@ -1195,6 +1211,7 @@ match_re:
npc[1] = pc[1];
npc[1].func_name = fname; /* name of the builtin */
npc[1].c_function = bc->c_function;
+ in_indirect_call = true;
ni = npc;
JUMPTO(ni);
} else