Format
This commit is contained in:
parent
80b2181a61
commit
73cb09624a
116 changed files with 19741 additions and 21522 deletions
|
|
@ -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,86 +28,75 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* $SonyRCSfile: clstudy.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $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(), *srchclpos();
|
||||
static int delclold();
|
||||
|
||||
static u_char *delcldata(), *srchclpos();
|
||||
static int delclold();
|
||||
|
||||
|
||||
int
|
||||
clstudy(u_char *yomi1, u_char *yomi2, STDYOUT *stdy)
|
||||
{
|
||||
int clstudy(u_char* yomi1, u_char* yomi2, STDYOUT* stdy) {
|
||||
u_char ytmp[CLSTDY_TMPLEN];
|
||||
u_char *dst, *ptr;
|
||||
u_char *dst, *ptr;
|
||||
int ret;
|
||||
int len1, len2;
|
||||
int alen, blen;
|
||||
int i;
|
||||
|
||||
if (!StudyExist()) return CLSTUDYNODICT;
|
||||
if(!StudyExist()) return CLSTUDYNODICT;
|
||||
|
||||
if (!yomi1 || !*yomi1) return CLSTUDYPARAERR;
|
||||
if(!yomi1 || !*yomi1) return CLSTUDYPARAERR;
|
||||
|
||||
if (!yomi2 || !*yomi2) {
|
||||
if (!sj2cd_str(yomi1, ytmp, CLSTDY_TMPLEN))
|
||||
if(!yomi2 || !*yomi2) {
|
||||
if(!sj2cd_str(yomi1, ytmp, CLSTDY_TMPLEN))
|
||||
return CLSTUDYYOMIERR;
|
||||
|
||||
(void)delcldata(ytmp);
|
||||
|
||||
ret = CLSTUDYNORMEND;
|
||||
}
|
||||
else if (!stdy)
|
||||
} else if(!stdy)
|
||||
return CLSTUDYPARAERR;
|
||||
|
||||
else {
|
||||
if (!sj2cd_str(yomi1, ytmp, CLSTDY_TMPLEN))
|
||||
if(!sj2cd_str(yomi1, ytmp, CLSTDY_TMPLEN))
|
||||
return CLSTUDYYOMIERR;
|
||||
len1 = sstrlen(ytmp);
|
||||
|
||||
if (!sj2cd_str(yomi2, ytmp + len1, CLSTDY_TMPLEN - len1))
|
||||
if(!sj2cd_str(yomi2, ytmp + len1, CLSTDY_TMPLEN - len1))
|
||||
return CLSTUDYYOMIERR;
|
||||
len2 = len1 + stdy -> len;
|
||||
len2 = len1 + stdy->len;
|
||||
|
||||
ytmp[len2] = 0;
|
||||
|
||||
alen = len2 + CL_HDLEN;
|
||||
|
||||
if (alen + 1 >= CLSTUDYLEN) return CLSTUDYNOAREA;
|
||||
if(alen + 1 >= CLSTUDYLEN) return CLSTUDYNOAREA;
|
||||
|
||||
blen = CLSTUDYTAIL - delcldata(ytmp) - 1;
|
||||
|
||||
while (blen < alen) {
|
||||
if (!(i = delclold())) break;
|
||||
while(blen < alen) {
|
||||
if(!(i = delclold())) break;
|
||||
blen += i;
|
||||
}
|
||||
|
||||
|
||||
if (blen >= alen) {
|
||||
if(blen >= alen) {
|
||||
dst = srchclpos(ytmp);
|
||||
|
||||
ptr = CLSTUDYTAIL - alen;
|
||||
mvmemd(ptr, CLSTUDYTAIL, (ptr - dst));
|
||||
ClYomiLen(dst) = (u_char)len2;
|
||||
ClGramCode(dst) = stdy -> hinshi;
|
||||
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
|
||||
} else
|
||||
ret = CLSTUDYNOAREA;
|
||||
}
|
||||
mkclidx();
|
||||
|
|
@ -116,32 +105,28 @@ clstudy(u_char *yomi1, u_char *yomi2, STDYOUT *stdy)
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static u_char *
|
||||
delcldata(u_char *ycode)
|
||||
{
|
||||
u_char *tagptr;
|
||||
u_char *ptr1;
|
||||
u_char *ptr2;
|
||||
static u_char*
|
||||
delcldata(u_char* ycode) {
|
||||
u_char* tagptr;
|
||||
u_char* ptr1;
|
||||
u_char* ptr2;
|
||||
int len1;
|
||||
|
||||
tagptr = CLSTUDYDICT;
|
||||
while (!iseocl(tagptr)) {
|
||||
while(!iseocl(tagptr)) {
|
||||
ptr1 = ycode;
|
||||
ptr2 = ClYomiPos(tagptr);
|
||||
len1 = ClYomiLen(tagptr);
|
||||
|
||||
while (*ptr1 && len1) {
|
||||
if (*ptr1 != *ptr2) break;
|
||||
while(*ptr1 && len1) {
|
||||
if(*ptr1 != *ptr2) break;
|
||||
ptr1++;
|
||||
ptr2++;
|
||||
len1--;
|
||||
}
|
||||
if (!*ptr1 || !len1) {
|
||||
if(!*ptr1 || !len1) {
|
||||
delclsub(tagptr);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
tagptr = ClNextTag(tagptr);
|
||||
}
|
||||
}
|
||||
|
|
@ -149,12 +134,8 @@ delcldata(u_char *ycode)
|
|||
return tagptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
delclsub(u_char *target)
|
||||
{
|
||||
u_char *src;
|
||||
void delclsub(u_char* target) {
|
||||
u_char* src;
|
||||
int num;
|
||||
int tmp;
|
||||
int len;
|
||||
|
|
@ -170,10 +151,10 @@ delclsub(u_char *target)
|
|||
memset(CLSTUDYTAIL - len, 0, len);
|
||||
|
||||
src = CLSTUDYDICT;
|
||||
while (!iseocl(src)) {
|
||||
while(!iseocl(src)) {
|
||||
tmp = ClGetNum(src);
|
||||
|
||||
if (tmp > num) {
|
||||
if(tmp > num) {
|
||||
tmp -= 1;
|
||||
ClSetNum(src, tmp);
|
||||
}
|
||||
|
|
@ -182,32 +163,29 @@ delclsub(u_char *target)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
delclold()
|
||||
{
|
||||
u_char *tagptr;
|
||||
u_char *target;
|
||||
delclold() {
|
||||
u_char* tagptr;
|
||||
u_char* target;
|
||||
int num;
|
||||
int tmp;
|
||||
|
||||
target = NULL;
|
||||
num = 0;
|
||||
num = 0;
|
||||
|
||||
tagptr = CLSTUDYDICT;
|
||||
while (!iseocl(tagptr)) {
|
||||
while(!iseocl(tagptr)) {
|
||||
tmp = ClGetNum(tagptr);
|
||||
|
||||
if (tmp >= num) {
|
||||
num = tmp;
|
||||
if(tmp >= num) {
|
||||
num = tmp;
|
||||
target = tagptr;
|
||||
}
|
||||
|
||||
tagptr = ClNextTag(tagptr);
|
||||
}
|
||||
|
||||
if (target) {
|
||||
if(target) {
|
||||
num = ClBlkLen(tagptr);
|
||||
delclsub(target);
|
||||
}
|
||||
|
|
@ -215,21 +193,18 @@ delclold()
|
|||
return num;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static u_char *
|
||||
srchclpos(u_char *ycode)
|
||||
{
|
||||
u_char *tagptr;
|
||||
u_char *target;
|
||||
u_char *ptr1;
|
||||
u_char *ptr2;
|
||||
static u_char*
|
||||
srchclpos(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)) {
|
||||
while(!iseocl(tagptr)) {
|
||||
tmp = ClGetNum(tagptr);
|
||||
|
||||
tmp++;
|
||||
|
|
@ -238,19 +213,19 @@ srchclpos(u_char *ycode)
|
|||
ptr1 = ycode;
|
||||
ptr2 = ClYomiPos(tagptr);
|
||||
len = ClYomiLen(tagptr);
|
||||
while (*ptr1 && len) {
|
||||
if (*ptr1 != *ptr2) break;
|
||||
while(*ptr1 && len) {
|
||||
if(*ptr1 != *ptr2) break;
|
||||
ptr1++;
|
||||
ptr2++;
|
||||
len--;
|
||||
}
|
||||
|
||||
if (!target) {
|
||||
if (!len)
|
||||
if(!target) {
|
||||
if(!len)
|
||||
;
|
||||
else if (!*ptr1)
|
||||
else if(!*ptr1)
|
||||
target = tagptr;
|
||||
else if (*ptr1 < *ptr2)
|
||||
else if(*ptr1 < *ptr2)
|
||||
target = tagptr;
|
||||
}
|
||||
tagptr = ClNextTag(tagptr);
|
||||
|
|
@ -259,25 +234,21 @@ srchclpos(u_char *ycode)
|
|||
return target ? target : tagptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
mkclidx()
|
||||
{
|
||||
u_char *ptr;
|
||||
void mkclidx() {
|
||||
u_char* ptr;
|
||||
int num;
|
||||
int st, ed;
|
||||
|
||||
if (!StudyExist()) return;
|
||||
if(!StudyExist()) return;
|
||||
|
||||
ptr = CLSTUDYDICT;
|
||||
for (num = st = 0 ; st < 0x100 ; num++, st = ed) {
|
||||
for(num = st = 0; st < 0x100; num++, st = ed) {
|
||||
ed = st + CLSTUDYSTEP;
|
||||
while (!iseocl(ptr)) {
|
||||
if ((unsigned int) *ClYomiPos(ptr) >= st) break;
|
||||
while(!iseocl(ptr)) {
|
||||
if((unsigned int)*ClYomiPos(ptr) >= st) break;
|
||||
ptr = ClNextTag(ptr);
|
||||
}
|
||||
if (ClYomiLen(ptr) && ((int)*ClYomiPos(ptr) < ed))
|
||||
if(ClYomiLen(ptr) && ((int)*ClYomiPos(ptr) < ed))
|
||||
CLSTUDYIDX[num] = ptr - CLSTUDYDICT;
|
||||
else
|
||||
CLSTUDYIDX[num] = (u_short)-1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue