In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/a5b826d8165a41732eb7d5f4748c454add7de669?hp=b46e009d94293e069270690750f6c669c6d0ce22>

- Log -----------------------------------------------------------------
commit a5b826d8165a41732eb7d5f4748c454add7de669
Author: Father Chrysostomos <spr...@cpan.org>
Date:   Fri Oct 3 14:40:57 2014 -0700

    Add linked mods to known_pod_issues

M       t/porting/known_pod_issues.dat

commit 013f94d66103ed7ac288cd188558a9a2f755e029
Author: Father Chrysostomos <spr...@cpan.org>
Date:   Fri Oct 3 14:40:00 2014 -0700

    perl5220delta: Mention mods from #122814

M       Porting/perl5220delta.pod

commit 22584011b351111e36812ae3e5ecbe3862fe896a
Author: Father Chrysostomos <spr...@cpan.org>
Date:   Fri Oct 3 14:19:59 2014 -0700

    Deparse inverted for(;;) condition correctly
    
    This is wrong:
    
    $ perl -MO=Deparse -e 'for($a;!$b;$c){}'
    for ($a; $b; $c) {
        ();
    }
    
    -e syntax OK
    
    What happened to the bang?
    
    This was broken in 5.12 by edbe35ea95.

M       lib/B/Deparse.pm
M       lib/B/Deparse.t
-----------------------------------------------------------------------

Summary of changes:
 Porting/perl5220delta.pod      | 16 ++++++++++++++++
 lib/B/Deparse.pm               | 25 ++++++++++++++++++++-----
 lib/B/Deparse.t                |  9 +++++++++
 t/porting/known_pod_issues.dat |  4 ++++
 4 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/Porting/perl5220delta.pod b/Porting/perl5220delta.pod
index 22e70f6..93e386c 100644
--- a/Porting/perl5220delta.pod
+++ b/Porting/perl5220delta.pod
@@ -365,6 +365,10 @@ soon:
 
 =item *
 
+L<Dancer> version 1.3130
+
+=item *
+
 L<Data::Alias> version 1.18
 
 =item *
@@ -373,12 +377,24 @@ L<Data::Util> version 0.63
 
 =item *
 
+L<Function::Parameters> version 1.0402
+
+=item *
+
 L<Future> version 0.29
 
 =item *
 
 L<Hook::LexWrap> version 0.24
 
+=item *
+
+L<Padre> version 1.00
+
+=item *
+
+L<Parse::Keyword> 0.08
+
 =back
 
 =back
diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm
index 31f1be8..68b4667 100644
--- a/lib/B/Deparse.pm
+++ b/lib/B/Deparse.pm
@@ -3160,6 +3160,7 @@ sub loop_common {
     my $bare = 0;
     my $body;
     my $cond = undef;
+    my $name;
     if ($kid->name eq "lineseq") { # bare or infinite loop
        if ($kid->last->name eq "unstack") { # infinite
            $head = "while (1) "; # Can't use for(;;) if there's a continue
@@ -3203,9 +3204,8 @@ sub loop_common {
        $head = "foreach $var ($ary) ";
     } elsif ($kid->name eq "null") { # while/until
        $kid = $kid->first;
-       my $name = {"and" => "while", "or" => "until"}->{$kid->name};
-       $cond = $self->deparse($kid->first, 1);
-       $head = "$name ($cond) ";
+       $name = {"and" => "while", "or" => "until"}->{$kid->name};
+       $cond = $kid->first;
        $body = $kid->first->sibling;
     } elsif ($kid->name eq "stub") { # bare and empty
        return "{;}"; # {} could be a hashref
@@ -3217,6 +3217,8 @@ sub loop_common {
     # block (or the last in a bare loop).
     my $cont_start = $enter->nextop;
     my $cont;
+    my $precond;
+    my $postcond;
     if ($$cont_start != $$op && ${$cont_start} != ${$body->last}) {
        if ($bare) {
            $cont = $body->last;
@@ -3234,7 +3236,8 @@ sub loop_common {
        }
        $body = $self->lineseq(undef, 0, @states);
        if (defined $cond and not is_scope $cont and $self->{'expand'} < 3) {
-           $head = "for ($init; $cond; " . $self->deparse($cont, 1) .") ";
+           $precond = "for ($init; ";
+           $postcond = "; " . $self->deparse($cont, 1) .") ";
            $cont = "\cK";
        } else {
            $cont = $cuddle . "continue {\n\t" .
@@ -3243,11 +3246,23 @@ sub loop_common {
     } else {
        return "" if !defined $body;
        if (length $init) {
-           $head = "for ($init; $cond;) ";
+           $precond = "for ($init; ";
+           $postcond = ";) ";
        }
        $cont = "\cK";
        $body = $self->deparse($body, 0);
     }
+    if ($precond) { # for(;;)
+       $cond &&= $self->deparse($cond, $name eq 'until' ? 3 : 1);
+       if ($name eq 'until') {
+           substr $cond, 0, 0, = $cond =~ /^\(/ ? "not" : "not ";
+       }
+       $head = "$precond$cond$postcond";
+    }
+    if ($name && !$head) {
+       ref $cond and $cond = $self->deparse($cond, 1);
+       $head = "$name ($cond) ";
+    }
     $body =~ s/;?$/;\n/;
 
     return $head . "{\n\t" . $body . "\b}" . $cont;
diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t
index d79572a..02ed877 100644
--- a/lib/B/Deparse.t
+++ b/lib/B/Deparse.t
@@ -405,6 +405,15 @@ for (my $i = 0; $i < 2; ++$i) {
     my $z = 1;
 }
 ####
+# 3-argument for with inverted condition
+for (my $i; not $i;) {
+    die;
+}
+for (my $i; not $i; ++$i) {
+    die;
+}
+Something_to_put_the_loop_in_void_context();
+####
 # while/continue
 my $i;
 while ($i) { my $z = 1; } continue { $i = 99; }
diff --git a/t/porting/known_pod_issues.dat b/t/porting/known_pod_issues.dat
index 637e697..0d16b19 100644
--- a/t/porting/known_pod_issues.dat
+++ b/t/porting/known_pod_issues.dat
@@ -43,6 +43,7 @@ cpanp(1)
 CPANPLUS
 Crypt::Random
 curl(1)
+Dancer
 Data::Alias
 Data::Entropy
 Data::Float
@@ -75,6 +76,7 @@ File::MMagic
 File::ShareDir
 flock(3)
 fsync(3c)
+Function::Parameters
 Future
 gcc(1)
 Getopt::Std
@@ -129,7 +131,9 @@ open(2)
 OS2::Proc
 OS2::WinObject
 Package::Constants
+Padre
 PadWalker
+Parse::Keyword
 passwd(1)
 perl(1)
 Perl4::CoreLibs

--
Perl5 Master Repository

Reply via email to