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