Skip to content

Commit 3a34ca0

Browse files
committed
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.
1 parent a316481 commit 3a34ca0

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

t/op/tr.t

+10-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ BEGIN {
1313

1414
use utf8;
1515

16-
plan tests => 164;
16+
plan tests => 166;
1717

1818
# Test this first before we extend the stack with other operations.
1919
# This caused an asan failure due to a bad write past the end of the stack.
@@ -647,4 +647,13 @@ for ("", nullrocow) {
647647
ok(1, "tr///d on glob does not assert");
648648
}
649649

650+
{ # [perl #128734
651+
my $string = "\x{00e0}";
652+
$string =~ tr/\N{U+00e0}/A/;
653+
is($string, "A", 'tr// of \N{U+...} works for upper-Latin1');
654+
$string = "\x{00e1}";
655+
$string =~ tr/\N{LATIN SMALL LETTER A WITH ACUTE}/A/;
656+
is($string, "A", 'tr// of \N{name} works for upper-Latin1');
657+
}
658+
650659
1;

toke.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3534,7 +3534,7 @@ S_scan_const(pTHX_ char *start)
35343534
}
35353535

35363536
/* Add the (Unicode) code point to the output. */
3537-
if (OFFUNI_IS_INVARIANT(uv)) {
3537+
if (! has_utf8 || OFFUNI_IS_INVARIANT(uv)) {
35383538
*d++ = (char) LATIN1_TO_NATIVE(uv);
35393539
}
35403540
else {

0 commit comments

Comments
 (0)