Blame SOURCES/perl-5.24.0-PATCH-perl-128734-tr-N-.-failing-for-128-255.patch

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