develooper Front page | perl.perl5.changes | Postings from March 2018

[perl.git] branch blead updated. v5.27.9-124-g823ba44036

From:
Dave Mitchell
Date:
March 7, 2018 09:35
Subject:
[perl.git] branch blead updated. v5.27.9-124-g823ba44036
Message ID:
E1etVTw-0002tL-5u@git.dc.perl.space
In perl.git, the branch blead has been updated

<https://perl5.git.perl.org/perl.git/commitdiff/823ba440369100de3f2693420a3887a645a57d28?hp=32ce30d709666239149a4f04ddcfbdec00005288>

- Log -----------------------------------------------------------------
commit 823ba440369100de3f2693420a3887a645a57d28
Author: David Mitchell <davem@iabyn.com>
Date:   Wed Mar 7 09:27:26 2018 +0000

    fix line numbers in multi-line s///
    
    my commit v5.25.6-230-g6432a58, "Eliminate SVrepl_EVAL and SvEVALED()",
    introduced a regression: __LINE__ no longer took account of multiple
    lines in the s///.
    
    Now fixed.
    
    Spotted by Abigail.

-----------------------------------------------------------------------

Summary of changes:
 t/re/subst.t | 12 +++++++++++-
 toke.c       |  2 +-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/t/re/subst.t b/t/re/subst.t
index b9b9939b11..dd62e95ee6 100644
--- a/t/re/subst.t
+++ b/t/re/subst.t
@@ -11,7 +11,7 @@ BEGIN {
     require './loc_tools.pl';
 }
 
-plan(tests => 275);
+plan(tests => 276);
 
 $_ = 'david';
 $a = s/david/rules/r;
@@ -1163,6 +1163,16 @@ __EOF__
     pass("RT #130188");
 }
 
+# RT #131930
+# a multi-line s/// wasn't resetting the cop_line correctly
+{
+    my $l0 = __LINE__;
+    my $s = "a";
+    $s =~ s[a]
+           [b];
+    my $lines = __LINE__ - $l0;
+    is $lines, 4, "RT #131930";
+}
 
 
 
diff --git a/toke.c b/toke.c
index 9dbad98408..0ef33415c0 100644
--- a/toke.c
+++ b/toke.c
@@ -9884,7 +9884,7 @@ S_scan_subst(pTHX_ char *start)
          * the NVX field indicates how many src code lines the replacement
          * spreads over */
         sv_upgrade(PL_parser->lex_sub_repl, SVt_PVNV);
-        ((XPVNV*)SvANY(PL_parser->lex_sub_repl))->xnv_u.xnv_lines = 0;
+        ((XPVNV*)SvANY(PL_parser->lex_sub_repl))->xnv_u.xnv_lines = linediff;
         ((XPVIV*)SvANY(PL_parser->lex_sub_repl))->xiv_u.xivu_eval_seen =
                                                                     cBOOL(es);
     }

-- 
Perl5 Master Repository



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About