Fix line numbers in multi-line s///

This commit is contained in:
Petr Písař 2018-04-20 11:19:16 +02:00
parent 0c45015a3b
commit b8e600698b
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,68 @@
From 823ba440369100de3f2693420a3887a645a57d28 Mon Sep 17 00:00:00 2001
From: David Mitchell <davem@iabyn.com>
Date: Wed, 7 Mar 2018 09:27:26 +0000
Subject: [PATCH] fix line numbers in multi-line s///
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
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);
}
--
2.14.3

View File

@ -260,6 +260,9 @@ Patch80: perl-5.26.1-fix-parsing-of-braced-subscript-after-parens.patch
# in upstream after 5.27.8
Patch81: perl-5.27.8-don-t-clobber-file-bytes-in-encoding-layer.patch
# Fix line numbers in multi-line s///, RT#131930, in upstream after 5.27.9
Patch82: perl-5.27.9-fix-line-numbers-in-multi-line-s.patch
# Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
@ -2862,6 +2865,7 @@ Perl extension for Version Objects
%patch79 -p1
%patch80 -p1
%patch81 -p1
%patch82 -p1
%patch200 -p1
%patch201 -p1
@ -2911,6 +2915,7 @@ perl -x patchlevel.h \
'Fedora Patch79: Link XS modules to pthread library to fix linking with -z defs' \
'Fedora Patch80: Fix parsing braced subscript after parentheses (RT#8045)' \
'Fedora Patch81: Do not clobber file bytes in :encoding layer (RT#132833)' \
'Fedora Patch82: Fix line numbers in multi-line s/// (RT#131930)' \
'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
%{nil}
@ -5202,6 +5207,7 @@ popd
- perl-devel requires redhat-rpm-config because of hardened compiler profiles
(bug #1557667)
- Do not clobber file bytes in :encoding layer (RT#132833)
- Fix line numbers in multi-line s/// (RT#131930)
* Mon Apr 16 2018 Petr Pisar <ppisar@redhat.com> - 4:5.26.2-411
- 5.26.2 bump