diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2020-06-14 11:18:15 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2020-06-14 11:18:15 +0300 |
commit | 8b1a5b7dbf993908f24c1a0a1ddebbf2b96c70dd (patch) | |
tree | 11e82319a978fb134df2c42d48ae36927cfba98c /builtin.c | |
parent | 2911138b7d7901a2f6dcd2d99879f055dec5e3f7 (diff) | |
download | gawk-8b1a5b7dbf993908f24c1a0a1ddebbf2b96c70dd.tar.gz |
Check for FUNCTAB and SYMTAB as destination in builtin functions.
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -2678,6 +2678,8 @@ do_match(int nargs) dest = POP_PARAM(); if (dest->type != Node_var_array) fatal(_("match: third argument is not an array")); + check_symtab_functab(dest, "match", + _("%s: cannot use %s as third argument")); assoc_clear(dest); } tre = POP(); @@ -4328,3 +4330,15 @@ fmt: } return buf; } + + +/* check_symtab_functab --- check if dest is SYMTAB or FUNCTAB, fatal if so */ + +void +check_symtab_functab(NODE *dest, const char *fname, const char *msg) +{ + if (dest == symbol_table) + fatal(msg, fname, "SYMTAB"); + else if (dest == func_table) + fatal(msg, fname, "FUNCTAB"); +} |