aboutsummaryrefslogtreecommitdiffstats
path: root/interpret.h
diff options
context:
space:
mode:
Diffstat (limited to 'interpret.h')
-rw-r--r--interpret.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/interpret.h b/interpret.h
index 8c9675bb..13394e22 100644
--- a/interpret.h
+++ b/interpret.h
@@ -886,6 +886,8 @@ mod:
size_t num_elems = 0;
static NODE *sorted_in = NULL;
const char *how_to_sort = "@unsorted";
+ char save;
+ bool saved_end = false;
/* get the array */
array = POP_ARRAY();
@@ -908,11 +910,16 @@ mod:
if (sort_str != NULL) {
sort_str = force_string(sort_str);
- if (sort_str->stlen > 0)
+ if (sort_str->stlen > 0) {
how_to_sort = sort_str->stptr;
+ str_terminate(sort_str, save);
+ saved_end = true;
+ }
}
list = assoc_list(array, how_to_sort, SORTED_IN);
+ if (saved_end)
+ str_restore(sort_str, save);
arrayfor:
getnode(r);
@@ -1049,6 +1056,7 @@ match_re:
{
NODE *f = NULL;
int arg_count;
+ char save;
arg_count = (pc + 1)->expr_count;
t1 = PEEK(arg_count); /* indirect var */
@@ -1057,12 +1065,14 @@ match_re:
fatal(_("indirect function call requires a simple scalar value"));
t1 = force_string(t1);
+ str_terminate(t1, save);
if (t1->stlen > 0) {
/* retrieve function definition node */
f = pc->func_body;
if (f != NULL && strcmp(f->vname, t1->stptr) == 0) {
/* indirect var hasn't been reassigned */
+ str_restore(t1, save);
ni = setup_frame(pc);
JUMPTO(ni); /* Op_func */
}
@@ -1087,10 +1097,12 @@ match_re:
r = call_split_func(t1->stptr, arg_count);
else
r = the_func(arg_count);
+ str_restore(t1, save);
PUSH(r);
break;
} else if (f->type != Node_func) {
+ str_restore(t1, save);
if (f->type == Node_ext_func) {
/* code copied from below, keep in sync */
INSTRUCTION *bc;
@@ -1115,6 +1127,7 @@ match_re:
pc->func_name);
}
pc->func_body = f; /* save for next call */
+ str_restore(t1, save);
ni = setup_frame(pc);
JUMPTO(ni); /* Op_func */