This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #91834] utf8::decode does not respect copy-on-write
authorFather Chrysostomos <sprout@cpan.org>
Sun, 29 May 2011 21:21:06 +0000 (14:21 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 29 May 2011 21:46:22 +0000 (14:46 -0700)
commit40f11004fb3b5fa1cd207a20090df837d721b736
tree6a34379b467f76b48ac57cc85685ec0c104e9848
parent694cf0d2097096aceb05356229e210423cd909c2
[perl #91834] utf8::decode does not respect copy-on-write

utf8::decode was not respecting copy-on-write, but simply modify-
ing the PV (the scalar’s string buffer) in place, causing problems
with hashes:

my $name = "\x{c3}\x{b3}";
my ($k1) = keys %{ { $name=>undef } };
my $k2 = $name;
utf8::decode($k1);
utf8::decode($k2);
print "k1 eq k2 = '", $k1 eq $k2, "'\n";
my $h = { $k1 => 1, $k2 => 2 };
print "{k1} '", $h->{$k1}, "'\n";
print "{k2} '", $h->{$k2}, "'\n";

This example (from the RT ticket) shows that there were two hash ele-
ments with the same key.

As of this commit, the hash only has one element.
lib/utf8.t
universal.c