In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/3a34ca0bce7835211b45e070373cf653c253636a?hp=a3164817e46808339a605914ac61f15117615fe5>

- Log -----------------------------------------------------------------
commit 3a34ca0bce7835211b45e070373cf653c253636a
Author: Karl Williamson <[email protected]>
Date:   Wed Jul 27 12:44:42 2016 -0600

    PATCH: [perl #128734] tr/\N{...}/ failing for 128-255
    
    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.
-----------------------------------------------------------------------

Summary of changes:
 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 b50ac42..046d44f 100644
--- a/t/op/tr.t
+++ b/t/op/tr.t
@@ -13,7 +13,7 @@ BEGIN {
 
 use utf8;
 
-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.
@@ -647,4 +647,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 19883d6..bf2ac05 100644
--- a/toke.c
+++ b/toke.c
@@ -3534,7 +3534,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 {

--
Perl5 Master Repository

Reply via email to