diff options
author | Karl Williamson <public@khwilliamson.com> | 2011-07-01 10:25:28 -0600 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2011-07-03 14:05:49 -0600 |
commit | a92d5c2e4647ac12b60c5732210445ac4c458ad3 (patch) | |
tree | b149d7e57ce1d7af6820665ba533e1819bfb5d17 /lib | |
parent | e1759d043939c0b3bb25c6d8408f1ee9f81175c1 (diff) | |
download | perl-a92d5c2e4647ac12b60c5732210445ac4c458ad3.tar.gz |
mktables: Suppress complement tables
Consider the property \p{AHex}. This is really \p{AHex=Y}, and there
is a corresponding \p{AHex=N} that is just the complement. Prior to
this patch, 2 tables were generated for AHex. Now, just one is, and the
N table is set-up in Heavy.pl to be the complement of the Y table. This
saves quite a few tables and corresponding disk space.
Note that not all complements need be binary tables.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/unicore/mktables | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/lib/unicore/mktables b/lib/unicore/mktables index 95eff41e2d..02623d1c68 100644 --- a/lib/unicore/mktables +++ b/lib/unicore/mktables @@ -6465,6 +6465,11 @@ sub trace { return main::trace(@_); } # points. main::set_access('matches_all', \%matches_all, 'r'); + my %complement; + # Points to the complement that this table is expressed in terms of; 0 if + # none. + main::set_access('complement', \%complement, 'r', 's' ); + sub new { my $class = shift; @@ -6513,6 +6518,7 @@ sub trace { return main::trace(@_); } $matches_all{$addr} = $matches_all; $leader{$addr} = $self; $parent{$addr} = $self; + $complement{$addr} = 0; if (defined $format && $format ne $EMPTY_FORMAT) { Carp::my_carp_bug("'Format' must be '$EMPTY_FORMAT' in a match table instead of '$format'. Using '$EMPTY_FORMAT'"); @@ -11193,6 +11199,19 @@ sub finish_Unicode() { $default_table = $property->add_match_table($default_map); } + # And, if the property is binary, the default table will just + # be the complement of the other table. + if ($property_type == $BINARY) { + my $non_default_table; + + # Find the non-default table. + for my $table ($property->tables) { + next if $table == $default_table; + $non_default_table = $table; + } + $default_table->set_complement($non_default_table); + } + # This fills in any missing values with the default. It's # tempting to save some time and memory in running this program # by skipping this step for binary tables where the default @@ -12278,6 +12297,21 @@ sub register_file_for_name($$$) { # table, so skip if isn't the leader. return if $table->leader != $table; + # If this is a complement of another file, use that other file instead, + # with a ! prepended to it. + my $complement; + if (($complement = $table->complement) != 0) { + my @directories = $complement->file_path; + + # This assumes that the 0th element is something like 'lib', + # the 1th element the property name (in its own directory), like + # 'AHex', and the 2th element the file like 'Y' which will have a .pl + # appended to it later. + $directories[1] =~ s/^/!/; + $file = pop @directories; + $directory_ref =\@directories; + } + # Join all the file path components together, using slashes. my $full_filename = join('/', @$directory_ref, $file); @@ -12345,7 +12379,7 @@ sub register_file_for_name($$$) { } # Keep a list of the deprecated properties and their filenames - if ($deprecated) { + if ($deprecated && $complement == 0) { $utf8::why_deprecated{$sub_filename} = $deprecated; } @@ -13511,6 +13545,14 @@ sub write_all_tables() { return 1 if ! defined $ext_a; my $ext_b = $b->external_name; return -1 if ! defined $ext_b; + + # But return the non-complement table before + # the complement one, as the latter is defined + # in terms of the former, and needs to have + # the information for the former available. + return 1 if $a->complement != 0; + return -1 if $b->complement != 0; + my $cmp = length $ext_a <=> length $ext_b; # Return result if lengths not equal @@ -13803,7 +13845,8 @@ sub write_all_tables() { # Only need to write one file when shared by more than one # property - next if ! $is_property && $table->leader != $table; + next if ! $is_property + && ($table->leader != $table || $table->complement != 0); # Construct a nice comment to add to the file $table->set_final_comment; |