Annotation of embedaddon/libiconv/tools/cjk_variants.c, revision 1.1.1.1
1.1 misho 1: /* Copyright (C) 1999-2002 Free Software Foundation, Inc.
2: This file is part of the GNU LIBICONV Tools.
3:
4: This program is free software: you can redistribute it and/or modify
5: it under the terms of the GNU General Public License as published by
6: the Free Software Foundation; either version 3 of the License, or
7: (at your option) any later version.
8:
9: This program is distributed in the hope that it will be useful,
10: but WITHOUT ANY WARRANTY; without even the implied warranty of
11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: GNU General Public License for more details.
13:
14: You should have received a copy of the GNU General Public License
15: along with this program; if not, write to the Free Software Foundation,
16: Inc., along with this program. If not, see <http://www.gnu.org/licenses/>. */
17:
18: /*
19: * Generates Unicode variants table from Koichi Yasuoka's UniVariants file.
20: */
21:
22: #include <stdio.h>
23: #include <stdlib.h>
24:
25: #define ENTRIES 8176 /* number of lines in UniVariants file */
26: #define MAX_PER_ENTRY 10 /* max number of entries per line in file */
27:
28: int main (int argc, char *argv[])
29: {
30: int variants[MAX_PER_ENTRY*ENTRIES];
31: int uni2index[0x10000];
32: int index;
33:
34: if (argc != 1)
35: exit(1);
36:
37: printf("/*\n");
38: printf(" * Copyright (C) 1999-2002 Free Software Foundation, Inc.\n");
39: printf(" * This file is part of the GNU LIBICONV Library.\n");
40: printf(" *\n");
41: printf(" * The GNU LIBICONV Library is free software; you can redistribute it\n");
42: printf(" * and/or modify it under the terms of the GNU Library General Public\n");
43: printf(" * License as published by the Free Software Foundation; either version 2\n");
44: printf(" * of the License, or (at your option) any later version.\n");
45: printf(" *\n");
46: printf(" * The GNU LIBICONV Library is distributed in the hope that it will be\n");
47: printf(" * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
48: printf(" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n");
49: printf(" * Library General Public License for more details.\n");
50: printf(" *\n");
51: printf(" * You should have received a copy of the GNU Library General Public\n");
52: printf(" * License along with the GNU LIBICONV Library; see the file COPYING.LIB.\n");
53: printf(" * If not, write to the Free Software Foundation, Inc., 51 Franklin Street,\n");
54: printf(" * Fifth Floor, Boston, MA 02110-1301, USA.\n");
55: printf(" */\n");
56: printf("\n");
57: printf("/*\n");
58: printf(" * CJK variants table\n");
59: printf(" */\n");
60: printf("\n");
61: {
62: int c;
63: int j;
64: for (j = 0; j < 0x10000; j++)
65: uni2index[j] = -1;
66: index = 0;
67: for (;;) {
68: c = getc(stdin);
69: if (c == EOF)
70: break;
71: if (c == '#') {
72: do { c = getc(stdin); } while (!(c == EOF || c == '\n'));
73: continue;
74: }
75: ungetc(c,stdin);
76: if (scanf("%x",&j) != 1)
77: exit(1);
78: c = getc(stdin);
79: if (c != '\t')
80: exit(1);
81: uni2index[j] = index;
82: for (;;) {
83: int i;
84: if (scanf("%x",&i) != 1)
85: exit(1);
86: if (!(i >= 0x3000 && i < 0x3000+0x8000))
87: exit(1);
88: variants[index++] = i-0x3000;
89: c = getc(stdin);
90: if (c != ' ')
91: break;
92: }
93: variants[index-1] |= 0x8000; /* end of list marker */
94: if (c != '\n')
95: exit(1);
96: }
97: }
98: printf("static const unsigned short cjk_variants[%d] = {",index);
99: {
100: int i;
101: for (i = 0; i < index; i++) {
102: if ((i % 8) == 0)
103: printf("\n ");
104: printf(" 0x%04x,",variants[i]);
105: }
106: printf("\n};\n");
107: }
108: printf("\n");
109: printf("static const short cjk_variants_indx[0x5200] = {\n");
110: {
111: int j;
112: for (j = 0x4e00; j < 0xa000; j++) {
113: if ((j % 0x100) == 0)
114: printf(" /* 0x%04x */\n", j);
115: if ((j % 8) == 0)
116: printf(" ");
117: printf(" %5d,",uni2index[j]);
118: if ((j % 8) == 7)
119: printf("\n");
120: }
121: printf("};\n");
122: }
123: printf("\n");
124:
125: return 0;
126: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>