File: search.c

package info (click to toggle)
kdrill 6.5deb2-12
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,340 kB
  • sloc: ansic: 7,636; makefile: 47
file content (899 lines) | stat: -rw-r--r-- 19,186 bytes parent folder | download | duplicates (7)
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
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
/* I'm changing this so that only the actual SEARCH routines are in here. 
 * widget creation has been moved to "searchwidgets.c"
 */

#include <stdio.h>

#include <Xos.h>
#include <Intrinsic.h>
#include <StringDefs.h>

#include <Shell.h>



#include "defs.h"
#include "externs.h"
#include "game.h"
#include "widgets.h"
#include "search.h"
#include "convert.h"
#include "multikanji.h"
#include "strokesearch.h"
#include "readfile.h"
#include "utils.h"
#include "log.h"

#include "searchwidgets.h"


TRANSLATION lastsearch=NULL;	/* holds index of last kanji searched */

/* called from DoStrokeSearch()
 * Go look for all kanji with this strokecount.
 * 
 */
void dostrokefind(BYTE strokecount, BITS16 skipval)
{
	short skipmask=skipfromthree(3,0,0);
	TRANSLATION searchtarget = NULL;
	TRANSLATION firstmatch = NULL;
	int searchndx=lowestkanji;

	if(strokecount==0)
		return;

#ifdef DEBUG
	printf("searching for strokecount %d\n",strokecount);
#endif

	setstatus("Searching...");

	ClearAllMulti();

	for(searchndx=lowestkanji; searchndx <=highestkanji; searchndx++){
		searchtarget=translations[searchndx];
		if(searchtarget==NULL) continue;

		if(searchtarget->Strokecount != strokecount) {
			continue;
		}

		if(skipval!=0)
			if((searchtarget->Sindex & skipmask) != skipval){
				continue;
			}

		if(match_onlyactive){
			if(!UseThisKanji(searchndx)) {
				continue;
			}
		}
		
		AddMultiTranslation(searchtarget);
		if(firstmatch==NULL)
			firstmatch=searchtarget;

	}

	if(firstmatch!=NULL){
		setstatus("Search complete");
		if(getMultiCount() >1){
			ShowMulti();
		}
	} else{
		setstatus("No match found");
		Beep();
	}
	
}

/* called by doenglishfind, if we need to restrict search to
 * "beginning of word only"
 * return 1 on match, 0 on not.
 */
int matchengfirst(char *full, char *frag){
	int len=strlen(frag);
	while(1){
		if(strncmp(full,frag,len) ==0){
			return 1;
		}
		full=strchr(full,':'); /* actually, " : " */
		if(full==NULL){
			return 0;
		}
		full+=1;
	}
	return 0;
}

/* doenglishfind:
 *	Assume what we want to look for is in the search ENGLISH INPUT widget.
 *	First, read in that value from the widget
 *	(okay, this is not modular :-)
 *
 *	Then go through the whole dictionary looking for matches,
 *	and adding any matches to the multi window.
 *	We show the multiwindow, if appropriate
 *	We return the first match, if any.
 *	But we do not set the main search window, for some reason.
 */
TRANSLATION doenglishfind()
{
	String str;
	TRANSLATION searchtarget = NULL;
	TRANSLATION firstmatch = NULL;
	int searchndx=lowestkanji;

	setstatus("Searching...");

	XtVaGetValues(searchwidgets[SEARCH_ENG_W],XtNstring,&str,NULL);

	if((str[0] == '\0') || (str[0] == '\n')){
		return NULL;
	}

	ClearAllMulti();
	searchtarget=translations[lowestkanji];



	for(searchndx=lowestkanji;searchndx<=highestkanji;searchndx++){
		searchtarget=translations[searchndx];
		if(searchtarget==NULL) continue;

		if(match_onlyatstart){
			if(matchengfirst(searchtarget->english,str) != 1){
				continue;
			}
		} else {
			if(strstr(searchtarget->english,str) == NULL){
				continue;
			}
		}

		if(match_onlyactive){
			if(!UseThisKanji(searchndx)){
				continue;
			}
		}
			
		AddMultiTranslation(searchtarget);
		if(firstmatch==NULL){
			firstmatch=searchtarget;
		}
	}



	if(firstmatch!=NULL){
		setstatus("Search complete");
		if(getMultiCount() >1){
			ShowMulti();
		}
	} else{
		setstatus("No match found");
		Beep();
	}

	return firstmatch;
	
}

/********************************************************************
 * suite of really stupid-looking routines, so I can do INTELLIGENT *
 * generic-comparisons in DoFind, and posibly elsewhere             *
 ********************************************************************/

Boolean compareUnicode(TRANSLATION entry, int compvalue){
	if(entry->Uindex==compvalue) return True;
	return False;
}
Boolean compareHalpern(TRANSLATION entry, int compvalue){
	if(entry->Hindex==compvalue) return True;
	return False;
}
Boolean compareNelson(TRANSLATION entry, int compvalue){
	if(entry->Nindex==compvalue) return True;
	return False;
}
Boolean compareFreq(TRANSLATION entry, int compvalue){
	if(entry->frequency==compvalue) return True;
	return False;
}

/************************************************************/


/* DoFind
 *   (do-find)accelerator hook
 *   This handles callbacks for multiple widgets.
 *   Basically, any inputfield on the Search window, that uses
 *   [ENTER] as a trigger for a search.
 *   Except for the kanasearch
 */
void 
DoFind(Widget w,XEvent *event,String *params,Cardinal *num_parags){
	TRANSLATION findtarget = NULL;
	int targetval=0, retval=0, ndx=0;
	Boolean (* comparefunc)(TRANSLATION,int);

	setstatus("Searching...");

	if(w == searchwidgets[SEARCH_ENG_W]){
		findtarget = doenglishfind();

		if(findtarget == NULL){
			setstatus("No match found");
			Beep();
			printsearch(lastsearch);
		} else {
			printsearch(findtarget);
		}
		return;
	}

	/* Special case: not a "find this index", but a
	 * "find me this index or greater"
	 */
	if (w == searchnumbers[POUND_INPUT]){
		int number;
		/* want closest index match */
		number = GetWidgetHexval(w);

		if((number <lowestkanji) || (number> highestkanji)){
			setstatus("input out of dict. range");
			Beep();
			printsearch(lastsearch);
			return;
		} 

		if(number > highestkanji){
			number = highestkanji;
		} else if (number <lowestkanji){
			number = lowestkanji;
		} else {
			/* find closest non-blank */
			while(translations[number] == NULL){
				number++;
				/* this should never be triggered, but... */
				if(number >highestkanji)
					number = lowestkanji;
			}
		}

		findtarget = translations[number];

		printsearch(findtarget);

		setstatus("Search complete");
		return;
	}


	if(w==searchnumbers[U_INPUT]) {
		targetval=GetWidgetHexval(w);
	} else {
		targetval=GetWidgetNumberval(w);
	}

	if(w==searchnumbers[U_INPUT]){
		comparefunc=compareUnicode;
	} else if (w == searchnumbers[F_INPUT]) {
		comparefunc=compareFreq;
	} else if (w == searchnumbers[H_INPUT]) {
		comparefunc=compareHalpern;
	} else if (w == searchnumbers[N_INPUT]) {
		comparefunc=compareNelson;
	} else {
		puts("DEBUG: ERROR: unrecognized compare type in DoFind");
		return ;
	}

	for(ndx=lowestkanji;ndx<highestkanji;ndx++){
		if(translations[ndx]==NULL)
			continue;
		if(comparefunc(translations[ndx],targetval)){
			retval=ndx;
			break;
		}
	}


	if(retval!=0){
		findtarget = translations[retval];
		printsearch(findtarget);
		setstatus("Displaying match");
	} else {
		setstatus("No match found");
		Beep();
	}

	

}



/* Finds a match for single UNICODE-encoded widechar.
 * Returns pointer to translation struct, or NULL if no match.
 */
TRANSLATION dounicodefind(XChar2b *target)
{
	/* The guts of this are modeled after the special-case for xU,
	 * in DoFind()
	 */

	int ndx, retval=0;
	int targetval=(target->byte1 <<8) | target->byte2;

	for(ndx=lowestkanji;ndx<highestkanji;ndx++){
		if(translations[ndx]==NULL)
			continue;
		if(compareUnicode(translations[ndx],targetval)){
			retval=ndx;
			break;
		}
	}
	if(retval!=0){
		return translations[retval];
	} else {
		return NULL;
	}
}


/* pass in unicode string.
 * look for match. display if found.
 * Fancy stuff;
 *   If single-char, just looks it up in kanjidic.
 *
 *   If multi-char, then attempts to look up each char in kanjidic,
 *   to convert unicode to JIS, THEN does search on JIS string. Wheee!
 */
void findunicodestring(XChar2b *target)
{
	XChar2b jisstring[5];
	TRANSLATION umatch;
	bzero(jisstring, sizeof(XChar2b) * 5);

	if(target==NULL) return;

	umatch=dounicodefind(target);

	if(umatch==NULL){
		setstatus("No match found");
		Beep();
		return;
	}

	/* only a single-char long */
	if(target[1].byte1==0){
		printsearch(umatch);
		setstatus("Displaying match");
		return;
	}

	jisstring[0].byte1=umatch->kanji->byte1;
	jisstring[0].byte2=umatch->kanji->byte2;

	umatch=dounicodefind(&target[1]);
	if(umatch==NULL){
		/* allow for a bit of mouse overswipe on a line */
		/* setstatus("Displaying fragment match"); */
		findkanjiall(jisstring);
		return;
	}
	jisstring[1].byte1=umatch->kanji->byte1;
	jisstring[1].byte2=umatch->kanji->byte2;

	if(target[2].byte1){
		umatch=dounicodefind(&target[2]);
		if(umatch!=NULL){
			jisstring[2].byte1=umatch->kanji->byte1;
			jisstring[2].byte2=umatch->kanji->byte2;
		}
	}

	findkanjiall(jisstring);
	
}


/* if fragment matches FIRST chars of fullstring, return 1.
 * Otherwise, return  0
 *   Allow hiragana/kanakana folding.
 */
int matchkanafirst(XChar2b *fullstring, XChar2b *fragment)
{
	while(1){
		if(fragment->byte1==0)
			return 1;

		/* no need to test for fullstring->byte1==0,
		 * it will just fail match :-)
		 * Although if we were nice, we could return a value
		 * saying the thing is too short
		 */

		/* theres almost no point to this. sigh.*/
		if(fullstring->byte1 != fragment->byte1){
			if((fullstring->byte1 != 0x24) &&
			   (fullstring->byte1 != 0x25))
				return 0;
			if((fragment->byte1 != 0x24) &&
			   (fragment->byte1 != 0x25))
				return 0;
		}

		if(fullstring->byte2 != fragment->byte2)
			return 0;

		fragment++;
		fullstring++;
	}
}

/* match XChar2b
 *	Attempt to find occurence of fragment in xchar2b string
 *	return 1 on match, 0 on fail.
 *
 *	Note that we try to allow match of kanagana, by hiragana.
 *	If match_onlyatstart!=0, only match if start of a kana phrase
 *	matches fragment
 */
int matchkana(XChar2b *fullstring, XChar2b *fragment)
{

	if(match_onlyatstart){
		while(fullstring->byte1 != 0){
			if(matchkanafirst(fullstring,fragment))
				return 1;

			/* Oh well.... Find start of next "word".
			 * First skip over "current" word, then
			 * then look for valid kanji char.
			 * Remember, we need to skip space, AND things
			 * like parenthesis
			 */

			/* Look for space, explicitly */
			while(fullstring->byte1 != 0){
				if((fullstring->byte1==0x21) &&
				   (fullstring->byte2==0x21)){
					break;
				}
				fullstring++;
			}
			/* now have either space, or end-of-string */
			/* so look for begining of word */
			while(fullstring->byte1 < 0x24){
				if(fullstring->byte1 ==0)
					break;
				fullstring++;
			}
			
			if(fullstring->byte1 ==0){
				/* oh well, end of string hit */
				break;
			}

			/* We must be in the kana-and-above range now.
			 * just loop and search again!
			 */
		}

		return 0;
	}

	/* else */

	while(fullstring->byte1 != 0){
		if(matchkanafirst(fullstring,fragment))
			return 1;
		fullstring++;

	}
	return 0;

}


/*
 *	Equivalent to matchkana!
 *	return 1 if match, 0 if no match
 *
 *	Note that this takes intoaccount 'match_onlyatstart'
 *	Which will presumably only match the kanji if at beginning
 *	of the phrase. Hmmm.
 */
int matchkanji(XChar2b *fullstring, XChar2b *fragment)
{
	return matchkana(fullstring,fragment);
}

/*
 * a kanji equivalent to strchr()
 * Returns pointer to first place the single widechar kchar is found in
 * kanji string, or NULL if no match
 */
XChar2b * kstrchr(XChar2b *string, XChar2b kchar)
{
	while(string->byte1 !=0){
		if((kchar.byte1==string->byte1) &&
		   (kchar.byte2==string->byte2))
		{
			return string;
		}
		string++;
	}

	return NULL;
}



/* dokanafind()
 *	find match to XChar2b string in kana translations
 */

void dokanafind(XChar2b *target)
{
	TRANSLATION firstmatch = NULL;
	TRANSLATION searchtarget = NULL;
	int searchndx=lowestkanji;

	setstatus("Searching...");

	searchtarget=translations[lowestkanji];
	ClearAllMulti();

	for(searchndx=lowestkanji; searchndx <=highestkanji; searchndx++){
	
		searchtarget=translations[searchndx];
		if(searchtarget==NULL) continue;
		if(match_onlyactive){
			if(!UseThisKanji(searchndx)) {
				continue;
			}
		}

		if(matchkana(searchtarget->pronunciation, target)){
			AddMultiTranslation(searchtarget);
			if(firstmatch==NULL)
				firstmatch=searchtarget;
		}
	}

	if(firstmatch!=NULL){
		printsearch(firstmatch);
		setstatus("Search complete");
		if(getMultiCount() >1){
			ShowMulti();
		}
	} else{
		setstatus("No match found");
		Beep();
	}

	return;
}


/* This is here, because I want to preserve all "search" type
 * routines together in this file.
 * But it is called by Handle_showusefile
 *
 * The purpose is to let the user easily see which chars are in the
 * usefile, and easily remove them. They already have an easy way
 * to ADD them, via the search window :-)
 */
void dousefilefind()
{
	/*int kcount=getMultiMax();*/
	int kindex=lowestkanji;

	ClearAllMulti();
	for(kindex=lowestkanji; kindex<=highestkanji;kindex++){
		if(InUsefile(kindex)){
			AddMultiTranslation(translations[kindex]);

			/*
			 * let the multi-window complain about
			 * truncation, if appropriate
			if(--kcount <=0){
				return;
			}
			*/
		}
	}

	ShowMulti();
}

/* dokanjifind()
 *	find match to "Four Corner" encoding in kanjidic translations
 */

void dokanjifind(int target)
{
	TRANSLATION firstmatch = NULL;
	TRANSLATION searchtarget = NULL;
	int searchndx=lowestkanji;

	setstatus("Searching...");

	ClearAllMulti();

	for(searchndx=lowestkanji; searchndx <=highestkanji; searchndx++){
		searchtarget=translations[searchndx];
		if(searchtarget==NULL) continue;

		if(searchtarget->Qindex == target){
			if(match_onlyactive){
				if(!UseThisKanji(searchndx)) {
					continue;
				}
			}

			AddMultiTranslation(searchtarget);
			if(firstmatch==NULL)
				firstmatch=searchtarget;
		}

	}

	if(firstmatch!=NULL){
		printsearch(firstmatch);
		setstatus("Search complete");
		if(getMultiCount() >1){
			ShowMulti();
		}
	} else{
		setstatus("No match found");
		Beep();
	}

	return;
}

/* doskipfind()
 *	find match to "SKIP" encoding in kanjidic translations
 *	Indentical to dokanjifind, except look at Qindex instead of Sindex
 */

void doskipfind(int target)
{
	TRANSLATION firstmatch = NULL;
	TRANSLATION searchtarget = NULL;
	int searchndx=lowestkanji;

	setstatus("Searching...");

	ClearAllMulti();

	for(searchndx=lowestkanji; searchndx <=highestkanji; searchndx++){
		searchtarget=translations[searchndx];
		if(searchtarget==NULL) continue;

		if(searchtarget->Sindex == target){
			if(match_onlyactive){
				if(!UseThisKanji(searchndx)) {
					continue;
				}
			}

			AddMultiTranslation(searchtarget);
			if(firstmatch==NULL)
				firstmatch=searchtarget;
		}

	}

	if(firstmatch!=NULL){
		setstatus("Search complete");
		printsearch(firstmatch);
		if(getMultiCount() >1){
			ShowMulti();
		}
	} else{
		setstatus("No match found");
		Beep();
	}

	return;
}


/* process_kinput
 *	Accepts a single 2-byte char as input.
 *	We assume this is hiragana, katakana, or special-directive char.
 *
 *	Adjusts the SEARCH_KANA_W widget labelstring appropriately
 *	(allowing backspacing)
 *	Also handles the mirrored labelwidget on the popup window itself
 *
 *	We call the convert routine "romajitokana" on our internal
 *	string, to handle romaji-to-kana stuffs.
 *	Note that we get called by both the point-n-click-kana window,
 *	AND by the kepress-event handler for the window.
 */
void process_kinput(XChar2b in_char)
{
	/* 'kanastring' is a GLOBAL BUFFER!! */
	XChar2b *kparse = kanastring;
	int kanalength;

	for(kanalength=0; kparse->byte1 != 0; kanalength++){
		kparse++;
	}

	/********************************************/
	/* Handle special embedded directives first */
	/********************************************/
	/* backspace */
	if((in_char.byte1 == 0x22) && (in_char.byte2 == 0x2b) ) {
		if(kanalength==0)
			return;
		kanalength--;
		kanastring[kanalength].byte1 = 0;
		kanastring[kanalength].byte2 = 0;

		XtVaSetValues(searchwidgets[SEARCH_KANA_W],
		      XtNlabel, kanastring, NULL);
		XtVaSetValues(romajiinput,
		      XtNlabel, kanastring, NULL);

		return;
	
	}
	/* 'paragraph' means "do search now" */
	if((in_char.byte1 == paragraphglyph[0].byte1) &&
	   (in_char.byte2 == paragraphglyph[0].byte2))
	{
		if(kanalength == 0)
			return;
		/* accept.. search! */
		dokanafind(kanastring);
		return;
	}

	/* Done with special directives. Anything else is meant
	 * to be displayed
	 */

	if(kanalength<MAXKANALENGTH-1) {
		kanastring[kanalength].byte1 = in_char.byte1;
		kanastring[kanalength].byte2 = in_char.byte2;

		kanalength++;
		kanastring[kanalength].byte1 = 0;
		kanastring[kanalength].byte1 = 0;
	}

	/* See if we have enough romaji to convert to kana, before display */
	romajitokana(kanastring);

	XtVaSetValues(searchwidgets[SEARCH_KANA_W],
		      XtNlabel, kanastring, NULL);
	XtVaSetValues(romajiinput,
		      XtNlabel, kanastring, NULL);
	
}


void debugkprint(XChar2b* kstr){
	XChar2b *ptr=kstr;
	while(ptr->byte1 != 0){
		printf("%x%x",ptr[0].byte1,ptr[0].byte2);
		ptr++;
	}
	printf("\n");
}

/* Take the "current search" string, and split it up into separate
 * kanji, if it is longer than 1 kanji
 */
void split_kanji_search()
{
	XChar2b *kanjistring;
	if(lastsearch==NULL){
		return;
	}
	kanjistring=lastsearch->kanji;
	if(kanjistring[1].byte1==0){
		return;
	}
	/* Okay, we now have non-null string, of at least 2 chars in length*/
	ClearAllMulti();
	while(kanjistring->byte1!=0){
		/* kanji start at 0x3021 */
		if(kanjistring->byte1>=0x30){
			int knum=(kanjistring->byte1 <<8) | kanjistring->byte2;
			TRANSLATION tptr;
			if(knum >highestkanji){
#ifdef DEBUG
				puts("ERR: cant find kanji 0x%d\n",knum);
#endif
				continue; /* error */
			}
			tptr=translations[knum];
			AddMultiTranslation(translations[knum]);
		}
		kanjistring++;
	}

	ShowMulti();
}


/****************************************************************\
 * Find matches for a kanji 'string'                            *
 *   (used for cut-n-paste, and "match kanji" button)           *
 * If match found, will take care of calling ShowMulti()	*
\****************************************************************/
void findkanjiall(XChar2b *Schars)
{
	int foundone=0;
	TRANSLATION searchparse=NULL;
	int searchndx=0;
	int min_ndx=lowestkanji,max_ndx=highestkanji;

	if(Schars==NULL){
		puts("Paranoid coding is A Good Thing: findkanjiall passed NULL");
		return;
	}
	if(Schars->byte1==0){
		puts("Paranoid coding is A Good Thing: findkanjiall passed zerolen string");
		return;
	}

	/* if match_active on, and high levels not enabled, dont
	 * bother searching through edict lines
	 */
	if(match_onlyactive &&  ((gradelevelflags & ABOVESIXGRADE)==0)) {
		max_ndx=MAXKANJIALLOWED;
	}

	if(Schars[1].byte1!=0){
		/* We have multi-kanji string.
		 * It is now impossible to match single-kanji range,
		 * so start at edict range
		 */
		min_ndx=MAXKANJIALLOWED;
	}

	for(searchndx=min_ndx; searchndx <=max_ndx; searchndx++){
		searchparse=translations[searchndx];
		if(searchparse==NULL) continue;

		if(match_onlyactive){
			if(!UseThisKanji(searchndx)) {
				continue;
			}
		}
		
		if(matchkanji(searchparse->kanji,Schars)){
			if(foundone==0) {
				ClearAllMulti();
				foundone=1;
				printsearch(searchparse);
			}
			AddMultiTranslation(searchparse);
		}
		searchparse=searchparse->nextk;
	}

	if(foundone>0) {
		setstatus("Displaying search result");
		/* Search window already updated. So only show "multi"
		 * window, if there are actual multiple matches
		 */
		if(getMultiCount() >1){
			ShowMulti();
		}
	} else {
		setstatus("no match found");
	}
	
}