aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
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));
}