aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-06-22 22:56:06 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-06-22 22:56:06 +0300
commita3e0954544c7cc4f34b710ac863d56419b57915a (patch)
tree534d4c02a8d71fc19073543f0558ad2f29701afc
parentd43f951d4e8be461fd8be7182a4ff1b219fa8edd (diff)
downloadegawk-a3e0954544c7cc4f34b710ac863d56419b57915a.tar.gz
egawk-a3e0954544c7cc4f34b710ac863d56419b57915a.tar.bz2
egawk-a3e0954544c7cc4f34b710ac863d56419b57915a.zip
Fix typeof to work correctly on subarrays.
-rw-r--r--ChangeLog5
-rw-r--r--builtin.c5
2 files changed, 9 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 84792446..9e412428 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,11 @@
(initialize_watch_item): Ditto.
(print_memory): Ditto.
+ Fix typeof to work on subarrays. Thanks, yet again, to
+ Hermann Peifer for the bug report.
+
+ * builtin.c (do_typeof): Don't deref Node_var_array.
+
2015-06-21 Arnold D. Robbins <arnold@skeeve.com>
Fixes for typeof - Don't let typeof change an untyped variable
diff --git a/builtin.c b/builtin.c
index 942a36dd..e476ec99 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3872,11 +3872,13 @@ do_typeof(int nargs)
{
NODE *arg;
char *res = "unknown";
+ bool deref = true;
arg = POP();
switch (arg->type) {
case Node_var_array:
res = "array";
+ deref = false;
break;
case Node_typedregex:
res = "regexp";
@@ -3899,7 +3901,8 @@ do_typeof(int nargs)
break;
}
- DEREF(arg);
+ if (deref)
+ DEREF(arg);
return make_string(res, strlen(res));
}