comparison admin/unidata/biditype.awk @ 108984:684f6b36230b

Use Unicode database for attribute tables in bidi.c. admin/unidata/bidimirror.awk: New file. admin/unidata/BidiMirroring.txt: New file from http://www.unicode.org/Public/6.0.0/ucd/BidiMirroring-6.0.0d1.txt. admin/unidata/Makefile.in: (../../src/bidimirror.h): New target. (all): Depend on ../../src/biditype.h and ../../src/bidimirror.h. admin/unidata/makefile.w32-in (../../src/bidimirror.h): New target. (all): Depend on ../../src/biditype.h and ../../src/bidimirror.h. admin/unidata/biditype.awk: New file. admin/unidata/Makefile.in (../../src/biditype.h): New target. admin/unidata/makefile.w32-in (../../src/biditype.h): New target. src/makefile.w32-in ($(BLD)/bidi.$(O)): Depend on biditype.h and bidimirror.h. src/deps.mk (bidi.o): Depend on biditype.h and bidimirror.h. src/bidi.c (bidi_initialize): Remove explicit initialization of bidi_type_table; include biditype.h instead. Don't support entries whose second codepoint is zero. Initialize bidi_mirror_table. (bidi_mirror_char): Use bidi_mirror_table. src/biditype.h: New file. src/bidimirror.h: New file.
author Eli Zaretskii <eliz@gnu.org>
date Sun, 13 Jun 2010 20:40:25 +0300
parents 7e588bac2220
children 6378d1b57038
comparison
equal deleted inserted replaced
108981:b7963ca9e06e 108984:684f6b36230b
1 # Generate data for filling bidi_type_table, see src/bidi.c:bidi_initialize.
2
3 # Copyright (C) 2010, Free Software Foundation, Inc.
4
5 # This file is part of GNU Emacs.
6
7 # GNU Emacs is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11
12 # GNU Emacs is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19
20 # Written by Eli Zaretskii <eliz@gnu.org>
21
22 function trtype(type)
23 {
24 # Types are listed in the order of decresing use in UnicodeData.txt:
25 if (type == "ON")
26 return "NEUTRAL_ON";
27 else if (type == "NSM")
28 return "WEAK_NSM";
29 else if (type == "AL")
30 return "STRONG_AL";
31 else if (type == "R")
32 return "STRONG_R";
33 else if (type == "BN")
34 return "WEAK_BN";
35 else if (type == "EN")
36 return "WEAK_EN";
37 else if (type == "ET")
38 return "WEAK_ET";
39 else if (type == "AN")
40 return "WEAK_AN";
41 else if (type == "WS")
42 return "NEUTRAL_WS";
43 else if (type == "CS")
44 return "WEAK_CS";
45 else if (type == "ES")
46 return "WEAK_ES";
47 else if (type == "B")
48 return "NEUTRAL_B";
49 else if (type == "S")
50 return "NEUTRAL_S";
51 else if (type == "LRE" || type == "RLE" || type == "LRO" || type == "RLO" || type == "PDF")
52 return type;
53 else if (type == "L")
54 return "STRONG_L";
55 else
56 {
57 printf "Unknown type: %s\n", type > "/dev/stderr";
58 exit 1;
59 }
60 }
61
62 BEGIN {
63 otype = "";
64 startcode = "";
65 endcode = "";
66 printf " struct {\n int from, to;\n bidi_type_t type;\n } bidi_type[] = {\n";
67 first = 1;
68 }
69
70 { code = $1;
71 ntype = $5;
72 if (ntype != otype)
73 {
74 # Don't output data for L, as that's the default value, see bidi.c.
75 if (otype != "L" && startcode != "")
76 {
77 if (!first)
78 printf ",\n";
79 else
80 first = 0;
81 printf "\t{ 0x%s, 0x%s, %s }", startcode, endcode, trtype(otype);
82 }
83 otype = ntype;
84 startcode = code;
85 endcode = code;
86 }
87 else
88 endcode = code;
89 }
90
91 END {
92 printf " };\n";
93 }