Mercurial > emacs
annotate admin/charsets/gb180302.awk @ 102307:1bf9a079b56d
Checked variables.texi.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Fri, 27 Feb 2009 03:59:22 +0000 |
parents | ce88a631c161 |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
100971 | 1 # Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
91416
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 |
94832
eb2d9dfc8486
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91416
diff
changeset
|
4 |
91416
350e1f95b7d0
Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents:
89916
diff
changeset
|
5 # This file is part of GNU Emacs. |
94832
eb2d9dfc8486
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91416
diff
changeset
|
6 |
eb2d9dfc8486
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91416
diff
changeset
|
7 # GNU Emacs is free software: you can redistribute it and/or modify |
91416
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 |
94832
eb2d9dfc8486
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91416
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
eb2d9dfc8486
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91416
diff
changeset
|
10 # (at your option) any later version. |
eb2d9dfc8486
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91416
diff
changeset
|
11 |
91416
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. |
94832
eb2d9dfc8486
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91416
diff
changeset
|
16 |
91416
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 |
94832
eb2d9dfc8486
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91416
diff
changeset
|
18 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
91416
350e1f95b7d0
Add copyright and license notice.
Glenn Morris <rgm@gnu.org>
parents:
89916
diff
changeset
|
19 |
88123 | 20 BEGIN { |
21 tohex["A"] = 10; | |
22 tohex["B"] = 11; | |
23 tohex["C"] = 12; | |
24 tohex["D"] = 13; | |
25 tohex["E"] = 14; | |
26 tohex["F"] = 15; | |
27 tohex["a"] = 10; | |
28 tohex["b"] = 11; | |
29 tohex["c"] = 12; | |
30 tohex["d"] = 13; | |
31 tohex["e"] = 14; | |
32 tohex["f"] = 15; | |
33 from_gb = 0; | |
34 to_gb = -1; | |
35 to_unicode = 0; | |
36 from_unicode = 0; | |
37 } | |
38 | |
39 function decode_hex(str) { | |
40 n = 0; | |
41 len = length(str); | |
42 for (i = 1; i <= len; i++) | |
43 { | |
44 c = substr (str, i, 1); | |
45 if (c >= "0" && c <= "9") | |
46 n = n * 16 + (c - "0"); | |
47 else | |
48 n = n * 16 + tohex[c]; | |
49 } | |
50 return n; | |
51 } | |
52 | |
53 function gb_to_index(gb) { | |
54 b0 = int(gb / 256); | |
55 b1 = gb % 256; | |
56 idx = (((b0 - 129)) * 191 + b1 - 64); | |
57 # if (b1 >= 128) | |
58 # idx--; | |
59 return idx | |
60 } | |
61 | |
62 function index_to_gb(idx) { | |
63 b0 = int(idx / 191) + 129; | |
64 b1 = (idx % 191) + 64; | |
65 # if (b1 >= 127) | |
66 # b1++; | |
67 return (b0 * 256 + b1); | |
68 } | |
69 | |
70 /^\#/ { | |
71 print; | |
72 next; | |
73 } | |
74 | |
75 { | |
76 gb = gb_to_index(decode_hex(substr($1, 3, 4))); | |
77 unicode = decode_hex(substr($2, 3, 4)); | |
78 if ((gb == to_gb + 1) && (unicode == to_unicode + 1)) | |
79 { | |
80 to_gb++; | |
81 to_unicode++; | |
82 } | |
83 else | |
84 { | |
85 if (from_gb == to_gb) | |
86 printf "0x%04X 0x%04X\n", index_to_gb(from_gb), from_unicode; | |
87 else if (from_gb < to_gb) | |
88 printf "0x%04X-0x%04X 0x%04X\n", | |
89 index_to_gb(from_gb), index_to_gb(to_gb), from_unicode; | |
90 from_gb = to_gb = gb; | |
91 from_unicode = to_unicode = unicode; | |
92 } | |
93 } | |
94 | |
95 END { | |
96 if (from_gb <= to_gb) | |
97 printf "0x%04X-0x%04X 0x%04X\n", | |
98 index_to_gb(from_gb), index_to_gb(to_gb), from_unicode; | |
99 } | |
89916
e0e4e6a0599f
Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents:
88123
diff
changeset
|
100 |
e0e4e6a0599f
Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents:
88123
diff
changeset
|
101 # arch-tag: d7dbad89-a512-41a4-8ee0-ba1a4505b8c1 |