aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-03-24 22:15:31 +0200
committerArnold D. Robbins <arnold@skeeve.com>2015-03-24 22:15:31 +0200
commit080694ae82635e76992158591b39a06af7363da0 (patch)
tree454a9361afa2904702baac9b3777fe76e721d7ca /builtin.c
parent75459887958f5246bc5126261ec92c8f4d366a47 (diff)
downloadegawk-080694ae82635e76992158591b39a06af7363da0.tar.gz
egawk-080694ae82635e76992158591b39a06af7363da0.tar.bz2
egawk-080694ae82635e76992158591b39a06af7363da0.zip
Further progress on indirect calls of builtins.
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);
}