0
|
1 /*
|
|
2 * $Id: rk_bltinfn.c,v 1.2 2001/06/14 18:16:09 ura 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 *
|
|
14 * Author: OMRON SOFTWARE Co., Ltd. <freewnn@rd.kyoto.omronsoft.co.jp>
|
|
15 *
|
|
16 * This program is free software; you can redistribute it and/or modify
|
|
17 * it under the terms of the GNU General Public License as published by
|
|
18 * the Free Software Foundation; either version 2, or (at your option)
|
|
19 * any later version.
|
|
20 *
|
|
21 * This program is distributed in the hope that it will be useful,
|
|
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
24 * GNU General Public License for more details.
|
|
25 *
|
|
26 * You should have received a copy of the GNU General Public License
|
|
27 * along with GNU Emacs; see the file COPYING. If not, write to the
|
|
28 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
29 *
|
|
30 * Commentary:
|
|
31 *
|
|
32 * Change log:
|
|
33 *
|
|
34 * Last modified date: 8,Feb.1999
|
|
35 *
|
|
36 * Code:
|
|
37 *
|
|
38 */
|
|
39 /***********************************************************************
|
|
40 rk_bltinfn.c
|
|
41 87.12. 6 Äû Êä
|
|
42
|
|
43 ÊÑ´¹ÍѤÎÁȤ߹þ¤ß´Ø¿ô¤Î¤¦¤ÁÊ£»¨¤Ê¤â¤Î¤òÄêµÁ¤·¤Æ¤¢¤ë¡£
|
|
44 Á´³Ñ¢«¢ªÈ¾³Ñ¤ÎÊÑ´¹¤¬¼çÂΡ£
|
|
45 ***********************************************************************/
|
|
46 /* Version 3.1 88/06/14 H.HASHIMOTO
|
|
47 */
|
|
48 #ifndef OMRON_LIB
|
|
49 #include "rk_header.h"
|
|
50 #endif
|
|
51 #include "rext.h"
|
|
52
|
|
53 /* Ⱦ³Ñʸ»ú¤Î¥³¡¼¥É¤Îdefine */
|
|
54 #define HKCHOU (SS2 * 0x100 + 0xB0) /* ¨° */
|
|
55 #define HKDKTN (SS2 * 0x100 + 0xDE) /* ¨Þ */
|
|
56 #define HKHNDK (SS2 * 0x100 + 0xDF) /* ¨ß */
|
|
57 #define HKMARU (SS2 * 0x100 + 0xA1) /* ¨¡ */
|
|
58 #define HKHRKG (SS2 * 0x100 + 0xA2) /* ¨¢ */
|
|
59 #define HKTJKG (SS2 * 0x100 + 0xA3) /* ¨£ */
|
|
60 #define HKTTEN (SS2 * 0x100 + 0xA4) /* ¨¤ */
|
|
61 #define HKNKPT (SS2 * 0x100 + 0xA5) /* ¨¥ */
|
|
62
|
|
63 /* Á´³Ñʸ»ú¤Î¥³¡¼¥É¤Îdefine */
|
|
64 #define CHOUON (0xA1BC) /* ¡¼ */
|
|
65 #define DAKUTN (0xA1AB) /* ¡« */
|
|
66 #define HNDAKU (0xA1AC) /* ¡¬ */
|
|
67 #define MNMARU (0xA1A3) /* ¡£ */ /* ̾Á°¤Ï MaNMARU¡Ê¤Þ¤ó¤Þ¤ë¡Ë¤Îά */
|
|
68 #define HRKKAG (0xA1D6) /* ¡Ö */
|
|
69 #define TJIKAG (0xA1D7) /* ¡× */
|
|
70 #define TOUTEN (0xA1A2) /* ¡¢ */
|
|
71 #define NKPOTU (0xA1A6) /* ¡¦ */
|
|
72
|
|
73
|
|
74 /** ASCIIʸ»ú¢ªÁ´³Ñ */
|
|
75 #ifdef OMRON_LIB
|
|
76 static
|
|
77 #endif
|
|
78 letter
|
|
79 to_zenalpha (l)
|
|
80 fast letter l; /* V3.1 */
|
|
81 {
|
|
82 fast letter retval; /* V3.1 */
|
|
83
|
|
84 static uns_chr *data = (uns_chr *) "¡¡¡ª¡É¡ô¡ð¡ó¡õ¡Ç¡Ê¡Ë¡ö¡Ü¡¤¡Ý¡¥¡¿£°£±£²£³£´£µ£¶£·£¸£¹¡§¡¨¡ã¡á¡ä¡©\
|
|
85 ¡÷£Á£Â£Ã£Ä£Å£Æ£Ç£È£É£Ê£Ë£Ì£Í£Î£Ï£Ð£Ñ£Ò£Ó£Ô£Õ£Ö£×£Ø£Ù£Ú¡Î¡ï¡Ï¡°¡²¡®£á£â£ã£ä£å\
|
|
86 £æ£ç£è£é£ê£ë£ì£í£î£ï£ð£ñ£ò£ó£ô£õ£ö£÷£ø£ù£ú¡Ð¡Ã¡Ñ¡±";
|
|
87
|
|
88 if (' ' <= l && l <= '~')
|
|
89 {
|
|
90 l = (l - ' ') << 1;
|
|
91 retval = data[l] << 8;
|
|
92 retval += data[++l];
|
|
93 return (retval);
|
|
94 /* } else return(l); *//* V3.1 */
|
|
95 }
|
|
96 return (l);
|
|
97 }
|
|
98
|
|
99 static char *hankdata[] = {
|
|
100 "Ž§", "Ž±", "Ž¨", "Ž²", "Ž©", "Ž³", "Žª", "Ž´", "Ž«", "Žµ",
|
|
101 "Ž¶", "Ž¶ŽÞ", "Ž·", "Ž·ŽÞ", "Ž¸", "Ž¸ŽÞ", "Ž¹", "Ž¹ŽÞ", "Žº", "ŽºŽÞ",
|
|
102 "Ž»", "Ž»ŽÞ", "Ž¼", "Ž¼ŽÞ", "Ž½", "Ž½ŽÞ", "Ž¾", "Ž¾ŽÞ", "Ž¿", "Ž¿ŽÞ",
|
|
103 "ŽÀ", "ŽÀŽÞ", "ŽÁ", "ŽÁŽÞ", "Ž¯", "ŽÂ", "ŽÂŽÞ", "ŽÃ", "ŽÃŽÞ", "ŽÄ", "ŽÄŽÞ",
|
|
104 "ŽÅ", "ŽÆ", "ŽÇ", "ŽÈ", "ŽÉ",
|
|
105 "ŽÊ", "ŽÊŽÞ", "ŽÊŽß", "ŽË", "ŽËŽÞ", "ŽËŽß", "ŽÌ", "ŽÌŽÞ", "ŽÌŽß",
|
|
106 "ŽÍ", "ŽÍŽÞ", "ŽÍŽß", "ŽÎ", "ŽÎŽÞ", "ŽÎŽß",
|
|
107 "ŽÏ", "ŽÐ", "ŽÑ", "ŽÒ", "ŽÓ",
|
|
108 "Ž¬", "ŽÔ", "Ž", "ŽÕ", "Ž®", "ŽÖ",
|
|
109 "Ž×", "ŽØ", "ŽÙ", "ŽÚ", "ŽÛ",
|
|
110 "¥î", "ŽÜ", "¥ð", "¥ñ", "Ž¦", "ŽÝ",
|
|
111 "Ž³ŽÞ", "¥õ", "¥ö"
|
|
112 }; /* Á´³Ñ¤¬º®¤¸¤Ã¤Æ¤ë¤Î¤ÇÃí°Õ */
|
|
113 /*
|
|
114 static char *hankdata[] = {
|
|
115 "¨§","¨±","¨¨","¨²","¨©","¨³","¨ª","¨´","¨«","¨µ",
|
|
116 "¨¶","¨¶¨Þ","¨·","¨·¨Þ","¨¸","¨¸¨Þ","¨¹","¨¹¨Þ","¨º","¨º¨Þ",
|
|
117 "¨»","¨»¨Þ","¨¼","¨¼¨Þ","¨½","¨½¨Þ","¨¾","¨¾¨Þ","¨¿","¨¿¨Þ",
|
|
118 "¨À","¨À¨Þ","¨Á","¨Á¨Þ","¨¯","¨Â","¨Â¨Þ","¨Ã","¨Ã¨Þ","¨Ä","¨Ä¨Þ",
|
|
119 "¨Å","¨Æ","¨Ç","¨È","¨É",
|
|
120 "¨Ê","¨Ê¨Þ","¨Ê¨ß","¨Ë","¨Ë¨Þ","¨Ë¨ß","¨Ì","¨Ì¨Þ","¨Ì¨ß",
|
|
121 "¨Í","¨Í¨Þ","¨Í¨ß","¨Î","¨Î¨Þ","¨Î¨ß",
|
|
122 "¨Ï","¨Ð","¨Ñ","¨Ò","¨Ó",
|
|
123 "¨¬","¨Ô","¨","¨Õ","¨®","¨Ö",
|
|
124 "¨×","¨Ø","¨Ù","¨Ú","¨Û",
|
|
125 "¥î","¨Ü","¥ð","¥ñ","¨¦","¨Ý",
|
|
126 "¨³¨Þ","¥õ","¥ö"
|
|
127 };*//* Á´³Ñ¤¬º®¤¸¤Ã¤Æ¤ë¤Î¤ÇÃí°Õ */
|
|
128
|
|
129 /** ¾å¤Îhankdata¤¬¡¢¼ÂºÝ¤Ë»È¤¦È¾³Ñ¥³¡¼¥É¤òɽ¤·¤Æ¤¤¤Ê¤¤¤È¤¡¢¼ÂºÝ¤Î¤â¤Î¤Ë
|
|
130 ½¤Àµ¤¹¤ë¡£½é´üÀßÄê»þ¤Ë°ì²ó¤À¤±¸Æ¤Ö */
|
|
131 #ifdef OMRON_LIB
|
|
132 static
|
|
133 #endif
|
|
134 void
|
|
135 hank_setup ()
|
|
136 {
|
|
137 fast int i; /* V3.1 */
|
|
138 fast char *s, orig_hnkak1; /* V3.1 */
|
|
139
|
|
140 orig_hnkak1 = *hankdata[0];
|
|
141 /* *hankdata[] ¤Ç¤ÎȾ³Ñʸ»ú¤Î£±¥Ð¥¤¥È¤á¡£È¾³Ñʸ»ú¤Î£±¥Ð¥¤¥È¤á¤À¤±¤¬°Û¤Ê¤ë
|
|
142 ¤è¤¦¤Ê¾µ¡¼ï¤Ë°Ü¿¢¤¹¤ë¤È¤¤Ï¡¢SS2¤Îdefine¤òÊѤ¨¤ì¤ÐOK¡£Ã¢¤·romkan¤Î
|
|
143 ¥½¡¼¥¹Ãæ¤ÎȾ³Ñʸ»ú¡Ê¤³¤Î¥Õ¥¡¥¤¥ë¤Ë¤Î¤ß¸ºß¡Ë¤â¥³¥ó¥Ð¡¼¥È¤·¤Æ¡¢¤½¤Îµ¡¼ï
|
|
144 ¤Ë¹ç¤ï¤»¤ë¤Û¤¦¤¬Ë¾¤Þ¤·¤¤¡£¤·¤«¤·¡¢¥¨¥Ç¥£¥¿¤Ç¤³¤Î¥Õ¥¡¥¤¥ë¤ò½¤Àµ¤·¤¿¤ê
|
|
145 ¤¹¤ë¾ì¹ç¤Ë¡¢È¾³Ñʸ»ú¤Î°·¤¤¤¬¤¦¤Þ¤¯¤¤¤«¤Ê¤¤¾ì¹ç¤¬¤¢¤ë¤Î¤Ç¡¢ÆäË
|
|
146 ¥³¥ó¥Ð¡¼¥È¤ò¤·¤Ê¤¯¤È¤âÆ°ºî¤¹¤ë¤è¤¦¤Ë½èÃ֤Ϥ·¤Æ¤¢¤ë¡£¤½¤ì¤¬¡¢¤³¤Î
|
|
147 hank_setup()¤Ç¤¢¤ë¡£hankdata¤Ï¡¢½é´üÀßÄê»þ¤Ë hank_setup()¤Ë¤è¤Ã¤Æ
|
|
148 ¼ÂºÝ¤ÎȾ³Ñ¥³¡¼¥É¤Ëľ¤µ¤ì¤ë¡£ */
|
|
149
|
|
150 if (orig_hnkak1 == (char) SS2)
|
|
151 return;
|
|
152 for (i = 0; i < numberof (hankdata); i++)
|
|
153 {
|
|
154 for (s = hankdata[i]; *s; s += 2)
|
|
155 if (*s == orig_hnkak1)
|
|
156 *s = SS2;
|
|
157 }
|
|
158 }
|
|
159
|
|
160 /** ¤«¤Ê¢ªÈ¾³Ñ¥«¥¿¥«¥Ê¡£·ë²Ì¤¬Æóʸ»ú¤Ë¤Ê¤ë¤³¤È¤â¤¢¤ë¡£*/
|
|
161 #ifdef OMRON_LIB
|
|
162 static
|
|
163 #endif
|
|
164 void
|
|
165 to_hankata (in, outp)
|
|
166 fast letter in, **outp; /* V3.1 */
|
|
167 {
|
|
168 fast uns_chr *p, c; /* V3.1 */
|
|
169 fast letter *out; /* V3.1 */
|
|
170
|
|
171 out = *outp;
|
|
172 switch (in)
|
|
173 {
|
|
174 case CHOUON:
|
|
175 *out++ = HKCHOU;
|
|
176 break;
|
|
177 case DAKUTN:
|
|
178 *out++ = HKDKTN;
|
|
179 break;
|
|
180 case HNDAKU:
|
|
181 *out++ = HKHNDK;
|
|
182 break;
|
|
183 case MNMARU:
|
|
184 *out++ = HKMARU;
|
|
185 break;
|
|
186 case HRKKAG:
|
|
187 *out++ = HKHRKG;
|
|
188 break;
|
|
189 case TJIKAG:
|
|
190 *out++ = HKTJKG;
|
|
191 break;
|
|
192 case TOUTEN:
|
|
193 *out++ = HKTTEN;
|
|
194 break;
|
|
195 case NKPOTU:
|
|
196 *out++ = HKNKPT;
|
|
197 break;
|
|
198 default:
|
|
199 if (is_kata (in))
|
|
200 {
|
|
201 for (p = (uns_chr *) hankdata[in - KATBGN]; c = *p; p++)
|
|
202 *out++ = (c << 8) + *++p;
|
|
203 }
|
|
204 else if (is_hira (in))
|
|
205 {
|
|
206 for (p = (uns_chr *) hankdata[in - HIRBGN]; c = *p; p++)
|
|
207 *out++ = (c << 8) + *++p;
|
|
208 }
|
|
209 else
|
|
210 {
|
|
211 *out++ = in;
|
|
212 }
|
|
213 }
|
|
214 *out = EOLTTR;
|
|
215 *outp = out;
|
|
216 }
|
|
217
|
|
218 /** Ⱦ³Ñ¥«¥¿¥«¥Ê¢ª¤Ò¤é¤¬¤Ê¡£Ã¢¤·¡¢ÂùÅÀ¤ò»ý¤Äʸ»ú¤ò°ì¤Ä¤Ë¤Þ¤È¤á¤Æ¤Ï
|
|
219 ¤¯¤ì¤Ê¤¤¤Î¤ÇÃí°Õ¡£*/
|
|
220 #ifdef OMRON_LIB
|
|
221 static
|
|
222 #endif
|
|
223 letter
|
|
224 to_zenhira (l)
|
|
225 fast letter l; /* V3.1 */
|
|
226 {
|
|
227 fast letter retval; /* V3.1 */
|
|
228
|
|
229 static uns_chr *data = (uns_chr *) "¡£¡Ö¡×¡¢¡¦¤ò¤¡¤£¤¥¤§¤©¤ã¤å¤ç¤Ã¡¼¤¢¤¤¤¦¤¨¤ª¤«¤¤¯¤±¤³¤µ¤·¤¹¤»¤½¤¿\
|
|
230 ¤Á¤Ä¤Æ¤È¤Ê¤Ë¤Ì¤Í¤Î¤Ï¤Ò¤Õ¤Ø¤Û¤Þ¤ß¤à¤á¤â¤ä¤æ¤è¤é¤ê¤ë¤ì¤í¤ï¤ó¡«¡¬";
|
|
231
|
|
232 if (is_hankata (l))
|
|
233 {
|
|
234 l = (l - HKKBGN) << 1;
|
|
235 retval = data[l] << 8;
|
|
236 retval += data[++l];
|
|
237 return (retval);
|
|
238 }
|
|
239 else
|
|
240 return (l);
|
|
241 }
|
|
242
|
|
243 /** Ⱦ³Ñ¥«¥¿¥«¥Ê¢ªÁ´³Ñ¡£Ã¢¤·¡¢ÂùÅÀ¤ò»ý¤Äʸ»ú¤ò°ì¤Ä¤Ë¤Þ¤È¤á¤Æ¤Ï
|
|
244 ¤¯¤ì¤Ê¤¤¤Î¤ÇÃí°Õ¡£*/
|
|
245 #ifdef OMRON_LIB
|
|
246 static
|
|
247 #endif
|
|
248 letter
|
|
249 to_zenkata (l)
|
|
250 fast letter l; /* V3.1 */
|
|
251 {
|
|
252 return (is_hankata (l) ? (l = to_zenhira (l), to_kata (l)) : l);
|
|
253 }
|
|
254
|
|
255 /* ¥Ó¥Ã¥È¥Ù¥¯¥¿¤Î¹½À® */
|
|
256 #define bitvec(b0, b1, b2, b3, b4, b5, b6, b7) ( \
|
|
257 (char)b0 | ((char)b1 << 1) | ((char)b2 << 2) | ((char)b3 << 3) | ((char)b4 << 4) | ((char)b5 << 5) | \
|
|
258 ((char)b6 << 6) | ((char)b7 << 7) \
|
|
259 )
|
|
260
|
|
261 /** char¤ÎÇÛÎó h ¤ò¥Ó¥Ã¥È¥Ù¥¯¥¿¤È¸«¤Æ¤½¤ÎÂèi¥Ó¥Ã¥È¤ò¥Á¥§¥Ã¥¯¤¹¤ë */
|
|
262 #define bitlook(h, i) (h[(i) >> 3] & (1 << ((i) & 7)))
|
|
263
|
|
264 #define KATRPT 0xA1B3 /* ¡³ */
|
|
265 #define HIRRPT 0xA1B5 /* ¡µ */
|
|
266 #define KATA_U 0xA5A6 /* ¥¦ */
|
|
267 #define KAT_VU 0xA5F4 /* ¥ô */
|
|
268 #define HIR_KA 0xA4AB /* ¤« */
|
|
269 #define HIR_HO 0xA4DB /* ¤Û */
|
|
270 #define KAT_KA 0xA5AB /* ¥« */
|
|
271 #define KAT_HO 0xA5DB /* ¥Û */
|
|
272 #define HIR_HA 0xA4CF /* ¤Ï */
|
|
273 #define KAT_HA 0xA5CF /* ¥Ï */
|
|
274
|
|
275 /** ¸å¤í¤ËȾÂùÅÀ¤ò¤¯¤Ã¤Ä¤±¤ë¡£·ë²Ì¤Ï°ìËô¤ÏÆóʸ»ú¡£*/
|
|
276 #ifdef OMRON_LIB
|
|
277 static
|
|
278 #endif
|
|
279 void
|
|
280 handakuadd (in, outp)
|
|
281 fast letter in, **outp; /* V3.1 */
|
|
282 {
|
|
283 if ((HIR_HA <= in && in <= HIR_HO) ? 0 == (in - HIR_HA) % 3 : (KAT_HA <= in && in <= KAT_HO && 0 == (in - KAT_HA) % 3))
|
|
284 {
|
|
285 *(*outp)++ = in + 2;
|
|
286 }
|
|
287 else
|
|
288 {
|
|
289 *(*outp)++ = in;
|
|
290 *(*outp)++ = HNDAKU;
|
|
291 }
|
|
292 **outp = EOLTTR;
|
|
293 }
|
|
294
|
|
295 /** ¸å¤í¤ËÂùÅÀ¤ò¤¯¤Ã¤Ä¤±¤ë¡£·ë²Ì¤Ï°ìËô¤ÏÆóʸ»ú¡£*/
|
|
296 #ifdef OMRON_LIB
|
|
297 static
|
|
298 #endif
|
|
299 void
|
|
300 dakuadd (in, outp)
|
|
301 fast letter in, **outp; /* V3.1 */
|
|
302 {
|
|
303 static char flgbit[] = {
|
|
304 bitvec (1, 0, 1, 0, 1, 0, 1, 0), /* ¤«¤¬¤¤®¤¯¤°¤±¤² */
|
|
305 bitvec (1, 0, 1, 0, 1, 0, 1, 0), /* ¤³¤´¤µ¤¶¤·¤¸¤¹¤º */
|
|
306 bitvec (1, 0, 1, 0, 1, 0, 1, 0), /* ¤»¤¼¤½¤¾¤¿¤À¤Á¤Â */
|
|
307 bitvec (0, 1, 0, 1, 0, 1, 0, 0), /* ¤Ã¤Ä¤Å¤Æ¤Ç¤È¤É¤Ê */
|
|
308 bitvec (0, 0, 0, 0, 1, 0, 0, 1), /* ¤Ë¤Ì¤Í¤Î¤Ï¤Ð¤Ñ¤Ò */
|
|
309 bitvec (0, 0, 1, 0, 0, 1, 0, 0), /* ¤Ó¤Ô¤Õ¤Ö¤×¤Ø¤Ù¤Ú */
|
|
310 bitvec (1, 0, 0, 0, 0, 0, 0, 0) /* ¤Û */
|
|
311 };
|
|
312 fast letter c; /* V3.1 */
|
|
313
|
|
314 if ((HIR_KA <= in && in <= HIR_HO) ? (c = in - HIR_KA, 1) : (KAT_KA <= in && in <= KAT_HO && (c = in - KAT_KA, 1)))
|
|
315 {
|
|
316 if (bitlook (flgbit, c))
|
|
317 {
|
|
318 *(*outp)++ = in + 1;
|
|
319 }
|
|
320 else
|
|
321 {
|
|
322 *(*outp)++ = in;
|
|
323 *(*outp)++ = DAKUTN;
|
|
324 }
|
|
325 }
|
|
326 else
|
|
327 switch (in)
|
|
328 {
|
|
329 case KATRPT:
|
|
330 case HIRRPT:
|
|
331 *(*outp)++ = in + 1;
|
|
332 break;
|
|
333 case KATA_U:
|
|
334 *(*outp)++ = KAT_VU;
|
|
335 break;
|
|
336 default:
|
|
337 *(*outp)++ = in;
|
|
338 *(*outp)++ = DAKUTN;
|
|
339 }
|
|
340 **outp = EOLTTR;
|
|
341 }
|
|
342
|
|
343 /** in¤ÇÍ¿¤¨¤é¤ì¤¿¥³¡¼¥É¤òbase¿Ê¤Î¿ô»ú¤Ë¤·¤Æoutp¤ËÆþ¤ì¤ë¡£*/
|
|
344 #ifdef OMRON_LIB
|
|
345 static
|
|
346 #endif
|
|
347 void
|
|
348 to_digit (in, base, outp)
|
|
349 fast letter in, base, **outp; /* V3.1 */
|
|
350 {
|
|
351 fast letter c; /* V3.1 */
|
|
352 extern letter vtol (); /* V3.1 */
|
|
353
|
|
354 if (c = in, c /= base)
|
|
355 to_digit (c, base, outp);
|
|
356 *(*outp)++ = vtol (in % base);
|
|
357 **outp = EOLTTR;
|
|
358 }
|