Fix handling \N{} in tr for characters in range 128--255

This commit is contained in:
Petr Písař 2016-07-28 10:37:31 +02:00
parent eaff35bbf5
commit 765c6152c1
2 changed files with 72 additions and 1 deletions

View File

@ -0,0 +1,62 @@
From 9b3f53bd7af9574dcc38432cb191b90e9f957362 Mon Sep 17 00:00:00 2001
From: Karl Williamson <khw@cpan.org>
Date: Wed, 27 Jul 2016 12:44:42 -0600
Subject: [PATCH] PATCH: [perl #128734] tr/\N{...}/ failing for 128-255
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The upper latin1 characters when expressed as \N{U+...} were failing.
This was due to trying to convert them to UTF-8 when the result isn't
UTF-8. I added a test for \N{name} as well, though these were not
affected by this regression.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
t/op/tr.t | 11 ++++++++++-
toke.c | 2 +-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/t/op/tr.t b/t/op/tr.t
index 6783dad..d40187f 100644
--- a/t/op/tr.t
+++ b/t/op/tr.t
@@ -9,7 +9,7 @@ BEGIN {
set_up_inc('../lib');
}
-plan tests => 164;
+plan tests => 166;
# Test this first before we extend the stack with other operations.
# This caused an asan failure due to a bad write past the end of the stack.
@@ -643,4 +643,13 @@ for ("", nullrocow) {
ok(1, "tr///d on glob does not assert");
}
+{ # [perl #128734
+ my $string = "\x{00e0}";
+ $string =~ tr/\N{U+00e0}/A/;
+ is($string, "A", 'tr// of \N{U+...} works for upper-Latin1');
+ $string = "\x{00e1}";
+ $string =~ tr/\N{LATIN SMALL LETTER A WITH ACUTE}/A/;
+ is($string, "A", 'tr// of \N{name} works for upper-Latin1');
+}
+
1;
diff --git a/toke.c b/toke.c
index 59a0749..52e658f 100644
--- a/toke.c
+++ b/toke.c
@@ -3540,7 +3540,7 @@ S_scan_const(pTHX_ char *start)
}
/* Add the (Unicode) code point to the output. */
- if (OFFUNI_IS_INVARIANT(uv)) {
+ if (! has_utf8 || OFFUNI_IS_INVARIANT(uv)) {
*d++ = (char) LATIN1_TO_NATIVE(uv);
}
else {
--
2.5.5

View File

@ -28,7 +28,7 @@
Name: perl
Version: %{perl_version}
# release number must be even higher, because dual-lived modules will be broken otherwise
Release: 375%{?dist}
Release: 376%{?dist}
Epoch: %{perl_epoch}
Summary: Practical Extraction and Report Language
Group: Development/Languages
@ -157,6 +157,10 @@ Patch41: perl-5.25.2-SEGV-in-Subroutine-redefined-warning.patch
# Fix a crash in lexical scope warnings, RT#128597, in upstream after 5.25.2
Patch42: perl-5.25.2-perl-128597-Crash-from-gp_free-ckWARN_d.patch
# Fix handling \N{} in tr for characters in range 128--255, RT#128734,
# in upstream after 5.25.3
Patch43: perl-5.24.0-PATCH-perl-128734-tr-N-.-failing-for-128-255.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
@ -2819,6 +2823,7 @@ Perl extension for Version Objects
%patch40 -p1
%patch41 -p1
%patch42 -p1
%patch43 -p1
%patch200 -p1
%patch201 -p1
@ -2852,6 +2857,7 @@ perl -x patchlevel.h \
'Fedora Patch40: Fix a crash when vivifying a stub in a deleted package (RT#128532)' \
'Fedora Patch41: Fix a crash in "Subroutine redefined" warning (RT#128257)' \
'Fedora Patch42: Fix a crash in lexical scope warnings (RT#128597)' \
'Fedora Patch43: Fix handling \N{} in tr for characters in range 128--255 (RT#128734)' \
'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}
@ -5130,6 +5136,9 @@ popd
# Old changelog entries are preserved in CVS.
%changelog
* Thu Jul 28 2016 Petr Pisar <ppisar@redhat.com> - 4:5.24.0-376
- Fix handling \N{} in tr for characters in range 128--255 (RT#128734)
* Tue Jul 26 2016 Petr Pisar <ppisar@redhat.com> - 4:5.24.0-375
- Fix building without perl in the build root
- Own systemtap directories by perl-devel