aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2020-01-08 20:53:54 +0200
committerArnold D. Robbins <arnold@skeeve.com>2020-01-08 20:53:54 +0200
commitebe9dd1633c6f5e5d42e922a70f72829c14c193c (patch)
treefeb83b935704aaecb189657213b6e98b8f6ee709
parent660a55b365e4ee22f3f0efe69c887e2fd1f71303 (diff)
downloadegawk-ebe9dd1633c6f5e5d42e922a70f72829c14c193c.tar.gz
egawk-ebe9dd1633c6f5e5d42e922a70f72829c14c193c.tar.bz2
egawk-ebe9dd1633c6f5e5d42e922a70f72829c14c193c.zip
Fix a bug in retrieving unset variables through SYMTAB.
-rw-r--r--ChangeLog6
-rw-r--r--interpret.h5
-rw-r--r--test/ChangeLog13
-rw-r--r--test/Makefile.am8
-rw-r--r--test/Makefile.in18
-rw-r--r--test/Maketests10
-rw-r--r--test/stupid1.awk13
-rw-r--r--test/stupid1.ok2
-rw-r--r--test/stupid2.awk5
-rw-r--r--test/stupid2.ok0
10 files changed, 73 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 32aa228d..496c341d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,12 @@
* interpret.h (Op_assign_concat): Handle newly created node
better.
+ Unrelated:
+
+ * interpret.h (Op_subscript): When retrieving from SYMTAB, check
+ for Node_var_new; variables can exist but have not been assigned
+ a value.
+
2019-12-22 Arnold D. Robbins <arnold@skeeve.com>
* config.guess: Updated from GNULIB.
diff --git a/interpret.h b/interpret.h
index 4a7979bd..d157b5b2 100644
--- a/interpret.h
+++ b/interpret.h
@@ -288,6 +288,11 @@ uninitialized_scalar:
}
if (r->type == Node_var)
r = r->var_value;
+ else if (r->type == Node_var_new) {
+ // variable may exist but have never been set.
+ r->var_value = dupnode(Nnull_string);
+ r = r->var_value;
+ }
}
if (r->type == Node_val)
diff --git a/test/ChangeLog b/test/ChangeLog
index f0eac9bd..05e60edc 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -2,6 +2,9 @@
* indirectbuiltin.awk, numrange.awk, numrange.ok: Changes
after code changes.
+ * Makefile.am (EXTRA_DIST): New tests, stupid1 and stupid2.
+ * stupid1.awk, stupid1.ok: New files.
+ * stupid2.awk, stupid2.ok: New files.
2019-11-09 Alexey Pawlow <alexey.pawlow@gmail.com>
@@ -10,30 +13,30 @@
2019-11-03 Arnold D. Robbins <arnold@skeeve.com>
- * Makefile.am (EXTRA_DISTS): New test, fpat7.
+ * Makefile.am (EXTRA_DIST): New test, fpat7.
* fpat7.awk, fpat7.ok, fpat7.in: New files.
2019-10-13 Arnold D. Robbins <arnold@skeeve.com>
- * Makefile.am (EXTRA_DISTS): New tests, typedregex5 and
+ * Makefile.am (EXTRA_DIST): New tests, typedregex5 and
typedregex6.
* typedregex5.awk, typedregex5.ok, typedregex6.in,
typedregex5.in, typedregex6.awk, typedregex6.ok: New files.
2019-09-24 Jürgen Kahrs Google <juergen.kahrs@googlemail.com>
- * Makefile.am (EXTRA_DISTS): New test, mpfranswer42.
+ * Makefile.am (EXTRA_DIST): New test, mpfranswer42.
* mpfranswer42.awk, mpfranswer42.ok: New files.
2019-07-23 Arnold D. Robbins <arnold@skeeve.com>
- * Makefile.am (EXTRA_DISTS): Fix typos in filenames.
+ * Makefile.am (EXTRA_DIST): Fix typos in filenames.
2019-06-28 Michal Jaegermann <michal.jnn@gmail.com>
Add backwards compatibility tests for inplace.
- * Makefile.am (EXTRA_DISTS): New tests, inplace2bcomp, inplace2bcomp.
+ * Makefile.am (EXTRA_DIST): New tests, inplace2bcomp, inplace2bcomp.
* inplace2bcomp.1.ok, test/inplace2bcomp.1.orig.ok,
test/inplace2bcomp.2.ok, test/inplace2bcomp.2.orig.ok,
test/inplace2bcomp.ok, test/inplace3bcomp.1.ok,
diff --git a/test/Makefile.am b/test/Makefile.am
index c6e33ddb..14e5b0a5 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1172,6 +1172,10 @@ EXTRA_DIST = \
strtonum.ok \
strtonum1.awk \
strtonum1.ok \
+ stupid1.awk \
+ stupid1.ok \
+ stupid2.awk \
+ stupid2.ok \
subamp.awk \
subamp.in \
subamp.ok \
@@ -1390,7 +1394,9 @@ GAWK_EXT_TESTS = \
rsstart1 rsstart2 rsstart3 rstest6 \
sandbox1 shadow shadowbuiltin sortfor sortfor2 sortu \
sourcesplit split_after_fpat \
- splitarg4 strftfld strftime strtonum strtonum1 switch2 symtab1 symtab2 \
+ splitarg4 strftfld strftime strtonum strtonum1 \
+ stupid1 stupid2 \
+ switch2 symtab1 symtab2 \
symtab3 symtab4 symtab5 symtab6 symtab7 symtab8 symtab9 symtab10 \
timeout typedregex1 typedregex2 typedregex3 typedregex4 \
typedregex5 typedregex6 \
diff --git a/test/Makefile.in b/test/Makefile.in
index 52b487b6..0fae9058 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1431,6 +1431,10 @@ EXTRA_DIST = \
strtonum.ok \
strtonum1.awk \
strtonum1.ok \
+ stupid1.awk \
+ stupid1.ok \
+ stupid2.awk \
+ stupid2.ok \
subamp.awk \
subamp.in \
subamp.ok \
@@ -1649,7 +1653,9 @@ GAWK_EXT_TESTS = \
rsstart1 rsstart2 rsstart3 rstest6 \
sandbox1 shadow shadowbuiltin sortfor sortfor2 sortu \
sourcesplit split_after_fpat \
- splitarg4 strftfld strftime strtonum strtonum1 switch2 symtab1 symtab2 \
+ splitarg4 strftfld strftime strtonum strtonum1 \
+ stupid1 stupid2 \
+ switch2 symtab1 symtab2 \
symtab3 symtab4 symtab5 symtab6 symtab7 symtab8 symtab9 symtab10 \
timeout typedregex1 typedregex2 typedregex3 typedregex4 \
typedregex5 typedregex6 \
@@ -4748,6 +4754,16 @@ strtonum1:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+stupid1:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
+stupid2:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
switch2:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 627d6ecf..6c8ebf08 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1911,6 +1911,16 @@ strtonum1:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+stupid1:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
+stupid2:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
switch2:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/stupid1.awk b/test/stupid1.awk
new file mode 100644
index 00000000..9881ac6a
--- /dev/null
+++ b/test/stupid1.awk
@@ -0,0 +1,13 @@
+BEGIN {
+ abc("varname")
+ varname
+}
+
+func abc(n)
+{
+ if (n in SYMTAB) {
+ print "before"
+ is = SYMTAB[n]
+ print "after"
+ }
+}
diff --git a/test/stupid1.ok b/test/stupid1.ok
new file mode 100644
index 00000000..eecca907
--- /dev/null
+++ b/test/stupid1.ok
@@ -0,0 +1,2 @@
+before
+after
diff --git a/test/stupid2.awk b/test/stupid2.awk
new file mode 100644
index 00000000..3f6d0d85
--- /dev/null
+++ b/test/stupid2.awk
@@ -0,0 +1,5 @@
+BEGIN {
+ n = "varname"
+ SYMTAB[n]
+ varname
+}
diff --git a/test/stupid2.ok b/test/stupid2.ok
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/stupid2.ok