In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/e56a605e8f98dd29e64fecbc92a6af8044c717e9?hp=704b97aa6fbde2d13d9db5c7615d8baa5dbb885f>

- Log -----------------------------------------------------------------
commit e56a605e8f98dd29e64fecbc92a6af8044c717e9
Author: Father Chrysostomos <[email protected]>
Date:   Thu Dec 4 12:32:55 2014 -0800

    Don’t deparse formats with #line directives
    
    $ perl5.20.1 -mO=Deparse,-l -e 'format =' -e\@ -e'$foo' -e.
    format STDOUT =
    @
    $foo
    .
    -e syntax OK
    $ ./perl -Ilib -mO=Deparse,-l -e 'format =' -e\@ -e'$foo' -e.
    format STDOUT =
    @
    
    #line 3 "-e"
    ; $foo
    .
    -e syntax OK
    
    The second is not valid syntax.
    
    I probably broke that when fixing BEGIN blocks.
-----------------------------------------------------------------------

Summary of changes:
 lib/B/Deparse.pm |  2 +-
 lib/B/Deparse.t  | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm
index 1974414..dea21a9 100644
--- a/lib/B/Deparse.pm
+++ b/lib/B/Deparse.pm
@@ -1894,7 +1894,7 @@ sub pp_nextstate {
     # This should go after of any branches that add statements, to
     # increase the chances that it refers to the same line it did in
     # the original program.
-    if ($self->{'linenums'}) {
+    if ($self->{'linenums'} && $cx != .5) { # $cx == .5 means in a format
        push @text, "\f#line " . $op->line .
          ' "' . $op->file, qq'"\n';
     }
diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t
index 1e8d545..f39e1c8 100644
--- a/lib/B/Deparse.t
+++ b/lib/B/Deparse.t
@@ -13,7 +13,7 @@ BEGIN {
 use warnings;
 use strict;
 
-my $tests = 32; # not counting those in the __DATA__ section
+my $tests = 33; # not counting those in the __DATA__ section
 
 use B::Deparse;
 my $deparse = B::Deparse->new();
@@ -292,6 +292,15 @@ $;
 .
 EOCODM
 
+is runperl(stderr => 1, switches => [ '-MO=-qq,Deparse,-l', $path ],
+           prog => "format =\n\@\n\$foo\n.\n"),
+   <<'EOCODM', 'formats with -l';
+format STDOUT =
+@
+$foo
+.
+EOCODM
+
 # CORE::format
 $a = readpipe qq`$^X $path "-MO=Deparse" -e "use feature q|:all|;`
              .qq` my sub format; CORE::format =" -e. 2>&1`;

--
Perl5 Master Repository

Reply via email to