Rename to Sj4
This commit is contained in:
parent
0184e70f04
commit
0a2839610b
121 changed files with 1471 additions and 1461 deletions
499
lib/sj4core/adddic.c
Normal file
499
lib/sj4core/adddic.c
Normal file
|
|
@ -0,0 +1,499 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: adddic.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:26 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sj_euc.h"
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static void sprt_seg(SJ4_CONTEXT TypeDicSeg, TypeDicOfs);
|
||||
static void apnd_uidx(SJ4_CONTEXT TypeDicSeg, u_char*, int);
|
||||
static int cal_nextym(SJ4_CONTEXT u_char*);
|
||||
static int usr_freelen(SJ4_CONTEXT2);
|
||||
static u_int checkdict(SJ4_CONTEXT u_char*, TypeGram);
|
||||
|
||||
u_int adddic(SJ4_CONTEXT u_char* yomi, u_char* kanji, TypeGram hinsi) {
|
||||
u_int err;
|
||||
u_char yptr[MAXWDYOMILEN + 1];
|
||||
u_char kptr[MAXWDKANJILEN + 1];
|
||||
int klen;
|
||||
TypeDicSeg segnum;
|
||||
int saml;
|
||||
TypeDicOfs dstofs;
|
||||
TypeDicOfs douofs;
|
||||
TypeDicOfs hnsofs;
|
||||
TypeDicOfs knjofs;
|
||||
TypeDicOfs nxtask;
|
||||
TypeDicOfs newsiz;
|
||||
TypeDicOfs oldsiz;
|
||||
TypeDicOfs fresiz;
|
||||
TypeIdxOfs freidx;
|
||||
u_char* douptr;
|
||||
u_char* dstptr;
|
||||
TypeDicOfs pos;
|
||||
u_char* p1;
|
||||
int i;
|
||||
int nlen, plen;
|
||||
int size;
|
||||
STDYIN* stdy;
|
||||
STDYOUT stdydat;
|
||||
|
||||
if((err = addel_arg(SJ4_CONTEXT_PASS yomi, kanji, hinsi, yptr, sizeof(yptr))))
|
||||
return err;
|
||||
|
||||
inputyomi = yomi;
|
||||
cnvstart = ystart = yptr;
|
||||
cnvlen = sstrlen(yptr);
|
||||
|
||||
if((err = checkdict(SJ4_CONTEXT_PASS kanji, hinsi)))
|
||||
return err;
|
||||
|
||||
if(!curdict->maxunit)
|
||||
return AD_NOTUSERDICT;
|
||||
|
||||
klen = cvtknj(SJ4_CONTEXT_PASS yomi, kanji, kptr);
|
||||
|
||||
newsiz = DOUONBLKSIZENUMBER + cnvlen + (klen != 0 ? klen + 1 : 0) + 2;
|
||||
|
||||
if(newsiz > MAXDOUONBLK)
|
||||
return AD_OVFLWDOUBLK;
|
||||
if(newsiz > curdict->seglen)
|
||||
return AD_OVFLWDOUBLK;
|
||||
|
||||
segnum = srchidx(SJ4_CONTEXT_PASS(TypeDicSeg) DICSEGBASE, cnvlen);
|
||||
|
||||
for(;;) {
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, segnum);
|
||||
i = srchkana(SJ4_CONTEXT_PASS & p1, &saml);
|
||||
dstofs = douofs = p1 - dicbuf;
|
||||
hnsofs = knjofs = 0;
|
||||
if(i) {
|
||||
i = srchgram(p1, &p1, hinsi);
|
||||
dstofs = hnsofs = p1 - dicbuf;
|
||||
if(i) {
|
||||
srchkanji(&p1, kptr, klen);
|
||||
if(*p1 != HINSIBLKTERM)
|
||||
return AD_AREXIST;
|
||||
dstofs = knjofs = p1 - dicbuf;
|
||||
}
|
||||
}
|
||||
|
||||
p1 = dicbuf + douofs;
|
||||
|
||||
if(!hnsofs) {
|
||||
oldsiz = 0;
|
||||
nlen = cnvlen - saml;
|
||||
newsiz = DOUONBLKSIZENUMBER + nlen;
|
||||
|
||||
nxtask = cal_nextym(SJ4_CONTEXT_PASS p1);
|
||||
} else {
|
||||
oldsiz = newsiz = getsize(p1);
|
||||
nxtask = 0;
|
||||
}
|
||||
if(!knjofs) newsiz += 2;
|
||||
|
||||
newsiz += (klen != 0 ? klen + 1 : 0);
|
||||
|
||||
fresiz = usr_freelen(SJ4_CONTEXT_PASS2);
|
||||
|
||||
if((unsigned int)(newsiz - oldsiz - nxtask) <=
|
||||
(unsigned int)fresiz) break;
|
||||
|
||||
if(segend(p1) && (segnum + 1 < curdict->segunit)) {
|
||||
segnum++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(curdict->segunit >= curdict->maxunit)
|
||||
return AD_OVFLWUSRDIC;
|
||||
|
||||
freidx = count_uidx(SJ4_CONTEXT_PASS2);
|
||||
|
||||
if((unsigned int)(douofs + newsiz) <= curdict->seglen) {
|
||||
if(hnsofs)
|
||||
p1 = getntag(p1);
|
||||
pos = p1 - dicbuf;
|
||||
|
||||
nlen = getnlen(p1);
|
||||
if((unsigned int)freidx < getplen(p1) + nlen + 1)
|
||||
return AD_OVFLWINDEX;
|
||||
|
||||
if((*curdict->putdic)(SJ4_CONTEXT_PASS curdict, curdict->segunit))
|
||||
return AD_OVFLWUSRDIC;
|
||||
|
||||
sprt_seg(SJ4_CONTEXT_PASS segnum, pos);
|
||||
|
||||
nxtask = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if(segend(p1)) {
|
||||
if((unsigned int)freidx < cnvlen + 1)
|
||||
return AD_OVFLWINDEX;
|
||||
|
||||
if((*curdict->putdic)(SJ4_CONTEXT_PASS curdict, curdict->segunit))
|
||||
return AD_OVFLWUSRDIC;
|
||||
curdict->segunit++;
|
||||
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, curdict->segunit - 1);
|
||||
memset(dicbuf, DICSEGTERM, (int)curdict->seglen);
|
||||
dicbuf[0] = 0;
|
||||
(*curdict->putdic)(SJ4_CONTEXT_PASS curdict, curdict->segunit - 1);
|
||||
(*curdict->rszdic)(SJ4_CONTEXT_PASS curdict, curdict->segunit);
|
||||
mkidxtbl(SJ4_CONTEXT_PASS curdict);
|
||||
|
||||
segnum++;
|
||||
} else {
|
||||
nlen = getnlen(p1);
|
||||
if((unsigned int)freidx < getplen(p1) + nlen + 1)
|
||||
return AD_OVFLWINDEX;
|
||||
|
||||
if((*curdict->putdic)(SJ4_CONTEXT_PASS curdict, curdict->segunit))
|
||||
return AD_OVFLWUSRDIC;
|
||||
|
||||
sprt_seg(SJ4_CONTEXT_PASS segnum, douofs);
|
||||
|
||||
segnum++;
|
||||
}
|
||||
}
|
||||
|
||||
douptr = dicbuf + douofs;
|
||||
|
||||
if(nxtask) {
|
||||
u_char* tp;
|
||||
|
||||
size = getsize(douptr) - nxtask;
|
||||
plen = getplen(douptr) + nxtask;
|
||||
nlen = getnlen(douptr) - nxtask;
|
||||
*douptr = (size >> 8);
|
||||
if(nlen & 0x10)
|
||||
*douptr |= NOKORIYOMITOP;
|
||||
if(plen & 0x10)
|
||||
*douptr |= ASSYUKUYOMITOP;
|
||||
*(douptr + 1) = size;
|
||||
*(douptr + 2) = ((nlen & 0x0f) | ((plen & 0x0f) << 4));
|
||||
|
||||
p1 = douptr + DOUONBLKSIZENUMBER;
|
||||
tp = p1 + nxtask;
|
||||
mvmemi(tp, p1, dicbuf + curdict->seglen - tp);
|
||||
}
|
||||
|
||||
dstptr = dicbuf + dstofs;
|
||||
size = newsiz - oldsiz;
|
||||
p1 = dicbuf + curdict->seglen;
|
||||
mvmemd(p1 - size, p1, p1 - dstptr - size);
|
||||
|
||||
if(!hnsofs) {
|
||||
if(douofs == segtop() - dicbuf) {
|
||||
chg_uidx(SJ4_CONTEXT_PASS segnum, yptr, cnvlen);
|
||||
}
|
||||
|
||||
*dstptr = 0;
|
||||
nlen = cnvlen - saml;
|
||||
if(nlen & 0x10)
|
||||
*dstptr |= NOKORIYOMITOP;
|
||||
if(saml & 0x10)
|
||||
*dstptr |= ASSYUKUYOMITOP;
|
||||
*dstptr++ |= (size >> 8);
|
||||
*dstptr++ = size;
|
||||
*dstptr++ = ((nlen & 0x0f) | ((saml & 0x0f) << 4));
|
||||
|
||||
while(saml < cnvlen) *dstptr++ = yptr[saml++];
|
||||
} else {
|
||||
plen = getplen(douptr);
|
||||
nlen = getnlen(douptr);
|
||||
*douptr = (newsiz >> 8);
|
||||
if(nlen & 0x10)
|
||||
*douptr |= NOKORIYOMITOP;
|
||||
if(plen & 0x10)
|
||||
*douptr |= ASSYUKUYOMITOP;
|
||||
*(douptr + 1) = newsiz;
|
||||
*(douptr + 2) = ((nlen & 0x0f) | ((plen & 0x0f) << 4));
|
||||
}
|
||||
|
||||
if(!knjofs)
|
||||
*dstptr++ = hinsi;
|
||||
|
||||
stdydat.stdy1.offset = dstptr - dicbuf;
|
||||
for(saml = 0; saml < klen;)
|
||||
*dstptr++ = kptr[saml++];
|
||||
if(klen > 0)
|
||||
*dstptr++ = KANJISTREND;
|
||||
|
||||
if(!knjofs)
|
||||
*dstptr++ = HINSIBLKTERM;
|
||||
|
||||
(*curdict->putdic)(SJ4_CONTEXT_PASS curdict, segnum);
|
||||
|
||||
if(StudyExist()) {
|
||||
size -= nxtask;
|
||||
for(i = STUDYCOUNT, stdy = STUDYDICT; i--; stdy++) {
|
||||
if(stdy->dicid != curdict->dicid)
|
||||
continue;
|
||||
if(stdy->seg != segnum)
|
||||
continue;
|
||||
if(stdy->offset >= dstofs)
|
||||
stdy->offset += size;
|
||||
}
|
||||
|
||||
for(p1 = CLSTUDYDICT; !iseocl(p1); p1 = ClNextTag(p1)) {
|
||||
err = sstrncmp(yptr, (u_char*)ClYomiPos(p1),
|
||||
(int)ClYomiLen(p1));
|
||||
if(err == MATCH) {
|
||||
delclsub(SJ4_CONTEXT_PASS p1);
|
||||
mkclidx(SJ4_CONTEXT_PASS2);
|
||||
putcldic(SJ4_CONTEXT_PASS2);
|
||||
break;
|
||||
} else if(err == OVER)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
stdydat.stdy1.seg = segnum;
|
||||
stdydat.stdy1.dicid = curdict->dicid;
|
||||
stdydat.stdy1.styno = 0;
|
||||
stdydat.stdy1.sttkj = 0;
|
||||
stdydat.stdy1.ka_kj = 0;
|
||||
stdydat.stdy1.nmflg = 0;
|
||||
stdydat.hinshi = hinsi;
|
||||
stdydat.len = cnvlen;
|
||||
stdydat.sttlen = 0;
|
||||
stdydat.sttfg = 0;
|
||||
stdydat.ka_fg = 0;
|
||||
(void)study(SJ4_CONTEXT_PASS & stdydat);
|
||||
|
||||
return AD_DONE;
|
||||
}
|
||||
|
||||
static int
|
||||
checksub(SJ4_CONTEXT u_char* kanji, TypeGram grm) {
|
||||
u_char* tagp;
|
||||
u_char* ptr;
|
||||
u_char* endp;
|
||||
int flg, nlen;
|
||||
int dounum;
|
||||
u_char buf[MAXWDKANJILEN + 1];
|
||||
|
||||
dicinl = cnvlen;
|
||||
dicsaml = 0;
|
||||
prevseg = (TypeDicSeg)-1;
|
||||
for(;;) {
|
||||
if(!(tagp = srchdict(SJ4_CONTEXT_PASS tagp)))
|
||||
return 0;
|
||||
if(cnvlen == getnlen(tagp) + getplen(tagp))
|
||||
break;
|
||||
}
|
||||
|
||||
dounum = 0;
|
||||
|
||||
nlen = getnlen(tagp);
|
||||
ptr = tagp + DOUONBLKSIZENUMBER + nlen;
|
||||
|
||||
endp = tagp + getsize(tagp);
|
||||
|
||||
while(ptr < endp) {
|
||||
flg = (grm == *ptr++);
|
||||
while(*ptr != HINSIBLKTERM) {
|
||||
if(flg) {
|
||||
buf[getkanji(SJ4_CONTEXT_PASS inputyomi, cnvlen, ptr, buf)] = 0;
|
||||
if(cmpstr(kanji, buf))
|
||||
return -1;
|
||||
}
|
||||
dounum++;
|
||||
ptr = skipkstr(ptr);
|
||||
}
|
||||
|
||||
ptr++;
|
||||
}
|
||||
|
||||
return dounum;
|
||||
}
|
||||
|
||||
static u_int
|
||||
checkdict(SJ4_CONTEXT u_char* kanji, TypeGram grm) {
|
||||
DICTL* dp;
|
||||
int dounum = 0;
|
||||
int tmp;
|
||||
DICT* tmpdict;
|
||||
|
||||
tmpdict = curdict;
|
||||
for(dp = dictlist; dp; dp = dp->next) {
|
||||
|
||||
curdict = dp->dict;
|
||||
|
||||
if((tmp = checksub(SJ4_CONTEXT_PASS kanji, grm)) < 0) {
|
||||
curdict = tmpdict;
|
||||
return AD_AREXIST;
|
||||
}
|
||||
|
||||
dounum += tmp;
|
||||
}
|
||||
curdict = tmpdict;
|
||||
|
||||
if(MAXKOUHONUMBER <= dounum)
|
||||
return AD_OVFLWDOUNUM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cal_nextym(SJ4_CONTEXT u_char* ptr) {
|
||||
int count = 0;
|
||||
u_char* src;
|
||||
int len;
|
||||
|
||||
if(!segend(ptr)) {
|
||||
src = cnvstart + getplen(ptr);
|
||||
|
||||
len = getnlen(ptr);
|
||||
ptr += DOUONBLKSIZENUMBER;
|
||||
|
||||
while(len--) {
|
||||
if(*ptr++ == *src++)
|
||||
count++;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static int
|
||||
usr_freelen(SJ4_CONTEXT2) {
|
||||
u_char* ptr;
|
||||
|
||||
ptr = segtop();
|
||||
while(!segend(ptr))
|
||||
ptr += getsize(ptr);
|
||||
|
||||
return curdict->seglen - (ptr - dicbuf);
|
||||
}
|
||||
|
||||
static void
|
||||
sprt_seg(SJ4_CONTEXT TypeDicSeg seg, TypeDicOfs ofs) {
|
||||
TypeDicSeg s;
|
||||
u_char* pos;
|
||||
u_char* p;
|
||||
u_char* q;
|
||||
int i;
|
||||
int j;
|
||||
int ylen, nlen;
|
||||
TypeDicID dicid;
|
||||
u_char yomi[MAXWDYOMILEN];
|
||||
STDYIN* stdy;
|
||||
|
||||
for(s = curdict->segunit - 1; s >= seg; s--) {
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, s);
|
||||
(*curdict->putdic)(SJ4_CONTEXT_PASS curdict, s + 1);
|
||||
}
|
||||
curdict->segunit++;
|
||||
(*curdict->rszdic)(SJ4_CONTEXT_PASS curdict, curdict->segunit);
|
||||
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, seg + 1);
|
||||
|
||||
pos = dicbuf + ofs;
|
||||
|
||||
for(p = segtop(); (p <= pos) && !segend(p); p = q) {
|
||||
q = getntag(p);
|
||||
i = getplen(p);
|
||||
nlen = getnlen(p);
|
||||
j = (nlen != 0) ? nlen + 1 : 0;
|
||||
p += DOUONBLKSIZENUMBER;
|
||||
while(j-- > 0)
|
||||
yomi[i++] = *p++;
|
||||
}
|
||||
|
||||
nlen = getnlen(pos);
|
||||
ylen = (i = getplen(pos)) + (j = nlen);
|
||||
|
||||
apnd_uidx(SJ4_CONTEXT_PASS seg, yomi, ylen);
|
||||
|
||||
set_size(segtop(), getsize(pos) + i, 0, ylen);
|
||||
|
||||
mvmemi(yomi, (p = segtop() + DOUONBLKSIZENUMBER), ylen);
|
||||
|
||||
q = pos + DOUONBLKSIZENUMBER + j;
|
||||
i = dicbuf + curdict->seglen - q;
|
||||
mvmemi(q, p += ylen, i);
|
||||
j = q - p;
|
||||
|
||||
p += i;
|
||||
memset(p, DICSEGTERM, (dicbuf + curdict->seglen - p));
|
||||
|
||||
(*curdict->putdic)(SJ4_CONTEXT_PASS curdict, seg + 1);
|
||||
|
||||
if(StudyExist()) {
|
||||
dicid = curdict->dicid;
|
||||
for(i = STUDYCOUNT, stdy = STUDYDICT; i-- > 0; stdy++) {
|
||||
if(stdy->dicid != dicid)
|
||||
continue;
|
||||
else if(stdy->seg < seg)
|
||||
continue;
|
||||
else if(stdy->seg > seg)
|
||||
stdy->seg += 1;
|
||||
else if(stdy->offset >= ofs) {
|
||||
stdy->seg += 1;
|
||||
stdy->offset -= j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, seg);
|
||||
memset(dicbuf + ofs, DICSEGTERM, (int)(curdict->seglen - ofs));
|
||||
(*curdict->putdic)(SJ4_CONTEXT_PASS curdict, seg);
|
||||
}
|
||||
|
||||
static void
|
||||
apnd_uidx(SJ4_CONTEXT TypeDicSeg seg, u_char* yomi, int len) {
|
||||
u_char* p;
|
||||
u_char* q;
|
||||
|
||||
p = get_idxptr(SJ4_CONTEXT_PASS seg);
|
||||
while(*p++);
|
||||
|
||||
q = idxbuf + curdict->idxlen;
|
||||
mvmemd(q - (len + 1), q, (int)(q - (len + 1) - p));
|
||||
|
||||
while(len--)
|
||||
*p++ = *yomi++;
|
||||
*p = 0;
|
||||
|
||||
(*curdict->putidx)(SJ4_CONTEXT_PASS curdict, 0);
|
||||
|
||||
mkidxtbl(SJ4_CONTEXT_PASS curdict);
|
||||
}
|
||||
353
lib/sj4core/addelcmn.c
Normal file
353
lib/sj4core/addelcmn.c
Normal file
|
|
@ -0,0 +1,353 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: addelcmn.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:27 $
|
||||
*/
|
||||
|
||||
#include "sj_euc.h"
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_hinsi.h"
|
||||
#include "sj_yomi.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
void set_size(u_char* p, int size, int plen, int nlen) {
|
||||
*p = (u_char)(size >> 8);
|
||||
if(nlen & 0x10) *p |= NOKORIYOMITOP;
|
||||
if(plen & 0x10) *p |= ASSYUKUYOMITOP;
|
||||
*(p + 1) = (u_char)size;
|
||||
*(p + 2) = (u_char)((nlen & 0x0f) | ((plen & 0x0f) << 4));
|
||||
}
|
||||
|
||||
static int
|
||||
isvyomi(u_char* yp) {
|
||||
int len;
|
||||
|
||||
if(!*yp) return FALSE;
|
||||
|
||||
if(!(Chrtbl[*yp] & DICTOP)) return FALSE;
|
||||
|
||||
for(len = 0; *yp; yp++) {
|
||||
if(!(Chrtbl[*yp]) || (*yp >= Y_KUTEN)) return FALSE;
|
||||
|
||||
if(++len > MAXWDYOMILEN) return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
isvknj(u_char* kanji) {
|
||||
int len;
|
||||
|
||||
if(!*kanji) return FALSE;
|
||||
|
||||
for(len = 0; *kanji;) {
|
||||
if(*kanji == SS3) {
|
||||
kanji += 3;
|
||||
len += 2;
|
||||
} else
|
||||
|
||||
if(isknj1(*kanji)) {
|
||||
kanji += 2;
|
||||
len += 2;
|
||||
}
|
||||
|
||||
else {
|
||||
kanji++;
|
||||
len += 2;
|
||||
}
|
||||
|
||||
if(len > MAXWDKANJILEN) return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
isgrm(TypeGram gram) {
|
||||
int grm = gram;
|
||||
|
||||
if(MEISI_1 <= grm && grm <= D_MEISI_6) return TRUE;
|
||||
if(MYOUJI <= grm && grm <= JOSUUSI2) return TRUE;
|
||||
if(KEIYOUSI_1 <= grm && grm <= DO_ZAHEN) return TRUE;
|
||||
if(DO_1DAN_1 <= grm && grm <= DO_WAGO_2) return TRUE;
|
||||
if(DO_KAGO_5 <= grm && grm <= DO_WAGO_5) return TRUE;
|
||||
if(DO_KAGO_6 <= grm && grm <= DO_WAGO_6) return TRUE;
|
||||
if(DO_1DAN_3 <= grm && grm <= DO_WAGO_3) return TRUE;
|
||||
if(DO_1DAN_4 <= grm && grm <= DO_WAGO_4) return TRUE;
|
||||
if(DO_KAGO_7 <= grm && grm <= DO_WAGO_7) return TRUE;
|
||||
if(DO_KAGO_8 <= grm && grm <= DO_WAGO_8) return TRUE;
|
||||
if(SP_SA_MI1 <= grm && grm <= TANKANJI) return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u_int addel_arg(SJ4_CONTEXT u_char* yp, u_char* kp, TypeGram grm, u_char* nyp, int len) {
|
||||
u_short err = 0;
|
||||
|
||||
if(!sj2cd_str(yp, nyp, len)) err |= AD_BADYOMI;
|
||||
|
||||
if(!isvyomi(nyp)) err |= AD_BADYOMI;
|
||||
|
||||
if(!isvknj(kp)) err |= AD_BADKANJI;
|
||||
|
||||
if(!isgrm(grm)) err |= AD_BADHINSI;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void
|
||||
yomi2kata(u_char* src, u_char* dst) {
|
||||
int first;
|
||||
int second;
|
||||
|
||||
while((first = *src++)) {
|
||||
second = *src++;
|
||||
|
||||
if(first != 0xa4) {
|
||||
*dst++ = first;
|
||||
*dst++ = second;
|
||||
}
|
||||
|
||||
else {
|
||||
*dst++ = 0xa5;
|
||||
*dst++ = second;
|
||||
}
|
||||
}
|
||||
|
||||
*dst = 0;
|
||||
}
|
||||
|
||||
static int
|
||||
top_strcmp(u_char* src, u_char* dst) {
|
||||
int i;
|
||||
|
||||
for(i = 0; *src && (*src == *dst); src++, dst++) i++;
|
||||
|
||||
i /= 2;
|
||||
|
||||
return (i > MAXYOMIASKNUMBER) ? MAXYOMIASKNUMBER : i;
|
||||
}
|
||||
|
||||
static int
|
||||
last_strcmp(u_char* src, u_char* dst) {
|
||||
int slen;
|
||||
int dlen;
|
||||
|
||||
slen = sstrlen(src);
|
||||
dlen = sstrlen(dst);
|
||||
|
||||
if(dlen > MAXYOMIASKNUMBER * 2) return 0;
|
||||
|
||||
if(sstrcmp(src + (slen - dlen), dst)) return 0;
|
||||
|
||||
return (dlen / 2);
|
||||
}
|
||||
|
||||
int cvtknj(SJ4_CONTEXT u_char* yomi, u_char* knj, u_char* dst) {
|
||||
u_char kana[MAXWDYOMILEN * 2 + 1];
|
||||
int len;
|
||||
u_char* keep;
|
||||
|
||||
keep = dst;
|
||||
yomi2kata(yomi, kana);
|
||||
|
||||
if((len = top_strcmp(yomi, knj))) {
|
||||
*dst = (u_char)(ZENHIRAASSYUKU | (len - 1));
|
||||
} else if((len = top_strcmp(kana, knj))) {
|
||||
*dst = (u_char)(ZENKATAASSYUKU | (len - 1));
|
||||
}
|
||||
|
||||
if(len) {
|
||||
knj += len * 2;
|
||||
dst++;
|
||||
}
|
||||
|
||||
if(*knj) {
|
||||
for(;;) {
|
||||
if((len = last_strcmp(yomi, knj))) {
|
||||
*dst++ = (u_char)(ZENHIRAASSYUKU | (len - 1));
|
||||
break;
|
||||
} else if((len = last_strcmp(kana, knj))) {
|
||||
*dst++ = (u_char)(ZENKATAASSYUKU | (len - 1));
|
||||
break;
|
||||
} else if(*knj == SS2) {
|
||||
knj++;
|
||||
*dst++ = (u_char)LEADINGHANKAKU;
|
||||
*dst++ = *knj++;
|
||||
} else if(*knj == SS3) {
|
||||
knj++;
|
||||
*dst++ = (*knj & NORMALKANJIMASK);
|
||||
knj++;
|
||||
*dst++ = *knj++;
|
||||
} else if(*knj & 0x80) {
|
||||
*dst++ = (*knj & NORMALKANJIMASK);
|
||||
knj++;
|
||||
*dst++ = (*knj & NORMALKANJIMASK);
|
||||
knj++;
|
||||
} else {
|
||||
*dst++ = (u_char)LEADINGHANKAKU;
|
||||
*dst++ = *knj++;
|
||||
}
|
||||
if(!*knj) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
*dst = 0;
|
||||
|
||||
return (dst - keep);
|
||||
}
|
||||
|
||||
int srchkana(SJ4_CONTEXT u_char** ptr, int* saml) {
|
||||
u_char* p;
|
||||
int cmp;
|
||||
int cnt = 0;
|
||||
u_char same;
|
||||
int flg = 0;
|
||||
|
||||
same = 0;
|
||||
|
||||
p = segtop();
|
||||
|
||||
while(!segend(p)) {
|
||||
if(flg == 0) {
|
||||
cmp = yomicmp(SJ4_CONTEXT_PASS cnvstart, p, &same);
|
||||
|
||||
if(cmp == OVER) break;
|
||||
if(cmp == MATCH && *(cnvstart + same) == 0) {
|
||||
*ptr = p;
|
||||
*saml = same;
|
||||
flg = 1;
|
||||
}
|
||||
}
|
||||
p = getntag(p);
|
||||
cnt++;
|
||||
}
|
||||
|
||||
if(flg != 0) return cnt;
|
||||
|
||||
*ptr = p;
|
||||
*saml = same;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int srchgram(u_char* ptr, u_char** dst, TypeGram hinsi) {
|
||||
u_char* endp;
|
||||
int cnt = 0, nlen;
|
||||
int flg = FALSE;
|
||||
|
||||
endp = getntag(ptr);
|
||||
|
||||
nlen = getnlen(ptr);
|
||||
|
||||
ptr += DOUONBLKSIZENUMBER + nlen;
|
||||
while(ptr < endp) {
|
||||
if(*ptr == hinsi) {
|
||||
*dst = ptr;
|
||||
flg = TRUE;
|
||||
}
|
||||
do {
|
||||
ptr += codesize(*ptr);
|
||||
} while(*ptr != HINSIBLKTERM);
|
||||
ptr++;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
if(flg) return cnt;
|
||||
|
||||
*dst = ptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int srchkanji(u_char** dst, u_char* knj, int klen) {
|
||||
u_char* ptr;
|
||||
u_char *p, *q;
|
||||
int len;
|
||||
int flg = FALSE;
|
||||
int cnt = 0;
|
||||
|
||||
ptr = *dst + 1;
|
||||
|
||||
while(*ptr != HINSIBLKTERM) {
|
||||
for(p = ptr, q = knj, len = klen; len; len--)
|
||||
if(*p++ != *q++) break;
|
||||
|
||||
if(!len) {
|
||||
*dst = ptr;
|
||||
flg = TRUE;
|
||||
}
|
||||
|
||||
while(!(*ptr == KANJISTREND)) {
|
||||
ptr += codesize(*ptr);
|
||||
}
|
||||
ptr++;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
if(!flg) *dst = ptr;
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
TypeIdxOfs
|
||||
count_uidx(SJ4_CONTEXT2) {
|
||||
u_char* p;
|
||||
|
||||
p = get_idxptr(SJ4_CONTEXT_PASS curdict->segunit - 1);
|
||||
while(*p++);
|
||||
|
||||
return (curdict->idxlen - (p - idxbuf));
|
||||
}
|
||||
|
||||
void chg_uidx(SJ4_CONTEXT TypeDicSeg seg, u_char* yomi, int len) {
|
||||
u_char *p, *q;
|
||||
int olen;
|
||||
|
||||
p = get_idxptr(SJ4_CONTEXT_PASS seg);
|
||||
|
||||
olen = sstrlen(p);
|
||||
|
||||
q = idxbuf + curdict->idxlen;
|
||||
|
||||
if(len > olen) {
|
||||
mvmemd(q - (len - olen), q, (int)(q - (len - olen) - p));
|
||||
} else {
|
||||
mvmemi(p + (olen - len), p, (int)(q - (p + (olen - len))));
|
||||
}
|
||||
while(len--) *p++ = *yomi++;
|
||||
|
||||
(*curdict->putidx)(SJ4_CONTEXT_PASS curdict, 0);
|
||||
|
||||
mkidxtbl(SJ4_CONTEXT_PASS curdict);
|
||||
}
|
||||
112
lib/sj4core/alloc.c
Normal file
112
lib/sj4core/alloc.c
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: alloc.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:28 $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
#include "sj_const.h"
|
||||
#include "sj_var.h"
|
||||
#include "sj_struct.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
#define JREC_NUM 128
|
||||
#define CLREC_NUM 128
|
||||
|
||||
#ifdef SJ4_GLOBAL
|
||||
static JREC* jrec = NULL;
|
||||
static CLREC* clrec = NULL;
|
||||
#else
|
||||
#define jrec ctx->jrec_free
|
||||
#define clrec ctx->clrec_free
|
||||
#endif
|
||||
|
||||
JREC* alloc_jrec(SJ4_CONTEXT2) {
|
||||
JREC* p;
|
||||
int i;
|
||||
|
||||
if(jrec == NULL) {
|
||||
jrec = (JREC*)malloc(sizeof(JREC) * JREC_NUM);
|
||||
if(jrec == NULL) return (JREC*)malloc(sizeof(JREC));
|
||||
for(i = 0, p = jrec; i < JREC_NUM - 1; i++, p++)
|
||||
p->jsort = p + 1;
|
||||
p->jsort = NULL;
|
||||
|
||||
#ifndef SJ4_GLOBAL
|
||||
ctx->jrec_pool = jrec;
|
||||
#endif
|
||||
}
|
||||
p = jrec;
|
||||
jrec = jrec->jsort;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void free_jrec(SJ4_CONTEXT JREC* p) {
|
||||
if(p != NULL) {
|
||||
p->jsort = jrec;
|
||||
jrec = p;
|
||||
}
|
||||
}
|
||||
|
||||
CLREC*
|
||||
alloc_clrec(SJ4_CONTEXT2) {
|
||||
CLREC* p;
|
||||
int i;
|
||||
|
||||
if(clrec == NULL) {
|
||||
clrec = (CLREC*)malloc(sizeof(CLREC) * CLREC_NUM);
|
||||
if(clrec == NULL) return (CLREC*)malloc(sizeof(CLREC));
|
||||
for(i = 0, p = clrec; i < CLREC_NUM - 1; i++, p++)
|
||||
p->clsort = p + 1;
|
||||
p->clsort = NULL;
|
||||
|
||||
#ifndef SJ4_GLOBAL
|
||||
ctx->clrec_pool = clrec;
|
||||
#endif
|
||||
}
|
||||
p = clrec;
|
||||
clrec = clrec->clsort;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void free_clrec(SJ4_CONTEXT CLREC* p) {
|
||||
if(p != NULL) {
|
||||
p->clsort = clrec;
|
||||
clrec = p;
|
||||
}
|
||||
}
|
||||
57
lib/sj4core/charsize.c
Normal file
57
lib/sj4core/charsize.c
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: charsize.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:29 $
|
||||
*/
|
||||
|
||||
#include "sj_euc.h"
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
#include "sj_dict.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
int codesize(u_char code) {
|
||||
switch(code & KANJIMODEMASK) {
|
||||
case ZENHIRAASSYUKU:
|
||||
case ZENKATAASSYUKU:
|
||||
case KANJIASSYUKU:
|
||||
case KANJISTREND:
|
||||
return 1;
|
||||
case LEADINGHANKAKU:
|
||||
case OFFSETASSYUKU:
|
||||
case AIATTRIBUTE:
|
||||
return 2;
|
||||
default:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
299
lib/sj4core/chrtbl.c
Normal file
299
lib/sj4core/chrtbl.c
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: chrtbl.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:30 $
|
||||
*/
|
||||
|
||||
#include "sj_const.h"
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
u_char chrtbl[256] =
|
||||
{
|
||||
0,
|
||||
FZKTOP,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU + BEFORNUM,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
DICTOP + NUMBER,
|
||||
DICTOP + NUMBER,
|
||||
DICTOP + NUMBER,
|
||||
DICTOP + NUMBER,
|
||||
DICTOP + NUMBER,
|
||||
DICTOP + NUMBER,
|
||||
DICTOP + NUMBER,
|
||||
DICTOP + NUMBER,
|
||||
DICTOP + NUMBER,
|
||||
DICTOP + NUMBER,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DICTOP + TAI_KGU,
|
||||
DEPEND,
|
||||
DICTOP,
|
||||
DEPEND,
|
||||
DICTOP,
|
||||
DEPEND,
|
||||
DICTOP,
|
||||
DEPEND,
|
||||
DICTOP,
|
||||
DEPEND,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
FZKTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DEPEND,
|
||||
DICTOP,
|
||||
DEPEND,
|
||||
DICTOP,
|
||||
DEPEND,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DEPEND,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
FZKTOP,
|
||||
DICTOP,
|
||||
DICTOP,
|
||||
DEPEND,
|
||||
DEPEND,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
FZK_KGU,
|
||||
FZK_KGU,
|
||||
FZK_KGU + MIDNUM,
|
||||
FZK_KGU + MIDNUM,
|
||||
FZK_KGU + TAI_KGU,
|
||||
FZK_KGU + TAI_KGU,
|
||||
TAI_KGU + BEFORNUM,
|
||||
TAI_KGU,
|
||||
FZK_KGU,
|
||||
TAI_KGU,
|
||||
TAI_KGU,
|
||||
TAI_KGU,
|
||||
TAI_KGU,
|
||||
0};
|
||||
192
lib/sj4core/cl2knj.c
Normal file
192
lib/sj4core/cl2knj.c
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: cl2knj.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:31 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static CLREC *nextrecblk(SJ4_CONTEXT2), *prevrecblk(SJ4_CONTEXT2);
|
||||
|
||||
static void initkbuf(SJ4_CONTEXT u_char*);
|
||||
|
||||
int cl2knj(SJ4_CONTEXT u_char* yomi, int len, u_char* kouho) {
|
||||
u_char* ptr1;
|
||||
u_char* ptr2;
|
||||
int i;
|
||||
|
||||
khcount = nkhcount = 0;
|
||||
|
||||
initkbuf(SJ4_CONTEXT_PASS kouho);
|
||||
|
||||
if(len > MAXCLINPUTLEN * 2) len = MAXCLINPUTLEN * 2;
|
||||
|
||||
ptr1 = yomi;
|
||||
ptr2 = hyomi;
|
||||
for(i = 0; i < len; i++) {
|
||||
if(isknj1(*ptr1)) {
|
||||
if(++i >= len) break;
|
||||
}
|
||||
ptr1 += sj2cd_chr(ptr1, ptr2++);
|
||||
}
|
||||
*ptr2 = 0;
|
||||
|
||||
strlcpy((char*)orgyomi, (char*)yomi, (int)(ptr1 - yomi) + 1);
|
||||
|
||||
if(!hyomi[0]) return 0;
|
||||
|
||||
freework(SJ4_CONTEXT_PASS2);
|
||||
|
||||
inputyomi = orgyomi;
|
||||
cnvstart = ystart = hyomi;
|
||||
cnvlen = sstrlen(hyomi);
|
||||
|
||||
mkjiritu(SJ4_CONTEXT_PASS 0);
|
||||
|
||||
mkbunsetu(SJ4_CONTEXT_PASS2);
|
||||
|
||||
if(!maxclptr) wakachi(SJ4_CONTEXT_PASS2);
|
||||
|
||||
jrt1st = maxjptr;
|
||||
clt1st = maxclptr;
|
||||
|
||||
mkkouho(SJ4_CONTEXT_PASS2);
|
||||
|
||||
getrank(SJ4_CONTEXT_PASS2);
|
||||
|
||||
selectid = 1;
|
||||
|
||||
cvtclknj(SJ4_CONTEXT_PASS2);
|
||||
|
||||
return hzstrlen(inputyomi, (int)clt1st->cllen);
|
||||
}
|
||||
|
||||
int nextcl(SJ4_CONTEXT u_char* kouho, int mode) {
|
||||
CLREC* clptr;
|
||||
|
||||
initkbuf(SJ4_CONTEXT_PASS kouho);
|
||||
|
||||
if(!khcount) return 0;
|
||||
|
||||
if(!mode && (selectid < khcount))
|
||||
selectid++;
|
||||
|
||||
else if((mode < 2) && (clptr = nextrecblk(SJ4_CONTEXT_PASS2))) {
|
||||
selectid = 1;
|
||||
clt1st = clptr;
|
||||
mkkouho(SJ4_CONTEXT_PASS2);
|
||||
getrank(SJ4_CONTEXT_PASS2);
|
||||
} else {
|
||||
cvtclknj(SJ4_CONTEXT_PASS2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cvtclknj(SJ4_CONTEXT_PASS2);
|
||||
|
||||
return hzstrlen(inputyomi, (int)clt1st->cllen);
|
||||
}
|
||||
|
||||
static CLREC*
|
||||
nextrecblk(SJ4_CONTEXT2) {
|
||||
CLREC* clptr;
|
||||
int keeplen;
|
||||
|
||||
keeplen = clt1st->cllen;
|
||||
|
||||
clptr = clt1st->clsort;
|
||||
|
||||
while(clptr && (int)clptr->cllen == keeplen)
|
||||
clptr = clptr->clsort;
|
||||
|
||||
return clptr;
|
||||
}
|
||||
|
||||
int prevcl(SJ4_CONTEXT u_char* kouho, int mode) {
|
||||
CLREC* clptr;
|
||||
|
||||
initkbuf(SJ4_CONTEXT_PASS kouho);
|
||||
|
||||
if(!khcount) return 0;
|
||||
|
||||
if(!mode && (selectid > 1))
|
||||
selectid--;
|
||||
|
||||
else if((mode < 2) && (clptr = prevrecblk(SJ4_CONTEXT_PASS2))) {
|
||||
clt1st = clptr;
|
||||
mkkouho(SJ4_CONTEXT_PASS2);
|
||||
getrank(SJ4_CONTEXT_PASS2);
|
||||
selectid = khcount;
|
||||
} else {
|
||||
cvtclknj(SJ4_CONTEXT_PASS2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cvtclknj(SJ4_CONTEXT_PASS2);
|
||||
|
||||
return hzstrlen(inputyomi, (int)clt1st->cllen);
|
||||
}
|
||||
|
||||
static CLREC*
|
||||
prevrecblk(SJ4_CONTEXT2) {
|
||||
CLREC* clptr;
|
||||
CLREC* keepptr;
|
||||
int keeplen;
|
||||
int cllen;
|
||||
|
||||
clptr = maxclptr;
|
||||
|
||||
if((cllen = clt1st->cllen) == clptr->cllen)
|
||||
return NULL;
|
||||
|
||||
while((int)clptr->cllen > cllen) {
|
||||
keeplen = clptr->cllen;
|
||||
|
||||
keepptr = clptr;
|
||||
|
||||
while((int)clptr->cllen == keeplen)
|
||||
clptr = clptr->clsort;
|
||||
}
|
||||
|
||||
return keepptr;
|
||||
}
|
||||
|
||||
static void
|
||||
initkbuf(SJ4_CONTEXT u_char* kouho) {
|
||||
kanjitmp = kouho;
|
||||
memset(kanjitmp, 0, sizeof(STDYOUT) + 1);
|
||||
}
|
||||
|
||||
int selectnum(SJ4_CONTEXT2) {
|
||||
return selectid;
|
||||
}
|
||||
256
lib/sj4core/clstudy.c
Normal file
256
lib/sj4core/clstudy.c
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: clstudy.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:32 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static u_char *delcldata(SJ4_CONTEXT u_char*), *srchclpos(SJ4_CONTEXT u_char*);
|
||||
static int delclold(SJ4_CONTEXT2);
|
||||
|
||||
int clstudy(SJ4_CONTEXT u_char* yomi1, u_char* yomi2, STDYOUT* stdy) {
|
||||
u_char ytmp[CLSTDY_TMPLEN];
|
||||
u_char *dst, *ptr;
|
||||
int ret;
|
||||
int len1, len2;
|
||||
int alen, blen;
|
||||
int i;
|
||||
|
||||
if(!StudyExist()) return CLSTUDYNODICT;
|
||||
|
||||
if(!yomi1 || !*yomi1) return CLSTUDYPARAERR;
|
||||
|
||||
if(!yomi2 || !*yomi2) {
|
||||
if(!sj2cd_str(yomi1, ytmp, CLSTDY_TMPLEN))
|
||||
return CLSTUDYYOMIERR;
|
||||
|
||||
(void)delcldata(SJ4_CONTEXT_PASS ytmp);
|
||||
|
||||
ret = CLSTUDYNORMEND;
|
||||
} else if(!stdy)
|
||||
return CLSTUDYPARAERR;
|
||||
|
||||
else {
|
||||
if(!sj2cd_str(yomi1, ytmp, CLSTDY_TMPLEN))
|
||||
return CLSTUDYYOMIERR;
|
||||
len1 = sstrlen(ytmp);
|
||||
|
||||
if(!sj2cd_str(yomi2, ytmp + len1, CLSTDY_TMPLEN - len1))
|
||||
return CLSTUDYYOMIERR;
|
||||
len2 = len1 + stdy->len;
|
||||
|
||||
ytmp[len2] = 0;
|
||||
|
||||
alen = len2 + CL_HDLEN;
|
||||
|
||||
if(alen + 1 >= CLSTUDYLEN) return CLSTUDYNOAREA;
|
||||
|
||||
blen = CLSTUDYTAIL - delcldata(SJ4_CONTEXT_PASS ytmp) - 1;
|
||||
|
||||
while(blen < alen) {
|
||||
if(!(i = delclold(SJ4_CONTEXT_PASS2))) break;
|
||||
blen += i;
|
||||
}
|
||||
|
||||
if(blen >= alen) {
|
||||
dst = srchclpos(SJ4_CONTEXT_PASS ytmp);
|
||||
|
||||
ptr = CLSTUDYTAIL - alen;
|
||||
mvmemd(ptr, CLSTUDYTAIL, (ptr - dst));
|
||||
ClYomiLen(dst) = (u_char)len2;
|
||||
ClGramCode(dst) = stdy->hinshi;
|
||||
ClYomi1Len(dst) = (u_char)len1;
|
||||
ClSetNum(dst, 1);
|
||||
memcpy(ClYomiPos(dst), ytmp, len2);
|
||||
|
||||
ret = CLSTUDYNORMEND;
|
||||
} else
|
||||
ret = CLSTUDYNOAREA;
|
||||
}
|
||||
mkclidx(SJ4_CONTEXT_PASS2);
|
||||
putcldic(SJ4_CONTEXT_PASS2);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static u_char*
|
||||
delcldata(SJ4_CONTEXT u_char* ycode) {
|
||||
u_char* tagptr;
|
||||
u_char* ptr1;
|
||||
u_char* ptr2;
|
||||
int len1;
|
||||
|
||||
tagptr = CLSTUDYDICT;
|
||||
while(!iseocl(tagptr)) {
|
||||
ptr1 = ycode;
|
||||
ptr2 = ClYomiPos(tagptr);
|
||||
len1 = ClYomiLen(tagptr);
|
||||
|
||||
while(*ptr1 && len1) {
|
||||
if(*ptr1 != *ptr2) break;
|
||||
ptr1++;
|
||||
ptr2++;
|
||||
len1--;
|
||||
}
|
||||
if(!*ptr1 || !len1) {
|
||||
delclsub(SJ4_CONTEXT_PASS tagptr);
|
||||
} else {
|
||||
tagptr = ClNextTag(tagptr);
|
||||
}
|
||||
}
|
||||
|
||||
return tagptr;
|
||||
}
|
||||
|
||||
void delclsub(SJ4_CONTEXT u_char* target) {
|
||||
u_char* src;
|
||||
int num;
|
||||
int tmp;
|
||||
int len;
|
||||
|
||||
num = ClGetNum(target);
|
||||
|
||||
len = ClBlkLen(target);
|
||||
|
||||
src = target + len;
|
||||
|
||||
mvmemi(src, target, (CLSTUDYTAIL - src));
|
||||
|
||||
memset(CLSTUDYTAIL - len, 0, len);
|
||||
|
||||
src = CLSTUDYDICT;
|
||||
while(!iseocl(src)) {
|
||||
tmp = ClGetNum(src);
|
||||
|
||||
if(tmp > num) {
|
||||
tmp -= 1;
|
||||
ClSetNum(src, tmp);
|
||||
}
|
||||
|
||||
src = ClNextTag(src);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
delclold(SJ4_CONTEXT2) {
|
||||
u_char* tagptr;
|
||||
u_char* target;
|
||||
int num;
|
||||
int tmp;
|
||||
|
||||
target = NULL;
|
||||
num = 0;
|
||||
|
||||
tagptr = CLSTUDYDICT;
|
||||
while(!iseocl(tagptr)) {
|
||||
tmp = ClGetNum(tagptr);
|
||||
|
||||
if(tmp >= num) {
|
||||
num = tmp;
|
||||
target = tagptr;
|
||||
}
|
||||
|
||||
tagptr = ClNextTag(tagptr);
|
||||
}
|
||||
|
||||
if(target) {
|
||||
num = ClBlkLen(tagptr);
|
||||
delclsub(SJ4_CONTEXT_PASS target);
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
static u_char*
|
||||
srchclpos(SJ4_CONTEXT u_char* ycode) {
|
||||
u_char* tagptr;
|
||||
u_char* target;
|
||||
u_char* ptr1;
|
||||
u_char* ptr2;
|
||||
int len;
|
||||
int tmp;
|
||||
|
||||
target = NULL;
|
||||
tagptr = CLSTUDYDICT;
|
||||
while(!iseocl(tagptr)) {
|
||||
tmp = ClGetNum(tagptr);
|
||||
|
||||
tmp++;
|
||||
ClSetNum(tagptr, tmp);
|
||||
|
||||
ptr1 = ycode;
|
||||
ptr2 = ClYomiPos(tagptr);
|
||||
len = ClYomiLen(tagptr);
|
||||
while(*ptr1 && len) {
|
||||
if(*ptr1 != *ptr2) break;
|
||||
ptr1++;
|
||||
ptr2++;
|
||||
len--;
|
||||
}
|
||||
|
||||
if(!target) {
|
||||
if(!len)
|
||||
;
|
||||
else if(!*ptr1)
|
||||
target = tagptr;
|
||||
else if(*ptr1 < *ptr2)
|
||||
target = tagptr;
|
||||
}
|
||||
tagptr = ClNextTag(tagptr);
|
||||
}
|
||||
|
||||
return target ? target : tagptr;
|
||||
}
|
||||
|
||||
void mkclidx(SJ4_CONTEXT2) {
|
||||
u_char* ptr;
|
||||
int num;
|
||||
int st, ed;
|
||||
|
||||
if(!StudyExist()) return;
|
||||
|
||||
ptr = CLSTUDYDICT;
|
||||
for(num = st = 0; st < 0x100; num++, st = ed) {
|
||||
ed = st + CLSTUDYSTEP;
|
||||
while(!iseocl(ptr)) {
|
||||
if((unsigned int)*ClYomiPos(ptr) >= st) break;
|
||||
ptr = ClNextTag(ptr);
|
||||
}
|
||||
if(ClYomiLen(ptr) && ((int)*ClYomiPos(ptr) < ed))
|
||||
CLSTUDYIDX[num] = ptr - CLSTUDYDICT;
|
||||
else
|
||||
CLSTUDYIDX[num] = (u_short)-1;
|
||||
}
|
||||
}
|
||||
52
lib/sj4core/cmpstr.c
Normal file
52
lib/sj4core/cmpstr.c
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: cmpstr.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:32 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_const.h"
|
||||
#include "sj_typedef.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
int cmpstr(u_char* src, u_char* dst) {
|
||||
while(*src) {
|
||||
if(*src != *dst) return FALSE;
|
||||
src++;
|
||||
dst++;
|
||||
}
|
||||
|
||||
if(*dst) return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
1177
lib/sj4core/conjunc.c
Normal file
1177
lib/sj4core/conjunc.c
Normal file
File diff suppressed because it is too large
Load diff
7868
lib/sj4core/connect.c
Normal file
7868
lib/sj4core/connect.c
Normal file
File diff suppressed because it is too large
Load diff
57
lib/sj4core/cvtclknj.c
Normal file
57
lib/sj4core/cvtclknj.c
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: cvtclknj.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:38 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
void cvtclknj(SJ4_CONTEXT2) {
|
||||
KHREC* krec;
|
||||
int i;
|
||||
|
||||
if(!selectid) selectid = khcount;
|
||||
|
||||
i = khcount;
|
||||
krec = kouhotbl;
|
||||
|
||||
while(i--) {
|
||||
if((int)krec->rank == (int)selectid) break;
|
||||
krec++;
|
||||
}
|
||||
|
||||
setstyrec(SJ4_CONTEXT_PASS krec);
|
||||
|
||||
cvtkouho(SJ4_CONTEXT_PASS krec);
|
||||
}
|
||||
212
lib/sj4core/cvtdict.c
Normal file
212
lib/sj4core/cvtdict.c
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: cvtdict.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:40 $
|
||||
*/
|
||||
|
||||
#include "sj_euc.h"
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
void cvtdict(SJ4_CONTEXT KHREC* krec, CLREC* clrec, int flg) {
|
||||
TypeDicOfs ofs;
|
||||
u_char* yptr;
|
||||
int jlen;
|
||||
int stblen;
|
||||
int sttlen;
|
||||
u_char* fptr;
|
||||
int cllen;
|
||||
JREC* jrec;
|
||||
int i, j;
|
||||
|
||||
ofs = krec->offs;
|
||||
jrec = clrec->jnode;
|
||||
cllen = clrec->cllen;
|
||||
|
||||
yptr = inputyomi;
|
||||
|
||||
jlen = jrec->jlen;
|
||||
|
||||
if((i = jrec->sttofs)) {
|
||||
|
||||
if(i == SETTOU_KIGOU) {
|
||||
sttlen = 1;
|
||||
fptr = yptr;
|
||||
}
|
||||
|
||||
else {
|
||||
fptr = Settou_ptr(i);
|
||||
sttlen = SttYomiLen(fptr);
|
||||
fptr++;
|
||||
if(!krec->sttkj) fptr += 2;
|
||||
}
|
||||
|
||||
*kanjitmp++ = *fptr++;
|
||||
*kanjitmp++ = *fptr++;
|
||||
jlen -= sttlen;
|
||||
yptr += sttlen * 2;
|
||||
}
|
||||
|
||||
else
|
||||
sttlen = 0;
|
||||
|
||||
if(flg) {
|
||||
|
||||
(*Cvtnum_func[krec->mode - 1])(SJ4_CONTEXT_PASS ystart + sttlen, yptr, jrec);
|
||||
|
||||
yptr += (i = jrec->numlen) * 2;
|
||||
jlen -= i;
|
||||
|
||||
if(jrec->stbofs) {
|
||||
*kanjitmp++ = *yptr++;
|
||||
*kanjitmp++ = *yptr++;
|
||||
jlen--;
|
||||
}
|
||||
|
||||
stblen = 0;
|
||||
}
|
||||
|
||||
else if((i = jrec->stbofs) && (fptr = getstb(jrec->hinsi))) {
|
||||
fptr += i - 1;
|
||||
stblen = StbYomiLen(fptr);
|
||||
jlen -= stblen;
|
||||
}
|
||||
|
||||
else {
|
||||
stblen = 0;
|
||||
}
|
||||
|
||||
if(ofs) {
|
||||
if(seldict(SJ4_CONTEXT_PASS jrec->dicid)) {
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, jrec->jseg);
|
||||
get_askknj(SJ4_CONTEXT_PASS2);
|
||||
kanjitmp +=
|
||||
getkanji(SJ4_CONTEXT_PASS yptr, jlen, dicbuf + ofs, kanjitmp);
|
||||
yptr += jlen * 2;
|
||||
} else {
|
||||
while(jlen-- > 0) {
|
||||
for(i = 0; i < euc_codesize(*yptr); i++)
|
||||
*kanjitmp++ = yptr[i];
|
||||
yptr += euc_codesize(*yptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(stblen) {
|
||||
i = StbKnjLen(fptr);
|
||||
fptr += stblen + 2;
|
||||
while(i-- > 0) *kanjitmp++ = *fptr++;
|
||||
yptr += stblen * 2;
|
||||
}
|
||||
|
||||
i = cllen - (jrec->jlen);
|
||||
while(i-- > 0) {
|
||||
for(j = 0; j < euc_codesize(*yptr); j++)
|
||||
*kanjitmp++ = yptr[j];
|
||||
yptr += euc_codesize(*yptr);
|
||||
}
|
||||
}
|
||||
|
||||
void cvtminasi(SJ4_CONTEXT int len) {
|
||||
u_char* ptr;
|
||||
|
||||
ptr = inputyomi;
|
||||
|
||||
while(len-- > 0) {
|
||||
|
||||
if(isknj1(*ptr)) {
|
||||
*kanjitmp++ = *ptr++;
|
||||
*kanjitmp++ = *ptr++;
|
||||
}
|
||||
|
||||
else if(*ptr == SS3) {
|
||||
*kanjitmp++ = *ptr++;
|
||||
*kanjitmp++ = *ptr++;
|
||||
*kanjitmp++ = *ptr++;
|
||||
} else {
|
||||
*kanjitmp++ = *ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cvtwakachi(SJ4_CONTEXT CLREC* clrec) {
|
||||
int jlen;
|
||||
u_char* ym;
|
||||
int cnt;
|
||||
u_char ch;
|
||||
|
||||
ym = inputyomi;
|
||||
|
||||
cnt = jlen = clrec->jnode->jlen;
|
||||
while(cnt-- > 0) {
|
||||
if(isknj1(*ym)) {
|
||||
|
||||
if(*ym == 0xa4) {
|
||||
ch = *++ym;
|
||||
if(0xa1 <= ch && ch <= 0xf3) {
|
||||
*kanjitmp++ = 0xa5;
|
||||
} else {
|
||||
*kanjitmp++ = 0xa4;
|
||||
}
|
||||
*kanjitmp++ = ch;
|
||||
ym++;
|
||||
} else {
|
||||
*kanjitmp++ = *ym++;
|
||||
*kanjitmp++ = *ym++;
|
||||
}
|
||||
} else if(*ym == SS3) {
|
||||
*kanjitmp++ = *ym++;
|
||||
*kanjitmp++ = *ym++;
|
||||
*kanjitmp++ = *ym++;
|
||||
} else {
|
||||
*kanjitmp++ = *ym++;
|
||||
}
|
||||
}
|
||||
|
||||
cnt = clrec->cllen - jlen;
|
||||
while(cnt-- > 0) {
|
||||
|
||||
if(isknj1(*ym)) {
|
||||
*kanjitmp++ = *ym++;
|
||||
*kanjitmp++ = *ym++;
|
||||
}
|
||||
|
||||
else if(*ym == SS3) {
|
||||
*kanjitmp++ = *ym++;
|
||||
*kanjitmp++ = *ym++;
|
||||
*kanjitmp++ = *ym++;
|
||||
} else {
|
||||
*kanjitmp++ = *ym++;
|
||||
}
|
||||
}
|
||||
}
|
||||
175
lib/sj4core/cvtkanji.c
Normal file
175
lib/sj4core/cvtkanji.c
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: cvtkanji.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:41 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
void cvtphknj(SJ4_CONTEXT2) {
|
||||
int i, j;
|
||||
CLREC* clrec;
|
||||
CLREC* clkp;
|
||||
|
||||
if(!kanjilen) goto not_enough_memory;
|
||||
|
||||
khcount = 0;
|
||||
clkp = NULL;
|
||||
stdytop = NULL;
|
||||
|
||||
clrec = clt1st;
|
||||
while(clrec) {
|
||||
if(ph_khtbl(SJ4_CONTEXT_PASS clrec)) clkp = clrec;
|
||||
clrec = clrec->clsort;
|
||||
}
|
||||
|
||||
if(clkp && stdytop) {
|
||||
|
||||
if(stdytop->nmflg)
|
||||
ph_setkouho(SJ4_CONTEXT_PASS clkp, (TypeDicOfs)0, (STDYIN*)0);
|
||||
}
|
||||
|
||||
kouhotbl[0].rank = 1;
|
||||
|
||||
kanjitmp = kanjibuf + 1;
|
||||
|
||||
setstyrec(SJ4_CONTEXT_PASS kouhotbl);
|
||||
|
||||
cvtkouho(SJ4_CONTEXT_PASS kouhotbl);
|
||||
|
||||
i = kanjitmp - kanjibuf;
|
||||
if(i < kanjilen) {
|
||||
|
||||
kanjilen -= i;
|
||||
|
||||
ystart += clt1st->cllen;
|
||||
|
||||
j = hzstrlen(inputyomi, (int)clt1st->cllen);
|
||||
kanjibuf[0] = (u_char)j;
|
||||
|
||||
inputyomi += j;
|
||||
|
||||
memcpy(kanjipos, kanjibuf, i);
|
||||
kanjipos += i;
|
||||
} else
|
||||
kanjilen = 0;
|
||||
|
||||
not_enough_memory:
|
||||
|
||||
free_clall(SJ4_CONTEXT_PASS clt1st);
|
||||
free_jall(SJ4_CONTEXT_PASS jrt1st);
|
||||
}
|
||||
|
||||
void cvtkouho(SJ4_CONTEXT KHREC* krec) {
|
||||
CLREC* clrec;
|
||||
|
||||
clrec = krec->clrec;
|
||||
|
||||
switch(clrec->jnode->class) {
|
||||
case C_DICT:
|
||||
cvtdict(SJ4_CONTEXT_PASS krec, clrec, FALSE);
|
||||
break;
|
||||
|
||||
case C_N_ARABIA:
|
||||
case C_N_ARACMA:
|
||||
case C_N_KAZU:
|
||||
case C_N_SUUJI:
|
||||
case C_N_NANSUU:
|
||||
case C_N_KANKURA:
|
||||
case C_N_ARAKURA:
|
||||
case C_N_KAZULONG:
|
||||
case C_N_KAZULCMA:
|
||||
case C_N_SUUJILONG:
|
||||
cvtdict(SJ4_CONTEXT_PASS krec, clrec, TRUE);
|
||||
break;
|
||||
|
||||
case C_BUNSETU:
|
||||
case C_MINASI:
|
||||
cvtminasi(SJ4_CONTEXT_PASS(int) clrec->cllen);
|
||||
break;
|
||||
|
||||
case C_WAKACHI:
|
||||
cvtwakachi(SJ4_CONTEXT_PASS clrec);
|
||||
break;
|
||||
}
|
||||
|
||||
*kanjitmp++ = 0;
|
||||
}
|
||||
|
||||
void setstyrec(SJ4_CONTEXT KHREC* krec) {
|
||||
JREC* jrec;
|
||||
KHREC* kptr;
|
||||
int ii;
|
||||
u_char* fptr;
|
||||
STDYOUT stdy;
|
||||
|
||||
jrec = krec->clrec->jnode;
|
||||
|
||||
if(krec->mode && !krec->offs) {
|
||||
|
||||
for(ii = khcount, kptr = kouhotbl; ii--; kptr++)
|
||||
if(kptr->rank == 1) break;
|
||||
|
||||
stdy.stdy1.offset = kptr->offs;
|
||||
stdy.stdy1.seg = kptr->clrec->jnode->jseg;
|
||||
stdy.stdy1.styno = kptr->styno;
|
||||
stdy.stdy1.dicid = kptr->clrec->jnode->dicid;
|
||||
stdy.stdy1.nmflg = 1;
|
||||
}
|
||||
|
||||
else {
|
||||
stdy.stdy1.offset = krec->offs;
|
||||
stdy.stdy1.seg = jrec->jseg;
|
||||
stdy.stdy1.styno = krec->styno;
|
||||
stdy.stdy1.dicid = jrec->dicid;
|
||||
stdy.stdy1.nmflg = 0;
|
||||
}
|
||||
stdy.stdy1.sttkj = krec->sttkj;
|
||||
stdy.stdy1.ka_kj = krec->ka_kj;
|
||||
stdy.hinshi = jrec->hinsi;
|
||||
stdy.len = jrec->jlen;
|
||||
stdy.sttfg = krec->sttfg;
|
||||
stdy.ka_fg = krec->ka_fg;
|
||||
|
||||
if(jrec->stbofs && (fptr = getstb(jrec->hinsi)))
|
||||
stdy.len -= StbYomiLen(fptr + jrec->stbofs - 1);
|
||||
|
||||
if((fptr = Settou_ptr(jrec->sttofs)))
|
||||
stdy.sttlen = SttYomiLen(fptr);
|
||||
else
|
||||
stdy.sttlen = 0;
|
||||
|
||||
memcpy(kanjitmp, (u_char*)&stdy, sizeof(STDYOUT));
|
||||
kanjitmp += sizeof(STDYOUT);
|
||||
}
|
||||
270
lib/sj4core/deldic.c
Normal file
270
lib/sj4core/deldic.c
Normal file
|
|
@ -0,0 +1,270 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: deldic.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:42 $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static int del_douon(SJ4_CONTEXT TypeDicSeg, u_char*, TypeDicOfs);
|
||||
static int del_segment(SJ4_CONTEXT TypeDicSeg);
|
||||
static void del_uidx(SJ4_CONTEXT TypeDicSeg);
|
||||
static void del_stdy(SJ4_CONTEXT TypeDicSeg, TypeDicOfs, int);
|
||||
|
||||
u_int deldic(SJ4_CONTEXT u_char* yomi, u_char* kanji, TypeGram hinsi) {
|
||||
u_char yptr[MAXWDYOMILEN + 1];
|
||||
u_char kptr[MAXWDKANJILEN + 1];
|
||||
u_short err;
|
||||
int knjlen;
|
||||
TypeDicSeg useg;
|
||||
TypeDicOfs ofs;
|
||||
u_char * p1, *p2, *p3;
|
||||
int dblknum;
|
||||
int hblknum;
|
||||
int kblknum;
|
||||
int samlen;
|
||||
u_char * stp, *edp;
|
||||
int size, len;
|
||||
|
||||
if((err = addel_arg(SJ4_CONTEXT_PASS yomi, kanji, hinsi, yptr, sizeof(yptr))))
|
||||
return err;
|
||||
|
||||
if(!curdict->maxunit) return AD_NOTUSERDICT;
|
||||
|
||||
knjlen = cvtknj(SJ4_CONTEXT_PASS yomi, kanji, kptr);
|
||||
|
||||
cnvstart = yptr;
|
||||
cnvlen = sstrlen(yptr);
|
||||
|
||||
useg = srchidx(SJ4_CONTEXT_PASS(TypeDicSeg) DICSEGBASE, cnvlen);
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, useg);
|
||||
|
||||
if(!(dblknum = srchkana(SJ4_CONTEXT_PASS & p1, &samlen))) return AD_NOMIDASI;
|
||||
|
||||
if(!(hblknum = srchgram(p1, &p2, hinsi))) return AD_NOHINSI;
|
||||
|
||||
p3 = p2;
|
||||
kblknum = srchkanji(&p3, kptr, knjlen);
|
||||
if(*p3 == HINSIBLKTERM) return AD_NOKANJI;
|
||||
ofs = p3 - dicbuf;
|
||||
|
||||
edp = skipkstr(p3);
|
||||
|
||||
if(kblknum == 1) {
|
||||
if(hblknum == 1) {
|
||||
if(dblknum == 1) {
|
||||
return del_segment(SJ4_CONTEXT_PASS useg);
|
||||
} else {
|
||||
return del_douon(SJ4_CONTEXT_PASS useg, p1, ofs);
|
||||
}
|
||||
} else {
|
||||
stp = p2;
|
||||
edp++;
|
||||
}
|
||||
} else {
|
||||
stp = p3;
|
||||
}
|
||||
|
||||
size = edp - stp;
|
||||
|
||||
len = dicbuf + (curdict->seglen) - edp;
|
||||
mvmemi(edp, stp, len);
|
||||
|
||||
edp += len;
|
||||
memset(edp, DICSEGTERM, dicbuf + curdict->seglen - edp);
|
||||
|
||||
set_size(p1, (int)(getsize(p1) - size),
|
||||
(int)getplen(p1), (int)getnlen(p1));
|
||||
|
||||
(*curdict->putdic)(SJ4_CONTEXT_PASS curdict, useg);
|
||||
|
||||
del_stdy(SJ4_CONTEXT_PASS useg, ofs, size);
|
||||
|
||||
return AD_DONE;
|
||||
}
|
||||
|
||||
static int
|
||||
del_douon(SJ4_CONTEXT TypeDicSeg seg, u_char* ptr, TypeDicOfs ofs) {
|
||||
u_char *nxt, *p1, *p2;
|
||||
int size;
|
||||
int nlen, plen, len;
|
||||
|
||||
nxt = getntag(ptr);
|
||||
|
||||
if(segend(nxt)) {
|
||||
size = nxt - ptr;
|
||||
|
||||
memset(ptr, DICSEGTERM, dicbuf + curdict->seglen - nxt);
|
||||
} else {
|
||||
size = getsize(nxt);
|
||||
nlen = getnlen(nxt);
|
||||
plen = getplen(nxt);
|
||||
|
||||
if(ptr == segtop()) {
|
||||
if(nlen + plen > (unsigned int)count_uidx(SJ4_CONTEXT_PASS2) + sstrlen(get_idxptr(SJ4_CONTEXT_PASS seg)))
|
||||
return AD_OVFLWINDEX;
|
||||
}
|
||||
|
||||
len = ((len = getplen(ptr)) < plen) ? plen - len : 0;
|
||||
|
||||
set_size(ptr, size + len, plen - len, nlen + len);
|
||||
|
||||
p1 = nxt + DOUONBLKSIZENUMBER;
|
||||
p2 = ptr + DOUONBLKSIZENUMBER + len;
|
||||
|
||||
mvmemi(p1, p2, dicbuf + curdict->seglen - p1);
|
||||
|
||||
size = p1 - p2;
|
||||
memset(dicbuf + curdict->seglen - size, DICSEGTERM, size);
|
||||
|
||||
if(ptr == segtop()) {
|
||||
chg_uidx(SJ4_CONTEXT_PASS seg, ptr + DOUONBLKSIZENUMBER, nlen + len);
|
||||
}
|
||||
}
|
||||
|
||||
(*curdict->putdic)(SJ4_CONTEXT_PASS curdict, seg);
|
||||
|
||||
del_stdy(SJ4_CONTEXT_PASS seg, ofs, size);
|
||||
|
||||
return AD_DONE;
|
||||
}
|
||||
|
||||
static int
|
||||
del_segment(SJ4_CONTEXT TypeDicSeg seg) {
|
||||
int i;
|
||||
STDYIN* styp;
|
||||
TypeDicID dicid;
|
||||
TypeStyNum stdynum;
|
||||
TypeDicSeg sg;
|
||||
|
||||
if(curdict->segunit > 1) {
|
||||
for(sg = seg + 1; sg < curdict->segunit; sg++) {
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, sg);
|
||||
(*curdict->putdic)(SJ4_CONTEXT_PASS curdict, sg - 1);
|
||||
}
|
||||
curdict->segunit--;
|
||||
} else {
|
||||
memset(dicbuf, DICSEGTERM, (int)curdict->seglen);
|
||||
dicbuf[0] = 0;
|
||||
(*curdict->putdic)(SJ4_CONTEXT_PASS curdict, DICSEGBASE);
|
||||
}
|
||||
|
||||
(*curdict->rszdic)(SJ4_CONTEXT_PASS curdict, curdict->segunit);
|
||||
|
||||
del_uidx(SJ4_CONTEXT_PASS seg);
|
||||
|
||||
if(StudyExist()) {
|
||||
dicid = curdict->dicid;
|
||||
for(i = 0, styp = STUDYDICT; i < STUDYCOUNT;) {
|
||||
if(styp->dicid != dicid)
|
||||
;
|
||||
else if(styp->seg > seg)
|
||||
styp->seg -= 1;
|
||||
else if(styp->seg < seg)
|
||||
;
|
||||
else {
|
||||
stdynum = styp->styno;
|
||||
STUDYCOUNT--;
|
||||
mvmemi((u_char*)(styp + 1), (u_char*)styp,
|
||||
sizeof(*styp) * (STUDYCOUNT - i));
|
||||
continue;
|
||||
}
|
||||
|
||||
i++;
|
||||
styp++;
|
||||
}
|
||||
for(i = 0, styp = STUDYDICT; i < STUDYCOUNT; i++, styp++)
|
||||
if(styp->styno > stdynum) styp->styno -= 1;
|
||||
|
||||
putstydic(SJ4_CONTEXT_PASS2);
|
||||
}
|
||||
|
||||
return AD_DONE;
|
||||
}
|
||||
|
||||
static void
|
||||
del_uidx(SJ4_CONTEXT TypeDicSeg seg) {
|
||||
u_char *p, *q;
|
||||
int len;
|
||||
|
||||
p = get_idxptr(SJ4_CONTEXT_PASS seg);
|
||||
for(q = p; *q++;);
|
||||
|
||||
mvmemi(q, p, idxbuf + curdict->idxlen - q);
|
||||
|
||||
len = q - p;
|
||||
memset(idxbuf + curdict->idxlen - len, 0, len);
|
||||
|
||||
(*curdict->putidx)(SJ4_CONTEXT_PASS curdict, 0);
|
||||
|
||||
mkidxtbl(SJ4_CONTEXT_PASS curdict);
|
||||
}
|
||||
|
||||
static void
|
||||
del_stdy(SJ4_CONTEXT TypeDicSeg seg, TypeDicOfs ofs, int size) {
|
||||
int i;
|
||||
TypeStyNum stdynum;
|
||||
STDYIN* stdy;
|
||||
TypeDicID dicid;
|
||||
|
||||
if(StudyExist()) {
|
||||
|
||||
stdynum = 0;
|
||||
dicid = curdict->dicid;
|
||||
for(i = 0, stdy = STUDYDICT; i < STUDYCOUNT;) {
|
||||
if(stdy->dicid != dicid)
|
||||
;
|
||||
else if(stdy->seg != seg)
|
||||
;
|
||||
else if(stdy->offset > ofs)
|
||||
stdy->offset -= size;
|
||||
|
||||
else if(stdy->offset == ofs) {
|
||||
stdynum = stdy->styno;
|
||||
STUDYCOUNT--;
|
||||
mvmemi((u_char*)(stdy + 1), (u_char*)stdy,
|
||||
sizeof(*stdy) * (STUDYCOUNT - i));
|
||||
continue;
|
||||
}
|
||||
|
||||
i++;
|
||||
stdy++;
|
||||
}
|
||||
for(i = 0, stdy = STUDYDICT; i < STUDYCOUNT; i++, stdy++)
|
||||
if(stdy->styno > stdynum) (stdy->styno)--;
|
||||
|
||||
putstydic(SJ4_CONTEXT_PASS2);
|
||||
}
|
||||
}
|
||||
89
lib/sj4core/dict.c
Normal file
89
lib/sj4core/dict.c
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: dict.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:45 $
|
||||
*/
|
||||
|
||||
#include "sj_euc.h"
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
void get_askknj(SJ4_CONTEXT2) {
|
||||
u_char* p;
|
||||
u_char* q;
|
||||
u_char* r;
|
||||
int i = 0, csize;
|
||||
int flg;
|
||||
|
||||
p = q = dicbuf;
|
||||
|
||||
q += *p++;
|
||||
|
||||
while(p < q) {
|
||||
askknj[i] = p;
|
||||
|
||||
r = NULL;
|
||||
flg = TRUE;
|
||||
do {
|
||||
csize = codesize(*p);
|
||||
if(p[csize] == KANJISTREND) flg = FALSE;
|
||||
|
||||
if(!r && (*p != AIATTRIBUTE))
|
||||
r = p;
|
||||
|
||||
p += csize;
|
||||
} while(flg);
|
||||
p++;
|
||||
askknj_k[i++] = r;
|
||||
}
|
||||
}
|
||||
|
||||
int seldict(SJ4_CONTEXT TypeDicID id) {
|
||||
DICTL* dp;
|
||||
|
||||
for(dp = dictlist; dp; dp = dp->next) {
|
||||
if((curdict = dp->dict)->dicid == id)
|
||||
return TRUE;
|
||||
}
|
||||
curdict = NULL;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u_char*
|
||||
get_idxptr(SJ4_CONTEXT TypeDicSeg seg) {
|
||||
(*curdict->getofs)(SJ4_CONTEXT_PASS curdict);
|
||||
(*curdict->getidx)(SJ4_CONTEXT_PASS curdict);
|
||||
|
||||
return idxbuf + idxofs[seg];
|
||||
}
|
||||
69
lib/sj4core/functbl.c
Normal file
69
lib/sj4core/functbl.c
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: functbl.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:46 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
VFunc cvtnum_func[] = {
|
||||
(VFunc)num_type00, (VFunc)num_type01, (VFunc)num_type02, (VFunc)num_type03,
|
||||
(VFunc)num_type04, (VFunc)num_type05, (VFunc)num_type06, (VFunc)num_type07,
|
||||
(VFunc)num_type08, (VFunc)num_type09, (VFunc)num_type10, (VFunc)num_type11,
|
||||
(VFunc)num_type12, (VFunc)num_type13, (VFunc)num_type14};
|
||||
|
||||
UCPFunc getkan_func[] = {
|
||||
(UCPFunc)getkan_norm, (UCPFunc)getkan_norm, (UCPFunc)getkan_hira, (UCPFunc)getkan_kata,
|
||||
(UCPFunc)getkan_knj, (UCPFunc)getkan_ofs, (UCPFunc)getkan_norm, (UCPFunc)getkan_none,
|
||||
(UCPFunc)getkan_norm, (UCPFunc)getkan_norm, (UCPFunc)getkan_hira, (UCPFunc)getkan_kata,
|
||||
(UCPFunc)getkan_knj, (UCPFunc)getkan_ofs, (UCPFunc)getkan_norm, (UCPFunc)getkan_none};
|
||||
|
||||
IFunc setjrec_func[] = {
|
||||
(IFunc)setj_norm2, (IFunc)setj_norm2, (IFunc)setj_norm1, (IFunc)setj_norm1,
|
||||
(IFunc)setj_knj, (IFunc)setj_ofs, (IFunc)setj_norm2, (IFunc)setj_atrb,
|
||||
(IFunc)setj_norm2, (IFunc)setj_norm2, (IFunc)setj_norm1, (IFunc)setj_norm1,
|
||||
(IFunc)setj_knj, (IFunc)setj_ofs, (IFunc)setj_norm2, (IFunc)setj_atrb};
|
||||
|
||||
IFunc hiraknj_func[] = {
|
||||
(IFunc)hiraknj_hira, (IFunc)hiraknj_norm, (IFunc)hiraknj_hask, (IFunc)hiraknj_kask,
|
||||
(IFunc)hiraknj_knj, (IFunc)hiraknj_ofs, (IFunc)hiraknj_norm, (IFunc)hiraknj_atrb,
|
||||
(IFunc)hiraknj_hira, (IFunc)hiraknj_norm, (IFunc)hiraknj_hask, (IFunc)hiraknj_kask,
|
||||
(IFunc)hiraknj_knj, (IFunc)hiraknj_ofs, (IFunc)hiraknj_norm, (IFunc)hiraknj_atrb};
|
||||
|
||||
UCPFunc makekan_func[] = {
|
||||
(UCPFunc)makekan_norm, (UCPFunc)makekan_norm, (UCPFunc)makekan_1byte, (UCPFunc)makekan_1byte,
|
||||
(UCPFunc)makekan_knj, (UCPFunc)makekan_ofs, (UCPFunc)makekan_norm, (UCPFunc)makekan_none,
|
||||
(UCPFunc)makekan_norm, (UCPFunc)makekan_norm, (UCPFunc)makekan_1byte, (UCPFunc)makekan_1byte,
|
||||
(UCPFunc)makekan_knj, (UCPFunc)makekan_ofs, (UCPFunc)makekan_norm, (UCPFunc)makekan_none};
|
||||
255
lib/sj4core/fuzoku.c
Normal file
255
lib/sj4core/fuzoku.c
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: fuzoku.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:47 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_hinsi.h"
|
||||
#include "sj_right.h"
|
||||
#include "sj_yomi.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static int
|
||||
fzkstrcmp(u_char* yptr, u_char* fzkp, int* saml) {
|
||||
int asklen, nkrlen;
|
||||
|
||||
asklen = FzkAskLen(fzkp);
|
||||
|
||||
if(*saml < asklen) return CONT;
|
||||
|
||||
if(*saml > asklen) return OVER;
|
||||
|
||||
nkrlen = FzkNkrLen(fzkp);
|
||||
|
||||
yptr += asklen;
|
||||
fzkp++;
|
||||
|
||||
while(nkrlen--) {
|
||||
if(*yptr > *fzkp)
|
||||
return CONT;
|
||||
|
||||
else if(*yptr < *fzkp) {
|
||||
if(!*yptr) return PARTLY;
|
||||
return OVER;
|
||||
}
|
||||
|
||||
else {
|
||||
yptr++;
|
||||
fzkp++;
|
||||
(*saml)++;
|
||||
}
|
||||
}
|
||||
|
||||
return MATCH;
|
||||
}
|
||||
|
||||
void setclrec(SJ4_CONTEXT JREC* jrec, u_char* yptr, TypeCnct right) {
|
||||
CLREC* new;
|
||||
TypeGram hinsi;
|
||||
int len;
|
||||
|
||||
if(!(len = yptr - cnvstart)) return;
|
||||
|
||||
if(len > MAXCLINPUTLEN) return;
|
||||
|
||||
if(!(new = argclrec(SJ4_CONTEXT_PASS len))) return;
|
||||
|
||||
new->jnode = jrec;
|
||||
new->gobiln = gobilen;
|
||||
new->right = right;
|
||||
new->fzk_ka = fzk_ka_flg;
|
||||
(jrec->count)++;
|
||||
|
||||
hinsi = jrec->hinsi;
|
||||
|
||||
if(hinsi >= DO_SAHEN && hinsi <= SP_KA_ONB)
|
||||
new->kubun = K_DOUSHI;
|
||||
|
||||
else if((hinsi >= KEIYOUSI_1 && hinsi <= KE_DOUSI_9) ||
|
||||
(hinsi == SP_KEIYOUSI)) {
|
||||
if(right == R_FZKMEISI)
|
||||
new->kubun = K_TAIGEN;
|
||||
else
|
||||
new->kubun = K_YOUGEN;
|
||||
}
|
||||
|
||||
else if(hinsi == RENTAISI)
|
||||
new->kubun = K_RENTAISI;
|
||||
|
||||
else if((hinsi >= FUKUSI_1 && hinsi <= FUKUSI_9) ||
|
||||
(hinsi == SP_FUKUSI))
|
||||
new->kubun = K_FUKUSI;
|
||||
|
||||
else if(hinsi == SETUZOKU || hinsi == KANDOUSI ||
|
||||
hinsi == TANKANJI || hinsi == AISATU)
|
||||
new->kubun = K_SONOTA;
|
||||
|
||||
else if(gobilen) {
|
||||
if(hinsi >= MEISI_5 && hinsi <= MEISI_7)
|
||||
new->kubun = K_DOUSHI;
|
||||
|
||||
else if(hinsi == D_MEISI_4)
|
||||
new->kubun = K_DOUSHI;
|
||||
|
||||
else if(hinsi == SETUBI_7 || hinsi == SETUBI_8)
|
||||
new->kubun = K_DOUSHI;
|
||||
|
||||
else if(hinsi == D_MEISI_5)
|
||||
new->kubun = K_YOUGEN;
|
||||
|
||||
else if(hinsi == SETUBI_5 || hinsi == SETUBI_6)
|
||||
new->kubun = K_YOUGEN;
|
||||
else
|
||||
new->kubun = K_TAIGEN;
|
||||
} else if(hinsi >= MEISI_5 && hinsi <= MEISI_7) {
|
||||
if(right >= R_I && right <= R_ITADAKE)
|
||||
new->kubun = K_DOUSHI;
|
||||
|
||||
else if(right >= R_DESHI && right <= R_TAI)
|
||||
new->kubun = K_DOUSHI;
|
||||
|
||||
else if(right >= R_NAI && right <= R_MEIREI2)
|
||||
new->kubun = K_DOUSHI;
|
||||
|
||||
else if(right == R_TE2 || right == R_TERU)
|
||||
new->kubun = K_DOUSHI;
|
||||
else
|
||||
new->kubun = K_TAIGEN;
|
||||
} else
|
||||
new->kubun = K_TAIGEN;
|
||||
}
|
||||
|
||||
static int
|
||||
fzkcnct(TypeCnct right, TypeCnct left) {
|
||||
u_char* cncttbl;
|
||||
|
||||
if(right && left) {
|
||||
cncttbl = Rigtadr(right);
|
||||
left--;
|
||||
if(cncttbl[left >> 3] << (left & 0x07) & 0x80)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RECURS
|
||||
void srchfzk(SJ4_CONTEXT JREC* jrec, u_char* yptr, TypeCnct right, int level) {
|
||||
u_char* fzk;
|
||||
int len = 0;
|
||||
int cmp;
|
||||
u_char* next;
|
||||
FREC* fzkrec;
|
||||
int i;
|
||||
int nlen;
|
||||
TypeCnct rt;
|
||||
|
||||
if((level >= MAXFLVL) && !(Chrtbl[*yptr] & FZK_KGU)) return;
|
||||
|
||||
if(terminate(SJ4_CONTEXT_PASS right, yptr) && Chrtbl[*yptr] & FZK_KGU) {
|
||||
if(!level) fzk_ka_flg = 0;
|
||||
yptr++;
|
||||
while(Chrtbl[*yptr] & FZK_KGU) yptr++;
|
||||
setclrec(SJ4_CONTEXT_PASS jrec, yptr, (TypeCnct)R_FZKKGU);
|
||||
return;
|
||||
}
|
||||
|
||||
if(right == R_CUT) return;
|
||||
|
||||
if(!*yptr) return;
|
||||
|
||||
if(!(*yptr >= _XA && *yptr <= _NN)) return;
|
||||
|
||||
fzkrec = fzktbl;
|
||||
|
||||
for(i = fzkcount; i; i--, fzkrec++) {
|
||||
|
||||
if(yptr != fzkrec->yomip) continue;
|
||||
|
||||
fzk = fzkrec->fzkp;
|
||||
|
||||
len = FzkAskLen(fzk) + (nlen = FzkNkrLen(fzk)) + 1;
|
||||
|
||||
if(!fzkcnct(right, (TypeCnct)FzkLeft(fzk))) continue;
|
||||
|
||||
if(!level) fzk_ka_flg = FzkStrKa(fzk);
|
||||
|
||||
next = yptr + len;
|
||||
|
||||
if(terminate(SJ4_CONTEXT_PASS rt = FzkRight(fzk), next)) {
|
||||
setclrec(SJ4_CONTEXT_PASS jrec, next, rt);
|
||||
}
|
||||
|
||||
srchfzk(SJ4_CONTEXT_PASS jrec, next, rt, level + 1);
|
||||
}
|
||||
|
||||
if(len) return;
|
||||
|
||||
if(!(fzk = Fzkadr(*yptr - _XA))) return;
|
||||
|
||||
yptr++;
|
||||
|
||||
for(; *fzk != FZKEND; fzk += nlen + (i ? 4 : 3)) {
|
||||
|
||||
nlen = FzkNkrLen(fzk);
|
||||
i = FzkHasCode(fzk);
|
||||
|
||||
cmp = fzkstrcmp(yptr, fzk, &len);
|
||||
|
||||
if(cmp == OVER)
|
||||
break;
|
||||
|
||||
else if(cmp == PARTLY)
|
||||
break;
|
||||
|
||||
else if((cmp != MATCH) || isdpnd(*(yptr + len)))
|
||||
continue;
|
||||
|
||||
fzktbl[fzkcount].yomip = yptr - 1;
|
||||
fzktbl[fzkcount].fzkp = fzk;
|
||||
fzkcount++;
|
||||
|
||||
if(!fzkcnct(right, (TypeCnct)FzkLeft(fzk))) continue;
|
||||
|
||||
if(!level) fzk_ka_flg = FzkStrKa(fzk);
|
||||
|
||||
next = yptr + len;
|
||||
|
||||
if(terminate(SJ4_CONTEXT_PASS rt = FzkRight(fzk), next)) {
|
||||
setclrec(SJ4_CONTEXT_PASS jrec, next, rt);
|
||||
}
|
||||
|
||||
srchfzk(SJ4_CONTEXT_PASS jrec, next, rt, level + 1);
|
||||
}
|
||||
}
|
||||
716
lib/sj4core/fzkyomi.c
Normal file
716
lib/sj4core/fzkyomi.c
Normal file
|
|
@ -0,0 +1,716 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: fzkyomi.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:48 $
|
||||
*/
|
||||
|
||||
#include "sj_const.h"
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
#include "sj_yomi.h"
|
||||
#include "sj_right.h"
|
||||
#include "sj_left.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static u_char fzk_wo[] = {
|
||||
(0 << 5) + 0, L_WO, R_WO,
|
||||
(0 << 5) + 0, L_WO_S, R_WO_S,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_xtu[] = {
|
||||
(0 << 5) + 1, _KE, L_KKE, R_SHUUJO,
|
||||
(0 << 5) + 3, _TA, _XTU, _TE, L_TTATTE, R_TTATTE,
|
||||
(1 << 5) + 1, _RA, L_TTARA, R_TTARA,
|
||||
(2 << 5) + 2, _SI, _I, L_TTARASII, R_KSHUUSI,
|
||||
(3 << 5) + 2, _KA, _XTU, L_TTARASII, R_ONBIN1,
|
||||
(4 << 5) + 2, _RO, _U, L_TTARASII, R_KAROU,
|
||||
(3 << 5) + 1, _KU, L_TTARASII, R_KRENYOU,
|
||||
(3 << 5) + 2, _KE, _RE, L_TTARASII, R_KATEI1,
|
||||
(3 << 5) + 1, _SA, L_TTARASII, R_FZKMEISI,
|
||||
(0 << 5) + 1, _TE, L_TTE1, R_TTE1,
|
||||
(1 << 5) + 0, L_TTE2, R_TTE2,
|
||||
(0 << 5) + 3, _PA, _NA, _SI, L_PPANASI, R_PPANASI,
|
||||
(0 << 5) + 2, _PO, _I, L_PPOI, R_PPOI,
|
||||
(1 << 5) + 2, _KA, _XTU, L_PPOI, R_ONBIN1,
|
||||
(2 << 5) + 2, _RO, _U, L_PPOI, R_KAROU,
|
||||
(1 << 5) + 1, _KU, L_PPOI, R_KRENYOU,
|
||||
(1 << 5) + 2, _KE, _RE, L_PPOI, R_KATEI1,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_a[] = {
|
||||
(0 << 5) + 1, _GE, L_YOUGEN, R_AGE,
|
||||
(1 << 5) + 1, _YO, L_YOUGEN, R_MEIREI2,
|
||||
(1 << 5) + 1, _RU, L_YOUGEN, R_SHUUSI,
|
||||
(1 << 5) + 1, _RE, L_YOUGEN, R_KATEI3,
|
||||
(1 << 5) + 1, _RO, L_YOUGEN, R_MEIREI1,
|
||||
(0 << 5) + 1, _XTU, L_ARU, R_AXTU,
|
||||
(0 << 5) + 1, _RA, L_ARA, R_MIZEN2,
|
||||
(0 << 5) + 1, _RI, L_ARI1, R_ARI1,
|
||||
(1 << 5) + 0, L_ARI2, R_ARI2,
|
||||
(1 << 5) + 0, L_ARI3, R_ARI3,
|
||||
(0 << 5) + 1, _RU, L_ARU, R_SHUUSI,
|
||||
(0 << 5) + 1, _RE, L_ARE1, R_KAMEI,
|
||||
(1 << 5) + 0, L_ARE2, R_KATEI2,
|
||||
(1 << 5) + 3, _BA, _KO, _SO, L_ARE1, R_CUT,
|
||||
(0 << 5) + 2, _RO, _U, L_AROU, R_AROU,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_i[] = {
|
||||
(0 << 5) + 0, L_IRU, R_I,
|
||||
(0 << 5) + 1, _I, L_II, R_SHUUSI,
|
||||
(0 << 5) + 1, _KA, L_YOUGEN, R_MIZEN5,
|
||||
(0 << 5) + 1, _KI, L_YOUGEN, R_IKI,
|
||||
(0 << 5) + 1, _KU, L_YOUGEN, R_SHUUSI,
|
||||
(0 << 5) + 1, _KE, L_YOUGEN, R_IKE,
|
||||
(0 << 5) + 2, _KO, _U, L_YOUGEN, R_AROU,
|
||||
(0 << 5) + 2, _TA, _SI, L_ITASI, R_ITASI,
|
||||
(1 << 5) + 2, _DA, _I, L_ITADAKU, R_ONBIN2,
|
||||
(2 << 5) + 1, _KA, L_ITADAKU, R_MIZEN4,
|
||||
(2 << 5) + 1, _KI, L_ITADAKU, R_ITADAKI,
|
||||
(2 << 5) + 1, _KU, L_ITADAKU, R_SHUUSI,
|
||||
(2 << 5) + 1, _KE, L_ITADAKU, R_ITADAKE,
|
||||
(2 << 5) + 2, _KO, _U, L_ITADAKU, R_AROU,
|
||||
(0 << 5) + 1, _XTU, L_YOUGEN, R_ONBIN8,
|
||||
(0 << 5) + 1, _YO, L_IRU, R_MEIREI2,
|
||||
(0 << 5) + 1, _RU, L_IRU, R_SHUUSI,
|
||||
(0 << 5) + 1, _RE, L_IRU, R_KATEI2,
|
||||
(0 << 5) + 1, _RO, L_IRU, R_MEIREI1,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_u[] = {
|
||||
(0 << 5) + 1, _E, L_UE, R_UE,
|
||||
(0 << 5) + 1, _TI, L_UTI, R_UTI,
|
||||
(0 << 5) + 1, _RU, L_ERU, R_SHUUSI,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_e[] = {
|
||||
(0 << 5) + 0, L_ERU, R_E,
|
||||
(0 << 5) + 1, _RU, L_ERU, R_SHUUSI,
|
||||
(0 << 5) + 1, _RE, L_ERU, R_KATEI3,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_o[] = {
|
||||
(0 << 5) + 1, _I, L_YOUGEN, R_ONBIN8,
|
||||
(1 << 5) + 1, _TE, L_OITE, R_OITE,
|
||||
(0 << 5) + 1, _KA, L_YOUGEN, R_MIZEN5,
|
||||
(0 << 5) + 1, _KI, L_YOUGEN, R_IKI,
|
||||
(0 << 5) + 1, _KU, L_YOUGEN, R_SHUUSI,
|
||||
(0 << 5) + 1, _KE, L_YOUGEN, R_IKE,
|
||||
(1 << 5) + 1, _RU, L_OKERU, R_OKERU,
|
||||
(0 << 5) + 2, _KO, _U, L_YOUGEN, R_AROU,
|
||||
(0 << 5) + 1, _RA, L_YOUGEN, R_MIZEN2,
|
||||
(0 << 5) + 1, _RI, L_ORI, R_ORI1,
|
||||
(1 << 5) + 0, L_YOUGEN, R_ORI2,
|
||||
(0 << 5) + 1, _RE, L_YOUGEN, R_KAMEI,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ka[] = {
|
||||
(0 << 5) + 0 + 8, L_KA1, R_KA1,
|
||||
(0 << 5) + 0 + 8, L_KA2, R_KA2,
|
||||
(0 << 5) + 1, _I, L_KAI, R_SHUUJO,
|
||||
(0 << 5) + 1, _KE, L_KAKERU, R_KAKE,
|
||||
(1 << 5) + 1, _RU, L_KAKERU, R_SHUUSI,
|
||||
(1 << 5) + 1, _RE, L_KAKERU, R_KATEI3,
|
||||
(0 << 5) + 2, _SI, _RA, L_KASIRA, R_SHUUJO,
|
||||
(2 << 5) + 1, _NE, L_KASIRA, R_SHUUJO,
|
||||
(0 << 5) + 3, _TA, _GA, _TA, L_KATAGATA, R_KATAGATA,
|
||||
(0 << 5) + 3, _DO, _U, _KA, L_KADOUKA, R_KADOUKA,
|
||||
(0 << 5) + 1, _NA, L_KANA, R_SHUUJO,
|
||||
(0 << 5) + 1, _NE, L_KANE, R_SHUUJO,
|
||||
(1 << 5) + 0, L_KANERU, R_KANE2,
|
||||
(1 << 5) + 1, _RU, L_KANERU, R_SHUUSI,
|
||||
(1 << 5) + 1, _RE, L_KANERU, R_KATEI3,
|
||||
(0 << 5) + 3, _MA, _TA, _HA, L_KA1, R_CUT,
|
||||
(0 << 5) + 1, _MO, L_KAMO, R_KAMO,
|
||||
(0 << 5) + 1, _RA, L_KARA1, R_KARA1,
|
||||
(1 << 5) + 0, L_KARA2, R_KARA2,
|
||||
(1 << 5) + 1, _ZU, L_KARAZU, R_ZU,
|
||||
(1 << 5) + 1, _NU, L_KARAZU, R_NU,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ga[] = {
|
||||
(0 << 5) + 0, L_GA1, R_GA1,
|
||||
(0 << 5) + 0, L_GA2, R_GA2,
|
||||
(0 << 5) + 2, _TA, _I, L_GATAI, R_KSHUUSI,
|
||||
(1 << 5) + 2, _KA, _XTU, L_GATAI, R_ONBIN1,
|
||||
(2 << 5) + 2, _RO, _U, L_GATAI, R_KAROU,
|
||||
(1 << 5) + 1, _KU, L_GATAI, R_GATAKU,
|
||||
(1 << 5) + 2, _KE, _RE, L_GATAI, R_KATEI2,
|
||||
(0 << 5) + 1, _TI, L_GATIDA, R_GATI,
|
||||
(1 << 5) + 1, _DA, L_GATIDA, R_DSHUUSI1,
|
||||
(2 << 5) + 1, _XTU, L_GATIDA, R_ONBIN1,
|
||||
(2 << 5) + 2, _RO, _U, L_GATIDA, R_DAROU,
|
||||
(1 << 5) + 1, _DE, L_GATIDA, R_DRENYOU1,
|
||||
(1 << 5) + 1, _NA, L_GATIDA, R_DRENTAI1,
|
||||
(2 << 5) + 1, _RA, L_GATIDA, R_KATEI1,
|
||||
(1 << 5) + 1, _NI, L_GATIDA, R_DRENYOU2,
|
||||
(0 << 5) + 2, _TE, _RA, L_GATERA, R_GATERA,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ki[] = {
|
||||
(0 << 5) + 0, L_YOUGEN, R_FZKKI,
|
||||
(0 << 5) + 1, _RI, L_KIRI, R_KIRI,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ku[] = {
|
||||
(0 << 5) + 2, _SE, _NI, L_KUSENI, R_KUSENI,
|
||||
(0 << 5) + 3, _DA, _SA, _I, L_KUDASARU, R_KUDASAI,
|
||||
(2 << 5) + 1, _XTU, L_KUDASARU, R_ONBIN6,
|
||||
(2 << 5) + 1, _RA, L_KUDASARU, R_MIZEN4,
|
||||
(2 << 5) + 1, _RI, L_KUDASARU, R_ITADAKI,
|
||||
(2 << 5) + 1, _RU, L_KUDASARU, R_SHUUSI,
|
||||
(2 << 5) + 1, _RE, L_KUDASARU, R_KATEI3,
|
||||
(0 << 5) + 2, _RA, _I, L_KURAI, R_KURAI,
|
||||
(0 << 5) + 1, _RU, L_YOUGEN, R_SHUUSI,
|
||||
(0 << 5) + 1, _RE, L_YOUGEN, R_KURE,
|
||||
(1 << 5) + 1, _RU, L_YOUGEN, R_SHUUSI,
|
||||
(1 << 5) + 1, _RE, L_YOUGEN, R_KATEI3,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_gu[] = {
|
||||
(0 << 5) + 2, _RA, _I, L_KURAI, R_KURAI,
|
||||
(0 << 5) + 2, _RU, _MI, L_GURUMI, R_GURUMI,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ke[] = {
|
||||
(0 << 5) + 1, _DO, L_KEDO, R_KEDO,
|
||||
(1 << 5) + 1, _MO, L_KEDO, R_KEDO,
|
||||
(0 << 5) + 2, _RE, _DO, L_KEDO, R_KEDO,
|
||||
(2 << 5) + 1, _MO, L_KEDO, R_KEDO,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ko[] = {
|
||||
(0 << 5) + 0, L_YOUGEN, R_KO,
|
||||
(0 << 5) + 1, _I, L_YOUGEN, R_MEIREI1,
|
||||
(0 << 5) + 1, _SO, L_KOSO, R_KOSO,
|
||||
(0 << 5) + 1, _TO, L_KOTO, R_KOTO,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_go[] = {
|
||||
(0 << 5) + 2, _ZA, _I, L_GOZAI, R_GOZAI,
|
||||
(0 << 5) + 2, _TO, _KI, L_GOTOSI, R_GOTOKI,
|
||||
(1 << 5) + 1, _KU, L_GOTOSI, R_GOTOKU,
|
||||
(1 << 5) + 1, _SI, L_GOTOSI, R_GOTOSI,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_sa[] = {
|
||||
(0 << 5) + 0, L_SA1, R_MIZEN1,
|
||||
(0 << 5) + 0, L_SA2, R_SHUUJO,
|
||||
(0 << 5) + 1, _E, L_SAE, R_SAE,
|
||||
(0 << 5) + 1, _SE, L_SASERU, R_SASE,
|
||||
(1 << 5) + 1, _YO, L_SASERU, R_MEIREI2,
|
||||
(1 << 5) + 1, _RU, L_SASERU, R_SHUUSI,
|
||||
(1 << 5) + 1, _RE, L_SASERU, R_KATEI2,
|
||||
(1 << 5) + 1, _RO, L_SASERU, R_MEIREI1,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_za[] = {
|
||||
(0 << 5) + 1, _RU, L_ZARU, R_ZARU,
|
||||
(0 << 5) + 1, _RE, L_ZARU, R_KATEI2,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_si[] = {
|
||||
(0 << 5) + 0, L_SI1, R_SI1,
|
||||
(0 << 5) + 0, L_SI2, R_SI2,
|
||||
(0 << 5) + 0, L_N_SI, R_N_SI,
|
||||
(0 << 5) + 1, _KA, L_SIKA, R_SIKA,
|
||||
(0 << 5) + 1, _TE, L_SITE, R_SITE,
|
||||
(0 << 5) + 2, _MA, _I, L_YOUGEN, R_IKI,
|
||||
(1 << 5) + 1, _U, L_YOUGEN, R_SHUUSI,
|
||||
(1 << 5) + 1, _E, L_YOUGEN, R_IKE,
|
||||
(1 << 5) + 2, _O, _U, L_YOUGEN, R_AROU,
|
||||
(1 << 5) + 1, _XTU, L_YOUGEN, R_ONBIN6,
|
||||
(1 << 5) + 1, _WA, L_YOUGEN, R_MIZEN5,
|
||||
(0 << 5) + 1, _RO, L_SIRO, R_MEIREI1,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ji[] = {
|
||||
(0 << 5) + 2, _MA, _I, L_JIMAU, R_IKI,
|
||||
(1 << 5) + 1, _U, L_JIMAU, R_SHUUSI,
|
||||
(1 << 5) + 1, _E, L_JIMAU, R_IKE,
|
||||
(1 << 5) + 2, _O, _U, L_JIMAU, R_AROU,
|
||||
(1 << 5) + 1, _XTU, L_JIMAU, R_ONBIN6,
|
||||
(1 << 5) + 1, _WA, L_JIMAU, R_MIZEN5,
|
||||
(0 << 5) + 1, _XYA, L_JYA, R_JYA,
|
||||
(1 << 5) + 1, _I, L_JYAU, R_IKI,
|
||||
(1 << 5) + 1, _U, L_JYAU, R_SHUUSI,
|
||||
(1 << 5) + 1, _E, L_JYAU, R_IKE,
|
||||
(1 << 5) + 2, _O, _U, L_JYAU, R_AROU,
|
||||
(1 << 5) + 1, _XTU, L_JYAU, R_ONBIN6,
|
||||
(1 << 5) + 1, _WA, L_JYAU, R_MIZEN5,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_su[] = {
|
||||
(0 << 5) + 1, _GI, L_SUGIRU, R_SUGI,
|
||||
(1 << 5) + 1, _RU, L_SUGIRU, R_SHUUSI,
|
||||
(1 << 5) + 1, _RE, L_SUGIRU, R_KATEI2,
|
||||
(0 << 5) + 3, _BE, _KA, _RA, L_SUBESI, R_BEKARA,
|
||||
(1 << 5) + 1, _KI, L_SUBESI, R_BEKI,
|
||||
(1 << 5) + 1, _KU, L_SUBESI, R_BEKU,
|
||||
(1 << 5) + 1, _SI, L_SUBESI, R_BESI,
|
||||
(0 << 5) + 1, _RA, L_SURA, R_SURA,
|
||||
(0 << 5) + 1, _RU, L_SURU, R_SHUUSI,
|
||||
(0 << 5) + 1, _RE, L_SURE, R_KATEI2,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_zu[] = {
|
||||
(0 << 5) + 0, L_ZU, R_ZU,
|
||||
(0 << 5) + 1, _TU, L_ZUTU, R_ZUTU,
|
||||
(0 << 5) + 2, _NI, _I, L_ZU, R_I,
|
||||
(2 << 5) + 1, _RU, L_ZU, R_SHUUSI,
|
||||
(0 << 5) + 2, _NN, _BA, L_ZUNBA, R_CUT,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_se[] = {
|
||||
(0 << 5) + 0, L_SE, R_MIZEN2,
|
||||
(0 << 5) + 0, L_SERU, R_SASE,
|
||||
(0 << 5) + 1, _YO, L_SEYO, R_MEIREI2,
|
||||
(1 << 5) + 0, L_SERU, R_MEIREI2,
|
||||
(0 << 5) + 1, _RU, L_SERU, R_SHUUSI,
|
||||
(0 << 5) + 1, _RE, L_SERU, R_KATEI2,
|
||||
(0 << 5) + 1, _RO, L_SERU, R_MEIREI1,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ze[] = {
|
||||
(0 << 5) + 0, L_ZE, R_SHUUJO,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_so[] = {
|
||||
(0 << 5) + 1, _U, L_SOUDA, R_SOU,
|
||||
(1 << 5) + 1, _DA, L_SOUDA, R_SOUDA,
|
||||
(2 << 5) + 1, _XTU, L_YOUTAI, R_ONBIN1,
|
||||
(2 << 5) + 2, _RO, _U, L_YOUTAI, R_DAROU,
|
||||
(1 << 5) + 1, _DE, L_SOUDA, R_SOUDE,
|
||||
(2 << 5) + 1, _SI, L_SOUDA, R_DESHI,
|
||||
(3 << 5) + 1, _XYO, L_YOUTAI, R_SHO,
|
||||
(4 << 5) + 1, _U, L_YOUTAI, R_DESHOU,
|
||||
(2 << 5) + 1, _SU, L_SOUDA, R_SOUDESU,
|
||||
(1 << 5) + 1, _NA, L_DENBUN, R_SOUNA1,
|
||||
(2 << 5) + 0, L_YOUTAI, R_SOUNA2,
|
||||
(2 << 5) + 1, _RA, L_SOUDA, R_KATEI1,
|
||||
(1 << 5) + 1, _NI, L_YOUTAI, R_SOUNI,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_zo[] = {
|
||||
(0 << 5) + 0, L_ZO, R_SHUUJO,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ta[] = {
|
||||
(0 << 5) + 0, L_TA, R_TA,
|
||||
(0 << 5) + 1, _I, L_TAI, R_TAI,
|
||||
(0 << 5) + 2, _KA, _XTU, L_TAI, R_ONBIN1,
|
||||
(1 << 5) + 2, _RO, _U, L_TAI, R_KAROU,
|
||||
(0 << 5) + 2, _GA, _XTU, L_TAGARU, R_ONBIN6,
|
||||
(1 << 5) + 1, _RA, L_TAGARU, R_TAGARA,
|
||||
(1 << 5) + 1, _RI, L_TAGARU, R_TAGARI,
|
||||
(1 << 5) + 1, _RU, L_TAGARU, R_SHUUSI,
|
||||
(1 << 5) + 1, _RE, L_TAGARU, R_KATEI3,
|
||||
(1 << 5) + 2, _RO, _U, L_TAGARU, R_KAROU,
|
||||
(0 << 5) + 1, _KU, L_TAI, R_TAKU,
|
||||
(0 << 5) + 2, _KE, _RE, L_TAI, R_KATEI3,
|
||||
(0 << 5) + 2, _MA, _I, L_TAMAU, R_IKI,
|
||||
(1 << 5) + 1, _U, L_TAMAU, R_SHUUSI,
|
||||
(1 << 5) + 1, _E, L_TAMAU, R_KAMEI,
|
||||
(1 << 5) + 1, _XTU, L_TAMAU, R_ONBIN6,
|
||||
(1 << 5) + 1, _WA, L_TAMAU, R_MIZEN5,
|
||||
(0 << 5) + 1, _ME, L_TAME, R_TAME,
|
||||
(0 << 5) + 1, _RA, L_TA, R_KATEI1,
|
||||
(0 << 5) + 1, _RI, L_TA, R_TARI,
|
||||
(0 << 5) + 1, _RU, L_TARU, R_CUT,
|
||||
(0 << 5) + 2, _RO, _U, L_TA, R_KAROU,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_da[] = {
|
||||
(0 << 5) + 0, L_DA1, R_TA,
|
||||
(0 << 5) + 0, L_DA2, R_DSHUUSI1,
|
||||
(0 << 5) + 1, _KE, L_DAKE, R_DAKE,
|
||||
(0 << 5) + 1, _XTU, L_DAXTU, R_ONBIN1,
|
||||
(0 << 5) + 1, _NO, L_DANO, R_DANO,
|
||||
(0 << 5) + 1, _RA, L_DA1, R_KATEI1,
|
||||
(1 << 5) + 1, _KE, L_DARAKE, R_DARAKE,
|
||||
(0 << 5) + 1, _RI, L_DA1, R_TARI,
|
||||
(0 << 5) + 2, _RO, _U, L_DAROU, R_DAROU,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ti[] = {
|
||||
(0 << 5) + 2, _MA, _I, L_TIMAU, R_IKI,
|
||||
(1 << 5) + 1, _U, L_TIMAU, R_SHUUSI,
|
||||
(1 << 5) + 1, _E, L_TIMAU, R_IKE,
|
||||
(1 << 5) + 2, _O, _U, L_TIMAU, R_AROU,
|
||||
(1 << 5) + 1, _XTU, L_TIMAU, R_ONBIN6,
|
||||
(1 << 5) + 1, _WA, L_TIMAU, R_MIZEN5,
|
||||
(0 << 5) + 1, _XYA, L_TYA, R_CUT,
|
||||
(1 << 5) + 1, _I, L_TYAU, R_IKI,
|
||||
(1 << 5) + 1, _U, L_TYAU, R_SHUUSI,
|
||||
(1 << 5) + 1, _E, L_TYAU, R_IKE,
|
||||
(1 << 5) + 2, _O, _U, L_TYAU, R_AROU,
|
||||
(1 << 5) + 1, _XTU, L_TYAU, R_ONBIN6,
|
||||
(1 << 5) + 1, _WA, L_TYAU, R_MIZEN5,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_di[] = {
|
||||
(0 << 5) + 1, _XYA, L_JYA, R_JYA,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_tu[] = {
|
||||
(0 << 5) + 2, _I, _TE, L_TUITE, R_TUITE,
|
||||
(0 << 5) + 1, _KI, L_TUKI, R_TUKI,
|
||||
(0 << 5) + 1, _TU, L_TUTU, R_TUTU,
|
||||
(0 << 5) + 2, _MO, _RI, L_TUMORI, R_TUMORI,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_te[] = {
|
||||
(0 << 5) + 0, L_TE1, R_TE1,
|
||||
(0 << 5) + 0, L_TE2, R_TE2,
|
||||
(0 << 5) + 1, _RU, L_TERU, R_TERU,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_de[] = {
|
||||
(0 << 5) + 0, L_DE, R_DE,
|
||||
(0 << 5) + 0, L_DA1, R_TE2,
|
||||
(0 << 5) + 3, _A, _RO, _U, L_DEAROU, R_AROU,
|
||||
(0 << 5) + 1, _KI, L_DEKIRU, R_DEKI,
|
||||
(1 << 5) + 1, _RU, L_DEKIRU, R_SHUUSI,
|
||||
(1 << 5) + 1, _RE, L_DEKIRU, R_KATEI3,
|
||||
(0 << 5) + 1, _SI, L_DESI, R_DESHI,
|
||||
(1 << 5) + 1, _XYO, L_DESHO, R_SHO,
|
||||
(2 << 5) + 1, _U, L_DESHO, R_DESHOU,
|
||||
(0 << 5) + 1, _SU, L_DESU, R_DESU,
|
||||
(0 << 5) + 1, _HA, L_DEHA, R_DEHA,
|
||||
(0 << 5) + 1, _RU, L_DERU, R_TERU,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_to[] = {
|
||||
(0 << 5) + 0, L_TO1, R_TO1,
|
||||
(0 << 5) + 0, L_TO2, R_TO2,
|
||||
(0 << 5) + 1, _I, L_TE2, R_ONBIN8,
|
||||
(1 << 5) + 1, _U, L_TOIU, R_TOIU,
|
||||
(0 << 5) + 2, _O, _RI, L_TOORI, R_TOORI,
|
||||
(0 << 5) + 1, _KA, L_TE2, R_MIZEN5,
|
||||
(0 << 5) + 1, _KI, L_TOKI, R_TOKI,
|
||||
(1 << 5) + 0, L_TE2, R_IKI,
|
||||
(0 << 5) + 1, _KU, L_TE2, R_SHUUSI,
|
||||
(0 << 5) + 1, _KE, L_TE2, R_IKE,
|
||||
(0 << 5) + 1, _KO, L_TOKORO, R_TOKORO,
|
||||
(1 << 5) + 1, _U, L_TE2, R_AROU,
|
||||
(1 << 5) + 1, _RO, L_TOKORO, R_TOKORO,
|
||||
(0 << 5) + 2, _XTU, _TE, L_TOTTE, R_TOTTE,
|
||||
(0 << 5) + 1, _TE, L_TOTE, R_TOTE,
|
||||
(0 << 5) + 3, _HA, _I, _E, L_TOHAIE, R_TOHAIE,
|
||||
(0 << 5) + 1, _MO, L_TOMO, R_TOMO,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_do[] = {
|
||||
(0 << 5) + 0, L_DO, R_DO,
|
||||
(0 << 5) + 1, _I, L_DA1, R_ONBIN8,
|
||||
(0 << 5) + 2, _O, _RI, L_DOORI, R_DOORI,
|
||||
(0 << 5) + 1, _KA, L_DA1, R_MIZEN5,
|
||||
(0 << 5) + 1, _KI, L_DA1, R_IKI,
|
||||
(0 << 5) + 1, _KU, L_DA1, R_SHUUSI,
|
||||
(0 << 5) + 1, _KE, L_DA1, R_IKE,
|
||||
(0 << 5) + 2, _KO, _U, L_DA1, R_AROU,
|
||||
(1 << 5) + 1, _RO, L_DOKORO, R_DOKORO,
|
||||
(2 << 5) + 1, _KA, L_DOKOROKA, R_DOKOROKA,
|
||||
(0 << 5) + 1, _MO, L_DOMO, R_DOMO,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_na[] = {
|
||||
(0 << 5) + 0, L_NA1, R_SHUUJO,
|
||||
(0 << 5) + 0, L_NA2, R_NA2,
|
||||
(0 << 5) + 1, _XA, L_NAA, R_SHUUJO,
|
||||
(0 << 5) + 1, _A, L_NAA, R_SHUUJO,
|
||||
(0 << 5) + 1, _I, L_NAI, R_NAI,
|
||||
(1 << 5) + 1, _DE, L_NAI, R_NAIDE,
|
||||
(0 << 5) + 2, _KA, _XTU, L_NAI, R_ONBIN1,
|
||||
(1 << 5) + 2, _RO, _U, L_NAI, R_KAROU,
|
||||
(0 << 5) + 2, _GA, _RA, L_NAGARA, R_NAGARA,
|
||||
(2 << 5) + 0, L_NAGARA2, R_NAGARA2,
|
||||
(0 << 5) + 2, _KI, _XYA, L_NAI, R_CUT,
|
||||
(0 << 5) + 1, _KU, L_NAI, R_NAKU,
|
||||
(0 << 5) + 2, _KE, _RE, L_NAI, R_KATEI3,
|
||||
(0 << 5) + 2, _SA, _I, L_NASAI, R_NASAI,
|
||||
(1 << 5) + 1, _RA, L_NASARU, R_MIZEN4,
|
||||
(1 << 5) + 1, _RI, L_NASARU, R_ITADAKI,
|
||||
(1 << 5) + 1, _RU, L_NASARU, R_SHUUSI,
|
||||
(1 << 5) + 1, _RE, L_NASARU, R_KATEI3,
|
||||
(2 << 5) + 1, _RU, L_NASARU, R_SHUUSI,
|
||||
(0 << 5) + 1, _ZO, L_NAZO, R_NAZO,
|
||||
(0 << 5) + 1, _XTU, L_NARU, R_ONBIN2,
|
||||
(0 << 5) + 1, _DO, L_NADO, R_NADO,
|
||||
(0 << 5) + 1, _YO, L_NA1, R_SHUUJO,
|
||||
(0 << 5) + 1, _RA, L_NARA, R_KATEI1,
|
||||
(1 << 5) + 0, L_NARU, R_MIZEN5,
|
||||
(0 << 5) + 1, _RI, L_NARI, R_NARI,
|
||||
(1 << 5) + 0, L_NARU, R_IKI,
|
||||
(0 << 5) + 1, _RU, L_NARU, R_SHUUSI,
|
||||
(0 << 5) + 1, _RE, L_NARU, R_IKE,
|
||||
(0 << 5) + 2, _RO, _U, L_NARU, R_AROU,
|
||||
(0 << 5) + 2, _NN, _KA, L_NANKA, R_NANKA,
|
||||
(1 << 5) + 1, _ZO, L_NANZO, R_NANZO,
|
||||
(1 << 5) + 1, _TE, L_NANTE, R_NANTE,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ni[] = {
|
||||
(0 << 5) + 0, L_NI1, R_NI1,
|
||||
(0 << 5) + 0, L_NI2, R_NI2,
|
||||
(0 << 5) + 0, L_NI3, R_NI3,
|
||||
(0 << 5) + 2, _KU, _I, L_NIKUI, R_KSHUUSI,
|
||||
(1 << 5) + 2, _KA, _XTU, L_NIKUI, R_ONBIN1,
|
||||
(2 << 5) + 2, _RO, _U, L_NIKUI, R_KAROU,
|
||||
(1 << 5) + 1, _KU, L_NIKUI, R_TAKU,
|
||||
(1 << 5) + 2, _KE, _RE, L_NIKUI, R_KATEI3,
|
||||
(1 << 5) + 1, _SA, L_NIKUI, R_FZKMEISI,
|
||||
(0 << 5) + 1, _TE, L_NITE, R_NITE,
|
||||
(0 << 5) + 2, _DE, _MO, L_NI1, R_MO1,
|
||||
(0 << 5) + 1, _MO, L_NIMO, R_NIMO,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_nu[] = {
|
||||
(0 << 5) + 0, L_NU, R_NU,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ne[] = {
|
||||
(0 << 5) + 0, L_NE1, R_SHUUJO,
|
||||
(0 << 5) + 0, L_NE2, R_KATEI2,
|
||||
(0 << 5) + 1, _E, L_NEE, R_SHUUJO,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_no[] = {
|
||||
(0 << 5) + 0, L_NO1, R_NO1,
|
||||
(0 << 5) + 0, L_NO2, R_NO2,
|
||||
(0 << 5) + 1, _DE, L_NODE, R_NODE,
|
||||
(0 << 5) + 1, _NI, L_NONI, R_NONI,
|
||||
(0 << 5) + 1, _MI, L_NOMI, R_NOMI,
|
||||
(1 << 5) + 3, _NA, _RA, _ZU, L_NOMINRZ, R_NOMINRZ,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ha[] = {
|
||||
(0 << 5) + 0, L_HA, R_HA,
|
||||
(0 << 5) + 1, _SI, L_HA, R_HASI,
|
||||
(0 << 5) + 1, _ZU, L_HAZU, R_HAZU,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ba[] = {
|
||||
(0 << 5) + 0, L_BA, R_BA,
|
||||
(0 << 5) + 2, _KA, _SI, L_BAKARI, R_BAKARI,
|
||||
(1 << 5) + 1, _RI, L_BAKARI, R_BAKARI,
|
||||
(0 << 5) + 3, _XTU, _KA, _SI, L_BAKARI, R_BAKARI,
|
||||
(2 << 5) + 1, _RI, L_BAKARI, R_BAKARI,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_hu[] = {
|
||||
(0 << 5) + 2, _U, _DA, L_FUUDA, R_SOUDA,
|
||||
(2 << 5) + 1, _XTU, L_FUUDA, R_ONBIN1,
|
||||
(2 << 5) + 2, _RO, _U, L_FUUDA, R_DAROU,
|
||||
(1 << 5) + 1, _DE, L_FUUDA, R_SOUDE,
|
||||
(2 << 5) + 1, _SI, L_FUUDA, R_DESHI,
|
||||
(3 << 5) + 1, _XYO, L_FUUDA, R_SHO,
|
||||
(4 << 5) + 1, _U, L_FUUDA, R_DESHOU,
|
||||
(2 << 5) + 1, _SU, L_FUUDA, R_SOUDESU,
|
||||
(1 << 5) + 1, _NA, L_FUUDA, R_SOUNA2,
|
||||
(2 << 5) + 1, _RA, L_FUUDA, R_KATEI1,
|
||||
(1 << 5) + 1, _NI, L_FUUDA, R_FUUNI,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_he[] = {
|
||||
(0 << 5) + 0, L_HE, R_HE,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_be[] = {
|
||||
(0 << 5) + 2, _KA, _RA, L_BESI, R_BEKARA,
|
||||
(0 << 5) + 1, _KI, L_BESI, R_BEKI,
|
||||
(0 << 5) + 1, _KU, L_BESI, R_BEKU,
|
||||
(0 << 5) + 1, _SI, L_BESI, R_BESI,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ho[] = {
|
||||
(0 << 5) + 1, _U, L_HOU, R_HOU,
|
||||
(0 << 5) + 1, _KA, L_HOKA, R_HOKA,
|
||||
(0 << 5) + 1, _DO, L_HODO, R_HODO,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ma[] = {
|
||||
(0 << 5) + 1, _I, L_MAI, R_MAI,
|
||||
(0 << 5) + 1, _SI, L_MASU, R_DESHI,
|
||||
(1 << 5) + 0, L_MASU, R_MEIREI2,
|
||||
(1 << 5) + 1, _XYO, L_MASU, R_SHO,
|
||||
(2 << 5) + 1, _U, L_MASU, R_DESHOU,
|
||||
(0 << 5) + 1, _SU, L_MASU, R_MASU,
|
||||
(1 << 5) + 1, _RE, L_MASURE, R_KATEI2,
|
||||
(0 << 5) + 1, _SE, L_MASE, R_MEIREI1,
|
||||
(1 << 5) + 1, _NU, L_MASU, R_NU,
|
||||
(1 << 5) + 1, _NN, L_MASU, R_NN2,
|
||||
(0 << 5) + 1, _DE, L_MADE, R_MADE,
|
||||
(0 << 5) + 1, _MA, L_MAMA, R_MAMA,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_mi[] = {
|
||||
(0 << 5) + 0, L_YOUGEN, R_MI,
|
||||
(0 << 5) + 2, _TA, _I, L_MITAIDA, R_MITAI,
|
||||
(2 << 5) + 1, _DA, L_MITAIDA, R_MITAIDA,
|
||||
(3 << 5) + 1, _XTU, L_MITAIDA, R_ONBIN1,
|
||||
(3 << 5) + 2, _RO, _U, L_MITAIDA, R_DAROU,
|
||||
(2 << 5) + 1, _DE, L_MITAIDA, R_SOUDE,
|
||||
(3 << 5) + 1, _SI, L_MITAIDA, R_DESHI,
|
||||
(4 << 5) + 1, _XYO, L_MITAIDA, R_SHO,
|
||||
(5 << 5) + 1, _U, L_MITAIDA, R_DESHOU,
|
||||
(3 << 5) + 1, _SU, L_MITAIDA, R_SOUDESU,
|
||||
(2 << 5) + 1, _NA, L_MITAIDA, R_SOUNA2,
|
||||
(3 << 5) + 1, _RA, L_MITAIDA, R_KATEI1,
|
||||
(2 << 5) + 1, _NI, L_MITAIDA, R_FUUNI,
|
||||
(0 << 5) + 1, _YO, L_YOUGEN, R_MEIREI2,
|
||||
(0 << 5) + 1, _RU, L_YOUGEN, R_SHUUSI,
|
||||
(0 << 5) + 1, _RE, L_YOUGEN, R_KATEI2,
|
||||
(0 << 5) + 1, _RO, L_YOUGEN, R_MEIREI1,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_mo[] = {
|
||||
(0 << 5) + 0, L_MO1, R_MO1,
|
||||
(0 << 5) + 0, L_MO2, R_MO2,
|
||||
(0 << 5) + 2, _XTU, _TE, L_MOTTE, R_MOTTE,
|
||||
(0 << 5) + 1, _NO, L_MONO, R_MONO,
|
||||
(0 << 5) + 2, _RA, _I, L_YOUGEN, R_IKI,
|
||||
(1 << 5) + 1, _U, L_YOUGEN, R_SHUUSI,
|
||||
(1 << 5) + 1, _E, L_YOUGEN, R_IKE,
|
||||
(1 << 5) + 2, _O, _U, L_YOUGEN, R_AROU,
|
||||
(1 << 5) + 1, _XTU, L_YOUGEN, R_ONBIN2,
|
||||
(1 << 5) + 1, _WA, L_YOUGEN, R_MIZEN5,
|
||||
(0 << 5) + 1, _NN, L_WAYO, R_SHUUJO,
|
||||
(1 << 5) + 1, _KA, L_WAYO, R_SHUUJO,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ya[] = {
|
||||
(0 << 5) + 0, L_YA1, R_YA1,
|
||||
(0 << 5) + 0, L_YA2, R_YA2,
|
||||
(0 << 5) + 2, _SU, _I, L_YASUI, R_KSHUUSI,
|
||||
(1 << 5) + 2, _KA, _XTU, L_YASUI, R_ONBIN1,
|
||||
(2 << 5) + 2, _RO, _U, L_YASUI, R_KAROU,
|
||||
(1 << 5) + 1, _KU, L_YASUI, R_TAKU,
|
||||
(1 << 5) + 2, _KE, _RE, L_YASUI, R_KATEI3,
|
||||
(1 << 5) + 1, _SA, L_YASUI, R_FZKMEISI,
|
||||
(0 << 5) + 1, _XTU, L_YOUGEN, R_ONBIN2,
|
||||
(0 << 5) + 1, _RA, L_YARA, R_YARA,
|
||||
(1 << 5) + 0, L_YOUGEN, R_MIZEN5,
|
||||
(0 << 5) + 1, _RI, L_YOUGEN, R_IKI,
|
||||
(0 << 5) + 1, _RU, L_YOUGEN, R_SHUUSI,
|
||||
(0 << 5) + 1, _RE, L_YOUGEN, R_KATEI2,
|
||||
(0 << 5) + 2, _RO, _U, L_YOUGEN, R_AROU,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_yu[] = {
|
||||
(0 << 5) + 1, _E, L_YUE, R_YUE,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_yo[] = {
|
||||
(0 << 5) + 0, L_YO, R_SHUUJO,
|
||||
(0 << 5) + 1, _I, L_YOI, R_KSHUUSI,
|
||||
(0 << 5) + 1, _U, L_YOU, R_YOU1,
|
||||
(1 << 5) + 0, L_YOUDA, R_YOU2,
|
||||
(1 << 5) + 1, _DA, L_YOUDA, R_SOUDA,
|
||||
(2 << 5) + 1, _XTU, L_YOUDA, R_ONBIN1,
|
||||
(2 << 5) + 2, _RO, _U, L_YOUDA, R_DAROU,
|
||||
(1 << 5) + 1, _DE, L_YOUDA, R_SOUDE,
|
||||
(2 << 5) + 1, _SI, L_YOUDA, R_DESHI,
|
||||
(3 << 5) + 1, _XYO, L_YOUDA, R_SHO,
|
||||
(4 << 5) + 1, _U, L_YOUDA, R_DESHOU,
|
||||
(2 << 5) + 1, _SU, L_YOUDA, R_SOUDESU,
|
||||
(1 << 5) + 1, _NA, L_YOUDA, R_SOUNA2,
|
||||
(2 << 5) + 1, _RA, L_YOUDA, R_KATEI1,
|
||||
(1 << 5) + 1, _NI, L_YOUDA, R_FUUNI,
|
||||
(0 << 5) + 2, _KA, _XTU, L_YOI, R_ONBIN1,
|
||||
(1 << 5) + 2, _RO, _U, L_YOI, R_KAROU,
|
||||
(0 << 5) + 1, _KU, L_YOI, R_TAKU,
|
||||
(0 << 5) + 2, _KE, _RE, L_YOI, R_KATEI3,
|
||||
(0 << 5) + 1, _SA, L_YOI, R_FZKMEISI,
|
||||
(0 << 5) + 2, _XTU, _TE, L_YORU, R_YOTTE,
|
||||
(0 << 5) + 2, _NA, _XA, L_YO, R_SHUUJO,
|
||||
(1 << 5) + 1, _A, L_YO, R_SHUUJO,
|
||||
(0 << 5) + 1, _NE, L_YO, R_SHUUJO,
|
||||
(0 << 5) + 1, _RA, L_YORU, R_MIZEN4,
|
||||
(0 << 5) + 1, _RI, L_YORI, R_YORI1,
|
||||
(1 << 5) + 0, L_YORU, R_YORI2,
|
||||
(0 << 5) + 1, _RU, L_YORU, R_SHUUSI,
|
||||
(0 << 5) + 1, _RE, L_YORU, R_KATEI3,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_ra[] = {
|
||||
(0 << 5) + 2, _SI, _I, L_RASII, R_RASII,
|
||||
(1 << 5) + 2, _KA, _XTU, L_RASII, R_ONBIN1,
|
||||
(1 << 5) + 1, _KI, L_RASII, R_GOTOKI,
|
||||
(1 << 5) + 1, _KU, L_RASII, R_TAKU,
|
||||
(1 << 5) + 2, _XYU, _U, L_RASII, R_RASHUU,
|
||||
(0 << 5) + 1, _RE, L_RARERU, R_RARE,
|
||||
(1 << 5) + 1, _YO, L_RARERU, R_MEIREI2,
|
||||
(1 << 5) + 1, _RU, L_RARERU, R_SHUUSI,
|
||||
(1 << 5) + 1, _RE, L_RARERU, R_KATEI2,
|
||||
(1 << 5) + 1, _RO, L_RARERU, R_MEIREI1,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_re[] = {
|
||||
(0 << 5) + 0, L_RERU, R_RARE,
|
||||
(0 << 5) + 1, _YO, L_RERU, R_MEIREI2,
|
||||
(0 << 5) + 1, _RU, L_RERU, R_SHUUSI,
|
||||
(0 << 5) + 1, _RE, L_RERU, R_KATEI2,
|
||||
(0 << 5) + 1, _RO, L_RERU, R_MEIREI1,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_wa[] = {
|
||||
(0 << 5) + 0, L_WA, R_SHUUJO,
|
||||
(0 << 5) + 1, _KE, L_WAKE, R_WAKE,
|
||||
(0 << 5) + 1, _NE, L_WANE, R_SHUUJO,
|
||||
(0 << 5) + 1, _YO, L_WAYO, R_SHUUJO,
|
||||
0xff};
|
||||
|
||||
static u_char fzk_nn[] = {
|
||||
(0 << 5) + 0, L_NN1, R_NN1,
|
||||
(0 << 5) + 0, L_NN2, R_NN2,
|
||||
0xff};
|
||||
|
||||
u_char* fzkadr[] = {
|
||||
0, fzk_a, 0, fzk_i, 0,
|
||||
fzk_u, 0, fzk_e, 0, fzk_o,
|
||||
fzk_ka, fzk_ga, fzk_ki, 0, fzk_ku,
|
||||
fzk_gu, fzk_ke, 0, fzk_ko, fzk_go,
|
||||
fzk_sa, fzk_za, fzk_si, fzk_ji, fzk_su,
|
||||
fzk_zu, fzk_se, fzk_ze, fzk_so, fzk_zo,
|
||||
fzk_ta, fzk_da, fzk_ti, fzk_di, fzk_xtu,
|
||||
fzk_tu, 0, fzk_te, fzk_de, fzk_to,
|
||||
fzk_do, fzk_na, fzk_ni, fzk_nu, fzk_ne,
|
||||
fzk_no, fzk_ha, fzk_ba, 0, 0,
|
||||
0, 0, fzk_hu, 0, 0,
|
||||
fzk_he, fzk_be, 0, fzk_ho, 0,
|
||||
0, fzk_ma, fzk_mi, 0, 0,
|
||||
fzk_mo, 0, fzk_ya, 0, fzk_yu,
|
||||
0, fzk_yo, fzk_ra, 0, 0,
|
||||
fzk_re, 0, 0, fzk_wa, 0,
|
||||
0, fzk_wo, fzk_nn};
|
||||
211
lib/sj4core/getkanji.c
Normal file
211
lib/sj4core/getkanji.c
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: getkanji.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:49 $
|
||||
*/
|
||||
|
||||
#include "sj_euc.h"
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static u_char* code2kanji(SJ4_CONTEXT u_char* s, u_char* d, u_char* ym, int yl, int flg);
|
||||
|
||||
u_char*
|
||||
getkan_none(u_char* s, u_char* d, u_char* ym, int yl, int flg) {
|
||||
return d;
|
||||
}
|
||||
|
||||
u_char*
|
||||
getkan_hira(u_char* s, u_char* d, u_char* ym, int yl, int flg) {
|
||||
int cnt, csize;
|
||||
|
||||
csize = codesize(*s);
|
||||
|
||||
cnt = (*s & KANJICODEMASK) + 1;
|
||||
|
||||
if(flg && (s[csize] == KANJISTREND)) ym += (yl - cnt) * 2;
|
||||
|
||||
cnt *= 2;
|
||||
while(cnt-- > 0) *d++ = *ym++;
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
u_char*
|
||||
getkan_kata(u_char* s, u_char* d, u_char* ym, int yl, int flg) {
|
||||
int cnt, csize;
|
||||
u_char ch;
|
||||
|
||||
csize = codesize(*s);
|
||||
|
||||
cnt = (*s & KANJICODEMASK) + 1;
|
||||
|
||||
if(flg && (s[csize] == KANJISTREND)) ym += (yl - cnt) * 2;
|
||||
|
||||
while(cnt-- > 0) {
|
||||
if(*ym == 0xa4) {
|
||||
ch = *++ym;
|
||||
if(0xa1 <= ch && ch <= 0xf3) {
|
||||
*d++ = 0xa5;
|
||||
} else {
|
||||
*d++ = 0xa4;
|
||||
}
|
||||
*d++ = ch;
|
||||
ym++;
|
||||
} else {
|
||||
*d++ = *ym++;
|
||||
*d++ = *ym++;
|
||||
}
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
u_char*
|
||||
getkan_knj(SJ4_CONTEXT u_char* s, u_char* d, u_char* ym, int yl, int flg) {
|
||||
return code2kanji(SJ4_CONTEXT_PASS askknj[*s & KNJASSYUKUMASK], d, ym, yl, flg);
|
||||
}
|
||||
|
||||
u_char*
|
||||
getkan_ofs(SJ4_CONTEXT u_char* s, u_char* d, u_char* ym, int yl, int flg) {
|
||||
return code2kanji(SJ4_CONTEXT_PASS dicbuf + ((*s & KANJICODEMASK) << 8) + *(s + 1),
|
||||
d, ym, yl, flg);
|
||||
}
|
||||
|
||||
u_char*
|
||||
getkan_norm(u_char* s, u_char* d, u_char* ym, int yl, int flg) {
|
||||
u_char c;
|
||||
|
||||
if(*s != 0) {
|
||||
c = s[1];
|
||||
if(c & 0x80)
|
||||
*d++ = SS3;
|
||||
*d++ = *s | 0x80;
|
||||
*d++ = c | 0x80;
|
||||
} else {
|
||||
*d++ = *s;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
u_char*
|
||||
getkan_ascii(u_char* s, u_char* d, u_char* ym, int yl, int flg) {
|
||||
u_char c;
|
||||
|
||||
c = s[1];
|
||||
if(c & 0x80)
|
||||
*d++ = SS2;
|
||||
*d++ = c;
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
static u_char*
|
||||
code2kanji(SJ4_CONTEXT u_char* s, u_char* d, u_char* ym, int yl, int flg) {
|
||||
int csize;
|
||||
|
||||
for(;;) {
|
||||
csize = codesize(*s);
|
||||
if(s[csize] == KANJISTREND) {
|
||||
switch(*s & KANJIMODEMASK) {
|
||||
case ZENHIRAASSYUKU:
|
||||
d = getkan_hira(s, d, ym, yl, flg);
|
||||
break;
|
||||
|
||||
case ZENKATAASSYUKU:
|
||||
d = getkan_kata(s, d, ym, yl, flg);
|
||||
break;
|
||||
|
||||
case OFFSETASSYUKU:
|
||||
d = getkan_ofs(SJ4_CONTEXT_PASS s, d, ym, yl, flg);
|
||||
break;
|
||||
|
||||
case AIATTRIBUTE:
|
||||
d = getkan_none(s, d, ym, yl, flg);
|
||||
break;
|
||||
|
||||
case LEADINGHANKAKU:
|
||||
d = getkan_ascii(s, d, ym, yl, flg);
|
||||
break;
|
||||
|
||||
case KANJIASSYUKU:
|
||||
d = getkan_knj(SJ4_CONTEXT_PASS s, d, ym, yl, flg);
|
||||
break;
|
||||
|
||||
default:
|
||||
d = getkan_norm(s, d, ym, yl, flg);
|
||||
}
|
||||
break;
|
||||
} else
|
||||
switch(*s & KANJIMODEMASK) {
|
||||
case ZENHIRAASSYUKU:
|
||||
d = getkan_hira(s, d, ym, yl, FALSE);
|
||||
break;
|
||||
|
||||
case ZENKATAASSYUKU:
|
||||
d = getkan_kata(s, d, ym, yl, FALSE);
|
||||
break;
|
||||
|
||||
case OFFSETASSYUKU:
|
||||
d = getkan_ofs(SJ4_CONTEXT_PASS s, d, ym, yl, FALSE);
|
||||
break;
|
||||
|
||||
case AIATTRIBUTE:
|
||||
d = getkan_none(s, d, ym, yl, FALSE);
|
||||
break;
|
||||
|
||||
case LEADINGHANKAKU:
|
||||
d = getkan_ascii(s, d, ym, yl, FALSE);
|
||||
break;
|
||||
|
||||
case KANJIASSYUKU:
|
||||
d = getkan_knj(SJ4_CONTEXT_PASS s, d, ym, yl, FALSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
d = getkan_norm(s, d, ym, yl, FALSE);
|
||||
}
|
||||
|
||||
s += codesize(*s);
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
int getkanji(SJ4_CONTEXT u_char* ym, int yl, u_char* ptr, u_char* buf) {
|
||||
u_char* q;
|
||||
|
||||
q = code2kanji(SJ4_CONTEXT_PASS ptr, buf, ym, yl, TRUE);
|
||||
|
||||
return q - buf;
|
||||
}
|
||||
153
lib/sj4core/getrank.c
Normal file
153
lib/sj4core/getrank.c
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: getrank.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:50 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static void setstynum(SJ4_CONTEXT2), setnspr(SJ4_CONTEXT KHREC*, STDYIN*), regetrank(SJ4_CONTEXT2);
|
||||
|
||||
void getrank(SJ4_CONTEXT2) {
|
||||
|
||||
trank = nrank = 1;
|
||||
|
||||
setstynum(SJ4_CONTEXT_PASS2);
|
||||
|
||||
regetrank(SJ4_CONTEXT_PASS2);
|
||||
}
|
||||
|
||||
static void
|
||||
setstynum(SJ4_CONTEXT2) {
|
||||
KHREC* kptr;
|
||||
STDYIN* sptr;
|
||||
int count;
|
||||
|
||||
for(kptr = kouhotbl, count = khcount; count--; kptr++) {
|
||||
|
||||
sptr = srchstdy(SJ4_CONTEXT_PASS kptr->clrec->jnode->jseg, kptr->offs,
|
||||
kptr->clrec->jnode->dicid);
|
||||
|
||||
if(!sptr) continue;
|
||||
|
||||
setnspr(SJ4_CONTEXT_PASS kptr, sptr);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
setnspr(SJ4_CONTEXT KHREC* kptr, STDYIN* sptr) {
|
||||
KHREC* ptr;
|
||||
int keepnm;
|
||||
TypeStyNum styno;
|
||||
|
||||
styno = kptr->styno = sptr->styno;
|
||||
|
||||
keepnm = trank;
|
||||
|
||||
for(ptr = kouhotbl; ptr < kptr; ptr++) {
|
||||
|
||||
if(styno < ptr->styno) {
|
||||
|
||||
ptr->rank++;
|
||||
|
||||
keepnm--;
|
||||
}
|
||||
|
||||
else if(styno == ptr->styno) {
|
||||
|
||||
if(kptr->sttfg && kptr->ka_fg) {
|
||||
|
||||
if((sptr->sttkj == kptr->sttkj) &&
|
||||
(sptr->ka_kj == kptr->ka_kj)) {
|
||||
ptr->rank++;
|
||||
keepnm--;
|
||||
}
|
||||
}
|
||||
|
||||
else if(kptr->sttfg) {
|
||||
|
||||
if(sptr->sttkj == kptr->sttkj) {
|
||||
ptr->rank++;
|
||||
keepnm--;
|
||||
}
|
||||
}
|
||||
|
||||
else if(kptr->ka_fg) {
|
||||
|
||||
if(sptr->ka_kj == kptr->ka_kj) {
|
||||
ptr->rank++;
|
||||
keepnm--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kptr->rank = (u_char)keepnm;
|
||||
trank++;
|
||||
|
||||
if(keepnm <= nrank) nrank++;
|
||||
|
||||
if(sptr->nmflg && (nrank > keepnm)) nrank = keepnm;
|
||||
}
|
||||
|
||||
static void
|
||||
regetrank(SJ4_CONTEXT2) {
|
||||
KHREC* kptr;
|
||||
int count;
|
||||
int tmp;
|
||||
|
||||
if(nrank < trank) {
|
||||
|
||||
tmp = nrank;
|
||||
|
||||
trank += nkhcount;
|
||||
}
|
||||
|
||||
else {
|
||||
nkhcount = tmp = 0;
|
||||
}
|
||||
|
||||
for(count = khcount, kptr = kouhotbl; count--; kptr++) {
|
||||
|
||||
if(!(kptr->rank)) {
|
||||
if(tmp && kptr->mode && !(kptr->offs)) {
|
||||
kptr->rank = (u_char)tmp++;
|
||||
} else
|
||||
kptr->rank = (u_char)trank++;
|
||||
}
|
||||
|
||||
else if((short)kptr->rank >= nrank)
|
||||
kptr->rank += (u_char)nkhcount;
|
||||
}
|
||||
}
|
||||
55
lib/sj4core/global.c
Normal file
55
lib/sj4core/global.c
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: global.c,v $
|
||||
* $SonyRevision: 1.2 $
|
||||
* $SonyDate: 1994/12/09 11:27:06 $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
#include "sj_const.h"
|
||||
#include "sj_var.h"
|
||||
#include "sj_struct.h"
|
||||
#include "sj_dict.h"
|
||||
#include "Const.h"
|
||||
#include "Struct.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
#ifdef SJ4_GLOBAL
|
||||
Global* work_base;
|
||||
|
||||
STDY* stdy_base;
|
||||
#endif
|
||||
|
||||
int serv_errno;
|
||||
64
lib/sj4core/hzstrlen.c
Normal file
64
lib/sj4core/hzstrlen.c
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: hzstrlen.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:52 $
|
||||
*/
|
||||
|
||||
#include "sj_euc.h"
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
#include "sj_const.h"
|
||||
#include "sj_dict.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
int euc_codesize(u_char c) {
|
||||
if((c & KANJIMODEMASK) == 0x90) {
|
||||
return 1;
|
||||
} else if(isknj1(c)) {
|
||||
return 2;
|
||||
} else if(c == SS3) {
|
||||
return 3;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int hzstrlen(u_char* ptr, int len) {
|
||||
u_char* head;
|
||||
|
||||
head = ptr;
|
||||
|
||||
while(len-- > 0) ptr += euc_codesize(*ptr);
|
||||
|
||||
return (ptr - head);
|
||||
}
|
||||
134
lib/sj4core/init.c
Normal file
134
lib/sj4core/init.c
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: init.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:54 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
void seg_count(SJ4_CONTEXT DICT* dict) {
|
||||
u_char* p;
|
||||
u_char* q;
|
||||
TypeDicSeg segcnt = 0;
|
||||
|
||||
if(dict->getidx) {
|
||||
(*dict->getidx)(SJ4_CONTEXT_PASS dict);
|
||||
|
||||
p = idxbuf;
|
||||
q = p + dict->idxlen;
|
||||
while(p < q && *p) {
|
||||
segcnt++;
|
||||
while(*p++);
|
||||
}
|
||||
}
|
||||
|
||||
dict->segunit = (segcnt == 0) ? 1 : segcnt;
|
||||
}
|
||||
|
||||
void mkidxtbl(SJ4_CONTEXT DICT* dict) {
|
||||
u_char* p;
|
||||
TypeDicSeg seg;
|
||||
|
||||
if(!dict->getidx || !dict->getofs) return;
|
||||
|
||||
seg = 0;
|
||||
|
||||
(*dict->getidx)(SJ4_CONTEXT_PASS dict);
|
||||
(*dict->getofs)(SJ4_CONTEXT_PASS dict);
|
||||
|
||||
idxofs[0] = 0;
|
||||
for(p = idxbuf; p < idxbuf + dict->idxlen && seg < dict->segunit;) {
|
||||
idxofs[seg++] = p - idxbuf;
|
||||
while(*p++);
|
||||
}
|
||||
}
|
||||
|
||||
void initwork(SJ4_CONTEXT2) {
|
||||
jrt1st = jrt2nd = maxjptr = (JREC*)0;
|
||||
clt1st = clt2nd = maxclptr = (CLREC*)0;
|
||||
}
|
||||
|
||||
#ifndef SJ4_GLOBAL
|
||||
Sj4Context* alloccontext(const char* dic) {
|
||||
Sj4Context* ctx = calloc(1, sizeof(*ctx));
|
||||
DictFile* dict;
|
||||
DICTL* node;
|
||||
|
||||
ctx->work = calloc(1, sizeof(*ctx->work));
|
||||
ctx->stdy = calloc(1, sizeof(*ctx->stdy));
|
||||
|
||||
node = calloc(1, sizeof(*node));
|
||||
ctx->work->Jdictlist = node;
|
||||
|
||||
initwork(ctx);
|
||||
|
||||
dict = opendict(ctx, (char*)dic, "");
|
||||
|
||||
if(dict == NULL){
|
||||
free_context(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node->dict = &dict->dict;
|
||||
node->next = NULL;
|
||||
|
||||
seldict(ctx, dict->dict.dicid);
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void free_context(Sj4Context* ctx) {
|
||||
DICTL* node;
|
||||
|
||||
node = ctx->work->Jdictlist;
|
||||
while(node != NULL) {
|
||||
DICTL* next = node->next;
|
||||
|
||||
if(node->dict != NULL) closedict(ctx, (DictFile*)node->dict);
|
||||
free(node);
|
||||
|
||||
node = next;
|
||||
}
|
||||
|
||||
freework(ctx);
|
||||
|
||||
if(ctx->jrec_pool != NULL) free(ctx->jrec_pool);
|
||||
if(ctx->clrec_pool != NULL) free(ctx->clrec_pool);
|
||||
|
||||
free(ctx->stdy);
|
||||
free(ctx->work);
|
||||
|
||||
free(ctx);
|
||||
}
|
||||
#endif
|
||||
58
lib/sj4core/istrcmp.c
Normal file
58
lib/sj4core/istrcmp.c
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: istrcmp.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:55 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
#include "sj_const.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
int istrcmp(u_char* yomip, u_char* idxp, int ylen, int ilen) {
|
||||
for(;;) {
|
||||
|
||||
if((ilen | ylen) == 0) return MATCH;
|
||||
|
||||
if(ilen == 0) return UNDER;
|
||||
|
||||
if((ylen == 0) || (*yomip < *idxp)) return OVER;
|
||||
|
||||
if(*yomip > *idxp) return UNDER;
|
||||
|
||||
yomip++;
|
||||
idxp++;
|
||||
ylen--;
|
||||
ilen--;
|
||||
}
|
||||
}
|
||||
136
lib/sj4core/memory.c
Normal file
136
lib/sj4core/memory.c
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: memory.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:58 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
JREC* free_jlst(SJ4_CONTEXT JREC* p) {
|
||||
JREC* jpk;
|
||||
JREC* jp;
|
||||
JREC* jn;
|
||||
|
||||
jp = NULL;
|
||||
|
||||
for(; p; p = jn) {
|
||||
|
||||
jn = p->jsort;
|
||||
|
||||
if(p->count) {
|
||||
if(jp)
|
||||
jp->jsort = p;
|
||||
else
|
||||
jpk = p;
|
||||
jp = p;
|
||||
}
|
||||
|
||||
else {
|
||||
free_jrec(SJ4_CONTEXT_PASS p);
|
||||
}
|
||||
}
|
||||
|
||||
if(jp) jp->jsort = NULL;
|
||||
|
||||
return jpk;
|
||||
}
|
||||
|
||||
CLREC*
|
||||
free_clst(SJ4_CONTEXT CLREC* p, int l) {
|
||||
CLREC* cpk;
|
||||
CLREC* cp;
|
||||
CLREC* cn;
|
||||
|
||||
cp = cpk = NULL;
|
||||
|
||||
for(; p; p = cn) {
|
||||
|
||||
cn = p->clsort;
|
||||
|
||||
if((int)p->cllen == l) {
|
||||
if(p == selcl) {
|
||||
if(cp) {
|
||||
p->clsort = cpk;
|
||||
cpk = p;
|
||||
} else
|
||||
cpk = cp = p;
|
||||
} else {
|
||||
if(cp)
|
||||
cp->clsort = p;
|
||||
else
|
||||
cpk = p;
|
||||
cp = p;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
(p->jnode->count)--;
|
||||
|
||||
free_clrec(SJ4_CONTEXT_PASS p);
|
||||
}
|
||||
}
|
||||
|
||||
if(cp) cp->clsort = NULL;
|
||||
|
||||
return cpk;
|
||||
}
|
||||
|
||||
void free_clall(SJ4_CONTEXT CLREC* p) {
|
||||
CLREC* next;
|
||||
|
||||
while(p) {
|
||||
(p->jnode->count)--;
|
||||
next = p->clsort;
|
||||
free_clrec(SJ4_CONTEXT_PASS p);
|
||||
p = next;
|
||||
}
|
||||
}
|
||||
|
||||
void free_jall(SJ4_CONTEXT JREC* p) {
|
||||
JREC* next;
|
||||
|
||||
while(p) {
|
||||
next = p->jsort;
|
||||
free_jrec(SJ4_CONTEXT_PASS p);
|
||||
p = next;
|
||||
}
|
||||
}
|
||||
|
||||
void freework(SJ4_CONTEXT2) {
|
||||
free_clall(SJ4_CONTEXT_PASS maxclptr);
|
||||
clt1st = maxclptr = NULL;
|
||||
|
||||
free_jall(SJ4_CONTEXT_PASS maxjptr);
|
||||
jrt1st = maxjptr = NULL;
|
||||
}
|
||||
156
lib/sj4core/mk2claus.c
Normal file
156
lib/sj4core/mk2claus.c
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: mk2claus.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:00 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_right.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static int
|
||||
set2nd(SJ4_CONTEXT CLREC* clrec) {
|
||||
|
||||
CLREC* rec2;
|
||||
|
||||
mkjiritu(SJ4_CONTEXT_PASS DO_IKKATU | DO_CLSTUDY);
|
||||
|
||||
mkbunsetu(SJ4_CONTEXT_PASS2);
|
||||
|
||||
if(!maxclptr) {
|
||||
wakachi(SJ4_CONTEXT_PASS2);
|
||||
return clrec->cllen;
|
||||
}
|
||||
|
||||
for(rec2 = maxclptr; rec2; rec2 = rec2->clsort) {
|
||||
if(terminate(SJ4_CONTEXT_PASS rec2->right, cnvstart + rec2->cllen) != SHU)
|
||||
break;
|
||||
}
|
||||
|
||||
return rec2 ? (clrec->cllen + rec2->cllen) : (clrec->cllen);
|
||||
}
|
||||
|
||||
void mk2claus(SJ4_CONTEXT2) {
|
||||
u_char* keepptr;
|
||||
int keeplen;
|
||||
CLREC* clrec;
|
||||
int len;
|
||||
int save2ln;
|
||||
int prty;
|
||||
int maxprty;
|
||||
int count;
|
||||
int prty2;
|
||||
|
||||
prty = maxprty = prty2 = 0;
|
||||
|
||||
clt2nd = maxclptr = NULL;
|
||||
jrt2nd = maxjptr = NULL;
|
||||
|
||||
selcl = clt1st;
|
||||
|
||||
if(selcl->right == R_FZKKGU) {
|
||||
pritiny(SJ4_CONTEXT_PASS2);
|
||||
return;
|
||||
}
|
||||
|
||||
if(cnvlen == selcl->cllen) {
|
||||
pritiny(SJ4_CONTEXT_PASS2);
|
||||
return;
|
||||
}
|
||||
|
||||
keepptr = cnvstart;
|
||||
keeplen = cnvlen;
|
||||
|
||||
len = count = 0;
|
||||
for(clrec = selcl; clrec && count < 5; clrec = clrec->clsort) {
|
||||
|
||||
cnvstart = keepptr + clrec->cllen;
|
||||
cnvlen = keeplen - clrec->cllen;
|
||||
|
||||
if(len != clrec->cllen) {
|
||||
if(clt2nd != maxclptr) {
|
||||
free_clall(SJ4_CONTEXT_PASS maxclptr);
|
||||
free_jall(SJ4_CONTEXT_PASS maxjptr);
|
||||
}
|
||||
|
||||
save2ln = set2nd(SJ4_CONTEXT_PASS clrec);
|
||||
|
||||
count++;
|
||||
len = clrec->cllen;
|
||||
prty2 = 0;
|
||||
}
|
||||
|
||||
if(Termtbl[clrec->right] & T_SHUUJO)
|
||||
clrec->cl2len = (u_char)len;
|
||||
else
|
||||
clrec->cl2len = (u_char)save2ln;
|
||||
|
||||
if(selcl->cl2len > clrec->cl2len) continue;
|
||||
|
||||
prty = priority(SJ4_CONTEXT_PASS clrec) - prty2;
|
||||
|
||||
prty2++;
|
||||
|
||||
if(selcl->cl2len == clrec->cl2len) {
|
||||
if(clrec->cllen == nextcllen) {
|
||||
if(selcl->cllen != nextcllen)
|
||||
;
|
||||
else if(prty <= maxprty)
|
||||
continue;
|
||||
}
|
||||
|
||||
else if(prty <= maxprty)
|
||||
continue;
|
||||
}
|
||||
|
||||
selcl = clrec;
|
||||
maxprty = prty;
|
||||
|
||||
if(clt2nd == maxclptr) continue;
|
||||
|
||||
free_clall(SJ4_CONTEXT_PASS clt2nd);
|
||||
free_jall(SJ4_CONTEXT_PASS jrt2nd);
|
||||
jrt2nd = maxjptr;
|
||||
clt2nd = maxclptr;
|
||||
}
|
||||
|
||||
if(clt2nd != maxclptr) {
|
||||
free_clall(SJ4_CONTEXT_PASS maxclptr);
|
||||
maxclptr = NULL;
|
||||
free_jall(SJ4_CONTEXT_PASS maxjptr);
|
||||
maxjptr = NULL;
|
||||
}
|
||||
|
||||
cnvstart = keepptr;
|
||||
cnvlen = keeplen;
|
||||
}
|
||||
157
lib/sj4core/mkbunset.c
Normal file
157
lib/sj4core/mkbunset.c
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: mkbunset.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:02 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_hinsi.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
void mkbunsetu(SJ4_CONTEXT2) {
|
||||
JREC* jrec;
|
||||
TypeGram hinsi;
|
||||
u_char* cnj;
|
||||
CREC crec[4];
|
||||
int count;
|
||||
TypeCnct right;
|
||||
u_char* next;
|
||||
int i;
|
||||
|
||||
fzkcount = 0;
|
||||
|
||||
maxclptr = NULL;
|
||||
|
||||
jrec = maxjptr;
|
||||
|
||||
while(jrec) {
|
||||
|
||||
if(jrec->stbofs && (cnj = getstb(jrec->hinsi)))
|
||||
hinsi = StbHinsi(cnj + jrec->stbofs - 1);
|
||||
else
|
||||
hinsi = jrec->hinsi;
|
||||
|
||||
if((right = Connadr[hinsi])) {
|
||||
gobilen = 0;
|
||||
next = cnvstart + jrec->jlen;
|
||||
|
||||
if(terminate(SJ4_CONTEXT_PASS right, next)) {
|
||||
fzk_ka_flg = 0;
|
||||
setclrec(SJ4_CONTEXT_PASS jrec, next, right);
|
||||
}
|
||||
|
||||
srchfzk(SJ4_CONTEXT_PASS jrec, next, right, 0);
|
||||
}
|
||||
|
||||
else if((count = setconj(SJ4_CONTEXT_PASS hinsi, jrec, crec))) {
|
||||
|
||||
for(i = count; i-- > 0;) {
|
||||
|
||||
right = crec[i].right;
|
||||
gobilen = crec[i].len;
|
||||
next = cnvstart + jrec->jlen + gobilen;
|
||||
|
||||
if(terminate(SJ4_CONTEXT_PASS right, next)) {
|
||||
fzk_ka_flg = 0;
|
||||
setclrec(SJ4_CONTEXT_PASS jrec, next, right);
|
||||
}
|
||||
|
||||
srchfzk(SJ4_CONTEXT_PASS jrec, next, right, 0);
|
||||
}
|
||||
}
|
||||
|
||||
jrec = jrec->jsort;
|
||||
}
|
||||
}
|
||||
|
||||
CLREC*
|
||||
argclrec(SJ4_CONTEXT int len) {
|
||||
CLREC* ptr;
|
||||
CLREC* rec;
|
||||
CLREC* child;
|
||||
|
||||
rec = alloc_clrec(SJ4_CONTEXT_PASS2);
|
||||
|
||||
if(!rec) {
|
||||
if(!maxclptr)
|
||||
return NULL;
|
||||
|
||||
ptr = NULL;
|
||||
rec = maxclptr;
|
||||
while((child = rec->clsort)) {
|
||||
ptr = rec;
|
||||
rec = child;
|
||||
}
|
||||
|
||||
if(len <= (int)rec->cllen)
|
||||
return NULL;
|
||||
|
||||
if(ptr)
|
||||
ptr->clsort = NULL;
|
||||
else
|
||||
maxclptr = NULL;
|
||||
if(rec->jnode) (rec->jnode)--;
|
||||
}
|
||||
|
||||
memset((u_char*)rec, 0, sizeof(*rec));
|
||||
rec->cllen = rec->cl2len = (u_char)len;
|
||||
|
||||
if(!maxclptr) {
|
||||
maxclptr = rec;
|
||||
return rec;
|
||||
}
|
||||
|
||||
ptr = maxclptr;
|
||||
|
||||
if(((int)ptr->cllen < len) ||
|
||||
(((int)ptr->cllen == len) &&
|
||||
(ptr->jnode->hinsi == TANKANJI))) {
|
||||
rec->clsort = maxclptr;
|
||||
maxclptr = rec;
|
||||
return rec;
|
||||
}
|
||||
|
||||
while((child = ptr->clsort)) {
|
||||
if((int)child->cllen < len ||
|
||||
((int)child->cllen == len &&
|
||||
child->jnode->hinsi == TANKANJI)) {
|
||||
ptr->clsort = rec;
|
||||
rec->clsort = child;
|
||||
return rec;
|
||||
} else
|
||||
ptr = child;
|
||||
}
|
||||
|
||||
ptr->clsort = rec;
|
||||
return rec;
|
||||
}
|
||||
183
lib/sj4core/mkjiritu.c
Normal file
183
lib/sj4core/mkjiritu.c
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: mkjiritu.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:03 $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static void dic_mu(SJ4_CONTEXT int), dic_cl(SJ4_CONTEXT2);
|
||||
|
||||
void mkjiritu(SJ4_CONTEXT int mode) {
|
||||
u_char chkind1;
|
||||
u_char chkind2;
|
||||
JREC* jrec;
|
||||
u_char* stb;
|
||||
|
||||
headcode = headlen = 0;
|
||||
|
||||
maxjptr = NULL;
|
||||
|
||||
chkind1 = Chrtbl[*cnvstart];
|
||||
|
||||
if(chkind1 & DICTOP) {
|
||||
dic_mu(SJ4_CONTEXT_PASS mode);
|
||||
}
|
||||
|
||||
if(mode & DO_CLSTUDY) dic_cl(SJ4_CONTEXT_PASS2);
|
||||
|
||||
srchnum(SJ4_CONTEXT_PASS2);
|
||||
|
||||
if(srchhead(SJ4_CONTEXT_PASS2) && cnvlen != headlen) {
|
||||
cnvstart += headlen;
|
||||
cnvlen -= headlen;
|
||||
|
||||
chkind2 = Chrtbl[*cnvstart];
|
||||
|
||||
if(chkind2 & DICTOP) {
|
||||
dic_mu(SJ4_CONTEXT_PASS mode);
|
||||
}
|
||||
|
||||
if(headcode == SETTOU_DAI) {
|
||||
srchnum(SJ4_CONTEXT_PASS2);
|
||||
}
|
||||
|
||||
cnvstart -= headlen;
|
||||
cnvlen += headlen;
|
||||
}
|
||||
|
||||
for(jrec = maxjptr; jrec; jrec = jrec->jsort) {
|
||||
if((stb = getstb(jrec->hinsi)))
|
||||
setubi(SJ4_CONTEXT_PASS jrec, stb);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
dic_mu(SJ4_CONTEXT int mode) {
|
||||
u_char* tagp;
|
||||
DICTL* dp;
|
||||
|
||||
for(dp = dictlist; dp; dp = dp->next) {
|
||||
curdict = dp->dict;
|
||||
dicinl = 1;
|
||||
dicsaml = 0;
|
||||
prevseg = -1;
|
||||
|
||||
while((tagp = srchdict(SJ4_CONTEXT_PASS tagp))) setjrec(SJ4_CONTEXT_PASS tagp, mode);
|
||||
}
|
||||
}
|
||||
|
||||
JREC* argjrec(SJ4_CONTEXT int len, JREC* rec) {
|
||||
JREC* ptr;
|
||||
JREC* jrec;
|
||||
JREC* child;
|
||||
|
||||
jrec = alloc_jrec(SJ4_CONTEXT_PASS2);
|
||||
|
||||
if(!jrec) {
|
||||
if(!maxjptr) return NULL;
|
||||
|
||||
ptr = NULL;
|
||||
jrec = maxjptr;
|
||||
while((child = jrec->jsort)) {
|
||||
ptr = jrec;
|
||||
jrec = child;
|
||||
}
|
||||
|
||||
if(len <= (int)jrec->jlen) return NULL;
|
||||
|
||||
if(ptr)
|
||||
ptr->jsort = NULL;
|
||||
else
|
||||
maxjptr = NULL;
|
||||
}
|
||||
|
||||
if(rec)
|
||||
memcpy((u_char*)jrec, (u_char*)rec, sizeof(JREC));
|
||||
else
|
||||
memset((u_char*)jrec, 0, sizeof(*jrec));
|
||||
jrec->jlen = (u_char)len;
|
||||
|
||||
if(!maxjptr) {
|
||||
maxjptr = jrec;
|
||||
jrec->jsort = NULL;
|
||||
return jrec;
|
||||
}
|
||||
|
||||
ptr = maxjptr;
|
||||
|
||||
if((int)ptr->jlen < len) {
|
||||
jrec->jsort = maxjptr;
|
||||
maxjptr = jrec;
|
||||
return jrec;
|
||||
}
|
||||
|
||||
while((child = ptr->jsort)) {
|
||||
if((int)child->jlen < len) break;
|
||||
|
||||
ptr = child;
|
||||
}
|
||||
|
||||
ptr->jsort = jrec;
|
||||
jrec->jsort = child;
|
||||
return jrec;
|
||||
}
|
||||
|
||||
static void
|
||||
dic_cl(SJ4_CONTEXT2) {
|
||||
u_char* p;
|
||||
u_short pos;
|
||||
int len;
|
||||
int cmp;
|
||||
|
||||
if(!StudyExist()) return;
|
||||
|
||||
if((pos = CLSTUDYIDX[(short)*cnvstart / CLSTUDYSTEP]) != (u_short)-1) {
|
||||
|
||||
for(p = CLSTUDYDICT + pos; !iseocl(p); p = ClNextTag(p)) {
|
||||
cmp = sstrncmp(cnvstart, (u_char*)ClYomiPos(p),
|
||||
len = ClYomiLen(p));
|
||||
|
||||
if(cmp == MATCH) {
|
||||
if(!isdpnd(*(cnvstart + len))) {
|
||||
setcrec(SJ4_CONTEXT_PASS p);
|
||||
}
|
||||
}
|
||||
|
||||
else if(cmp == OVER)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
426
lib/sj4core/mkkouho.c
Normal file
426
lib/sj4core/mkkouho.c
Normal file
|
|
@ -0,0 +1,426 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: mkkouho.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:04 $
|
||||
*/
|
||||
|
||||
#include "sj_euc.h"
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_hinsi.h"
|
||||
#include "sj_suuji.h"
|
||||
#include "sj_dict.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static void getkhtbl(SJ4_CONTEXT CLREC*), cl_kanji(SJ4_CONTEXT JREC*, CLREC*);
|
||||
static int diffknj(SJ4_CONTEXT JREC*, u_char*, int);
|
||||
static void cl_numcmn(SJ4_CONTEXT JREC*, CLREC*);
|
||||
static u_char* makekan(SJ4_CONTEXT u_char*, u_char*, int);
|
||||
|
||||
void mkkouho(SJ4_CONTEXT2) {
|
||||
CLREC* clrec;
|
||||
int keeplen;
|
||||
|
||||
khcount = nkhcount = 0;
|
||||
|
||||
keeplen = clt1st->cllen;
|
||||
|
||||
clrec = clt1st;
|
||||
|
||||
do {
|
||||
getkhtbl(SJ4_CONTEXT_PASS clrec);
|
||||
clrec = clrec->clsort;
|
||||
} while(clrec && (keeplen == clrec->cllen));
|
||||
}
|
||||
|
||||
static void
|
||||
getkhtbl(SJ4_CONTEXT CLREC* clrec) {
|
||||
JREC* jrec;
|
||||
|
||||
jrec = clrec->jnode;
|
||||
|
||||
switch(jrec->class) {
|
||||
case C_DICT:
|
||||
cl_kanji(SJ4_CONTEXT_PASS jrec, clrec);
|
||||
break;
|
||||
case C_N_ARABIA:
|
||||
case C_N_ARACMA:
|
||||
case C_N_KAZU:
|
||||
case C_N_SUUJI:
|
||||
case C_N_NANSUU:
|
||||
case C_N_KANKURA:
|
||||
case C_N_ARAKURA:
|
||||
case C_N_KAZULONG:
|
||||
case C_N_KAZULCMA:
|
||||
case C_N_SUUJILONG:
|
||||
cl_numcmn(SJ4_CONTEXT_PASS jrec, clrec);
|
||||
break;
|
||||
case C_BUNSETU:
|
||||
break;
|
||||
case C_MINASI:
|
||||
case C_WAKACHI:
|
||||
setkouho(SJ4_CONTEXT_PASS clrec, (TypeDicOfs)0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cl_kanji(SJ4_CONTEXT JREC* jrec, CLREC* clrec) {
|
||||
u_char* ptr;
|
||||
int kcount = khcount;
|
||||
|
||||
if(seldict(SJ4_CONTEXT_PASS jrec->dicid)) {
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, jrec->jseg);
|
||||
ptr = dicbuf + jrec->jofsst + 1;
|
||||
|
||||
get_askknj(SJ4_CONTEXT_PASS2);
|
||||
|
||||
while(*ptr != HINSIBLKTERM) {
|
||||
if(diffknj(SJ4_CONTEXT_PASS jrec, ptr, kcount)) {
|
||||
setkouho(SJ4_CONTEXT_PASS clrec, (TypeDicOfs)(ptr - dicbuf), 0);
|
||||
}
|
||||
ptr = skipkstr(ptr);
|
||||
}
|
||||
} else {
|
||||
setkouho(SJ4_CONTEXT_PASS clrec, (TypeDicOfs)1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
u_char*
|
||||
makekan_none(SJ4_CONTEXT u_char* s, u_char* d, int flg) {
|
||||
return d;
|
||||
}
|
||||
|
||||
u_char*
|
||||
makekan_1byte(SJ4_CONTEXT u_char* s, u_char* d, int flg) {
|
||||
if((*s & KANJIMODEMASK) == ZENHIRAASSYUKU)
|
||||
*d++ = 0x10 | (*s & KNJASSYUKUMASK);
|
||||
else
|
||||
*d++ = 0x90 | (*s & KNJASSYUKUMASK);
|
||||
|
||||
if(flg) *d++ = KANJISTREND;
|
||||
return d;
|
||||
}
|
||||
|
||||
u_char*
|
||||
makekan_knj(SJ4_CONTEXT u_char* s, u_char* d, int flg) {
|
||||
return makekan(SJ4_CONTEXT_PASS askknj[*s & KNJASSYUKUMASK], d, flg);
|
||||
}
|
||||
|
||||
u_char* makekan_ofs(SJ4_CONTEXT u_char* s, u_char* d, int flg) {
|
||||
return makekan(SJ4_CONTEXT_PASS dicbuf + ((*s & KANJICODEMASK) << 8) + *(s + 1),
|
||||
d, flg);
|
||||
}
|
||||
|
||||
u_char*
|
||||
makekan_norm(SJ4_CONTEXT u_char* s, u_char* d, int flg) {
|
||||
u_char c;
|
||||
|
||||
if(*s != 0) {
|
||||
c = s[1];
|
||||
if(c & 0x80)
|
||||
*d++ = SS3;
|
||||
*d++ = *s | 0x80;
|
||||
*d++ = c | 0x80;
|
||||
} else {
|
||||
*d++ = *s;
|
||||
}
|
||||
if(flg) *d++ = KANJISTREND;
|
||||
return d;
|
||||
}
|
||||
|
||||
u_char*
|
||||
makekan_ascii(SJ4_CONTEXT u_char* s, u_char* d, int flg) {
|
||||
u_char c;
|
||||
|
||||
c = s[1];
|
||||
if(c & 0x80)
|
||||
*d++ = SS2;
|
||||
*d++ = c;
|
||||
|
||||
if(flg) *d++ = KANJISTREND;
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
static u_char*
|
||||
makekan(SJ4_CONTEXT u_char* s, u_char* d, int flg) {
|
||||
int csize;
|
||||
|
||||
for(;;) {
|
||||
csize = codesize(*s);
|
||||
if(s[csize] == KANJISTREND) {
|
||||
switch(*s & KANJIMODEMASK) {
|
||||
case ZENHIRAASSYUKU:
|
||||
d = makekan_1byte(SJ4_CONTEXT_PASS s, d, flg);
|
||||
break;
|
||||
|
||||
case ZENKATAASSYUKU:
|
||||
d = makekan_1byte(SJ4_CONTEXT_PASS s, d, flg);
|
||||
break;
|
||||
|
||||
case OFFSETASSYUKU:
|
||||
d = makekan_ofs(SJ4_CONTEXT_PASS s, d, flg);
|
||||
break;
|
||||
|
||||
case AIATTRIBUTE:
|
||||
d = makekan_none(SJ4_CONTEXT_PASS s, d, flg);
|
||||
break;
|
||||
|
||||
case LEADINGHANKAKU:
|
||||
d = makekan_ascii(SJ4_CONTEXT_PASS s, d, flg);
|
||||
break;
|
||||
|
||||
case KANJIASSYUKU:
|
||||
d = makekan_knj(SJ4_CONTEXT_PASS s, d, flg);
|
||||
break;
|
||||
|
||||
default:
|
||||
d = makekan_norm(SJ4_CONTEXT_PASS s, d, flg);
|
||||
}
|
||||
break;
|
||||
} else
|
||||
switch(*s & KANJIMODEMASK) {
|
||||
case ZENHIRAASSYUKU:
|
||||
d = makekan_1byte(SJ4_CONTEXT_PASS s, d, FALSE);
|
||||
break;
|
||||
|
||||
case ZENKATAASSYUKU:
|
||||
d = makekan_1byte(SJ4_CONTEXT_PASS s, d, FALSE);
|
||||
break;
|
||||
|
||||
case OFFSETASSYUKU:
|
||||
d = makekan_ofs(SJ4_CONTEXT_PASS s, d, FALSE);
|
||||
break;
|
||||
|
||||
case AIATTRIBUTE:
|
||||
d = makekan_none(SJ4_CONTEXT_PASS s, d, FALSE);
|
||||
break;
|
||||
|
||||
case LEADINGHANKAKU:
|
||||
d = makekan_ascii(SJ4_CONTEXT_PASS s, d, FALSE);
|
||||
break;
|
||||
|
||||
case KANJIASSYUKU:
|
||||
d = makekan_knj(SJ4_CONTEXT_PASS s, d, FALSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
d = makekan_norm(SJ4_CONTEXT_PASS s, d, FALSE);
|
||||
}
|
||||
s += codesize(*s);
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
#define PEND 2
|
||||
#define QEND 1
|
||||
static int
|
||||
sameknj(u_char* p, u_char plen, u_char* q, u_char qlen) {
|
||||
int i;
|
||||
int j;
|
||||
int endf = 0;
|
||||
int brkf;
|
||||
|
||||
do {
|
||||
if((i = euc_codesize(*p)) != euc_codesize(*q)) return FALSE;
|
||||
|
||||
brkf = 0;
|
||||
for(j = 0; j < i; j++) {
|
||||
if(p[j] != q[j]) {
|
||||
brkf = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(brkf) break;
|
||||
|
||||
if(p[i] == KANJISTREND) endf += PEND;
|
||||
if(q[i] == KANJISTREND) endf += QEND;
|
||||
|
||||
p += i;
|
||||
q += i;
|
||||
} while(!endf);
|
||||
|
||||
switch(endf) {
|
||||
case(PEND | QEND):
|
||||
if(plen == qlen) return TRUE;
|
||||
break;
|
||||
|
||||
case PEND:
|
||||
i = plen;
|
||||
plen = qlen;
|
||||
qlen = i;
|
||||
p = q;
|
||||
|
||||
case QEND:
|
||||
if(p[euc_codesize(*p)] != KANJISTREND) break;
|
||||
if((*p & KANJIMODEMASK) != 0x10) break;
|
||||
if(qlen != plen - (*p & KANJICODEMASK) - 1) break;
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
if(q[euc_codesize(*q)] != KANJISTREND) break;
|
||||
if(p[euc_codesize(*p)] != KANJISTREND) break;
|
||||
if((*q & KANJIMODEMASK) != 0x10) break;
|
||||
if((*p & KANJIMODEMASK) != 0x10) break;
|
||||
if(plen - (*p & KANJICODEMASK) != qlen - (*q & KANJICODEMASK))
|
||||
break;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#undef PEND
|
||||
#undef QEND
|
||||
|
||||
static int
|
||||
diffknj(SJ4_CONTEXT JREC* jrec, u_char* ptr, int num) {
|
||||
KHREC* kptr;
|
||||
JREC* jptr;
|
||||
int i;
|
||||
u_char kbuf1[MAXWDKANJILEN];
|
||||
u_char kbuf2[MAXWDKANJILEN];
|
||||
|
||||
if(jrec->hinsi == TANKANJI) return TRUE;
|
||||
|
||||
makekan(SJ4_CONTEXT_PASS ptr, kbuf1, TRUE);
|
||||
|
||||
for(i = 0, kptr = kouhotbl; i < num; i++, kptr++) {
|
||||
if((jptr = kptr->clrec->jnode) == jrec)
|
||||
return FALSE;
|
||||
|
||||
if(jptr->hinsi == TANKANJI) continue;
|
||||
|
||||
if(jptr->class != jrec->class) continue;
|
||||
|
||||
if(jptr->dicid != jrec->dicid) continue;
|
||||
|
||||
if(jptr->jseg != jrec->jseg) continue;
|
||||
|
||||
if(jptr->sttofs != jrec->sttofs) continue;
|
||||
|
||||
if(jptr->stbofs != jrec->stbofs) continue;
|
||||
|
||||
makekan(SJ4_CONTEXT_PASS dicbuf + kptr->offs, kbuf2, TRUE);
|
||||
|
||||
if(sameknj(kbuf1, jrec->jlen, kbuf2, jptr->jlen))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
chrck_numtbl(u_short flg, u_short cond) {
|
||||
u_short must;
|
||||
|
||||
if((cond = SelNumCond(cond))) {
|
||||
if((must = (cond & SELNUMMUST))) {
|
||||
if((flg & must) != must) return FALSE;
|
||||
cond &= ~must;
|
||||
}
|
||||
if(cond && !(cond & flg)) return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int sel_sjmode(JREC* jrec) {
|
||||
u_short i;
|
||||
u_short* p;
|
||||
u_short* q;
|
||||
|
||||
switch(jrec->class) {
|
||||
case C_N_ARABIA:
|
||||
case C_N_ARACMA:
|
||||
case C_N_KAZU:
|
||||
case C_N_SUUJI:
|
||||
case C_N_NANSUU:
|
||||
case C_N_KANKURA:
|
||||
case C_N_ARAKURA:
|
||||
case C_N_KAZULONG:
|
||||
case C_N_KAZULCMA:
|
||||
case C_N_SUUJILONG:
|
||||
p = q = Selsjadrs(jrec->class - C_N_ARABIA);
|
||||
break;
|
||||
|
||||
default:
|
||||
return SELARB;
|
||||
}
|
||||
|
||||
while((i = *p++) != SELNUMTERM) {
|
||||
if(chrck_numtbl(jrec->flags, i)) break;
|
||||
}
|
||||
|
||||
if(i == SELNUMTERM) i = *q;
|
||||
|
||||
return SelNumFunc(i);
|
||||
}
|
||||
|
||||
static void
|
||||
cl_numcmn(SJ4_CONTEXT JREC* jrec, CLREC* clrec) {
|
||||
u_char* p;
|
||||
int i;
|
||||
u_short j;
|
||||
u_short* tbl;
|
||||
|
||||
p = cnvstart;
|
||||
if((i = jrec->sttofs) == SETTOU_DAI)
|
||||
p += SttYomiLen(Settou_ptr(i));
|
||||
else if(i == SETTOU_KIGOU)
|
||||
p++;
|
||||
|
||||
if(jrec->jofsst) {
|
||||
i = sel_sjmode(jrec);
|
||||
|
||||
if(seldict(SJ4_CONTEXT_PASS jrec->dicid)) {
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, jrec->jseg);
|
||||
|
||||
p = dicbuf + jrec->jofsst + 1;
|
||||
|
||||
while(*p != HINSIBLKTERM) {
|
||||
setkouho(SJ4_CONTEXT_PASS clrec, (TypeDicOfs)(p - dicbuf), i);
|
||||
p = skipkstr(p);
|
||||
}
|
||||
} else {
|
||||
setkouho(SJ4_CONTEXT_PASS clrec, (TypeDicOfs)1, i);
|
||||
}
|
||||
} else {
|
||||
tbl = Selsjadrs(jrec->class - C_N_ARABIA);
|
||||
while((j = *tbl++) != SELNUMTERM) {
|
||||
if(!chrck_numtbl(jrec->flags, j)) continue;
|
||||
|
||||
setkouho(SJ4_CONTEXT_PASS clrec, (TypeDicOfs)0, (int)SelNumFunc(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
321
lib/sj4core/mknumber.c
Normal file
321
lib/sj4core/mknumber.c
Normal file
|
|
@ -0,0 +1,321 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: mknumber.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:05 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_yomi.h"
|
||||
#include "sj_suuji.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static int
|
||||
word2char(SJ4_CONTEXT u_short wd, u_char* tbl, int keta, int flg) {
|
||||
int mask;
|
||||
int num;
|
||||
u_char* src;
|
||||
|
||||
for(mask = 0x1000; mask; mask >>= 4) {
|
||||
switch(num = (unsigned int)wd / mask) {
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case _NUM0:
|
||||
if(!flg) break;
|
||||
|
||||
default:
|
||||
src = tbl + (num - _NUM0) * 2;
|
||||
*kanjitmp++ = *src++;
|
||||
*kanjitmp++ = *src;
|
||||
flg = TRUE;
|
||||
|
||||
if(keta && !(keta % 3)) {
|
||||
*kanjitmp++ = COMMAHIGH;
|
||||
*kanjitmp++ = COMMALOW;
|
||||
}
|
||||
}
|
||||
if(keta) keta--;
|
||||
wd &= (mask - 1);
|
||||
}
|
||||
|
||||
return flg;
|
||||
}
|
||||
|
||||
static void
|
||||
words2num(SJ4_CONTEXT u_short* wd, u_char* tbl, int flgc) {
|
||||
int i;
|
||||
int keta;
|
||||
int flg;
|
||||
u_char* kp = kanjitmp;
|
||||
|
||||
if(flgc) {
|
||||
keta = NUMKETALENGTH - 1;
|
||||
flg = FALSE;
|
||||
} else {
|
||||
keta = 0;
|
||||
flg = TRUE;
|
||||
}
|
||||
|
||||
for(i = NUMWORDBUF; i-- > 0;) {
|
||||
flg = word2char(SJ4_CONTEXT_PASS * (wd + i), tbl, keta, flg);
|
||||
if(keta) keta -= 4;
|
||||
}
|
||||
|
||||
if(kp == kanjitmp) {
|
||||
*kanjitmp++ = *tbl++;
|
||||
*kanjitmp++ = *tbl;
|
||||
}
|
||||
}
|
||||
|
||||
void num_type00(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
u_short num[NUMWORDBUF];
|
||||
|
||||
setwdnum(SJ4_CONTEXT_PASS s1, (int)jrec->numlen, num);
|
||||
|
||||
words2num(SJ4_CONTEXT_PASS num, Num1tbl, FALSE);
|
||||
}
|
||||
|
||||
void num_type01(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
u_short num[NUMWORDBUF];
|
||||
|
||||
setwdnum(SJ4_CONTEXT_PASS s1, (int)jrec->numlen, num);
|
||||
|
||||
words2num(SJ4_CONTEXT_PASS num, Num1tbl, FALSE);
|
||||
}
|
||||
|
||||
void num_type02(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
u_short num[NUMWORDBUF];
|
||||
|
||||
setwdnum(SJ4_CONTEXT_PASS s1, (int)jrec->numlen, num);
|
||||
|
||||
words2num(SJ4_CONTEXT_PASS num, Num1tbl, TRUE);
|
||||
}
|
||||
|
||||
void num_type03(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
u_short num[NUMWORDBUF];
|
||||
|
||||
setwdnum(SJ4_CONTEXT_PASS s1, (int)jrec->numlen, num);
|
||||
|
||||
words2num(SJ4_CONTEXT_PASS num, Num2tbl, FALSE);
|
||||
}
|
||||
|
||||
void num_type04(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
u_short num[NUMWORDBUF];
|
||||
|
||||
setwdnum(SJ4_CONTEXT_PASS s1, (int)jrec->numlen, num);
|
||||
|
||||
words2num(SJ4_CONTEXT_PASS num, Num2tbl, FALSE);
|
||||
}
|
||||
|
||||
void num_type05(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
u_short num[NUMWORDBUF];
|
||||
|
||||
setwdnum(SJ4_CONTEXT_PASS s1, (int)jrec->numlen, num);
|
||||
|
||||
words2num(SJ4_CONTEXT_PASS num, Num2tbl, TRUE);
|
||||
}
|
||||
|
||||
void num_type06(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
u_short num[NUMWORDBUF];
|
||||
|
||||
setwdnum(SJ4_CONTEXT_PASS s1, (int)jrec->numlen, num);
|
||||
|
||||
words2num(SJ4_CONTEXT_PASS num, Num3tbl, FALSE);
|
||||
}
|
||||
|
||||
void num_type07(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
u_short num[NUMWORDBUF];
|
||||
|
||||
setwdnum(SJ4_CONTEXT_PASS s1, (int)jrec->numlen, num);
|
||||
|
||||
words2num(SJ4_CONTEXT_PASS num, Num3tbl, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
kan_num(SJ4_CONTEXT u_short* wd, u_char* tbl1, u_char* tbl2) {
|
||||
int ii;
|
||||
u_short tmp;
|
||||
int mask;
|
||||
int num;
|
||||
int flg;
|
||||
u_char* kurai1;
|
||||
u_char* kurai2;
|
||||
u_char* src;
|
||||
u_char* keep = kanjitmp;
|
||||
|
||||
kurai2 = Num6tbl - 2;
|
||||
mask = 0;
|
||||
wd += NUMWORDBUF - 1;
|
||||
flg = FALSE;
|
||||
|
||||
for(ii = NUMKETALENGTH; ii-- > 0;) {
|
||||
if(!mask) {
|
||||
if(flg) {
|
||||
*kanjitmp++ = *kurai2++;
|
||||
*kanjitmp++ = *kurai2++;
|
||||
} else
|
||||
kurai2 += 2;
|
||||
|
||||
mask = 0x1000;
|
||||
tmp = *wd--;
|
||||
flg = FALSE;
|
||||
kurai1 = tbl2;
|
||||
}
|
||||
|
||||
if((num = (unsigned int)tmp / mask) > _NUM0) {
|
||||
if((num != _NUM1) || !*kurai1) {
|
||||
src = tbl1 + (num - _NUM0) * 2;
|
||||
*kanjitmp++ = *src++;
|
||||
*kanjitmp++ = *src;
|
||||
}
|
||||
|
||||
if(*kurai1) {
|
||||
*kanjitmp++ = *kurai1++;
|
||||
*kanjitmp++ = *kurai1++;
|
||||
}
|
||||
flg = TRUE;
|
||||
} else
|
||||
kurai1 += 2;
|
||||
|
||||
tmp &= (mask - 1);
|
||||
mask >>= 4;
|
||||
}
|
||||
|
||||
if(kanjitmp == keep) {
|
||||
*kanjitmp++ = *tbl1++;
|
||||
*kanjitmp++ = *tbl1;
|
||||
}
|
||||
}
|
||||
|
||||
void num_type08(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
u_short num[NUMWORDBUF];
|
||||
|
||||
setwdnum(SJ4_CONTEXT_PASS s1, (int)jrec->numlen, num);
|
||||
|
||||
kan_num(SJ4_CONTEXT_PASS num, Num2tbl, Num4tbl);
|
||||
}
|
||||
|
||||
void num_type09(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
u_short num[NUMWORDBUF];
|
||||
|
||||
setwdnum(SJ4_CONTEXT_PASS s1, (int)jrec->numlen, num);
|
||||
|
||||
kan_num(SJ4_CONTEXT_PASS num, Num3tbl, Num5tbl);
|
||||
}
|
||||
|
||||
void num_type10(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
int i;
|
||||
|
||||
for(i = jrec->numlen; i > 0; i--) {
|
||||
if(Chrtbl[*s1++] & NUMBER) {
|
||||
*kanjitmp++ = *s2++;
|
||||
*kanjitmp++ = *s2++;
|
||||
} else
|
||||
s2 += euc_codesize(*s2);
|
||||
}
|
||||
}
|
||||
|
||||
void num_type11(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
int i;
|
||||
int j;
|
||||
|
||||
i = j = jrec->numlen;
|
||||
if(!(Chrtbl[*(s1 + j - 4)] & NUMBER)) j -= (j - 1) / 4;
|
||||
|
||||
for(; i > 0; i--) {
|
||||
if(Chrtbl[*s1++] & NUMBER) {
|
||||
*kanjitmp++ = *s2++;
|
||||
*kanjitmp++ = *s2++;
|
||||
if(--j > 0) {
|
||||
if((j % 3) == 0) {
|
||||
*kanjitmp++ = COMMAHIGH;
|
||||
*kanjitmp++ = COMMALOW;
|
||||
}
|
||||
}
|
||||
} else
|
||||
s2 += euc_codesize(*s2);
|
||||
}
|
||||
}
|
||||
|
||||
void num_type12(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
int i;
|
||||
int j;
|
||||
|
||||
for(i = jrec->numlen; i > 0; i--) {
|
||||
if(Chrtbl[j = *s1++] & NUMBER) {
|
||||
j = (j - N_0) * 2;
|
||||
*kanjitmp++ = Num2tbl[j];
|
||||
*kanjitmp++ = Num2tbl[j + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
num_kurai(SJ4_CONTEXT u_char* p, int len, u_char* tbl) {
|
||||
int i;
|
||||
int j;
|
||||
u_char tmp;
|
||||
|
||||
for(i = 0; i < len; i++) {
|
||||
tmp = *p++;
|
||||
|
||||
*kanjitmp++ = tbl[j = ((tmp & 0x0f) - _NUM0) * 2];
|
||||
*kanjitmp++ = tbl[j + 1];
|
||||
if((j = ((tmp >> 4) & 3))) {
|
||||
*kanjitmp++ = Num4tbl[j = (3 - j) * 2];
|
||||
*kanjitmp++ = Num4tbl[j + 1];
|
||||
}
|
||||
if((j = ((tmp >> 6) & 3))) {
|
||||
*kanjitmp++ = Num6tbl[j = (3 - j) * 2];
|
||||
*kanjitmp++ = Num6tbl[j + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void num_type13(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
u_char num[NUMKETALENGTH];
|
||||
int len;
|
||||
|
||||
len = setucnum(SJ4_CONTEXT_PASS s1, (int)jrec->numlen, num);
|
||||
|
||||
num_kurai(SJ4_CONTEXT_PASS num, len, Num1tbl);
|
||||
}
|
||||
|
||||
void num_type14(SJ4_CONTEXT u_char* s1, u_char* s2, JREC* jrec) {
|
||||
u_char num[NUMKETALENGTH];
|
||||
int len;
|
||||
|
||||
len = setucnum(SJ4_CONTEXT_PASS s1, (int)jrec->numlen, num);
|
||||
|
||||
num_kurai(SJ4_CONTEXT_PASS num, len, Num2tbl);
|
||||
}
|
||||
43
lib/sj4core/mvmemd.c
Normal file
43
lib/sj4core/mvmemd.c
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: mvmemd.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:05 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
void mvmemd(u_char* src, u_char* dest, int len) {
|
||||
while(len-- > 0) *(--dest) = *(--src);
|
||||
}
|
||||
43
lib/sj4core/mvmemi.c
Normal file
43
lib/sj4core/mvmemi.c
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: mvmemi.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:06 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
void mvmemi(u_char* src, u_char* dest, int len) {
|
||||
while(len-- > 0) *dest++ = *src++;
|
||||
}
|
||||
363
lib/sj4core/peepdic.c
Normal file
363
lib/sj4core/peepdic.c
Normal file
|
|
@ -0,0 +1,363 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: peepdic.c,v $
|
||||
* $SonyRevision: 1.2 $
|
||||
* $SonyDate: 1995/07/21 05:22:51 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_yomi.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static int prev_kanji(SJ4_CONTEXT2), prev_hinsi(SJ4_CONTEXT2), prev_douon(SJ4_CONTEXT2);
|
||||
static int next_kanji(SJ4_CONTEXT2), next_hinsi(SJ4_CONTEXT2), next_douon(SJ4_CONTEXT2);
|
||||
static void set_kanji(SJ4_CONTEXT2), set_buf(SJ4_CONTEXT u_char*), add_yomi(SJ4_CONTEXT2);
|
||||
static void set_idxyomi(SJ4_CONTEXT2);
|
||||
|
||||
static void cd2sjh_chr(u_char ch, u_char* dst);
|
||||
|
||||
int getusr(SJ4_CONTEXT u_char* buf) {
|
||||
int nlen;
|
||||
|
||||
peepyomi[0] = peepknj[0] = peepgrm = 0;
|
||||
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, peepidx = DICSEGBASE);
|
||||
get_askknj(SJ4_CONTEXT_PASS2);
|
||||
|
||||
peepdptr = segtop();
|
||||
|
||||
if(segend(peepdptr)) return 0;
|
||||
|
||||
add_yomi(SJ4_CONTEXT_PASS2);
|
||||
|
||||
nlen = getnlen(peepdptr);
|
||||
peephptr = peepdptr + DOUONBLKSIZENUMBER + nlen;
|
||||
|
||||
peepgrm = *peephptr;
|
||||
|
||||
peepkptr = peephptr + 1;
|
||||
|
||||
set_kanji(SJ4_CONTEXT_PASS2);
|
||||
|
||||
set_buf(SJ4_CONTEXT_PASS buf);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int nextusr(SJ4_CONTEXT u_char* buf) {
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, peepidx);
|
||||
get_askknj(SJ4_CONTEXT_PASS2);
|
||||
|
||||
if(next_kanji(SJ4_CONTEXT_PASS2)) {
|
||||
set_kanji(SJ4_CONTEXT_PASS2);
|
||||
|
||||
set_buf(SJ4_CONTEXT_PASS buf);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int prevusr(SJ4_CONTEXT u_char* buf) {
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, peepidx);
|
||||
get_askknj(SJ4_CONTEXT_PASS2);
|
||||
|
||||
if(prev_kanji(SJ4_CONTEXT_PASS2)) {
|
||||
set_kanji(SJ4_CONTEXT_PASS2);
|
||||
|
||||
set_buf(SJ4_CONTEXT_PASS buf);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
set_kanji(SJ4_CONTEXT2) {
|
||||
int len;
|
||||
|
||||
len = getkanji(SJ4_CONTEXT_PASS peepyomi, getnlen(peepdptr) + getplen(peepdptr),
|
||||
peepkptr, peepknj);
|
||||
*(peepknj + len) = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
set_buf(SJ4_CONTEXT u_char* buf) {
|
||||
u_char* p;
|
||||
int i, csize;
|
||||
|
||||
for(p = peepyomi; *p;) *buf++ = *p++;
|
||||
*buf++ = 0;
|
||||
|
||||
for(p = peepknj; *p;) {
|
||||
csize = euc_codesize(*p);
|
||||
for(i = 0; i < csize; i++) *buf++ = *p++;
|
||||
}
|
||||
*buf++ = 0;
|
||||
|
||||
*buf++ = peepgrm;
|
||||
*buf++ = 0;
|
||||
}
|
||||
|
||||
static int
|
||||
prev_kanji(SJ4_CONTEXT2) {
|
||||
u_char* p1;
|
||||
u_char* p2;
|
||||
|
||||
p1 = peephptr + 1;
|
||||
if(peepkptr <= p1) return prev_hinsi(SJ4_CONTEXT_PASS2);
|
||||
|
||||
p2 = peepkptr;
|
||||
while(p1 < p2) {
|
||||
peepkptr = p1;
|
||||
p1 = skipkstr(p1);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
prev_hinsi(SJ4_CONTEXT2) {
|
||||
u_char* p1;
|
||||
u_char* p2;
|
||||
int nlen;
|
||||
|
||||
nlen = getnlen(peepdptr);
|
||||
p1 = peepdptr + DOUONBLKSIZENUMBER + nlen;
|
||||
|
||||
if(peephptr <= p1) return prev_douon(SJ4_CONTEXT_PASS2);
|
||||
|
||||
p2 = peephptr;
|
||||
while(p1 < p2) {
|
||||
peephptr = p1;
|
||||
p1 = skiphblk(p1);
|
||||
}
|
||||
|
||||
peepgrm = *peephptr;
|
||||
|
||||
p1 = peephptr + 1;
|
||||
while(*p1 != HINSIBLKTERM) {
|
||||
peepkptr = p1;
|
||||
|
||||
p1 = skipkstr(p1);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
prev_douon(SJ4_CONTEXT2) {
|
||||
u_char* p1;
|
||||
u_char* p2;
|
||||
int nlen;
|
||||
|
||||
if(peepdptr <= segtop()) {
|
||||
if(peepidx <= DICSEGBASE) return 0;
|
||||
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, --peepidx);
|
||||
get_askknj(SJ4_CONTEXT_PASS2);
|
||||
|
||||
set_idxyomi(SJ4_CONTEXT_PASS2);
|
||||
|
||||
p1 = segtop();
|
||||
do {
|
||||
peepdptr = p1;
|
||||
|
||||
add_yomi(SJ4_CONTEXT_PASS2);
|
||||
|
||||
p1 = getntag(p1);
|
||||
} while(!segend(p1));
|
||||
} else {
|
||||
set_idxyomi(SJ4_CONTEXT_PASS2);
|
||||
|
||||
p1 = segtop();
|
||||
p2 = peepdptr;
|
||||
do {
|
||||
peepdptr = p1;
|
||||
|
||||
add_yomi(SJ4_CONTEXT_PASS2);
|
||||
|
||||
p1 = getntag(p1);
|
||||
} while(p1 < p2);
|
||||
}
|
||||
|
||||
nlen = getnlen(peepdptr);
|
||||
p1 = peepdptr + DOUONBLKSIZENUMBER + nlen;
|
||||
|
||||
p2 = getntag(peepdptr);
|
||||
do {
|
||||
peephptr = p1;
|
||||
p1 = skiphblk(p1);
|
||||
} while(p1 < p2);
|
||||
|
||||
peepgrm = *peephptr;
|
||||
|
||||
p1 = peephptr + 1;
|
||||
do {
|
||||
peepkptr = p1;
|
||||
|
||||
p1 = skipkstr(p1);
|
||||
} while(*p1 != HINSIBLKTERM);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
next_kanji(SJ4_CONTEXT2) {
|
||||
u_char* p1;
|
||||
|
||||
p1 = skipkstr(peepkptr);
|
||||
|
||||
if(*p1 == HINSIBLKTERM) return next_hinsi(SJ4_CONTEXT_PASS2);
|
||||
|
||||
peepkptr = p1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
next_hinsi(SJ4_CONTEXT2) {
|
||||
u_char* p1;
|
||||
|
||||
p1 = skiphblk(peephptr);
|
||||
|
||||
if(p1 >= getntag(peepdptr)) return next_douon(SJ4_CONTEXT_PASS2);
|
||||
|
||||
peephptr = p1;
|
||||
|
||||
peepgrm = *p1;
|
||||
|
||||
peepkptr = p1 + 1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
next_douon(SJ4_CONTEXT2) {
|
||||
u_char* p1;
|
||||
int nlen;
|
||||
|
||||
p1 = getntag(peepdptr);
|
||||
|
||||
if(segend(p1)) {
|
||||
if(peepidx + 1 < curdict->segunit) {
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, ++peepidx);
|
||||
get_askknj(SJ4_CONTEXT_PASS2);
|
||||
peepdptr = segtop();
|
||||
|
||||
set_idxyomi(SJ4_CONTEXT_PASS2);
|
||||
} else
|
||||
return 0;
|
||||
} else {
|
||||
peepdptr = p1;
|
||||
}
|
||||
|
||||
add_yomi(SJ4_CONTEXT_PASS2);
|
||||
|
||||
nlen = getnlen(peepdptr);
|
||||
peephptr = peepdptr + DOUONBLKSIZENUMBER + nlen;
|
||||
|
||||
peepgrm = *peephptr;
|
||||
|
||||
peepkptr = peephptr + 1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
set_idxyomi(SJ4_CONTEXT2) {
|
||||
u_char *p1, *p2;
|
||||
|
||||
if((p2 = get_idxptr(SJ4_CONTEXT_PASS peepidx))) {
|
||||
p1 = peepyomi;
|
||||
while(*p2) {
|
||||
cd2sjh_chr(*p2++, p1);
|
||||
p1 += 2;
|
||||
}
|
||||
*p1 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_yomi(SJ4_CONTEXT2) {
|
||||
int nlen;
|
||||
u_char *p1, *p2;
|
||||
|
||||
nlen = getnlen(peepdptr);
|
||||
|
||||
p1 = peepyomi + getplen(peepdptr) * 2;
|
||||
|
||||
p2 = peepdptr + DOUONBLKSIZENUMBER;
|
||||
|
||||
while(nlen--) {
|
||||
cd2sjh_chr(*p2++, p1);
|
||||
p1 += 2;
|
||||
}
|
||||
|
||||
*p1 = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
cd2sjh_chr(u_char ch, u_char* dst) {
|
||||
if(ch == _TYOUON) {
|
||||
*dst++ = 0xa1;
|
||||
*dst++ = 0xbc;
|
||||
} else if(ch == _IGETA) {
|
||||
*dst++ = 0xa1;
|
||||
*dst++ = 0xf4;
|
||||
} else if(ch == _ATTO) {
|
||||
*dst++ = 0xa1;
|
||||
*dst++ = 0xf7;
|
||||
} else if(ch == _YUUBIN) {
|
||||
*dst++ = 0xa2;
|
||||
*dst++ = 0xa9;
|
||||
} else if(ch < N_0) {
|
||||
} else if(ch <= N_9) {
|
||||
*dst++ = 0xa3;
|
||||
*dst++ = ch + 0xa0;
|
||||
} else if(ch <= A_Z) {
|
||||
*dst++ = 0xa3;
|
||||
*dst++ = ch + 0xa7;
|
||||
} else if(ch <= A_z) {
|
||||
*dst++ = 0xa3;
|
||||
*dst++ = ch + 0xad;
|
||||
} else if(ch <= _NN) {
|
||||
*dst++ = 0xa4;
|
||||
*dst++ = ch + 0x53;
|
||||
} else if(ch <= _XKE) {
|
||||
*dst++ = 0xa5;
|
||||
*dst++ = ch + 0x53;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
108
lib/sj4core/ph2knj.c
Normal file
108
lib/sj4core/ph2knj.c
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: ph2knj.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:09 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_yomi.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
int ph2knj(SJ4_CONTEXT u_char* zyomi, u_char* kanji, int knjlen) {
|
||||
u_char* ptr;
|
||||
u_char* dst;
|
||||
int i;
|
||||
|
||||
for(ptr = zyomi, dst = hyomi, i = 0; *ptr;) {
|
||||
if(i++ >= MAXPHINPUTLEN) {
|
||||
*kanji = 0;
|
||||
return 0;
|
||||
}
|
||||
ptr += sj2cd_chr(ptr, dst++);
|
||||
}
|
||||
*dst = 0;
|
||||
|
||||
freework(SJ4_CONTEXT_PASS2);
|
||||
prevclgrm = 0;
|
||||
prevclrow = 0;
|
||||
|
||||
khcount = 0;
|
||||
nextcllen = 0;
|
||||
|
||||
inputyomi = zyomi;
|
||||
cnvstart = ystart = hyomi;
|
||||
cnvlen = sstrlen(hyomi);
|
||||
|
||||
kanjipos = kanji;
|
||||
kanjilen = knjlen;
|
||||
|
||||
while(cnvlen && kanjilen) {
|
||||
if(!clt1st) {
|
||||
mkjiritu(SJ4_CONTEXT_PASS DO_CLSTUDY | DO_IKKATU);
|
||||
|
||||
mkbunsetu(SJ4_CONTEXT_PASS2);
|
||||
|
||||
if(!maxclptr) wakachi(SJ4_CONTEXT_PASS2);
|
||||
|
||||
jrt1st = maxjptr;
|
||||
clt1st = maxclptr;
|
||||
}
|
||||
|
||||
mk2claus(SJ4_CONTEXT_PASS2);
|
||||
|
||||
selclrec(SJ4_CONTEXT_PASS2);
|
||||
|
||||
prevclgrm = selcl->jnode->hinsi;
|
||||
prevclrow = selcl->right;
|
||||
|
||||
clt1st = free_clst(SJ4_CONTEXT_PASS clt1st, (int)selcl->cllen);
|
||||
jrt1st = free_jlst(SJ4_CONTEXT_PASS jrt1st);
|
||||
|
||||
cnvstart += selcl->cllen;
|
||||
cnvlen -= selcl->cllen;
|
||||
|
||||
cvtphknj(SJ4_CONTEXT_PASS2);
|
||||
|
||||
clt1st = clt2nd;
|
||||
jrt1st = jrt2nd;
|
||||
}
|
||||
|
||||
if(!kanjilen) {
|
||||
free_clall(SJ4_CONTEXT_PASS clt1st);
|
||||
free_jall(SJ4_CONTEXT_PASS jrt1st);
|
||||
}
|
||||
|
||||
*kanjipos = 0;
|
||||
|
||||
return (inputyomi - zyomi);
|
||||
}
|
||||
114
lib/sj4core/ph_khtbl.c
Normal file
114
lib/sj4core/ph_khtbl.c
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: ph_khtbl.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:09 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static void
|
||||
ph_setsty(SJ4_CONTEXT CLREC* clrec) {
|
||||
JREC* jrec;
|
||||
TypeDicOfs offset;
|
||||
u_char* ptr;
|
||||
STDYIN* sptr;
|
||||
|
||||
if(!seldict(SJ4_CONTEXT_PASS(jrec = clrec->jnode)->dicid)) {
|
||||
if(!khcount)
|
||||
ph_setkouho(SJ4_CONTEXT_PASS clrec, (TypeDicOfs)1, (STDYIN*)NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, jrec->jseg);
|
||||
ptr = dicbuf + jrec->jofsst + 1;
|
||||
|
||||
for(; *ptr != HINSIBLKTERM; ptr = skipkstr(ptr)) {
|
||||
|
||||
offset = ptr - dicbuf;
|
||||
|
||||
sptr = srchstdy(SJ4_CONTEXT_PASS jrec->jseg, offset, jrec->dicid);
|
||||
|
||||
if(!khcount) {
|
||||
ph_setkouho(SJ4_CONTEXT_PASS clrec, offset, sptr);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!sptr) continue;
|
||||
|
||||
if(sptr->styno < kouhotbl[0].styno) {
|
||||
ph_setkouho(SJ4_CONTEXT_PASS clrec, offset, sptr);
|
||||
}
|
||||
|
||||
else if(sptr->styno == kouhotbl->styno) {
|
||||
if(!(kouhotbl[0].ka_fg &&
|
||||
sptr->ka_kj == kouhotbl[0].ka_kj)) {
|
||||
ph_setkouho(SJ4_CONTEXT_PASS clrec, offset, sptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ph_khtbl(SJ4_CONTEXT CLREC* clrec) {
|
||||
JREC* jrec;
|
||||
int flg = FALSE;
|
||||
|
||||
switch((jrec = clrec->jnode)->class) {
|
||||
case C_DICT:
|
||||
ph_setsty(SJ4_CONTEXT_PASS clrec);
|
||||
break;
|
||||
|
||||
case C_N_ARABIA:
|
||||
case C_N_ARACMA:
|
||||
case C_N_KAZU:
|
||||
case C_N_SUUJI:
|
||||
case C_N_NANSUU:
|
||||
case C_N_KANKURA:
|
||||
case C_N_ARAKURA:
|
||||
case C_N_KAZULONG:
|
||||
case C_N_KAZULCMA:
|
||||
case C_N_SUUJILONG:
|
||||
if(jrec->jofsst) {
|
||||
ph_setsty(SJ4_CONTEXT_PASS clrec);
|
||||
break;
|
||||
} else
|
||||
flg = TRUE;
|
||||
case C_BUNSETU:
|
||||
case C_MINASI:
|
||||
case C_WAKACHI:
|
||||
if(!khcount) ph_setkouho(SJ4_CONTEXT_PASS clrec, (TypeDicOfs)0, (STDYIN*)0);
|
||||
break;
|
||||
}
|
||||
|
||||
return flg;
|
||||
}
|
||||
271
lib/sj4core/priority.c
Normal file
271
lib/sj4core/priority.c
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: priority.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:10 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_hinsi.h"
|
||||
#include "sj_right.h"
|
||||
#include "sj_prty.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static int
|
||||
isfukusi(TypeGram hinsi) {
|
||||
if(FUKUSI_1 <= hinsi && hinsi <= FUKUSI_7)
|
||||
return TRUE;
|
||||
else if(hinsi == MEISI_11 || hinsi == D_MEISI_6)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
istaigen(TypeCnct right) {
|
||||
if(right == R_MEISI || right == R_DMEISI || right == R_SMEISI1)
|
||||
return TRUE;
|
||||
if(right == R_WO_MEISI || right == R_DAIMEISI || right == R_JOSUUSI)
|
||||
return TRUE;
|
||||
if(right == R_RENYOU1 || (R_RENYOU3 <= right && right <= R_SA5RENYOU4))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
taicnt(TypeGram hinsi1, TypeGram hinsi2) {
|
||||
if(hinsi2 == TANKANJI) return 0;
|
||||
|
||||
if(MYOUJI <= hinsi1 && hinsi1 <= KEN_KU) {
|
||||
if(MEISI_1 <= hinsi2 && hinsi2 <= SETUBI_9)
|
||||
return Taipri(hinsi1 - MYOUJI, hinsi2);
|
||||
else
|
||||
return 3;
|
||||
} else if((MEISI_1 <= hinsi1 && hinsi1 <= MEISI_11) ||
|
||||
hinsi1 == D_MEISI_2) {
|
||||
if(MEISI_1 <= hinsi2 && hinsi2 <= SETUBI_9) {
|
||||
return Taipri(5, hinsi2);
|
||||
} else
|
||||
return 5;
|
||||
}
|
||||
|
||||
else {
|
||||
if(MEISI_1 <= hinsi2 && hinsi2 <= SETUBI_9)
|
||||
return Taipri(6, hinsi2);
|
||||
else
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
sttcnt(TypeGram hinsi1, TypeGram hinsi2) {
|
||||
if(SETTOU_1 <= hinsi1 && hinsi1 <= SETTOU_5) {
|
||||
if(MEISI_1 <= hinsi2 && hinsi2 <= SUUSI)
|
||||
return Sttpri(hinsi1 - SETTOU_1, hinsi2);
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
int priority(SJ4_CONTEXT CLREC* clrec) {
|
||||
int prty;
|
||||
CLREC* cl2rec;
|
||||
int keeplen;
|
||||
TypeGram hinsi1;
|
||||
int i;
|
||||
int prev = 0;
|
||||
|
||||
if(clrec->cllen == clrec->cl2len) return 0xff;
|
||||
|
||||
if(clrec->jnode->class == C_BUNSETU) {
|
||||
prty = Termtbl[clrec->right] & GETPRI;
|
||||
return (0xf0 + prty);
|
||||
}
|
||||
|
||||
hinsi1 = clrec->jnode->hinsi;
|
||||
|
||||
if(prevclrow == R_WO || prevclrow == R_WO_S ||
|
||||
prevclrow == R_NI1 || prevclrow == R_DRENYOU2) {
|
||||
if(clrec->kubun == K_DOUSHI || isfukusi(hinsi1))
|
||||
prev = 5;
|
||||
}
|
||||
|
||||
else if(istaigen(prevclrow)) {
|
||||
|
||||
if(clrec->kubun == K_TAIGEN)
|
||||
prev = taicnt(prevclgrm, hinsi1);
|
||||
|
||||
else
|
||||
prev = 0;
|
||||
}
|
||||
|
||||
else if(prevclrow == R_SETTOU) {
|
||||
if(clrec->jnode->sttofs)
|
||||
prty = 2;
|
||||
else
|
||||
prty = sttcnt(prevclgrm, hinsi1);
|
||||
}
|
||||
|
||||
if(hinsi1 >= SETUBI_1 && hinsi1 <= SETUBI_9 && (!prev)) {
|
||||
prty = 1;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
cl2rec = maxclptr;
|
||||
keeplen = cl2rec->cllen;
|
||||
|
||||
if(clrec->right == R_WO || clrec->right == R_WO_S ||
|
||||
clrec->right == R_NI1 || clrec->right == R_DRENYOU2) {
|
||||
while(cl2rec && (int)cl2rec->cllen == keeplen) {
|
||||
if(cl2rec->kubun == K_DOUSHI) {
|
||||
prty = 14;
|
||||
goto finish;
|
||||
}
|
||||
cl2rec = cl2rec->clsort;
|
||||
}
|
||||
}
|
||||
|
||||
else if(clrec->right == R_SETTOU) {
|
||||
prty = 0;
|
||||
while(cl2rec && (int)cl2rec->cllen == keeplen) {
|
||||
if(cl2rec->jnode->sttofs)
|
||||
i = 2;
|
||||
else
|
||||
i = sttcnt(hinsi1, cl2rec->jnode->hinsi);
|
||||
|
||||
if(i > prty)
|
||||
prty = i;
|
||||
cl2rec = cl2rec->clsort;
|
||||
}
|
||||
goto finish;
|
||||
}
|
||||
|
||||
else if(istaigen(clrec->right)) {
|
||||
prty = 0;
|
||||
while(cl2rec && (int)cl2rec->cllen == keeplen) {
|
||||
i = taicnt(hinsi1, cl2rec->jnode->hinsi);
|
||||
if(i > prty)
|
||||
prty = i;
|
||||
cl2rec = cl2rec->clsort;
|
||||
}
|
||||
if(clrec->jnode->stbofs) {
|
||||
prty -= 3;
|
||||
}
|
||||
goto finish;
|
||||
}
|
||||
|
||||
prty = Termtbl[clrec->right];
|
||||
|
||||
if(prty & RENTAI) {
|
||||
while(cl2rec && (int)cl2rec->cllen == keeplen) {
|
||||
if(cl2rec->kubun == K_TAIGEN) {
|
||||
prty &= GETPRI;
|
||||
goto finish;
|
||||
}
|
||||
cl2rec = cl2rec->clsort;
|
||||
}
|
||||
prty = 4;
|
||||
}
|
||||
|
||||
else {
|
||||
prty &= GETPRI;
|
||||
|
||||
if(prty == P_RENYOU_J || prty == P_RENYOU_M) {
|
||||
while(clrec->cllen != 1 && cl2rec &&
|
||||
(int)cl2rec->cllen == keeplen) {
|
||||
if(cl2rec->kubun == K_DOUSHI) {
|
||||
prty = 6;
|
||||
goto finish;
|
||||
} else if(cl2rec->jnode->hinsi == SETUBI_1 ||
|
||||
cl2rec->jnode->hinsi == SETUBI_2) {
|
||||
prty = 7;
|
||||
goto finish;
|
||||
}
|
||||
cl2rec = cl2rec->clsort;
|
||||
}
|
||||
prty = 4;
|
||||
}
|
||||
}
|
||||
|
||||
finish:
|
||||
cl2rec = maxclptr;
|
||||
|
||||
if(hinsi1 == SUUSI) prty -= 4;
|
||||
|
||||
if(cl2rec->jnode->hinsi == SUUSI) prty -= 3;
|
||||
|
||||
if(cl2rec->jnode->class == C_DICT &&
|
||||
cl2rec->jnode->jlen == 1 && (cl2rec->kubun != K_DOUSHI)) {
|
||||
prty -= 2;
|
||||
}
|
||||
|
||||
if((!istaigen(clrec->right)) && (cl2rec->jnode->hinsi == SETUBI_2)) {
|
||||
prty -= 4;
|
||||
}
|
||||
|
||||
prty += 20 - clrec->cllen + clrec->jnode->jlen + clrec->gobiln;
|
||||
return (prty + prev);
|
||||
}
|
||||
|
||||
void pritiny(SJ4_CONTEXT2) {
|
||||
CLREC* clrec;
|
||||
int keeplen;
|
||||
int i, prty = 0;
|
||||
|
||||
clrec = selcl;
|
||||
keeplen = clrec->cllen;
|
||||
|
||||
if(istaigen(prevclrow)) {
|
||||
while(clrec && (int)clrec->cllen == keeplen) {
|
||||
i = taicnt(prevclgrm, clrec->jnode->hinsi);
|
||||
if(i > prty) {
|
||||
selcl = clrec;
|
||||
prty = i;
|
||||
}
|
||||
clrec = clrec->clsort;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
while(clrec && (int)clrec->cllen == keeplen) {
|
||||
if(clrec->jnode->hinsi >= MYOUJI &&
|
||||
clrec->jnode->hinsi <= KEN_KU)
|
||||
clrec = clrec->clsort;
|
||||
|
||||
else if(clrec->jnode->hinsi == TANKANJI)
|
||||
return;
|
||||
else {
|
||||
selcl = clrec;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
248
lib/sj4core/prtytbl.c
Normal file
248
lib/sj4core/prtytbl.c
Normal file
|
|
@ -0,0 +1,248 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: prtytbl.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:11 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
u_char taipri[7][45] = {
|
||||
|
||||
{0, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 3, 3, 3, 3, 3, 3, 0, 0,
|
||||
0, 3, 20, 4, 3, 3, 4, 4, 4, 4,
|
||||
4, 4, 4, 20, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
|
||||
|
||||
{0, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 3, 3, 3, 3, 3, 3, 0, 0,
|
||||
0, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 20, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
|
||||
|
||||
{0, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 3, 3, 3, 3, 3, 3, 0, 0,
|
||||
0, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6},
|
||||
|
||||
{0, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 3, 3, 3, 3, 3, 3, 0, 0,
|
||||
0, 3, 3, 3, 4, 5, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 4, 4, 4, 4, 6},
|
||||
|
||||
{0, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 4, 4, 4, 4, 4, 4, 0, 0,
|
||||
0, 4, 4, 4, 20, 20, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6},
|
||||
|
||||
{0, 8, 8, 8, 8, 8, 7, 8, 8, 8,
|
||||
8, 8, 3, 6, 7, 3, 3, 5, 0, 0,
|
||||
0, 3, 3, 3, 3, 3, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 8, 8, 11, 5, 7, 7, 7, 7, 7},
|
||||
|
||||
{0, 5, 6, 6, 6, 6, 5, 6, 6, 6,
|
||||
6, 6, 3, 3, 3, 3, 3, 5, 0, 0,
|
||||
0, 3, 3, 3, 3, 3, 5, 5, 5, 5,
|
||||
4, 5, 5, 5, 5, 5, 5, 6, 6, 5, 5, 5, 5, 5, 5}};
|
||||
|
||||
u_char sttpri[5][31] = {
|
||||
|
||||
{
|
||||
0,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
2,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
},
|
||||
|
||||
{
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
10,
|
||||
10,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
},
|
||||
|
||||
{
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
10,
|
||||
10,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
},
|
||||
|
||||
{
|
||||
0,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
15,
|
||||
},
|
||||
|
||||
{
|
||||
0,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
}};
|
||||
150
lib/sj4core/s2ctbl.c
Normal file
150
lib/sj4core/s2ctbl.c
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: s2ctbl.c,v $
|
||||
* $SonyRevision: 1.2 $
|
||||
* $SonyDate: 1995/07/21 05:22:51 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
#include "sj_yomi.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
u_char kigou[] = {
|
||||
Y_L_KAKKO,
|
||||
Y_KUTEN,
|
||||
Y_TOUTEN,
|
||||
Y_COMMA,
|
||||
Y_PERIOD,
|
||||
Y_L_KAKKO,
|
||||
Y_L_KAKKO,
|
||||
Y_L_KAKKO,
|
||||
Y_BIKKURI,
|
||||
Y_BIKKURI,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
_TYOUON,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_L_KAKKO,
|
||||
Y_QUOTA,
|
||||
Y_L_KAKKO,
|
||||
Y_QUOTA,
|
||||
Y_L_KAKKO,
|
||||
Y_R_KAKKO,
|
||||
Y_L_KAKKO,
|
||||
Y_R_KAKKO,
|
||||
Y_L_KAKKO,
|
||||
Y_R_KAKKO,
|
||||
Y_L_KAKKO,
|
||||
Y_R_KAKKO,
|
||||
Y_L_KAKKO,
|
||||
Y_R_KAKKO,
|
||||
Y_L_KAKKO,
|
||||
Y_R_KAKKO,
|
||||
Y_L_KAKKO,
|
||||
Y_R_KAKKO,
|
||||
Y_L_KAKKO,
|
||||
Y_R_KAKKO,
|
||||
Y_L_KAKKO,
|
||||
Y_R_KAKKO,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_S_KIGOU2,
|
||||
Y_S_KIGOU1,
|
||||
Y_S_KIGOU1,
|
||||
Y_S_KIGOU2,
|
||||
Y_S_KIGOU1,
|
||||
Y_S_KIGOU2,
|
||||
_IGETA,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
_ATTO,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
_YUUBIN,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU,
|
||||
Y_KIGOU};
|
||||
756
lib/sj4core/sdepend.c
Normal file
756
lib/sj4core/sdepend.c
Normal file
|
|
@ -0,0 +1,756 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: depend.c,v $
|
||||
* $SonyRevision: 1.4 $
|
||||
* $SonyDate: 1997/10/07 07:39:45 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
#include "Dict.h"
|
||||
#include "sj4err.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
#if defined(__FD_SET) && !defined(FD_SET)
|
||||
#define FD_SET __FD_SET
|
||||
#define FD_CLR __FD_CLR
|
||||
#endif
|
||||
|
||||
#ifndef L_SET
|
||||
#define L_SET SEEK_SET
|
||||
#endif
|
||||
|
||||
#ifndef L_CUR
|
||||
#define L_CUR SEEK_CUR
|
||||
#endif
|
||||
|
||||
#ifndef L_END
|
||||
#define L_END SEEK_END
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define ftruncate chsize
|
||||
#endif
|
||||
|
||||
DictFile* dictlink = NULL;
|
||||
StdyFile* stdylink = NULL;
|
||||
|
||||
static long
|
||||
get4byte(u_char* p) {
|
||||
long i;
|
||||
|
||||
i = *p;
|
||||
i = (i << 8) + *++p;
|
||||
i = (i << 8) + *++p;
|
||||
return ((i << 8) + *++p);
|
||||
}
|
||||
static void
|
||||
Put4byte(u_char* p, long n) {
|
||||
p += 3;
|
||||
*p-- = n;
|
||||
n >>= 8;
|
||||
*p-- = n;
|
||||
n >>= 8;
|
||||
*p-- = n;
|
||||
n >>= 8;
|
||||
*p = n;
|
||||
}
|
||||
#define put4byte(p, n) Put4byte((p), (long)(n))
|
||||
|
||||
static int
|
||||
fgetfile(FILE* fp, long pos, long len, u_char* p) {
|
||||
if(fseek(fp, pos, 0) == ERROR) {
|
||||
serv_errno = SJ4_FileSeekError;
|
||||
return ERROR;
|
||||
}
|
||||
if(fread(p, len, 1, fp) != 1) {
|
||||
serv_errno = SJ4_FileReadError;
|
||||
return ERROR;
|
||||
}
|
||||
return SJ4_NormalEnd;
|
||||
}
|
||||
static int
|
||||
fputfile(FILE* fp, long pos, int len, u_char* p) {
|
||||
if(fseek(fp, pos, 0) == ERROR) {
|
||||
serv_errno = SJ4_FileSeekError;
|
||||
return ERROR;
|
||||
}
|
||||
if(fwrite(p, len, 1, fp) != 1) {
|
||||
serv_errno = SJ4_FileWriteError;
|
||||
return ERROR;
|
||||
}
|
||||
return SJ4_NormalEnd;
|
||||
}
|
||||
static int
|
||||
getfile(int fd, int pos, int len, u_char* p) {
|
||||
if(lseek(fd, pos, L_SET) == ERROR) {
|
||||
serv_errno = SJ4_FileSeekError;
|
||||
return ERROR;
|
||||
}
|
||||
if(read(fd, p, len) != len) {
|
||||
serv_errno = SJ4_FileReadError;
|
||||
return ERROR;
|
||||
}
|
||||
return SJ4_NormalEnd;
|
||||
}
|
||||
static int
|
||||
putfile(int fd, int pos, int len, u_char* p) {
|
||||
if(lseek(fd, pos, L_SET) == ERROR) {
|
||||
serv_errno = SJ4_FileSeekError;
|
||||
return ERROR;
|
||||
}
|
||||
if(write(fd, p, len) != len) {
|
||||
serv_errno = SJ4_FileWriteError;
|
||||
return ERROR;
|
||||
}
|
||||
return SJ4_NormalEnd;
|
||||
}
|
||||
|
||||
static int
|
||||
check_passwd(u_char* buf, char* passwd) {
|
||||
buf += PASSWDPOS;
|
||||
return (*buf && strncmp(passwd, (char*)buf, PASSWDLEN)) ? FALSE : TRUE;
|
||||
}
|
||||
static void
|
||||
set_passwd(u_char* buf, char* passwd) {
|
||||
strncpy((char*)buf + PASSWDPOS, passwd, PASSWDLEN);
|
||||
}
|
||||
|
||||
static int
|
||||
check_dictfile(u_char* buf) {
|
||||
return (DICTVERSION != get4byte(buf + VERSIONPOS)) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
static DictFile*
|
||||
search_same_dict(ino_t ino) {
|
||||
DictFile* p;
|
||||
|
||||
for(p = dictlink; p != NULL; p = p->link)
|
||||
if(p->dict.dicid == ino) return p;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
getofs(SJ4_CONTEXT DictFile* dp) {
|
||||
idxofs = dp->ofsptr;
|
||||
return 0;
|
||||
}
|
||||
static int
|
||||
getidx(SJ4_CONTEXT DictFile* dp) {
|
||||
idxbuf = dp->buffer + dp->idxstrt;
|
||||
return 0;
|
||||
}
|
||||
/* XXX: not IFunc */
|
||||
static int
|
||||
getdic(SJ4_CONTEXT DictFile* dp, TypeDicSeg seg) {
|
||||
if(seg >= dp->dict.segunit) return -1;
|
||||
dicbuf = dp->buffer + dp->segstrt + dp->dict.seglen * seg;
|
||||
return 0;
|
||||
}
|
||||
static int
|
||||
putidx(SJ4_CONTEXT DictFile* dp) {
|
||||
return putfile(dp->fd, dp->idxstrt, dp->dict.idxlen, idxbuf);
|
||||
}
|
||||
/* XXX: not IFunc */
|
||||
static int
|
||||
putdic(SJ4_CONTEXT DictFile* dp, TypeDicSeg seg) {
|
||||
u_char* p;
|
||||
long i, j;
|
||||
|
||||
if(seg >= dp->dict.maxunit) return -1;
|
||||
i = dp->segstrt + dp->dict.seglen * (seg + 1);
|
||||
if(i > dp->bufsiz) {
|
||||
if(!(p = (u_char*)malloc(i))) return -1;
|
||||
memcpy(p, dp->buffer, dp->bufsiz);
|
||||
|
||||
if(idxbuf - dp->buffer == dp->idxstrt)
|
||||
idxbuf = p + dp->idxstrt;
|
||||
if((dicbuf >= dp->buffer) &&
|
||||
((j = dicbuf - dp->buffer) < dp->bufsiz))
|
||||
dicbuf = p + j;
|
||||
|
||||
free((char*)(dp->buffer));
|
||||
dp->buffer = p;
|
||||
dp->bufsiz = i;
|
||||
}
|
||||
|
||||
i = dp->segstrt + dp->dict.seglen * seg;
|
||||
if((p = dp->buffer + i) != dicbuf) memcpy(p, dicbuf, dp->dict.seglen);
|
||||
|
||||
return putfile(dp->fd, i, dp->dict.seglen, p);
|
||||
}
|
||||
/* XXX: not IFunc */
|
||||
static int
|
||||
rszdic(SJ4_CONTEXT DictFile* dp, TypeDicSeg seg) {
|
||||
long i;
|
||||
u_char* p;
|
||||
|
||||
i = dp->segstrt + dp->dict.seglen * seg;
|
||||
if(dp->bufsiz != i) {
|
||||
if(!(p = (u_char*)malloc(i))) return -1;
|
||||
memcpy(p, dp->buffer, ((i > dp->bufsiz) ? dp->bufsiz : i));
|
||||
|
||||
if(idxbuf - dp->buffer == dp->idxstrt)
|
||||
idxbuf = p + dp->idxstrt;
|
||||
if((dicbuf >= dp->buffer) &&
|
||||
((i = dicbuf - dp->buffer) < dp->bufsiz))
|
||||
dicbuf = p + i;
|
||||
|
||||
free((char*)(dp->buffer));
|
||||
dp->buffer = p;
|
||||
dp->bufsiz = i;
|
||||
if(ftruncate(dp->fd, i) == -1) return -1;
|
||||
}
|
||||
put4byte(dp->buffer + DICTSEGNUM, seg);
|
||||
return putfile(dp->fd, 0, HEADERLENGTH, dp->buffer);
|
||||
}
|
||||
|
||||
DictFile*
|
||||
opendict(SJ4_CONTEXT char* name, char* passwd) {
|
||||
FILE* fp;
|
||||
struct stat sbuf;
|
||||
DictFile* dfp;
|
||||
u_char tmp[HEADERLENGTH];
|
||||
int i;
|
||||
u_char* dp;
|
||||
|
||||
if(stat(name, &sbuf) == ERROR) {
|
||||
if(errno == ENOENT)
|
||||
serv_errno = SJ4_FileNotExist;
|
||||
else
|
||||
serv_errno = SJ4_CannotAccessFile;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if((dfp = search_same_dict(sbuf.st_ino)) != NULL) {
|
||||
dfp->refcnt++;
|
||||
return dfp;
|
||||
}
|
||||
|
||||
if((fp = fopen(name, "r+b")) == NULL) {
|
||||
if((fp = fopen(name, "rb")) == NULL) {
|
||||
serv_errno = SJ4_CannotOpenFile;
|
||||
return NULL;
|
||||
}
|
||||
i = FALSE;
|
||||
} else
|
||||
i = TRUE;
|
||||
|
||||
if(fgetfile(fp, 0L, sizeof(tmp), tmp) == ERROR) goto error1;
|
||||
|
||||
if(!check_dictfile(tmp)) {
|
||||
serv_errno = SJ4_IllegalDictFile;
|
||||
goto error1;
|
||||
}
|
||||
|
||||
if(!check_passwd(tmp, passwd)) {
|
||||
serv_errno = SJ4_IncorrectPasswd;
|
||||
goto error1;
|
||||
}
|
||||
|
||||
if((dp = (u_char*)malloc((long)sbuf.st_size)) == NULL) {
|
||||
serv_errno = SJ4_NotEnoughMemory;
|
||||
goto error1;
|
||||
}
|
||||
if((dfp = (DictFile*)malloc(sizeof(*dfp))) == NULL) {
|
||||
serv_errno = SJ4_NotEnoughMemory;
|
||||
goto error2;
|
||||
}
|
||||
memset(dfp, '\0', sizeof(*dfp));
|
||||
|
||||
if(fgetfile(fp, 0L, (long)sbuf.st_size, dp) == ERROR) goto error3;
|
||||
|
||||
dfp->dict.dicid = sbuf.st_ino;
|
||||
dfp->dict.idxlen = get4byte(dp + DICTIDXLEN);
|
||||
dfp->dict.seglen = get4byte(dp + DICTSEGLEN);
|
||||
dfp->dict.segunit = get4byte(dp + DICTSEGNUM);
|
||||
dfp->dict.maxunit = i ? get4byte(dp + DICTSEGMAX) : 0;
|
||||
dfp->dict.getofs = (IFuncDict)getofs;
|
||||
dfp->dict.getidx = (IFuncDict)getidx;
|
||||
dfp->dict.getdic = (IFunc)getdic;
|
||||
dfp->dict.putidx = (IFunc)putidx;
|
||||
dfp->dict.putdic = (IFunc)putdic;
|
||||
dfp->dict.rszdic = (IFunc)rszdic;
|
||||
dfp->refcnt = 1;
|
||||
dfp->fp = fp;
|
||||
dfp->fd = fileno(fp);
|
||||
dfp->buffer = dp;
|
||||
dfp->bufsiz = sbuf.st_size;
|
||||
dfp->idxstrt = get4byte(dp + DICTIDXPOS);
|
||||
dfp->segstrt = get4byte(dp + DICTSEGPOS);
|
||||
|
||||
i = dfp->dict.segunit;
|
||||
if(i < dfp->dict.maxunit) i = dfp->dict.maxunit;
|
||||
i *= sizeof(TypeIdxOfs);
|
||||
if((dfp->ofsptr = (TypeIdxOfs*)malloc(i)) == NULL) {
|
||||
serv_errno = SJ4_NotEnoughMemory;
|
||||
goto error3;
|
||||
}
|
||||
mkidxtbl(SJ4_CONTEXT_PASS & (dfp->dict));
|
||||
|
||||
dfp->link = dictlink;
|
||||
dictlink = dfp;
|
||||
|
||||
return dfp;
|
||||
|
||||
error3:
|
||||
free((char*)dfp);
|
||||
error2:
|
||||
free((char*)dp);
|
||||
error1:
|
||||
fclose(fp);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int closedict(SJ4_CONTEXT DictFile* dfp) {
|
||||
DictFile* df;
|
||||
|
||||
if(--dfp->refcnt > 0) return 0;
|
||||
|
||||
if(dictlink == dfp)
|
||||
dictlink = dfp->link;
|
||||
else {
|
||||
for(df = dictlink; df; df = df->link)
|
||||
if(df->link == dfp) {
|
||||
df->link = dfp->link;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(dfp->fp) fclose(dfp->fp);
|
||||
|
||||
free((char*)(dfp->ofsptr));
|
||||
free((char*)(dfp->buffer));
|
||||
free((char*)dfp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SJ4_LOCK
|
||||
static fd_set zero_fd_set; /* XXX */
|
||||
#endif
|
||||
|
||||
void lock_dict(DictFile* p, int fd) {
|
||||
#ifdef SJ4_LOCK
|
||||
FD_SET(fd, &(p->lock));
|
||||
#endif
|
||||
}
|
||||
|
||||
void unlock_dict(DictFile* p, int fd) {
|
||||
#ifdef SJ4_LOCK
|
||||
FD_CLR(fd, &(p->lock));
|
||||
#endif
|
||||
}
|
||||
|
||||
int is_dict_locked(DictFile* p) {
|
||||
#ifdef SJ4_LOCK
|
||||
return memcmp(&(p->lock), &zero_fd_set, sizeof(zero_fd_set));
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
check_stdyfile(u_char* buf) {
|
||||
return (STDYVERSION != get4byte(buf + VERSIONPOS)) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
static StdyFile*
|
||||
search_same_stdy(ino_t ino) {
|
||||
StdyFile* p;
|
||||
|
||||
for(p = stdylink; p != NULL; p = p->link)
|
||||
if(p->inode == ino) return p;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
StdyFile*
|
||||
openstdy(char* name, char* passwd) {
|
||||
FILE* fp;
|
||||
struct stat sbuf;
|
||||
StdyFile* sfp;
|
||||
u_char* hd;
|
||||
STDYIN* sp;
|
||||
u_short* cip;
|
||||
u_char* clp;
|
||||
long stdycnt, stdypos, stdylen, stdymax;
|
||||
long clidxpos, clidxlen;
|
||||
long clstdypos, clstdylen, clstdystep;
|
||||
long len;
|
||||
|
||||
if(stat(name, &sbuf) == ERROR) {
|
||||
if(errno == ENOENT)
|
||||
serv_errno = SJ4_FileNotExist;
|
||||
else
|
||||
serv_errno = SJ4_CannotAccessFile;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if((sfp = search_same_stdy(sbuf.st_ino)) != NULL) {
|
||||
sfp->refcnt++;
|
||||
return sfp;
|
||||
}
|
||||
|
||||
if((hd = (u_char*)malloc(HEADERLENGTH + COMMENTLENGTH)) == NULL) {
|
||||
serv_errno = SJ4_NotEnoughMemory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if((fp = fopen(name, "r+b")) == NULL) {
|
||||
serv_errno = SJ4_CannotOpenFile;
|
||||
goto error0;
|
||||
}
|
||||
|
||||
if(fgetfile(fp, 0L, HEADERLENGTH + COMMENTLENGTH, hd) == ERROR)
|
||||
goto error1;
|
||||
|
||||
if(!check_stdyfile(hd)) {
|
||||
serv_errno = SJ4_IllegalStdyFile;
|
||||
goto error1;
|
||||
}
|
||||
|
||||
if(!check_passwd(hd, passwd)) {
|
||||
serv_errno = SJ4_IncorrectPasswd;
|
||||
goto error1;
|
||||
}
|
||||
|
||||
stdycnt = get4byte(hd + STDYNORMCNT);
|
||||
stdypos = get4byte(hd + STDYNORMPOS);
|
||||
stdylen = get4byte(hd + STDYNORMLEN);
|
||||
stdymax = get4byte(hd + STDYNORMNUM);
|
||||
clidxpos = get4byte(hd + STDYCLIDXPOS);
|
||||
clidxlen = get4byte(hd + STDYCLIDXLEN);
|
||||
clstdypos = get4byte(hd + STDYCLSEGPOS);
|
||||
clstdylen = get4byte(hd + STDYCLSEGLEN);
|
||||
clstdystep = get4byte(hd + STDYCLIDXSTEP);
|
||||
len = sizeof(STDYIN) * stdymax;
|
||||
|
||||
if((sfp = (StdyFile*)malloc(sizeof(*sfp))) == NULL) {
|
||||
serv_errno = SJ4_NotEnoughMemory;
|
||||
goto error1;
|
||||
}
|
||||
memset(sfp, '\0', sizeof(*sfp));
|
||||
if((sp = (STDYIN*)malloc(len)) == NULL) {
|
||||
serv_errno = SJ4_NotEnoughMemory;
|
||||
goto error2;
|
||||
}
|
||||
if((cip = (u_short*)malloc(clidxlen)) == NULL) {
|
||||
serv_errno = SJ4_NotEnoughMemory;
|
||||
goto error3;
|
||||
}
|
||||
if((clp = (u_char*)malloc(clstdylen)) == NULL) {
|
||||
serv_errno = SJ4_NotEnoughMemory;
|
||||
goto error4;
|
||||
}
|
||||
|
||||
if(fgetfile(fp, clidxpos, clidxlen, (u_char*)cip) == ERROR) goto error5; /* XXX */
|
||||
if(fgetfile(fp, clstdypos, clstdylen, (u_char*)clp) == ERROR) goto error5; /* XXX */
|
||||
if(fgetfile(fp, stdypos, len, (u_char*)sp) == ERROR) stdycnt = 0; /* XXX */
|
||||
|
||||
sfp->stdy.stdycnt = stdycnt;
|
||||
sfp->stdy.stdymax = stdymax;
|
||||
sfp->stdy.stdydic = sp;
|
||||
sfp->stdy.clstdystep = clstdystep;
|
||||
sfp->stdy.clstdyidx = cip;
|
||||
sfp->stdy.clstdylen = clstdylen;
|
||||
sfp->stdy.clstdydic = clp;
|
||||
sfp->refcnt = 1;
|
||||
sfp->inode = sbuf.st_ino;
|
||||
sfp->fp = fp;
|
||||
sfp->fd = fileno(fp);
|
||||
sfp->header = hd;
|
||||
|
||||
sfp->link = stdylink;
|
||||
stdylink = sfp;
|
||||
|
||||
return sfp;
|
||||
|
||||
error5:
|
||||
free((char*)clp);
|
||||
error4:
|
||||
free((char*)cip);
|
||||
error3:
|
||||
free((char*)sp);
|
||||
error2:
|
||||
free((char*)sfp);
|
||||
error1:
|
||||
fclose(fp);
|
||||
error0:
|
||||
free((char*)hd);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int closestdy(StdyFile* sfp) {
|
||||
StdyFile* sf;
|
||||
|
||||
if(--sfp->refcnt > 0) return 0;
|
||||
|
||||
if(stdylink == sfp)
|
||||
stdylink = sfp->link;
|
||||
else {
|
||||
for(sf = stdylink; sf; sf = sf->link)
|
||||
if(sf->link == sfp) {
|
||||
sf->link = sfp->link;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(sfp->fp) fclose(sfp->fp);
|
||||
|
||||
free((char*)sfp->stdy.stdydic);
|
||||
free((char*)sfp->stdy.clstdyidx);
|
||||
free((char*)sfp->stdy.clstdydic);
|
||||
free((char*)sfp->header);
|
||||
free((char*)sfp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int putstydic(SJ4_CONTEXT2) {
|
||||
int fd;
|
||||
u_char* hd;
|
||||
StdyFile* sf;
|
||||
long len;
|
||||
|
||||
sf = (StdyFile*)stdy_base;
|
||||
fd = sf->fd;
|
||||
hd = sf->header;
|
||||
|
||||
put4byte(hd + STDYNORMCNT, sf->stdy.stdycnt);
|
||||
|
||||
len = sizeof(STDYIN) * sf->stdy.stdymax;
|
||||
put4byte(hd + STDYNORMLEN, len);
|
||||
|
||||
if(putfile(fd, 0, HEADERLENGTH + COMMENTLENGTH, hd)) return ERROR;
|
||||
|
||||
return putfile(fd, get4byte(hd + STDYNORMPOS), len, (u_char*)sf->stdy.stdydic);
|
||||
}
|
||||
|
||||
int putcldic(SJ4_CONTEXT2) {
|
||||
int fd;
|
||||
u_char* hd;
|
||||
StdyFile* sf;
|
||||
|
||||
sf = (StdyFile*)stdy_base;
|
||||
fd = sf->fd;
|
||||
hd = sf->header;
|
||||
|
||||
if(putfile(fd, get4byte(hd + STDYCLIDXPOS),
|
||||
get4byte(hd + STDYCLIDXLEN), (u_char*)sf->stdy.clstdyidx)) /* XXX */
|
||||
return ERROR;
|
||||
return putfile(fd, get4byte(hd + STDYCLSEGPOS),
|
||||
get4byte(hd + STDYCLSEGLEN), sf->stdy.clstdydic);
|
||||
}
|
||||
|
||||
int makedict(char* path, int idxlen, int seglen, int segnum) {
|
||||
FILE* fp;
|
||||
u_char tmp[HEADERLENGTH + COMMENTLENGTH];
|
||||
long pos = HEADERLENGTH + COMMENTLENGTH;
|
||||
int ret = ERROR;
|
||||
int i;
|
||||
|
||||
if(idxlen < MINIDXLEN || seglen < MINSEGLEN || segnum < MINSEGNUM) {
|
||||
serv_errno = SJ4_IllegalParameter;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(!(fp = fopen(path, "wb"))) {
|
||||
serv_errno = SJ4_CannotCreateFile;
|
||||
return ret;
|
||||
}
|
||||
memset(tmp, '\0', sizeof(tmp));
|
||||
put4byte(tmp + VERSIONPOS, DICTVERSION);
|
||||
|
||||
put4byte(tmp + DICTIDXPOS, pos);
|
||||
put4byte(tmp + DICTIDXLEN, idxlen);
|
||||
if(fseek(fp, pos, 0) == ERROR) {
|
||||
serv_errno = SJ4_FileSeekError;
|
||||
goto error;
|
||||
}
|
||||
for(i = 0; i < idxlen; i++)
|
||||
if(putc(0, fp)) {
|
||||
serv_errno = SJ4_FileWriteError;
|
||||
goto error;
|
||||
}
|
||||
pos += idxlen;
|
||||
|
||||
put4byte(tmp + DICTSEGPOS, pos);
|
||||
put4byte(tmp + DICTSEGLEN, seglen);
|
||||
put4byte(tmp + DICTSEGNUM, 1);
|
||||
put4byte(tmp + DICTSEGMAX, segnum);
|
||||
if(fseek(fp, pos, 0) == ERROR) {
|
||||
serv_errno = SJ4_FileSeekError;
|
||||
goto error;
|
||||
}
|
||||
if(putc(0, fp)) {
|
||||
serv_errno = SJ4_FileWriteError;
|
||||
goto error;
|
||||
}
|
||||
for(i = 1; i < seglen; i++)
|
||||
if(putc(0xff, fp) != 0xff) {
|
||||
serv_errno = SJ4_FileWriteError;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(fputfile(fp, 0L, sizeof(tmp), tmp) == SJ4_NormalEnd)
|
||||
ret = SJ4_NormalEnd;
|
||||
error:
|
||||
fclose(fp);
|
||||
if(ret != SJ4_NormalEnd) unlink(path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int makestdy(char* path, int stynum, int clstep, int cllen) {
|
||||
FILE* fp;
|
||||
u_char tmp[HEADERLENGTH + COMMENTLENGTH];
|
||||
long pos = HEADERLENGTH + COMMENTLENGTH;
|
||||
int ret = ERROR;
|
||||
int i, j;
|
||||
|
||||
if(stynum == 0) stynum = MINSTYNUM;
|
||||
if(clstep == 0) clstep = MINCLSTEP;
|
||||
if(cllen == 0) cllen = MINCLLEN;
|
||||
|
||||
if(stynum < MINSTYNUM || clstep < MINCLSTEP || cllen < MINCLLEN) {
|
||||
serv_errno = SJ4_IllegalParameter;
|
||||
return ret;
|
||||
}
|
||||
if(stynum > MAXSTYNUM || clstep > MAXCLSTEP || cllen > MAXCLLEN) {
|
||||
serv_errno = SJ4_IllegalParameter;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(!(fp = fopen(path, "wb"))) {
|
||||
serv_errno = SJ4_CannotCreateFile;
|
||||
return ret;
|
||||
}
|
||||
memset(tmp, '\0', sizeof(tmp));
|
||||
put4byte(tmp + VERSIONPOS, STDYVERSION);
|
||||
|
||||
j = 256 * sizeof(u_short);
|
||||
put4byte(tmp + STDYCLIDXPOS, pos);
|
||||
put4byte(tmp + STDYCLIDXLEN, j);
|
||||
put4byte(tmp + STDYCLIDXSTEP, clstep);
|
||||
if(fseek(fp, pos, 0) == ERROR) {
|
||||
serv_errno = SJ4_FileSeekError;
|
||||
goto error;
|
||||
}
|
||||
for(i = 0; i < j; i++)
|
||||
if(putc(0, fp)) {
|
||||
serv_errno = SJ4_FileWriteError;
|
||||
goto error;
|
||||
}
|
||||
pos += j;
|
||||
|
||||
put4byte(tmp + STDYCLSEGPOS, pos);
|
||||
put4byte(tmp + STDYCLSEGLEN, cllen);
|
||||
if(fseek(fp, pos, 0) == ERROR) {
|
||||
serv_errno = SJ4_FileSeekError;
|
||||
goto error;
|
||||
}
|
||||
for(i = 0; i < cllen; i++)
|
||||
if(putc(0, fp)) {
|
||||
serv_errno = SJ4_FileWriteError;
|
||||
goto error;
|
||||
}
|
||||
pos += cllen;
|
||||
|
||||
j = sizeof(STDYIN) * stynum;
|
||||
put4byte(tmp + STDYNORMPOS, pos);
|
||||
put4byte(tmp + STDYNORMLEN, j);
|
||||
put4byte(tmp + STDYNORMNUM, stynum);
|
||||
put4byte(tmp + STDYNORMCNT, 0);
|
||||
if(fseek(fp, pos, 0) == ERROR) {
|
||||
serv_errno = SJ4_FileSeekError;
|
||||
goto error;
|
||||
}
|
||||
for(i = 0; i < j; i++) {
|
||||
if(putc(0, fp)) {
|
||||
serv_errno = SJ4_FileWriteError;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
pos += j;
|
||||
|
||||
if(fputfile(fp, 0L, sizeof(tmp), tmp) == SJ4_NormalEnd)
|
||||
ret = SJ4_NormalEnd;
|
||||
error:
|
||||
fclose(fp);
|
||||
if(ret != SJ4_NormalEnd) unlink(path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void sj_closeall(SJ4_CONTEXT2) {
|
||||
while(dictlink) closedict(SJ4_CONTEXT_PASS dictlink);
|
||||
while(stdylink) closestdy(stdylink);
|
||||
}
|
||||
|
||||
int set_dictpass(DictFile* dp, char* pass) {
|
||||
set_passwd(dp->buffer, pass);
|
||||
return putfile(dp->fd, 0, HEADERLENGTH + COMMENTLENGTH, dp->buffer);
|
||||
}
|
||||
|
||||
int set_stdypass(SJ4_CONTEXT char* pass) {
|
||||
StdyFile* sp;
|
||||
|
||||
sp = (StdyFile*)stdy_base;
|
||||
set_passwd(sp->header, pass);
|
||||
return putfile(sp->fd, 0, HEADERLENGTH + COMMENTLENGTH, sp->header);
|
||||
}
|
||||
|
||||
static void
|
||||
set_comment(u_char* buf, char* comment) {
|
||||
strlcpy((char*)buf + HEADERLENGTH, comment, COMMENTLENGTH);
|
||||
}
|
||||
|
||||
int set_dictcmnt(DictFile* dp, char* cmnt) {
|
||||
set_comment(dp->buffer, cmnt);
|
||||
return putfile(dp->fd, 0, HEADERLENGTH + COMMENTLENGTH, dp->buffer);
|
||||
}
|
||||
|
||||
int set_stdycmnt(SJ4_CONTEXT char* cmnt) {
|
||||
StdyFile* sp;
|
||||
|
||||
sp = (StdyFile*)stdy_base;
|
||||
set_comment(sp->header, cmnt);
|
||||
return putfile(sp->fd, 0, HEADERLENGTH + COMMENTLENGTH, sp->header);
|
||||
}
|
||||
|
||||
int get_stdysize(SJ4_CONTEXT int* stynum, int* clstep, int* cllen) {
|
||||
*stynum = STUDYMAX;
|
||||
*clstep = CLSTUDYSTEP;
|
||||
*cllen = CLSTUDYLEN;
|
||||
return 1;
|
||||
}
|
||||
104
lib/sj4core/selclrec.c
Normal file
104
lib/sj4core/selclrec.c
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: selclrec.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:14 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
void selclrec(SJ4_CONTEXT2) {
|
||||
int len;
|
||||
CLREC* rec;
|
||||
|
||||
nextcllen = 0;
|
||||
|
||||
len = selcl->cllen;
|
||||
rec = clt1st;
|
||||
while(rec) {
|
||||
if(len >= (unsigned int)rec->cllen) break;
|
||||
rec = rec->clsort;
|
||||
}
|
||||
|
||||
while(rec) {
|
||||
if(len > (unsigned int)rec->cllen) return;
|
||||
if(rec->jnode->class == C_BUNSETU) break;
|
||||
rec = rec->clsort;
|
||||
}
|
||||
if(!rec) return;
|
||||
|
||||
len = ClYomi1Len(CLSTUDYDICT + rec->jnode->jofsst);
|
||||
|
||||
nextcllen = rec->cllen - len;
|
||||
|
||||
while(rec) {
|
||||
if(len == rec->cllen) {
|
||||
selcl = rec;
|
||||
break;
|
||||
}
|
||||
|
||||
else if(len > (unsigned int)rec->cllen) {
|
||||
rec = NULL;
|
||||
break;
|
||||
}
|
||||
rec = rec->clsort;
|
||||
}
|
||||
|
||||
if(rec == NULL) {
|
||||
int klen;
|
||||
u_char ch;
|
||||
|
||||
free_clall(SJ4_CONTEXT_PASS clt1st);
|
||||
free_jall(SJ4_CONTEXT_PASS jrt1st);
|
||||
|
||||
klen = cnvlen;
|
||||
cnvlen = len;
|
||||
ch = *(cnvstart + len);
|
||||
*(cnvstart + len) = 0;
|
||||
|
||||
mkjiritu(SJ4_CONTEXT_PASS DO_IKKATU);
|
||||
|
||||
mkbunsetu(SJ4_CONTEXT_PASS2);
|
||||
if(!maxclptr) wakachi(SJ4_CONTEXT_PASS2);
|
||||
|
||||
jrt1st = maxjptr;
|
||||
selcl = clt1st = maxclptr;
|
||||
|
||||
cnvlen = klen;
|
||||
*(cnvstart + len) = ch;
|
||||
}
|
||||
|
||||
free_clall(SJ4_CONTEXT_PASS clt2nd);
|
||||
clt2nd = NULL;
|
||||
free_jall(SJ4_CONTEXT_PASS jrt2nd);
|
||||
jrt2nd = NULL;
|
||||
}
|
||||
111
lib/sj4core/selsuuji.c
Normal file
111
lib/sj4core/selsuuji.c
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: selsuuji.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:15 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
#include "sj_const.h"
|
||||
#include "sj_suuji.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static u_short selsjAR[] = {
|
||||
SELARB0,
|
||||
SELARBCMA | JFLAG_NK4 | JFLAG_NN0,
|
||||
SELKANSJYM | JFLAG_NN0,
|
||||
SELKANSJYM2 | SELNUM1_23_10_1 | JFLAG_NN0,
|
||||
SELKANSJ0 | JFLAG_NK2,
|
||||
SELNUMTERM};
|
||||
|
||||
static u_short selsjARCM[] = {
|
||||
SELARBCMA | JFLAG_NK4 | JFLAG_NN0,
|
||||
SELARB0,
|
||||
SELKANSJYM | JFLAG_NN0,
|
||||
SELKANSJYM2 | SELNUM1_23_10_1 | JFLAG_NN0,
|
||||
SELKANSJ0 | JFLAG_NK2,
|
||||
SELNUMTERM};
|
||||
|
||||
static u_short selsjKAZU[] = {
|
||||
SELKANSJYM | JFLAG_NN0,
|
||||
SELKANSJYM2 | SELNUM1_23_10_1 | JFLAG_NN0,
|
||||
SELKANSJ0 | JFLAG_NK2,
|
||||
SELARB0,
|
||||
SELARBCMA | JFLAG_NK4 | JFLAG_NN0,
|
||||
SELNUMTERM};
|
||||
|
||||
static u_short selsjSUUJI[] = {
|
||||
SELKANSJ0,
|
||||
SELARB0,
|
||||
SELNUMTERM};
|
||||
|
||||
static u_short selsjNANSUU[] = {
|
||||
SELKANSJYM,
|
||||
SELNUMTERM};
|
||||
|
||||
static u_short selsjAR17[] = {
|
||||
SELLONGARB,
|
||||
SELLONGARBCMA,
|
||||
SELNUMTERM};
|
||||
|
||||
static u_short selsjAR17CM[] = {
|
||||
SELLONGARBCMA,
|
||||
SELLONGARB,
|
||||
SELNUMTERM};
|
||||
|
||||
static u_short selsjAR17SJ[] = {
|
||||
SELLONGARB,
|
||||
SELLONGSJ,
|
||||
SELNUMTERM};
|
||||
|
||||
static u_short selsjKANKURA[] = {
|
||||
SELKANSJKR,
|
||||
SELARBKR,
|
||||
SELNUMTERM};
|
||||
|
||||
static u_short selsjARAKURA[] = {
|
||||
SELARBKR,
|
||||
SELKANSJKR | JFLAG_NSN,
|
||||
SELNUMTERM};
|
||||
|
||||
u_short* selsjadrs[] = {
|
||||
selsjAR,
|
||||
selsjARCM,
|
||||
selsjKAZU,
|
||||
selsjSUUJI,
|
||||
selsjNANSUU,
|
||||
selsjKANKURA,
|
||||
selsjARAKURA,
|
||||
selsjAR17,
|
||||
selsjAR17CM,
|
||||
selsjAR17SJ};
|
||||
152
lib/sj4core/setconj.c
Normal file
152
lib/sj4core/setconj.c
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: setconj.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:16 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_right.h"
|
||||
#include "sj_hinsi.h"
|
||||
#include "sj_yomi.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static int
|
||||
cnjstrcmp(u_char* yptr, u_char* cnjp, int* saml) {
|
||||
int asklen;
|
||||
int nkrlen;
|
||||
|
||||
asklen = CnjAskLen(cnjp);
|
||||
|
||||
if(*saml < asklen) return CONT;
|
||||
|
||||
if(*saml > asklen) return OVER;
|
||||
|
||||
nkrlen = CnjNkrLen(cnjp);
|
||||
|
||||
yptr += asklen;
|
||||
cnjp++;
|
||||
|
||||
while(nkrlen--) {
|
||||
if(*yptr > *cnjp)
|
||||
return CONT;
|
||||
|
||||
else if(*yptr < *cnjp) {
|
||||
if(!*yptr) return PARTLY;
|
||||
return OVER;
|
||||
}
|
||||
|
||||
else {
|
||||
yptr++;
|
||||
cnjp++;
|
||||
(*saml)++;
|
||||
}
|
||||
}
|
||||
|
||||
return MATCH;
|
||||
}
|
||||
|
||||
static TypeCnct
|
||||
cnvrow(JREC* rec, TypeCnct row) {
|
||||
TypeGram hinsi;
|
||||
int stt;
|
||||
|
||||
hinsi = rec->hinsi;
|
||||
|
||||
if((stt = rec->sttofs) == SETTOU_O) {
|
||||
|
||||
if(R_RENYOU1 <= row && row <= R_SA5RENYOU1)
|
||||
row += 6;
|
||||
|
||||
else if(R_RENYOU3 <= row && row <= R_SA5RENYOU3)
|
||||
row += 3;
|
||||
|
||||
else if((hinsi >= KEIYOUSI_1 && hinsi <= KE_DOUSI_9) ||
|
||||
(hinsi == MEISI_5) || (hinsi == MEISI_9))
|
||||
;
|
||||
|
||||
else
|
||||
row = 0;
|
||||
}
|
||||
|
||||
else if(stt == SETTOU_GO) {
|
||||
|
||||
if(hinsi == MEISI_7 && row == R_SMEISI1)
|
||||
row++;
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
int setconj(SJ4_CONTEXT TypeGram hinsi, JREC* jrec, CREC* crec) {
|
||||
u_char* yptr;
|
||||
int cmp;
|
||||
TypeCnct right;
|
||||
int saml;
|
||||
int ofslen;
|
||||
int count = 0;
|
||||
u_char* cnj;
|
||||
|
||||
if((cnj = Conjadr(hinsi))) {
|
||||
saml = ofslen = 0;
|
||||
|
||||
yptr = cnvstart + jrec->jlen;
|
||||
|
||||
if((*cnj) & TYOUONFLG) {
|
||||
while(*yptr == _TYOUON) {
|
||||
yptr++;
|
||||
ofslen++;
|
||||
}
|
||||
}
|
||||
|
||||
for(; *cnj != CNJEND; cnj += CnjRecLen(cnj)) {
|
||||
cmp = cnjstrcmp(yptr, cnj, &saml);
|
||||
|
||||
if(cmp == OVER) break;
|
||||
|
||||
if(cmp == PARTLY) break;
|
||||
|
||||
if(cmp != MATCH) continue;
|
||||
|
||||
if(isdpnd(*(yptr + saml))) continue;
|
||||
|
||||
if((right = cnvrow(jrec, (TypeCnct)CnjRight(cnj)))) {
|
||||
crec->len = (u_char)(ofslen + saml);
|
||||
crec->right = right;
|
||||
count++;
|
||||
crec++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
309
lib/sj4core/setjrec.c
Normal file
309
lib/sj4core/setjrec.c
Normal file
|
|
@ -0,0 +1,309 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: setjrec.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:17 $
|
||||
*/
|
||||
|
||||
#include "sj_euc.h"
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_hinsi.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
int setj_atrb(SJ4_CONTEXT u_char* p) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
int setj_ofs(SJ4_CONTEXT u_char* p) {
|
||||
int contf = TRUE;
|
||||
|
||||
p = dicbuf + ((*p & KANJICODEMASK) << 8) + *(p + 1);
|
||||
|
||||
do {
|
||||
if(p[codesize(*p)] == KANJISTREND) contf = FALSE;
|
||||
switch(*p & KANJIMODEMASK) {
|
||||
case ZENHIRAASSYUKU:
|
||||
p += setj_norm1(SJ4_CONTEXT_PASS p);
|
||||
break;
|
||||
|
||||
case ZENKATAASSYUKU:
|
||||
p += setj_norm1(SJ4_CONTEXT_PASS p);
|
||||
break;
|
||||
|
||||
case OFFSETASSYUKU:
|
||||
p += setj_ofs(SJ4_CONTEXT_PASS p);
|
||||
break;
|
||||
|
||||
case AIATTRIBUTE:
|
||||
p += setj_atrb(SJ4_CONTEXT_PASS p);
|
||||
break;
|
||||
|
||||
case LEADINGHANKAKU:
|
||||
p += setj_norm2(SJ4_CONTEXT_PASS p);
|
||||
break;
|
||||
|
||||
case KANJIASSYUKU:
|
||||
p += setj_knj(SJ4_CONTEXT_PASS p);
|
||||
break;
|
||||
|
||||
case KANJISTREND:
|
||||
contf = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
p += setj_norm2(SJ4_CONTEXT_PASS p);
|
||||
}
|
||||
} while(contf);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
int setj_knj(SJ4_CONTEXT u_char* p) {
|
||||
int contf = TRUE;
|
||||
|
||||
p = askknj[*p & KNJASSYUKUMASK];
|
||||
|
||||
do {
|
||||
if(p[codesize(*p)] == KANJISTREND) contf = FALSE;
|
||||
switch(*p & KANJIMODEMASK) {
|
||||
case ZENHIRAASSYUKU:
|
||||
p += setj_norm1(SJ4_CONTEXT_PASS p);
|
||||
break;
|
||||
|
||||
case ZENKATAASSYUKU:
|
||||
p += setj_norm1(SJ4_CONTEXT_PASS p);
|
||||
break;
|
||||
|
||||
case OFFSETASSYUKU:
|
||||
p += setj_ofs(SJ4_CONTEXT_PASS p);
|
||||
break;
|
||||
|
||||
case AIATTRIBUTE:
|
||||
p += setj_atrb(SJ4_CONTEXT_PASS p);
|
||||
break;
|
||||
|
||||
case LEADINGHANKAKU:
|
||||
p += setj_norm2(SJ4_CONTEXT_PASS p);
|
||||
break;
|
||||
|
||||
case KANJIASSYUKU:
|
||||
p += setj_knj(SJ4_CONTEXT_PASS p);
|
||||
break;
|
||||
|
||||
case KANJISTREND:
|
||||
contf = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
p += setj_norm2(SJ4_CONTEXT_PASS p);
|
||||
}
|
||||
} while(contf);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int setj_norm1(SJ4_CONTEXT u_char* p) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int setj_norm2(SJ4_CONTEXT u_char* p) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
int setj_norm3(SJ4_CONTEXT u_char* p) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
static u_char
|
||||
chkhead(SJ4_CONTEXT TypeGram gram) {
|
||||
if(!headcode) return TRUE;
|
||||
|
||||
if(headcode == SETTOU_DAI) {
|
||||
|
||||
if(gram == SUUSI) return TRUE;
|
||||
}
|
||||
|
||||
else {
|
||||
gram--;
|
||||
if((Scncttbl(headcode - 1, gram >> 3) << (gram & 0x07)) & 0x80) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void setjrec(SJ4_CONTEXT u_char* tagp, int mode) {
|
||||
TypeGram gram;
|
||||
u_char* ptr;
|
||||
u_char* endp;
|
||||
u_char* tmp;
|
||||
JREC* rec;
|
||||
int plen;
|
||||
int nlen;
|
||||
int len;
|
||||
|
||||
plen = getplen(tagp);
|
||||
nlen = getnlen(tagp);
|
||||
|
||||
len = plen + nlen;
|
||||
|
||||
if(headcode) len += headlen;
|
||||
|
||||
ptr = tagp + DOUONBLKSIZENUMBER + nlen;
|
||||
|
||||
endp = tagp + getsize(tagp);
|
||||
|
||||
for(; ptr < endp; ptr = tmp + 1) {
|
||||
for(tmp = ptr + 1; *tmp != HINSIBLKTERM;) {
|
||||
switch(*tmp & KANJIMODEMASK) {
|
||||
case ZENHIRAASSYUKU:
|
||||
tmp += setj_norm1(SJ4_CONTEXT_PASS tmp);
|
||||
break;
|
||||
|
||||
case ZENKATAASSYUKU:
|
||||
tmp += setj_norm1(SJ4_CONTEXT_PASS tmp);
|
||||
break;
|
||||
|
||||
case OFFSETASSYUKU:
|
||||
tmp += setj_ofs(SJ4_CONTEXT_PASS tmp);
|
||||
break;
|
||||
|
||||
case AIATTRIBUTE:
|
||||
tmp += setj_atrb(SJ4_CONTEXT_PASS tmp);
|
||||
break;
|
||||
|
||||
case LEADINGHANKAKU:
|
||||
tmp += setj_norm2(SJ4_CONTEXT_PASS tmp);
|
||||
break;
|
||||
|
||||
case KANJIASSYUKU:
|
||||
tmp += setj_knj(SJ4_CONTEXT_PASS tmp);
|
||||
break;
|
||||
|
||||
case KANJISTREND:
|
||||
tmp++;
|
||||
break;
|
||||
|
||||
default:
|
||||
tmp += setj_norm2(SJ4_CONTEXT_PASS tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if((gram = *ptr) == IKKATU && !(mode & DO_IKKATU)) continue;
|
||||
|
||||
if(!chkhead(SJ4_CONTEXT_PASS gram)) continue;
|
||||
|
||||
if(!(rec = argjrec(SJ4_CONTEXT_PASS len, (JREC*)NULL))) continue;
|
||||
|
||||
rec->jseg = prevseg;
|
||||
rec->jofsst = ptr - dicbuf;
|
||||
rec->jofsed = tmp - dicbuf;
|
||||
rec->class = C_DICT;
|
||||
rec->dicid = curdict->dicid;
|
||||
rec->hinsi = gram;
|
||||
rec->sttofs = headcode;
|
||||
}
|
||||
}
|
||||
|
||||
void setnumrec(SJ4_CONTEXT u_char* tagp, JREC* rec, TypeGram gram) {
|
||||
u_char* ptr;
|
||||
u_char* endp;
|
||||
u_char* tmp;
|
||||
int plen, nlen, len;
|
||||
JREC* jrec;
|
||||
|
||||
plen = getplen(tagp);
|
||||
nlen = getnlen(tagp);
|
||||
|
||||
len = plen + nlen;
|
||||
|
||||
ptr = tagp + DOUONBLKSIZENUMBER + nlen;
|
||||
|
||||
endp = tagp + getsize(tagp);
|
||||
|
||||
for(; ptr < endp; ptr = tmp + 1) {
|
||||
for(tmp = ptr + 1; *tmp != HINSIBLKTERM;) {
|
||||
switch(*tmp & KANJIMODEMASK) {
|
||||
case ZENHIRAASSYUKU:
|
||||
tmp += setj_norm1(SJ4_CONTEXT_PASS tmp);
|
||||
break;
|
||||
|
||||
case ZENKATAASSYUKU:
|
||||
tmp += setj_norm1(SJ4_CONTEXT_PASS tmp);
|
||||
break;
|
||||
|
||||
case OFFSETASSYUKU:
|
||||
tmp += setj_ofs(SJ4_CONTEXT_PASS tmp);
|
||||
break;
|
||||
|
||||
case AIATTRIBUTE:
|
||||
tmp += setj_atrb(SJ4_CONTEXT_PASS tmp);
|
||||
break;
|
||||
|
||||
case LEADINGHANKAKU:
|
||||
tmp += setj_norm2(SJ4_CONTEXT_PASS tmp);
|
||||
break;
|
||||
|
||||
case KANJIASSYUKU:
|
||||
tmp += setj_knj(SJ4_CONTEXT_PASS tmp);
|
||||
break;
|
||||
|
||||
case KANJISTREND:
|
||||
tmp++;
|
||||
break;
|
||||
|
||||
default:
|
||||
tmp += setj_norm2(SJ4_CONTEXT_PASS tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if(gram != *ptr) continue;
|
||||
|
||||
if(!(jrec = argjrec(SJ4_CONTEXT_PASS(int)(rec->jlen + len), rec))) continue;
|
||||
|
||||
jrec->jseg = prevseg;
|
||||
jrec->jofsst = ptr - dicbuf;
|
||||
jrec->jofsed = tmp - dicbuf;
|
||||
jrec->dicid = curdict->dicid;
|
||||
}
|
||||
}
|
||||
|
||||
void setcrec(SJ4_CONTEXT u_char* tagp) {
|
||||
JREC* rec;
|
||||
|
||||
if(!(rec = argjrec(SJ4_CONTEXT_PASS(int) ClYomiLen(tagp), (JREC*)NULL))) return;
|
||||
|
||||
rec->jofsst = tagp - CLSTUDYDICT;
|
||||
rec->class = C_BUNSETU;
|
||||
rec->hinsi = ClGramCode(tagp);
|
||||
}
|
||||
250
lib/sj4core/setkouho.c
Normal file
250
lib/sj4core/setkouho.c
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: setkouho.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:20 $
|
||||
*/
|
||||
|
||||
#include "sj_euc.h"
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_hinsi.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static int hiraknj(SJ4_CONTEXT u_char*);
|
||||
|
||||
void setkouho(SJ4_CONTEXT CLREC* clrec, TypeDicOfs offs, int mode) {
|
||||
JREC* jrec;
|
||||
KHREC* kptr;
|
||||
u_char* fptr;
|
||||
int flg;
|
||||
int i;
|
||||
|
||||
if(khcount >= MAXKOUHONUMBER) return;
|
||||
|
||||
jrec = clrec->jnode;
|
||||
|
||||
kptr = &kouhotbl[khcount++];
|
||||
|
||||
if(mode && !offs) nkhcount++;
|
||||
|
||||
kptr->clrec = clrec;
|
||||
kptr->offs = offs;
|
||||
kptr->rank = 0;
|
||||
kptr->styno = 0;
|
||||
kptr->mode = (u_char)mode;
|
||||
|
||||
if(jrec->flags & JFLAG_KA) {
|
||||
kptr->ka_fg = 1;
|
||||
kptr->ka_kj = 1;
|
||||
flg = 1;
|
||||
} else if(clrec->fzk_ka) {
|
||||
kptr->ka_fg = 1;
|
||||
kptr->ka_kj = 0;
|
||||
flg = 2;
|
||||
} else {
|
||||
kptr->ka_fg = 0;
|
||||
kptr->ka_kj = 0;
|
||||
flg = 0;
|
||||
}
|
||||
|
||||
kptr->sttfg = kptr->sttkj = 0;
|
||||
|
||||
if(!(fptr = Settou_ptr(jrec->sttofs))) return;
|
||||
|
||||
if(!SttHiraKnj(fptr)) return;
|
||||
|
||||
kptr->sttfg = 1;
|
||||
kptr->sttkj = 0;
|
||||
|
||||
i = hiraknj(SJ4_CONTEXT_PASS dicbuf + offs);
|
||||
if(offs > 1 && (i == 2 || i == 3)) return;
|
||||
|
||||
if(khcount >= MAXKOUHONUMBER) return;
|
||||
|
||||
kptr++;
|
||||
khcount++;
|
||||
|
||||
if(mode && !offs) nkhcount++;
|
||||
|
||||
kptr->clrec = clrec;
|
||||
kptr->offs = offs;
|
||||
kptr->rank = 0;
|
||||
kptr->styno = 0;
|
||||
kptr->mode = (u_char)mode;
|
||||
|
||||
kptr->sttfg = 1;
|
||||
kptr->sttkj = 1;
|
||||
|
||||
switch(flg) {
|
||||
case 1:
|
||||
kptr->ka_fg = kptr->ka_kj = 1;
|
||||
break;
|
||||
case 2:
|
||||
kptr->ka_fg = 1;
|
||||
kptr->ka_kj = 0;
|
||||
break;
|
||||
default:
|
||||
kptr->ka_fg = kptr->ka_kj = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ph_setkouho(SJ4_CONTEXT CLREC* clrec, TypeDicOfs offs, STDYIN* sptr) {
|
||||
JREC* jrec;
|
||||
u_char* p;
|
||||
|
||||
if(sptr) {
|
||||
stdytop = sptr;
|
||||
kouhotbl[0].styno = sptr->styno;
|
||||
kouhotbl[0].sttkj = sptr->sttkj;
|
||||
} else {
|
||||
kouhotbl[0].styno = -1;
|
||||
kouhotbl[0].sttkj = 0;
|
||||
}
|
||||
|
||||
kouhotbl[0].clrec = clrec;
|
||||
kouhotbl[0].offs = offs;
|
||||
kouhotbl[0].rank = 0;
|
||||
|
||||
kouhotbl[0].mode = sel_sjmode(jrec = clrec->jnode);
|
||||
|
||||
kouhotbl[0].sttfg = (u_char)((p = Settou_ptr(jrec->sttofs)) ? (SttHiraKnj(p) ? 1 : 0) : 0);
|
||||
|
||||
if(jrec->flags & JFLAG_KA) {
|
||||
kouhotbl[0].ka_fg =
|
||||
kouhotbl[0].ka_kj = 1;
|
||||
} else if(clrec->fzk_ka) {
|
||||
kouhotbl[0].ka_fg = 1;
|
||||
kouhotbl[0].ka_kj = 0;
|
||||
} else {
|
||||
kouhotbl[0].ka_fg =
|
||||
kouhotbl[0].ka_kj = 0;
|
||||
}
|
||||
|
||||
khcount = 1;
|
||||
}
|
||||
|
||||
static int
|
||||
hiraknj(SJ4_CONTEXT u_char* p) {
|
||||
char flg = TRUE;
|
||||
int i;
|
||||
int result;
|
||||
|
||||
do {
|
||||
if(p[codesize(*p)] == KANJISTREND) flg = FALSE;
|
||||
switch(*p & KANJIMODEMASK) {
|
||||
case ZENHIRAASSYUKU:
|
||||
result = hiraknj_hask(SJ4_CONTEXT_PASS p, &i);
|
||||
break;
|
||||
|
||||
case ZENKATAASSYUKU:
|
||||
result = hiraknj_kask(SJ4_CONTEXT_PASS p, &i);
|
||||
break;
|
||||
|
||||
case OFFSETASSYUKU:
|
||||
result = hiraknj_ofs(SJ4_CONTEXT_PASS p, &i);
|
||||
break;
|
||||
|
||||
case AIATTRIBUTE:
|
||||
result = hiraknj_atrb(SJ4_CONTEXT_PASS p, &i);
|
||||
break;
|
||||
|
||||
case LEADINGHANKAKU:
|
||||
result = hiraknj_norm(SJ4_CONTEXT_PASS p, &i);
|
||||
break;
|
||||
|
||||
case KANJIASSYUKU:
|
||||
result = hiraknj_knj(SJ4_CONTEXT_PASS p, &i);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = hiraknj_hira(SJ4_CONTEXT_PASS p, &i);
|
||||
}
|
||||
|
||||
if(result) return result;
|
||||
|
||||
p += i;
|
||||
} while(flg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hiraknj_atrb(SJ4_CONTEXT u_char* p, int* len) {
|
||||
*len = 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hiraknj_ofs(SJ4_CONTEXT u_char* p, int* len) {
|
||||
*len = 2;
|
||||
return hiraknj(SJ4_CONTEXT_PASS dicbuf + ((*p & KANJICODEMASK) << 8) + *(p + 1));
|
||||
}
|
||||
|
||||
int hiraknj_knj(SJ4_CONTEXT u_char* p, int* len) {
|
||||
*len = 1;
|
||||
return hiraknj(SJ4_CONTEXT_PASS askknj[*p & KNJASSYUKUMASK]);
|
||||
}
|
||||
|
||||
int hiraknj_hask(SJ4_CONTEXT u_char* p, int* len) {
|
||||
*len = 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
int hiraknj_kask(SJ4_CONTEXT u_char* p, int* len) {
|
||||
*len = 1;
|
||||
return 3;
|
||||
}
|
||||
|
||||
int hiraknj_norm(SJ4_CONTEXT u_char* p, int* len) {
|
||||
*len = codesize(*p);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int hiraknj_hira(SJ4_CONTEXT u_char* p, int* len) {
|
||||
u_char ch;
|
||||
|
||||
*len = codesize(*p);
|
||||
ch = *(p + 1);
|
||||
|
||||
switch(*p) {
|
||||
case 0x24:
|
||||
if(ch >= 0x21 && ch <= 0x73) return 2;
|
||||
return 1;
|
||||
|
||||
case 0x25:
|
||||
if(ch >= 0x21 && ch <= 0x76) return 3;
|
||||
return 1;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
76
lib/sj4core/setubi.c
Normal file
76
lib/sj4core/setubi.c
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: setubi.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:22 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_hinsi.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
u_char*
|
||||
getstb(TypeGram hinsi) {
|
||||
if(hinsi < MEISI_1 || hinsi > TIMEI) return NULL;
|
||||
|
||||
return Stbadr(hinsi);
|
||||
}
|
||||
|
||||
void setubi(SJ4_CONTEXT JREC* rec, u_char* stbtbl) {
|
||||
u_char* stb;
|
||||
u_char* yptr;
|
||||
u_char* sptr;
|
||||
int slen;
|
||||
JREC* new;
|
||||
int cmp;
|
||||
|
||||
stb = stbtbl--;
|
||||
|
||||
yptr = cnvstart + rec->jlen;
|
||||
|
||||
for(; *stb; stb = sptr + slen + StbKnjLen(stb)) {
|
||||
|
||||
slen = StbYomiLen(stb);
|
||||
sptr = StbYomiTop(stb);
|
||||
|
||||
cmp = sstrncmp(yptr, sptr, slen);
|
||||
|
||||
if(cmp == OVER || cmp == PARTLY) break;
|
||||
|
||||
if((cmp != MATCH) || isdpnd(*(yptr + slen))) continue;
|
||||
|
||||
if(!(new = argjrec(SJ4_CONTEXT_PASS(int)(rec->jlen + slen), rec))) continue;
|
||||
|
||||
new->stbofs = (u_char)(stb - stbtbl);
|
||||
new->flags |= StbBakeru(stb) ? JFLAG_KA : 0;
|
||||
}
|
||||
}
|
||||
121
lib/sj4core/sj2code.c
Normal file
121
lib/sj4core/sj2code.c
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: sj2code.c,v $
|
||||
* $SonyRevision: 1.2 $
|
||||
* $SonyDate: 1995/07/21 05:22:51 $
|
||||
*/
|
||||
|
||||
#include "sj_euc.h"
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_yomi.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
int sj2cd_chr(u_char* euc, u_char* yomi) {
|
||||
u_char chr;
|
||||
|
||||
if((chr = *euc++) == EUC_a1) {
|
||||
chr = *euc;
|
||||
if(chr < EUC_START)
|
||||
*yomi = Y_ZENKAKU;
|
||||
else if(chr <= EUC_END)
|
||||
*yomi = Kigou[chr - EUC_START];
|
||||
else
|
||||
*yomi = Y_ZENKAKU;
|
||||
} else if(chr == EUC_a2) {
|
||||
chr = *euc;
|
||||
|
||||
if(chr < EUC_START)
|
||||
*yomi = Y_ZENKAKU;
|
||||
else if(chr <= EUC_END_KIGOU)
|
||||
*yomi = Kigou[chr - EUC_START + 94];
|
||||
else
|
||||
*yomi = Y_ZENKAKU;
|
||||
} else if(chr == EUC_a3) {
|
||||
chr = *euc;
|
||||
if(chr < EUC_0)
|
||||
*yomi = Y_ZENKAKU;
|
||||
else if(chr <= EUC_END_0)
|
||||
*yomi = chr - EUC_0 + N_0;
|
||||
else if(chr < EUC_A)
|
||||
*yomi = Y_ZENKAKU;
|
||||
else if(chr <= EUC_END_A)
|
||||
*yomi = chr - EUC_A + A_A;
|
||||
else if(chr < EUC_a)
|
||||
*yomi = Y_ZENKAKU;
|
||||
else if(chr <= EUC_END_a)
|
||||
*yomi = chr - EUC_a + A_a;
|
||||
else
|
||||
*yomi = Y_ZENKAKU;
|
||||
} else if(chr == EUC_a4) {
|
||||
chr = *euc;
|
||||
if(chr < EUC_START)
|
||||
*yomi = Y_ZENKAKU;
|
||||
else if(chr <= EUC_END_HIRA)
|
||||
*yomi = chr - EUC_START + _XA;
|
||||
else
|
||||
*yomi = Y_ZENKAKU;
|
||||
} else if(chr == EUC_a5) {
|
||||
chr = *euc;
|
||||
if(chr == EUC_VU)
|
||||
*yomi = _VU;
|
||||
else if(chr == EUC_XKA)
|
||||
*yomi = _XKA;
|
||||
else if(chr == EUC_XKE)
|
||||
*yomi = _XKE;
|
||||
else
|
||||
*yomi = Y_ZENKAKU;
|
||||
} else {
|
||||
|
||||
if(!(chr & 0x80)) {
|
||||
*yomi = Y_HANKAKU;
|
||||
return 1;
|
||||
} else if(chr == SS2) {
|
||||
*yomi = Y_HANKAKU;
|
||||
} else if(chr == SS3) {
|
||||
*yomi = Y_ZENKAKU;
|
||||
return 3;
|
||||
} else
|
||||
*yomi = Y_ZENKAKU;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
int sj2cd_str(u_char* euc, u_char* yomi, int len) {
|
||||
|
||||
if(!len--) return FALSE;
|
||||
|
||||
while(*euc && len--) euc += sj2cd_chr(euc, yomi++);
|
||||
*yomi = 0;
|
||||
|
||||
return *euc ? FALSE : TRUE;
|
||||
}
|
||||
51
lib/sj4core/skiphblk.c
Normal file
51
lib/sj4core/skiphblk.c
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: skiphblk.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:24 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
#include "sj_dict.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
u_char*
|
||||
skiphblk(u_char* ptr) {
|
||||
ptr++;
|
||||
|
||||
while(*ptr != HINSIBLKTERM) ptr = skipkstr(ptr);
|
||||
|
||||
ptr++;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
60
lib/sj4core/skipkstr.c
Normal file
60
lib/sj4core/skipkstr.c
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: skipkstr.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:25 $
|
||||
*/
|
||||
|
||||
#include "sj_euc.h"
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
#include "sj_const.h"
|
||||
#include "sj_dict.h"
|
||||
#include "sj_table.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
u_char*
|
||||
skipkstr(u_char* ptr) {
|
||||
int contf = TRUE, csize;
|
||||
|
||||
do {
|
||||
csize = codesize(*ptr);
|
||||
|
||||
if(ptr[csize] == KANJISTREND) contf = FALSE;
|
||||
|
||||
ptr += csize;
|
||||
} while(contf);
|
||||
|
||||
ptr++;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
149
lib/sj4core/srchdict.c
Normal file
149
lib/sj4core/srchdict.c
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: srchdict.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:26 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
int yomicmp(SJ4_CONTEXT u_char* ptr1, u_char* ptr2, u_char* saml) {
|
||||
int i, j;
|
||||
int same;
|
||||
|
||||
same = *saml;
|
||||
|
||||
i = getplen(ptr2);
|
||||
j = getnlen(ptr2);
|
||||
|
||||
if(j == 0) {
|
||||
ptr2 = get_idxptr(SJ4_CONTEXT_PASS prevseg);
|
||||
|
||||
for(i = same; i; i--)
|
||||
if(*ptr1++ != *ptr2++) return OVER;
|
||||
|
||||
j = sstrlen(ptr2);
|
||||
}
|
||||
|
||||
else if(i > same)
|
||||
return CONT;
|
||||
|
||||
else {
|
||||
if(i < same) same = i;
|
||||
ptr1 += same;
|
||||
ptr2 += DOUONBLKSIZENUMBER;
|
||||
}
|
||||
|
||||
while(j-- > 0) {
|
||||
if(*ptr1 > *ptr2) {
|
||||
*saml = same;
|
||||
return CONT;
|
||||
} else if(*ptr1++ < *ptr2++) {
|
||||
return OVER;
|
||||
}
|
||||
same++;
|
||||
}
|
||||
|
||||
*saml = same;
|
||||
return MATCH;
|
||||
}
|
||||
|
||||
u_char*
|
||||
srchdict(SJ4_CONTEXT u_char* tagp) {
|
||||
TypeDicSeg segno;
|
||||
int cmp;
|
||||
int maxlen;
|
||||
|
||||
maxlen = (cnvlen > MAXWDYOMILEN) ? MAXWDYOMILEN : cnvlen;
|
||||
|
||||
while((int)dicinl <= maxlen) {
|
||||
|
||||
segno = srchidx(SJ4_CONTEXT_PASS prevseg, (int)dicinl);
|
||||
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, segno);
|
||||
|
||||
if(prevseg != segno) {
|
||||
|
||||
prevseg = segno;
|
||||
|
||||
tagp = dicbuf;
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
tagp = getntag(tagp);
|
||||
|
||||
if(segend(tagp)) {
|
||||
|
||||
prevseg = ++segno;
|
||||
|
||||
if(segno >= curdict->segunit) return NULL;
|
||||
|
||||
(*curdict->getdic)(SJ4_CONTEXT_PASS curdict, segno);
|
||||
|
||||
tagp = dicbuf;
|
||||
}
|
||||
}
|
||||
|
||||
if(tagp == dicbuf) {
|
||||
get_askknj(SJ4_CONTEXT_PASS2);
|
||||
tagp += *tagp + 1;
|
||||
}
|
||||
|
||||
while(!segend(tagp)) {
|
||||
|
||||
cmp = yomicmp(SJ4_CONTEXT_PASS cnvstart, tagp, &dicsaml);
|
||||
|
||||
if((int)dicsaml > maxlen) return NULL;
|
||||
|
||||
if(cmp == OVER)
|
||||
return NULL;
|
||||
|
||||
else if(cmp == MATCH) {
|
||||
|
||||
if(isdpnd(*(cnvstart + dicsaml))) {
|
||||
break;
|
||||
}
|
||||
|
||||
else {
|
||||
dicinl = dicsaml + 1;
|
||||
return tagp;
|
||||
}
|
||||
}
|
||||
tagp = getntag(tagp);
|
||||
}
|
||||
dicinl = dicsaml + 1;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
62
lib/sj4core/srchhead.c
Normal file
62
lib/sj4core/srchhead.c
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: srchhead.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:28 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_yomi.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
int srchhead(SJ4_CONTEXT2) {
|
||||
if(*cnvstart == _O) {
|
||||
headcode = SETTOU_O;
|
||||
headlen = 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
else if(*cnvstart == _GO) {
|
||||
headcode = SETTOU_GO;
|
||||
headlen = 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
else if((*cnvstart == _DA) && (*(cnvstart + 1) == _I)) {
|
||||
headcode = SETTOU_DAI;
|
||||
headlen = 2;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
headcode = headlen = 0;
|
||||
return FALSE;
|
||||
}
|
||||
73
lib/sj4core/srchidx.c
Normal file
73
lib/sj4core/srchidx.c
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: srchidx.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:29 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
TypeDicSeg
|
||||
srchidx(SJ4_CONTEXT TypeDicSeg low, int len) {
|
||||
TypeDicSeg high;
|
||||
TypeDicSeg mid;
|
||||
int cmp;
|
||||
u_char* target;
|
||||
|
||||
if((high = curdict->segunit - 1) < 1) return 0;
|
||||
|
||||
if(low == (TypeDicSeg)-1) low = 0;
|
||||
|
||||
while(low <= high) {
|
||||
|
||||
mid = (low + high) >> 1;
|
||||
|
||||
target = get_idxptr(SJ4_CONTEXT_PASS mid);
|
||||
|
||||
cmp = istrcmp(cnvstart, target, len, sstrlen(target));
|
||||
|
||||
if(cmp == OVER) {
|
||||
high = mid - 1;
|
||||
}
|
||||
|
||||
else if(cmp != MATCH) {
|
||||
low = mid + 1;
|
||||
}
|
||||
|
||||
else {
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
|
||||
return (cmp == OVER && mid != DICSEGBASE) ? mid - 1 : mid;
|
||||
}
|
||||
574
lib/sj4core/srchnum.c
Normal file
574
lib/sj4core/srchnum.c
Normal file
|
|
@ -0,0 +1,574 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: srchnum.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:30 $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_yomi.h"
|
||||
#include "sj_hinsi.h"
|
||||
#include "sj_suuji.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static void srch_kurai1(SJ4_CONTEXT u_char*, u_char*), srch_kurai2(SJ4_CONTEXT u_char*, u_char*);
|
||||
|
||||
static void
|
||||
srch_josuu_sub(SJ4_CONTEXT JREC* jrec, TypeGram gram) {
|
||||
u_char* tagp;
|
||||
DICTL* dp;
|
||||
|
||||
for(dp = dictlist; dp; dp = dp->next) {
|
||||
curdict = dp->dict;
|
||||
dicinl = 1;
|
||||
dicsaml = 0;
|
||||
prevseg = -1;
|
||||
while((tagp = srchdict(SJ4_CONTEXT_PASS tagp))) setnumrec(SJ4_CONTEXT_PASS tagp, jrec, gram);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
srch_josuu(SJ4_CONTEXT JREC* jrec) {
|
||||
u_char* kp;
|
||||
int klen;
|
||||
int len;
|
||||
|
||||
if(headcode && headcode != SETTOU_DAI) return;
|
||||
|
||||
kp = cnvstart;
|
||||
klen = cnvlen;
|
||||
|
||||
cnvstart += (len = jrec->numlen);
|
||||
cnvlen -= len;
|
||||
|
||||
srch_josuu_sub(SJ4_CONTEXT_PASS jrec, JOSUUSI);
|
||||
|
||||
if(!headcode) srch_josuu_sub(SJ4_CONTEXT_PASS jrec, JOSUUSI2);
|
||||
|
||||
cnvstart = kp;
|
||||
cnvlen = klen;
|
||||
}
|
||||
|
||||
static void
|
||||
setnrec_sub(SJ4_CONTEXT u_char* p, u_short flag, int stb) {
|
||||
JREC* rec;
|
||||
int len1;
|
||||
int len2;
|
||||
|
||||
len1 = len2 = p - suuji_yptr;
|
||||
if(headcode) len1 += headlen;
|
||||
if(stb) len2--;
|
||||
|
||||
if((int)suuji_len == len2) {
|
||||
if(suuji_wkeep) {
|
||||
memcpy((u_char*)suuji_wkeep, (u_char*)suuji_wbuf,
|
||||
sizeof(suuji_wbuf[0]) * NUMWORDBUF);
|
||||
}
|
||||
if(suuji_ukeep) {
|
||||
memcpy(suuji_ukeep, suuji_ubuf, NUMKETALENGTH);
|
||||
}
|
||||
suuji_exit = suuji_keta;
|
||||
return;
|
||||
}
|
||||
|
||||
if((rec = argjrec(SJ4_CONTEXT_PASS len1, (JREC*)NULL))) {
|
||||
rec->class = suuji_class;
|
||||
rec->hinsi = SUUSI;
|
||||
rec->sttofs = headcode;
|
||||
rec->stbofs = (u_char)stb;
|
||||
rec->flags = flag;
|
||||
rec->numlen = (u_char)len2;
|
||||
|
||||
if(!stb) srch_josuu(SJ4_CONTEXT_PASS rec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
setnrec(SJ4_CONTEXT u_char* p, u_short flag) {
|
||||
setnrec_sub(SJ4_CONTEXT_PASS p, flag, 0);
|
||||
|
||||
if(!headcode && (*p == Y_S_KIGOU2)) {
|
||||
setnrec_sub(SJ4_CONTEXT_PASS p + 1, flag, -1);
|
||||
}
|
||||
}
|
||||
|
||||
static u_char*
|
||||
srchtbl(u_char ch, u_char* tbl, int rec, int n) {
|
||||
int high, low, mid;
|
||||
u_char* p;
|
||||
|
||||
if(!ch) return NULL;
|
||||
|
||||
low = 0;
|
||||
high = n - 1;
|
||||
|
||||
while(low <= high) {
|
||||
mid = (low + high) / 2;
|
||||
p = tbl + mid * rec;
|
||||
|
||||
if(ch == *p)
|
||||
break;
|
||||
|
||||
else if(ch < *p)
|
||||
high = mid - 1;
|
||||
|
||||
else
|
||||
low = mid + 1;
|
||||
}
|
||||
|
||||
if(low > high) return NULL;
|
||||
|
||||
while(mid-- > 0 && ch == *(p - rec)) p -= rec;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static int
|
||||
isconnect(u_char* cnct, int num) {
|
||||
return (cnct[num / 8] & (0x80 >> (num % 8)));
|
||||
}
|
||||
|
||||
static int
|
||||
string_cmp(u_char* s, int l, u_char* d) {
|
||||
u_char* p;
|
||||
|
||||
p = s;
|
||||
|
||||
while(*s && l-- > 0) {
|
||||
if(*s != *d) return 0;
|
||||
s++;
|
||||
d++;
|
||||
}
|
||||
|
||||
return (s - p);
|
||||
}
|
||||
|
||||
static int
|
||||
check_num(SJ4_CONTEXT u_char* ptr) {
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
int tmp;
|
||||
int hketa;
|
||||
int lketa;
|
||||
int flg = FALSE;
|
||||
int cnt;
|
||||
u_short flag;
|
||||
|
||||
memset((u_char*)suuji_wbuf, 0, sizeof(u_short) * NUMWORDBUF);
|
||||
flag = 0;
|
||||
|
||||
hketa = lketa = cnt = 0;
|
||||
for(i = suuji_keta; --i >= 0;) {
|
||||
if(hketa >= 4) return FALSE;
|
||||
tmp = suuji_ubuf[i];
|
||||
if((j = ((tmp >> 6) & 3))) {
|
||||
if(j < hketa) return FALSE;
|
||||
if(j > hketa) {
|
||||
flag |= JFLAG_N01;
|
||||
do {
|
||||
suuji_wbuf[hketa] |= (_NUM0 << (lketa * 4));
|
||||
if(++lketa >= 4) {
|
||||
lketa = 0;
|
||||
hketa++;
|
||||
}
|
||||
} while(j > hketa);
|
||||
}
|
||||
}
|
||||
k = ((tmp >> 4) & 3);
|
||||
if(j || k) {
|
||||
if(k < lketa) return FALSE;
|
||||
if(k > lketa) {
|
||||
flag |= JFLAG_N01;
|
||||
do {
|
||||
suuji_wbuf[hketa] |= (_NUM0 << (lketa * 4));
|
||||
lketa++;
|
||||
} while(k > lketa);
|
||||
}
|
||||
flg = TRUE;
|
||||
}
|
||||
tmp &= 0x0f;
|
||||
suuji_wbuf[hketa] |= (tmp << (lketa * 4));
|
||||
cnt++;
|
||||
|
||||
j = (1 << tmp);
|
||||
if(j & NUMBERS1) flag |= JFLAG_NS1;
|
||||
if(j & NUMBER01) flag |= JFLAG_N01;
|
||||
if(j & NUMBER23) flag |= JFLAG_N23;
|
||||
|
||||
if(tmp != _NUM0) {
|
||||
flg = FALSE;
|
||||
|
||||
switch(lketa) {
|
||||
case 0:
|
||||
if(tmp == _NUM1) flag |= JFLAG_N_1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
flag |= JFLAG_N10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(++lketa >= 4) {
|
||||
lketa = 0;
|
||||
hketa++;
|
||||
}
|
||||
}
|
||||
|
||||
if(flg) return FALSE;
|
||||
|
||||
if(suuji_keta == 1 || tmp != _NUM0) flag |= JFLAG_NN0;
|
||||
|
||||
if(hketa)
|
||||
flag |= (JFLAG_NK4 | JFLAG_NK2);
|
||||
else if(lketa > 1)
|
||||
flag |= JFLAG_NK2;
|
||||
|
||||
if(cnt > 1) flag |= JFLAG_NSN;
|
||||
|
||||
setnrec(SJ4_CONTEXT_PASS ptr, flag);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
srch_number1(SJ4_CONTEXT u_char* ptr) {
|
||||
u_char ch;
|
||||
u_char mode;
|
||||
u_char* p;
|
||||
int l;
|
||||
TypeClass cls;
|
||||
int len;
|
||||
u_char* tptr;
|
||||
|
||||
if(suuji_keta >= NUMKETALENGTH) return;
|
||||
|
||||
if(!(p = srchtbl((ch = *ptr), Suuji_tbl, SJTBLRECLEN, SJTBLRECNUM)))
|
||||
return;
|
||||
|
||||
len = suuji_yptr + MAXCLINPUTLEN - ptr;
|
||||
|
||||
for(; *SjTblYPos(p) == ch; p += SJTBLRECLEN) {
|
||||
if(!(l = string_cmp(SjTblYPos(p), SJTBLYLEN, ptr))) continue;
|
||||
|
||||
if(l > len) continue;
|
||||
|
||||
mode = *SjTblModeP(p);
|
||||
suuji_ubuf[suuji_keta++] = SjTblNumber(mode);
|
||||
tptr = ptr + l;
|
||||
|
||||
switch(suuji_class) {
|
||||
case C_N_ARABIA:
|
||||
if(!(mode & SJTBLNARABIAF)) break;
|
||||
|
||||
check_num(SJ4_CONTEXT_PASS tptr);
|
||||
srch_number1(SJ4_CONTEXT_PASS tptr);
|
||||
srch_kurai2(SJ4_CONTEXT_PASS tptr, (u_char*)NULL);
|
||||
|
||||
break;
|
||||
|
||||
case C_N_SUUJI:
|
||||
if(mode & (SJTBLNARABIAF | SJTBLNYOMIF)) break;
|
||||
|
||||
check_num(SJ4_CONTEXT_PASS tptr);
|
||||
srch_number1(SJ4_CONTEXT_PASS tptr);
|
||||
srch_kurai1(SJ4_CONTEXT_PASS tptr, (u_char*)NULL);
|
||||
srch_kurai2(SJ4_CONTEXT_PASS tptr, (u_char*)NULL);
|
||||
|
||||
break;
|
||||
|
||||
case C_N_KAZU:
|
||||
case C_N_NANSUU:
|
||||
if(mode & SJTBLNNARABIF) break;
|
||||
if(mode & SJTBLNNANSUUF) {
|
||||
cls = suuji_class;
|
||||
suuji_class = C_N_NANSUU;
|
||||
}
|
||||
|
||||
check_num(SJ4_CONTEXT_PASS tptr);
|
||||
srch_kurai1(SJ4_CONTEXT_PASS tptr, SjTblCnctP(p));
|
||||
srch_kurai2(SJ4_CONTEXT_PASS tptr, SjTblCnctP(p));
|
||||
|
||||
if(mode & SJTBLNNANSUUF) suuji_class = cls;
|
||||
break;
|
||||
|
||||
default:
|
||||
if(mode & SJTBLNARABIAF) {
|
||||
suuji_class = C_N_ARABIA;
|
||||
check_num(SJ4_CONTEXT_PASS tptr);
|
||||
srch_number1(SJ4_CONTEXT_PASS tptr);
|
||||
srch_kurai2(SJ4_CONTEXT_PASS tptr, (u_char*)NULL);
|
||||
|
||||
suuji_class = C_N_KAZU;
|
||||
} else if(mode & SJTBLNYOMIF) {
|
||||
if(mode & SJTBLNNANSUUF)
|
||||
suuji_class = C_N_NANSUU;
|
||||
else
|
||||
suuji_class = C_N_KAZU;
|
||||
check_num(SJ4_CONTEXT_PASS tptr);
|
||||
} else if(mode & SJTBLNNARABIF) {
|
||||
suuji_class = C_N_SUUJI;
|
||||
check_num(SJ4_CONTEXT_PASS tptr);
|
||||
srch_number1(SJ4_CONTEXT_PASS tptr);
|
||||
break;
|
||||
} else {
|
||||
suuji_class = C_N_SUUJI;
|
||||
srch_number1(SJ4_CONTEXT_PASS tptr);
|
||||
|
||||
suuji_class = C_N_KAZU;
|
||||
check_num(SJ4_CONTEXT_PASS tptr);
|
||||
}
|
||||
srch_kurai1(SJ4_CONTEXT_PASS tptr, SjTblCnctP(p));
|
||||
srch_kurai2(SJ4_CONTEXT_PASS tptr, SjTblCnctP(p));
|
||||
break;
|
||||
}
|
||||
|
||||
suuji_keta--;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
srch_kurai1(SJ4_CONTEXT u_char* ptr, u_char* cnct) {
|
||||
u_char ch;
|
||||
u_char* p;
|
||||
int l;
|
||||
int keta;
|
||||
int mode;
|
||||
TypeClass cls;
|
||||
int len;
|
||||
u_char* tptr;
|
||||
|
||||
if(!(p = srchtbl((ch = *ptr), Kurai1_tbl, KR1TBLRECLEN, KR1TBLRECNUM)))
|
||||
return;
|
||||
|
||||
len = suuji_yptr + MAXCLINPUTLEN - ptr;
|
||||
|
||||
for(; *Kr1TblYPos(p) == ch; p += KR1TBLRECLEN) {
|
||||
if(!(l = string_cmp(Kr1TblYPos(p), KR1TBLYLEN, ptr))) continue;
|
||||
|
||||
if(l > len) continue;
|
||||
|
||||
mode = *Kr1TblModeP(p);
|
||||
keta = Kr1TblKeta(mode);
|
||||
tptr = ptr + l;
|
||||
|
||||
if(suuji_class != C_N_KAZU && suuji_class != C_N_NANSUU) {
|
||||
cls = suuji_class;
|
||||
suuji_class = (suuji_class == C_N_ARABIA) ? C_N_ARAKURA : C_N_KANKURA;
|
||||
suuji_ubuf[suuji_keta - 1] |= (keta << 4);
|
||||
check_num(SJ4_CONTEXT_PASS tptr);
|
||||
suuji_class = cls;
|
||||
suuji_ubuf[suuji_keta - 1] &= 0xcf;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(cnct) {
|
||||
if(!isconnect(cnct, (int)Kr1TblCnct(mode))) continue;
|
||||
suuji_ubuf[suuji_keta - 1] |= (keta << 4);
|
||||
} else {
|
||||
if(!Kr1TblTop(mode)) continue;
|
||||
if(suuji_keta >= NUMKETALENGTH) continue;
|
||||
suuji_ubuf[suuji_keta++] = (_NUM1 | (keta << 4));
|
||||
}
|
||||
|
||||
check_num(SJ4_CONTEXT_PASS tptr);
|
||||
|
||||
srch_number1(SJ4_CONTEXT_PASS tptr);
|
||||
srch_kurai1(SJ4_CONTEXT_PASS tptr, (u_char*)NULL);
|
||||
srch_kurai2(SJ4_CONTEXT_PASS tptr, Kr1TblCnctP(p));
|
||||
|
||||
if(cnct)
|
||||
suuji_ubuf[suuji_keta - 1] &= 0xcf;
|
||||
else
|
||||
suuji_keta--;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
srch_kurai2(SJ4_CONTEXT u_char* ptr, u_char* cnct) {
|
||||
u_char ch;
|
||||
u_char* p;
|
||||
int l;
|
||||
int keta;
|
||||
int mode;
|
||||
TypeClass cls;
|
||||
int len;
|
||||
u_char* tptr;
|
||||
|
||||
if((suuji_ubuf[0] & 0x0f) == _NUM0) return;
|
||||
|
||||
if(!(p = srchtbl((ch = *ptr), Kurai2_tbl, KR2TBLRECLEN, KR2TBLRECNUM)))
|
||||
return;
|
||||
|
||||
len = suuji_yptr + MAXCLINPUTLEN - ptr;
|
||||
|
||||
for(; *Kr2TblYPos(p) == ch; p += KR2TBLRECLEN) {
|
||||
if(!(l = string_cmp(Kr2TblYPos(p), KR2TBLYLEN, ptr))) continue;
|
||||
|
||||
if(l > len) continue;
|
||||
|
||||
mode = *Kr2TblModeP(p);
|
||||
keta = Kr2TblKeta(mode);
|
||||
tptr = ptr + l;
|
||||
|
||||
if(suuji_class != C_N_KAZU && suuji_class != C_N_NANSUU) {
|
||||
suuji_ubuf[suuji_keta - 1] |= (keta << 6);
|
||||
cls = suuji_class;
|
||||
suuji_class = (suuji_class == C_N_ARABIA) ? C_N_ARAKURA : C_N_KANKURA;
|
||||
check_num(SJ4_CONTEXT_PASS tptr);
|
||||
suuji_class = cls;
|
||||
suuji_ubuf[suuji_keta - 1] &= 0x3f;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(cnct) {
|
||||
if(!isconnect(cnct, (int)Kr2TblCnct(mode))) continue;
|
||||
suuji_ubuf[suuji_keta - 1] |= (keta << 6);
|
||||
} else {
|
||||
if(suuji_keta >= NUMKETALENGTH) continue;
|
||||
suuji_ubuf[suuji_keta++] = (_NUM1 | (keta << 6));
|
||||
}
|
||||
|
||||
check_num(SJ4_CONTEXT_PASS tptr);
|
||||
|
||||
srch_number1(SJ4_CONTEXT_PASS tptr);
|
||||
srch_kurai1(SJ4_CONTEXT_PASS tptr, (u_char*)NULL);
|
||||
|
||||
if(cnct)
|
||||
suuji_ubuf[suuji_keta - 1] &= 0x3f;
|
||||
else
|
||||
suuji_keta--;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
srch_number2(SJ4_CONTEXT u_char* p) {
|
||||
u_char ch;
|
||||
int i;
|
||||
|
||||
suuji_class = (*p == N_0) ? C_N_SUUJILONG : C_N_KAZULONG;
|
||||
|
||||
suuji_keta = suuji_comma = 0;
|
||||
for(i = 0; i < MAXCLINPUTLEN; i++) {
|
||||
if((ch = *p++) == Y_COMMA) {
|
||||
if(suuji_keta) {
|
||||
if(suuji_comma) {
|
||||
if(suuji_comma != 3) break;
|
||||
} else {
|
||||
if(suuji_keta >= 4) break;
|
||||
if(*suuji_yptr == N_0) break;
|
||||
}
|
||||
} else
|
||||
break;
|
||||
|
||||
suuji_comma = 1;
|
||||
ch = *p++;
|
||||
} else if(suuji_comma) {
|
||||
suuji_comma++;
|
||||
}
|
||||
|
||||
if(suuji_comma > 3) break;
|
||||
|
||||
if(!(Chrtbl[ch] & NUMBER)) break;
|
||||
|
||||
if(suuji_keta < NUMKETALENGTH) {
|
||||
suuji_ubuf[suuji_keta] = ch - N_0 + _NUM0;
|
||||
}
|
||||
suuji_keta++;
|
||||
|
||||
if(!suuji_comma && suuji_keta > NUMKETALENGTH) {
|
||||
setnrec(SJ4_CONTEXT_PASS p, 0);
|
||||
} else if(suuji_comma == 3) {
|
||||
if(suuji_keta <= NUMKETALENGTH) {
|
||||
suuji_class = C_N_ARACMA;
|
||||
check_num(SJ4_CONTEXT_PASS p);
|
||||
} else {
|
||||
suuji_class = C_N_KAZULCMA;
|
||||
setnrec(SJ4_CONTEXT_PASS p, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
srchnum_sub(SJ4_CONTEXT u_char* p) {
|
||||
suuji_yptr = p;
|
||||
|
||||
suuji_comma = suuji_keta = 0;
|
||||
suuji_class = 0;
|
||||
srch_number1(SJ4_CONTEXT_PASS p);
|
||||
|
||||
suuji_keta = 0;
|
||||
suuji_class = C_N_KAZU;
|
||||
srch_kurai1(SJ4_CONTEXT_PASS p, (u_char*)NULL);
|
||||
if(suuji_exit) return;
|
||||
|
||||
srch_number2(SJ4_CONTEXT_PASS p);
|
||||
}
|
||||
|
||||
void srchnum(SJ4_CONTEXT2) {
|
||||
suuji_len = suuji_exit = 0;
|
||||
|
||||
srchnum_sub(SJ4_CONTEXT_PASS cnvstart);
|
||||
|
||||
if(!headcode && (*cnvstart == Y_S_KIGOU1)) {
|
||||
headcode = SETTOU_KIGOU;
|
||||
headlen = 1;
|
||||
|
||||
srchnum_sub(SJ4_CONTEXT_PASS cnvstart + 1);
|
||||
|
||||
headcode = headlen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void setwdnum(SJ4_CONTEXT u_char* p, int len, u_short* wd) {
|
||||
suuji_len = (u_char)len;
|
||||
suuji_wkeep = wd;
|
||||
suuji_ukeep = NULL;
|
||||
headcode = headlen = 0;
|
||||
suuji_exit = 0;
|
||||
|
||||
srchnum_sub(SJ4_CONTEXT_PASS p);
|
||||
}
|
||||
|
||||
int setucnum(SJ4_CONTEXT u_char* p, int len, u_char* ud) {
|
||||
suuji_len = (u_char)len;
|
||||
suuji_wkeep = NULL;
|
||||
suuji_ukeep = ud;
|
||||
headcode = headlen = 0;
|
||||
suuji_exit = 0;
|
||||
|
||||
srchnum_sub(SJ4_CONTEXT_PASS p);
|
||||
|
||||
return (int)suuji_exit;
|
||||
}
|
||||
46
lib/sj4core/sstrcmp.c
Normal file
46
lib/sj4core/sstrcmp.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: sstrcmp.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:31 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
int sstrcmp(u_char* src, u_char* dst) {
|
||||
for(; *src; src++, dst++)
|
||||
if(*src != *dst) break;
|
||||
|
||||
return (*src - *dst);
|
||||
}
|
||||
49
lib/sj4core/sstrlen.c
Normal file
49
lib/sj4core/sstrlen.c
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: sstrlen.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:32 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
int sstrlen(u_char* ptr) {
|
||||
u_char* head;
|
||||
|
||||
head = ptr;
|
||||
|
||||
while(*ptr) ptr++;
|
||||
|
||||
return (ptr - head);
|
||||
}
|
||||
58
lib/sj4core/sstrncmp.c
Normal file
58
lib/sj4core/sstrncmp.c
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: sstrncmp.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:33 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
#include "sj_const.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
int sstrncmp(u_char* src, u_char* dst, int len) {
|
||||
|
||||
while(len-- > 0) {
|
||||
|
||||
if(*src > *dst)
|
||||
return CONT;
|
||||
|
||||
if(*src < *dst) {
|
||||
if(!*src) return PARTLY;
|
||||
return OVER;
|
||||
}
|
||||
src++;
|
||||
dst++;
|
||||
}
|
||||
|
||||
return MATCH;
|
||||
}
|
||||
157
lib/sj4core/stbtbl.c
Normal file
157
lib/sj4core/stbtbl.c
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: stbtbl.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:34 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
#include "sj_yomi.h"
|
||||
#include "sj_hinsi.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static u_char name_stb[] = {
|
||||
0x22, MEISI_1, _KU, _NN,
|
||||
0xb7, 0xaf,
|
||||
0x22, MEISI_1, _SA, _MA,
|
||||
0xcd, 0xcd,
|
||||
0x24, MEISI_1, _SA, _NN,
|
||||
0xa4, 0xb5, 0xa4, 0xf3,
|
||||
0x12, MEISI_1, _SI,
|
||||
0xbb, 0xe1,
|
||||
0x36, MEISI_1, _TI, _XYA, _NN,
|
||||
0xa4, 0xc1, 0xa4, 0xe3, 0xa4, 0xf3,
|
||||
0x22, MEISI_1, _DO, _NO,
|
||||
0xc5, 0xc2,
|
||||
0x00};
|
||||
|
||||
static u_char timei_stb[] = {
|
||||
0x22, MEISI_1, _E, _KI,
|
||||
0xb1, 0xd8,
|
||||
0x44, MEISI_1, _E, _KI, _HA, _TU,
|
||||
0xb1, 0xd8, 0xc8, 0xaf,
|
||||
0x44, MEISI_1, _E, _KI, _YU, _KI,
|
||||
0xb1, 0xd8, 0xb9, 0xd4,
|
||||
0x22, MEISI_1, _GU, _NN,
|
||||
0xb7, 0xb4,
|
||||
0x12, MEISI_1, _SI,
|
||||
0xbb, 0xd4,
|
||||
0x32, MEISI_1, _TI, _XYO, _U,
|
||||
0xc4, 0xae,
|
||||
0x22, MEISI_1, _HA, _TU,
|
||||
0xc8, 0xaf,
|
||||
0x22, MEISI_1, _MA, _TI,
|
||||
0xc4, 0xae,
|
||||
0x22, MEISI_1, _MU, _RA,
|
||||
0xc2, 0xbc,
|
||||
0x00};
|
||||
|
||||
static u_char meisi_stb[] = {
|
||||
0x44, MEISI_6, _A, _TU, _KA, _I,
|
||||
0xb0, 0xb7, 0xa4, 0xa4,
|
||||
0x1a, MEISI_6, _KA,
|
||||
0xb2, 0xbd,
|
||||
0x22, MEISI_8, _TE, _KI,
|
||||
0xc5, 0xaa,
|
||||
0x56, FUKUSI_1, _NI, _TO, _MO, _NA, _I,
|
||||
0xa4, 0xcb, 0xc8, 0xbc, 0xa4, 0xa4,
|
||||
0x56, FUKUSI_1, _NI, _TO, _MO, _NA, _U,
|
||||
0xa4, 0xcb, 0xc8, 0xbc, 0xa4, 0xa6,
|
||||
0x22, MEISI_8, _HU, _U,
|
||||
0xc9, 0xf7,
|
||||
0x00};
|
||||
|
||||
static u_char sahen_stb[] = {
|
||||
0x44, MEISI_6, _A, _TU, _KA, _I,
|
||||
0xb0, 0xb7, 0xa4, 0xa4,
|
||||
0x1a, MEISI_6, _KA,
|
||||
0xb2, 0xbd,
|
||||
0x12, MEISI_11, _GO,
|
||||
0xb8, 0xe5,
|
||||
0x22, MEISI_11, _GO, _TO,
|
||||
0xcb, 0xe8,
|
||||
0x32, MEISI_11, _ZI, _XYO, _U,
|
||||
0xbe, 0xe5,
|
||||
0x32, MEISI_11, _TI, _XYU, _U,
|
||||
0xc3, 0xe6,
|
||||
0x22, MEISI_8, _TE, _KI,
|
||||
0xc5, 0xaa,
|
||||
0x56, FUKUSI_1, _NI, _TO, _MO, _NA, _I,
|
||||
0xa4, 0xcb, 0xc8, 0xbc, 0xa4, 0xa4,
|
||||
0x56, FUKUSI_1, _NI, _TO, _MO, _NA, _U,
|
||||
0xa4, 0xcb, 0xc8, 0xbc, 0xa4, 0xa6,
|
||||
0x22, MEISI_8, _HU, _U,
|
||||
0xc9, 0xf7,
|
||||
0x22, MEISI_11, _MA, _E,
|
||||
0xc1, 0xb0,
|
||||
0x00};
|
||||
|
||||
static u_char human_stb[] = {
|
||||
0x24, MEISI_1, _SA, _NN,
|
||||
0xa4, 0xb5, 0xa4, 0xf3,
|
||||
0x00};
|
||||
|
||||
static u_char ippan_stb[] = {
|
||||
0x56, FUKUSI_1, _NI, _TO, _MO, _NA, _I,
|
||||
0xa4, 0xcb, 0xc8, 0xbc, 0xa4, 0xa4,
|
||||
0x56, FUKUSI_1, _NI, _TO, _MO, _NA, _U,
|
||||
0xa4, 0xcb, 0xc8, 0xbc, 0xa4, 0xa6,
|
||||
0x00};
|
||||
|
||||
u_char* stbadr[] = {
|
||||
0,
|
||||
ippan_stb,
|
||||
ippan_stb,
|
||||
ippan_stb,
|
||||
meisi_stb,
|
||||
sahen_stb,
|
||||
sahen_stb,
|
||||
sahen_stb,
|
||||
meisi_stb,
|
||||
meisi_stb,
|
||||
meisi_stb,
|
||||
ippan_stb,
|
||||
ippan_stb,
|
||||
human_stb,
|
||||
ippan_stb,
|
||||
ippan_stb,
|
||||
ippan_stb,
|
||||
ippan_stb,
|
||||
ippan_stb,
|
||||
0,
|
||||
0,
|
||||
name_stb,
|
||||
name_stb,
|
||||
0,
|
||||
timei_stb,
|
||||
};
|
||||
71
lib/sj4core/stttbl.c
Normal file
71
lib/sj4core/stttbl.c
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: stttbl.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:37 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
static u_char o_settou[] = {
|
||||
0xA1, 0xb8, 0xe6, 0xa4, 0xaa};
|
||||
|
||||
static u_char go_settou[] = {
|
||||
0xA1, 0xb8, 0xe6, 0xa4, 0xb4};
|
||||
|
||||
static u_char dai_settou[] = {
|
||||
0x22, 0xc2, 0xe8, 0xc2, 0xe8};
|
||||
|
||||
static u_char kigou_settou[] = {
|
||||
0x01};
|
||||
|
||||
u_char* settou_ptr[] = {
|
||||
NULL, o_settou, go_settou, dai_settou, kigou_settou};
|
||||
|
||||
u_char scncttbl[2][24] = {
|
||||
{
|
||||
|
||||
0x48, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x18, 0x18, 0x00, 0x00, 0x1f, 0xf0, 0x00, 0xff,
|
||||
|
||||
0x00, 0x1f, 0xf0, 0x00, 0xff, 0x00, 0x00, 0x00},
|
||||
|
||||
{
|
||||
|
||||
0x22, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
|
||||
182
lib/sj4core/study.c
Normal file
182
lib/sj4core/study.c
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: study.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:38 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
int study(SJ4_CONTEXT STDYOUT* stdy) {
|
||||
STDYOUT outp;
|
||||
STDYIN* p1;
|
||||
STDYIN* p2;
|
||||
int wcnt;
|
||||
int ret;
|
||||
TypeDicSeg seg;
|
||||
TypeDicOfs ofs;
|
||||
TypeStyNum nm;
|
||||
TypeStyNum wi;
|
||||
|
||||
if(!StudyExist()) return STUDYNODICT;
|
||||
|
||||
memcpy((u_char*)&outp, (u_char*)stdy, sizeof(outp));
|
||||
|
||||
if(outp.stdy1.offset == 0) return STUDYNOTSTUDY;
|
||||
|
||||
p1 = srchstdy(SJ4_CONTEXT_PASS outp.stdy1.seg, outp.stdy1.offset, outp.stdy1.dicid);
|
||||
if(p1) {
|
||||
nm = p1->styno;
|
||||
|
||||
for(wcnt = STUDYCOUNT, p2 = STUDYDICT; wcnt--; p2++) {
|
||||
if(p2->styno < nm) p2->styno++;
|
||||
}
|
||||
|
||||
p1->styno = 1;
|
||||
|
||||
if(outp.sttfg) p1->sttkj = outp.stdy1.sttkj;
|
||||
if(outp.ka_fg) p1->ka_kj = outp.stdy1.ka_kj;
|
||||
|
||||
p1->nmflg = outp.stdy1.nmflg;
|
||||
|
||||
putstydic(SJ4_CONTEXT_PASS2);
|
||||
|
||||
return STUDYNORMEND;
|
||||
}
|
||||
|
||||
if(STUDYCOUNT >= STUDYMAX) {
|
||||
|
||||
p1 = STUDYDICT;
|
||||
p2 = NULL;
|
||||
wi = 0;
|
||||
for(wcnt = STUDYMAX; wcnt--; p1++) {
|
||||
if((nm = p1->styno + 1) > wi) {
|
||||
wi = nm;
|
||||
p2 = p1;
|
||||
}
|
||||
|
||||
p1->styno = nm;
|
||||
}
|
||||
|
||||
if(p2) {
|
||||
mvmemi((u_char*)(p2 + 1), (u_char*)p2,
|
||||
(STUDYTAIL - p2) * STUDYRECSIZE);
|
||||
STUDYCOUNT -= 1;
|
||||
} else
|
||||
return STUDYERROR;
|
||||
|
||||
ret = STUDYFULLAREA;
|
||||
} else {
|
||||
p1 = STUDYDICT;
|
||||
for(wcnt = STUDYCOUNT; wcnt--; p1++) p1->styno++;
|
||||
|
||||
ret = STUDYNORMEND;
|
||||
}
|
||||
|
||||
p1 = STUDYDICT;
|
||||
seg = outp.stdy1.seg;
|
||||
for(wcnt = STUDYCOUNT; wcnt && (p1->seg < seg);) {
|
||||
wcnt--;
|
||||
p1++;
|
||||
}
|
||||
|
||||
ofs = outp.stdy1.offset;
|
||||
while(wcnt-- && (p1->seg == seg)) {
|
||||
if(p1->offset > ofs) break;
|
||||
p1++;
|
||||
}
|
||||
|
||||
mvmemd((u_char*)(STUDYTAIL - 1), (u_char*)STUDYTAIL,
|
||||
(u_char*)(STUDYTAIL - 1) - (u_char*)p1);
|
||||
p1->offset = outp.stdy1.offset;
|
||||
p1->seg = outp.stdy1.seg;
|
||||
p1->dicid = outp.stdy1.dicid;
|
||||
p1->styno = 1;
|
||||
p1->sttkj = (outp.sttfg) ? outp.stdy1.sttkj : 0;
|
||||
p1->ka_kj = (outp.ka_fg) ? outp.stdy1.ka_kj : 0;
|
||||
p1->nmflg = outp.stdy1.nmflg;
|
||||
STUDYCOUNT += 1;
|
||||
|
||||
putstydic(SJ4_CONTEXT_PASS2);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
STDYIN*
|
||||
srchstdy(SJ4_CONTEXT TypeDicSeg seg, TypeDicOfs ofs, TypeDicID dicid) {
|
||||
int high;
|
||||
int mid;
|
||||
int low;
|
||||
STDYIN* ptr;
|
||||
|
||||
if(!StudyExist()) return NULL;
|
||||
|
||||
if(!STUDYCOUNT || !ofs) return NULL;
|
||||
|
||||
low = 0;
|
||||
high = STUDYCOUNT - 1;
|
||||
|
||||
for(;;) {
|
||||
mid = ((low + high) >> 1);
|
||||
|
||||
if(STUDYDICT[mid].seg > seg)
|
||||
high = mid - 1;
|
||||
|
||||
else if(STUDYDICT[mid].seg < seg)
|
||||
low = mid + 1;
|
||||
|
||||
else
|
||||
break;
|
||||
|
||||
if(low > high) return NULL;
|
||||
}
|
||||
|
||||
low = mid + 1;
|
||||
ptr = &STUDYDICT[mid];
|
||||
while(ptr->seg == seg) {
|
||||
if(ptr->offset < ofs) break;
|
||||
if(ptr->dicid == dicid && ptr->offset == ofs) return ptr;
|
||||
if(!mid--) break;
|
||||
ptr--;
|
||||
}
|
||||
|
||||
ptr = &STUDYDICT[low];
|
||||
mid = STUDYCOUNT - low;
|
||||
while(mid-- && ptr->seg == seg) {
|
||||
if(ptr->offset > ofs) break;
|
||||
if(ptr->dicid == dicid && ptr->offset == ofs) return ptr;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
166
lib/sj4core/suujitbl.c
Normal file
166
lib/sj4core/suujitbl.c
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: suujitbl.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:39 $
|
||||
*/
|
||||
|
||||
#include "sj_const.h"
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
#include "sj_yomi.h"
|
||||
#include "sj_suuji.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
#define NA SJTBLNARABIAF
|
||||
#define NY SJTBLNYOMIF
|
||||
#define NN SJTBLNNARABIF
|
||||
#define NS SJTBLNNANSUUF
|
||||
|
||||
u_char suuji_tbl[] = {
|
||||
N_0, _NIL, _NIL, _NUM0 | NA, 0x00, 0x00,
|
||||
N_1, _NIL, _NIL, _NUM1 | NA, 0xec, 0x07,
|
||||
N_2, _NIL, _NIL, _NUM2 | NA, 0xec, 0x07,
|
||||
N_3, _NIL, _NIL, _NUM3 | NA, 0xff, 0x07,
|
||||
N_4, _NIL, _NIL, _NUM4 | NA, 0xec, 0x07,
|
||||
N_5, _NIL, _NIL, _NUM5 | NA, 0xec, 0x07,
|
||||
N_6, _NIL, _NIL, _NUM6 | NA, 0xec, 0xc7,
|
||||
N_7, _NIL, _NIL, _NUM7 | NA, 0xec, 0x07,
|
||||
N_8, _NIL, _NIL, _NUM8 | NA, 0xec, 0xc7,
|
||||
N_9, _NIL, _NIL, _NUM9 | NA, 0xec, 0x07,
|
||||
_I, _TI, _NIL, _NUM1, 0x00, 0x05,
|
||||
_I, _XTU, _NIL, _NUM1S | NY, 0x20, 0x02,
|
||||
_KI, _XYU, _U, _NUM9, 0xec, 0x07,
|
||||
_KU, _NIL, _NIL, _NUM9 | NY, 0x00, 0x00,
|
||||
_GO, _NIL, _NIL, _NUM5, 0xec, 0x07,
|
||||
_GO, _U, _NIL, _NUM5 | NN, 0x00, 0x00,
|
||||
_SA, _NN, _NIL, _NUM3, 0xd3, 0x07,
|
||||
_SI, _NIL, _NIL, _NUM4 | NY, 0x80, 0x00,
|
||||
_SI, _I, _NIL, _NUM4 | NN, 0x00, 0x00,
|
||||
_SI, _TI, _NIL, _NUM7, 0xec, 0x07,
|
||||
_SU, _U, _NIL, _NUMS | NY | NS, 0xec, 0x07,
|
||||
_ZE, _RO, _NIL, _NUM0 | NN, 0x00, 0x00,
|
||||
_NA, _NA, _NIL, _NUM7, 0xec, 0x07,
|
||||
_NA, _NN, _NIL, _NUMN | NY | NS, 0xf3, 0x07,
|
||||
_NI, _NIL, _NIL, _NUM2, 0xec, 0x07,
|
||||
_NI, _I, _NIL, _NUM2 | NN, 0x00, 0x00,
|
||||
_HA, _TI, _NIL, _NUM8, 0xc0, 0x05,
|
||||
_HA, _XTU, _NIL, _NUM8 | NY, 0x20, 0xc2,
|
||||
_MA, _RU, _NIL, _NUM0 | NN, 0x00, 0x00,
|
||||
_YO, _NIL, _NIL, _NUM4 | NY, 0x00, 0x00,
|
||||
_YO, _NN, _NIL, _NUM4, 0xec, 0x07,
|
||||
_RE, _I, _NIL, _NUM0 | NN, 0xec, 0x00,
|
||||
_RO, _KU, _NIL, _NUM6, 0xe0, 0x07,
|
||||
_RO, _XTU, _NIL, _NUM6 | NY, 0x00, 0xc2,
|
||||
0};
|
||||
|
||||
u_char kurai1_tbl[] = {
|
||||
_ZI, _XYU, _U, (1 << 4) + 0 + KR1TBLTOPF, 0x05,
|
||||
_ZI, _XYU, _XTU, (1 << 4) + 1 + KR1TBLTOPF, 0x02,
|
||||
_SE, _NN, _NIL, (3 << 4) + 2 + KR1TBLTOPF, 0x07,
|
||||
_ZE, _NN, _NIL, (3 << 4) + 3, 0x05,
|
||||
_HI, _XYA, _KU, (2 << 4) + 4 + KR1TBLTOPF, 0x07,
|
||||
_HI, _XYA, _XTU, (2 << 4) + 5 + KR1TBLTOPF, 0x02,
|
||||
_BI, _XYA, _KU, (2 << 4) + 6, 0x07,
|
||||
_BI, _XYA, _XTU, (2 << 4) + 7, 0x00,
|
||||
_PI, _XYA, _KU, (2 << 4) + 8, 0x07,
|
||||
_PI, _XYA, _XTU, (2 << 4) + 9, 0x00,
|
||||
0};
|
||||
|
||||
u_char kurai2_tbl[] = {
|
||||
_O, _KU, _NIL, (2 << 4) + 13,
|
||||
_TI, _XYO, _U, (3 << 4) + 14,
|
||||
_MA, _NN, _NIL, (1 << 4) + 15,
|
||||
0};
|
||||
|
||||
u_char num1tbl[] = {
|
||||
0xa3, 0xb0,
|
||||
0xa3, 0xb1,
|
||||
0xa3, 0xb2,
|
||||
0xa3, 0xb3,
|
||||
0xa3, 0xb4,
|
||||
0xa3, 0xb5,
|
||||
0xa3, 0xb6,
|
||||
0xa3, 0xb7,
|
||||
0xa3, 0xb8,
|
||||
0xa3, 0xb9,
|
||||
0xa3, 0xb1,
|
||||
0xbf, 0xf4,
|
||||
0xb2, 0xbf};
|
||||
|
||||
u_char num2tbl[] = {
|
||||
0xa1, 0xbb,
|
||||
0xb0, 0xec,
|
||||
0xc6, 0xf3,
|
||||
0xbb, 0xb0,
|
||||
0xbb, 0xcd,
|
||||
0xb8, 0xde,
|
||||
0xcf, 0xbb,
|
||||
0xbc, 0xb7,
|
||||
0xc8, 0xac,
|
||||
0xb6, 0xe5,
|
||||
0xb0, 0xec,
|
||||
0xbf, 0xf4,
|
||||
0xb2, 0xbf};
|
||||
|
||||
u_char num3tbl[] = {
|
||||
0xce, 0xed,
|
||||
0xb0, 0xed,
|
||||
0xc6, 0xf5,
|
||||
0xbb, 0xb2,
|
||||
0xbb, 0xcd,
|
||||
0xb8, 0xde,
|
||||
0xcf, 0xbb,
|
||||
0xbc, 0xb7,
|
||||
0xc8, 0xac,
|
||||
0xb6, 0xe5,
|
||||
0xb0, 0xed,
|
||||
0xbf, 0xf4,
|
||||
0xb2, 0xbf};
|
||||
|
||||
u_char num4tbl[] = {
|
||||
0xc0, 0xe9,
|
||||
0xc9, 0xb4,
|
||||
0xbd, 0xbd,
|
||||
0};
|
||||
|
||||
u_char num5tbl[] = {
|
||||
0xc0, 0xe9,
|
||||
0xc9, 0xb4,
|
||||
0xbd, 0xa6,
|
||||
0};
|
||||
|
||||
u_char num6tbl[] = {
|
||||
0xc3, 0xfb,
|
||||
0xb2, 0xaf,
|
||||
0xcb, 0xfc,
|
||||
0};
|
||||
65
lib/sj4core/terminat.c
Normal file
65
lib/sj4core/terminat.c
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: terminat.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:40 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_right.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
int terminate(SJ4_CONTEXT TypeCnct right, u_char* yomi) {
|
||||
u_char ch;
|
||||
|
||||
if((yomi > cnvstart) && (Chrtbl[*(yomi - 1)] & NUMBER))
|
||||
return TRUE;
|
||||
|
||||
ch = *yomi;
|
||||
if(Termtbl[right] & T_SHUUJO) {
|
||||
|
||||
if(!ch) return TRUE;
|
||||
|
||||
if(Chrtbl[ch] & FZKTOP) return FALSE;
|
||||
|
||||
if(!isdpnd(ch)) return SHU;
|
||||
}
|
||||
|
||||
if(Termtbl[right] & T_KANOU) {
|
||||
|
||||
if(ch && (Chrtbl[ch] & FZKTOP)) return FALSE;
|
||||
|
||||
if(!isdpnd(ch)) return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
324
lib/sj4core/termtbl.c
Normal file
324
lib/sj4core/termtbl.c
Normal file
|
|
@ -0,0 +1,324 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: termtbl.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:42 $
|
||||
*/
|
||||
|
||||
#include "sj_rename.h"
|
||||
#include "sj_typedef.h"
|
||||
#include "sj_const.h"
|
||||
#include "sj_prty.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
u_char termtbl[] = {
|
||||
0,
|
||||
T_KANOU + P_JOSHI_B,
|
||||
T_KANOU + P_JOSHI_A,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_B,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_B,
|
||||
T_KANOU + 8,
|
||||
T_KANOU + P_JOSHI_B,
|
||||
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_B,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_E,
|
||||
T_KANOU + P_JOSHI_B,
|
||||
0 + P_FUKA,
|
||||
0 + P_FUKA,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
0 + P_FUKA,
|
||||
T_KANOU + P_RENYOU_J,
|
||||
T_KANOU + P_RENYOU_J,
|
||||
T_KANOU + P_RENYOU_J,
|
||||
T_KANOU + P_RENYOU_J,
|
||||
|
||||
T_KANOU + P_RENYOU_M,
|
||||
T_KANOU + P_RENYOU_M,
|
||||
T_KANOU + P_RENYOU_M,
|
||||
T_KANOU + P_RENYOU_M,
|
||||
T_KANOU + P_RENYOU_M,
|
||||
T_KANOU + P_RENYOU_M,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
T_KANOU + P_RENYOU_J,
|
||||
|
||||
T_KANOU + P_JOSHI_B,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_RENYOU_J,
|
||||
0 + P_FUKA,
|
||||
0 + P_FUKA,
|
||||
0 + P_FUKA,
|
||||
0 + P_FUKA,
|
||||
0 + P_FUKA,
|
||||
0 + P_FUKA,
|
||||
0 + P_FUKA,
|
||||
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
0 + P_FUKA,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_SHUUJO + P_SHUUSI,
|
||||
T_KANOU + P_SHUUSI,
|
||||
T_KANOU + P_SHUUSI,
|
||||
T_KANOU + P_SHUUSI,
|
||||
T_KANOU + P_SHUUSI,
|
||||
T_KANOU + P_SHUUSI,
|
||||
|
||||
T_KANOU + P_SHUUSI,
|
||||
T_KANOU + P_SHUUSI,
|
||||
T_KANOU + RENTAI + 8,
|
||||
T_KANOU + RENTAI + 10,
|
||||
T_KANOU + RENTAI + 7,
|
||||
T_KANOU + P_SHUUSI,
|
||||
T_KANOU + RENTAI + 7,
|
||||
T_KANOU + RENTAI + 6,
|
||||
T_KANOU + P_SHUUSI,
|
||||
T_KANOU + RENTAI + 7,
|
||||
|
||||
T_KANOU + RENTAI + 6,
|
||||
T_KANOU + RENTAI + 6,
|
||||
T_SHUUJO + RENTAI + 6,
|
||||
T_KANOU + RENTAI + 6,
|
||||
T_KANOU + RENTAI + 7,
|
||||
T_KANOU + RENTAI + 6,
|
||||
T_KANOU + RENTAI + 6,
|
||||
T_KANOU + RENTAI + 6,
|
||||
T_KANOU + RENTAI + 6,
|
||||
T_KANOU + RENTAI + 6,
|
||||
|
||||
0 + P_FUKA,
|
||||
T_KANOU + RENTAI + 6,
|
||||
0 + P_FUKA,
|
||||
T_KANOU + 3,
|
||||
0 + P_FUKA,
|
||||
0 + P_FUKA,
|
||||
T_KANOU + P_KAMEI,
|
||||
T_KANOU + P_MEIREI,
|
||||
T_KANOU + P_MEIREI,
|
||||
T_SHUUJO + P_MEIREI,
|
||||
T_SHUUJO + P_MEIREI,
|
||||
|
||||
T_KANOU + P_MEISI,
|
||||
0 + P_FUKA,
|
||||
T_KANOU + P_FUKA,
|
||||
T_KANOU + P_MEISI,
|
||||
T_KANOU + P_DAIMEISI,
|
||||
T_KANOU + P_DAIMEISI,
|
||||
T_KANOU + P_MEISI,
|
||||
T_KANOU + P_JOSHI_D,
|
||||
T_KANOU + P_JOSHI_E,
|
||||
|
||||
T_KANOU + P_SHUUSI,
|
||||
T_KANOU + P_DAIMEISI,
|
||||
T_KANOU + P_FUKUSI,
|
||||
T_KANOU + P_FUKUSI,
|
||||
T_KANOU + P_SHUUSI,
|
||||
0 + P_FUKA,
|
||||
T_KANOU + P_DAIMEISI,
|
||||
T_KANOU + 7,
|
||||
0 + P_FUKA,
|
||||
T_SHUUJO + P_JOSHI_E,
|
||||
|
||||
T_KANOU + P_JOSHI_B,
|
||||
T_KANOU + P_JOSHI_A,
|
||||
T_KANOU + P_MEISI,
|
||||
T_KANOU + P_JOSHI_B,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_F_FUKUSI,
|
||||
0,
|
||||
T_KANOU + P_JOSHI_F,
|
||||
0,
|
||||
0,
|
||||
|
||||
0 + P_FUKA,
|
||||
0 + P_FUKA,
|
||||
0 + P_FUKA,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
T_KANOU + P_RENYOU_J,
|
||||
T_KANOU + P_RENYOU_F,
|
||||
0 + P_FUKA,
|
||||
T_KANOU + P_SHUUSI,
|
||||
T_KANOU + P_SHUUSI,
|
||||
T_KANOU + P_SHUUSI,
|
||||
|
||||
T_KANOU + P_SHUUSI,
|
||||
0 + P_FUKA,
|
||||
0 + P_FUKA,
|
||||
0 + P_FUKA,
|
||||
T_SHUUJO + P_SHUUSI,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + 1,
|
||||
T_KANOU + P_JOSHI_F,
|
||||
T_KANOU + P_JOSHI_F,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_JOSHI_F,
|
||||
T_KANOU + P_SHUUSI,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_B,
|
||||
T_KANOU + P_JOSHI_D,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_JOSHI_D,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_B,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_JOSHI_D,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_KEISIKI,
|
||||
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_B,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_D,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_KEISIKI,
|
||||
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_D,
|
||||
T_KANOU + P_JOSHI_D,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
|
||||
T_SHUUJO + P_SHUUSI,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_KEISIKI,
|
||||
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_B,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_JOSHI_B,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_JOSHI_C,
|
||||
T_KANOU + P_KEISIKI,
|
||||
T_KANOU + P_KEISIKI,
|
||||
|
||||
0 + P_JOSHI_C,
|
||||
T_KANOU + P_SUUSI,
|
||||
T_KANOU + P_SETUZOKU,
|
||||
T_KANOU + P_KANDOU,
|
||||
T_KANOU + P_SETTOU,
|
||||
T_KANOU + P_FUKUSI,
|
||||
T_KANOU + P_FZKKGU,
|
||||
T_KANOU + P_MEISI,
|
||||
T_KANOU + P_MEISI,
|
||||
T_KANOU + P_MEISI,
|
||||
|
||||
T_KANOU + P_MEISI,
|
||||
0 + P_SETUBI,
|
||||
T_KANOU + P_SETUBI,
|
||||
T_KANOU + P_JOSUUSI,
|
||||
T_KANOU + P_RENTAISI,
|
||||
T_KANOU + P_TANKAN};
|
||||
125
lib/sj4core/wakachi.c
Normal file
125
lib/sj4core/wakachi.c
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* Copyright (c) 1991-1994 Sony Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of Sony Corporation
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* from Sony Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: wakachi.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:02:43 $
|
||||
*/
|
||||
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_right.h"
|
||||
#include "sj_hinsi.h"
|
||||
|
||||
#include "sj_kanakan.h"
|
||||
|
||||
void wakachi(SJ4_CONTEXT2) {
|
||||
JREC* jrec;
|
||||
CLREC* clrec;
|
||||
|
||||
CREC crec[4];
|
||||
int count;
|
||||
u_char* next;
|
||||
TypeCnct right;
|
||||
int i;
|
||||
int maxlen;
|
||||
|
||||
free_jall(SJ4_CONTEXT_PASS maxjptr);
|
||||
maxjptr = NULL;
|
||||
|
||||
maxlen = (cnvlen > MAXCLINPUTLEN) ? MAXCLINPUTLEN : cnvlen;
|
||||
|
||||
next = cnvstart;
|
||||
if(Chrtbl[*next] & (TAI_KGU | FZK_KGU)) {
|
||||
|
||||
while(*next && (Chrtbl[*next] & (TAI_KGU | FZK_KGU)))
|
||||
next++;
|
||||
|
||||
if((i = next - cnvstart) > maxlen) {
|
||||
next = cnvstart + maxlen;
|
||||
i = maxlen;
|
||||
}
|
||||
|
||||
if(!(jrec = argjrec(SJ4_CONTEXT_PASS i, (JREC*)NULL))) return;
|
||||
|
||||
jrec->class = C_WAKACHI;
|
||||
jrec->hinsi = D_MEISI_1;
|
||||
|
||||
if(Chrtbl[*(next - 1)] & TAI_KGU)
|
||||
srchfzk(SJ4_CONTEXT_PASS jrec, next, R_DAIMEISI, 0);
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
if(!(jrec = argjrec(SJ4_CONTEXT_PASS 0, (JREC*)NULL))) return;
|
||||
jrec->class = C_WAKACHI;
|
||||
jrec->hinsi = MEISI_6;
|
||||
|
||||
while((int)jrec->jlen < maxlen) {
|
||||
|
||||
count = setconj(SJ4_CONTEXT_PASS(TypeGram) MEISI_6, jrec, crec);
|
||||
|
||||
for(i = count; i-- > 0;) {
|
||||
|
||||
right = crec[i].right;
|
||||
gobilen = crec[i].len;
|
||||
next = cnvstart + jrec->jlen + gobilen;
|
||||
|
||||
if(gobilen) {
|
||||
if(terminate(SJ4_CONTEXT_PASS right, next)) {
|
||||
fzk_ka_flg = 0;
|
||||
setclrec(SJ4_CONTEXT_PASS jrec, next, right);
|
||||
}
|
||||
} else if((Chrtbl[*next] & NUMBER) && (jrec->jlen)) {
|
||||
fzk_ka_flg = 0;
|
||||
setclrec(SJ4_CONTEXT_PASS jrec, next, right);
|
||||
return;
|
||||
}
|
||||
|
||||
srchfzk(SJ4_CONTEXT_PASS jrec, next, right, 0);
|
||||
}
|
||||
|
||||
if(maxclptr) break;
|
||||
|
||||
(jrec->jlen)++;
|
||||
}
|
||||
}
|
||||
|
||||
if((maxclptr) && (Chrtbl[*(cnvstart + jrec->jlen)] & FZKTOP))
|
||||
return;
|
||||
|
||||
if(jrec->jlen) {
|
||||
if((clrec = argclrec(SJ4_CONTEXT_PASS(int) jrec->jlen))) {
|
||||
clrec->jnode = jrec;
|
||||
clrec->right = R_MEISI;
|
||||
clrec->kubun = K_TAIGEN;
|
||||
(jrec->count)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue