summaryrefslogtreecommitdiff
path: root/builtin.c
diff options
context:
space:
mode:
authorjohn haque <j.eh@mchsi.com>2012-04-19 05:27:31 -0500
committerjohn haque <j.eh@mchsi.com>2012-04-19 05:27:31 -0500
commit87dc23679566c5ad96f4869de6aec39c2a4c3aa7 (patch)
treea4202078cb9b63fb69828cb9a7a54d969f53bd19 /builtin.c
parentc3033f11415c6323ad6b4503c220d20d68c841a3 (diff)
downloadgawk-87dc23679566c5ad96f4869de6aec39c2a4c3aa7.tar.gz
Improve array interface.
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/builtin.c b/builtin.c
index 9134e024..6ca6509d 100644
--- a/builtin.c
+++ b/builtin.c
@@ -492,6 +492,7 @@ do_length(int nargs)
tmp = POP();
if (tmp->type == Node_var_array) {
static short warned = FALSE;
+ unsigned long size;
if (do_posix)
fatal(_("length: received array argument"));
@@ -499,7 +500,15 @@ do_length(int nargs)
warned = TRUE;
lintwarn(_("`length(array)' is a gawk extension"));
}
- return make_number((AWKNUM) tmp->table_size);
+
+ /*
+ * Support for deferred loading of array elements requires that
+ * we use the array length interface even though it isn't
+ * necessary for the built-in array types.
+ */
+
+ size = assoc_length(tmp);
+ return make_number(size);
}
assert(tmp->type == Node_val);
@@ -2450,6 +2459,9 @@ do_match(int nargs)
lhs = assoc_lookup(dest, sub);
unref(*lhs);
*lhs = it;
+ /* execute post-assignment routine if any */
+ if (dest->astore != NULL)
+ (*dest->astore)(dest, sub);
unref(sub);
sprintf(buff, "%d", ii);
@@ -2473,6 +2485,8 @@ do_match(int nargs)
lhs = assoc_lookup(dest, sub);
unref(*lhs);
*lhs = it;
+ if (dest->astore != NULL)
+ (*dest->astore)(dest, sub);
unref(sub);
memcpy(buf, buff, ilen);
@@ -2486,6 +2500,8 @@ do_match(int nargs)
lhs = assoc_lookup(dest, sub);
unref(*lhs);
*lhs = it;
+ if (dest->astore != NULL)
+ (*dest->astore)(dest, sub);
unref(sub);
}
}