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