unicode: Use existing helpers to build the l_intl.nls file.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
152bd21d95
commit
bd9d83b73a
|
@ -1983,66 +1983,21 @@ sub dump_two_level_mapping($$@)
|
|||
sub dump_binary_case_table(@)
|
||||
{
|
||||
my (@table) = @_;
|
||||
my $max_char = 0x10000;
|
||||
my $level1 = $max_char / 16;
|
||||
my $level2 = $level1 / 16;
|
||||
|
||||
my %difftables_hash = ();
|
||||
my @difftables;
|
||||
my %offtables2_hash = ();
|
||||
my @offtables2 = ();
|
||||
|
||||
my @offtable = ();
|
||||
for (my $i = 0; $i < 256; $i++)
|
||||
{
|
||||
my @offtable2 = ();
|
||||
for(my $j = 0; $j < 16; $j++) # offset table for xx00-xxFF characters
|
||||
{
|
||||
my @difftable;
|
||||
for (my $k = 0; $k < 16; $k++) # case map table for xxx0-xxxF characters
|
||||
for (my $i = 0; $i < @table; $i++)
|
||||
{
|
||||
my $char = ($i<<8) + ($j<<4) + $k;
|
||||
$difftable[$k] = (defined $table[$char]) ? (($table[$char]-$char) & 0xffff) : 0;
|
||||
next unless defined $table[$i];
|
||||
$difftable[$i] = ($table[$i] - $i) & 0xffff;
|
||||
}
|
||||
|
||||
my $diff_key = pack "S*", @difftable;
|
||||
my $offset3 = $difftables_hash{$diff_key};
|
||||
if (!defined $offset3)
|
||||
{
|
||||
$offset3 = scalar @difftables;
|
||||
$difftables_hash{$diff_key} = $offset3;
|
||||
push @difftables, @difftable;
|
||||
}
|
||||
$offtable2[$j] = $offset3;
|
||||
}
|
||||
|
||||
my $offtable2_key = pack "S*", @offtable2;
|
||||
my $offset2 = $offtables2_hash{$offtable2_key};
|
||||
if (!defined $offset2)
|
||||
{
|
||||
$offset2 = scalar @offtables2;
|
||||
$offtables2_hash{$offtable2_key} = $offset2;
|
||||
push @offtables2, \@offtable2;
|
||||
}
|
||||
$offtable[$i] = $offset2;
|
||||
}
|
||||
|
||||
my @output;
|
||||
my $offset = 0x100; # offset of first subtable in words
|
||||
foreach (@offtable)
|
||||
{
|
||||
push @output, 0x10 * $_ + $offset; # offset of subtable in words
|
||||
}
|
||||
|
||||
$offset = 0x100 + 0x10 * scalar @offtables2; # offset of first difftable in words
|
||||
foreach(@offtables2)
|
||||
{
|
||||
my $table = $_;
|
||||
foreach(@$table)
|
||||
{
|
||||
push @output, $_ + $offset; # offset of difftable in words
|
||||
}
|
||||
}
|
||||
|
||||
my $len = 1 + scalar @output + scalar @difftables;
|
||||
return pack "S<*", $len, @output, @difftables;
|
||||
my @row_array = compress_array( $level1, 0, @difftable[0..$max_char-1] );
|
||||
my @array = compress_array( $level2, 0, @row_array[0..$level1-1] );
|
||||
for (my $i = $level2; $i < @array; $i++) { $array[$i] += @array - $level1; }
|
||||
return @array, @row_array[$level1..$#row_array];
|
||||
}
|
||||
|
||||
|
||||
|
@ -2050,14 +2005,17 @@ sub dump_binary_case_table(@)
|
|||
# dump case mappings for l_intl.nls
|
||||
sub dump_intl_nls($)
|
||||
{
|
||||
my @upper = dump_binary_case_table( @toupper_table );
|
||||
my @lower = dump_binary_case_table( @tolower_table );
|
||||
|
||||
my $filename = shift;
|
||||
open OUTPUT,">$filename.new" or die "Cannot create $filename";
|
||||
printf "Building $filename\n";
|
||||
|
||||
binmode OUTPUT;
|
||||
print OUTPUT pack "S<", 1; # version
|
||||
print OUTPUT dump_binary_case_table( @toupper_table );
|
||||
print OUTPUT dump_binary_case_table( @tolower_table );
|
||||
print OUTPUT pack "S<*", 1 + scalar @upper, @upper;
|
||||
print OUTPUT pack "S<*", 1 + scalar @lower, @lower;
|
||||
close OUTPUT;
|
||||
save_file($filename);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue