Mercurial > freewnn
annotate Wnn/jutil/dtoa.c @ 23:e1aadb6dcbd4
- fixed the build rule for build_stamp.h. keywords in template for hg tip should surrounded by curly braces instead of hash marks.
- fixed usage of libtool in building jlib.V3. newer libtool does not work without mode specifier.
- replaced some libtool related files. (should remove these?)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Fri, 23 Jan 2009 16:36:13 +0900 |
parents | c966456648ad |
children | a7ccf412ba02 |
rev | line source |
---|---|
0 | 1 /* |
2 * $Id: dtoa.c,v 1.9 2005/06/12 17:14:23 aonoto Exp $ | |
3 */ | |
4 | |
5 /* | |
6 * FreeWnn is a network-extensible Kana-to-Kanji conversion system. | |
7 * This file is part of FreeWnn. | |
8 * | |
9 * Copyright Kyoto University Research Institute for Mathematical Sciences | |
10 * 1987, 1988, 1989, 1990, 1991, 1992 | |
11 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999 | |
12 * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992 | |
13 * Copyright FreeWnn Project 1999, 2000, 2002, 2005 | |
14 * | |
15 * Maintainer: FreeWnn Project <freewnn@tomo.gr.jp> | |
16 * | |
17 * This program is free software; you can redistribute it and/or modify | |
18 * it under the terms of the GNU General Public License as published by | |
19 * the Free Software Foundation; either version 2 of the License, or | |
20 * (at your option) any later version. | |
21 * | |
22 * This program is distributed in the hope that it will be useful, | |
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 * GNU General Public License for more details. | |
26 * | |
27 * You should have received a copy of the GNU General Public License | |
28 * along with this program; if not, write to the Free Software | |
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
30 */ | |
31 | |
32 /* | |
33 辞書を ASCII 形式の辞書に変換するプログラム。 | |
34 */ | |
35 | |
36 #ifndef lint | |
37 static char *rcs_id = "$Id: dtoa.c,v 1.9 2005/06/12 17:14:23 aonoto Exp $"; | |
38 #endif /* lint */ | |
39 | |
40 #ifdef HAVE_CONFIG_H | |
41 # include <config.h> | |
42 #endif | |
43 | |
44 #include <stdio.h> | |
45 #if STDC_HEADERS | |
46 # include <stdlib.h> | |
47 # include <string.h> | |
48 #else | |
49 # if HAVE_MALLOC_H | |
50 # include <malloc.h> | |
51 # endif | |
52 # if HAVE_STRINGS_H | |
53 # include <strings.h> | |
54 # endif | |
55 #endif /* STDC_HEADERS */ | |
56 #if HAVE_UNISTD_H | |
57 # include <unistd.h> | |
58 #endif | |
59 | |
60 #include "commonhd.h" | |
61 #include "wnn_config.h" | |
62 #include "jslib.h" | |
63 #include "jh.h" | |
64 #include "jdata.h" | |
65 #include "wnn_string.h" | |
66 #include "wnn_os.h" | |
67 | |
68 #ifdef CONVERT_with_SiSheng | |
69 #include "cplib.h" | |
70 extern int pzy_flag; /* Pinyin or Zhuyin */ | |
71 #endif | |
72 | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
73 /* prototypes */ |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
74 void parse_options(int *argc, char ***argv); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
75 void usage(void); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
76 void input_dic(FILE *ifpter); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
77 void udtoujis(void); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
78 void kset(void); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
79 void sdtoujis(char *hopter, register int level); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
80 void ghindo (int argc, char **argv); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
81 int input_comment (register FILE *fp); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
82 int input_hinsi_list (register FILE *fp); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
83 static int rdtoujis (void); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
84 static int set_hinsi (void); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
85 static int input_hindo (register FILE *ifpter); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
86 static int add_hindo (register FILE *ifpter, int num); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
87 |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
88 /* extern */ |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
89 void sort (void); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
90 void output_ujis (register FILE *opter, int serial_out, int esc_exp); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
91 void exit1 (void); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
92 void init_jeary (void); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
93 void get_kanji_str (UCHAR* kptr, w_char* kanji, w_char* yomi, w_char* comment); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
94 |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
95 int input_header (FILE* ifpter, struct JT* jtp, struct wnn_file_head* fhp); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
96 int little_endian (void); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
97 int revdic (struct JT *jtl, int match); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
98 int wnn_loadhinsi (unsigned char *fname); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
99 int w_stradd (register w_char *str, register w_char **cp); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
100 int motoni2 (int hin); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
101 int init_heap (int hpb, int yhpb, int l, int rl, FILE *ipf); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
102 int input_hindo_header (FILE* ifpter, struct HJT* hjtp, struct wnn_file_head* fhp); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
103 |
0 | 104 #ifdef CONVERT_with_SiSheng |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
105 int cwnn_yincod_pzy (register w_char *pzy_buf, register w_char c, int which); |
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
106 int input_sisheng (register FILE *ifpter); |
0 | 107 #endif |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
108 |
0 | 109 /* Moved from Wnn/etc/bdic.c */ |
110 int get_n_EU_str (FILE* ifpter, int n, w_char* st); | |
111 int get_short (short* sp, FILE* ifpter); | |
112 | |
113 int which_dict; | |
114 | |
115 char *com_name; | |
116 char infile[LINE_SIZE]; | |
117 int esc_expand = 1; | |
118 | |
119 int serial_out = 0; | |
120 int need_sort = 1; | |
121 struct JT jt; | |
122 struct wnn_file_head file_head; | |
123 | |
124 char *hinsi_file_name = NULL; | |
125 | |
126 int | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
127 main (int argc, char **argv) |
0 | 128 { |
129 FILE *ifpter; | |
130 char *cswidth_name; | |
131 extern char *get_cswidth_name (); | |
132 extern void set_cswidth (); | |
133 | |
134 com_name = argv[0]; | |
135 | |
136 if (cswidth_name = get_cswidth_name (WNN_DEFAULT_LANG)) | |
137 set_cswidth (create_cswidth (cswidth_name)); | |
138 parse_options (&argc, &argv); | |
139 | |
140 if ((ifpter = fopen (infile, "r")) == NULL) | |
141 { | |
142 fprintf (stderr, "Can't open the input file %s.\n", infile); | |
143 perror (""); | |
144 exit (1); | |
145 } | |
146 if (input_header (ifpter, &jt, &file_head) == -1) | |
147 exit (1); | |
148 which_dict = jt.syurui; | |
149 input_comment (ifpter); | |
150 input_hinsi_list (ifpter); | |
151 input_dic (ifpter); | |
152 if (little_endian ()) | |
153 { | |
154 revdic (&jt, 0); | |
155 } | |
156 set_hinsi (); | |
157 ghindo (argc - 2, argv + 2); /* Gather Hindo */ | |
158 if (which_dict == WNN_STATIC_DICT) | |
159 { | |
160 kset (); | |
161 sdtoujis (jt.hontai, 0); | |
162 #ifdef CHINESE | |
163 } | |
164 else if ((which_dict & 0x00ff) == WNN_REV_DICT) | |
165 { | |
166 #else | |
167 } | |
168 else if (which_dict == WNN_REV_DICT) | |
169 { | |
170 #endif | |
171 rdtoujis (); | |
172 } | |
173 else | |
174 { | |
175 udtoujis (); | |
176 } | |
177 if (need_sort) | |
178 { | |
179 sort (); | |
180 } | |
181 output_ujis (stdout, serial_out, esc_expand); | |
182 exit (0); | |
183 } | |
184 | |
185 | |
186 void | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
187 parse_options (int *argc, char ***argv) |
0 | 188 { |
189 int c; | |
190 extern int optind; | |
191 extern char *optarg; | |
192 | |
193 #ifdef CONVERT_with_SiSheng | |
194 # define OPTSTRING "nseEzh:" | |
195 #else | |
196 # define OPTSTRING "nseEh:" | |
197 #endif | |
198 | |
199 while ((c = getopt (*argc, *argv, OPTSTRING)) != EOF) | |
200 { | |
201 switch (c) | |
202 { | |
203 case 'n': | |
204 need_sort = 0; | |
205 break; | |
206 case 's': | |
207 serial_out = 1; | |
208 break; | |
209 case 'e': | |
210 esc_expand = 1; | |
211 break; | |
212 case 'E': | |
213 esc_expand = 0; | |
214 break; | |
215 case 'h': | |
216 hinsi_file_name = optarg; | |
217 break; | |
218 #ifdef CONVERT_with_SiSheng | |
219 case 'z': | |
220 pzy_flag = CWNN_ZHUYIN; | |
221 break; | |
222 #endif | |
223 default: | |
224 usage (); | |
225 } | |
226 } | |
227 if (optind) | |
228 { | |
229 optind--; | |
230 *argc -= optind; | |
231 *argv += optind; | |
232 } | |
233 if (*argc < 2) | |
234 { | |
235 usage (); | |
236 } | |
237 strcpy (infile, (*argv)[1]); | |
238 if (wnn_loadhinsi (hinsi_file_name) != 0) | |
239 { | |
240 fprintf (stderr, "Can't Open hinsi_file.\n"); | |
241 exit (1); | |
242 } | |
243 } | |
244 | |
245 | |
246 void | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
247 usage (void) |
0 | 248 { |
249 fprintf (stderr, "Usage: %s [-nse -h hinsi_file_name] <dictionary file> <hindo file>*\n", com_name); | |
250 fprintf (stderr, "Output the Text dictionary to stdout\n"); | |
251 #ifdef CONVERT_with_SiSheng | |
252 fprintf (stderr, "-z : Output Zhuyin (Default is Pinyin)\n"); | |
253 #endif | |
254 exit1 (); | |
255 } | |
256 | |
257 void | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
258 input_dic (FILE *ifpter) |
0 | 259 { |
260 | |
261 init_heap (0, /* jt.maxkanji, */ | |
262 jt.maxserial * YOMI_PER_LINE * 5, /* may be enough */ | |
263 jt.maxserial, jt.maxserial, stdin); | |
264 jt.table = (struct uind1 *) malloc (jt.maxtable * sizeof (struct uind1)); | |
265 jt.hontai = (UCHAR *) malloc (jt.maxhontai); | |
266 jt.ri1[D_YOMI] = (struct rind1 *) malloc (jt.maxri1[D_YOMI] * sizeof (struct rind1)); | |
267 jt.ri1[D_KANJI] = (struct rind1 *) malloc (jt.maxri1[D_KANJI] * sizeof (struct rind1)); | |
268 jt.kanji = (UCHAR *) malloc (jt.maxkanji + 1); | |
269 jt.ri2 = (struct rind2 *) malloc (jt.maxserial * sizeof (struct rind2)); | |
270 jt.hinsi = (w_char *) malloc (jt.maxserial * sizeof (w_char)); | |
271 if (!jt.table || !jt.hontai || !jt.ri1[D_YOMI] || !jt.ri1[D_KANJI] || !jt.kanji || !jt.ri2 || !jt.hinsi) | |
272 { | |
273 fprintf (stderr, "Malloc Failed.\n"); | |
274 exit (1); | |
275 } | |
276 init_jeary (); | |
277 | |
278 input_hindo (ifpter); | |
279 fread (jt.hinsi, 2, jt.maxserial, ifpter); | |
280 #ifdef CONVERT_with_SiSheng | |
281 if (which_dict == CWNN_REV_DICT) | |
282 input_sisheng (ifpter); | |
283 #endif | |
284 fread (jt.kanji, 1, jt.maxkanji, ifpter); | |
285 /* input_kanji(ifpter); */ | |
286 fread (jt.table, sizeof (struct uind1), jt.maxtable, ifpter); | |
287 fread (jt.ri1[D_YOMI], sizeof (struct rind1), jt.maxri1[D_YOMI], ifpter); | |
288 fread (jt.ri1[D_KANJI], sizeof (struct rind1), jt.maxri1[D_KANJI], ifpter); | |
289 fread (jt.hontai, 1, jt.maxhontai, ifpter); | |
290 fread (jt.ri2, sizeof (struct rind2), jt.maxserial, ifpter); | |
291 } | |
292 | |
293 void | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
294 udtoujis (void) |
0 | 295 { |
296 | |
297 w_char yomi[LENGTHYOMI]; /* 2 byte yomi */ | |
298 w_char kan[LENGTHYOMI]; /* 2 byte kanji */ | |
299 w_char comm[LENGTHYOMI]; | |
300 w_char ryomi[LENGTHYOMI]; | |
301 register struct uind2 *hop; | |
302 register int i, k; | |
303 register int serial; | |
304 int len; | |
305 UCHAR *c; | |
306 | |
307 for (i = 0; i < jt.maxtable; i++) | |
308 { | |
309 for (hop = (struct uind2 *) (jt.table[i].pter + (char *) jt.hontai); hop != (struct uind2 *) jt.hontai; hop = (struct uind2 *) (hop->next + (char *) jt.hontai)) | |
310 { | |
311 /* Though each hop has the same yomi, but calculate yomi each time. */ | |
312 yomi[0] = jt.table[i].yomi1 >> 16; | |
313 yomi[1] = jt.table[i].yomi1 & 0xffff; | |
314 if (yomi[1]) | |
315 { | |
316 yomi[2] = jt.table[i].yomi2 >> 16; | |
317 if (yomi[2]) | |
318 { | |
319 yomi[3] = jt.table[i].yomi2 & 0xffff; | |
320 } | |
321 } | |
322 len = hop->yomi[0]; | |
323 wnn_Strncpy (yomi + 4, (hop->yomi) + 1, len - 4); | |
324 yomi[len] = 0; | |
325 serial = hop->serial; | |
326 for (k = hop->kosuu, c = hop->kanjipter + jt.kanji; k > 0; k--, serial++) | |
327 { | |
328 get_kanji_str (c, kan, NULL, comm); | |
329 jeary[serial]->kanji = c; | |
330 c += *c; | |
331 jeary[serial]->serial = serial; | |
332 #ifdef CONVERT_with_SiSheng | |
333 wnn_Strcpy (ryomi, yomi); | |
334 #else | |
335 wnn_Sreverse (ryomi, yomi); | |
336 #endif | |
337 w_stradd (ryomi, &jeary[serial]->yomi); | |
338 w_stradd (kan, &jeary[serial]->kan); | |
339 w_stradd (comm, &jeary[serial]->comm); | |
340 } | |
341 } | |
342 } | |
343 } | |
344 | |
345 /* SD routine */ | |
346 | |
347 w_char yomi[LENGTHYOMI]; | |
348 int je = 0; | |
349 | |
350 void | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
351 kset (void) |
0 | 352 { |
353 int i; | |
354 UCHAR *c; | |
355 w_char kan[LENGTHYOMI]; /* 2 byte kanji */ | |
356 w_char comm[LENGTHYOMI]; /* 2 byte kanji */ | |
357 | |
358 | |
359 c = jt.kanji; | |
360 for (i = 0; i < jt.maxserial; i++) | |
361 { | |
362 get_kanji_str (c, kan, NULL, comm); | |
363 w_stradd (kan, &jeary[i]->kan); | |
364 w_stradd (comm, &jeary[i]->comm); | |
365 jeary[i]->kanji = c; | |
366 c += *c; | |
367 } | |
368 } | |
369 | |
370 void | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
371 sdtoujis (char *hopter, register int level) |
0 | 372 { |
373 register int k, j; | |
374 register int tsize; | |
375 register w_char *charst; | |
376 register w_char *sumst; | |
377 int *ptrst; | |
378 static w_char ry[LENGTHYOMI]; | |
379 | |
380 yomi[level + 1] = 0; | |
381 switch (*(w_char *) hopter) | |
382 { | |
383 case ST_NORMAL: | |
384 tsize = *(w_char *) (hopter + 2); | |
385 charst = (w_char *) (hopter + 12); | |
386 sumst = ((w_char *) charst + tsize + 2); /* + 2 keeps two zero words */ | |
387 ptrst = (int *) ((w_char *) sumst + tsize); | |
388 for (k = 0; k < tsize; k++) | |
389 { | |
390 j = sumst[k] - sumst[k - 1]; | |
391 if (j) | |
392 { | |
393 yomi[level] = charst[k]; | |
394 for (; j > 0; j--) | |
395 { | |
396 jeary[je]->serial = je; | |
397 #ifdef CONVERT_with_SiSheng | |
398 wnn_Strcpy (ry, yomi); | |
399 #else | |
400 wnn_Sreverse (ry, yomi); | |
401 #endif | |
402 w_stradd (ry, &jeary[je++]->yomi); | |
403 } | |
404 } | |
405 } | |
406 for (k = 0; k < tsize; k++) | |
407 { | |
408 if (ptrst[k] != ENDPTR) | |
409 { | |
410 yomi[level] = charst[k]; | |
411 sdtoujis ((char *) jt.hontai + ptrst[k], level + 1); | |
412 } | |
413 } | |
414 break; | |
415 case ST_NOENT: | |
416 tsize = *(w_char *) (hopter + 2); | |
417 charst = (w_char *) (hopter + 4); | |
418 ptrst = (int *) AL_INT ((w_char *) charst + tsize); | |
419 for (k = 0; k < tsize; k++) | |
420 { | |
421 if (ptrst[k] != ENDPTR) | |
422 { | |
423 yomi[level] = charst[k]; | |
424 sdtoujis ((char *) jt.hontai + ptrst[k], level + 1); | |
425 } | |
426 } | |
427 break; | |
428 case ST_NOPTER: | |
429 tsize = *(w_char *) (hopter + 2); | |
430 charst = (w_char *) (hopter + 12); | |
431 sumst = ((w_char *) charst + tsize + 2); /* + 2 keeps two zero words */ | |
432 for (k = 0; k < tsize; k++) | |
433 { | |
434 j = sumst[k] - sumst[k - 1]; | |
435 if (j) | |
436 { | |
437 yomi[level] = charst[k]; | |
438 for (; j > 0; j--) | |
439 { | |
440 jeary[je]->serial = je; | |
441 #ifdef CONVERT_with_SiSheng | |
442 wnn_Strcpy (ry, yomi); | |
443 #else | |
444 wnn_Sreverse (ry, yomi); | |
445 #endif | |
446 w_stradd (ry, &jeary[je++]->yomi); | |
447 } | |
448 } | |
449 } | |
450 break; | |
451 case ST_SMALL: | |
452 yomi[level] = *(w_char *) (hopter + 2); | |
453 sdtoujis (hopter + 4, level + 1); | |
454 break; | |
455 } | |
456 } | |
457 | |
458 static int | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
459 rdtoujis (void) |
0 | 460 { |
461 w_char yomi[LENGTHYOMI]; /* 2 byte yomi */ | |
462 w_char kan[LENGTHYOMI]; /* 2 byte yomi */ | |
463 w_char comm[LENGTHYOMI]; /* 2 byte yomi */ | |
464 register struct rind2 *hop; | |
465 register int hopi; | |
466 register int i; | |
467 register int serial; | |
468 | |
469 for (i = 0; i < jt.maxri1[D_YOMI]; i++) | |
470 { | |
471 for (hopi = jt.ri1[D_YOMI][i].pter; hopi != RD_ENDPTR; hopi = hop->next[D_YOMI]) | |
472 { | |
473 hop = hopi + jt.ri2; | |
474 /* Though each hop has the same yomi, but calculate yomi each time. */ | |
475 get_kanji_str (hop->kanjipter + jt.kanji, kan, yomi, comm); | |
476 #ifdef CONVERT_with_SiSheng | |
477 cwnn_yincod_pzy_str (yomi, yomi, wnn_Strlen (yomi), pzy_flag); | |
478 #endif | |
479 serial = hopi; | |
480 jeary[serial]->kanji = hop->kanjipter + jt.kanji; | |
481 jeary[serial]->serial = serial; | |
482 | |
483 w_stradd (yomi, &jeary[serial]->yomi); | |
484 w_stradd (kan, &jeary[serial]->kan); | |
485 w_stradd (comm, &jeary[serial++]->comm); | |
486 } | |
487 } | |
488 return (0); | |
489 } | |
490 | |
491 void | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
492 ghindo (int argc, char **argv) |
0 | 493 { |
494 FILE *fp; | |
495 struct wnn_file_head h_file_head; | |
496 struct HJT hjt; | |
497 | |
498 | |
499 while (argc-- > 0) | |
500 { | |
501 if ((fp = fopen (*argv++, "r")) == NULL) | |
502 { | |
503 fprintf (stderr, "can't open %s\n", *(argv - 1)); | |
504 perror ("error in ghindo"); | |
505 exit (1); | |
506 } | |
507 if (input_hindo_header (fp, &hjt, &h_file_head) == -1) | |
508 { | |
509 perror ("error in ghindo 1"); | |
510 exit (1); | |
511 } | |
512 if (bcmp (&file_head.file_uniq_org, &hjt.dic_file_uniq, sizeof (struct wnn_file_uniq))) | |
513 { | |
514 fprintf (stderr, "%s(%s)Dic File and Hindo File mismatch.\n", infile, *(argv - 1)); | |
515 exit (1); | |
516 } | |
517 add_hindo (fp, hjt.maxserial); | |
518 } | |
519 } | |
520 | |
521 static int | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
522 add_hindo (register FILE *ifpter, int num) |
0 | 523 { |
524 register int i; | |
525 register int k; | |
526 for (i = 0; i < num; i++) | |
527 { | |
528 jeary[i]->hindo += motoni2 ((k = getc (ifpter)) & 0x7f); | |
529 if (k == -1) | |
530 return (-1); | |
531 } | |
532 return (0); | |
533 } | |
534 | |
535 /* input dict routines */ | |
536 | |
537 int | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
538 input_comment (register FILE *fp) |
0 | 539 { |
540 return (get_n_EU_str (fp, jt.maxcomment, file_comment)); | |
541 } | |
542 | |
543 int | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
544 input_hinsi_list (register FILE *fp) |
0 | 545 { |
546 return (get_n_EU_str (fp, jt.maxhinsi_list, hinsi_list)); | |
547 } | |
548 | |
549 | |
550 static int | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
551 input_hindo (register FILE *ifpter) |
0 | 552 { |
553 register int i; | |
554 register int k; | |
555 for (i = 0; i < jt.maxserial; i++) | |
556 { | |
557 jeary[i]->hindo = motoni2 ((k = getc (ifpter)) & 0x7f); | |
558 if (k == -1) | |
559 return (-1); | |
560 } | |
561 return (0); | |
562 } | |
563 | |
564 static int | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
565 set_hinsi (void) |
0 | 566 { |
567 register int i; | |
568 | |
569 for (i = 0; i < jt.maxserial; i++) | |
570 { | |
571 jeary[i]->hinsi = jt.hinsi[i]; | |
572 } | |
573 return (0); | |
574 } | |
575 | |
576 #ifdef CONVERT_with_SiSheng | |
577 int | |
22
c966456648ad
- fixed argument style in function definition
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
0
diff
changeset
|
578 input_sisheng (register FILE *ifpter) |
0 | 579 { |
580 register int i; | |
581 unsigned short s; | |
582 | |
583 for (i = 0; i < jt.maxserial; i++) | |
584 { | |
585 if (get_short (&s, ifpter) == -1) | |
586 return (-1); | |
587 jeary[i]->ss = s; | |
588 } | |
589 return (0); | |
590 } | |
591 | |
592 #endif | |
593 | |
594 int | |
595 get_n_EU_str (FILE* ifpter, int n, w_char* st) | |
596 { | |
597 int k; | |
598 | |
599 for (; n; n--) | |
600 { | |
601 k = get_short ((short *) st++, ifpter); | |
602 if (k == -1) | |
603 return (-1); | |
604 } | |
605 return (0); | |
606 } | |
607 | |
608 int | |
609 get_short (short* sp, FILE* ifpter) | |
610 { | |
611 int i = 0; | |
612 int k; | |
613 | |
614 i |= (k = getc (ifpter)) << 8; | |
615 if (k == -1) | |
616 return (-1); | |
617 i |= (k = getc (ifpter)); | |
618 if (k == -1) | |
619 return (-1); | |
620 *sp = i; | |
621 return (0); | |
622 } |