OSDN Git Service

Forgot to update ltjclasses.dtx
[luatex-ja/luatexja.git] / tool / ltj-unicode-ccfix_make2.pl
1 #!/usr/bin/env perl
2
3 # create ltj-unicode-ccfix.tex by processing Unicode data file
4 #       LineBreak.txt
5
6 # modified from unicode-char-prep.pl (part of the XeTeX typesetting system).
7 # original copyright is as follows:
8 #
9 # /****************************************************************************\
10 #  Part of the XeTeX typesetting system
11 #  Copyright (c) 1994-2008 by SIL International
12 #  Copyright (c) 2009 by Jonathan Kew
13
14 #  SIL Author(s): Jonathan Kew
15
16 # Permission is hereby granted, free of charge, to any person obtaining
17 # a copy of this software and associated documentation files (the
18 # "Software"), to deal in the Software without restriction, including
19 # without limitation the rights to use, copy, modify, merge, publish,
20 # distribute, sublicense, and/or sell copies of the Software, and to
21 # permit persons to whom the Software is furnished to do so, subject to
22 # the following conditions:
23
24 # The above copyright notice and this permission notice shall be
25 # included in all copies or substantial portions of the Software.
26
27 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 # NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
31 # FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
32 # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34
35 # Except as contained in this notice, the name of the copyright holders
36 # shall not be used in advertising or otherwise to promote the sale,
37 # use or other dealings in this Software without prior written
38 # authorization from the copyright holders.
39 # \****************************************************************************/
40
41 die "usage: perl $0 LineBreak.txt > unicode-letters.tex\n"
42         unless $#ARGV == 0;
43
44 sub parse_unidata {
45         my (@u) = @_;
46         $lccode{$u[0]} = $u[13] if $u[13] ne '';
47         $lccode{$u[0]} = $u[0]  if $u[13] eq '' and ($u[2] =~ /^L/ or $u[12] ne '');
48         $uccode{$u[0]} = $u[12] if $u[12] ne '';
49         $uccode{$u[0]} = $u[0]  if $u[12] eq '' and ($u[2] =~ /^L/ or $u[13] ne '');
50         if ($u[2] =~ /^L/) {
51                 push(@letters, $u[0]);
52         }
53         elsif ($u[2] =~ /^M/) {
54                 push(@marks, $u[0]);
55         }
56         elsif (exists $lccode{$u[0]} or exists $uccode{$u[0]}) {
57                 push(@casesym, $u[0]);
58         }
59 }
60
61
62 my ($start, $end);
63 $date = `date`;
64 chomp $date;
65 print << "__EOT__";
66 -- Do not edit this file!
67 -- Created from LineBreak.txt by ltj-unicode-ccfix_make.pl on $date.
68 -- In case of errors, fix the Perl script instead.
69 __EOT__
70
71 %lineBreakClass = (
72         'ID' => 1,              # ideograph
73 );
74
75
76 print << '__EOT__';
77 local tex_catcode = tex.setcatcode
78 local tex_getcc = tex.getcatcode
79 local function set_letter(b,e)
80   if tex_getcc(b)~=11 then
81     for i=b,e do tex_catcode('global', i, 11) end
82   end
83 end
84 __EOT__
85
86 open LineBreak, $ARGV[0] or die "can't read $ARGV[0]";
87 while (<LineBreak>) {
88         chomp;
89         s/ *#.*//;
90         s/ +$//;
91         if (m/([0-9A-F]{4,6})(?:\.\.([0-9A-F]{4,6}))?;(..)/) {
92                 $s = $1;
93                 $e = $2;
94                 $lb = $3;
95                 $e = $s if $e eq '';
96                 if (exists $lineBreakClass{$lb}) {
97                         if ($lineBreakClass{$lb} == 1) {
98                                 # ideographs: set whole range to class 1
99                                 print "set_letter(0x$s,0x$e)\n";
100                         }
101                 }
102         }
103 }
104 close LineBreak;
105
106 print << '__EOT__';
107 __EOT__