summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-01-27 18:07:45 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-01-27 20:14:21 -0800
commitc4cf781e24ac2941611eb63f1ee7c1d146cf4c06 (patch)
tree1d5cbc88f3bfbe7615baa1c67a3254ad1e5dd63c /lib
parente744ae1811ea6e874fc30e4b775d8dcd0637d9f7 (diff)
downloadperl-c4cf781e24ac2941611eb63f1ee7c1d146cf4c06.tar.gz
[perl #121050] Teach B::Deparse about prototype whitespace
It has been hanging or unnecessarily using & since commit d16269d835 caused spaces to be preserved in the prototype and stripped when applied during sub call compilation. That commit did not update B::Deparse accordingly.
Diffstat (limited to 'lib')
-rw-r--r--lib/B/Deparse.pm5
-rw-r--r--lib/B/Deparse.t9
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm
index 31ad998b10..f620db48c1 100644
--- a/lib/B/Deparse.pm
+++ b/lib/B/Deparse.pm
@@ -3698,8 +3698,9 @@ sub check_proto {
my @reals;
# An unbackslashed @ or % gobbles up the rest of the args
1 while $proto =~ s/(?<!\\)([@%])[^\]]+$/$1/;
+ $proto =~ s/^\s*//;
while ($proto) {
- $proto =~ s/^(\\?[\$\@&%*_]|\\\[[\$\@&%*]+\]|;)//;
+ $proto =~ s/^(\\?[\$\@&%*_]|\\\[[\$\@&%*]+\]|;)\s*//;
my $chr = $1;
if ($chr eq "") {
return "&" if @args;
@@ -3856,7 +3857,7 @@ sub pp_entersub {
my $dproto = defined($proto) ? $proto : "undefined";
if (!$declared) {
return "$kid(" . $args . ")";
- } elsif ($dproto eq "") {
+ } elsif ($dproto =~ /^\s*\z/) {
return $kid;
} elsif ($dproto eq "\$" and is_scalar($exprs[0])) {
# is_scalar is an excessively conservative test here:
diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t
index b0ecf395b3..c7af6a0bf6 100644
--- a/lib/B/Deparse.t
+++ b/lib/B/Deparse.t
@@ -1428,3 +1428,12 @@ print f();
####
# Elements of %# should not be confused with $#{ array }
() = ${#}{'foo'};
+####
+# [perl #121050] Prototypes with whitespace
+sub _121050(\$ \$) { }
+_121050($a,$b);
+sub _121050empty( ) {}
+() = _121050empty() + 1;
+>>>>
+_121050 $a, $b;
+() = _121050empty + 1;