summaryrefslogtreecommitdiff
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2020-06-14 11:18:15 +0300
committerArnold D. Robbins <arnold@skeeve.com>2020-06-14 11:18:15 +0300
commit8b1a5b7dbf993908f24c1a0a1ddebbf2b96c70dd (patch)
tree11e82319a978fb134df2c42d48ae36927cfba98c /builtin.c
parent2911138b7d7901a2f6dcd2d99879f055dec5e3f7 (diff)
downloadgawk-8b1a5b7dbf993908f24c1a0a1ddebbf2b96c70dd.tar.gz
Check for FUNCTAB and SYMTAB as destination in builtin functions.
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/builtin.c b/builtin.c
index 7ef2acd8..9b5609fa 100644
--- a/builtin.c
+++ b/builtin.c
@@ -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");
+}