mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-01 09:50:52 +00:00
libwine: Download Unicode data files from unicode.org as needed in cpmap.pl.
This commit is contained in:
parent
2a9b4e0142
commit
65a82cb180
1 changed files with 42 additions and 26 deletions
|
@ -21,15 +21,12 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
# base directory for ftp.unicode.org files
|
# base URLs for www.unicode.org files
|
||||||
my $BASEDIR = "ftp.unicode.org/Public/";
|
my $MAPPINGS = "http://www.unicode.org/Public/MAPPINGS";
|
||||||
my $MAPPREFIX = $BASEDIR . "MAPPINGS/";
|
my $UNIDATA = "http://www.unicode.org/Public/5.0.0/ucd";
|
||||||
|
|
||||||
# UnicodeData file
|
|
||||||
my $UNICODEDATA = $BASEDIR . "UNIDATA/UnicodeData.txt";
|
|
||||||
|
|
||||||
# Sort keys file
|
# Sort keys file
|
||||||
my $SORTKEYS = "www.unicode.org/reports/tr10/allkeys.txt";
|
my $SORTKEYS = "http://www.unicode.org/reports/tr10/allkeys.txt";
|
||||||
|
|
||||||
# Defaults mapping
|
# Defaults mapping
|
||||||
my $DEFAULTS = "./defaults";
|
my $DEFAULTS = "./defaults";
|
||||||
|
@ -202,6 +199,23 @@ my @decomp_table = ();
|
||||||
my @compose_table = ();
|
my @compose_table = ();
|
||||||
|
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
# fetch a unicode.org file and open it
|
||||||
|
sub open_data_file($)
|
||||||
|
{
|
||||||
|
my $url = shift;
|
||||||
|
(my $name = $url) =~ s/^.*\///;
|
||||||
|
local *FILE;
|
||||||
|
unless (-f "data/$name")
|
||||||
|
{
|
||||||
|
print "Fetching $url...\n";
|
||||||
|
mkdir "data";
|
||||||
|
!system "wget", "-q", "-O", "data/$name", $url or die "cannot fetch $url";
|
||||||
|
}
|
||||||
|
open FILE, "<data/$name" or die "cannot open data/$name";
|
||||||
|
return *FILE;
|
||||||
|
}
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# read in the defaults file
|
# read in the defaults file
|
||||||
sub READ_DEFAULTS($)
|
sub READ_DEFAULTS($)
|
||||||
|
@ -234,12 +248,12 @@ sub READ_DEFAULTS($)
|
||||||
}
|
}
|
||||||
die "Unrecognized line $_\n";
|
die "Unrecognized line $_\n";
|
||||||
}
|
}
|
||||||
|
close DEFAULTS;
|
||||||
|
|
||||||
# now build mappings from the decomposition field of the Unicode database
|
# now build mappings from the decomposition field of the Unicode database
|
||||||
|
|
||||||
open UNICODEDATA, "$UNICODEDATA" or die "Cannot open $UNICODEDATA";
|
my $UNICODE_DATA = open_data_file "$UNIDATA/UnicodeData.txt";
|
||||||
print "Loading $UNICODEDATA\n";
|
while (<$UNICODE_DATA>)
|
||||||
while (<UNICODEDATA>)
|
|
||||||
{
|
{
|
||||||
# Decode the fields ...
|
# Decode the fields ...
|
||||||
my ($code, $name, $cat, $comb, $bidi,
|
my ($code, $name, $cat, $comb, $bidi,
|
||||||
|
@ -344,6 +358,7 @@ sub READ_DEFAULTS($)
|
||||||
}
|
}
|
||||||
$unicode_defaults[$src] = $dst;
|
$unicode_defaults[$src] = $dst;
|
||||||
}
|
}
|
||||||
|
close $UNICODE_DATA;
|
||||||
|
|
||||||
# patch the category of some special characters
|
# patch the category of some special characters
|
||||||
|
|
||||||
|
@ -360,9 +375,9 @@ sub READ_DEFAULTS($)
|
||||||
sub READ_FILE($)
|
sub READ_FILE($)
|
||||||
{
|
{
|
||||||
my $name = shift;
|
my $name = shift;
|
||||||
open INPUT,$name or die "Cannot open $name";
|
my $INPUT = open_data_file $name;
|
||||||
|
|
||||||
while (<INPUT>)
|
while (<$INPUT>)
|
||||||
{
|
{
|
||||||
next if /^\#/; # skip comments
|
next if /^\#/; # skip comments
|
||||||
next if /^$/; # skip empty lines
|
next if /^$/; # skip empty lines
|
||||||
|
@ -391,6 +406,7 @@ sub READ_FILE($)
|
||||||
}
|
}
|
||||||
die "$name: Unrecognized line $_\n";
|
die "$name: Unrecognized line $_\n";
|
||||||
}
|
}
|
||||||
|
close $INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -485,8 +501,8 @@ sub READ_JIS0208_FILE($)
|
||||||
$cp2uni[0xa1c0] = 0xff3c;
|
$cp2uni[0xa1c0] = 0xff3c;
|
||||||
$uni2cp[0xff3c] = 0xa1c0;
|
$uni2cp[0xff3c] = 0xa1c0;
|
||||||
|
|
||||||
open INPUT, "$name" or die "Cannot open $name";
|
my $INPUT = open_data_file $name;
|
||||||
while (<INPUT>)
|
while (<$INPUT>)
|
||||||
{
|
{
|
||||||
next if /^\#/; # skip comments
|
next if /^\#/; # skip comments
|
||||||
next if /^$/; # skip empty lines
|
next if /^$/; # skip empty lines
|
||||||
|
@ -501,6 +517,7 @@ sub READ_JIS0208_FILE($)
|
||||||
}
|
}
|
||||||
die "$name: Unrecognized line $_\n";
|
die "$name: Unrecognized line $_\n";
|
||||||
}
|
}
|
||||||
|
close $INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -511,9 +528,8 @@ sub READ_SORTKEYS_FILE()
|
||||||
my @sortkeys = ();
|
my @sortkeys = ();
|
||||||
for (my $i = 0; $i < 65536; $i++) { $sortkeys[$i] = [ -1, 0, 0, 0, 0 ] };
|
for (my $i = 0; $i < 65536; $i++) { $sortkeys[$i] = [ -1, 0, 0, 0, 0 ] };
|
||||||
|
|
||||||
open INPUT, "$SORTKEYS" or die "Cannot open $SORTKEYS";
|
my $INPUT = open_data_file $SORTKEYS;
|
||||||
print "Loading $SORTKEYS\n";
|
while (<$INPUT>)
|
||||||
while (<INPUT>)
|
|
||||||
{
|
{
|
||||||
next if /^\#/; # skip comments
|
next if /^\#/; # skip comments
|
||||||
next if /^$/; # skip empty lines
|
next if /^$/; # skip empty lines
|
||||||
|
@ -533,7 +549,7 @@ sub READ_SORTKEYS_FILE()
|
||||||
}
|
}
|
||||||
die "$SORTKEYS: Unrecognized line $_\n";
|
die "$SORTKEYS: Unrecognized line $_\n";
|
||||||
}
|
}
|
||||||
close INPUT;
|
close $INPUT;
|
||||||
|
|
||||||
# compress the keys to 32 bit:
|
# compress the keys to 32 bit:
|
||||||
# key 1 to 16 bits, key 2 to 8 bits, key 3 to 4 bits, key 4 to 1 bit
|
# key 1 to 16 bits, key 2 to 8 bits, key 3 to 4 bits, key 4 to 1 bit
|
||||||
|
@ -1206,9 +1222,9 @@ sub handle_bestfit_file($$$)
|
||||||
my ($lb_cur, $lb_end);
|
my ($lb_cur, $lb_end);
|
||||||
my @lb_ranges = ();
|
my @lb_ranges = ();
|
||||||
|
|
||||||
open INPUT,$MAPPREFIX . $filename or die "Cannot open $filename";
|
my $INPUT = open_data_file "$MAPPINGS/$filename" or die "Cannot open $filename";
|
||||||
|
|
||||||
while (<INPUT>)
|
while (<$INPUT>)
|
||||||
{
|
{
|
||||||
next if /^;/; # skip comments
|
next if /^;/; # skip comments
|
||||||
next if /^\s*$/; # skip empty lines
|
next if /^\s*$/; # skip empty lines
|
||||||
|
@ -1278,7 +1294,7 @@ sub handle_bestfit_file($$$)
|
||||||
}
|
}
|
||||||
die "$filename: Unrecognized line $_\n";
|
die "$filename: Unrecognized line $_\n";
|
||||||
}
|
}
|
||||||
close INPUT;
|
close $INPUT;
|
||||||
|
|
||||||
my $output = sprintf "c_%03d.c", $codepage;
|
my $output = sprintf "c_%03d.c", $codepage;
|
||||||
open OUTPUT,">$output.new" or die "Cannot create $output";
|
open OUTPUT,">$output.new" or die "Cannot create $output";
|
||||||
|
@ -1288,7 +1304,7 @@ sub handle_bestfit_file($$$)
|
||||||
# dump all tables
|
# dump all tables
|
||||||
|
|
||||||
printf OUTPUT "/* code page %03d (%s) */\n", $codepage, $comment;
|
printf OUTPUT "/* code page %03d (%s) */\n", $codepage, $comment;
|
||||||
printf OUTPUT "/* generated from %s */\n", $MAPPREFIX . $filename;
|
printf OUTPUT "/* generated from $MAPPINGS/$filename */\n";
|
||||||
printf OUTPUT "/* DO NOT EDIT!! */\n\n";
|
printf OUTPUT "/* DO NOT EDIT!! */\n\n";
|
||||||
printf OUTPUT "#include \"wine/unicode.h\"\n\n";
|
printf OUTPUT "#include \"wine/unicode.h\"\n\n";
|
||||||
|
|
||||||
|
@ -1310,14 +1326,14 @@ sub HANDLE_FILE(@)
|
||||||
@uni2cp = ();
|
@uni2cp = ();
|
||||||
|
|
||||||
# symbol codepage file is special
|
# symbol codepage file is special
|
||||||
if ($codepage == 20932) { READ_JIS0208_FILE($MAPPREFIX . $filename); }
|
if ($codepage == 20932) { READ_JIS0208_FILE "$MAPPINGS/$filename"; }
|
||||||
elsif ($codepage == 20127) { fill_20127_codepage(); }
|
elsif ($codepage == 20127) { fill_20127_codepage(); }
|
||||||
elsif ($filename =~ /\/bestfit/)
|
elsif ($filename =~ /\/bestfit/)
|
||||||
{
|
{
|
||||||
handle_bestfit_file( $filename, $has_glyphs, $comment );
|
handle_bestfit_file( $filename, $has_glyphs, $comment );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else { READ_FILE($MAPPREFIX . $filename); }
|
else { READ_FILE "$MAPPINGS/$filename"; }
|
||||||
|
|
||||||
ADD_DEFAULT_MAPPINGS();
|
ADD_DEFAULT_MAPPINGS();
|
||||||
|
|
||||||
|
@ -1331,8 +1347,8 @@ sub HANDLE_FILE(@)
|
||||||
printf OUTPUT "/* code page %03d (%s) */\n", $codepage, $comment;
|
printf OUTPUT "/* code page %03d (%s) */\n", $codepage, $comment;
|
||||||
if ($filename)
|
if ($filename)
|
||||||
{
|
{
|
||||||
printf OUTPUT "/* generated from %s */\n", $MAPPREFIX . $filename;
|
print OUTPUT "/* generated from $MAPPINGS/$filename */\n";
|
||||||
printf OUTPUT "/* DO NOT EDIT!! */\n\n";
|
print OUTPUT "/* DO NOT EDIT!! */\n\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue