mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-15 08:00:11 +00:00
unicode: Add separate helper for removing linguistic case mappings.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
8207bdfecb
commit
57a6033c0a
|
@ -553,6 +553,28 @@ sub compose_hangul(@)
|
||||||
return @ret;
|
return @ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# remove linguistic-only mappings from the case table
|
||||||
|
sub remove_linguistic_mappings($$)
|
||||||
|
{
|
||||||
|
my ($upper, $lower) = @_;
|
||||||
|
|
||||||
|
# remove case mappings that don't round-trip
|
||||||
|
|
||||||
|
for (my $i = 0; $i < @{$upper}; $i++)
|
||||||
|
{
|
||||||
|
next unless defined ${$upper}[$i];
|
||||||
|
my $ch = ${$upper}[$i];
|
||||||
|
${$upper}[$i] = undef unless defined ${$lower}[$ch] && ${$lower}[$ch] == $i;
|
||||||
|
}
|
||||||
|
for (my $i = 0; $i < @{$lower}; $i++)
|
||||||
|
{
|
||||||
|
next unless defined ${$lower}[$i];
|
||||||
|
my $ch = ${$lower}[$i];
|
||||||
|
${$lower}[$i] = undef unless defined ${$upper}[$ch] && ${$upper}[$ch] == $i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# read in the Unicode database files
|
# read in the Unicode database files
|
||||||
sub load_data()
|
sub load_data()
|
||||||
|
@ -672,21 +694,6 @@ sub load_data()
|
||||||
foreach my $i (@{$special_categories{$cat}}) { $category_table[$i] |= $flag; }
|
foreach my $i (@{$special_categories{$cat}}) { $category_table[$i] |= $flag; }
|
||||||
}
|
}
|
||||||
|
|
||||||
# remove case mappings that don't round-trip
|
|
||||||
|
|
||||||
for (my $i = 0; $i < @toupper_table; $i++)
|
|
||||||
{
|
|
||||||
next unless defined $toupper_table[$i];
|
|
||||||
my $ch = $toupper_table[$i];
|
|
||||||
$toupper_table[$i] = undef unless defined $tolower_table[$ch] && $tolower_table[$ch] == $i;
|
|
||||||
}
|
|
||||||
for (my $i = 0; $i < @tolower_table; $i++)
|
|
||||||
{
|
|
||||||
next unless defined $tolower_table[$i];
|
|
||||||
my $ch = $tolower_table[$i];
|
|
||||||
$tolower_table[$i] = undef unless defined $toupper_table[$ch] && $toupper_table[$ch] == $i;
|
|
||||||
}
|
|
||||||
|
|
||||||
# load the composition exclusions
|
# load the composition exclusions
|
||||||
|
|
||||||
my $EXCL = open_data_file( $UNIDATA, "CompositionExclusions.txt" );
|
my $EXCL = open_data_file( $UNIDATA, "CompositionExclusions.txt" );
|
||||||
|
@ -1651,9 +1658,13 @@ sub dump_case_mappings($)
|
||||||
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
||||||
print OUTPUT "#include \"windef.h\"\n\n";
|
print OUTPUT "#include \"windef.h\"\n\n";
|
||||||
|
|
||||||
dump_case_table( "wine_casemap_lower", @tolower_table );
|
my @upper = @toupper_table;
|
||||||
|
my @lower = @tolower_table;
|
||||||
|
remove_linguistic_mappings( \@upper, \@lower );
|
||||||
|
|
||||||
|
dump_case_table( "wine_casemap_lower", @lower );
|
||||||
print OUTPUT "\n";
|
print OUTPUT "\n";
|
||||||
dump_case_table( "wine_casemap_upper", @toupper_table );
|
dump_case_table( "wine_casemap_upper", @upper );
|
||||||
close OUTPUT;
|
close OUTPUT;
|
||||||
save_file($filename);
|
save_file($filename);
|
||||||
}
|
}
|
||||||
|
@ -1793,17 +1804,21 @@ sub dump_binary_case_table(@)
|
||||||
|
|
||||||
my @row_array = compress_array( $level1, 0, @difftable[0..$max_char-1] );
|
my @row_array = compress_array( $level1, 0, @difftable[0..$max_char-1] );
|
||||||
my @array = compress_array( $level2, 0, @row_array[0..$level1-1] );
|
my @array = compress_array( $level2, 0, @row_array[0..$level1-1] );
|
||||||
for (my $i = $level2; $i < @array; $i++) { $array[$i] += @array - $level1; }
|
my $offset = @array - $level1;
|
||||||
return @array, @row_array[$level1..$#row_array];
|
for (my $i = $level2; $i < @array; $i++) { $array[$i] += $offset; }
|
||||||
|
return pack "S<*", 1 + $offset + @row_array, @array, @row_array[$level1..$#row_array];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# dump case mappings for l_intl.nls
|
# dump case mappings for l_intl.nls
|
||||||
sub dump_intl_nls($)
|
sub dump_intl_nls($)
|
||||||
{
|
{
|
||||||
my @upper = dump_binary_case_table( @toupper_table );
|
my @upper_table = @toupper_table;
|
||||||
my @lower = dump_binary_case_table( @tolower_table );
|
my @lower_table = @tolower_table;
|
||||||
|
remove_linguistic_mappings( \@upper_table, \@lower_table );
|
||||||
|
|
||||||
|
my $upper = dump_binary_case_table( @upper_table );
|
||||||
|
my $lower = dump_binary_case_table( @lower_table );
|
||||||
|
|
||||||
my $filename = shift;
|
my $filename = shift;
|
||||||
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
||||||
|
@ -1811,8 +1826,8 @@ sub dump_intl_nls($)
|
||||||
|
|
||||||
binmode OUTPUT;
|
binmode OUTPUT;
|
||||||
print OUTPUT pack "S<", 1; # version
|
print OUTPUT pack "S<", 1; # version
|
||||||
print OUTPUT pack "S<*", 1 + scalar @upper, @upper;
|
print OUTPUT $upper;
|
||||||
print OUTPUT pack "S<*", 1 + scalar @lower, @lower;
|
print OUTPUT $lower;
|
||||||
close OUTPUT;
|
close OUTPUT;
|
||||||
save_file($filename);
|
save_file($filename);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue