File diacritics.patch of Package xjdic
--- xjdic/xjdcomm.c 2003-05-28 07:43:27.000000000 +0200
+++ xjdic.new/xjdcomm.c 2003-09-12 07:30:57.000000000 +0200
@@ -177,6 +177,7 @@
extern unsigned char ENVname[], KDNSlist[];
extern unsigned char EXTJDXname[], EXTname[], Rname[], Vname[], ROMname[];
extern unsigned char RKname[];
+ extern unsigned char DIAname[];
extern unsigned char filtnames[NOFILT][50],filtcodes[NOFILT][10][10];
extern int Omode, Jverb, nofilts, filtact[], filtcoden[], filttype[], filton[];
extern int RVACTIVE;
@@ -347,6 +348,12 @@
}
#endif
#ifdef XJDFRONTEND
+ if( stringcomp((unsigned char *)"diacfile",rcwd) == 0)
+ {
+ rcwd = (unsigned char *)strtok(NULL," \t\f\r\n");
+ strcpy(DIAname,rcwd);
+ continue;
+ }
if( stringcomp((unsigned char *)"radkfile",rcwd) == 0)
{
rcwd = (unsigned char *)strtok(NULL," \t\f\r\n");
diff -ru xjdic/xjdfrontend.c xjdic.new/xjdfrontend.c
--- xjdic/xjdfrontend.c 2003-05-28 09:14:29.000000000 +0200
+++ xjdic.new/xjdfrontend.c 2003-09-13 09:49:07.000000000 +0200
@@ -101,6 +101,7 @@
unsigned char strfilt[10],tempout[80];
unsigned char KSname[50] = {"kanjstroke"};
unsigned char RKname[50] = {"radkfile"};
+unsigned char DIAname[50] = {"diacritics"};
unsigned char Rname[50] = {"radicals.tm"};
unsigned char ROMname[60] = {"romkana.cnv"};
unsigned char EXTJDXname[80] = {"edictext.xjdx"};
@@ -164,6 +165,8 @@
unsigned char clipstring1[51];
unsigned char clipstring2[51]={"XXXX"};
int RVACTIVE = TRUE;
+unsigned char dia212[300][4],diakeys[300][3];
+int nodia;
int DicNum;
long DicLoc;
@@ -171,6 +174,7 @@
/*====== Prototypes========================================================*/
FILE *xfopen(char *file_name, char *file_mode, int *xfilelen);
+int diafix(unsigned char *instr, int i);
int getcharxx();
void RadDisp();
void RadBuild();
@@ -178,6 +182,7 @@
void DoLOOKUP();
void RadLoad();
void KSLoad();
+void DiaLoad();
void xjdserver (int type, int dic_no, long index_posn, int sch_str_len,
unsigned char *sch_str, int *sch_resp, long *res_index,
int *hit_posn, int *res_len, unsigned char *res_str,
@@ -327,6 +332,64 @@
MaxY = window.ws_row;
}
+/*=====diafix====sort out input of possible diacritics============*/
+
+int diafix (unsigned char *instr, int pi)
+{
+
+ int di;
+ unsigned char ds[3];
+
+ ds[0] = instr[pi-1];
+ ds[1] = instr[pi];
+ ds[2] = 0;
+ for(di=0;di < nodia;di++)
+ {
+ if (strcmp(diakeys[di],ds) == 0)
+ {
+ strcpy(instr+pi-1,dia212[di]);
+ return(pi+1);
+ }
+ }
+ return(pi);
+}
+
+/*=====DiaLoad===Load file of diacritic mapping data===================*/
+void DiaLoad()
+{
+ int i,j,k,lno;
+ unsigned char *dptr;
+ FILE *fk,*fopen();
+
+ fk = xfopen(DIAname,"r",&xfilelen);
+ lno=0;
+ nodia = 0;
+ while(!feof(fk))
+ {
+ fgets(testline,99,fk);
+ if(feof(fk)) break;
+ testline[strlen(testline)-1] = 0;
+ lno++;
+ if (testline[0] == '#') continue;
+ dptr = strtok(testline,"\t");
+ if (strlen(dptr) != 3)
+ {
+ printf("\nBad data at line %d in diacritic file %s\n",lno,DIAname);
+ exit(1);
+ }
+ strcpy(dia212[nodia],dptr);
+ dptr = strtok(NULL,"\t");
+ if (strlen(dptr) != 2)
+ {
+ printf("\nBad data at line %d in diacritic file %s\n",lno,DIAname);
+ exit(1);
+ }
+ strcpy(diakeys[nodia],dptr);
+ nodia++;
+ }
+ fclose(fk);
+}
+
/*=====KSLoad===Load file of kanji/stroke data==========================*/
void KSLoad()
{
@@ -1168,6 +1231,7 @@
int i,j;
if (targ[0] < 127) return(noch+1);
+ if ((targ[0] == 0x8f) && (targ[1] <0xb0)) return(noch+1); /* diacritic*/
i = 0;
j = 0;
while(i <= noch)
@@ -1478,6 +1542,7 @@
/* now work forwards, displaying the line */
KTest = TRUE;
if (((fbuff[0] > 0xa5) || (fbuff[0] == 0x8f)) && (roff != 0)) KTest = FALSE;
+ if ((fbuff[0] == 0x8f) && (fbuff[1] < 0xb0)) KTest = TRUE;
if ((Dmode == 0) && GDmode) KTest = TRUE;
if (roff != 0) gdiclen--;
if (FiltOK && addhit(DicLoc) && (!FirstKanj || (FirstKanj && KTest)))
@@ -2807,6 +2872,7 @@
printf ("Loading Dictionary and Index files. Please wait...\n");
#endif
Verbinit();
+ DiaLoad();
DicSet ();
RadSet();
RadLoad();
@@ -2888,7 +2954,7 @@
break;
}
/* Turn on cmd mode for special characters */
- if ((!escf) && (!bit8) && (strchr("!{}$%*&^=/-:\'+\\;][|_`",c) != NULL))
+ if ((i==0) && (!escf) && (!bit8) && (strchr("!{}$%*&^=/-:\'+\\;][|_`",c) != NULL))
{
cmdmode = TRUE;
break;
@@ -2896,6 +2962,7 @@
/* backspace or rubout - shrink i/p buffer and redisplay */
if ((c == 0x7f) || (c == 8))
{
+ if ((i >= 2) && (instr[i-3] == 0x8f)) i-=2;
if(bit8) i--;
if( i > 0) instr[--i] = 0;
i--;
@@ -2908,6 +2975,15 @@
}
/* Actually an input character */
instr[i] = c;
+ if ((!escf) && (ispunct(c))) /* handle special diacritic input */
+ {
+ NoSJIS = TRUE;
+ i = diafix(instr,i);
+ strcpy(fbuff,instr);
+ printf("\r \r");
+ printf("%s",kbprompt);
+ KOut(fbuff);
+ }
if (AKanaMode)
{
if ((c == 'l') || (c == 'L'))
@@ -2927,8 +3003,10 @@
{
if (!bit8)
{
+ strcpy(fbuff,instr);
printf("\r \r");
- printf("%s%s",kbprompt,instr);
+ printf("%s",kbprompt);
+ KOut(fbuff);
}
else
{