ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/gencompose
(Generate patch)

Comparing rxvt-unicode/src/gencompose (file contents):
Revision 1.1 by pcg, Thu Mar 4 02:05:49 2004 UTC vs.
Revision 1.4 by root, Mon Jan 23 23:33:58 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines