diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-11-15 21:03:57 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-11-15 21:03:57 +0200 |
commit | b37675aa79213f2665abb2bbb4db90560642bdee (patch) | |
tree | 74a00854546a7a174b0722277def07fbfbc0e4cd /builtin.c | |
parent | 84a7c376d6322a6e2429af79358091d10d94c004 (diff) | |
download | egawk-b37675aa79213f2665abb2bbb4db90560642bdee.tar.gz egawk-b37675aa79213f2665abb2bbb4db90560642bdee.tar.bz2 egawk-b37675aa79213f2665abb2bbb4db90560642bdee.zip |
First steps reworking code away from node type.
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 26 |
1 files changed, 12 insertions, 14 deletions
@@ -536,7 +536,7 @@ do_length(int nargs) return make_number(size); } - assert(tmp->type == Node_val || tmp->type == Node_typedregex); + assert(tmp->type == Node_val); if (do_lint && (fixtype(tmp)->flags & STRING) == 0) lintwarn(_("length: received non-string argument")); @@ -2195,11 +2195,9 @@ do_print(int nargs, int redirtype) fatal(_("attempt to use array `%s' in a scalar context"), array_vname(tmp)); } - if (tmp->type == Node_typedregex) - args_array[i] = force_string(tmp); - else if ( (tmp->flags & STRCUR) == 0 - || ( tmp->stfmt != STFMT_UNUSED - && tmp->stfmt != OFMTidx)) + if ( (tmp->flags & STRCUR) == 0 + || ( tmp->stfmt != STFMT_UNUSED + && tmp->stfmt != OFMTidx)) args_array[i] = format_val(OFMT, OFMTidx, tmp); } @@ -3203,7 +3201,7 @@ call_sub(const char *name, int nargs) * push replace * push $0 */ - if (regex->type != Node_typedregex) + if ((regex->flags & REGEX) == 0) regex = make_regnode(Node_regex, regex); PUSH(regex); PUSH(replace); @@ -3228,7 +3226,7 @@ call_sub(const char *name, int nargs) * nargs++ * } */ - if (regex->type != Node_typedregex) + if ((regex->flags & REGEX) == 0) regex = make_regnode(Node_regex, regex); PUSH(regex); PUSH(replace); @@ -3266,7 +3264,7 @@ call_match(int nargs) /* Don't need to pop the string just to push it back ... */ - if (regex->type != Node_typedregex) + if ((regex->flags & REGEX) == 0) regex = make_regnode(Node_regex, regex); PUSH(regex); @@ -3295,7 +3293,7 @@ call_split_func(const char *name, int nargs) if (nargs >= 3) { regex = POP_STRING(); - if (regex->type != Node_typedregex) + if ((regex->flags & REGEX) == 0) regex = make_regnode(Node_regex, regex); } else { if (name[0] == 's') { @@ -3955,12 +3953,9 @@ do_typeof(int nargs) res = "array"; deref = false; break; - case Node_typedregex: - res = "regexp"; - break; case Node_val: case Node_var: - switch (arg->flags & (STRING|NUMBER|MAYBE_NUM)) { + switch (arg->flags & (STRING|NUMBER|MAYBE_NUM|REGEX)) { case STRING: res = "string"; break; @@ -3970,6 +3965,9 @@ do_typeof(int nargs) case STRING|MAYBE_NUM: res = "strnum"; break; + case REGEX: + res = "regexp"; + break; case NUMBER|STRING: if (arg == Nnull_string) { res = "unassigned"; |