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: srchdict.c,v $
|
|
|
|
|
* $SonyRevision: 1.1 $
|
2008-01-11 11:57:08 +00:00
|
|
|
* $SonyDate: 1994/06/03 08:02:26 $
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "sj_kcnv.h"
|
|
|
|
|
|
|
|
|
|
#include "sj_kanakan.h"
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
int yomicmp(u_char* ptr1, u_char* ptr2, u_char* saml) {
|
|
|
|
|
int i, j;
|
|
|
|
|
int same;
|
2008-01-11 11:57:08 +00:00
|
|
|
|
|
|
|
|
same = *saml;
|
|
|
|
|
|
|
|
|
|
i = getplen(ptr2);
|
|
|
|
|
j = getnlen(ptr2);
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(j == 0) {
|
2008-01-11 11:57:08 +00:00
|
|
|
ptr2 = get_idxptr(prevseg);
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
for(i = same; i; i--)
|
|
|
|
|
if(*ptr1++ != *ptr2++) return OVER;
|
2008-01-11 11:57:08 +00:00
|
|
|
|
|
|
|
|
j = sstrlen(ptr2);
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
else if(i > same)
|
2008-01-11 11:57:08 +00:00
|
|
|
return CONT;
|
|
|
|
|
|
|
|
|
|
else {
|
2026-06-19 01:49:53 +09:00
|
|
|
if(i < same) same = i;
|
2008-01-11 11:57:08 +00:00
|
|
|
ptr1 += same;
|
|
|
|
|
ptr2 += DOUONBLKSIZENUMBER;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
while(j-- > 0) {
|
|
|
|
|
if(*ptr1 > *ptr2) {
|
2008-01-11 11:57:08 +00:00
|
|
|
*saml = same;
|
|
|
|
|
return CONT;
|
2026-06-19 01:49:53 +09:00
|
|
|
} else if(*ptr1++ < *ptr2++) {
|
2008-01-11 11:57:08 +00:00
|
|
|
return OVER;
|
|
|
|
|
}
|
|
|
|
|
same++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*saml = same;
|
|
|
|
|
return MATCH;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
u_char*
|
|
|
|
|
srchdict(u_char* tagp) {
|
|
|
|
|
TypeDicSeg segno;
|
|
|
|
|
int cmp;
|
|
|
|
|
int maxlen;
|
2008-01-11 11:57:08 +00:00
|
|
|
|
|
|
|
|
maxlen = (cnvlen > MAXWDYOMILEN) ? MAXWDYOMILEN : cnvlen;
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
while((int)dicinl <= maxlen) {
|
2008-01-11 11:57:08 +00:00
|
|
|
|
|
|
|
|
segno = srchidx(prevseg, (int)dicinl);
|
|
|
|
|
|
|
|
|
|
(*curdict->getdic)(curdict, segno);
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(prevseg != segno) {
|
2008-01-11 11:57:08 +00:00
|
|
|
|
|
|
|
|
prevseg = segno;
|
|
|
|
|
|
|
|
|
|
tagp = dicbuf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
tagp = getntag(tagp);
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(segend(tagp)) {
|
2008-01-11 11:57:08 +00:00
|
|
|
|
|
|
|
|
prevseg = ++segno;
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(segno >= curdict->segunit) return NULL;
|
2008-01-11 11:57:08 +00:00
|
|
|
|
|
|
|
|
(*curdict->getdic)(curdict, segno);
|
|
|
|
|
|
|
|
|
|
tagp = dicbuf;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(tagp == dicbuf) {
|
2008-01-11 11:57:08 +00:00
|
|
|
get_askknj();
|
|
|
|
|
tagp += *tagp + 1;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
while(!segend(tagp)) {
|
2008-01-11 11:57:08 +00:00
|
|
|
|
|
|
|
|
cmp = yomicmp(cnvstart, tagp, &dicsaml);
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if((int)dicsaml > maxlen) return NULL;
|
2008-01-11 11:57:08 +00:00
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(cmp == OVER)
|
2008-01-11 11:57:08 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
else if(cmp == MATCH) {
|
2008-01-11 11:57:08 +00:00
|
|
|
|
2026-06-19 01:49:53 +09:00
|
|
|
if(isdpnd(*(cnvstart + dicsaml))) {
|
2008-01-11 11:57:08 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
dicinl = dicsaml + 1;
|
|
|
|
|
return tagp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tagp = getntag(tagp);
|
|
|
|
|
}
|
|
|
|
|
dicinl = dicsaml + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|