File: debian.patch

package info (click to toggle)
xjdic 24-14
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 1,080 kB
  • sloc: ansic: 23,275; makefile: 191; sh: 55
file content (605 lines) | stat: -rw-r--r-- 17,318 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
--- xjdic-24.orig/Makefile
+++ xjdic-24/Makefile
@@ -55,7 +55,7 @@
 #LIBS= -lsocket -lnsl
 #
 CC=gcc -g
-all: xjdic_sa xjdic_cl xjdserver xjdxgen exjdxgen
+all: xjdic_sa xjdic_cl xjdserver xjdxgen exjdxgen xjdrad
 client: xjdic_cl
 server: xjdserver
 stand: xjdic_sa
@@ -123,11 +123,17 @@ xjdservcomm_sv.o: xjdservcomm.c
 xjdserver.o: xjdserver.c
 	$(CC) -c $(SVCFLAGS) xjdserver.c 
 $(SVOBJECTS): xjdic.h
+
+# xjdrad
+xjdrad: xjdrad.c
+	$(CC) $^ -o $@
+
+
 #
 clean:
 	rm -f *.o
 realclean: clean
-	rm -f xjdic_sa xjdic_cl xjdserver xjdxgen exjdxgen
+	rm -f xjdic_sa xjdic_cl xjdserver xjdxgen exjdxgen xjdrad
 #
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
--- xjdic-24.orig/exjdxgen.c
+++ xjdic-24/exjdxgen.c
@@ -66,9 +66,7 @@ int stringcomp(unsigned char *s1, unsign
 }
 
 /*====function to Load Dictionary and load/create index table=======*/
-main(argc,argv)
-int argc;
-unsigned char **argv;
+main(int argc, char **argv)
 {
   FILE *fp;
   unsigned long schi,diclen,indlen;
@@ -104,7 +102,6 @@ unsigned char **argv;
 	 exit(1);
   }
   diclen = buf->st_size;
-  printf("\nWARNING!!  This program may take a long time to run .....\n");
 
   puts ("\nLoading Dictionary file.  Please wait.....\n");
   fp=fopen(Dname,"rb");
@@ -217,7 +214,7 @@ unsigned char **argv;
 	}
     }
     indptr-=2;
-    printf("Index entries: %ld  \nSorting (this is slow)......\n",indptr);
+    printf("Index entries: %ld  \nSorting ......\n",indptr);
     jqsort(llone,(indptr/2)+1);
     printf("Sorted\nWriting index file ....\n");
     fp = fopen(JDXname,"wb");
--- xjdic-24.orig/xjdclient.c
+++ xjdic-24/xjdclient.c
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -40,7 +41,6 @@
 
 #define CVERBOSE 0
 int chk_cnt=0;
-extern int errno;
 unsigned char host[51] = {"localhost"};
 unsigned char yn[2];
 unsigned int portno = XJ_PORTNO;
--- xjdic-24.orig/xjdcomm.c
+++ xjdic-24/xjdcomm.c
@@ -232,6 +232,7 @@ void xjdicrc()
 		while(fgets(rcstr,79,fm) != NULL)
 		{
 			rcwd = (unsigned char *)strtok(rcstr," \t");
+			if (rcwd == NULL) continue; /* Debian fix for bug #716515 */
 /*  dicdir works for all modes   */
 			if( stringcomp((unsigned char *)"dicdir",rcwd) == 0)
 			{
--- xjdic-24.orig/xjdfrontend.c
+++ xjdic-24/xjdfrontend.c
@@ -21,11 +21,15 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
+#ifdef __GNU__
+#include <sys/ioctl.h>
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdlib.h>
 #include <signal.h>
 #include <errno.h>
+#include <unistd.h>
 #include "xjdic.h"
 
 /*    Paul Burchard supplied a patch to provide BSD compatibility for xjdic
@@ -33,10 +37,14 @@
 order to enable this, people should compile with the option
 -D__STRICT_BSD___ .         */
 
+#if defined(__FreeBSD_kernel__)
+#define __STRICT_BSD__
+#endif
+
 #ifdef __STRICT_BSD__
 #include <sgtty.h>
 #else
-#ifdef __POSIX__
+#if defined(__POSIX__) || defined(__GNU__)
 #include <sys/termios.h>
 #else
 #include <termio.h>
@@ -55,6 +63,8 @@ IOCTL_RAW
 
 #ifdef __STRICT_BSD__
 static struct sgttyb    orig,new;
+#elif defined(__GNU__)
+static struct termios   orig,new;
 #else
 static struct termio    orig,new;
 #endif
@@ -98,7 +108,7 @@ int extlen,extjdxlen;
 unsigned char kmodes[2][10] = {"ON","OFF"};
 unsigned char kmodes_r[2][10] = {"OFF","ON"};
 unsigned long chline,chpos,it;
-unsigned char strfilt[10],tempout[80];
+unsigned char strfilt[10],tempout[256];
 unsigned char KSname[50] = {"kanjstroke"};
 unsigned char RKname[50] = {"radkfile"};
 unsigned char Rname[50] = {"radicals.tm"};
@@ -115,7 +125,7 @@ int jiver = 14;		/*The last time the ind
 unsigned char sver[] = {SVER};
 unsigned char fbuff[512],KLine[KFBUFFSIZE],karray[KANJARRAYSIZE][5];
 unsigned char LogLine[200];
-unsigned char ksch[50],ktarg[50];
+unsigned char ksch[256],ktarg[256];
 /* The following Help table has "~" to force spaces   */
 unsigned char Help[40][81] = {
 "\n~~~~~~~~~~~~~~~~~~XJDIC USAGE SUMMARY ",
@@ -154,7 +164,7 @@ unsigned char testline[1025],SingleFilte
 unsigned char vdicf[VMAX][7],vinfl[VMAX][21],vcomms[41][50];
 int strf,Jverb = TRUE,SFFlag=FALSE,vcommno[VMAX];
 int ROmode = 1,EMmode = 1,KLmode = 1,KImode = 1,KLRmode,KLcount;
-unsigned char vline[250],vstr[13];
+unsigned char vline[5000],vstr[13];
 unsigned char RadK1[300],RadK2[300],*RKanj1,*RKanj2,*RKSet[10];
 unsigned char RKTarg[21];
 int rmax,NoSets=0,NoRads,RKStart[300],RKCnt[300];
@@ -242,10 +253,19 @@ void    ioctlraw()
     new.sg_flags |= CBREAK; new.sg_flags &= ~ECHO;
     ioctl(0, TIOCSETP, &new);
 #else
+#ifdef __GNU__
+    tcgetattr(0, &orig); tcgetattr(0, &new);
+#else
     ioctl(0, TCGETA, &orig); ioctl(0, TCGETA, &new);
+#endif
     new.c_lflag &= ~ICANON; new.c_lflag &= ~ISIG; new.c_lflag &= ~ECHO;
     new.c_lflag &= ~IXON;
-    new.c_cc[4] = 1; new.c_cc[5] = 0;   ioctl(0, TCSETA, &new);
+    new.c_cc[VMIN] = 1; new.c_cc[VTIME] = 0;
+#ifdef __GNU__
+    tcsetattr(0, TCSANOW, &new);
+#else
+    ioctl(0, TCSETA, &new);
+#endif
 #endif
     myi_status=IOCTL_RAW;
   }
@@ -256,6 +276,8 @@ void    ioctlorig()
 {
 #ifdef __STRICT_BSD__
    ioctl(0, TIOCSETP, &orig);
+#elif defined(__GNU__)
+   tcsetattr(0, TCSANOW, &orig);
 #else
    ioctl(0, TCSETA, &orig);
 #endif
@@ -283,7 +305,12 @@ int getcharxx()
 	}
 	else
 	{
-		return(getchar());
+		int c = getchar();
+		if (c == EOF)
+		{
+			exit(0);
+		}
+		return(c);
 	}
 }
 /*====GetWinSize==== Hank Cohen's routine for getting the (new) window size==*/
@@ -440,7 +467,7 @@ void DoRomaji(unsigned char kc)
 			{
 				ksch[is-1] = '\0';
 				is--;
-  				sprintf(tempout,"\r                                     \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp);
+  				snprintf(tempout,sizeof(tempout),"\r                                     \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp);
 				KOut(tempout);
 				continue;
 			}
@@ -449,7 +476,7 @@ void DoRomaji(unsigned char kc)
 				if (strlen(ktarg) != 0)  /* kana mode - back over a kana  */
 				{
 					ktarg[strlen(ktarg)-2] = '\0';
-  					sprintf(tempout,"\r                                     \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp);
+  					snprintf(tempout,sizeof(tempout),"\r                                     \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp);
 					KOut(tempout);
 					continue;
 				}
@@ -460,7 +487,7 @@ void DoRomaji(unsigned char kc)
 		ksch[is] = c | 0x20;
 		ksch[is+1] = '\0';
 		is++;
-  		sprintf(tempout,"\r                                     \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp);
+  		snprintf(tempout,sizeof(tempout),"\r                                     \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp);
 		KOut(tempout);
   	}
 	if (ksp != is)
@@ -543,9 +570,9 @@ int kanaconv(int rpos, int rlen)
 	{
 		if (strlen(targ) != strlen(kanatab[ki])) continue;
 		if (stringcomp(targ,kanatab[ki]) != 0) continue;
-		strcat(ktarg,kanatab[ki+1]);
+		strncat(ktarg,kanatab[ki+1],sizeof(ktarg)-1-strlen(ktarg));
 		ksp = ksp+rlen;
-  		sprintf(tempout,"\r                                     \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp);
+  		snprintf(tempout,sizeof(tempout),"\r                                     \r%sROMAJI ENTRY:%s %s%s",RVon,RVoff,ktarg,ksch+ksp);
 		KOut(tempout);
 		return (TRUE);
 	}
@@ -668,7 +695,7 @@ int KFlush(unsigned char *msg)
 			if (!retf) return (FALSE);
 		}
 		KOut(ktemp);
-		if (DCol <= MAXCOLS) KOut(" ");
+		if (DCol <= MaxX) KOut(" ");
 		kptr = (unsigned char *)strtok(NULL," ");
 	}
 	KOut("\n");
@@ -1066,7 +1093,7 @@ int Vlookup()
 {
 
 	int xjresp,roff,rlen;
-	unsigned char repstr[512];
+	unsigned char repstr[MAX_ENTRY_SIZE];
 	long respos;
 	int hit,schix;
 	unsigned char khi,klo,cc,ops[4];
@@ -1255,7 +1282,7 @@ dictionary. It matches the full string,
 	unsigned char vlast[11],temp[11],ops[80];
 	int vi,vok,prevch,KDNSflag,KDskip,KTest;
 	int xjresp,roff,rlen;
-	unsigned char repstr[512];
+	unsigned char repstr[MAX_ENTRY_SIZE];
 	unsigned long respos;
 
 	vlast[0] = 0;
@@ -1812,7 +1839,7 @@ void DoRADICALS()
 			KFlushRes = KFlush("Continue displaying radicals? (y/n)");
 			if (!KFlushRes) return;
 			rstr[2] = 0;
-			sprintf(tempout,"%s Stroke Radicals ",rstr);
+			snprintf(tempout,sizeof(tempout),"%s Stroke Radicals ",rstr);
 			strcpy(KLine,tempout);
 			KFlushRes = KFlush("Continue displaying radicals? (y/n)");
 			if (!KFlushRes) return;
@@ -1826,7 +1853,7 @@ void DoRADICALS()
 		KOutc(rstr[1]);
 		KOutc(0xa1);
 		KOutc(0xa1);
-		sprintf(tempout,"%s ",rstr+3);
+		snprintf(tempout,sizeof(tempout),"%s ",rstr+3);
 		strcat(KLine,tempout);
 	}
 	KFlush("");
@@ -1919,7 +1946,7 @@ void DoJIS()
 	Dmode =1;
 	fbuff[0] = 0; fbuff[1] = 0;
 	if (hojof) fbuff[0] = 0x8f;
-	strcat(fbuff,instr);
+	strlcat(fbuff,instr,sizeof(fbuff));
 	fseek(stdin,0L,SEEK_END); /*kill any leftovers*/
 	KLookup();
 	instr[0] = 0;
@@ -1953,7 +1980,7 @@ void GetKBStr(unsigned char *prompt)
 			if(bit8) i--;
 			if( i > 0) instr[--i] = 0;
 			i--;
-			strcpy(fbuff,instr);
+			strncpy(fbuff,instr,sizeof(fbuff));
 			if (!NoSJIS) FixSJIS(fbuff);
 			printf("\r                                       \r");
 			printf("%s%s%s ",RVon,prompt,RVoff);
@@ -1970,7 +1997,7 @@ void GetKBStr(unsigned char *prompt)
 			}
 			else
 			{
-				strcpy(fbuff,instr);
+				strncpy(fbuff,instr,sizeof(fbuff));
 				if ((strlen(fbuff) % 2) > 0) fbuff[strlen(fbuff)-1] = 0;
 				printf("\r                                       \r");
 				printf("%s%s%s ",RVon,prompt,RVoff);
@@ -2573,10 +2600,7 @@ void FiltSet()
 
 /*                  M A I N                                      */
 
-main(argc,argv)
-int argc;
-unsigned char **argv;
-
+main(int argc,char **argv)
 {
 	int i,j,ip,cmdmode,bit8,escf;
   	unsigned char *dicenv,strtmp[50];
@@ -2636,6 +2660,7 @@ unsigned char **argv;
 				else
 				{
 					i++;
+					if (i >= argc) continue;
 					strcpy(xap,argv[i]);
 					strcpy (strtmp,xap);
 				}
@@ -2651,6 +2676,7 @@ unsigned char **argv;
 				else
 				{
 					i++;
+					if (i >= argc) continue;
 					strcpy(xap,argv[i]);
 					strcpy (strtmp,xap);
 				}
@@ -2681,7 +2707,8 @@ unsigned char **argv;
 				else
 				{
 					i++;
-					strcpy(xap,argv[i]);
+					if (i >= argc) continue;
+					strncpy(xap,argv[i],sizeof(xap));
 					strcpy(host,xap);
 				}
 				printf("Command-line request to use server: %s\n",host);
@@ -2696,6 +2723,7 @@ unsigned char **argv;
 				else
 				{
 					i++;
+					if (i >= argc) continue;
 					strcpy(xap,argv[i]);
 					portno = atoi(xap);
 				}
@@ -2713,6 +2741,7 @@ unsigned char **argv;
 				else
 				{
 					i++;
+					if (i >= argc) continue;
 					strcpy(xap,argv[i]);
 					strcpy (strtmp,xap);
 				}
@@ -2737,6 +2766,7 @@ unsigned char **argv;
 				else
 				{
 					i++;
+					if (i >= argc) continue;
 					strcpy(xap,argv[i]);
 					strcpy (strtmp,xap);
 				}
@@ -2756,6 +2786,7 @@ unsigned char **argv;
 				else
 				{
 					i++;
+					if (i >= argc) continue;
 					strcpy(xap,argv[i]);
 					strcpy (strtmp,xap);
 				}
@@ -2899,7 +2930,7 @@ exit(0);
 				if(bit8) i--;
 				if( i > 0) instr[--i] = 0;
 				i--;
-				strcpy(fbuff,instr);
+				strncpy(fbuff,instr,sizeof(fbuff));
 				if (!NoSJIS) FixSJIS(fbuff);
 				printf("\r                                       \r");
 				printf("%s",kbprompt);
@@ -2932,7 +2963,7 @@ exit(0);
 				}
 				else
 				{
-					strcpy(fbuff,instr);
+					strncpy(fbuff,instr,sizeof(fbuff));
 					if ((strlen(fbuff) % 2) > 0) fbuff[strlen(fbuff)-1] = 0;
 					printf("\r					 \r");
 					printf("%s",kbprompt);
@@ -3093,7 +3124,7 @@ exit(0);
 					GetKBStr("INDEX CODE:");
 					fflush(stdin);
 					Dmode =1;
-					strcat(fbuff," ");
+					strlcat(fbuff," ",sizeof(fbuff));
 			/* For bushu or classical radical, ask for stroke count	*/
 					if (((fbuff[0] | 0x20) == 'b')||((fbuff[0] | 0x20) == 'c'))
 					{
@@ -3104,7 +3135,7 @@ exit(0);
 								if((fbuff[1] != radkanj[i][0]) || (fbuff[2] != radkanj[i][1])) continue;
 								sprintf(strtmp,"%d",radnos[i]);
 								strcpy(fbuff+1,strtmp);
-								strcat(fbuff," ");
+								strlcat(fbuff," ",sizeof(fbuff));
 								printf("Bushu: %s\n",strtmp);
 								break;
 							}
@@ -3205,7 +3236,7 @@ exit(0);
 		if(strlen(instr) < 2) continue;
 		GetEUC(fbuff);
 		if (escf) KOut(fbuff);
-		sprintf(tempout,"\nSearching for: %s%s%s\n",RVon,fbuff,RVoff);
+		snprintf(tempout,sizeof(tempout),"\nSearching for: %s%s%s\n",RVon,fbuff,RVoff);
 		KOut(tempout);
 		Dmode = 0;
 		if (prieng && (fbuff[0] < 128)) /* if priority English key only */
--- xjdic-24.orig/xjdic.1
+++ xjdic-24/xjdic.1
@@ -434,6 +434,12 @@ set the screen output codes to EUC, JIS
 set the initial default input mode to hiragana
 .At
 
+.B exactmatch 
+[SA,CL]
+.Ap
+toggles the exact match option
+.At
+
 .B dicdir path_name 
 [SA,SV,CL]
 .Ap
--- xjdic-24.orig/xjdic.h
+++ xjdic-24/xjdic.h
@@ -2,8 +2,8 @@
 #define MAXCOLS 80      /* default cols per display */
 #define NRKANA 250*2   /*  size of the romaji to kana tables*/
 #define NOFILT 10      /* maximum number of general filters */
-#define VMAX 350       /* maximum entries in the verb table */
-#define DEFAULT_DICDIR ""    /* could be: "/usr/local/lib/xjdic"   */
+#define VMAX 600       /* maximum entries in the verb table */
+#define DEFAULT_DICDIR "/var/lib/xjdic"    /* could be: "/usr/local/lib/xjdic"   */
 #define NOHITS 1000       /* size of hittab  */
 #define SPTAG '@'         /* character that flags priority entries */
 #define KFBUFFSIZE 2000   /* size of the KFlush buffer */
@@ -19,6 +19,9 @@
 				  lookup (default 20)	*/
 #define MAXITER 40		/*maximum binary search iterations*/
 
+#define MAX_ENTRY_SIZE 4096	/* maximum size of an edict entry */
+				/* (this only applies to the stand-alone client) */
+
 /* The following is for Solarises   */
 
 #ifndef SEEK_END
--- xjdic-24.orig/xjdrad.c
+++ xjdic-24/xjdrad.c
@@ -149,15 +149,17 @@ FILE  *xfopen(char *file_name, char *fil
 /*=====xjdicrc - access and analyze "xjdicrc" file (if any)==============*/
 void xjdicrc()
 {
-	unsigned char xjdicdir[128],rcstr[80],*rcwd;
+	unsigned char xjdicdir[256],rcstr[80],*rcwd;
 	int ft,fn;
 	FILE *fm;
 
 	xjdicdir[0] = '\0';
 	if (strlen(ENVname) > 2)
 	{
-		strcpy(xjdicdir,ENVname);
-		strcat(xjdicdir,"/");
+		if (getenv("HOME") != NULL) {
+			strcpy(xjdicdir,ENVname);
+			strcat(xjdicdir,"/");
+		}
 	}
 	else    
 	{
@@ -172,7 +174,7 @@ void xjdicrc()
 		strcpy(xjdicdir,".xjdicrc");
 		fm = fopen(xjdicdir,"r");
 	}
-	if (fm == NULL)
+	if (fm == NULL && getenv("HOME") != NULL)
 	{
 		strcpy(xjdicdir,getenv("HOME"));
 		strcat(xjdicdir,"/");
--- xjdic-24.orig/xjdsa.c
+++ xjdic-24/xjdsa.c
@@ -186,7 +186,7 @@ void xjdserver (int type, int dic_no, lo
 	*dic_loc = schix;
 	for (i = 0; dbchar(schix+i) != 0x0a; i++)
 	{
-		if (i == 512)
+		if (i == MAX_ENTRY_SIZE)
 		{
 			printf ("Reply overrun\n");
 			exit(1);
--- xjdic-24.orig/xjdserver.c
+++ xjdic-24/xjdserver.c
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
@@ -28,6 +29,7 @@
 #include <netdb.h>
 #include <stdlib.h>
 #include <signal.h>
+#include <unistd.h>
 #include "xjdic.h"
 
 #define SVERBOSE 0
@@ -56,8 +58,6 @@ int jiver = 14;
 int thisdic = 0;
 int DicNum;
 
-extern int errno;
-
 extern unsigned char Dnamet[10][100],XJDXnamet[10][100];
 extern unsigned char *dicbufft[10];
 extern unsigned long diclent[10], indlent[10],indptrt[10];
@@ -144,7 +144,7 @@ void sendresponse()
 
 main(argc,argv)
 int argc;
-unsigned char **argv;
+char **argv;
 
 {
 	int iterlimit,i;
@@ -463,7 +463,7 @@ unsigned char **argv;
 		{
 			pdu_out.xjdrsp_resindex = htonl(schix);
 		}
-		for (i = 0; dbchar(schix+i) != 0x0a; i++)
+		for (i = 0; i < 510 && dbchar(schix+i) != 0x0a; i++)
 		{
 			pdu_out.xjdrsp_resstr[i] = dbchar(schix+i);
 		}
--- xjdic-24.orig/xjdxgen.c
+++ xjdic-24/xjdxgen.c
@@ -23,9 +23,10 @@
 #include <sys/stat.h>
 
 #include <stdio.h>
-/*#include <stdlib.h>*/
+#include <stdlib.h>
 #include <ctype.h>
 #include <string.h>
+#include <unistd.h>
 #include "xjdic.h"
 
 #define TRUE 1
@@ -74,9 +75,7 @@ int stringcomp(unsigned char *s1, unsign
 }
 
 /*====function to Load Dictionary and load/create index table=======*/
-main(argc,argv)
-int argc;
-unsigned char **argv;
+main(int argc, char **argv)
 {
   FILE *fp;
   unsigned long possav,schi,diclen,indlen;
@@ -113,7 +112,7 @@ unsigned char **argv;
 	strcpy(JDXname,*ap);
 	strcat(JDXname,".xjdx");
     	printf("Commandline request to use files %s and %s \n",Dname,JDXname);
-	ap++;
+	//ap++; fix for Mayhem Debian #716516
 	arg_c--;
   }
   xjdicrc();
@@ -128,7 +127,6 @@ unsigned char **argv;
 	 exit(1);
   }
   diclen = buf->st_size;
-  printf("\nWARNING!!  This program may take a long time to run .....\n");
 
   puts ("\nLoading Dictionary file.  Please wait.....\n");
   fp=fopen(Dname,"rb");
@@ -261,7 +259,7 @@ unsigned char **argv;
 	  }
     }
     indptr--;
-    printf("Index entries: %ld  \nSorting (this is slow)......\n",indptr);
+    printf("Index entries: %ld  \nSorting ......\n",indptr);
     jqsort(llone,indptr);
     printf("Sorted\nWriting index file ....\n");
     fp = fopen(JDXname,"wb");