Format source code

This commit is contained in:
Nishi 2026-06-18 13:40:14 +09:00
commit d0be6165c0
165 changed files with 30306 additions and 33687 deletions

447
mkkouho.c
View file

@ -1,6 +1,6 @@
/*
* 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
@ -8,10 +8,10 @@
* 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.
@ -19,7 +19,7 @@
* 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
@ -28,14 +28,13 @@
*/
/*
* $SonyRCSfile: mkkouho.c,v $
* $SonyRevision: 1.1 $
* $SonyRCSfile: mkkouho.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:04 $
*
* $Id$
*/
#include "sj_euc.h"
#include "sj_kcnv.h"
#include "sj_hinsi.h"
@ -43,369 +42,340 @@
#include "sj_dict.h"
#include "kanakan.h"
static void getkhtbl(CLREC* clrec);
static void cl_kanji(JREC* jrec, CLREC* clrec);
static void getkhtbl(CLREC* clrec);
static void cl_kanji(JREC* jrec, CLREC* clrec);
static unsigned char* makekan(unsigned char* s, unsigned char* d, int flg);
static int diffknj(JREC* jrec, unsigned char* ptr, int num);
static void cl_numcmn(JREC* jrec, CLREC* clrec);
static int diffknj(JREC* jrec, unsigned char* ptr, int num);
static void cl_numcmn(JREC* jrec, CLREC* clrec);
void mkkouho(void) {
CLREC* clrec;
int keeplen;
void
mkkouho(void)
{
CLREC *clrec;
int keeplen;
khcount = nkhcount = 0;
keeplen = clt1st -> cllen;
keeplen = clt1st->cllen;
clrec = clt1st;
do {
getkhtbl(clrec);
clrec = clrec -> clsort;
} while (clrec && (keeplen == clrec -> cllen));
getkhtbl(clrec);
clrec = clrec->clsort;
} while(clrec && (keeplen == clrec->cllen));
}
static void
getkhtbl(CLREC* clrec)
{
JREC *jrec;
jrec = clrec -> jnode;
switch (jrec -> class) {
case C_DICT:
getkhtbl(CLREC* clrec) {
JREC* jrec;
jrec = clrec->jnode;
switch(jrec->class) {
case C_DICT:
cl_kanji(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:
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(jrec, clrec);
break;
case C_BUNSETU:
break;
case C_MINASI:
case C_WAKACHI:
case C_MINASI:
case C_WAKACHI:
setkouho(clrec, (TypeDicOfs)0, 0);
break;
}
}
static void
cl_kanji(JREC* jrec, CLREC* clrec)
{
unsigned char *ptr;
int kcount = khcount;
cl_kanji(JREC* jrec, CLREC* clrec) {
unsigned char* ptr;
int kcount = khcount;
if (seldict(jrec -> dicid)) {
(*curdict->getdic)(curdict, jrec -> jseg);
if(seldict(jrec->dicid)) {
(*curdict->getdic)(curdict, jrec->jseg);
ptr = dicbuf + jrec->jofsst + 1;
get_askknj();
while (*ptr != HinsiBlkTerm) {
while(*ptr != HinsiBlkTerm) {
if(diffknj(jrec, ptr, kcount)) {
if (diffknj(jrec, ptr, kcount)) {
setkouho(clrec, (TypeDicOfs)(ptr - dicbuf), 0);
}
ptr = skipkstr(ptr);
}
}
else {
} else {
setkouho(clrec, (TypeDicOfs)1, 0);
}
}
unsigned char*
makekan_none(unsigned char* s, unsigned char* d, int flg)
{
makekan_none(unsigned char* s, unsigned char* d, int flg) {
return d;
}
unsigned char*
makekan_1byte(unsigned char* s, unsigned char* d, int flg)
{
if ((*s & KanjiModeMask) == ZenHiraAssyuku)
*d++ = 0x10 | (*s & KnjAssyukuMask);
else
*d++ = 0x90 | (*s & KnjAssyukuMask);
makekan_1byte(unsigned char* s, unsigned char* d, int flg) {
if((*s & KanjiModeMask) == ZenHiraAssyuku)
*d++ = 0x10 | (*s & KnjAssyukuMask);
else
*d++ = 0x90 | (*s & KnjAssyukuMask);
if (flg) *d++ = KanjiStrEnd;
if(flg) *d++ = KanjiStrEnd;
return d;
}
unsigned char*
makekan_knj(unsigned char* s, unsigned char* d, int flg)
{
makekan_knj(unsigned char* s, unsigned char* d, int flg) {
return makekan(askknj[*s & KnjAssyukuMask], d, flg);
}
unsigned char*
makekan_ofs(unsigned char* s, unsigned char* d, int flg)
{
return makekan(dicbuf + ((*s & KanjiCodeMask) << 8) + *(s + 1),
d, flg);
makekan_ofs(unsigned char* s, unsigned char* d, int flg) {
return makekan(dicbuf + ((*s & KanjiCodeMask) << 8) + *(s + 1),
d, flg);
}
unsigned char*
makekan_norm(unsigned char* s, unsigned char* d, int flg)
{
makekan_norm(unsigned char* s, unsigned char* d, int flg) {
unsigned char c;
if (*s != 0) {
if(*s != 0) {
c = s[1];
if (c & 0x80)
*d++ = SS3;
if(c & 0x80)
*d++ = SS3;
*d++ = *s | 0x80;
*d++ = c | 0x80;
*d++ = c | 0x80;
} else {
*d++ = *s;
}
if (flg) *d++ = KanjiStrEnd;
if(flg) *d++ = KanjiStrEnd;
return d;
}
unsigned char*
makekan_ascii(unsigned char* s, unsigned char* d, int flg)
{
makekan_ascii(unsigned char* s, unsigned char* d, int flg) {
unsigned char c;
c = s[1];
if (c & 0x80)
*d++ = SS2;
if(c & 0x80)
*d++ = SS2;
*d++ = c;
if (flg) *d++ = KanjiStrEnd;
if(flg) *d++ = KanjiStrEnd;
return d;
}
static unsigned char*
makekan(unsigned char* s, unsigned char* d, int flg)
{
makekan(unsigned char* s, unsigned char* d, int flg) {
int csize;
for ( ; ; ) {
for(;;) {
csize = codesize(*s);
if (s[csize] == KanjiStrEnd) {
if(s[csize] == KanjiStrEnd) {
switch(*s & KanjiModeMask) {
case ZenHiraAssyuku:
d = makekan_1byte(s, d, flg); break;
case ZenKataAssyuku:
d = makekan_1byte(s, d, flg); break;
case OffsetAssyuku:
d = makekan_ofs(s, d, flg); break;
case AiAttribute:
d = makekan_none(s, d, flg); break;
case ZenHiraAssyuku:
d = makekan_1byte(s, d, flg);
break;
case LeadingHankaku:
d = makekan_ascii(s, d, flg); break;
case KanjiAssyuku:
d = makekan_knj(s, d, flg); break;
default:
case ZenKataAssyuku:
d = makekan_1byte(s, d, flg);
break;
case OffsetAssyuku:
d = makekan_ofs(s, d, flg);
break;
case AiAttribute:
d = makekan_none(s, d, flg);
break;
case LeadingHankaku:
d = makekan_ascii(s, d, flg);
break;
case KanjiAssyuku:
d = makekan_knj(s, d, flg);
break;
default:
d = makekan_norm(s, d, flg);
}
break;
}
else
} else
switch(*s & KanjiModeMask) {
case ZenHiraAssyuku:
d = makekan_1byte(s, d, FALSE); break;
case ZenKataAssyuku:
d = makekan_1byte(s, d, FALSE); break;
case OffsetAssyuku:
d = makekan_ofs(s, d, FALSE); break;
case AiAttribute:
d = makekan_none(s, d, FALSE); break;
case ZenHiraAssyuku:
d = makekan_1byte(s, d, FALSE);
break;
case LeadingHankaku:
d = makekan_ascii(s, d, FALSE); break;
case ZenKataAssyuku:
d = makekan_1byte(s, d, FALSE);
break;
case KanjiAssyuku:
d = makekan_knj(s, d, FALSE); break;
case OffsetAssyuku:
d = makekan_ofs(s, d, FALSE);
break;
default:
case AiAttribute:
d = makekan_none(s, d, FALSE);
break;
case LeadingHankaku:
d = makekan_ascii(s, d, FALSE);
break;
case KanjiAssyuku:
d = makekan_knj(s, d, FALSE);
break;
default:
d = makekan_norm(s, d, FALSE);
}
s += codesize(*s);
}
return d;
}
#define PEND 2
#define QEND 1
#define PEND 2
#define QEND 1
static int
sameknj(unsigned char* p, int plen, unsigned char* q, int qlen)
{
int i;
int j;
int endf = 0;
int brkf;
sameknj(unsigned char* p, int plen, unsigned char* q, int qlen) {
int i;
int j;
int endf = 0;
int brkf;
do {
if ((i = euc_codesize(*p)) != euc_codesize(*q)) return FALSE;
if((i = euc_codesize(*p)) != euc_codesize(*q)) return FALSE;
brkf = 0;
for (j = 0; j < i; j++) {
if (p[j] != q[j] ) {
for(j = 0; j < i; j++) {
if(p[j] != q[j]) {
brkf = 1;
break;
}
}
if (brkf) break;
if(brkf) break;
if (p[i] == KanjiStrEnd) endf += PEND;
if (q[i] == KanjiStrEnd) endf += QEND;
if(p[i] == KanjiStrEnd) endf += PEND;
if(q[i] == KanjiStrEnd) endf += QEND;
p += i;
q += i;
} while (!endf);
} while(!endf);
switch (endf) {
case (PEND | QEND):
if (plen == qlen) return TRUE;
switch(endf) {
case(PEND | QEND):
if(plen == qlen) return TRUE;
break;
case PEND:
i = plen;
i = plen;
plen = qlen;
qlen = i;
p = q;
p = q;
case QEND:
if (p[euc_codesize(*p)] != KanjiStrEnd) break;
if ((*p & KanjiModeMask) != 0x10 ) break;
if (qlen != plen - (*p & KanjiCodeMask) - 1) break;
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))
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
#undef PEND
#undef QEND
static int
diffknj(JREC* jrec, unsigned char* ptr, int num)
{
KHREC *kptr;
JREC *jptr;
int i;
unsigned char kbuf1[MaxWdKanjiLen];
unsigned char kbuf2[MaxWdKanjiLen];
diffknj(JREC* jrec, unsigned char* ptr, int num) {
KHREC* kptr;
JREC* jptr;
int i;
unsigned char kbuf1[MaxWdKanjiLen];
unsigned char kbuf2[MaxWdKanjiLen];
if (jrec -> hinsi == TANKANJI) return TRUE;
if(jrec->hinsi == TANKANJI) return TRUE;
makekan(ptr, kbuf1, TRUE);
for (i = 0, kptr = kouhotbl ; i < num ; i++, kptr++) {
if ((jptr = kptr -> clrec -> jnode) == jrec)
for(i = 0, kptr = kouhotbl; i < num; i++, kptr++) {
if((jptr = kptr->clrec->jnode) == jrec)
return FALSE;
if (jptr -> hinsi == TANKANJI) continue;
if(jptr->hinsi == TANKANJI) continue;
if (jptr -> class != jrec -> class) continue;
if(jptr->class != jrec->class) continue;
if (jptr -> dicid != jrec -> dicid) continue;
if(jptr->dicid != jrec->dicid) continue;
if (jptr -> jseg != jrec -> jseg) continue;
if(jptr->jseg != jrec->jseg) continue;
if (jptr -> sttofs != jrec -> sttofs) continue;
if(jptr->sttofs != jrec->sttofs) continue;
if (jptr -> stbofs != jrec -> stbofs) continue;
if(jptr->stbofs != jrec->stbofs) continue;
makekan(dicbuf + kptr -> offs, kbuf2, TRUE);
makekan(dicbuf + kptr->offs, kbuf2, TRUE);
if (sameknj(kbuf1, jrec -> jlen, kbuf2, jptr -> jlen))
if(sameknj(kbuf1, jrec->jlen, kbuf2, jptr->jlen))
return FALSE;
}
return TRUE;
}
static int
chrck_numtbl(unsigned short flg, unsigned short cond)
{
unsigned short must;
chrck_numtbl(unsigned short flg, unsigned short cond) {
unsigned short must;
if ((cond = SelNumCond(cond)) != 0) {
if ((must = (cond & SelNumMust)) != 0) {
if ((flg & must) != must) return FALSE;
if((cond = SelNumCond(cond)) != 0) {
if((must = (cond & SelNumMust)) != 0) {
if((flg & must) != must) return FALSE;
cond &= ~must;
}
if (cond && !(cond & flg)) return FALSE;
if(cond && !(cond & flg)) return FALSE;
}
return TRUE;
}
int
sel_sjmode(JREC* jrec)
{
int sel_sjmode(JREC* jrec) {
unsigned short i;
unsigned short *p;
unsigned short *q;
unsigned short* p;
unsigned short* q;
switch (jrec -> class) {
switch(jrec->class) {
case C_N_ARABIA:
case C_N_ARACMA:
case C_N_KAZU:
@ -423,68 +393,57 @@ sel_sjmode(JREC* jrec)
return SelArb;
}
while ((i = *p++) != SelNumTerm) {
if (chrck_numtbl(jrec -> flags, i)) break;
while((i = *p++) != SelNumTerm) {
if(chrck_numtbl(jrec->flags, i)) break;
}
if (i == SelNumTerm) i = *q;
if(i == SelNumTerm) i = *q;
return SelNumFunc(i);
}
static void
cl_numcmn(JREC* jrec, CLREC* clrec)
{
unsigned char *p;
int i;
cl_numcmn(JREC* jrec, CLREC* clrec) {
unsigned char* p;
int i;
unsigned short j;
unsigned short *tbl;
unsigned short* tbl;
p = cnvstart;
if ((i = jrec -> sttofs) == SETTOU_DAI)
if((i = jrec->sttofs) == SETTOU_DAI)
p += SttYomiLen(Settou_ptr(i));
else if (i == SETTOU_KIGOU)
else if(i == SETTOU_KIGOU)
p++;
if (jrec -> jofsst) {
if(jrec->jofsst) {
i = sel_sjmode(jrec);
if (seldict(jrec -> dicid)) {
(*curdict->getdic)(curdict, jrec -> jseg);
if(seldict(jrec->dicid)) {
(*curdict->getdic)(curdict, jrec->jseg);
p = dicbuf + jrec->jofsst + 1;
while (*p != HinsiBlkTerm) {
while(*p != HinsiBlkTerm) {
setkouho(clrec, (TypeDicOfs)(p - dicbuf), i);
p = skipkstr(p);
}
}
else {
} else {
setkouho(clrec, (TypeDicOfs)1, i);
}
}
else {
tbl = Selsjadrs(jrec->class - C_N_ARABIA);
while ((j = *tbl++) != SelNumTerm) {
if (!chrck_numtbl(jrec -> flags, j)) continue;
else {
tbl = Selsjadrs(jrec->class - C_N_ARABIA);
while((j = *tbl++) != SelNumTerm) {
if(!chrck_numtbl(jrec->flags, j)) continue;
setkouho(clrec, (TypeDicOfs)0, (int)SelNumFunc(j));
}
}