diff options
author | Owen Taylor <otaylor@redhat.com> | 2003-05-28 21:46:09 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2003-05-28 21:46:09 +0000 |
commit | f74a7de5f5b66832db3102594973e638d5ced4ed (patch) | |
tree | eff088005fbcfa678d70fadbe9f643e7233e0513 /tools/compress-table.pl | |
parent | ffca2103adc0e68e0977a44297ec4b5213164876 (diff) | |
download | pango-f74a7de5f5b66832db3102594973e638d5ced4ed.tar.gz |
(#107630, Federic Zhang)
Wed May 28 17:43:16 2003 Owen Taylor <otaylor@redhat.com>
(#107630, Federic Zhang)
* tools/compress-table.pl (convert): Make read the
maps directly.
* tools/make-table.pl: Remove.
Diffstat (limited to 'tools/compress-table.pl')
-rwxr-xr-x | tools/compress-table.pl | 97 |
1 files changed, 56 insertions, 41 deletions
diff --git a/tools/compress-table.pl b/tools/compress-table.pl index a11f3d8a..55129651 100755 --- a/tools/compress-table.pl +++ b/tools/compress-table.pl @@ -36,28 +36,53 @@ sub output { } } -print "const guint32 char_mask_map[] = {\n 0,\n"; +# +# Read in the maps +# +my @codepoints = (); + +opendir (MAPS, "maps") || die "Cannot open maps/ subdirectory: $!\n"; +while (defined (my $map = readdir (MAPS))) { + next if ($map =~ /^\./); + next if ($map =~ /~$/); + next if ($map =~ /^CVS|README$/); + + open (MAP, "maps/$map") || die "Cannot open map '$map:!\n"; + + $encoding = convert($map); + while (<MAP>) { + s/\s*#.*//; + s/\s*$//; + next if /^$/; + if (!/^\s*(0x[A-Fa-f0-9]+)\s+(0x[A-Fa-f0-9]+)$/) { + die "Cannot parse line '%s' in map '$map'\n"; + } + push @codepoints, [hex($2), $encoding]; + } + close (MAP); +} + +# +# And sort them +# +@codepoints = sort { $a->[0] <=> $b->[0] } @codepoints; -open TABLE, "table"; +print "const guint32 char_mask_map[] = {\n 0,\n"; $encodings = ""; -while (<TABLE>) { - if (/^(0x[0-9a-fA-F]+)\s+([^:]*):(0x[0-9a-fA-F]+)/) { - ($u, $e) = ($1, $2); - - $u = oct($u); - - if (!defined $old_u) { - $old_u = $u; - $encodings = convert($e); - } elsif ($old_u ne $u) { - add($encodings); - $old_u = $u; - $encodings = convert($e); - } else { - $encodings .= "|".convert($e); - } +for $cp (@codepoints) { + $u = $cp->[0]; $e = $cp->[1]; + + if (!defined $old_u) { + $old_u = $u; + $encodings = $e; + } elsif ($old_u ne $u) { + add($encodings); + $old_u = $u; + $encodings = $e; + } else { + $encodings .= "|".$e; } } @@ -65,37 +90,29 @@ if (defined $old_u) { add($encodings); } -close TABLE; - print <<EOF; }; const guchar char_masks[] = { EOF -open TABLE, "table"; - $encodings = ""; undef $old_u; $start = 0; -while (<TABLE>) { - if (/^(0x[0-9a-fA-F]+)\s+([^:]*):(0x[0-9a-fA-F]+)/) { - ($u, $e) = ($1, $2); - - $u = oct($u); - - if (!defined $old_u) { - $old_u = $u; - $encodings = convert($e); - } elsif ($old_u ne $u) { - output($start, $old_u, $combos{$encodings}); - $start = $old_u + 1; - $old_u = $u; - $encodings = convert($e); - } else { - $encodings .= "|".convert($e); - } +for $cp (@codepoints) { + $u = $cp->[0]; $e = $cp->[1]; + + if (!defined $old_u) { + $old_u = $u; + $encodings = $e; + } elsif ($old_u ne $u) { + output($start, $old_u, $combos{$encodings}); + $start = $old_u + 1; + $old_u = $u; + $encodings = $e; + } else { + $encodings .= "|".$e; } } @@ -103,6 +120,4 @@ if (defined $old_u) { output($start, $old_u, $combos{$encodings}); } -close TABLE; - print "\n};\n"; |