[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-4297-gc89ce58
From: |
Arnold Robbins |
Subject: |
[SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-4297-gc89ce58 |
Date: |
Fri, 10 Sep 2021 03:44:44 -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 c89ce5850cf9dc9173364de62bb183b207826e96 (commit)
from 769de8893a550b3439aabe7c754fbf9cafa45df8 (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=c89ce5850cf9dc9173364de62bb183b207826e96
commit c89ce5850cf9dc9173364de62bb183b207826e96
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Fri Sep 10 10:43:21 2021 +0300
Bug fix for FUNCTAB and SYMTAB. Update tests.
diff --git a/ChangeLog b/ChangeLog
index 09512cf..e8f993e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-09-10 Arnold D. Robbins <arnold@skeeve.com>
+
+ * interpret.h: For Op_subscript, don't allow references into
+ FUNCTAB and SYMTAB to create new elements. Thanks to
+ Jason C. Kwan <jasonckwan@yahoo.com> for the bug report.
+
2021-09-09 Arnold D. Robbins <arnold@skeeve.com>
Move to Autoconf 2.71 (finally!)
diff --git a/interpret.h b/interpret.h
index 2ed4f01..4495d8c 100644
--- a/interpret.h
+++ b/interpret.h
@@ -67,6 +67,7 @@ r_interpret(INSTRUCTION *code)
Regexp *rp;
NODE *set_array = NULL; /* array with a post-assignment routine */
NODE *set_idx = NULL; /* the index of the array element */
+ bool subscript_in_array;
/* array subscript */
@@ -265,14 +266,27 @@ uninitialized_scalar:
t2 = mk_sub(pc->sub_count);
t1 = POP_ARRAY(false);
- if (do_lint && in_array(t1, t2) == NULL) {
+ subscript_in_array = (in_array(t1, t2) != NULL);
+
+ if (! subscript_in_array) {
t2 = force_string(t2);
- lintwarn(_("reference to uninitialized element
`%s[\"%.*s\"]'"),
- array_vname(t1), (int) t2->stlen,
t2->stptr);
- if (t2->stlen == 0)
- lintwarn(_("subscript of array `%s' is
null string"), array_vname(t1));
+
+ if (t1 == func_table) {
+ fatal(_("reference to uninitialized
element `%s[\"%.*s\"] is not allowed'"),
+ "FUNCTAB", (int) t2->stlen,
t2->stptr);
+ } else if (t1 == symbol_table) {
+ fatal(_("reference to uninitialized
element `%s[\"%.*s\"] is not allowed'"),
+ "SYMTAB", (int) t2->stlen,
t2->stptr);
+ } else if (do_lint) {
+ lintwarn(_("reference to uninitialized
element `%s[\"%.*s\"]'"),
+ array_vname(t1), (int)
t2->stlen, t2->stptr);
+ if (t2->stlen == 0)
+ lintwarn(_("subscript of array
`%s' is null string"), array_vname(t1));
+ }
}
+ // continue the regular processing
+
/* for FUNCTAB, get the name as the element value */
if (t1 == func_table) {
static bool warned = false;
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index a11dc1b..04dbbd4 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -198,7 +198,7 @@ GAWK_EXT_TESTS = \
devfd devfd1 devfd2 dfacheck1 dumpvars \
errno exit fieldwdth forcenum \
fpat1 fpat2 fpat3 fpat4 fpat5 fpat6 fpat7 fpat8 fpat9 fpatnull \
- fsfwfs funlen functab1 functab2 functab3 \
+ fsfwfs funlen functab1 functab2 functab3 functab6 \
fwtest fwtest2 fwtest3 fwtest4 fwtest5 fwtest6 fwtest7 fwtest8 \
genpot gensub gensub2 gensub3 getlndir gnuops2 gnuops3 gnureops gsubind
\
icasefs icasers id igncdym igncfs ignrcas2 ignrcas4 ignrcase incdupe \
@@ -251,7 +251,7 @@ SHLIB_TESTS = \
# List of the tests which should be run with --debug option:
-NEED_DEBUG = dbugtypedre1 dbugtypedre2 dbugeval2 dbugeval3 symtab10
+NEED_DEBUG = dbugtypedre1 dbugtypedre2 dbugeval2 dbugeval3
# List of the tests which should be run with --lint option:
NEED_LINT = \
@@ -2760,6 +2760,11 @@ functab3:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$?
>>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+functab6:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$?
>>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
fwtest:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 ||
echo EXIT CODE: $$? >>_$@
@@ -3322,7 +3327,7 @@ symtab7:
symtab10:
@echo $@
- @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --debug < "$(srcdir)"/$@.in >_$@
2>&1 || echo EXIT CODE: $$? >>_$@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$?
>>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
symtab11:
diff --git a/test/ChangeLog b/test/ChangeLog
index 007d182..f25469c 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,10 @@
+2021-09-10 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (EXTRA_DIST): functab6, new test.
+ * functab6.awk, functab6.ok: New files.
+ * symtab10.ok: Modified after code change.
+ * symtab10.in: Removed.
+
2021-09-06 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (EXTRA_DIST): typeof6, new test.
diff --git a/test/Makefile.am b/test/Makefile.am
index bd800ff..3663ac2 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -420,6 +420,8 @@ EXTRA_DIST = \
functab4.ok \
functab5.awk \
functab5.ok \
+ functab6.awk \
+ functab6.ok \
funlen.awk \
funlen.in \
funlen.ok \
@@ -1280,7 +1282,6 @@ EXTRA_DIST = \
symtab9.awk \
symtab9.ok \
symtab10.awk \
- symtab10.in \
symtab10.ok \
symtab11.awk \
symtab11.ok \
@@ -1445,7 +1446,7 @@ GAWK_EXT_TESTS = \
devfd devfd1 devfd2 dfacheck1 dumpvars \
errno exit fieldwdth forcenum \
fpat1 fpat2 fpat3 fpat4 fpat5 fpat6 fpat7 fpat8 fpat9 fpatnull \
- fsfwfs funlen functab1 functab2 functab3 \
+ fsfwfs funlen functab1 functab2 functab3 functab6 \
fwtest fwtest2 fwtest3 fwtest4 fwtest5 fwtest6 fwtest7 fwtest8 \
genpot gensub gensub2 gensub3 getlndir gnuops2 gnuops3 gnureops gsubind
\
icasefs icasers id igncdym igncfs ignrcas2 ignrcas4 ignrcase incdupe \
@@ -1501,7 +1502,7 @@ SHLIB_TESTS = \
testext time
# List of the tests which should be run with --debug option:
-NEED_DEBUG = dbugtypedre1 dbugtypedre2 dbugeval2 dbugeval3 symtab10
+NEED_DEBUG = dbugtypedre1 dbugtypedre2 dbugeval2 dbugeval3
# List of the tests which should be run with --lint option:
NEED_LINT = \
diff --git a/test/Makefile.in b/test/Makefile.in
index 3a8381c..01c9bcc 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -683,6 +683,8 @@ EXTRA_DIST = \
functab4.ok \
functab5.awk \
functab5.ok \
+ functab6.awk \
+ functab6.ok \
funlen.awk \
funlen.in \
funlen.ok \
@@ -1543,7 +1545,6 @@ EXTRA_DIST = \
symtab9.awk \
symtab9.ok \
symtab10.awk \
- symtab10.in \
symtab10.ok \
symtab11.awk \
symtab11.ok \
@@ -1708,7 +1709,7 @@ GAWK_EXT_TESTS = \
devfd devfd1 devfd2 dfacheck1 dumpvars \
errno exit fieldwdth forcenum \
fpat1 fpat2 fpat3 fpat4 fpat5 fpat6 fpat7 fpat8 fpat9 fpatnull \
- fsfwfs funlen functab1 functab2 functab3 \
+ fsfwfs funlen functab1 functab2 functab3 functab6 \
fwtest fwtest2 fwtest3 fwtest4 fwtest5 fwtest6 fwtest7 fwtest8 \
genpot gensub gensub2 gensub3 getlndir gnuops2 gnuops3 gnureops gsubind
\
icasefs icasers id igncdym igncfs ignrcas2 ignrcas4 ignrcase incdupe \
@@ -1761,7 +1762,7 @@ SHLIB_TESTS = \
# List of the tests which should be run with --debug option:
-NEED_DEBUG = dbugtypedre1 dbugtypedre2 dbugeval2 dbugeval3 symtab10
+NEED_DEBUG = dbugtypedre1 dbugtypedre2 dbugeval2 dbugeval3
# List of the tests which should be run with --lint option:
NEED_LINT = \
@@ -4438,6 +4439,11 @@ functab3:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$?
>>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+functab6:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$?
>>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
fwtest:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 ||
echo EXIT CODE: $$? >>_$@
@@ -4990,7 +4996,7 @@ symtab7:
symtab10:
@echo $@
- @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --debug < "$(srcdir)"/$@.in >_$@
2>&1 || echo EXIT CODE: $$? >>_$@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$?
>>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
symtab11:
diff --git a/test/Maketests b/test/Maketests
index a106273..5558ae7 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1497,6 +1497,11 @@ functab3:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$?
>>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+functab6:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$?
>>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
fwtest:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 ||
echo EXIT CODE: $$? >>_$@
@@ -2049,7 +2054,7 @@ symtab7:
symtab10:
@echo $@
- @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --debug < "$(srcdir)"/$@.in >_$@
2>&1 || echo EXIT CODE: $$? >>_$@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$?
>>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
symtab11:
diff --git a/test/functab6.awk b/test/functab6.awk
new file mode 100644
index 0000000..ec690d0
--- /dev/null
+++ b/test/functab6.awk
@@ -0,0 +1 @@
+BEGIN { print FUNCTAB[0] }
diff --git a/test/functab6.ok b/test/functab6.ok
new file mode 100644
index 0000000..171a656
--- /dev/null
+++ b/test/functab6.ok
@@ -0,0 +1,2 @@
+gawk: functab6.awk:1: fatal: reference to uninitialized element `FUNCTAB["0"]
is not allowed'
+EXIT CODE: 2
diff --git a/test/symtab10.in b/test/symtab10.in
deleted file mode 100644
index d9afcd6..0000000
--- a/test/symtab10.in
+++ /dev/null
@@ -1,4 +0,0 @@
-watch y
-run
-watch x
-continue
diff --git a/test/symtab10.ok b/test/symtab10.ok
index 9ab3855..8132222 100644
--- a/test/symtab10.ok
+++ b/test/symtab10.ok
@@ -1,11 +1,2 @@
-Watchpoint 1: y
-Starting program:
-Stopping in BEGIN ...
-Watchpoint 1: y
- Old value: untyped variable
- New value: 1
-main() at `symtab10.awk':1
-1 BEGIN { SYMTAB["x"] ; y=1 ; y++ }
-no symbol `x' in current context
-Program exited normally with exit value: 0
+gawk: symtab10.awk:1: fatal: reference to uninitialized element `SYMTAB["x"]
is not allowed'
EXIT CODE: 2
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 6 ++++++
interpret.h | 24 +++++++++++++++++++-----
pc/Makefile.tst | 11 ++++++++---
test/ChangeLog | 7 +++++++
test/Makefile.am | 7 ++++---
test/Makefile.in | 14 ++++++++++----
test/Maketests | 7 ++++++-
test/functab6.awk | 1 +
test/functab6.ok | 2 ++
test/symtab10.in | 4 ----
test/symtab10.ok | 11 +----------
11 files changed, 64 insertions(+), 30 deletions(-)
create mode 100644 test/functab6.awk
create mode 100644 test/functab6.ok
delete mode 100644 test/symtab10.in
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-4297-gc89ce58,
Arnold Robbins <=