Upgrade to libtool-1.4.
[libiconv.git] / tools / cjk_variants.c
blobf9e7e6d0bee76813d4388d2a8720607bcd52754f
1 /* Copyright (C) 1999-2001 Free Software Foundation, Inc.
2 This file is part of the GNU LIBICONV Tools.
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 2, or (at your option)
7 any later version.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19 * Generates Unicode variants table from Koichi Yasuoka's UniVariants file.
22 #include <stdio.h>
23 #include <stdlib.h>
25 #define ENTRIES 8176 /* number of lines in UniVariants file */
26 #define MAX_PER_ENTRY 10 /* max number of entries per line in file */
28 int main (int argc, char *argv[])
30 int variants[MAX_PER_ENTRY*ENTRIES];
31 int uni2index[0x10000];
32 int index;
34 if (argc != 1)
35 exit(1);
37 printf("/*\n");
38 printf(" * Copyright (C) 1999-2001 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., 59 Temple Place -\n");
54 printf(" * Suite 330, Boston, MA 02111-1307, USA.\n");
55 printf(" */\n");
56 printf("\n");
57 printf("/*\n");
58 printf(" * CJK variants table\n");
59 printf(" */\n");
60 printf("\n");
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;
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;
93 variants[index-1] |= 0x8000; /* end of list marker */
94 if (c != '\n')
95 exit(1);
98 printf("static const unsigned short cjk_variants[%d] = {",index);
100 int i;
101 for (i = 0; i < index; i++) {
102 if ((i % 8) == 0)
103 printf("\n ");
104 printf(" 0x%04x,",variants[i]);
106 printf("\n};\n");
108 printf("\n");
109 printf("static const short cjk_variants_indx[0x5200] = {\n");
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");
121 printf("};\n");
123 printf("\n");
125 return 0;