2008-01-11 11:57:08 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 1991-1994 Sony Corporation
|
2026-06-19 01:49:53 +09:00
|
|
|
*
|
2008-01-11 11:57:08 +00:00
|
|
|
* 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:
|
2026-06-19 01:49:53 +09:00
|
|
|
*
|
2008-01-11 11:57:08 +00:00
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
|
* included in all copies or substantial portions of the Software.
|
2026-06-19 01:49:53 +09:00
|
|
|
*
|
2008-01-11 11:57:08 +00:00
|
|
|
* 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.
|
2026-06-19 01:49:53 +09:00
|
|
|
*
|
2008-01-11 11:57:08 +00:00
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
2026-06-19 01:49:53 +09:00
|
|
|
* $SonyRCSfile: mkjiritu.c,v $
|
|
|
|
|
* $SonyRevision: 1.1 $
|
2008-01-11 11:57:08 +00:00
|
|
|
* $SonyDate: 1994/06/03 08:02:03 $
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include "sj_kcnv.h"
|
|
|
|
|
|
|
|
|
|
#include "sj_kanakan.h"
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
static void dic_mu(), dic_cl();
|
2008-01-11 11:57:08 +00:00
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
void mkjiritu(int mode) {
|
2008-01-11 11:57:08 +00:00
|
|
|
u_char chkind1;
|
|
|
|
|
u_char chkind2;
|
2026-06-19 01:49:53 +09:00
|
|
|
JREC* jrec;
|
|
|
|
|
u_char* stb;
|
2008-01-11 11:57:08 +00:00
|
|
|
|
|
|
|
|
headcode = headlen = 0;
|
|
|
|
|
|
|
|
|
|
maxjptr = NULL;
|
|
|
|
|
|
|
|
|
|
chkind1 = Chrtbl[*cnvstart];
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(chkind1 & DICTOP) {
|
2008-01-11 11:57:08 +00:00
|
|
|
dic_mu(mode);
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(mode & DO_CLSTUDY) dic_cl();
|
2008-01-11 11:57:08 +00:00
|
|
|
|
|
|
|
|
srchnum();
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(srchhead() && cnvlen != headlen) {
|
2008-01-11 11:57:08 +00:00
|
|
|
cnvstart += headlen;
|
|
|
|
|
cnvlen -= headlen;
|
|
|
|
|
|
|
|
|
|
chkind2 = Chrtbl[*cnvstart];
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(chkind2 & DICTOP) {
|
2008-01-11 11:57:08 +00:00
|
|
|
dic_mu(mode);
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(headcode == SETTOU_DAI) {
|
2008-01-11 11:57:08 +00:00
|
|
|
srchnum();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cnvstart -= headlen;
|
|
|
|
|
cnvlen += headlen;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
for(jrec = maxjptr; jrec; jrec = jrec->jsort) {
|
|
|
|
|
if(stb = getstb(jrec->hinsi))
|
2008-01-11 11:57:08 +00:00
|
|
|
setubi(jrec, stb);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2026-06-19 01:49:53 +09:00
|
|
|
dic_mu(int mode) {
|
|
|
|
|
u_char* tagp;
|
|
|
|
|
DICTL* dp;
|
|
|
|
|
|
|
|
|
|
for(dp = dictlist; dp; dp = dp->next) {
|
|
|
|
|
curdict = dp->dict;
|
|
|
|
|
dicinl = 1;
|
2008-01-11 11:57:08 +00:00
|
|
|
dicsaml = 0;
|
|
|
|
|
prevseg = -1;
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
while(tagp = srchdict(tagp)) setjrec(tagp, mode);
|
2008-01-11 11:57:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
JREC* argjrec(int len, JREC* rec) {
|
|
|
|
|
JREC* ptr;
|
|
|
|
|
JREC* jrec;
|
|
|
|
|
JREC* child;
|
2008-01-11 11:57:08 +00:00
|
|
|
|
|
|
|
|
jrec = alloc_jrec();
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(!jrec) {
|
|
|
|
|
if(!maxjptr) return NULL;
|
2008-01-11 11:57:08 +00:00
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
ptr = NULL;
|
2008-01-11 11:57:08 +00:00
|
|
|
jrec = maxjptr;
|
2026-06-19 01:49:53 +09:00
|
|
|
while(child = jrec->jsort) {
|
2008-01-11 11:57:08 +00:00
|
|
|
ptr = jrec;
|
|
|
|
|
jrec = child;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(len <= (int)jrec->jlen) return NULL;
|
2008-01-11 11:57:08 +00:00
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(ptr)
|
|
|
|
|
ptr->jsort = NULL;
|
2008-01-11 11:57:08 +00:00
|
|
|
else
|
|
|
|
|
maxjptr = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(rec)
|
|
|
|
|
memcpy((u_char*)jrec, (u_char*)rec, sizeof(JREC));
|
2008-01-11 11:57:08 +00:00
|
|
|
else
|
2026-06-19 01:49:53 +09:00
|
|
|
memset((u_char*)jrec, 0, sizeof(*jrec));
|
|
|
|
|
jrec->jlen = (u_char)len;
|
2008-01-11 11:57:08 +00:00
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(!maxjptr) {
|
|
|
|
|
maxjptr = jrec;
|
|
|
|
|
jrec->jsort = NULL;
|
2008-01-11 11:57:08 +00:00
|
|
|
return jrec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ptr = maxjptr;
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if((int)ptr->jlen < len) {
|
|
|
|
|
jrec->jsort = maxjptr;
|
|
|
|
|
maxjptr = jrec;
|
2008-01-11 11:57:08 +00:00
|
|
|
return jrec;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
while(child = ptr->jsort) {
|
|
|
|
|
if((int)child->jlen < len) break;
|
2008-01-11 11:57:08 +00:00
|
|
|
|
|
|
|
|
ptr = child;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
ptr->jsort = jrec;
|
|
|
|
|
jrec->jsort = child;
|
2008-01-11 11:57:08 +00:00
|
|
|
return jrec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2026-06-19 01:49:53 +09:00
|
|
|
dic_cl() {
|
|
|
|
|
u_char* p;
|
|
|
|
|
u_short pos;
|
2008-01-11 11:57:08 +00:00
|
|
|
int len;
|
|
|
|
|
int cmp;
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(!StudyExist()) return;
|
2008-01-11 11:57:08 +00:00
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if((pos = CLSTUDYIDX[(short)*cnvstart / CLSTUDYSTEP]) != (u_short)-1) {
|
2008-01-11 11:57:08 +00:00
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
for(p = CLSTUDYDICT + pos; !iseocl(p); p = ClNextTag(p)) {
|
|
|
|
|
cmp = sstrncmp(cnvstart, (u_char*)ClYomiPos(p),
|
|
|
|
|
len = ClYomiLen(p));
|
2008-01-11 11:57:08 +00:00
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(cmp == MATCH) {
|
|
|
|
|
if(!isdpnd(*(cnvstart + len))) {
|
2008-01-11 11:57:08 +00:00
|
|
|
setcrec(p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
else if(cmp == OVER)
|
2008-01-11 11:57:08 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|