This commit is contained in:
Nishi 2026-06-19 01:49:53 +09:00
commit 73cb09624a
116 changed files with 19741 additions and 21522 deletions

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,66 +28,66 @@
*/
/*
* $SonyRCSfile: char.c,v $
* $SonyRevision: 1.1 $
* $SonyRCSfile: char.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:32 $
*/
#include "sj_euc.h"
#include "sj3_dict_const.h"
#include "sj3mkdic.h"
int
cnvyomi(int code)
{
int cnvyomi(int code) {
u_short hh;
u_char high;
u_char low;
u_char low;
hh = ((code >> 16) & 0xffff);
hh = ((code >> 16) & 0xffff);
high = ((code >> 8) & 0xff);
low = (code & 0xff);
low = (code & 0xff);
if (!hh) {
if (high == 0xa1) {
switch (low) {
case 0xbc: return 1;
case 0xf4: return 2;
case 0xf7: return 3;
case 0xa7: return 4;
if(!hh) {
if(high == 0xa1) {
switch(low) {
case 0xbc:
return 1;
case 0xf4:
return 2;
case 0xf7:
return 3;
case 0xa7:
return 4;
}
}
else if (high == 0xa2) {
if (low == 0xa9)
return 4;
}
else if (high == 0xa3) {
if (low < 0xb0)
;
else if (low <= 0xb9)
return(low - 0xb0 + 0x10);
else if (low < 0xc0)
;
else if (low <= 0xda)
return(low - 0xc1 + 0x1A);
else if (low < 0xe1)
;
else if (low <= 0xfa)
return(low - 0xe1 + 0x34);
}
else if (high == 0xa4) {
if (low < 0xa1)
;
else if (low <= 0xf3)
return(low - 0xa1 + 0x4e);
}
else if (high == 0xa5) {
switch (low) {
case 0xf4: return 0xa1;
case 0xf5: return 0xa2;
case 0xf6: return 0xa3;
} else if(high == 0xa2) {
if(low == 0xa9)
return 4;
} else if(high == 0xa3) {
if(low < 0xb0)
;
else if(low <= 0xb9)
return (low - 0xb0 + 0x10);
else if(low < 0xc0)
;
else if(low <= 0xda)
return (low - 0xc1 + 0x1A);
else if(low < 0xe1)
;
else if(low <= 0xfa)
return (low - 0xe1 + 0x34);
} else if(high == 0xa4) {
if(low < 0xa1)
;
else if(low <= 0xf3)
return (low - 0xa1 + 0x4e);
} else if(high == 0xa5) {
switch(low) {
case 0xf4:
return 0xa1;
case 0xf5:
return 0xa2;
case 0xf6:
return 0xa3;
}
}
}
@ -95,177 +95,172 @@ cnvyomi(int code)
return 0;
}
int
h2kcode(int code)
{
int h2kcode(int code) {
u_short hh;
u_char high;
u_char low;
hh = ((code >> 16) & 0xffff);
hh = ((code >> 16) & 0xffff);
high = ((code >> 8) & 0xff);
low = (code & 0xff);
low = (code & 0xff);
if (!hh) {
if (high != 0xa4)
return code;
if(!hh) {
if(high != 0xa4)
return code;
else
return (code + 0x0100);
return (code + 0x0100);
}
return code; /* XXX */
}
int
codesize(u_char code)
{
switch (code & KANJIMODEMASK) {
case ZENHIRAASSYUKU:
case ZENKATAASSYUKU:
case KANJIASSYUKU:
case KANJISTREND:
int codesize(u_char code) {
switch(code & KANJIMODEMASK) {
case ZENHIRAASSYUKU:
case ZENKATAASSYUKU:
case KANJIASSYUKU:
case KANJISTREND:
return 1;
case LEADINGHANKAKU:
case OFFSETASSYUKU:
case AIATTRIBUTE:
case LEADINGHANKAKU:
case OFFSETASSYUKU:
case AIATTRIBUTE:
return 2;
default:
default:
return 2;
}
}
void
output_knj(FILE *fp, u_char *p, int l)
{
while (l > 0) {
switch (*p & KANJIMODEMASK) {
case ZENHIRAASSYUKU:
void output_knj(FILE* fp, u_char* p, int l) {
while(l > 0) {
switch(*p & KANJIMODEMASK) {
case ZENHIRAASSYUKU:
fprintf(fp, "\244\322%d", (*p++ & 0x0f) + 1);
l--;
break;
case ZENKATAASSYUKU:
case ZENKATAASSYUKU:
fprintf(fp, "\245\253%d", (*p++ & 0x0f) + 1);
l--;
break;
case KANJIASSYUKU:
case KANJIASSYUKU:
fprintf(fp, "\260\265%1x", (*p++ & 0x0f));
l--;
break;
case LEADINGHANKAKU:
case LEADINGHANKAKU:
#ifndef USEHANKAKUINDICT
l = 0;
fprintf(stderr, "\244\252\244\253\244\267\244\244");
#else
fputc(*p++, fp); l--;
fputc(*p++, fp); l--;
fputc(*p++, fp);
l--;
fputc(*p++, fp);
l--;
#endif
break;
case OFFSETASSYUKU:
case OFFSETASSYUKU:
fprintf(fp, "ofs%1x", (*p++ & 0x0f));
l--;
fprintf(fp, "%02x", *p++); l--;
fprintf(fp, "%02x", *p++);
l--;
break;
case AIATTRIBUTE:
case AIATTRIBUTE:
fprintf(fp, "\302\260%1x", (*p++ & 0x0f));
l--;
fprintf(fp, "%02x", *p++); l--;
fprintf(fp, "%02x", *p++);
l--;
break;
case KANJISTREND:
p++; l--;
case KANJISTREND:
p++;
l--;
break;
default:
if (p[1] & 0x80)
fputc(SS3, fp);
fputc((*p | 0x80), fp); l--; p++;
fputc((*p | 0x80), fp); l--; p++;
}
default:
if(p[1] & 0x80)
fputc(SS3, fp);
fputc((*p | 0x80), fp);
l--;
p++;
fputc((*p | 0x80), fp);
l--;
p++;
}
}
}
void
output_str(FILE *fp, char *p)
{
while (*p) { fputc(*p, fp); p++; }
void output_str(FILE* fp, char* p) {
while(*p) {
fputc(*p, fp);
p++;
}
}
void
output_int(FILE *fp, int *p)
{
while (*p) {
if (*p < 0x100) {
fputc(*p, fp); p++;
}
else if (*p < 0x10000) {
void output_int(FILE* fp, int* p) {
while(*p) {
if(*p < 0x100) {
fputc(*p, fp);
p++;
} else if(*p < 0x10000) {
fputc((*p >> 8) & 0xff, fp);
fputc(*p & 0xff, fp); p++;
}
else if (*p < 0x1000000) {
fputc(*p & 0xff, fp);
p++;
} else if(*p < 0x1000000) {
fputc((*p >> 16) & 0xff, fp);
fputc((*p >> 8) & 0xff, fp);
fputc(*p & 0xff, fp); p++;
}
else {
fputc(*p & 0xff, fp);
p++;
} else {
fputc((*p >> 24) & 0xff, fp);
fputc((*p >> 16) & 0xff, fp);
fputc((*p >> 8) & 0xff, fp);
fputc(*p & 0xff, fp); p++;
fputc(*p & 0xff, fp);
p++;
}
}
}
int yomi2zen(int code) {
static char num[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
int
yomi2zen(int code)
{
static char num[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
};
switch (code) {
case 0x01: return 0xa1bc;
case 0x02: return 0xa1f4;
case 0x03: return 0xa1f7;
case 0x04: return 0xa2a9;
case 0xa1: return 0xa5f4;
case 0xa2: return 0xa5f5;
case 0xa3: return 0xa5f6;
default: break;
switch(code) {
case 0x01:
return 0xa1bc;
case 0x02:
return 0xa1f4;
case 0x03:
return 0xa1f7;
case 0x04:
return 0xa2a9;
case 0xa1:
return 0xa5f4;
case 0xa2:
return 0xa5f5;
case 0xa3:
return 0xa5f6;
default:
break;
}
if (code < 0x10)
if(code < 0x10)
;
else if (code < 0x1a)
return(0xa300 + code - 0x10 + 0xb0);
else if(code < 0x1a)
return (0xa300 + code - 0x10 + 0xb0);
else if (code < 0x34)
return(0xa300 + code - 0x1a + 0xc1);
else if(code < 0x34)
return (0xa300 + code - 0x1a + 0xc1);
else if (code < 0x4e)
return(0xa300 + code - 0x34 + 0xe1);
else if(code < 0x4e)
return (0xa300 + code - 0x34 + 0xe1);
else if (code < 0xa1)
return(0xa400 + code - 0x4e + 0xa1);
else if(code < 0xa1)
return (0xa400 + code - 0x4e + 0xa1);
return ((num[(code >> 4) & 0x0f] << 8) | num[code & 0x0f]);
}
void output_yomi(FILE* fp, u_char* p) {
int i;
void
output_yomi(FILE *fp, u_char *p)
{
int i;
while (*p) {
while(*p) {
i = yomi2zen(*p++);
fputc((i >> 8) & 0xff, fp);
fputc(i & 0xff, fp);

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,88 +28,73 @@
*/
/*
* $SonyRCSfile: cnvhinsi.c,v $
* $SonyRevision: 1.2 $
* $SonyRCSfile: cnvhinsi.c,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1996/05/27 06:59:47 $
*/
#include "sj3mkdic.h"
static struct gram_code {
char *name;
int code;
char* name;
int code;
} gramtbl[] = {
#include "GramTable"
};
#define GramMax (sizeof(gramtbl)/sizeof(struct gram_code) - 1)
#define GramMax (sizeof(gramtbl) / sizeof(struct gram_code) - 1)
int
u_strcmp(u_char *a, u_char *b)
{
if (!a || !b) return 0;
int u_strcmp(u_char* a, u_char* b) {
if(!a || !b) return 0;
while (*a && *b) {
if (*a < *b) return -1;
if (*a > *b) return 1;
while(*a && *b) {
if(*a < *b) return -1;
if(*a > *b) return 1;
a++;
b++;
}
if (!*a && !*b) return 0;
if (!*a) return -1;
if(!*a && !*b) return 0;
if(!*a) return -1;
return 1;
}
int
cnvhinsi(u_char *buf)
{
int min;
int max;
int mid;
int i;
int cnvhinsi(u_char* buf) {
int min;
int max;
int mid;
int i;
min = 0;
max = GramMax;
while (min <= max) {
while(min <= max) {
mid = (min + max) / 2;
i = u_strcmp(buf, gramtbl[mid].name);
if (i < 0) {
if(i < 0) {
max = mid - 1;
}
else if (i > 0) {
else if(i > 0) {
min = mid + 1;
}
else {
return(gramtbl[mid].code);
return (gramtbl[mid].code);
}
}
return 0;
}
char* hinsi_str(int code) {
int i;
char *
hinsi_str(int code)
{
int i;
for (i = 0 ; i <= GramMax ; i++) {
if (gramtbl[i].code == code) return gramtbl[i].name;
for(i = 0; i <= GramMax; i++) {
if(gramtbl[i].code == code) return gramtbl[i].name;
}
return "Err";

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,129 +28,112 @@
*/
/*
* $SonyRCSfile: file.c,v $
* $SonyRevision: 1.2 $
* $SonyRCSfile: file.c,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1995/02/03 07:38:32 $
*/
#include "sj3mkdic.h"
typedef struct filelist {
FILE *fp;
char *fname;
struct filelist *next;
typedef struct filelist {
FILE* fp;
char* fname;
struct filelist* next;
} FileList;
static FileList *flist = NULL;
static FileList* flist = NULL;
static char *
get_fname(FILE *fp)
{
FileList *p;
static char*
get_fname(FILE* fp) {
FileList* p;
for (p = flist ; p ; p = p -> next)
if (p -> fp == fp) return p -> fname;
for(p = flist; p; p = p->next)
if(p->fp == fp) return p->fname;
return "some file";
}
FILE *
Fopen(char *filename, char *type)
{
FILE *fp;
char *p;
FileList *fl;
size_t len;
FILE* Fopen(char* filename, char* type) {
FILE* fp;
char* p;
FileList* fl;
size_t len;
if (!(fp = fopen(filename, type))) {
if(!(fp = fopen(filename, type))) {
fprintf(stderr, "Can't open %s mode \"%s\"\n", filename, type);
exit(1);
}
fl = (FileList *)Malloc(sizeof(*fl));
len = strlen(filename) + 1;
fl -> fname = Malloc(len);
strlcpy(fl -> fname, filename, len);
fl -> fp = fp;
fl -> next = flist;
fl = (FileList*)Malloc(sizeof(*fl));
len = strlen(filename) + 1;
fl->fname = Malloc(len);
strlcpy(fl->fname, filename, len);
fl->fp = fp;
fl->next = flist;
return fp;
}
void
Fclose(FILE *fp)
{
void Fclose(FILE* fp) {
FileList *p, *q;
if (fclose(fp) == EOF) {
if(fclose(fp) == EOF) {
fprintf(stderr, "Close error in %s\n", get_fname(fp));
exit(1);
}
for (p = flist, q = NULL ; p ; q = p, p = p -> next) {
if (p -> fp == fp) {
if (q)
q -> next = p -> next;
for(p = flist, q = NULL; p; q = p, p = p->next) {
if(p->fp == fp) {
if(q)
q->next = p->next;
else
flist = p -> next;
free(p -> fname);
flist = p->next;
free(p->fname);
free(p);
break;
}
}
}
int
Fseek(FILE *fp, long ofs, int ptr)
{
if (fseek(fp, ofs, ptr) == 0) return 0;
int Fseek(FILE* fp, long ofs, int ptr) {
if(fseek(fp, ofs, ptr) == 0) return 0;
fprintf(stderr, "Seek error in %s\n", get_fname(fp));
exit(1);
}
long
Ftell(FILE *fp)
{
long Ftell(FILE* fp) {
return ftell(fp);
}
long
Fsize(char *filename)
{
struct stat buf;
long Fsize(char* filename) {
struct stat buf;
if (stat(filename, &buf) == 0) return (long)buf.st_size;
if(stat(filename, &buf) == 0) return (long)buf.st_size;
fprintf(stderr, "Stat error in %s\n", filename);
exit(1);
}
size_t
Fread(char *p, int s, int n, FILE *fp)
{
if (fread(p, s, n, fp) == n) return n;
Fread(char* p, int s, int n, FILE* fp) {
if(fread(p, s, n, fp) == n) return n;
fprintf(stderr, "Read error in %s\n", get_fname(fp));
exit(1);
}
size_t
Fwrite(char *p, int s, int n, FILE *fp)
{
if (fwrite(p, s, n, fp) == n) return n;
Fwrite(char* p, int s, int n, FILE* fp) {
if(fwrite(p, s, n, fp) == n) return n;
fprintf(stderr, "Write error in %s\n", get_fname(fp));
exit(1);
}
int
Fgetc(FILE *fp)
{
int Fgetc(FILE* fp) {
return fgetc(fp);
}
int
Fflush(FILE *fp)
{
return fflush(fp);
int Fflush(FILE* fp) {
return fflush(fp);
}

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,31 +28,30 @@
*/
/*
* $SonyRCSfile: global.c,v $
* $SonyRevision: 1.1 $
* $SonyRCSfile: global.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:35 $
*/
#include "sj3_dict_struct.h"
#include "sj3mkdic.h"
DouonRec *douon_ptr = NULL;
int douon_num = 0;
int yomi_len = 0;
int hinsi_num = 0;
int kanji_len = 0;
DouonRec* douon_ptr = NULL;
int douon_num = 0;
int yomi_len = 0;
int hinsi_num = 0;
int kanji_len = 0;
HindoRec *hindo[MAXHINDONUMBER];
int hindo_num = 0;
HindoRec* hindo[MAXHINDONUMBER];
int hindo_num = 0;
OffsetRec *ofsrec[MAXOFFSETNUMBER];
int ofsrec_num = 0;
OffsetRec* ofsrec[MAXOFFSETNUMBER];
int ofsrec_num = 0;
AssyukuRec *assyuku = NULL;
AssyukuRec* assyuku = NULL;
HindoRec *askknj[MAXKNJASKNUMBER];
int askknj_num = 0;
HindoRec* askknj[MAXKNJASKNUMBER];
int askknj_num = 0;
int kanji_num = 0;
int kanji_num = 0;

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,236 +28,212 @@
*/
/*
* $SonyRCSfile: hindo.c,v $
* $SonyRevision: 1.2 $
* $SonyRCSfile: hindo.c,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1994/08/17 01:50:26 $
*/
#include "sj3_dict_struct.h"
#include "sj3mkdic.h"
int
check_hindo(u_char *ptr, int len)
{
int low, high, mid;
int i;
int check_hindo(u_char* ptr, int len) {
int low, high, mid;
int i;
if (hindo_num <= 0) return 0;
if(hindo_num <= 0) return 0;
low = 0; high = hindo_num - 1;
while (low <= high) {
low = 0;
high = hindo_num - 1;
while(low <= high) {
mid = (low + high) / 2;
i = string_cmp(hindo[mid]->kptr, hindo[mid]->klen, ptr, len);
if (i > 0)
i = string_cmp(hindo[mid]->kptr, hindo[mid]->klen, ptr, len);
if(i > 0)
high = mid - 1;
else if (i < 0)
else if(i < 0)
low = ++mid;
else
return(hindo[mid]->exist + hindo[mid]->hindo);
return (hindo[mid]->exist + hindo[mid]->hindo);
}
return 0;
}
static AssyukuRec*
makeassyuku(int num) {
AssyukuRec* arec;
static AssyukuRec *
makeassyuku(int num)
{
AssyukuRec *arec;
arec = (AssyukuRec *)Malloc(sizeof(AssyukuRec));
if (!arec) {
arec = (AssyukuRec*)Malloc(sizeof(AssyukuRec));
if(!arec) {
fprintf(stderr, "\245\341\245\342\245\352\244\254\302\255\244\352\244\336\244\273\244\363\n");
exit(1);
}
arec -> len = num;
arec -> nrec = NULL;
arec -> anext = NULL;
arec->len = num;
arec->nrec = NULL;
arec->anext = NULL;
return arec;
}
static int
assyuku_len(HindoRec *hrec)
{
int org;
int old;
int new;
OffsetRec *p;
assyuku_len(HindoRec* hrec) {
int org;
int old;
int new;
OffsetRec* p;
if (((*(hrec->kptr) & KANJIMODEMASK) == OFFSETASSYUKU) &&
(hrec->klen == 2)) {
p = real_ofsrec(hrec -> kptr);
org = check_hindo(p -> kptr, p -> klen);
if(((*(hrec->kptr) & KANJIMODEMASK) == OFFSETASSYUKU) &&
(hrec->klen == 2)) {
p = real_ofsrec(hrec->kptr);
org = check_hindo(p->kptr, p->klen);
old = p->klen * org + 2 * (hrec->exist + hrec->hindo);
new = p->klen + (hrec->exist + hrec->hindo + org);
}
else {
old = hrec -> klen * (hrec -> exist + hrec -> hindo);
new = hrec -> klen + (hrec -> exist + hrec -> hindo);
} else {
old = hrec->klen * (hrec->exist + hrec->hindo);
new = hrec->klen + (hrec->exist + hrec->hindo);
}
return (old - new);
}
static void
set_assyuku(HindoRec *hrec)
{
AssyukuRec *arec;
AssyukuRec *aprev;
int len;
set_assyuku(HindoRec* hrec) {
AssyukuRec* arec;
AssyukuRec* aprev;
int len;
len = assyuku_len(hrec);
if (len <= 0) return;
if(len <= 0) return;
arec = assyuku; aprev = NULL;
while (arec) {
if (arec -> len == len) {
hrec -> arec = arec;
hrec -> anext = arec -> nrec;
arec -> nrec = hrec;
arec = assyuku;
aprev = NULL;
while(arec) {
if(arec->len == len) {
hrec->arec = arec;
hrec->anext = arec->nrec;
arec->nrec = hrec;
return;
}
else if (arec -> len < len)
} else if(arec->len < len)
break;
aprev = arec;
arec = arec -> anext;
arec = arec->anext;
}
arec = makeassyuku(len);
hrec -> anext = NULL;
hrec -> arec = arec;
arec -> nrec = hrec;
hrec->anext = NULL;
hrec->arec = arec;
arec->nrec = hrec;
if (aprev) {
arec -> anext = aprev -> anext;
aprev -> anext = arec;
}
else {
arec -> anext = assyuku;
assyuku = arec;
if(aprev) {
arec->anext = aprev->anext;
aprev->anext = arec;
} else {
arec->anext = assyuku;
assyuku = arec;
}
}
static void
reset_assyuku(HindoRec *hrec)
{
AssyukuRec *arec;
AssyukuRec *aptr;
AssyukuRec *aprev;
HindoRec *hptr;
HindoRec *hprev;
reset_assyuku(HindoRec* hrec) {
AssyukuRec* arec;
AssyukuRec* aptr;
AssyukuRec* aprev;
HindoRec* hptr;
HindoRec* hprev;
arec = hrec -> arec;
arec = hrec->arec;
if (!arec) return;
hrec -> arec = NULL;
if(!arec) return;
hrec->arec = NULL;
hptr = arec -> nrec; hprev = NULL;
while (hptr) {
if (hptr == hrec) break;
hptr = arec->nrec;
hprev = NULL;
while(hptr) {
if(hptr == hrec) break;
hprev = hptr;
hptr = hptr -> anext;
hptr = hptr->anext;
}
if (!hptr) return;
if(!hptr) return;
if (hprev) {
hprev -> anext = hrec -> anext;
hrec -> anext = NULL;
if(hprev) {
hprev->anext = hrec->anext;
hrec->anext = NULL;
return;
}
if (hrec -> anext) {
arec -> nrec = hrec -> anext;
hrec -> anext = NULL;
if(hrec->anext) {
arec->nrec = hrec->anext;
hrec->anext = NULL;
return;
}
if (!assyuku) return;
aptr = assyuku; aprev = NULL;
while (aptr) {
if (aptr == arec) break;
if(!assyuku) return;
aptr = assyuku;
aprev = NULL;
while(aptr) {
if(aptr == arec) break;
aprev = aptr;
aptr = aptr -> anext;
aptr = aptr->anext;
}
if (!aptr) return;
if(!aptr) return;
if (aprev)
aprev -> anext = arec -> anext;
if(aprev)
aprev->anext = arec->anext;
else
assyuku = arec -> anext;
assyuku = arec->anext;
Free(arec);
hrec -> anext = NULL;
hrec->anext = NULL;
}
static HindoRec*
makehindo(u_char* ptr, int len, int alen) {
HindoRec* hrec;
u_char* p;
static HindoRec *
makehindo(u_char *ptr, int len, int alen)
{
HindoRec *hrec;
u_char *p;
hrec = (HindoRec *)Malloc(sizeof(HindoRec));
if (!hrec) {
hrec = (HindoRec*)Malloc(sizeof(HindoRec));
if(!hrec) {
fprintf(stderr, "\245\341\245\342\245\352\244\254\302\255\244\352\244\336\244\273\244\363\n");
exit(1);
}
p = (u_char *)Malloc(len);
if (!p) {
p = (u_char*)Malloc(len);
if(!p) {
fprintf(stderr, "\245\341\245\342\245\352\244\254\302\255\244\352\244\336\244\273\244\363\n");
exit(1);
}
hrec -> klen = len;
hrec -> kptr = p;
if (len == alen && len > 2) {
hrec -> hindo = 0;
hrec -> exist = 1;
hrec -> offset = ++kanji_num;
hrec->klen = len;
hrec->kptr = p;
if(len == alen && len > 2) {
hrec->hindo = 0;
hrec->exist = 1;
hrec->offset = ++kanji_num;
} else {
hrec->hindo = 1;
hrec->exist = 0;
hrec->offset = 0;
}
else {
hrec -> hindo = 1;
hrec -> exist = 0;
hrec -> offset = 0;
}
while (len-- > 0) *p++ = *ptr++;
hrec -> anext = NULL;
hrec -> arec = NULL;
while(len-- > 0) *p++ = *ptr++;
hrec->anext = NULL;
hrec->arec = NULL;
return hrec;
}
static void
set_hindo(u_char *ptr, int len, int alen)
{
HindoRec *hrec;
int low, high, mid;
int i;
set_hindo(u_char* ptr, int len, int alen) {
HindoRec* hrec;
int low, high, mid;
int i;
if (hindo_num <= 0) {
hrec = makehindo(ptr, len, alen);
hindo[0]= hrec;
if(hindo_num <= 0) {
hrec = makehindo(ptr, len, alen);
hindo[0] = hrec;
hindo_num = 1;
set_assyuku(hrec);
@ -265,87 +241,83 @@ set_hindo(u_char *ptr, int len, int alen)
return;
}
low = 0; high = hindo_num - 1;
while (low <= high) {
low = 0;
high = hindo_num - 1;
while(low <= high) {
mid = (low + high) / 2;
i = string_cmp(hindo[mid]->kptr, hindo[mid]->klen, ptr, len);
if (i > 0)
i = string_cmp(hindo[mid]->kptr, hindo[mid]->klen, ptr, len);
if(i > 0)
high = mid - 1;
else if (i < 0)
else if(i < 0)
low = ++mid;
else
break;
}
if (i) {
if (hindo_num >= MAXHINDONUMBER) {
if(i) {
if(hindo_num >= MAXHINDONUMBER) {
fprintf(stderr, "\311\321\305\331\245\306\241\274\245\326\245\353\244\254\244\242\244\325\244\354\244\336\244\267\244\277\n");
exit(1);
}
hrec = makehindo(ptr, len, alen);
for (i = hindo_num ; i > mid ; i--) hindo[i] = hindo[i - 1];
for(i = hindo_num; i > mid; i--) hindo[i] = hindo[i - 1];
hindo[mid] = hrec;
hindo_num++;
}
else {
} else {
hrec = hindo[mid];
reset_assyuku(hrec);
if (hrec -> exist > 0)
hrec -> exist += 1;
if(hrec->exist > 0)
hrec->exist += 1;
else if (len == alen && len > 2) {
hrec -> exist = 1;
hrec -> offset = ++kanji_num;
}
else
hrec -> hindo += 1;
else if(len == alen && len > 2) {
hrec->exist = 1;
hrec->offset = ++kanji_num;
} else
hrec->hindo += 1;
}
set_assyuku(hrec);
}
static void
reset_hindo(u_char *p, int l)
{
HindoRec *hrec;
int low, high, mid;
int i;
reset_hindo(u_char* p, int l) {
HindoRec* hrec;
int low, high, mid;
int i;
if (hindo_num <= 0) return;
if(hindo_num <= 0) return;
low = 0; high = hindo_num - 1;
while (low <= high) {
low = 0;
high = hindo_num - 1;
while(low <= high) {
mid = (low + high) / 2;
i = string_cmp(hindo[mid]->kptr, hindo[mid]->klen, p, l);
if (i > 0)
i = string_cmp(hindo[mid]->kptr, hindo[mid]->klen, p, l);
if(i > 0)
high = mid - 1;
else if (i < 0)
else if(i < 0)
low = ++mid;
else {
hrec = hindo[mid];
reset_assyuku(hrec);
if (hrec -> exist > 0)
hrec -> exist -= 1;
else if (hrec -> hindo > 0)
hrec -> hindo -= 1;
if(hrec->exist > 0)
hrec->exist -= 1;
else if(hrec->hindo > 0)
hrec->hindo -= 1;
if (hrec -> exist + hrec -> hindo == 0) {
while (++mid < hindo_num) {
if(hrec->exist + hrec->hindo == 0) {
while(++mid < hindo_num) {
hindo[mid - 1] = hindo[mid];
}
hindo_num--;
Free(hrec -> kptr);
Free(hrec->kptr);
Free(hrec);
}
else {
} else {
set_assyuku(hrec);
}
@ -355,29 +327,24 @@ reset_hindo(u_char *p, int l)
}
}
void
knjhnd_set(u_char *p, int l)
{
u_char *kp1;
u_char *kp2;
void knjhnd_set(u_char* p, int l) {
u_char* kp1;
u_char* kp2;
int i;
int kl1;
u_char tmp[MAXKANJILENGTH * 2 + MAXATRNUMBER * 2 + 1];
for (kp1 = p, kl1 = l ; kl1 > 0 ; ) {
for (i = 0, kp2 = kp1 ; i < kl1 ; ) {
if (codesize(*kp2) == 1) {
for(kp1 = p, kl1 = l; kl1 > 0;) {
for(i = 0, kp2 = kp1; i < kl1;) {
if(codesize(*kp2) == 1) {
tmp[i++] = *kp2++;
}
else if (codesize(*kp2) == 2) {
} else if(codesize(*kp2) == 2) {
tmp[i++] = *kp2++;
tmp[i++] = *kp2++;
} else {
tmp[i++] = *kp2++;
tmp[i++] = *kp2++;
tmp[i++] = *kp2++;
tmp[i++] = *kp2++;
tmp[i++] = *kp2++;
tmp[i++] = *kp2++;
}
set_hindo(tmp, i, l);
}
@ -387,29 +354,24 @@ knjhnd_set(u_char *p, int l)
}
}
void
knjhnd_reset(u_char *p, int l)
{
u_char *kp1;
u_char *kp2;
void knjhnd_reset(u_char* p, int l) {
u_char* kp1;
u_char* kp2;
int i;
int kl1;
u_char tmp[MAXKANJILENGTH * 2 + MAXATRNUMBER * 2 + 1];
for (kp1 = p, kl1 = l ; kl1 > 0 ; ) {
for (i = 0, kp2 = kp1 ; i < kl1 ; ) {
if (codesize(*kp2) == 1) {
for(kp1 = p, kl1 = l; kl1 > 0;) {
for(i = 0, kp2 = kp1; i < kl1;) {
if(codesize(*kp2) == 1) {
tmp[i++] = *kp2++;
}
else if (codesize(*kp2) == 2) {
} else if(codesize(*kp2) == 2) {
tmp[i++] = *kp2++;
tmp[i++] = *kp2++;
} else {
tmp[i++] = *kp2++;
tmp[i++] = *kp2++;
tmp[i++] = *kp2++;
tmp[i++] = *kp2++;
tmp[i++] = *kp2++;
tmp[i++] = *kp2++;
}
reset_hindo(tmp, i);
}
@ -419,90 +381,81 @@ knjhnd_reset(u_char *p, int l)
}
}
static int
check_assyuku(HindoRec *p, HindoRec *q)
{
u_char ptmp[128], qtmp[128];
int plen;
int qlen;
check_assyuku(HindoRec* p, HindoRec* q) {
u_char ptmp[128], qtmp[128];
int plen;
int qlen;
plen = make_knjstr(p -> kptr, p -> klen, ptmp);
plen = make_knjstr(p->kptr, p->klen, ptmp);
qlen = make_knjstr(q -> kptr, q -> klen, qtmp);
qlen = make_knjstr(q->kptr, q->klen, qtmp);
if (bubun_str(ptmp, plen, qtmp, qlen)) {
if(bubun_str(ptmp, plen, qtmp, qlen)) {
return -1;
}
if (overlap_str(ptmp, plen, qtmp, qlen))
if(overlap_str(ptmp, plen, qtmp, qlen))
return -1;
return 0;
}
int
decide_knjask()
{
int i, j;
AssyukuRec *p;
HindoRec *q;
u_char *r;
int len = 0;
int decide_knjask() {
int i, j;
AssyukuRec* p;
HindoRec* q;
u_char* r;
int len = 0;
askknj_num = 0;
for (p = assyuku ; p ; p = p -> anext) {
if (p -> len <= 0) break;
for(p = assyuku; p; p = p->anext) {
if(p->len <= 0) break;
for (q = p -> nrec ; q ; q = q -> anext) {
for(q = p->nrec; q; q = q->anext) {
i = q -> klen;
r = q -> kptr;
if (i > 2) {
while (i > 0) {
if ((*r & KANJIMODEMASK)
== OFFSETASSYUKU) {
i = q->klen;
r = q->kptr;
if(i > 2) {
while(i > 0) {
if((*r & KANJIMODEMASK) == OFFSETASSYUKU) {
break;
}
j = codesize(*r);
i -= j;
r += j;
}
if (i) continue;
if(i) continue;
}
if (askknj_num) {
for (i = 0 ; i < askknj_num ; i++) {
if (check_assyuku(askknj[i], q))
if(askknj_num) {
for(i = 0; i < askknj_num; i++) {
if(check_assyuku(askknj[i], q))
break;
}
if (i >= askknj_num) {
if(i >= askknj_num) {
askknj[askknj_num++] = q;
len += p -> len;
if (askknj_num >= MAXKNJASKNUMBER)
len += p->len;
if(askknj_num >= MAXKNJASKNUMBER)
goto end;
}
}
else {
} else {
askknj[askknj_num++] = q;
len += p -> len;
len += p->len;
}
}
}
end:
{
int i, j, len;
u_char *p;
u_char* p;
for (i = 0 ; i < askknj_num ; i++) {
len = askknj[i] -> klen;
p = askknj[i] -> kptr;
if (len <= 2) continue;
while (len > 0) {
if ((*p & KANJIMODEMASK) == OFFSETASSYUKU) {
for(i = 0; i < askknj_num; i++) {
len = askknj[i]->klen;
p = askknj[i]->kptr;
if(len <= 2) continue;
while(len > 0) {
if((*p & KANJIMODEMASK) == OFFSETASSYUKU) {
printf("\245\252\245\325\245\273\245\303\245\310\260\265\275\314\244\362\264\336\244\340 %d\n", i);
}
j = codesize(*p);
@ -514,14 +467,10 @@ end:
return len;
}
void clear_hindo() {
int i;
void
clear_hindo()
{
int i;
for (i = 0 ; i < hindo_num ; i++) {
for(i = 0; i < hindo_num; i++) {
Free(hindo[i]->kptr);
Free(hindo[i]);
}
@ -529,16 +478,12 @@ clear_hindo()
kanji_num = 0;
}
void clear_assyuku() {
AssyukuRec* p;
void
clear_assyuku()
{
AssyukuRec *p;
while (assyuku) {
p = assyuku;
assyuku = assyuku -> anext;
while(assyuku) {
p = assyuku;
assyuku = assyuku->anext;
Free(p);
}
}

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,8 +28,8 @@
*/
/*
* $SonyRCSfile: knjcvt.c,v $
* $SonyRevision: 1.1 $
* $SonyRCSfile: knjcvt.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:37 $
*/
@ -39,149 +39,137 @@
#include "sj3mkdic.h"
typedef struct div_list {
int len;
u_char code[3];
struct div_list *child;
int len;
u_char code[3];
struct div_list* child;
} DivList;
static void
free_divlist(DivList *p)
{
DivList *q;
free_divlist(DivList* p) {
DivList* q;
while (p) {
q = p -> child;
while(p) {
q = p->child;
Free(p);
p = q;
}
}
static DivList*
make_divrec() {
DivList* p;
static DivList *
make_divrec()
{
DivList *p;
p = (DivList *)Malloc(sizeof(DivList));
if (!p) {
p = (DivList*)Malloc(sizeof(DivList));
if(!p) {
fprintf(stderr, "\245\341\245\342\245\352\244\254\302\255\244\352\244\336\244\273\244\363\n");
exit(1);
}
p -> child = NULL;
p->child = NULL;
return p;
}
static int
make_divlist(DivList *parent, u_char *knj, int len)
{
int i, j;
int num;
int minlen = 0;
int tmplen;
DivList tmprec;
DivList *minrec;
make_divlist(DivList* parent, u_char* knj, int len) {
int i, j;
int num;
int minlen = 0;
int tmplen;
DivList tmprec;
DivList* minrec;
minrec = make_divrec();
if (len == 0) {
if(len == 0) {
free_divlist(minrec);
parent -> child = NULL;
parent->child = NULL;
return 0;
} else if (len == 1) {
minrec -> len = len;
minrec -> code[0] = *knj;
} else if(len == 1) {
minrec->len = len;
minrec->code[0] = *knj;
parent -> child = minrec;
parent->child = minrec;
return len;
}
if (codesize(*knj) == 1) {
minrec -> len = 1;
minrec -> code[0] = *knj;
minlen = make_divlist(minrec, knj + 1, len - 1) + 1;
} else if (codesize(*knj) == 2) {
minrec -> len = 2;
minrec -> code[0] = *knj;
minrec -> code[1] = *(knj + 1);
minlen = make_divlist(minrec, knj + 2, len - 2) + 2;
if(codesize(*knj) == 1) {
minrec->len = 1;
minrec->code[0] = *knj;
minlen = make_divlist(minrec, knj + 1, len - 1) + 1;
} else if(codesize(*knj) == 2) {
minrec->len = 2;
minrec->code[0] = *knj;
minrec->code[1] = *(knj + 1);
minlen = make_divlist(minrec, knj + 2, len - 2) + 2;
}
for (i = 0 ; i < len ; i = j) {
for(i = 0; i < len; i = j) {
j = i + codesize(*(knj + i));
if (j <= 2 || !(num = isknjexist(knj, j)))
if(j <= 2 || !(num = isknjexist(knj, j)))
continue;
tmprec.len = 2;
tmprec.code[0] = (OFFSETASSYUKU | ((num >> 8) & 0xff));
tmprec.code[1] = (num & 0xff);
tmprec.child = NULL;
tmplen = make_divlist(&tmprec, knj + j, len - j) + 2;
tmplen = make_divlist(&tmprec, knj + j, len - j) + 2;
if (tmplen < minlen) {
free_divlist(minrec -> child);
if(tmplen < minlen) {
free_divlist(minrec->child);
*minrec = tmprec;
minlen = tmplen;
}
else
minlen = tmplen;
} else
free_divlist(tmprec.child);
}
for (i = 0 ; i < askknj_num ; i++) {
if ((j = askknj[i] -> klen) > len) continue;
for(i = 0; i < askknj_num; i++) {
if((j = askknj[i]->klen) > len) continue;
if (string_cmp(askknj[i]->kptr, j, knj, j)) continue;
if(string_cmp(askknj[i]->kptr, j, knj, j)) continue;
tmprec.len = 1;
tmprec.code[0] = (KANJIASSYUKU | i);
tmprec.child = NULL;
tmplen = make_divlist(&tmprec, knj + j, len - j) + 1;
tmplen = make_divlist(&tmprec, knj + j, len - j) + 1;
if (tmplen < minlen) {
free_divlist(minrec -> child);
if(tmplen < minlen) {
free_divlist(minrec->child);
*minrec = tmprec;
minlen = tmplen;
}
else
minlen = tmplen;
} else
free_divlist(tmprec.child);
}
parent -> child = minrec;
parent->child = minrec;
return minlen;
}
u_char *
knjofscvt(u_char *ptr, int len, int *ret)
{
u_char*
knjofscvt(u_char* ptr, int len, int* ret) {
int i;
u_char *p, *q;
u_char *p, *q;
DivList parent, *dl;
askknj_num = 0;
parent.child = NULL;
i = make_divlist(&parent, ptr, len);
*ret = i;
i = make_divlist(&parent, ptr, len);
*ret = i;
p = (u_char *)Malloc(i);
if (!p) {
p = (u_char*)Malloc(i);
if(!p) {
fprintf(stderr, "\245\341\245\342\245\352\244\254\311\324\302\255\244\267\244\336\244\267\244\277");
exit(1);
}
for (q = p, dl = parent.child ; dl ; dl = dl -> child) {
*q++ = dl -> code[0];
if (dl -> len == 2) {
*q++ = dl -> code[1];
} else if (dl -> len == 3) {
*q++ = dl -> code[1];
*q++ = dl -> code[2];
for(q = p, dl = parent.child; dl; dl = dl->child) {
*q++ = dl->code[0];
if(dl->len == 2) {
*q++ = dl->code[1];
} else if(dl->len == 3) {
*q++ = dl->code[1];
*q++ = dl->code[2];
}
}
@ -190,36 +178,34 @@ knjofscvt(u_char *ptr, int len, int *ret)
return p;
}
u_char *
knjcvt(u_char *ptr, int len, int *ret)
{
u_char*
knjcvt(u_char* ptr, int len, int* ret) {
int i;
u_char *p, *q;
u_char *p, *q;
DivList parent, *dl;
parent.child = NULL;
i = make_divlist(&parent, ptr, len);
*ret = i;
i = make_divlist(&parent, ptr, len);
*ret = i;
p = (u_char *)Malloc(i);
if (!p) {
p = (u_char*)Malloc(i);
if(!p) {
fprintf(stderr, "\245\341\245\342\245\352\244\254\311\324\302\255\244\267\244\336\244\267\244\277");
exit(1);
}
for (q = p, dl = parent.child ; dl ; dl = dl -> child) {
*q++ = dl -> code[0];
if (dl -> len == 2) {
*q++ = dl -> code[1];
} else if (dl -> len == 3) {
*q++ = dl -> code[1];
*q++ = dl -> code[2];
for(q = p, dl = parent.child; dl; dl = dl->child) {
*q++ = dl->code[0];
if(dl->len == 2) {
*q++ = dl->code[1];
} else if(dl->len == 3) {
*q++ = dl->code[1];
*q++ = dl->code[2];
}
}
free_divlist(parent.child);
if (i != q - p) {
if(i != q - p) {
printf("\244\263\244\263\n");
exit(1);
}

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,8 +28,8 @@
*/
/*
* $SonyRCSfile: makedict.c,v $
* $SonyRevision: 1.2 $
* $SonyRCSfile: makedict.c,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1994/12/09 11:27:05 $
*/
@ -37,44 +37,35 @@
#include "sj3mkdic.h"
FILE *infp = NULL;
FILE *outfp = NULL;
FILE* infp = NULL;
FILE* outfp = NULL;
static char *idxtop = NULL;
static char* idxtop = NULL;
int
main(int argc, char **argv)
{
int main(int argc, char** argv) {
parse(argc, argv);
while (readline())
while(readline())
setline(makelist);
flush_douon();
makehead((u_char *)argv[2]);
makehead((u_char*)argv[2]);
return 0;
}
char *
make_idxlist(char *name)
{
int i;
char *p;
char* make_idxlist(char* name) {
int i;
char* p;
i = strlen(name);
p = Zalloc(i + 2);
strlcpy(p, name, i + 2);
return p;
}
char *
get_idxlist(char *name)
{
FILE *fp;
int i;
char *p, *q, *r;
char* get_idxlist(char* name) {
FILE* fp;
int i;
char *p, *q, *r;
fp = Fopen(name, "r");
@ -85,10 +76,10 @@ get_idxlist(char *name)
Fread(p, 1, i, fp);
Fclose(fp);
for (q = r = p ; *q ; ) {
while (*q <= ' ')
for(q = r = p; *q;) {
while(*q <= ' ')
q++;
while (*q > ' ')
while(*q > ' ')
*r++ = *q++;
*r++ = 0;
q++;
@ -96,86 +87,69 @@ get_idxlist(char *name)
*r = 0;
i = 0;
for (q = p ; *q ; ) {
if (fp = fopen(q, "r"))
for(q = p; *q;) {
if(fp = fopen(q, "r"))
fclose(fp);
else {
fprintf(stderr, "Can't open %s mode \"r\"\n", q);
i++;
}
while (*q++)
;
while(*q++);
}
if (i) exit(1);
if(i) exit(1);
return p;
}
void parse(int argc, char** argv) {
int i;
char* progname = NULL;
char* p;
void
parse(int argc, char **argv)
{
int i;
char *progname = NULL;
char *p;
if (progname = strrchr(argv[0], '/'))
if(progname = strrchr(argv[0], '/'))
progname++;
else
progname = argv[0];
if (argc != 3)
if(argc != 3)
usage(progname);
p = argv[1];
p = argv[1];
idxtop = (*p == '-') ? get_idxlist(p + 1) : make_idxlist(p);
outfp = Fopen(argv[2], "w");
}
/* XXX: strtonum??? */
int
get_number(char *ptr)
{
int i = 0;
int get_number(char* ptr) {
int i = 0;
while (*ptr >= '0' && *ptr <= '9') {
while(*ptr >= '0' && *ptr <= '9') {
i = i * 10 + (*ptr++ - '0');
}
return(i);
return (i);
}
void
usage(char *name)
{
void usage(char* name) {
fprintf(stderr, "Usage: %s text_file binary_file\n",
name ? name : "encode");
exit(0);
}
int getch() {
if(infp) {
int c;
int
getch()
{
if (infp) {
int c;
if ((c = Fgetc(infp)) != EOF) return c;
if((c = Fgetc(infp)) != EOF) return c;
Fclose(infp);
infp = NULL;
while (*idxtop++)
;
while(*idxtop++);
}
if (*idxtop) {
if(*idxtop) {
infp = Fopen(idxtop, "r");
fprintf(stderr, "Reading %s\n", idxtop);
@ -187,29 +161,25 @@ getch()
return EOF;
}
void mark_file(FILE* out) {
static char pathname[512];
static long pos;
void
mark_file(FILE *out)
{
static char pathname[512];
static long pos;
if (out) {
FILE *fp;
int c;
if(out) {
FILE* fp;
int c;
fprintf(out, "%s:\t", pathname);
fp = Fopen(pathname, "r");
Fseek(fp, pos, 0);
c = Fgetc(fp);
while (c != EOF && c != '\n') {
while(c != EOF && c != '\n') {
fputc(c, out);
c = Fgetc(fp);
}
fputc('\n', out);
Fclose(fp);
}
else {
} else {
strlcpy(pathname, idxtop, sizeof(pathname));
pos = infp ? Ftell(infp) : 0;
}

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,8 +28,8 @@
*/
/*
* $SonyRCSfile: makelist.c,v $
* $SonyRevision: 1.1 $
* $SonyRCSfile: makelist.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:39 $
*/
@ -41,56 +41,48 @@
#define SS2 0x8e
#endif
static DouonRec *drectmp = NULL;
static DouonRec* drectmp = NULL;
static void
clearklist(KanjiRec *krec)
{
KanjiRec *p;
clearklist(KanjiRec* krec) {
KanjiRec* p;
while (krec) {
Free(krec -> kptr);
Free(krec -> aptr);
while(krec) {
Free(krec->kptr);
Free(krec->aptr);
p = krec;
krec = krec -> knext;
p = krec;
krec = krec->knext;
Free(p);
}
}
static void
clearhlist(HinsiRec *hrec)
{
HinsiRec *p;
clearhlist(HinsiRec* hrec) {
HinsiRec* p;
while (hrec) {
clearklist(hrec -> krec);
while(hrec) {
clearklist(hrec->krec);
p = hrec;
hrec = hrec -> hnext;
p = hrec;
hrec = hrec->hnext;
Free(p);
}
}
void clear_list() {
DouonRec* p;
DouonRec* drec = douon_ptr;
while(drec) {
Free(drec->yptr);
void
clear_list()
{
DouonRec *p;
DouonRec *drec = douon_ptr;
clearhlist(drec->hrec);
while (drec) {
Free(drec -> yptr);
clearhlist(drec -> hrec);
p = drec;
drec = drec -> dnext;
p = drec;
drec = drec->dnext;
Free(p);
}
@ -98,62 +90,56 @@ clear_list()
douon_ptr = NULL;
}
static u_char *
makekanji(int *yomi, int *kanji, int *atr, int *len)
{
static u_char*
makekanji(int* yomi, int* kanji, int* atr, int* len) {
int kana[MAXYOMILENGTH + 1];
u_char ktmp[MAXKANJILENGTH * 3 + MAXATRNUMBER * 2 + 1];
int i;
int pos = 0;
int *p;
u_char *q;
int* p;
u_char* q;
for (p = yomi, i = 0 ; *p ; )
for(p = yomi, i = 0; *p;)
kana[i++] = h2kcode(*p++);
kana[i] = 0;
while (*atr) {
while(*atr) {
i = *atr;
atr++;
#ifndef NO_ATR
#ifndef NO_ATR
ktmp[pos++] = (AIATTRIBUTE | ((i >> 8) & 0xff));
ktmp[pos++] = (i & 0xff);
ktmp[pos++] = (i & 0xff);
#endif
}
if (i = top_strcmp(yomi, kanji)) {
if(i = top_strcmp(yomi, kanji)) {
kanji += i;
ktmp[pos++] = (ZENHIRAASSYUKU | (i - 1));
} else if (i = top_strcmp(kana, kanji)) {
} else if(i = top_strcmp(kana, kanji)) {
kanji += i;
ktmp[pos++] = (ZENKATAASSYUKU | (i - 1));
}
while (*kanji) {
if (i = last_strcmp(yomi, kanji)) {
while(*kanji) {
if(i = last_strcmp(yomi, kanji)) {
kanji += i;
ktmp[pos++] = (ZENHIRAASSYUKU | (i - 1));
}
else if (i = last_strcmp(kana, kanji)) {
} else if(i = last_strcmp(kana, kanji)) {
kanji += i;
ktmp[pos++] = (ZENKATAASSYUKU | (i - 1));
}
else if (((*kanji >> 8) & 0xff) == SS2 || *kanji < 0x100) {
ktmp[pos] = LEADINGHANKAKU;
} else if(((*kanji >> 8) & 0xff) == SS2 || *kanji < 0x100) {
ktmp[pos] = LEADINGHANKAKU;
ktmp[pos + 1] = (*kanji & 0xff);
kanji++;
pos += 2;
}
else {
if (*kanji < 0x10000) {
ktmp[pos] = ((*kanji >> 8) & NORMALKANJIMASK);
} else {
if(*kanji < 0x10000) {
ktmp[pos] = ((*kanji >> 8) & NORMALKANJIMASK);
ktmp[pos + 1] = (*kanji & NORMALKANJIMASK);
kanji++;
pos += 2;
} else if (*kanji < 0x1000000) {
ktmp[pos] = ((*kanji >> 8) & NORMALKANJIMASK);
} else if(*kanji < 0x1000000) {
ktmp[pos] = ((*kanji >> 8) & NORMALKANJIMASK);
ktmp[pos + 1] = (*kanji & 0xff);
kanji++;
pos += 2;
@ -165,8 +151,8 @@ makekanji(int *yomi, int *kanji, int *atr, int *len)
}
*len = pos;
q = (u_char *)Malloc(pos);
if (!q) {
q = (u_char*)Malloc(pos);
if(!q) {
fprintf(stderr, "\245\341\245\342\245\352\244\254\311\324\302\255\244\267\244\336\244\267\244\277");
exit(1);
}
@ -175,30 +161,28 @@ makekanji(int *yomi, int *kanji, int *atr, int *len)
return q;
}
static u_char *
makeyomi(int *yomi)
{
static u_char*
makeyomi(int* yomi) {
u_char tmp[MAXYOMILENGTH + 1];
int i;
int j;
int *y = yomi;
u_char *p;
int* y = yomi;
u_char* p;
for (i = 0 ; *y ; ) {
for(i = 0; *y;) {
j = cnvyomi(*y++);
if (j == 0) {
if(j == 0) {
fprintf(stderr, "\311\324\300\265\244\312\312\270\273\372\244\254\306\311\244\337\244\313\273\310\244\357\244\354\244\306\244\244\244\336\244\271\n");
output_int(stderr, yomi); fputc('\n', stderr);
output_int(stderr, yomi);
fputc('\n', stderr);
exit(1);
}
tmp[i++] = j;
}
tmp[i++] = 0;
p = (u_char *)Malloc(i);
if (!p) {
p = (u_char*)Malloc(i);
if(!p) {
fprintf(stderr, "\245\341\245\342\245\352\244\254\311\324\302\255\244\267\244\336\244\267\244\277");
exit(1);
}
@ -207,216 +191,204 @@ makeyomi(int *yomi)
return p;
}
static KanjiRec*
make_krec(u_char* kcode, int klen) {
KanjiRec* krec;
static KanjiRec *
make_krec(u_char *kcode, int klen)
{
KanjiRec *krec;
krec = (KanjiRec *)Malloc(sizeof(KanjiRec));
if (!krec) {
krec = (KanjiRec*)Malloc(sizeof(KanjiRec));
if(!krec) {
fprintf(stderr, "\245\341\245\342\245\352\244\254\311\324\302\255\244\267\244\336\244\267\244\277");
exit(1);
}
krec -> klen = klen;
krec -> kptr = kcode;
krec -> alen = 0;
krec -> aptr = NULL;
krec -> knext = NULL;
krec->klen = klen;
krec->kptr = kcode;
krec->alen = 0;
krec->aptr = NULL;
krec->knext = NULL;
return krec;
}
static HinsiRec*
make_hrec(int hinsi) {
HinsiRec* hrec;
static HinsiRec *
make_hrec(int hinsi)
{
HinsiRec *hrec;
hrec = (HinsiRec *)Malloc(sizeof(HinsiRec));
if (!hrec) {
hrec = (HinsiRec*)Malloc(sizeof(HinsiRec));
if(!hrec) {
fprintf(stderr, "\245\341\245\342\245\352\244\254\311\324\302\255\244\267\244\336\244\267\244\277");
exit(1);
}
hrec -> hinsi = hinsi;
hrec -> krec = NULL;
hrec -> hnext = NULL;
hrec->hinsi = hinsi;
hrec->krec = NULL;
hrec->hnext = NULL;
return hrec;
}
static DouonRec*
make_drec(u_char* ycode) {
DouonRec* drec;
static DouonRec *
make_drec(u_char *ycode)
{
DouonRec *drec;
drec = (DouonRec *)Malloc(sizeof(DouonRec));
if (!drec) {
drec = (DouonRec*)Malloc(sizeof(DouonRec));
if(!drec) {
fprintf(stderr, "\245\341\245\342\245\352\244\254\311\324\302\255\244\267\244\336\244\267\244\277");
exit(1);
}
drec -> yptr = ycode;
drec -> hrec_num = 0;
drec -> hrec = NULL;
drec -> dnext = NULL;
drec->yptr = ycode;
drec->hrec_num = 0;
drec->hrec = NULL;
drec->dnext = NULL;
return drec;
}
static int
diff_ylen(DouonRec *drec)
{
DouonRec *dptr;
DouonRec *dprev;
u_char *p1;
u_char *p2;
int ylen = 0;
diff_ylen(DouonRec* drec) {
DouonRec* dptr;
DouonRec* dprev;
u_char* p1;
u_char* p2;
int ylen = 0;
dptr = douon_ptr; dprev = NULL;
while (dptr) {
dptr = douon_ptr;
dprev = NULL;
while(dptr) {
dprev = dptr;
dptr = dptr -> dnext;
dptr = dptr->dnext;
}
if (dprev) {
p1 = dprev -> yptr; p2 = drec -> yptr;
while (*p1 && (*p1 == *p2)) {
if(dprev) {
p1 = dprev->yptr;
p2 = drec->yptr;
while(*p1 && (*p1 == *p2)) {
p1++;
p2++;
}
if (*p1 == *p2) {
if(*p1 == *p2) {
fprintf(stderr, "\305\371\244\267\244\244\306\311\244\337\244\316\306\261\262\273\270\354\245\326\245\355\245\303\245\257\244\254\244\242\244\353\n");
output_yomi(stderr, dprev -> yptr); fputc('\n', stderr);
output_yomi(stderr, dprev->yptr);
fputc('\n', stderr);
exit(1);
} else if (*p1 > *p2) {
} else if(*p1 > *p2) {
fprintf(stderr, "\306\311\244\337\244\316\275\347\275\370\244\254\244\252\244\253\244\267\244\244\n");
output_yomi(stderr, dprev->yptr); fputc('\n', stderr);
output_yomi(stderr, drec->yptr); fputc('\n', stderr);
output_yomi(stderr, dprev->yptr);
fputc('\n', stderr);
output_yomi(stderr, drec->yptr);
fputc('\n', stderr);
exit(1);
}
while (*p2++)
while(*p2++)
ylen++;
}
return ylen;
return ylen;
}
static int
douon_knj(DouonRec *drec)
{
int i;
int len = 0;
u_char *p;
u_char *knjofscvt();
HinsiRec *hrec;
KanjiRec *krec;
douon_knj(DouonRec* drec) {
int i;
int len = 0;
u_char* p;
u_char* knjofscvt();
HinsiRec* hrec;
KanjiRec* krec;
for (hrec = drec -> hrec ; hrec ; hrec = hrec -> hnext) {
for (krec = hrec -> krec ; krec ; krec = krec -> knext) {
p = knjofscvt(krec -> kptr, krec -> klen, &i);
for(hrec = drec->hrec; hrec; hrec = hrec->hnext) {
for(krec = hrec->krec; krec; krec = krec->knext) {
p = knjofscvt(krec->kptr, krec->klen, &i);
len += i + 1;
knjhnd_set(p, i);
krec -> alen = i;
krec -> aptr = p;
krec->alen = i;
krec->aptr = p;
set_ofsrec(krec -> kptr, krec -> klen, 0);
set_ofsrec(krec->kptr, krec->klen, 0);
}
}
return len;
}
static void
make_d_list(DouonRec *drec)
{
make_d_list(DouonRec* drec) {
DouonRec *dptr, *dprev;
HinsiRec *hptr;
KanjiRec *kptr;
int ylen;
int klen;
int hnum;
int len;
int i;
HinsiRec* hptr;
KanjiRec* kptr;
int ylen;
int klen;
int hnum;
int len;
int i;
start:
if (douon_ptr == NULL) {
if(douon_ptr == NULL) {
douon_num = 0;
yomi_len = 0;
hinsi_num = 0;
kanji_len = 0;
assyuku = NULL;
assyuku = NULL;
}
klen = douon_knj(drec);
ylen = diff_ylen(drec);
hnum = drec -> hrec_num;
hnum = drec->hrec_num;
i = 1 +
MAXKNJASKNUMBER +
douon_num * DOUONBLKSIZENUMBER + DOUONBLKSIZENUMBER +
yomi_len + ylen +
yomi_len + ylen +
hinsi_num + hnum +
hinsi_num + hnum +
kanji_len + klen;
len = (i <= MAINSEGMENTLENGTH) ? 0 : decide_knjask();
if ((i - len) <= MAINSEGMENTLENGTH) {
if (douon_ptr) {
dptr = douon_ptr; dprev = NULL;
while (dptr) {
if((i - len) <= MAINSEGMENTLENGTH) {
if(douon_ptr) {
dptr = douon_ptr;
dprev = NULL;
while(dptr) {
dprev = dptr;
dptr = dptr -> dnext;
dptr = dptr->dnext;
}
dprev -> dnext = drec;
dprev->dnext = drec;
} else {
douon_ptr = drec;
}
drec -> dnext = NULL;
drec->dnext = NULL;
drec -> dlen = ylen;
drec->dlen = ylen;
douon_num += 1;
yomi_len += ylen;
yomi_len += ylen;
hinsi_num += hnum;
kanji_len += klen;
return;
} else if (douon_ptr == NULL) {
} else if(douon_ptr == NULL) {
fprintf(stderr, "\243\261\306\261\262\273\270\354\245\326\245\355\245\303\245\257\244\254\302\347\244\255\244\271\244\256\244\336\244\271\n");
exit(1);
}
for (hptr = drec -> hrec ; hptr ; hptr = hptr -> hnext) {
for (kptr = hptr -> krec ; kptr ; kptr = kptr -> knext) {
for(hptr = drec->hrec; hptr; hptr = hptr->hnext) {
for(kptr = hptr->krec; kptr; kptr = kptr->knext) {
knjhnd_reset(kptr -> aptr, kptr -> alen);
knjhnd_reset(kptr->aptr, kptr->alen);
Free(kptr -> aptr);
kptr -> aptr = NULL;
Free(kptr->aptr);
kptr->aptr = NULL;
}
}
@ -437,18 +409,14 @@ start:
goto start;
}
void
flush_douon()
{
if (drectmp) {
void flush_douon() {
if(drectmp) {
make_d_list(drectmp);
drectmp = NULL;
}
if (douon_ptr) {
if(douon_ptr) {
decide_knjask();
makeseg();
@ -463,48 +431,45 @@ flush_douon()
}
}
void
makelist(int *yomi, int *kanji, int hinsi, int *atr)
{
u_char *ycode;
u_char *kcode;
int klen;
HinsiRec *hrec;
void makelist(int* yomi, int* kanji, int hinsi, int* atr) {
u_char* ycode;
u_char* kcode;
int klen;
HinsiRec* hrec;
KanjiRec *krec, *kprev = NULL;
ycode = makeyomi(yomi);
kcode = makekanji(yomi, kanji, atr, &klen);
if (drectmp && strcmp(ycode, drectmp -> yptr)) {
if(drectmp && strcmp(ycode, drectmp->yptr)) {
make_d_list(drectmp);
drectmp = NULL;
}
if (!drectmp) {
if(!drectmp) {
drectmp = make_drec(ycode);
hrec = make_hrec(hinsi);
drectmp -> hrec = hrec;
drectmp -> hrec_num = 1;
hrec = make_hrec(hinsi);
drectmp->hrec = hrec;
drectmp->hrec_num = 1;
krec = make_krec(kcode, klen);
hrec -> krec = krec;
krec = make_krec(kcode, klen);
hrec->krec = krec;
return;
}
for (hrec = drectmp -> hrec ; hrec -> hnext ; hrec = hrec -> hnext)
if (hrec -> hinsi == hinsi)
for(hrec = drectmp->hrec; hrec->hnext; hrec = hrec->hnext)
if(hrec->hinsi == hinsi)
break;
if (hrec -> hinsi == hinsi) {
for (krec=hrec->krec ; krec ; krec=krec->knext) {
if ((krec -> klen == klen) &&
!memcmp(krec -> kptr, kcode, klen)) {
if(hrec->hinsi == hinsi) {
for(krec = hrec->krec; krec; krec = krec->knext) {
if((krec->klen == klen) &&
!memcmp(krec->kptr, kcode, klen)) {
fprintf(stderr, "\306\261\260\354\244\316\275\317\270\354\244\254\302\270\272\337\244\267\244\277\n");
fprintf(stderr, "\t\306\311\244\337:");
output_int(stderr, yomi);
@ -520,16 +485,16 @@ makelist(int *yomi, int *kanji, int hinsi, int *atr)
kprev = krec;
}
if (kprev)
kprev -> knext = make_krec(kcode, klen);
if(kprev)
kprev->knext = make_krec(kcode, klen);
return;
}
hrec -> hnext = make_hrec(hinsi);
hrec = hrec -> hnext;
drectmp -> hrec_num += 1;
hrec->hnext = make_hrec(hinsi);
hrec = hrec->hnext;
drectmp->hrec_num += 1;
krec = make_krec(kcode, klen);
hrec -> krec = krec;
krec = make_krec(kcode, klen);
hrec->krec = krec;
}

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,8 +28,8 @@
*/
/*
* $SonyRCSfile: makeseg.c,v $
* $SonyRevision: 1.2 $
* $SonyRCSfile: makeseg.c,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1994/12/09 11:27:05 $
*/
@ -38,52 +38,49 @@
#include "sj3mkdic.h"
static u_char mindex[MAINSEGMENTLENGTH];
static int idxpos = 0;
static int idxnum = 0;
static u_char mindex[MAINSEGMENTLENGTH];
static int idxpos = 0;
static int idxnum = 0;
static u_char *
set_ofsask(u_char *src, u_char *dst)
{
int len;
u_char *ptr;
OffsetRec *ofsrec;
static u_char*
set_ofsask(u_char* src, u_char* dst) {
int len;
u_char* ptr;
OffsetRec* ofsrec;
ofsrec = real_ofsrec(src);
for (len = ofsrec->klen, ptr = ofsrec->kptr ; len > 0 ; ) {
switch (*ptr & KANJIMODEMASK) {
case ZENHIRAASSYUKU:
case ZENKATAASSYUKU:
case KANJIASSYUKU:
for(len = ofsrec->klen, ptr = ofsrec->kptr; len > 0;) {
switch(*ptr & KANJIMODEMASK) {
case ZENHIRAASSYUKU:
case ZENKATAASSYUKU:
case KANJIASSYUKU:
*dst++ = *ptr++;
len -= 1;
break;
case LEADINGHANKAKU:
#ifndef USEHANKAKUINDICT
fprintf(stderr, "\302\260\300\255\245\263\241\274\245\311\241\246\245\250\245\351\241\274\n");
exit(1);
case LEADINGHANKAKU:
#ifndef USEHANKAKUINDICT
fprintf(stderr, "\302\260\300\255\245\263\241\274\245\311\241\246\245\250\245\351\241\274\n");
exit(1);
#else
*dst++ = *ptr++;
*dst++ = *ptr++;
len -= 2;
break;
#endif
case OFFSETASSYUKU:
case OFFSETASSYUKU:
fprintf(stderr, "\306\363\275\305\244\313\245\252\245\325\245\273\245\303\245\310\244\254\273\262\276\310\244\265\244\354\244\306\244\244\244\353\n");
exit(1);
case AIATTRIBUTE:
case AIATTRIBUTE:
*dst++ = *ptr++;
*dst++ = *ptr++;
len -= 2;
break;
case KANJISTREND:
case KANJISTREND:
*dst++ = *ptr++;
len--;
break;
default:
default:
*dst++ = *ptr++;
*dst++ = *ptr++;
len -= 2;
@ -93,76 +90,72 @@ set_ofsask(u_char *src, u_char *dst)
return dst;
}
int make_knjstr(u_char* src, int len, u_char* dst) {
u_char* keep = dst;
int
make_knjstr(u_char *src, int len, u_char *dst)
{
u_char *keep = dst;
while (len > 0) {
switch (*src & KANJIMODEMASK) {
case ZENHIRAASSYUKU:
case ZENKATAASSYUKU:
case KANJIASSYUKU:
while(len > 0) {
switch(*src & KANJIMODEMASK) {
case ZENHIRAASSYUKU:
case ZENKATAASSYUKU:
case KANJIASSYUKU:
*dst++ = *src++;
len -= 1;
break;
case LEADINGHANKAKU:
case LEADINGHANKAKU:
#ifndef USEHANKAKUINDICT
fprintf(stderr, "\302\260\300\255\245\263\241\274\245\311\241\246\245\250\245\351\241\274\n");
exit(1);
fprintf(stderr, "\302\260\300\255\245\263\241\274\245\311\241\246\245\250\245\351\241\274\n");
exit(1);
#else
*dst++ = *src++;
*dst++ = *src++;
len -= 2;
break;
#endif
case OFFSETASSYUKU:
case OFFSETASSYUKU:
dst = set_ofsask(src, dst);
src += 2;
len -= 2;
break;
case AIATTRIBUTE:
case AIATTRIBUTE:
*dst++ = *src++;
*dst++ = *src++;
len -= 2;
break;
case KANJISTREND:
case KANJISTREND:
*dst++ = *src++;
len--;
break;
default:
default:
*dst++ = *src++;
*dst++ = *src++;
len -= 2;
}
}
return(dst - keep);
}
}
return (dst - keep);
}
static int
make_knjask()
{
make_knjask() {
int i;
u_char *p;
u_char* p;
u_char buf[128];
int len;
int tlen = 0;
for (i = 0 ; i < askknj_num ; i++) {
len = make_knjstr(askknj[i] -> kptr, askknj[i] -> klen, buf);
for(i = 0; i < askknj_num; i++) {
len = make_knjstr(askknj[i]->kptr, askknj[i]->klen, buf);
Free(askknj[i] -> kptr);
Free(askknj[i]->kptr);
p = (u_char *)Malloc(len);
if (!p) {
p = (u_char*)Malloc(len);
if(!p) {
fprintf(stderr, "\245\341\245\342\245\352\244\254\302\255\244\352\244\336\244\273\244\363\n");
exit(1);
}
memcpy(p, buf, len);
askknj[i] -> kptr = p;
askknj[i] -> klen = len;
askknj[i]->kptr = p;
askknj[i]->klen = len;
tlen += len + 1;
}
@ -170,46 +163,55 @@ make_knjask()
return tlen;
}
void makeseg() {
u_char buf[MAINSEGMENTLENGTH];
DouonRec* drec;
HinsiRec* hrec;
KanjiRec* krec;
int i, j, k;
int slen;
u_char* dst;
u_char* sdst;
u_char * p, *q;
void
makeseg()
{
u_char buf[MAINSEGMENTLENGTH];
DouonRec *drec;
HinsiRec *hrec;
KanjiRec *krec;
int i, j, k;
int slen;
u_char *dst;
u_char *sdst;
u_char *p, *q;
#ifndef HEHE
#define datset(i) { if (dst >= buf+sizeof(buf)) goto err; *dst++ = i; }
#ifndef HEHE
#define datset(i) \
{ \
if(dst >= buf + sizeof(buf)) goto err; \
*dst++ = i; \
}
#else
#define datset(i) { *dst++; i; }
#define datset(i) \
{ \
*dst++; \
i; \
}
#endif
dst = buf;
i = make_knjask();
if (i >= 0x100) {
if(i >= 0x100) {
fprintf(stderr, "\264\301\273\372\260\265\275\314\312\270\273\372\316\363\244\254\304\271\244\271\244\256\244\353\n");
exit(1);
}
datset(i);
for (i = 0 ; i < askknj_num ; i++) {
p = askknj[i] -> kptr;
j = askknj[i] -> klen;
while (j > 0) {
for(i = 0; i < askknj_num; i++) {
p = askknj[i]->kptr;
j = askknj[i]->klen;
while(j > 0) {
k = codesize(*p);
datset(*p); p++;
if (k > 2) {
datset(*p); p++;
datset(*p); p++;
} else if (k > 1) {
datset(*p); p++;
datset(*p);
p++;
if(k > 2) {
datset(*p);
p++;
datset(*p);
p++;
} else if(k > 1) {
datset(*p);
p++;
}
j -= k;
}
@ -218,99 +220,99 @@ makeseg()
clear_ofsrec();
for (drec = douon_ptr ; drec ; drec = drec->dnext) {
sdst = dst; dst += DOUONBLKSIZENUMBER;
for(drec = douon_ptr; drec; drec = drec->dnext) {
sdst = dst;
dst += DOUONBLKSIZENUMBER;
p = drec -> yptr;
slen = strlen(p) - drec -> dlen;
p = drec->yptr;
slen = strlen(p) - drec->dlen;
p += slen;
for (i = drec -> dlen ; i > 0 ; i--) {
datset(*p); p++;
for(i = drec->dlen; i > 0; i--) {
datset(*p);
p++;
}
for (hrec = drec->hrec ; hrec ; hrec = hrec->hnext) {
for(hrec = drec->hrec; hrec; hrec = hrec->hnext) {
datset(hrec -> hinsi);
datset(hrec->hinsi);
for (krec = hrec->krec ; krec ; krec = krec->knext) {
p = q = knjcvt(krec -> kptr, krec -> klen, &i);
for(krec = hrec->krec; krec; krec = krec->knext) {
p = q = knjcvt(krec->kptr, krec->klen, &i);
set_ofsrec(krec->kptr, krec->klen, dst - buf);
while (i-- > 0) {
datset(*p); p++;
while(i-- > 0) {
datset(*p);
p++;
}
datset(KANJISTREND);
Free(q);
}
datset(HINSIBLKTERM);
datset(HINSIBLKTERM);
}
i = dst - sdst;
*sdst = ((i >> 8) & 0x0f);
i = dst - sdst;
*sdst = ((i >> 8) & 0x0f);
*(sdst + 1) = (i & 0xff);
if (drec -> dlen > 0x0f) *sdst |= 0x40;
*(sdst + 2) = (drec -> dlen & 0x0f);
if(drec->dlen > 0x0f) *sdst |= 0x40;
*(sdst + 2) = (drec->dlen & 0x0f);
if (slen > 0x0f) *sdst |= 0x80;
if(slen > 0x0f) *sdst |= 0x80;
*(sdst + 2) |= ((slen << 4) & 0xf0);
}
if (dst < buf + sizeof(buf)) {
if(dst < buf + sizeof(buf)) {
datset(DOUONBLKTERM);
}
for (p = douon_ptr -> yptr ; ; ) {
if (idxpos < MAININDEXLENGTH) {
for(p = douon_ptr->yptr;;) {
if(idxpos < MAININDEXLENGTH) {
mindex[idxpos++] = *p;
}
else {
} else {
fprintf(stderr, "\245\244\245\363\245\307\245\303\245\257\245\271\244\254\244\242\244\325\244\354\244\336\244\267\244\277\n");
exit(1);
}
if (!*p++) break;
if(!*p++) break;
}
if (idxpos < MAININDEXLENGTH) {
if(idxpos < MAININDEXLENGTH) {
mindex[idxpos] = 0;
}
else {
} else {
fprintf(stderr, "\245\244\245\363\245\307\245\303\245\257\245\271\244\254\244\242\244\325\244\354\244\336\244\267\244\277\n");
exit(1);
}
i = dst - buf;
while (dst < buf + sizeof(buf)) *dst++ = DOUONBLKTERM;
while(dst < buf + sizeof(buf)) *dst++ = DOUONBLKTERM;
if (Fseek(outfp,
(long)(HEADERLENGTH + COMMENTLENGTH + MAININDEXLENGTH
+ idxnum * MAINSEGMENTLENGTH),
0) < 0) {
if(Fseek(outfp,
(long)(HEADERLENGTH + COMMENTLENGTH + MAININDEXLENGTH + idxnum * MAINSEGMENTLENGTH),
0) < 0) {
fprintf(stderr, "\275\320\316\317\245\325\245\241\245\244\245\353\244\307\245\267\241\274\245\257\245\250\245\351\241\274\n");
exit(1);
}
if (Fwrite(buf, sizeof(buf), 1, outfp) != 1) {
if(Fwrite(buf, sizeof(buf), 1, outfp) != 1) {
fprintf(stderr, "\275\320\316\317\245\325\245\241\245\244\245\353\244\307\245\351\245\244\245\310\245\250\245\351\241\274\n");
exit(1);
}
Fflush(outfp);
printf("\245\273\245\260\245\341\245\363\245\310\310\326\271\346:%d:", idxnum++);
output_yomi(stdout, douon_ptr -> yptr);
output_yomi(stdout, douon_ptr->yptr);
printf("\t\245\273\245\260\245\341\245\363\245\310\304\271:%d", i);
printf("\t\306\261\262\273\270\354\277\364:%d\n", douon_num);
printf("\264\301\273\372\260\265\275\314\312\270\273\372\316\363:");
for (i = j = 0 ; i < askknj_num ; i++) {
for(i = j = 0; i < askknj_num; i++) {
putchar('\t');
if (i && j == 0) putchar('\t');
output_knj(stdout, askknj[i] -> kptr, askknj[i] -> klen);
printf(":%d", askknj[i] -> hindo + askknj[i] -> exist);
if (++j >= 4) {
if(i && j == 0) putchar('\t');
output_knj(stdout, askknj[i]->kptr, askknj[i]->klen);
printf(":%d", askknj[i]->hindo + askknj[i]->exist);
if(++j >= 4) {
putchar('\n');
j = 0;
}
}
if (j) putchar('\n');
if(j) putchar('\n');
putchar('\n');
fflush(stdout);
@ -319,63 +321,67 @@ makeseg()
err:
fprintf(stderr, "\245\273\245\260\245\341\245\363\245\310\271\275\300\256\303\346\244\313\245\320\245\303\245\325\245\241\244\254\244\242\244\325\244\354\244\277\n");
fprintf(stderr, "\245\273\245\260\245\341\245\363\245\310\300\350\306\254\244\316\306\311\244\337:");
output_yomi(stderr, douon_ptr -> yptr);
output_yomi(stderr, douon_ptr->yptr);
fputc('\n', stderr);
exit(1);
#undef datset
#undef datset
}
static void put4byte(p, n)
u_char *p;
long n;
static void put4byte(p, n)
u_char* p;
long n;
{
p += 3;
*p-- = n; n >>= 8;
*p-- = n; n >>= 8;
*p-- = n; n >>= 8;
*p = n;
p += 3;
*p-- = n;
n >>= 8;
*p-- = n;
n >>= 8;
*p-- = n;
n >>= 8;
*p = n;
}
void
makehead(u_char *dict_name)
{
u_char header[HEADERLENGTH + COMMENTLENGTH];
time_t i;
u_char *p;
void makehead(u_char* dict_name) {
u_char header[HEADERLENGTH + COMMENTLENGTH];
time_t i;
u_char* p;
#define INDEXPOS (HEADERLENGTH + COMMENTLENGTH)
#define INDEXPOS (HEADERLENGTH + COMMENTLENGTH)
memset(header, '\0', sizeof(header));
put4byte(header + VERSIONPOS, DICTVERSION);
time(&i);
p = header + COMMENTPOS;
snprintf((char *)p, sizeof(header) - COMMENTPOS, "%s : %s", dict_name, ctime(&i));
while (*p) {
if (*p == '\n') { *p = 0; break; }
memset(header, '\0', sizeof(header));
put4byte(header + VERSIONPOS, DICTVERSION);
time(&i);
p = header + COMMENTPOS;
snprintf((char*)p, sizeof(header) - COMMENTPOS, "%s : %s", dict_name, ctime(&i));
while(*p) {
if(*p == '\n') {
*p = 0;
break;
}
p++;
}
i = INDEXPOS;
i = INDEXPOS;
put4byte(header + DICTIDXPOS, i);
put4byte(header + DICTIDXLEN, MAININDEXLENGTH);
i += MAININDEXLENGTH;
put4byte(header + DICTIDXPOS, i);
put4byte(header + DICTIDXLEN, MAININDEXLENGTH);
i += MAININDEXLENGTH;
put4byte(header + DICTSEGPOS, i);
put4byte(header + DICTSEGLEN, MAINSEGMENTLENGTH);
put4byte(header + DICTSEGMAX, 0);
put4byte(header + DICTSEGNUM, idxnum);
put4byte(header + DICTSEGPOS, i);
put4byte(header + DICTSEGLEN, MAINSEGMENTLENGTH);
put4byte(header + DICTSEGMAX, 0);
put4byte(header + DICTSEGNUM, idxnum);
put4byte(header + DICTAIDXPOS, 0);
put4byte(header + DICTAIDXLEN, 0);
put4byte(header + DICTAIDXPOS, 0);
put4byte(header + DICTAIDXLEN, 0);
put4byte(header + DICTASEGPOS, 0);
put4byte(header + DICTASEGLEN, 0);
put4byte(header + DICTASEGPOS, 0);
put4byte(header + DICTASEGLEN, 0);
Fseek(outfp, (long)HEADERPOS, 0);
Fwrite(header, sizeof(header), 1, outfp);
Fseek(outfp, (long)INDEXPOS, 0);
Fwrite(mindex, MAININDEXLENGTH, 1, outfp);
Fseek(outfp, (long)HEADERPOS, 0);
Fwrite(header, sizeof(header), 1, outfp);
Fseek(outfp, (long)INDEXPOS, 0);
Fwrite(mindex, MAININDEXLENGTH, 1, outfp);
#undef INDEXPOS
#undef INDEXPOS
}

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,38 +28,32 @@
*/
/*
* $SonyRCSfile: memory.c,v $
* $SonyRevision: 1.1 $
* $SonyRCSfile: memory.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:42 $
*/
#include "sj3mkdic.h"
void *
Malloc(unsigned size)
{
void *p;
void* Malloc(unsigned size) {
void* p;
p = malloc(size);
if (p == NULL) {
fprintf(stderr, "\245\341\245\342\245\352\244\254\263\316\312\335\244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277\241\243\n");
exit(1);
}
return p;
p = malloc(size);
if(p == NULL) {
fprintf(stderr, "\245\341\245\342\245\352\244\254\263\316\312\335\244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277\241\243\n");
exit(1);
}
return p;
}
void *
Zalloc(int size)
{
void *p;
void* Zalloc(int size) {
void* p;
p = Malloc(size);
memset(p, '\0', size);
return p;
p = Malloc(size);
memset(p, '\0', size);
return p;
}
void
Free(void *p)
{
free(p);
void Free(void* p) {
free(p);
}

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,8 +28,8 @@
*/
/*
* $SonyRCSfile: offset.c,v $
* $SonyRevision: 1.2 $
* $SonyRCSfile: offset.c,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1994/08/17 01:50:26 $
*/
@ -37,125 +37,111 @@
#include "sj3mkdic.h"
static OffsetRec*
makeoffset(u_char* ptr, int len, int ofs) {
OffsetRec* orec;
u_char* p;
static OffsetRec *
makeoffset(u_char *ptr, int len, int ofs)
{
OffsetRec *orec;
u_char *p;
orec = (OffsetRec*)Malloc(sizeof(OffsetRec));
orec = (OffsetRec *)Malloc(sizeof(OffsetRec));
p = (u_char *)Malloc(len);
p = (u_char*)Malloc(len);
memcpy(p, ptr, len);
orec -> kptr = p;
orec -> klen = len;
if (ofs)
orec -> offset = ofs;
orec->kptr = p;
orec->klen = len;
if(ofs)
orec->offset = ofs;
else
orec -> offset = ofsrec_num + 1;
orec->offset = ofsrec_num + 1;
return orec;
}
void set_ofsrec(u_char* ptr, int len, int ofs) {
OffsetRec* orec;
int low, high, mid;
int i;
void
set_ofsrec(u_char *ptr, int len, int ofs)
{
OffsetRec *orec;
int low, high, mid;
int i;
if (ofsrec_num <= 0) {
orec = makeoffset(ptr, len, ofs);
ofsrec[0]= orec;
if(ofsrec_num <= 0) {
orec = makeoffset(ptr, len, ofs);
ofsrec[0] = orec;
ofsrec_num++;
return;
}
low = 0; high = ofsrec_num - 1;
low = 0;
high = ofsrec_num - 1;
do {
mid = (low + high) / 2;
i = string_cmp(ofsrec[mid]->kptr, ofsrec[mid]->klen, ptr, len);
if (i > 0)
i = string_cmp(ofsrec[mid]->kptr, ofsrec[mid]->klen, ptr, len);
if(i > 0)
high = mid - 1;
else if (i < 0)
else if(i < 0)
low = ++mid;
else
break;
} while (low <= high);
} while(low <= high);
if (i) {
if (ofsrec_num >= MAXOFFSETNUMBER) {
if(i) {
if(ofsrec_num >= MAXOFFSETNUMBER) {
fprintf(stderr, "\245\252\245\325\245\273\245\303\245\310\241\246\245\306\241\274\245\326\245\353\244\254\244\242\244\325\244\354\244\336\244\267\244\277\n");
exit(1);
}
orec = makeoffset(ptr, len, ofs);
for (i = ofsrec_num ; i > mid ; i--) ofsrec[i] = ofsrec[i - 1];
for(i = ofsrec_num; i > mid; i--) ofsrec[i] = ofsrec[i - 1];
ofsrec[mid] = orec;
ofsrec_num++;
}
}
int isknjexist(u_char* knj, int len) {
int low, high, mid;
int i;
if(ofsrec_num <= 0) return 0;
int
isknjexist(u_char *knj, int len)
{
int low, high, mid;
int i;
if (ofsrec_num <= 0) return 0;
low = 0; high = ofsrec_num - 1;
while (low <= high) {
low = 0;
high = ofsrec_num - 1;
while(low <= high) {
mid = (low + high) / 2;
i = string_cmp(ofsrec[mid]->kptr, ofsrec[mid]->klen, knj, len);
if (i > 0)
i = string_cmp(ofsrec[mid]->kptr, ofsrec[mid]->klen, knj, len);
if(i > 0)
high = mid - 1;
else if (i < 0)
else if(i < 0)
low = ++mid;
else
return ofsrec[mid] -> offset;
return ofsrec[mid]->offset;
}
return 0;
}
void clear_ofsrec() {
int i;
void
clear_ofsrec()
{
int i;
for (i = 0 ; i < ofsrec_num ; i++) {
Free(ofsrec[i] -> kptr);
for(i = 0; i < ofsrec_num; i++) {
Free(ofsrec[i]->kptr);
Free(ofsrec[i]);
}
ofsrec_num = 0;
}
OffsetRec*
real_ofsrec(u_char* ptr) {
int ofs;
int i;
OffsetRec** p;
ofs = (*ptr++ & KNJASSYUKUMASK);
ofs <<= 8;
ofs += *ptr;
OffsetRec *
real_ofsrec(u_char *ptr)
{
int ofs;
int i;
OffsetRec **p;
ofs = (*ptr++ & KNJASSYUKUMASK);
ofs <<= 8;
ofs += *ptr;
for (i = ofsrec_num, p = ofsrec ; i-- > 0 ; p++)
if ((*p) -> offset == ofs)
for(i = ofsrec_num, p = ofsrec; i-- > 0; p++)
if((*p)->offset == ofs)
return *p;
fprintf(stderr, "real_ofsrec() \244\307\260\333\276\357\244\312\276\365\302\326 %x\n", ofs);

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,8 +28,8 @@
*/
/*
* $SonyRCSfile: readline.c,v $
* $SonyRevision: 1.1 $
* $SonyRCSfile: readline.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:44 $
*/
@ -38,144 +38,132 @@
#include "sj3mkdic.h"
static int yomi[MAXYOMILENGTH + 1];
static int kanji[MAXKANJILENGTH + 1];
static int hinsi[MAXHINSINUMBER + 1];
static int atr[MAXATRNUMBER + 1];
#define Isblank(c) ((c) == 0x20 || (c) == 0x09 || (c) == 0xa1a1)
#define Isillegal(c) ((c) < 0x20)
static int yomi[MAXYOMILENGTH + 1];
static int kanji[MAXKANJILENGTH + 1];
static int hinsi[MAXHINSINUMBER + 1];
static int atr[MAXATRNUMBER + 1];
#define Isblank(c) ((c) == 0x20 || (c) == 0x09 || (c) == 0xa1a1)
#define Isillegal(c) ((c) < 0x20)
static void
error(char *s)
{
if (s)
error(char* s) {
if(s)
fprintf(stderr, "%s\n", s);
mark_file(stderr);
exit(1);
}
static int
readchar()
{
int c1;
int c2;
readchar() {
int c1;
int c2;
c1 = getch();
if (c1 == EOF)
if(c1 == EOF)
return EOF;
if (c1 != SS3) {
if (c1 & 0x80) {
if(c1 != SS3) {
if(c1 & 0x80) {
c2 = getch();
if (c2 == EOF)
if(c2 == EOF)
error(NULL);
c1 = ((c1 & 0xff) << 8) + (c2 & 0xff);
}
} else {
c2 = getch();
if (c2 == EOF)
if(c2 == EOF)
error(NULL);
c1 = ((c1 & 0xff) << 8) + (c2 & 0xff);
c2 = getch();
if (c2 == EOF)
if(c2 == EOF)
error(NULL);
c1 = ((c1 & 0xffff) << 8) + (c2 & 0xff);
}
return c1;
}
static int
skip_blank()
{
int c;
skip_blank() {
int c;
c = readchar();
while (Isblank(c))
while(Isblank(c))
c = readchar();
return c;
}
static int
readhinsi()
{
static int c = 0;
int i;
unsigned char hinsi[128];
readhinsi() {
static int c = 0;
int i;
unsigned char hinsi[128];
retry:
if (c == '\n') {
if(c == '\n') {
c = 0;
return 0;
}
c = skip_blank();
if (c == '\n') {
if(c == '\n') {
c = 0;
return 0;
}
for (i = 0 ; !Isblank(c) ; ) {
if (c == '\n' || c == ':')
for(i = 0; !Isblank(c);) {
if(c == '\n' || c == ':')
break;
if (Isillegal(c))
if(Isillegal(c))
error(ILLEGALFORMAT);
if (c > 0xffffff) {
if (i >= 126)
if(c > 0xffffff) {
if(i >= 126)
error(TOOLONGHINSI);
hinsi[i++] = ((c >> 24) & 0xff);
if (i >= 126)
if(i >= 126)
error(TOOLONGHINSI);
hinsi[i++] = ((c >> 16) & 0xff);
if (i >= 126)
if(i >= 126)
error(TOOLONGHINSI);
hinsi[i++] = ((c >> 8) & 0xff);
} else if (c > 0xffff) {
if (i >= 126)
} else if(c > 0xffff) {
if(i >= 126)
error(TOOLONGHINSI);
hinsi[i++] = ((c >> 16) & 0xff);
if (i >= 126)
if(i >= 126)
error(TOOLONGHINSI);
hinsi[i++] = ((c >> 8) & 0xff);
} else if (c > 0xff) {
if (i >= 126)
} else if(c > 0xff) {
if(i >= 126)
error(TOOLONGHINSI);
hinsi[i++] = ((c >> 8) & 0xff);
}
if (i >= 127)
if(i >= 127)
error(TOOLONGHINSI);
hinsi[i++] = (c & 0xff);
c = readchar();
c = readchar();
}
if (i == 0)
if(i == 0)
return 0;
if (hinsi[0] == '[' && hinsi[i - 1] == ']') {
if(hinsi[0] == '[' && hinsi[i - 1] == ']') {
hinsi[i - 1] = 0;
i = cnvhinsi(hinsi + 1);
if (i > 0) {
i = cnvhinsi(hinsi + 1);
if(i > 0) {
fprintf(stderr, "\311\312\273\354 \"%s\" \244\313\263\347\270\314\244\254\244\304\244\244\244\306\244\244\244\353\n",
hinsi + 1);
} else if (!i) {
} else if(!i) {
fprintf(stderr, "\"%s\" \244\254\245\263\241\274\245\311\262\275\244\307\244\255\244\336\244\273\244\363\n",
hinsi + 1);
goto retry;
}
}
else {
} else {
hinsi[i] = 0;
i = cnvhinsi(hinsi);
if (!i) {
i = cnvhinsi(hinsi);
if(!i) {
fprintf(stderr, "\"%s\" \244\254\245\263\241\274\245\311\262\275\244\307\244\255\244\336\244\273\244\363\n", hinsi);
goto retry;
}
@ -184,98 +172,89 @@ retry:
return i;
}
int* readline() {
int c;
int i;
int j;
int *
readline()
{
int c;
int i;
int j;
for ( ; ; ) {
for(;;) {
mark_file(NULL);
c = skip_blank();
if (c == '#') {
while (c != '\n')
if(c == '#') {
while(c != '\n')
c = skip_blank();
}
if (c == EOF)
if(c == EOF)
return NULL;
if (c != '\n')
if(c != '\n')
break;
}
for (i = 0 ; !Isblank(c) ; ) {
if (Isillegal(c))
for(i = 0; !Isblank(c);) {
if(Isillegal(c))
error(ILLEGALFORMAT);
if (i >= MAXYOMILENGTH)
if(i >= MAXYOMILENGTH)
error(TOOLONGYOMI);
yomi[i++] = c;
c = readchar();
c = readchar();
}
yomi[i] = 0;
if (i == 0)
if(i == 0)
error(NOYOMISTRING);
c = skip_blank();
if (c != '"') {
for (i = 0 ; !Isblank(c) ; ) {
if (Isillegal(c))
if(c != '"') {
for(i = 0; !Isblank(c);) {
if(Isillegal(c))
error(ILLEGALFORMAT);
if (i >= MAXKANJILENGTH)
if(i >= MAXKANJILENGTH)
error(TOOLONGKANJI);
kanji[i++] = c;
c = readchar();
c = readchar();
}
} else {
c = readchar();
for (i = 0 ; c != '"' ; ) {
if (Isillegal(c))
for(i = 0; c != '"';) {
if(Isillegal(c))
error(ILLEGALFORMAT);
if (i >= MAXKANJILENGTH)
if(i >= MAXKANJILENGTH)
error(TOOLONGKANJI);
kanji[i++] = c;
c = readchar();
c = readchar();
}
}
kanji[i] = 0;
if (i == 0)
if(i == 0)
error(NOKANJISTRING);
i = j = 0;
while (c = readhinsi()) {
if (c < 0) {
if (i >= MAXATRNUMBER)
while(c = readhinsi()) {
if(c < 0) {
if(i >= MAXATRNUMBER)
error(TOOMANYATR);
atr[i++] = -c;
}
else {
if (j >= MAXHINSINUMBER)
} else {
if(j >= MAXHINSINUMBER)
error(TOOMANYHINSI);
hinsi[j++] = c;
}
}
atr[i] = 0;
if (j == 0)
if(j == 0)
hinsi[j++] = HINSITANKAN;
hinsi[j] = 0;
return yomi;
}
void setline(void (*func)(int*, int*, int, int*)) {
int i;
void
setline(void (*func)(int*, int*, int, int*))
{
int i;
for (i = 0 ; hinsi[i] ; i++)
for(i = 0; hinsi[i]; i++)
(*func)(yomi, kanji, hinsi[i], atr);
}

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,81 +28,80 @@
*/
/*
* $SonyRCSfile: sj3_dict_const.h,v $
* $SonyRevision: 1.1 $
* $SonyRCSfile: sj3_dict_const.h,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:24 $
*/
#ifndef SJ3_DICT_CONST_H
#define SJ3_DICT_CONST_H
#ifndef SJ3_DICT_CONST_H
#define SJ3_DICT_CONST_H
#define MAINSEGMENTLENGTH 2048
#define MAININDEXLENGTH 2048
#define MAININDEXNUMBER 512
#define MAINSEGMENTLENGTH 2048
#define MAININDEXLENGTH 2048
#define MAININDEXNUMBER 512
#define MAXYOMILENGTH 32
#define MAXKANJILENGTH 32
#define MAXHINSINUMBER 16
#define MAXATRNUMBER 16
#define MAXJOSINUMBER 16
#define MAXYOMILENGTH 32
#define MAXKANJILENGTH 32
#define MAXHINSINUMBER 16
#define MAXATRNUMBER 16
#define MAXJOSINUMBER 16
#define MAXKNJASKNUMBER 16
#define MAXYOMIASKNUMBER 16
#define MAXKNJASKNUMBER 16
#define MAXYOMIASKNUMBER 16
#define DOUONBLKSIZENUMBER 3
#define DOUONBLKSIZENUMBER 3
#define DOUONBLKTERM 0xff
#define HINSIBLKTERM 0xff
#define DOUONBLKTERM 0xff
#define HINSIBLKTERM 0xff
#define NORMALKANJIMASK 0x7f
#define SS3KANJI 0x0080
#define ZENHIRAASSYUKU 0x80
#define OFFSETASSYUKU 0x90
#define ZENKATAASSYUKU 0xa0
#define AIATTRIBUTE 0xb0
#define KANJIASSYUKU 0xc0
#define LEADINGHANKAKU 0xd0
#define KANJISTREND 0x00
#define ISASSYUKU 0x80
#define ASSUKUUSE2BYTE 0x90
#define KNJASSYUKUMASK 0x0f
#define KANJICODEMASK 0x0f
#define KANJIMODEMASK 0xf0
#define ATRMSKANJIOFS 0xc0c0
#define NORMALKANJIMASK 0x7f
#define SS3KANJI 0x0080
#define ZENHIRAASSYUKU 0x80
#define OFFSETASSYUKU 0x90
#define ZENKATAASSYUKU 0xa0
#define AIATTRIBUTE 0xb0
#define KANJIASSYUKU 0xc0
#define LEADINGHANKAKU 0xd0
#define KANJISTREND 0x00
#define ISASSYUKU 0x80
#define ASSUKUUSE2BYTE 0x90
#define KNJASSYUKUMASK 0x0f
#define KANJICODEMASK 0x0f
#define KANJIMODEMASK 0xf0
#define ATRMSKANJIOFS 0xc0c0
#define MAXHINDONUMBER 2000
#define MAXOFFSETNUMBER 1000
#define MAXHINDONUMBER 2000
#define MAXOFFSETNUMBER 1000
#define ILLEGALFORMAT "\245\325\245\251\241\274\245\336\245\303\245\310\244\254\260\333\276\357\244\307\244\271"
#define TOOLONGYOMI "\306\311\244\337\312\270\273\372\316\363\244\254\304\271\244\271\244\256\244\336\244\271"
#define TOOLONGKANJI "\264\301\273\372\312\270\273\372\316\363\244\254\304\271\244\271\244\256\244\336\244\271"
#define TOOLONGHINSI "\311\312\273\354\312\270\273\372\316\363\244\254\304\271\244\271\244\256\244\336\244\271"
#define TOOLONGGROUP "\245\260\245\353\241\274\245\327\314\276\244\254\260\333\276\357\244\307\244\271"
#define TOOLONGJOSI "\275\365\273\354\312\270\273\372\316\363\244\254\260\333\276\357\244\307\244\271"
#define BADHINSI "\305\320\317\277\244\265\244\354\244\306\244\244\244\312\244\244\311\312\273\354\244\307\244\271"
#define BADGROUP "\305\320\317\277\244\265\244\354\244\306\244\244\244\312\244\244\245\260\245\353\241\274\245\327\244\307\244\271"
#define BADJOSI "\305\320\317\277\244\265\244\354\244\306\244\244\244\312\244\244\275\365\273\354\244\307\244\271"
#define NOYOMISTRING "\306\311\244\337\312\270\273\372\316\363\244\254\274\350\306\300\244\307\244\255\244\336\244\273\244\363"
#define NOKANJISTRING "\264\301\273\372\312\270\273\372\316\363\244\254\274\350\306\300\244\307\244\255\244\336\244\273\244\363"
#define TOOMANYATR "\302\260\300\255\244\316\277\364\244\254\302\277\244\271\244\256\244\336\244\271"
#define TOOMANYHINSI "\311\312\273\354\244\316\277\364\244\254\302\277\244\271\244\256\244\336\244\271"
#define TOOMANYJOSI "\275\365\273\354\244\316\277\364\244\254\302\277\244\271\244\256\244\336\244\271"
#define NODATAINMAIN "\245\341\245\244\245\363\274\255\275\361\244\313\302\270\272\337\244\267\244\336\244\273\244\363"
#define TOOMANYTARGET "\311\312\273\354\244\362\243\261\244\304\273\330\304\352\244\267\244\306\244\257\244\300\244\265\244\244"
#define ILLEGALFORMAT "\245\325\245\251\241\274\245\336\245\303\245\310\244\254\260\333\276\357\244\307\244\271"
#define TOOLONGYOMI "\306\311\244\337\312\270\273\372\316\363\244\254\304\271\244\271\244\256\244\336\244\271"
#define TOOLONGKANJI "\264\301\273\372\312\270\273\372\316\363\244\254\304\271\244\271\244\256\244\336\244\271"
#define TOOLONGHINSI "\311\312\273\354\312\270\273\372\316\363\244\254\304\271\244\271\244\256\244\336\244\271"
#define TOOLONGGROUP "\245\260\245\353\241\274\245\327\314\276\244\254\260\333\276\357\244\307\244\271"
#define TOOLONGJOSI "\275\365\273\354\312\270\273\372\316\363\244\254\260\333\276\357\244\307\244\271"
#define BADHINSI "\305\320\317\277\244\265\244\354\244\306\244\244\244\312\244\244\311\312\273\354\244\307\244\271"
#define BADGROUP "\305\320\317\277\244\265\244\354\244\306\244\244\244\312\244\244\245\260\245\353\241\274\245\327\244\307\244\271"
#define BADJOSI "\305\320\317\277\244\265\244\354\244\306\244\244\244\312\244\244\275\365\273\354\244\307\244\271"
#define NOYOMISTRING "\306\311\244\337\312\270\273\372\316\363\244\254\274\350\306\300\244\307\244\255\244\336\244\273\244\363"
#define NOKANJISTRING "\264\301\273\372\312\270\273\372\316\363\244\254\274\350\306\300\244\307\244\255\244\336\244\273\244\363"
#define TOOMANYATR "\302\260\300\255\244\316\277\364\244\254\302\277\244\271\244\256\244\336\244\271"
#define TOOMANYHINSI "\311\312\273\354\244\316\277\364\244\254\302\277\244\271\244\256\244\336\244\271"
#define TOOMANYJOSI "\275\365\273\354\244\316\277\364\244\254\302\277\244\271\244\256\244\336\244\271"
#define NODATAINMAIN "\245\341\245\244\245\363\274\255\275\361\244\313\302\270\272\337\244\267\244\336\244\273\244\363"
#define TOOMANYTARGET "\311\312\273\354\244\362\243\261\244\304\273\330\304\352\244\267\244\306\244\257\244\300\244\265\244\244"
#define HINSITANKAN cnvhinsi("\303\261\264\301")
#define HINSITANKAN cnvhinsi("\303\261\264\301")
#define FALSE 0
#define TRUE (!FALSE)
#define FALSE 0
#define TRUE (!FALSE)
#define DIVLIST 1
#define ASSYUKUREC 2
#define STRING 3
#define HINDOREC 4
#define OFFSETREC 5
#define KANJIREC 6
#define HINSIREC 7
#define DOUONREC 8
#define DIVLIST 1
#define ASSYUKUREC 2
#define STRING 3
#define HINDOREC 4
#define OFFSETREC 5
#define KANJIREC 6
#define HINSIREC 7
#define DOUONREC 8
#endif

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,64 +28,61 @@
*/
/*
* $SonyRCSfile: sj3_dict_struct.h,v $
* $SonyRevision: 1.1 $
* $SonyRCSfile: sj3_dict_struct.h,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:26 $
*/
#include "sj3_dict_const.h"
#ifndef SJ3_DICT_STRUCT_H
#define SJ3_DICT_STRUCT_H
#ifndef SJ3_DICT_STRUCT_H
#define SJ3_DICT_STRUCT_H
#include <sj_typedef.h>
typedef struct kanji_rec {
int klen;
u_char *kptr;
int alen;
u_char *aptr;
struct kanji_rec *knext;
int klen;
u_char* kptr;
int alen;
u_char* aptr;
struct kanji_rec* knext;
} KanjiRec;
typedef struct hinsi_rec {
int hinsi;
KanjiRec *krec;
struct hinsi_rec *hnext;
int hinsi;
KanjiRec* krec;
struct hinsi_rec* hnext;
} HinsiRec;
typedef struct douon_rec {
u_char *yptr;
int dlen;
int hrec_num;
HinsiRec *hrec;
struct douon_rec *dnext;
u_char* yptr;
int dlen;
int hrec_num;
HinsiRec* hrec;
struct douon_rec* dnext;
} DouonRec;
typedef struct hindo_rec {
int klen;
u_char *kptr;
u_char* kptr;
int exist;
int hindo;
int offset;
int offset;
struct hindo_rec *anext;
struct assyuku_rec *arec;
struct hindo_rec* anext;
struct assyuku_rec* arec;
} HindoRec;
typedef struct assyuku_rec {
int len;
HindoRec *nrec;
struct assyuku_rec *anext;
int len;
HindoRec* nrec;
struct assyuku_rec* anext;
} AssyukuRec;
typedef struct offset_rec {
int klen;
u_char *kptr;
u_char* kptr;
int offset;
} OffsetRec;

View file

@ -28,102 +28,100 @@
#include "sj3_dict_struct.h"
/* char.c */
int cnvyomi(int);
int h2kcode(int);
int codesize(u_char);
void output_knj(FILE *, u_char *, int);
void output_str(FILE *, char *);
void output_int(FILE *, int *);
int yomi2zen(int);
void output_yomi(FILE *, u_char *);
int cnvyomi(int);
int h2kcode(int);
int codesize(u_char);
void output_knj(FILE*, u_char*, int);
void output_str(FILE*, char*);
void output_int(FILE*, int*);
int yomi2zen(int);
void output_yomi(FILE*, u_char*);
/* cnvhinsi.c */
int u_strcmp(u_char *, u_char *);
int cnvhinsi(u_char *);
char *hinsi_str(int);
int u_strcmp(u_char*, u_char*);
int cnvhinsi(u_char*);
char* hinsi_str(int);
/* file.c */
FILE *Fopen(char *, char *);
void Fclose(FILE *);
int Fseek(FILE *, long, int);
long Ftell(FILE *);
long Fsize(char *);
size_t Fread(char *, int, int, FILE *);
size_t Fwrite(char *, int, int, FILE *);
int Fgetc(FILE *);
int Fflush(FILE *);
FILE* Fopen(char*, char*);
void Fclose(FILE*);
int Fseek(FILE*, long, int);
long Ftell(FILE*);
long Fsize(char*);
size_t Fread(char*, int, int, FILE*);
size_t Fwrite(char*, int, int, FILE*);
int Fgetc(FILE*);
int Fflush(FILE*);
/* global.c */
extern DouonRec *douon_ptr;
extern int douon_num;
extern int yomi_len;
extern int hinsi_num;
extern int kanji_len;
extern HindoRec *hindo[MAXHINDONUMBER];
extern int hindo_num;
extern OffsetRec *ofsrec[MAXOFFSETNUMBER];
extern int ofsrec_num;
extern AssyukuRec *assyuku;
extern HindoRec *askknj[MAXKNJASKNUMBER];
extern int askknj_num;
extern int kanji_num;
extern DouonRec* douon_ptr;
extern int douon_num;
extern int yomi_len;
extern int hinsi_num;
extern int kanji_len;
extern HindoRec* hindo[MAXHINDONUMBER];
extern int hindo_num;
extern OffsetRec* ofsrec[MAXOFFSETNUMBER];
extern int ofsrec_num;
extern AssyukuRec* assyuku;
extern HindoRec* askknj[MAXKNJASKNUMBER];
extern int askknj_num;
extern int kanji_num;
/* hindo.c */
int check_hindo(u_char *, int);
void knjhnd_set(u_char *, int);
void knjhnd_reset(u_char *, int);
int decide_knjask();
int check_hindo(u_char*, int);
void knjhnd_set(u_char*, int);
void knjhnd_reset(u_char*, int);
int decide_knjask();
void clear_hindo();
void clear_assyuku();
/* knjcvt.c */
u_char *knjofscvt(u_char *, int, int *);
u_char *knjcvt(u_char *, int, int *);
u_char* knjofscvt(u_char*, int, int*);
u_char* knjcvt(u_char*, int, int*);
/* mkdict.c */
extern FILE *infp;
extern FILE *outfp;
char *make_idxlist(char *);
char *get_idxlist(char *);
void parse(int, char **);
int get_number(char *);
void usage(char *);
int getch();
void mark_file(FILE *);
extern FILE* infp;
extern FILE* outfp;
char* make_idxlist(char*);
char* get_idxlist(char*);
void parse(int, char**);
int get_number(char*);
void usage(char*);
int getch();
void mark_file(FILE*);
/* makelist */
void flush_douon();
void makelist(int *, int *, int, int *);
void makelist(int*, int*, int, int*);
/* makeseg.c */
int make_knjstr(u_char *, int, u_char *);
int make_knjstr(u_char*, int, u_char*);
void makeseg();
void makehead(u_char *);
void makehead(u_char*);
/* memory.c */
void *Malloc(unsigned);
void *Zalloc(int);
void Free(void *);
void* Malloc(unsigned);
void* Zalloc(int);
void Free(void*);
/* offset.c */
void set_ofsrec(u_char *, int, int);
int isknjexist(u_char *, int);
void clear_ofsrec();
OffsetRec *real_ofsrec(u_char *);
void set_ofsrec(u_char*, int, int);
int isknjexist(u_char*, int);
void clear_ofsrec();
OffsetRec* real_ofsrec(u_char*);
/* readline.c */
int *readline();
int* readline();
void setline(void (*)(int*, int*, int, int*));
/* string.c */
int bubun_str(u_char *, int, u_char *, int);
int overlap_str(u_char *, int, u_char *, int);
int istrlen(int *);
int istrcmp(int *, int *);
int top_strcmp(int *, int *);
int last_strcmp(int *, int *);
int string_cmp(u_char *, int, u_char *, int);
int bubun_str(u_char*, int, u_char*, int);
int overlap_str(u_char*, int, u_char*, int);
int istrlen(int*);
int istrcmp(int*, int*);
int top_strcmp(int*, int*);
int last_strcmp(int*, int*);
int string_cmp(u_char*, int, u_char*, int);
#endif /* SJ3MKDIC_H */

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,8 +28,8 @@
*/
/*
* $SonyRCSfile: string.c,v $
* $SonyRevision: 1.1 $
* $SonyRCSfile: string.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:45 $
*/
@ -37,31 +37,29 @@
#include "sj3mkdic.h"
int
bubun_str(u_char *p1, int l1, u_char *p2, int l2)
{
u_char *p;
int bubun_str(u_char* p1, int l1, u_char* p2, int l2) {
u_char* p;
int l;
int i;
for (p = p1, l = l1 ; l > 0 ; ) {
if (l < l2) break;
for (i = 0 ; i < l2 ; i++)
if (*(p + i) != *(p2 + i)) break;
for(p = p1, l = l1; l > 0;) {
if(l < l2) break;
for(i = 0; i < l2; i++)
if(*(p + i) != *(p2 + i)) break;
if (i >= l2) return 1;
if(i >= l2) return 1;
i = codesize(*p);
p += i;
l -= i;
}
for (p = p2, l = l2 ; l > 0 ; ) {
if (l < l1) break;
for (i = 0 ; i < l1 ; i++) if (*(p + i) != *(p1 + i)) break;
for(p = p2, l = l2; l > 0;) {
if(l < l1) break;
for(i = 0; i < l1; i++)
if(*(p + i) != *(p1 + i)) break;
if (i >= l1) return -1;
if(i >= l1) return -1;
i = codesize(*p);
p += i;
@ -71,28 +69,24 @@ bubun_str(u_char *p1, int l1, u_char *p2, int l2)
return 0;
}
int
overlap_str(u_char *p1, int l1, u_char *p2, int l2)
{
u_char *p;
int overlap_str(u_char* p1, int l1, u_char* p2, int l2) {
u_char* p;
int l;
int i;
int j;
u_char tmp[MAXKANJILENGTH * 2 + MAXATRNUMBER * 2];
for (p = p1, l = l1 ; l > 0 ; ) {
if (l < l2) {
for (i = 0 ; (i < l) && (*(p + i) == *(p2 + i)) ; i++) ;
for(p = p1, l = l1; l > 0;) {
if(l < l2) {
for(i = 0; (i < l) && (*(p + i) == *(p2 + i)); i++);
if ((i >= l) && (l2 + l1 - l < sizeof(tmp))) {
for (i = 0 ; i < l1 ; i++)
if((i >= l) && (l2 + l1 - l < sizeof(tmp))) {
for(i = 0; i < l1; i++)
tmp[i] = *(p1 + i);
for (j = l ; j < l2 ; i++, j++)
for(j = l; j < l2; i++, j++)
tmp[i] = *(p2 + j);
if (check_hindo(tmp, i)) {
if(check_hindo(tmp, i)) {
return -1;
}
}
@ -103,18 +97,18 @@ overlap_str(u_char *p1, int l1, u_char *p2, int l2)
l -= i;
}
for (p = p2, l = l2 ; l > 0 ; ) {
if (l < l1) {
for (i = 0 ; (i < l) && (*(p + i) == *(p1 + i)) ; i++) ;
for(p = p2, l = l2; l > 0;) {
if(l < l1) {
for(i = 0; (i < l) && (*(p + i) == *(p1 + i)); i++);
if ((i >= l) && (l1 + l2 - l < sizeof(tmp))) {
if((i >= l) && (l1 + l2 - l < sizeof(tmp))) {
for (i = 0 ; i < l2 ; i++)
for(i = 0; i < l2; i++)
tmp[i] = *(p2 + i);
for (j = l ; j < l1 ; i++, j++)
for(j = l; j < l1; i++, j++)
tmp[i] = *(p1 + j);
if (check_hindo(tmp, i)) {
if(check_hindo(tmp, i)) {
return -1;
}
}
@ -128,72 +122,54 @@ overlap_str(u_char *p1, int l1, u_char *p2, int l2)
return 0;
}
int istrlen(int* s) {
int* p;
for(p = s; *p; p++);
int
istrlen(int *s)
{
int *p;
for (p = s ; *p ; p++) ;
return(p - s);
return (p - s);
}
int
istrcmp(int *s, int *d)
{
for ( ; *s && (*s == *d) ; s++, d++) ;
int istrcmp(int* s, int* d) {
for(; *s && (*s == *d); s++, d++);
return (*s - *d);
}
int top_strcmp(int* src, int* dst) {
int i = 0;
int
top_strcmp(int *src, int *dst)
{
int i = 0;
for (i = 0 ; *src && (*src == *dst) ; src++, dst++)
for(i = 0; *src && (*src == *dst); src++, dst++)
i++;
return (i > MAXYOMIASKNUMBER) ? MAXYOMIASKNUMBER : i;
}
int
last_strcmp(int *src, int *dst)
{
int slen, dlen;
int last_strcmp(int* src, int* dst) {
int slen, dlen;
slen = istrlen(src);
dlen = istrlen(dst);
if (dlen > MAXYOMIASKNUMBER)
if(dlen > MAXYOMIASKNUMBER)
return 0;
if (istrcmp(src + (slen - dlen), dst))
if(istrcmp(src + (slen - dlen), dst))
return 0;
return dlen;
}
int
string_cmp(u_char *p1, int l1, u_char *p2, int l2)
{
while (l1 > 0 && l2 > 0) {
if (*p1 != *p2) return (*p1 - *p2);
p1++; l1--;
p2++; l2--;
int string_cmp(u_char* p1, int l1, u_char* p2, int l2) {
while(l1 > 0 && l2 > 0) {
if(*p1 != *p2) return (*p1 - *p2);
p1++;
l1--;
p2++;
l2--;
}
if (l1 == l2) return 0;
if (l1 > l2) return 1;
if(l1 == l2) return 0;
if(l1 > l2) return 1;
return -1;
}