]> code.delx.au - gnu-emacs/blob - admin/unidata/biditype.awk
Convert consecutive FSF copyright years to ranges.
[gnu-emacs] / admin / unidata / biditype.awk
1 # Generate data for filling bidi_type_table, see src/bidi.c:bidi_initialize.
2
3 # Copyright (C) 2010-2011 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 }