aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/builtin.c b/builtin.c
index 4dd08eb1..7926a320 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3000,7 +3000,7 @@ NODE *
call_sub_func(const char *name, int nargs)
{
unsigned int flags = 0;
- NODE *tmp;
+ NODE *regex, *replace;
if (name[0] == 'g') {
if (name[1] == 'e')
@@ -3009,10 +3009,15 @@ call_sub_func(const char *name, int nargs)
flags = GSUB;
}
- tmp = PEEK(1);
- if (tmp->type == Node_val) {
- flags |= LITERAL;
- }
+ if ((flags == 0 || flags == GSUB) && nargs != 2)
+ fatal(_("%s: can be called indirectly only with two arguments"), name);
+
+ replace = POP();
+
+ regex = POP(); /* the regex */
+ regex = make_regnode(Node_regex, regex);
+ PUSH(regex);
+ PUSH(replace);
return do_sub(nargs, flags);
}