Commit 97ef1ccbb2 for perl
commit 97ef1ccbb2fdedb8dc9d1c157a220bb6ad3cdab6
Author: Karl Williamson <khw@cpan.org>
Date: Thu Nov 5 11:37:56 2026 -0700
chop: Clear UTF-8 flag appropriately
Fixes #25035
chop() returns the chopped character, unlike chomp(). If TARG is UTF-8
from a previous operation, and this chop isn't, the flag wasn't cleared.
diff --git a/pp.c b/pp.c
index 835c179b08..e0118cec57 100644
--- a/pp.c
+++ b/pp.c
@@ -971,6 +971,7 @@ S_do_chomp(pTHX_ SV *retval, SV *sv, bool chomping)
else if (s && len) {
s += --len;
sv_setpvn(retval, s, 1);
+ SvUTF8_off(retval);
*s = '\0';
SvCUR_set(sv, len);
SvUTF8_off(sv);
diff --git a/t/op/chop.t b/t/op/chop.t
index 467cd3333a..44a9c80831 100644
--- a/t/op/chop.t
+++ b/t/op/chop.t
@@ -304,8 +304,9 @@ $/ = "\n";
}
}
-TODO: {
- local $::TODO = 'GH 25035';
+{ # GH 25035
+
+ # First iteration sets UTF-8 flag in TARG; 2nd needs to clear it.
for ("\x{100}", "\x{ff}") {
my $s = $_;
my $orig = $s;