From: Karl Williamson Date: Tue, 22 Nov 2011 16:18:28 +0000 (-0700) Subject: utf8_heavy.pl: Add inversion status to cache key X-Git-Tag: accepted/trunk/20130322.191538~1244 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4a7e937e5e38b45d73f74bc6acde04dfb15ad1aa;p=platform%2Fupstream%2Fperl.git utf8_heavy.pl: Add inversion status to cache key Contrary to what the debug statement said, what is being returned is a swash, and that swash is different from one that comes from the same file but differs in inversion, and so changing the INVERT_IT element messes things up for any existing one. Heretofore it hasn't mattered because the swash returned is always a copy, and so it actually hasn't created any problems. But future commits will stop the copying, so this would create problems then. The file will now have to be re-'do'ne to get an inverted list from it. --- diff --git a/lib/utf8_heavy.pl b/lib/utf8_heavy.pl index 3d78d80..675a8d1 100644 --- a/lib/utf8_heavy.pl +++ b/lib/utf8_heavy.pl @@ -405,8 +405,9 @@ sub _loose_name ($) { # Add the constant and go fetch it in. if (defined $file) { - # A beginning ! means to invert - $invert_it = $file =~ s/^!//; + # A beginning ! means to invert. The 0+ makes sure is + # numeric + $invert_it = 0 + $file =~ s/^!//; if ($utf8::why_deprecated{$file}) { warnings::warnif('deprecated', "Use of '$type' in \\p{} or \\P{} is deprecated because: $utf8::why_deprecated{$file};"); @@ -478,7 +479,8 @@ sub _loose_name ($) { # get it. $minbits = 1; - $invert_it = $file =~ s/^!//; + # The 0+ makes sure is numeric + $invert_it = 0 + $file =~ s/^!//; $file = "$unicore_dir/lib/$file.pl"; last GETFILE; } @@ -501,13 +503,13 @@ sub _loose_name ($) { ## (exception: user-defined properties and mappings), so we ## have a filename, so now we load it if we haven't already. ## If we have, return the cached results. The cache key is the - ## class and file to load. + ## class and file to load, and whether the results need to be + ## inverted. ## - my $found = $Cache{$class, $file}; + my $found = $Cache{$class, $file, $invert_it}; if ($found and ref($found) eq $class) { - print STDERR __LINE__, ": Returning cached '$file' for \\p{$type}; invert_it=$invert_it\n" if DEBUG; + print STDERR __LINE__, ": Returning cached swash for '$class,$file,$invert_it' for \\p{$type}\n" if DEBUG; pop @recursed if @recursed; - $found->{'INVERT_IT'} = $invert_it; return $found; } @@ -643,7 +645,7 @@ sub _loose_name ($) { } => $class; if ($file) { - $Cache{$class, $file} = $SWASH; + $Cache{$class, $file, $invert_it} = $SWASH; if ($type && exists $utf8::SwashInfo{$type} && exists $utf8::SwashInfo{$type}{'specials_name'})