annotate admin/charsets/gb180302.awk @ 93759:4e76a03232e5

Merge from emacs--rel--22 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1107
author Miles Bader <miles@gnu.org>
date Sat, 05 Apr 2008 23:01:26 +0000
parents 350e1f95b7d0
children eb2d9dfc8486
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
91416
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
1 # Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
2 # National Institute of Advanced Industrial Science and Technology (AIST)
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
3 # Registration Number H13PRO009
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
4 #
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
5 # This file is part of GNU Emacs.
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
6 #
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
7 # GNU Emacs is free software; you can redistribute it and/or modify
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
8 # it under the terms of the GNU General Public License as published by
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
9 # the Free Software Foundation; either version 3, or (at your option)
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
10 # any later version.
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
11 #
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
12 # GNU Emacs is distributed in the hope that it will be useful,
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
15 # GNU General Public License for more details.
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
16 #
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
17 # You should have received a copy of the GNU General Public License
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
18 # along with GNU Emacs; see the file COPYING. If not, write to the
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
19 # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
20 # Boston, MA 02110-1301, USA.
350e1f95b7d0 Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents: 89916
diff changeset
21
88123
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
22 BEGIN {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
23 tohex["A"] = 10;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
24 tohex["B"] = 11;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
25 tohex["C"] = 12;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26 tohex["D"] = 13;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
27 tohex["E"] = 14;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28 tohex["F"] = 15;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29 tohex["a"] = 10;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
30 tohex["b"] = 11;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31 tohex["c"] = 12;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
32 tohex["d"] = 13;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33 tohex["e"] = 14;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34 tohex["f"] = 15;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
35 from_gb = 0;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
36 to_gb = -1;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37 to_unicode = 0;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
38 from_unicode = 0;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
41 function decode_hex(str) {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
42 n = 0;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
43 len = length(str);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
44 for (i = 1; i <= len; i++)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
45 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
46 c = substr (str, i, 1);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
47 if (c >= "0" && c <= "9")
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
48 n = n * 16 + (c - "0");
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
49 else
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
50 n = n * 16 + tohex[c];
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
51 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
52 return n;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
53 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
54
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
55 function gb_to_index(gb) {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
56 b0 = int(gb / 256);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
57 b1 = gb % 256;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
58 idx = (((b0 - 129)) * 191 + b1 - 64);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
59 # if (b1 >= 128)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
60 # idx--;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
61 return idx
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
62 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
63
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
64 function index_to_gb(idx) {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
65 b0 = int(idx / 191) + 129;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
66 b1 = (idx % 191) + 64;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
67 # if (b1 >= 127)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
68 # b1++;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
69 return (b0 * 256 + b1);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
70 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
71
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
72 /^\#/ {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
73 print;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
74 next;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
75 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
76
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
77 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
78 gb = gb_to_index(decode_hex(substr($1, 3, 4)));
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
79 unicode = decode_hex(substr($2, 3, 4));
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
80 if ((gb == to_gb + 1) && (unicode == to_unicode + 1))
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
81 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
82 to_gb++;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
83 to_unicode++;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
84 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
85 else
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
86 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
87 if (from_gb == to_gb)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
88 printf "0x%04X 0x%04X\n", index_to_gb(from_gb), from_unicode;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
89 else if (from_gb < to_gb)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
90 printf "0x%04X-0x%04X 0x%04X\n",
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
91 index_to_gb(from_gb), index_to_gb(to_gb), from_unicode;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
92 from_gb = to_gb = gb;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
93 from_unicode = to_unicode = unicode;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
94 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
95 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
96
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
97 END {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
98 if (from_gb <= to_gb)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
99 printf "0x%04X-0x%04X 0x%04X\n",
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
100 index_to_gb(from_gb), index_to_gb(to_gb), from_unicode;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
101 }
89916
e0e4e6a0599f Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents: 88123
diff changeset
102
e0e4e6a0599f Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents: 88123
diff changeset
103 # arch-tag: d7dbad89-a512-41a4-8ee0-ba1a4505b8c1