X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FSub%2FPrototype%2FUtil.pm;h=d549a1cc992e8ea86ceac04a35f89d11a7207098;hb=06a00e8349c4f0c7b7388af0dbfcd562721e8d43;hp=c5c6ffd94294b2dbb04041e136a765604f107736;hpb=8475b0d17d26abf108ef898393e2b7e3adc61cca;p=perl%2Fmodules%2FSub-Prototype-Util.git diff --git a/lib/Sub/Prototype/Util.pm b/lib/Sub/Prototype/Util.pm index c5c6ffd..d549a1c 100644 --- a/lib/Sub/Prototype/Util.pm +++ b/lib/Sub/Prototype/Util.pm @@ -87,8 +87,8 @@ sub flatten { } elsif ($p =~ /[\@\%]/) { push @args, @_; last; - } elsif ($p eq '_' && @_ == 0) { - push @args, $_; + } elsif ($p eq '_') { + shift; # without prototype, this argument wouldn't have been passed } else { push @args, shift; } @@ -139,9 +139,8 @@ For example, this allows you to recall into C and C by us sub _wrap { my ($name, $proto, $i, $args, $cr, $opts) = @_; - if ($proto =~ /(\\?)(\[[^\]]+\]|[^\];])(.*)/g) { + while ($proto =~ s/(\\?)(\[[^\]]+\]|[^\];])//) { my ($ref, $p) = ($1, $2); - $proto = $3; $p = $1 if $p =~ /^\[([^\]]+)\]/; my $cur = '$_[' . $i . ']'; if ($ref) { @@ -176,11 +175,10 @@ sub _wrap { } else { $args .= $cur . ', '; } - return _wrap($name, $proto, ($i + 1), $args, $cr, $opts); - } else { - $args =~ s/,\s*$//; - return $name . '(' . $args . ')'; + ++$i; } + $args =~ s/,\s*$//; + return $name . '(' . $args . ')'; } sub _check_name {