*** empty log message ***
[dana/urxvt.git] / src / gencompose
1 #!/usr/bin/perl
2
3 open UNIDATA, "<", "www.unicode.org/Public/UNIDATA/UnicodeData.txt"
4    or die "www.unicode.org/Public/UNIDATA/UnicodeData.txt: $!";
5 #my %docom = qw(initial | medial | final | isolated | compat | none |); #+ arabic
6 my %docom = qw(compat | none |);
7
8 while (<UNIDATA>) {
9    my ($code, undef, $category, undef, undef, $decompose, undef) = split /;/;
10
11    push @cat_z, $code if $category =~ /^Z/;
12
13    if ($decompose) {
14       $type = $decompose =~ s/^<(.*)>\s*// ? $1 : "none";
15
16       next unless $docom{$type};
17       next unless $decompose =~ /^([0-9a-f]+) ([0-9a-f]+)$/i;
18       my $pfx = sprintf "%08d %08d %08d", hex $1, hex $2, hex $code;
19       push @compose, [$pfx, hex $1, hex $2, hex $code];
20    }
21 }
22
23 open TABLE, ">", "table/compose.h"
24    or die "table/compose.h: $!";
25
26 print TABLE <<EOF;
27 //
28 // AUTOMATICALLLY GENERATED by gencompose
29 //
30
31 struct rxvt_compose_entry {
32    uint32_t c1, c2, r;
33 } rxvt_compose_table[] = {
34 #ifdef ENCODING_COMPOSE
35 EOF
36
37 for (sort { $a->[0] cmp $b->[0] } @compose) {
38    next if $seen{$_->[1],$_->[2]}++;
39    printf TABLE " { 0x%05x, 0x%05x, 0x%05x },\n", $_->[1], $_->[2], $_->[3];
40 }
41
42
43 print TABLE <<EOF;
44 #endif
45 };
46 EOF
47
48 open TABLE_Z, ">", "table/category.h";
49
50 print TABLE_Z <<EOF;
51 //
52 // AUTOMATICALLLY GENERATED by gencompose
53 //
54
55 #define IS_SPACE(c)     \\
56 EOF
57
58 for (@cat_z) {
59    print TABLE_Z "      (c) == 0x$_ || \\\n";
60 }
61
62 print TABLE_Z " 0\n";
63