Rev 3718 | Rev 8161 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3718 | Rev 3808 | ||
---|---|---|---|
Line 40... | Line 40... | ||
40 | }; |
40 | }; |
41 | 41 | ||
42 | int compare(struct entry *e, const char *s2) |
42 | int compare(struct entry *e, const char *s2) |
43 | { |
43 | { |
44 | int k; |
44 | int k; |
45 | k=strncmp(e |
45 | k=strncmp((char*)e->original, (char*)s2, e->olen); |
46 | if(k==0 && isalnum(*(s2+e->olen))) return -1; |
46 | if(k==0 && isalnum(*(s2+e->olen))) return -1; |
47 | else return k; |
47 | else return k; |
48 | } |
48 | } |
49 | 49 | ||
50 | /* searches a list. Returns index if found, -1 if nomatch. |
50 | /* searches a list. Returns index if found, -1 if nomatch. |
Line 111... | Line 111... | ||
111 | p1=find_word_start(p1); pp=find_word_start(pp); |
111 | p1=find_word_start(p1); pp=find_word_start(pp); |
112 | if(*p1==0) continue; |
112 | if(*p1==0) continue; |
113 | if(i>entrycount && compare(entry+i-1,p1)>0) |
113 | if(i>entrycount && compare(entry+i-1,p1)>0) |
114 | error("unsorted_dictionary %s: %s > %s.\n", |
114 | error("unsorted_dictionary %s: %s > %s.\n", |
115 | fname,entry[i-1].original,p1); |
115 | fname,entry[i-1].original,p1); |
116 | if(i>entrycount && strcmp(entry[i-1].original,p1)==0) |
116 | if(i>entrycount && strcmp((char*)entry[i-1].original,p1)==0) |
117 | error("duplication_in_dictionary %s: %s.\n", |
117 | error("duplication_in_dictionary %s: %s.\n", |
118 | fname,p1); |
118 | fname,p1); |
119 | entry[i].original= |
119 | entry[i].original=(unsigned char*)p1; |
- | 120 | entry[i].replace=(unsigned char*)pp; |
|
120 | entry[i].olen=l=strlen(p1); entry[i].earlier=-1; |
121 | entry[i].olen=l=strlen(p1); entry[i].earlier=-1; |
121 | if(i>0) { |
122 | if(i>0) { |
122 | int l1,l2; |
123 | int l1,l2; |
123 | l1=entry[i-1].earlier; if(l1>=0) l2=entry[l1].olen; |
124 | l1=entry[i-1].earlier; if(l1>=0) l2=entry[l1].olen; |
124 | else {l2=entry[i-1].olen;l1=i-1;} |
125 | else {l2=entry[i-1].olen;l1=i-1;} |
125 | if(l>l2 && isspace(p1[l2]) |
126 | if(l>l2 && isspace(p1[l2]) |
126 | && strncmp(entry[l1].original,p1,l2)==0) |
127 | && strncmp((char*)entry[l1].original,p1,l2)==0) |
127 | entry[i].earlier=entry[i-1].earlier=l1; |
128 | entry[i].earlier=entry[i-1].earlier=l1; |
128 | } |
129 | } |
129 | i++; |
130 | i++; |
130 | } |
131 | } |
131 | thisdic->len=i-entrycount; |
132 | thisdic->len=i-entrycount; |
132 | pp=strrchr( |
133 | pp=strrchr(fname,'/'); if(pp==NULL) pp=fname; |
133 | snprintf(tbuf,sizeof(tbuf),"unknown_%s",pp); |
134 | snprintf(tbuf,sizeof(tbuf),"unknown_%s",pp); |
134 | _getdef(defbuf,tbuf,buf); |
135 | _getdef(defbuf,tbuf,buf); |
135 | p1=find_word_start(buf); *find_word_end(p1)=0; |
136 | p1=find_word_start(buf); *find_word_end(p1)=0; |
136 | for(pp=p1; *pp; pp++) *pp=tolower(*pp); |
137 | for(pp=p1; *pp; pp++) *pp=tolower(*pp); |
137 | thisdic->unknown_type=unk_delete; |
138 | thisdic->unknown_type=unk_delete; |
Line 176... | Line 177... | ||
176 | } |
177 | } |
177 | } |
178 | } |
178 | continue; |
179 | continue; |
179 | } |
180 | } |
180 | t+=dic[i].start; |
181 | t+=dic[i].start; |
181 | string_modify(troutbuf,p1,p1+strlen(entry[t].original), |
182 | string_modify(troutbuf,p1,p1+strlen((char*)entry[t].original), |
182 | entry[t].replace); |
183 | (char*)entry[t].replace); |
183 | p2=find_word_start(p1+strlen(entry[t].replace)); |
184 | p2=find_word_start(p1+strlen((char*)entry[t].replace)); |
184 | } |
185 | } |
185 | snprintf(p,MAX_LINELEN,"%s",troutbuf); |
186 | snprintf(p,MAX_LINELEN,"%s",troutbuf); |
186 | } |
187 | } |
187 | 188 | ||
188 | /* make translation using file name */ |
189 | /* make translation using file name */ |