File: indian.c

package info (click to toggle)
mlterm 3.1.2-1.3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 23,168 kB
  • sloc: ansic: 102,795; sh: 9,676; java: 2,018; perl: 1,601; makefile: 1,595; cpp: 771; sed: 16
file content (50 lines) | stat: -rw-r--r-- 976 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
#include "indian.h"
#include <ctype.h>	/* isprint */

char *binsearch(struct tabl *table, int sz, char *word) {
	int result, index, lindex, hindex;

	if (isprint(word[0])) return word;

	lindex = 0 ;
	hindex = sz ;

	while( 1)
	{
		index = (lindex + hindex) / 2;	

		result = strcmp(table[index].iscii,word);

		if (result == 0) return table[index].font;
		if (result > 0) hindex = index;
		if (result < 0) lindex = index + 1;

		if (lindex >= hindex) return NULL;
	}
}

char *illdefault(struct tabl *table, char *wrd, int sz) {
	
	int i;
	char *ostr;
	char iwrd[2];
	char *p;
	
	ostr = (char *) malloc(1000 * sizeof(char));
	bzero(ostr,1000);
		
	for(i = 0; i < strlen(wrd); i++) {
		iwrd[0]=wrd[i];
		iwrd[1]='\0';
		if((p=binsearch(table, sz, iwrd)))
			strcat(ostr,p);
	}

	return ostr;
}

int iscii2font(struct tabl *table, char *input, char *output, int sz) {
	bzero(output,strlen(output));
	strcat(output , (char *) split(table, input, sz));
	return strlen(output); 
}