2
* KAKASI (Kanji Kana Simple inversion program)
3
* $Id: jj2.c,v 1.7 2001/04/12 05:57:34 rug Exp $
5
* Hironobu Takahashi (takahasi@tiny.or.jp)
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either versions 2, or (at your option)
12
* This program is distributed in the hope that it will be useful
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with KAKASI, see the file COPYING. If not, write to the Free
19
* Software Foundation Inc., 59 Temple Place - Suite 330, Boston, MA
45
static char *cl_table[96] = {
46
"", "aiueow", "aiueow", "aiueow", "aiueow", "aiueow", "aiueow", "aiueow",
47
"aiueow", "aiueow", "aiueow", "k", "g", "k", "g", "k", "g", "k", "g", "k",
48
"g", "s", "zj", "s", "zj", "s", "zj", "s", "zj", "s", "zj", "t", "d", "tc",
49
"d", "aiueokstchgzjfdbpw", "t", "d", "t", "d", "t", "d", "n", "n", "n", "n",
50
"n", "h", "b", "p", "h", "b", "p", "hf", "b", "p", "h", "b", "p", "h", "b",
51
"p", "m", "m", "m", "m", "m", "y", "y", "y", "y", "y", "y", "rl", "rl",
52
"rl", "rl", "rl", "wiueo", "wiueo", "wiueo", "wiueo", "w", "n", "v", "k",
53
"k", "", "", "", "", "", "", "", "", ""};
57
if ((c1 == 0xa4) && (0xa0 <= c2 ) && (c2 < 0xff)) {
58
for (p = cl_table[c2 - 0xa0]; *p != '\0'; ++ p) {
74
for (i = 0; str[i] != '\0'; ++ i, ++j) {
96
unsigned char Jstr[J2HBUF], Hstr[J2READ][J2HBUF], Dstr[J2HBUF], *h_point;
97
int max_len, length, match_more, n_read, i, clen;
98
struct kanji_yomi *ptr;
104
for (i = 0; i * 2 < J2HBUF - 2 && c[i].c1 != 0; ++ i) { /* FIXME: chop down incoming string (ad-hoc solution)*/
107
if ((c[i].type == JIS83) || (c[i].type == JIS78)) {
116
assert(i*2 < J2HBUF);
120
add_kanwa((int)Jstr[0], (int)Jstr[1]);
122
for (ptr = jisyo_table[Jstr[0]&0x7f][Jstr[1]&0x7f];
125
length = ptr->length;
126
if (clen >= length) {
127
if (strncmp((char *)Jstr+2, (char *)(ptr->kanji),
128
(length & 1) ? length-3 : length-2))
131
if (J2_cletter(ptr->tail,Jstr[length-1],Jstr[length]))
133
if (max_len < length) {
135
sprintf((char *)Hstr[0], "%s%c%c", ptr->yomi,
136
Jstr[length-1],Jstr[length]);
138
strcpy((char *)Hstr[0], (const char *)(ptr->yomi));
142
} else if (max_len == length) {
143
if ((heiki_mode) && (n_read < J2READ)) {
145
sprintf((char *)Hstr[n_read], "%s%c%c", ptr->yomi,
146
Jstr[length-1],Jstr[length]);
148
strcpy((char *)Hstr[n_read], (const char *)(ptr->yomi));
150
for (i = 0; i < n_read; ++ i) {
151
if (strcmp((const char *)Hstr[i], (const char *)Hstr[n_read]) == 0) goto next;
160
else if (strncmp((char *)Jstr+2, (char *)(ptr->kanji), clen-2) == 0)
172
h_point = Jstr+((max_len-1) & 0xfffe);
173
if (strncmp((const char *)h_point, "\244\303", 2) == 0) {
174
if (clen <= max_len+1)
178
for (i = 0; i < n_read; ++ i) {
179
sprintf((char *)Hstr[i], "%s%c%c", Hstr[i], h_point[2], h_point[3]);
185
strcpy((char *)Dstr, "{");
186
for (i = 0; i < n_read; ++ i) {
187
strcat((char *)Dstr, (const char *)Hstr[i]);
189
strcat((char *)Dstr, "}");
191
strcat((char *)Dstr, "|");
195
J2append(n, Hstr[0]);
197
return (match_more == 0) ? (max_len+1)/2 : -(max_len+1)/2;
201
J2convert(m, n, proc)
209
while(m[mp].c1 != 0) {
210
if (m[mp].type != JIS83) {
211
n[np].type = m[mp].type;
217
ret = (* proc)(m+mp, n+np);
218
if (ret == 0) ret = 1;
219
mp += (ret < 0) ? -ret : ret;
220
for (; n[np].c1 != 0; ++ np) ;
237
J2convert(m, n, H2a);
250
J2convert(m, n, H2j);
263
J2convert(m, n, H2k);
276
J2convert(m, n, H2K);