diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-06-25 23:12:55 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-06-25 23:12:55 +0300 |
commit | 056cd074c60d940d5bb46410f114a6c2584daaae (patch) | |
tree | e2b095b3740b35cc95a8b25fd10ee5d81288565e /builtin.c | |
parent | 5b246a31d63a31180136934adbed361651f325ba (diff) | |
parent | 3712ad29b6cddcf49bf1507f5677a49ccfcff83d (diff) | |
download | egawk-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.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -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)); } |