a4ac56
From 823ba440369100de3f2693420a3887a645a57d28 Mon Sep 17 00:00:00 2001
a4ac56
From: David Mitchell <davem@iabyn.com>
a4ac56
Date: Wed, 7 Mar 2018 09:27:26 +0000
a4ac56
Subject: [PATCH] fix line numbers in multi-line s///
a4ac56
MIME-Version: 1.0
a4ac56
Content-Type: text/plain; charset=UTF-8
a4ac56
Content-Transfer-Encoding: 8bit
a4ac56
a4ac56
my commit v5.25.6-230-g6432a58, "Eliminate SVrepl_EVAL and SvEVALED()",
a4ac56
introduced a regression: __LINE__ no longer took account of multiple
a4ac56
lines in the s///.
a4ac56
a4ac56
Now fixed.
a4ac56
a4ac56
Spotted by Abigail.
a4ac56
a4ac56
Signed-off-by: Petr Písař <ppisar@redhat.com>
a4ac56
---
a4ac56
 t/re/subst.t | 12 +++++++++++-
a4ac56
 toke.c       |  2 +-
a4ac56
 2 files changed, 12 insertions(+), 2 deletions(-)
a4ac56
a4ac56
diff --git a/t/re/subst.t b/t/re/subst.t
a4ac56
index b9b9939b11..dd62e95ee6 100644
a4ac56
--- a/t/re/subst.t
a4ac56
+++ b/t/re/subst.t
a4ac56
@@ -11,7 +11,7 @@ BEGIN {
a4ac56
     require './loc_tools.pl';
a4ac56
 }
a4ac56
 
a4ac56
-plan(tests => 275);
a4ac56
+plan(tests => 276);
a4ac56
 
a4ac56
 $_ = 'david';
a4ac56
 $a = s/david/rules/r;
a4ac56
@@ -1163,6 +1163,16 @@ __EOF__
a4ac56
     pass("RT #130188");
a4ac56
 }
a4ac56
 
a4ac56
+# RT #131930
a4ac56
+# a multi-line s/// wasn't resetting the cop_line correctly
a4ac56
+{
a4ac56
+    my $l0 = __LINE__;
a4ac56
+    my $s = "a";
a4ac56
+    $s =~ s[a]
a4ac56
+           [b];
a4ac56
+    my $lines = __LINE__ - $l0;
a4ac56
+    is $lines, 4, "RT #131930";
a4ac56
+}
a4ac56
 
a4ac56
 
a4ac56
 
a4ac56
diff --git a/toke.c b/toke.c
a4ac56
index 9dbad98408..0ef33415c0 100644
a4ac56
--- a/toke.c
a4ac56
+++ b/toke.c
a4ac56
@@ -9884,7 +9884,7 @@ S_scan_subst(pTHX_ char *start)
a4ac56
          * the NVX field indicates how many src code lines the replacement
a4ac56
          * spreads over */
a4ac56
         sv_upgrade(PL_parser->lex_sub_repl, SVt_PVNV);
a4ac56
-        ((XPVNV*)SvANY(PL_parser->lex_sub_repl))->xnv_u.xnv_lines = 0;
a4ac56
+        ((XPVNV*)SvANY(PL_parser->lex_sub_repl))->xnv_u.xnv_lines = linediff;
a4ac56
         ((XPVIV*)SvANY(PL_parser->lex_sub_repl))->xiv_u.xivu_eval_seen =
a4ac56
                                                                     cBOOL(es);
a4ac56
     }
a4ac56
-- 
a4ac56
2.14.3
a4ac56