aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-06-25 23:12:55 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-06-25 23:12:55 +0300
commit056cd074c60d940d5bb46410f114a6c2584daaae (patch)
treee2b095b3740b35cc95a8b25fd10ee5d81288565e /builtin.c
parent5b246a31d63a31180136934adbed361651f325ba (diff)
parent3712ad29b6cddcf49bf1507f5677a49ccfcff83d (diff)
downloadegawk-056cd074c60d940d5bb46410f114a6c2584daaae.tar.gz
egawk-056cd074c60d940d5bb46410f114a6c2584daaae.tar.bz2
egawk-056cd074c60d940d5bb46410f114a6c2584daaae.zip
Merge branch 'master' into feature/cmake
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/builtin.c b/builtin.c
index 61a4398b..1dd7dcbe 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2144,7 +2144,9 @@ do_print(int nargs, int redirtype)
fatal(_("attempt to use array `%s' in a scalar context"), array_vname(tmp));
}
- if ((tmp->flags & (NUMBER|STRING)) == NUMBER) {
+ if (tmp->type == Node_typedregex)
+ args_array[i] = force_string(tmp);
+ else if ((tmp->flags & (NUMBER|STRING)) == NUMBER) {
if (OFMTidx == CONVFMTidx)
args_array[i] = force_string(tmp);
else
@@ -3872,19 +3874,23 @@ do_typeof(int nargs)
{
NODE *arg;
char *res = "unknown";
- int null_str_flags = (STRCUR|STRING|NUMCUR|NUMBER);
+ bool deref = true;
arg = POP();
switch (arg->type) {
case Node_var_array:
+ /* Node_var_array is never UPREF'ed */
res = "array";
+ deref = false;
break;
case Node_typedregex:
+ /* Op_push_re does not UPREF */
res = "regexp";
+ deref = false;
break;
case Node_val:
case Node_var:
- if ((arg->flags & null_str_flags) == null_str_flags)
+ if (arg == Nnull_string)
res = "untyped";
else if ((arg->flags & STRING) != 0)
res = "scalar_s";
@@ -3893,6 +3899,7 @@ do_typeof(int nargs)
break;
case Node_var_new:
res = "untyped";
+ deref = false;
break;
default:
fatal(_("typeof: unknown argument type `%s'"),
@@ -3900,7 +3907,8 @@ do_typeof(int nargs)
break;
}
- DEREF(arg);
+ if (deref)
+ DEREF(arg);
return make_string(res, strlen(res));
}