[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-3996-g8b1a5b7
From: |
Arnold Robbins |
Subject: |
[SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-3996-g8b1a5b7 |
Date: |
Sun, 14 Jun 2020 04:18:39 -0400 (EDT) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, gawk-5.1-stable has been updated
via 8b1a5b7dbf993908f24c1a0a1ddebbf2b96c70dd (commit)
from 2911138b7d7901a2f6dcd2d99879f055dec5e3f7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=8b1a5b7dbf993908f24c1a0a1ddebbf2b96c70dd
commit 8b1a5b7dbf993908f24c1a0a1ddebbf2b96c70dd
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Sun Jun 14 11:18:15 2020 +0300
Check for FUNCTAB and SYMTAB as destination in builtin functions.
diff --git a/ChangeLog b/ChangeLog
index 83bf1a0..384bc6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2020-06-14 Arnold D. Robbins <arnold@skeeve.com>
+
+ Disallow SYMTAB and FUNCTAB as destination arguments to builtin
+ functions that clear arrays:
+
+ * awk.h (check_symtab_functab): Add declaration.
+ * array.c (asort_actual): Call it in check for second argument.
+ * builtin.c (check_symtab_functab): New function.
+ (do_match): Call it in check for third argument.
+ * field.c (do_patsplit, do_split): Call it in checks for fourth and
+ second arguments.
+
2020-06-12 Arnold D. Robbins <arnold@skeeve.com>
* array.c (asort_actual): If SYMTAB or FUNCTAB is the second argument,
diff --git a/array.c b/array.c
index e3bbc83..c256620 100644
--- a/array.c
+++ b/array.c
@@ -824,12 +824,9 @@ asort_actual(int nargs, sort_context_t ctxt)
fatal(_("%s: second argument is not an array"),
ctxt == ASORT ? "asort" : "asorti");
}
- if (dest == symbol_table)
- fatal(_("%s: SYMTAB cannot be used as second argument"),
- ctxt == ASORT ? "asort" : "asorti");
- else if (dest == func_table)
- fatal(_("%s: FUNCTAB cannot be used as second
argument"),
- ctxt == ASORT ? "asort" : "asorti");
+ check_symtab_functab(dest,
+ ctxt == ASORT ? "asort" : "asorti",
+ _("%s: cannot use %s as second argument"));
}
array = POP_PARAM();
diff --git a/awk.h b/awk.h
index 9005ff3..cccb8ce 100644
--- a/awk.h
+++ b/awk.h
@@ -1498,6 +1498,7 @@ extern NODE *do_typeof(int nargs);
extern int strncasecmpmbs(const unsigned char *,
const unsigned char *, size_t);
extern int sanitize_exit_status(int status);
+extern void check_symtab_functab(NODE *dest, const char *fname, const char
*msg);
/* debug.c */
extern void init_debug(void);
extern int debug_prog(INSTRUCTION *pc);
diff --git a/builtin.c b/builtin.c
index 7ef2acd..9b5609f 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");
+}
diff --git a/field.c b/field.c
index 45ab9f5..0e84447 100644
--- a/field.c
+++ b/field.c
@@ -980,6 +980,8 @@ do_split(int nargs)
sep_arr = POP_PARAM();
if (sep_arr->type != Node_var_array)
fatal(_("split: fourth argument is not an array"));
+ check_symtab_functab(sep_arr, "split",
+ _("%s: cannot use %s as fourth argument"));
if ((do_lint_extensions || do_lint_old) && ! warned) {
warned = true;
lintwarn(_("split: fourth argument is a gawk
extension"));
@@ -990,6 +992,8 @@ do_split(int nargs)
arr = POP_PARAM();
if (arr->type != Node_var_array)
fatal(_("split: second argument is not an array"));
+ check_symtab_functab(arr, "split",
+ _("%s: cannot use %s as second argument"));
if (sep_arr != NULL) {
if (sep_arr == arr)
@@ -1073,11 +1077,15 @@ do_patsplit(int nargs)
sep_arr = POP_PARAM();
if (sep_arr->type != Node_var_array)
fatal(_("patsplit: fourth argument is not an array"));
+ check_symtab_functab(sep_arr, "patsplit",
+ _("%s: cannot use %s as fourth argument"));
}
sep = POP();
arr = POP_PARAM();
if (arr->type != Node_var_array)
fatal(_("patsplit: second argument is not an array"));
+ check_symtab_functab(arr, "patsplit",
+ _("%s: cannot use %s as second argument"));
src = TOP_STRING();
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 12 ++++++++++++
array.c | 9 +++------
awk.h | 1 +
builtin.c | 14 ++++++++++++++
field.c | 8 ++++++++
5 files changed, 38 insertions(+), 6 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-3996-g8b1a5b7,
Arnold Robbins <=