return $z;
}
+# In addition to get_nested(), skip single-quoted and double-quoted string literals
+sub get_function_args($$$) {
+ my ($r, $left, $right) = @_;
+ pos $$r = pos($$r) - 1;
+ my $z = "";
+ my $nest = 0;
+ do {
+ if ($$r =~ /\G([^$left$right"']+)/cgs
+ || $$r =~/\G("(\\.|[^"\\])*")/cgs # double-quoted string
+ || $$r =~/\G('(\\.|[^'\\])*')/cgs # single-quoted string
+ ) {
+ } elsif ($$r =~ /\G([$left])/cgs) {
+ $nest++;
+ } elsif ($$r =~ /\G([$right])/cgs) {
+ $nest--;
+ } else {
+ error "File ended when looking for matching $right";
+ }
+ $z .= $1;
+ } while ($nest);
+ return $z;
+}
+
sub eval_if_ok($) {
if ($cond[0] > 0) {
my $x = shift;
out (defined($arguments->{$x}) ? $arguments->{$x} : "");
} elsif ($t =~ /\G\@(\w+)\(/cgs) {
my $func = $1;
- my $args = get_nested(\$t, '(', ')');
+ my $args = get_function_args(\$t, '(', ')');
eval_func($func, $args);
} elsif ($t =~ /\G\@(\w+)([^\n]*)\n/cgs) {
eval_func($1, "($2)");