Import sj3-patches-20040916
Original description for the changes:
sj3 の patch をまとめました。
基本的に、SUS v2 の範囲に対応しているシステムを考えています。ですので、
autoconf 的な #ifdef はあまり使うつもりはありません。
FreeBSD の ports 向けを第一目的にしているので、strlcpy() のような非標準の
関数も使ってしまっていますが、それについては要望があれば存在しないシステム
でも make できるように対応するつもりです。
この patch set に関する要望がもしもあるようでしたら、
小野 寛生 (hiroo+sj3 at oikumene.gcd.org)
までご連絡ください。
---- patch 部分の Changelog
2004年 9月16日 木曜日 02時57分06秒 JST
* server/execute.c で malloc が失敗したときに dictlist を消去する処理が
バグで動かない状態だったのを修正した。ただし、その直後に segfault する
ようなコードになっているので問題は解消されていない。
エラー回復時にどのような処理が意図されていたか理解しないと、修正は無理
なので、そのままにしておく。
2004年 8月28日 土曜日 15時04分33秒 JST
* Move include/sj3lowlib.h and sj3lib/sj3lib_func.h to sj3lib/sj3lib.h.
It will enable softwares depending on sj3lib.h compile again.
2004年 7月24日 土曜日
* ヘッダの重複 include を許容する。
include/sj3lowlib.h, sj3lib/sj3lib_func.h
* 必要な型宣言のため、ヘッダを include する。
2004年 7月21日 水曜日 01時00分11秒 JST
* ISO C に適合するよういろいろ修正。(ただし、部分的)。
修正内容は7/3に準ずる。
修正したファイル名は省略する。
* dict/tool/makeseg.c の static index[] が <string.h> の index() と衝突
しないように、segindex[] に改名した。
(FreeBSD 4-stable/GCC 2.95.4 で compile に失敗していたものの修正)。
2004年 7月 4日 日曜日 17時47分33秒 JST
* ISO C に適合するよういろいろ修正。(ただし、部分的)。
修正内容は7/3に準ずる。
FreeBSD/amd64 上の gcc version 3.3.3 [FreeBSD] 20031106 では、致命的と
思われる error/warning はなくなった。動作確認は sj3serv が起動すること
のみ。
2004年 7月 3日 土曜日 03時53分23秒 JST
* スタイル修正を以下のファイルについて行なった。
- 関数宣言を ISO C スタイルにした。
- register キーワードを削除した。
- 構造体、配列の初期化に適切な {} をつけた。
- 条件判定文を if((something) != NULL) のような形式に変更した。
kanakan/alloc.c,
server/comuni.c, error.c, execute.c, setup.c
sj3/funckey.c, sj3.c, sjgetchar.c
sj3lib/Imakefile, sj.c, sj3lib.h
- プロトタイプ宣言をいれたヘッダファイルを追加作成。
kanakan/kanakan.h, sj3/sj3.h, sj3lib/sj3lib_func.h
2004年 7月 2日 金曜日 01時09分09秒 JST
* FreeBSD の ports にある patch を大部分もってきた。
注意点:
- server/execute.c, setup.c
snprintf と strlcpy を使っているコードがあり、将来は存在しない system の
ためにコードをもってきて、sj3.tmpl あたりに knob を設けるべきである。
現時点では、上記関数が存在しないシステムは、単にコンパイルに失敗する。
- FreeBSD の -lxpg4 は外した。古い release では、有効にする必要あり。(sj3.tmpl)
* dict/tool を ISO C style に変更した。
- amd64/FreeBSD で build できるようになったのを確認。
(sporsored by: AMD64JP Project, AMD developer support program).
- server は起動する。動作確認は未実施。
Signed-off-by: Masanori Ogino <mogino@acm.org>
This commit is contained in:
parent
109af13829
commit
4a2d141541
77 changed files with 3421 additions and 3850 deletions
|
|
@ -31,30 +31,26 @@
|
|||
* $SonyRCSfile: addelcmn.c,v $
|
||||
* $SonyRevision: 1.1 $
|
||||
* $SonyDate: 1994/06/03 08:01:27 $
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include "sj_euc.h"
|
||||
#include "sj_kcnv.h"
|
||||
#include "sj_hinsi.h"
|
||||
#include "sj_yomi.h"
|
||||
#include "kanakan.h"
|
||||
|
||||
|
||||
|
||||
Uchar *get_idxptr();
|
||||
Int sj2cd_str(), yomicmp(), codesize();
|
||||
Int sstrlen(), sstrcmp();
|
||||
Int sj2cd_str();
|
||||
Void mvmemi(), mvmemd(), mkidxtbl();
|
||||
|
||||
|
||||
|
||||
Void set_size(p, size, plen, nlen)
|
||||
Reg1 Uchar *p;
|
||||
Int size;
|
||||
Int plen;
|
||||
Int nlen;
|
||||
void
|
||||
set_size (Uchar *p, Int size, Int plen, Int nlen)
|
||||
{
|
||||
*p = (Uchar)(size >> 8);
|
||||
if (nlen & 0x10) *p |= NokoriYomiTop;
|
||||
|
|
@ -65,21 +61,17 @@ Int nlen;
|
|||
|
||||
|
||||
|
||||
Static Int isvyomi(yp)
|
||||
Reg1 Uchar *yp;
|
||||
static Int
|
||||
isvyomi (Uchar *yp)
|
||||
{
|
||||
Reg2 Int len;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -88,30 +80,28 @@ Reg1 Uchar *yp;
|
|||
|
||||
|
||||
|
||||
Static Int isvknj(kanji)
|
||||
Reg1 Uchar *kanji;
|
||||
static Int
|
||||
isvknj(Uchar *kanji)
|
||||
{
|
||||
Reg2 Int len;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -120,10 +110,10 @@ Reg1 Uchar *kanji;
|
|||
|
||||
|
||||
|
||||
Static Int isgrm(gram)
|
||||
TypeGram gram;
|
||||
static Int
|
||||
isgrm (TypeGram gram)
|
||||
{
|
||||
Reg1 Int grm = gram;
|
||||
Int grm = gram;
|
||||
|
||||
if (MEISI_1 <= grm && grm <= D_MEISI_6) return TRUE;
|
||||
if (MYOUJI <= grm && grm <= JOSUUSI2) return TRUE;
|
||||
|
|
@ -142,49 +132,33 @@ TypeGram gram;
|
|||
|
||||
|
||||
|
||||
Uint addel_arg(yp, kp, grm, nyp, len)
|
||||
Uchar *yp;
|
||||
Uchar *kp;
|
||||
TypeGram grm;
|
||||
Uchar *nyp;
|
||||
Int len;
|
||||
Uint
|
||||
addel_arg (Uchar *yp, Uchar *kp, TypeGram grm, Uchar *nyp, Int len)
|
||||
{
|
||||
Reg1 Ushort err = 0;
|
||||
Ushort 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(src, dst)
|
||||
Reg2 Uchar *src;
|
||||
Reg1 Uchar *dst;
|
||||
static void
|
||||
yomi2kata (Uchar *src, Uchar *dst)
|
||||
{
|
||||
Reg3 Int first;
|
||||
Reg4 Int second;
|
||||
Int first;
|
||||
Int second;
|
||||
|
||||
while (first = *src++) {
|
||||
while ((first = *src++) != 0) {
|
||||
second = *src++;
|
||||
|
||||
|
||||
if (first != 0xa4) {
|
||||
*dst++ = first;
|
||||
*dst++ = second;
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
*dst++ = 0xa5;
|
||||
*dst++ = second;
|
||||
|
|
@ -196,86 +170,64 @@ Reg1 Uchar *dst;
|
|||
|
||||
|
||||
|
||||
Static Int top_strcmp(src, dst)
|
||||
Reg1 Uchar *src;
|
||||
Reg3 Uchar *dst;
|
||||
static Int
|
||||
top_strcmp (Uchar *src, Uchar *dst)
|
||||
{
|
||||
Reg2 Int i;
|
||||
|
||||
|
||||
Int i;
|
||||
for (i = 0 ; *src && (*src == *dst) ; src++, dst++) i++;
|
||||
|
||||
|
||||
i /= 2;
|
||||
|
||||
|
||||
return (i > MaxYomiAskNumber) ? MaxYomiAskNumber : i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Static Int last_strcmp(src, dst)
|
||||
Uchar *src;
|
||||
Uchar *dst;
|
||||
static Int
|
||||
last_strcmp (Uchar *src, Uchar *dst)
|
||||
{
|
||||
Int slen;
|
||||
Reg1 Int dlen;
|
||||
Int dlen;
|
||||
|
||||
|
||||
slen = sstrlen(src);
|
||||
dlen = sstrlen(dst);
|
||||
slen = strlen(src);
|
||||
dlen = strlen(dst);
|
||||
|
||||
|
||||
if (dlen > MaxYomiAskNumber * 2) return 0;
|
||||
|
||||
|
||||
if (sstrcmp(src + (slen - dlen), dst)) return 0;
|
||||
if (strcmp(src + (slen - dlen), dst)) return 0;
|
||||
|
||||
|
||||
return (dlen / 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Int cvtknj(yomi, knj, dst)
|
||||
Uchar *yomi;
|
||||
Uchar *knj;
|
||||
Reg1 Uchar *dst;
|
||||
Int
|
||||
cvtknj (Uchar *yomi, Uchar *knj, Uchar *dst)
|
||||
{
|
||||
Uchar kana[MaxWdYomiLen * 2 + 1];
|
||||
Reg2 Int len;
|
||||
Int len;
|
||||
Uchar *keep;
|
||||
|
||||
keep = dst;
|
||||
yomi2kata(yomi, kana);
|
||||
|
||||
|
||||
if (len = top_strcmp(yomi, knj)) {
|
||||
if ((len = top_strcmp(yomi, knj)) != 0) {
|
||||
*dst = (Uchar)(ZenHiraAssyuku | (len - 1));
|
||||
}
|
||||
|
||||
else if (len = top_strcmp(kana, knj)) {
|
||||
else if ((len = top_strcmp(kana, knj)) != 0) {
|
||||
*dst = (Uchar)(ZenKataAssyuku | (len - 1));
|
||||
}
|
||||
|
||||
|
||||
if (len) {
|
||||
|
||||
knj += len * 2;
|
||||
dst++;
|
||||
|
||||
}
|
||||
|
||||
if (*knj) {
|
||||
|
||||
for ( ; ; ) {
|
||||
|
||||
if (len = last_strcmp(yomi, knj)) {
|
||||
if ((len = last_strcmp(yomi, knj)) != 0) {
|
||||
*dst++ = (Uchar)(ZenHiraAssyuku | (len - 1));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
else if (len = last_strcmp(kana, knj)) {
|
||||
else if ((len = last_strcmp(kana, knj)) != 0) {
|
||||
*dst++ = (Uchar)(ZenKataAssyuku | (len - 1));
|
||||
break;
|
||||
}
|
||||
|
|
@ -287,62 +239,48 @@ Reg1 Uchar *dst;
|
|||
knj++;
|
||||
*dst++ = (*knj & NormalKanjiMask); knj++;
|
||||
*dst++ = *knj++;
|
||||
|
||||
} else if (*knj & 0x80) {
|
||||
*dst++ = (*knj & NormalKanjiMask); knj++;
|
||||
*dst++ = (*knj & NormalKanjiMask); knj++;
|
||||
}
|
||||
|
||||
else {
|
||||
*dst++ = (Uchar)LeadingHankaku;
|
||||
*dst++ = *knj++;
|
||||
}
|
||||
|
||||
|
||||
if (!*knj) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*dst = 0;
|
||||
|
||||
|
||||
return (dst - keep);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Int srchkana(ptr, saml)
|
||||
Uchar **ptr;
|
||||
Int *saml;
|
||||
Int
|
||||
srchkana (Uchar **ptr, Int *saml)
|
||||
{
|
||||
Uchar *p;
|
||||
Int cmp;
|
||||
Int cnt = 0;
|
||||
Uchar same;
|
||||
Reg1 Int flg = 0;
|
||||
Int flg = 0;
|
||||
|
||||
|
||||
same = 0;
|
||||
|
||||
|
||||
p = segtop();
|
||||
|
||||
|
||||
while (!segend(p)) {
|
||||
|
||||
|
||||
if (flg == 0) {
|
||||
|
||||
|
||||
cmp = yomicmp(cnvstart, p, &same);
|
||||
|
||||
|
||||
if (cmp == OVER) break;
|
||||
|
||||
|
||||
if (cmp == MATCH && *(cnvstart + same) == 0) {
|
||||
*ptr = p;
|
||||
*saml = same;
|
||||
|
|
@ -350,15 +288,12 @@ Int *saml;
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
p = getntag(p);
|
||||
cnt++;
|
||||
}
|
||||
|
||||
|
||||
if (flg != 0) return cnt;
|
||||
|
||||
|
||||
*ptr = p;
|
||||
*saml = same;
|
||||
return 0;
|
||||
|
|
@ -366,30 +301,23 @@ Int *saml;
|
|||
|
||||
|
||||
|
||||
Int srchgram(ptr, dst, hinsi)
|
||||
Reg1 Uchar *ptr;
|
||||
Uchar **dst;
|
||||
TypeGram hinsi;
|
||||
Int
|
||||
srchgram (Uchar *ptr, Uchar **dst, TypeGram hinsi)
|
||||
{
|
||||
Uchar *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);
|
||||
|
|
@ -397,43 +325,34 @@ TypeGram hinsi;
|
|||
cnt++;
|
||||
}
|
||||
|
||||
|
||||
if (flg) return cnt;
|
||||
|
||||
|
||||
*dst = ptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Int srchkanji(dst, knj, klen)
|
||||
Uchar **dst;
|
||||
Uchar *knj;
|
||||
Int klen;
|
||||
Int
|
||||
srchkanji (Uchar **dst, Uchar *knj, Int klen)
|
||||
{
|
||||
Reg1 Uchar *ptr;
|
||||
Uchar *ptr;
|
||||
Uchar *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);
|
||||
}
|
||||
|
|
@ -441,62 +360,49 @@ Int klen;
|
|||
cnt++;
|
||||
}
|
||||
|
||||
|
||||
if (!flg) *dst = ptr;
|
||||
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
TypeIdxOfs count_uidx()
|
||||
TypeIdxOfs
|
||||
count_uidx (void)
|
||||
{
|
||||
Uchar *p;
|
||||
|
||||
|
||||
p = get_idxptr(curdict->segunit - 1);
|
||||
while (*p++) ;
|
||||
|
||||
|
||||
return (curdict->idxlen - (p - idxbuf));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Void chg_uidx(seg, yomi, len)
|
||||
TypeDicSeg seg;
|
||||
Uchar *yomi;
|
||||
Int len;
|
||||
void
|
||||
chg_uidx (TypeDicSeg seg, Uchar *yomi, Int len)
|
||||
{
|
||||
Uchar *p, *q;
|
||||
Int olen;
|
||||
|
||||
|
||||
p = get_idxptr(seg);
|
||||
|
||||
|
||||
olen = sstrlen(p);
|
||||
olen = strlen(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)(curdict, 0);
|
||||
|
||||
|
||||
mkidxtbl(curdict);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue