[perl #121050] Teach B::Deparse about prototype whitespace
authorFather Chrysostomos <sprout@cpan.org>
Tue, 28 Jan 2014 02:07:45 +0000 (18:07 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 28 Jan 2014 04:14:21 +0000 (20:14 -0800)
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.

lib/B/Deparse.pm
lib/B/Deparse.t

index 31ad998..f620db4 100644 (file)
@@ -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:
index b0ecf39..c7af6a0 100644 (file)
@@ -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;