aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-03-18 22:01:19 +0200
committerArnold D. Robbins <arnold@skeeve.com>2015-03-18 22:01:19 +0200
commitb062ba39d52c7e9dee06ac73030aba248ee81168 (patch)
tree643eef948b5b3ef7a07154c8fb5567ee535e1702 /builtin.c
parente29498dcb6a94edadf3d3ad3f631331c7ee40a33 (diff)
downloadegawk-b062ba39d52c7e9dee06ac73030aba248ee81168.tar.gz
egawk-b062ba39d52c7e9dee06ac73030aba248ee81168.tar.bz2
egawk-b062ba39d52c7e9dee06ac73030aba248ee81168.zip
Make @/.../ a terminal. Improve typeof() builtin function.
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/builtin.c b/builtin.c
index f6fed878..4a99ed6f 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3685,6 +3685,7 @@ do_typeof(int nargs)
{
NODE *arg;
char *res = "unknown";
+ int null_str_flags = (STRCUR|STRING|NUMCUR|NUMBER);
arg = POP();
switch (arg->type) {
@@ -3696,7 +3697,9 @@ do_typeof(int nargs)
break;
case Node_val:
case Node_var:
- if ((arg->flags & STRING) != 0)
+ if ((arg->flags & null_str_flags) == null_str_flags)
+ res = "untyped";
+ else if ((arg->flags & STRING) != 0)
res = "scalar_s";
else if ((arg->flags & NUMBER) != 0)
res = "scalar_n";