aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2011-01-30 21:55:59 +0200
committerArnold D. Robbins <arnold@skeeve.com>2011-01-30 21:55:59 +0200
commit318b7ac345d0e78502ac0674a8ebb467997174f3 (patch)
treed21662d1435c3c768cf2d2a2cc9ee7114912d9de /builtin.c
parenta7dd34e347fecd3a09be19c9c2b9fe99e1bbbcd7 (diff)
downloadegawk-318b7ac345d0e78502ac0674a8ebb467997174f3.tar.gz
egawk-318b7ac345d0e78502ac0674a8ebb467997174f3.tar.bz2
egawk-318b7ac345d0e78502ac0674a8ebb467997174f3.zip
Add isarray built-in function.
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 7156601e..dc811022 100644
--- a/builtin.c
+++ b/builtin.c
@@ -458,6 +458,21 @@ do_int(int nargs)
return make_number((AWKNUM) d);
}
+/* do_isarray --- check if argument is array */
+
+NODE *
+do_isarray(int nargs)
+{
+ NODE *tmp;
+ int ret = 1;
+
+ tmp = POP();
+ if (tmp->type != Node_var_array) {
+ ret = 0;
+ DEREF(tmp);
+ }
+ return make_number((AWKNUM) ret);
+}
/* do_length --- length of a string, array or $0 */
@@ -468,10 +483,11 @@ do_length(int nargs)
size_t len;
tmp = POP();
-
if (tmp->type == Node_var_array) {
static short warned = FALSE;
+ if (do_posix)
+ fatal(_("length: received array argument"));
if (do_lint && ! warned) {
warned = TRUE;
lintwarn(_("`length(array)' is a gawk extension"));