# 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;
$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'");
$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
# 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);
}
# Keep a list of the deprecated properties and their filenames
- if ($deprecated) {
+ if ($deprecated && $complement == 0) {
$utf8::why_deprecated{$sub_filename} = $deprecated;
}
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
# 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;