aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2019-01-20 21:42:36 +0200
committerArnold D. Robbins <arnold@skeeve.com>2019-01-20 21:42:36 +0200
commit5766636f7bb7eb6d8fa9fd1b097ca74329062173 (patch)
treedc94246ac43a8caa39816d78c1433b39cbcca9ff
parent7560c312229e5967ff1b479b8ced6d3e8e99dc37 (diff)
downloadegawk-5766636f7bb7eb6d8fa9fd1b097ca74329062173.tar.gz
egawk-5766636f7bb7eb6d8fa9fd1b097ca74329062173.tar.bz2
egawk-5766636f7bb7eb6d8fa9fd1b097ca74329062173.zip
Cleanups for assoc_set.
-rwxr-xr-xChangeLog6
-rw-r--r--debug.c4
-rw-r--r--interpret.h3
3 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d7d1471e..5e3f9a2e 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-01-20 Arnold D. Robbins <arnold@skeeve.com>
+
+ * debug.c (do_set_var): Add comments before calls to assoc_set.
+ * interpret.h (r_interpret): For Op_sub_array, deref the subscript
+ appropriately. Thanks to Andy Schorr for the catch.
+
2019-01-15 Arnold D. Robbins <arnold@skeeve.com>
* array.c (asort_actual): Use assoc_set in 2 places.
diff --git a/debug.c b/debug.c
index f36a3270..05083a48 100644
--- a/debug.c
+++ b/debug.c
@@ -1270,6 +1270,8 @@ do_set_var(CMDARG *arg, int cmd ATTRIBUTE_UNUSED)
arg = arg->next;
val = arg->a_node;
newval = dupnode(val);
+ // subs should not be freed, so
+ // use dupnode in call to assoc_set.
assoc_set(r, dupnode(subs), newval);
fprintf(out_fp, "%s[\"%.*s\"] = ", name, (int) subs->stlen, subs->stptr);
valinfo(newval, fprintf, out_fp);
@@ -1280,6 +1282,8 @@ do_set_var(CMDARG *arg, int cmd ATTRIBUTE_UNUSED)
array = make_array();
array->vname = estrdup(subs->stptr, subs->stlen);
array->parent_array = r;
+ // subs should not be freed, so
+ // use dupnode in call to assoc_set.
assoc_set(r, dupnode(subs), array);
r = array;
} else if (value->type != Node_var_array) {
diff --git a/interpret.h b/interpret.h
index 53abadcb..e9896672 100644
--- a/interpret.h
+++ b/interpret.h
@@ -310,7 +310,8 @@ uninitialized_scalar:
t2 = force_string(t2);
fatal(_("attempt to use scalar `%s[\"%.*s\"]' as an array"),
array_vname(t1), (int) t2->stlen, t2->stptr);
- }
+ } else
+ DEREF(t2);
PUSH(r);
break;