3 # Generate Expansion Table of Compatibility Ligatures
4 # (c) 2003 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
10 print STDERR "Reading ligature list\n";
11 open(L, "misc/u-ligatures") || die "lig file open";
19 print STDERR "Reading decompositions\n";
20 open(I, "unidata/UnicodeData.txt") || die "Unable to open UniCode data file";
24 (/^$/ || /^#/) && next;
25 my ($code,$name,$cat,$comb,$bidir,$decomp,$d0,$d1,$n0,$mirr,$cmt1,$cmt2,$upper,$lower,$title) = split /;/;
26 $code =~ /^....$/ || next;
27 if (my ($d) = ($decomp =~ /^<compat> (.*)/)) {
35 if (defined $decs{$c}) {
36 return join (" ", map { expand($_) } split(/\s+/, $decs{$c}));
42 print STDERR "Searching for a perfect hash function\n";
46 #print STDERR "Trying $div... ";
48 foreach my $l (keys %ligs) {
49 my $i = (hex $l) % $div;
51 #print STDERR "collision\n";
56 #print STDERR "FOUND\n";
60 print STDERR "Filling hash table with $div entries for $n ligatures\n";
61 my @ht = map { "NULL" } 1..$div;
62 foreach my $l (keys %ligs) {
63 my $i = (hex $l) % $div;
64 my $w = join(", ", map { "0x$_" } split(/ /, expand($l)));
65 $ht[$i] = "/* $l */ (const u16 []) { $w, 0 }";
68 print "#define LIG_HASH_SIZE $div\n\n";
69 print "static const u16 *_U_lig_hash[] = {\n";
70 for (my $i=0; $i<$div; $i++) {
71 print "\t", $ht[$i], ",\n";