Rev 10 | Rev 3718 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 10 | Rev 3247 | ||
---|---|---|---|
Line 87... | Line 87... | ||
87 | } |
87 | } |
88 | 88 | ||
89 | int compare(int i1, const char *s2) |
89 | int compare(int i1, const char *s2) |
90 | { |
90 | { |
91 | int k; |
91 | int k; |
92 | if(nocase) k=strncasecmp(entry[i1].original,s2,entry[i1].olen); |
92 | if(nocase) k=strncasecmp((char*)entry[i1].original,s2,entry[i1].olen); |
93 | else k=strncmp(entry[i1].original,s2,entry[i1].olen); |
93 | else k=strncmp((char*)entry[i1].original,s2,entry[i1].olen); |
94 | if(k==0 && (isalnum(*(s2+entry[i1].olen)) || (*(s2+entry[i1].olen)&128)!=0)) return -1; |
94 | if(k==0 && (isalnum(*(s2+entry[i1].olen)) || (*(s2+entry[i1].olen)&128)!=0)) return -1; |
95 | else return k; |
95 | else return k; |
96 | } |
96 | } |
97 | 97 | ||
98 | /* searches a list. Returns index if found, -1 if nomatch. |
98 | /* searches a list. Returns index if found, -1 if nomatch. |
Line 209... | Line 209... | ||
209 | if(has_digits==0) { |
209 | if(has_digits==0) { |
210 | char *p; |
210 | char *p; |
211 | for(p=p1;*p!=0 && p<pp && !isdigit(*p);p++); |
211 | for(p=p1;*p!=0 && p<pp && !isdigit(*p);p++); |
212 | if(isdigit(*p)) has_digits=1; |
212 | if(isdigit(*p)) has_digits=1; |
213 | } |
213 | } |
214 | entry[i].original= |
214 | entry[i].original=(unsigned char*)p1; |
- | 215 | entry[i].replace=(unsigned char*)pp; |
|
215 | entry[i].olen=l=strlen(p1); entry[i].earlier=-1; |
216 | entry[i].olen=l=strlen(p1); entry[i].earlier=-1; |
216 | if(i>0) { |
217 | if(i>0) { |
217 | int l1,l2; |
218 | int l1,l2; |
218 | l1=entry[i-1].earlier; if(l1>=0) l2=entry[l1].olen; |
219 | l1=entry[i-1].earlier; if(l1>=0) l2=entry[l1].olen; |
219 | else {l2=entry[i-1].olen;l1=i-1;} |
220 | else {l2=entry[i-1].olen;l1=i-1;} |
220 | if(l>l2 && isspace(p1[l2]) |
221 | if(l>l2 && isspace(p1[l2]) |
221 | && strncmp(entry[l1].original,p1,l2)==0) |
222 | && strncmp((char*)entry[l1].original,p1,l2)==0) |
222 | entry[i].earlier=entry[i-1].earlier=l1; |
223 | entry[i].earlier=entry[i-1].earlier=l1; |
223 | } |
224 | } |
224 | i++; |
225 | i++; |
225 | } |
226 | } |
226 | entrycount=i; if(entrycount<=0) escape(); |
227 | entrycount=i; if(entrycount<=0) escape(); |
Line 257... | Line 258... | ||
257 | p2=find_word_start(p1+strlen(unkbuf)); |
258 | p2=find_word_start(p1+strlen(unkbuf)); |
258 | } |
259 | } |
259 | } |
260 | } |
260 | continue; |
261 | continue; |
261 | } |
262 | } |
262 | string_modify(outbuf,p1,p1+strlen(entry[t].original), |
263 | string_modify(outbuf,p1,p1+strlen((char*)entry[t].original), |
263 | entry[t].replace); |
264 | (char*)entry[t].replace); |
264 | p2=find_word_start(p1+strlen(entry[t].replace)); |
265 | p2=find_word_start(p1+strlen((char*)entry[t].replace)); |
265 | } |
266 | } |
266 | outbuf[MAX_LINELEN]=0; printf("%s",outbuf); |
267 | outbuf[MAX_LINELEN]=0; printf("%s",outbuf); |
267 | } |
268 | } |
268 | 269 | ||
269 | void switches(void) |
270 | void switches(void) |