From 4a7e937e5e38b45d73f74bc6acde04dfb15ad1aa Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Tue, 22 Nov 2011 09:18:28 -0700 Subject: [PATCH] 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. --- lib/utf8_heavy.pl | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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'}) -- 2.7.4