diff options
Diffstat (limited to 'interpret.h')
-rw-r--r-- | interpret.h | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/interpret.h b/interpret.h index c7380bd4..ab6c9b33 100644 --- a/interpret.h +++ b/interpret.h @@ -210,8 +210,32 @@ top: lintwarn(_("subscript of array `%s' is null string"), array_vname(t1)); } - r = *assoc_lookup(t1, t2); + /* for FUNCTAB, get the name as the element value */ + if (t1 == func_table) { + static bool warned = false; + + if (do_lint && ! warned) { + warned = true; + lintwarn(_("FUNCTAB is a gawk extension")); + } + r = t2; + } else { + r = *assoc_lookup(t1, t2); + } DEREF(t2); + + /* for SYMTAB, step through to the actual variable */ + if (t1 == symbol_table) { + static bool warned = false; + + if (do_lint && ! warned) { + warned = true; + lintwarn(_("SYMTAB is a gawk extension")); + } + if (r->type == Node_var) + r = r->var_value; + } + if (r->type == Node_val) UPREF(r); PUSH(r); @@ -531,6 +555,12 @@ mod: array_vname(t1), (int) t2->stlen, t2->stptr); } DEREF(t2); + + if (t1 == func_table) + fatal(_("cannot assign to elements of FUNCTAB")); + else if (t1 == symbol_table && (*lhs)->type == Node_var) + lhs = & ((*lhs)->var_value); + unref(*lhs); *lhs = POP_SCALAR(); break; @@ -876,7 +906,10 @@ match_re: arg_count = (pc + 1)->expr_count; t1 = PEEK(arg_count); /* indirect var */ - assert(t1->type == Node_val); /* @a[1](p) not allowed in grammar */ + + if (t1->type != Node_val) /* @a[1](p) not allowed in grammar */ + fatal(_("indirect function call requires a simple scalar value")); + t1 = force_string(t1); if (t1->stlen > 0) { /* retrieve function definition node */ @@ -890,9 +923,13 @@ match_re: f = lookup(t1->stptr); } - if (f == NULL || f->type != Node_func) - fatal(_("function called indirectly through `%s' does not exist"), - pc->func_name); + if (f == NULL || f->type != Node_func) { + if (f->type == Node_ext_func) + fatal(_("cannot (yet) call extension functions indirectly")); + else + fatal(_("function called indirectly through `%s' does not exist"), + pc->func_name); + } pc->func_body = f; /* save for next call */ ni = setup_frame(pc); |