diff options
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 26 |
1 files changed, 21 insertions, 5 deletions
@@ -3202,7 +3202,10 @@ call_sub(const char *name, int nargs) * push replace * push $0 */ - regex = make_regnode(Node_regex, regex); + if ((regex->flags & REGEX) != 0) + regex = regex->typed_re; + else + regex = make_regnode(Node_regex, regex); PUSH(regex); PUSH(replace); lhs = r_get_field(zero, (Func_ptr *) 0, true); @@ -3226,7 +3229,10 @@ call_sub(const char *name, int nargs) * nargs++ * } */ - regex = make_regnode(Node_regex, regex); + if ((regex->flags & REGEX) != 0) + regex = regex->typed_re; + else + regex = make_regnode(Node_regex, regex); PUSH(regex); PUSH(replace); PUSH(glob_flag); @@ -3263,7 +3269,11 @@ call_match(int nargs) /* Don't need to pop the string just to push it back ... */ - regex = make_regnode(Node_regex, regex); + if ((regex->flags & REGEX) != 0) + regex = regex->typed_re; + else + regex = make_regnode(Node_regex, regex); + PUSH(regex); if (array) @@ -3291,7 +3301,10 @@ call_split_func(const char *name, int nargs) if (nargs >= 3) { regex = POP_STRING(); - regex = make_regnode(Node_regex, regex); + if ((regex->flags & REGEX) != 0) + regex = regex->typed_re; + else + regex = make_regnode(Node_regex, regex); } else { if (name[0] == 's') { regex = make_regnode(Node_regex, FS_node->var_value); @@ -3976,7 +3989,7 @@ do_typeof(int nargs) break; case Node_val: case Node_var: - switch (fixtype(arg)->flags & (STRING|NUMBER|USER_INPUT)) { + switch (fixtype(arg)->flags & (STRING|NUMBER|USER_INPUT|REGEX)) { case STRING: res = "string"; break; @@ -3986,6 +3999,9 @@ do_typeof(int nargs) case NUMBER|USER_INPUT: res = "strnum"; break; + case REGEX: + res = "regexp"; + break; case NUMBER|STRING: if (arg == Nnull_string) { res = "unassigned"; |