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