aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-11-22 20:30:09 +0200
committerArnold D. Robbins <arnold@skeeve.com>2016-11-22 20:30:09 +0200
commit52715ba9f8510f30368462fee1b1d24bf282b0aa (patch)
tree2b7569bb73d64433f84ccf2672c3973809804b51 /builtin.c
parentf7ae9cfb843379b95d8cb44dbb8de7bbf11862de (diff)
parent033faa34a743231a88a6c555503397045726666f (diff)
downloadegawk-52715ba9f8510f30368462fee1b1d24bf282b0aa.tar.gz
egawk-52715ba9f8510f30368462fee1b1d24bf282b0aa.tar.bz2
egawk-52715ba9f8510f30368462fee1b1d24bf282b0aa.zip
Merge branch 'master' into feature/cmake
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/builtin.c b/builtin.c
index 9a45e10f..5d7c3764 100644
--- a/builtin.c
+++ b/builtin.c
@@ -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";