aboutsummaryrefslogtreecommitdiffstats
path: root/libwc/map/mk_ucs_isdigit_map.pl
blob: c67f645199714472fb85bd23845ff1a49b21fbda (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
open(MAP, "> ucs_isdigit.map");
print MAP <<EOF;
/*
   File generated from UnicodeData-4.1.0.txt.
*/

EOF

for (<DATA>) {
  chop;
  ($name, $class) = split;
  
  @cp = ();
  
  open(UCD, "< private/UnicodeData-4.1.0.txt");
  while(<UCD>) {
    chop;
    @entry = split(';');
    last if $entry[0] =~ m/.{5,}/;
    if ($entry[2] eq $class) {
      push (@cp, $entry[0]);
    }
  }
  close UCD;

  @bs = ();
  $last = -1;
  $seq = -1;
  for my $e (@cp) {
    if (++$last != hex $e) {
      $seq = $e;
      $last = hex $e;
      push (@bs, $seq);
    }
    $end{$seq} = $e;
  }
  $nobs = @bs;
  
  print MAP <<EOF;

#define N_ucs_${name}_map ${nobs}

static wc_map ucs_${name}_map[ N_ucs_${name}_map ] = {
EOF
  
  for (@bs) {
    print MAP "  { 0x$_, 0x$end{$_} },\n";
  }
  print MAP <<EOF
};
EOF
}

__END__
isdigit Nd