summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2003-05-28 21:46:09 +0000
committerOwen Taylor <otaylor@src.gnome.org>2003-05-28 21:46:09 +0000
commitf74a7de5f5b66832db3102594973e638d5ced4ed (patch)
treeeff088005fbcfa678d70fadbe9f643e7233e0513 /tools
parentffca2103adc0e68e0977a44297ec4b5213164876 (diff)
downloadpango-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')
-rwxr-xr-xtools/compress-table.pl97
-rwxr-xr-xtools/make-table.sh16
2 files changed, 56 insertions, 57 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";
diff --git a/tools/make-table.sh b/tools/make-table.sh
deleted file mode 100755
index 5dbefb13..00000000
--- a/tools/make-table.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-echo -n > table.tmp
-
-for i in maps/* ; do
- name=`basename $i`
- case $name in
- README | CVS)
- ;;
- *)
- cat $i | grep -v '^#' | sed -e 's/[:space:]*#.*$//' | awk "{ printf \"%s %s:%s\\n\", \$NF, \"$name\", \$1 }" >> table.tmp
- ;;
- esac
-done
-sort table.tmp > table
-rm table.tmp