Rev 10 | Rev 7676 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 10 | Rev 3718 | ||
---|---|---|---|
Line 23... | Line 23... | ||
23 | #define buflim 1024*1024*16 |
23 | #define buflim 1024*1024*16 |
24 | 24 | ||
25 | /***************** Nothing should need change hereafter *****************/ |
25 | /***************** Nothing should need change hereafter *****************/ |
26 | 26 | ||
27 | #include "../wims.h" |
27 | #include "../wims.h" |
- | 28 | #include "../Lib/basicstr.c" |
|
28 | #include "../hmname.c" |
29 | #include "../hmname.c" |
29 | 30 | ||
30 | char fn1[1024]="", fn2[1024]=""; |
31 | char fn1[1024]="", fn2[1024]=""; |
31 | char mathbuf[MAX_LINELEN+1]; |
32 | char mathbuf[MAX_LINELEN+1]; |
32 | char *filebuf; |
33 | char *filebuf; |
Line 118... | Line 119... | ||
118 | vsnprintf(buf,sizeof(buf),good,vp); va_end(vp); |
119 | vsnprintf(buf,sizeof(buf),good,vp); va_end(vp); |
119 | if(strlen(start)-(bad_end-bad_beg)+strlen(buf)>=MAX_LINELEN) { |
120 | if(strlen(start)-(bad_end-bad_beg)+strlen(buf)>=MAX_LINELEN) { |
120 | return; |
121 | return; |
121 | } |
122 | } |
122 | strcat(buf,bad_end); |
123 | strcat(buf,bad_end); |
123 |
|
124 | ovlstrcpy(bad_beg,buf); |
124 | } |
125 | } |
125 | 126 | ||
126 | void cutamp(char *p) |
127 | void cutamp(char *p) |
127 | { |
128 | { |
128 | char *pp; |
129 | char *pp; |
129 | for(pp=strchr(p,'&'); pp; pp=strchr(pp+1,'&')) { |
130 | for(pp=strchr(p,'&'); pp; pp=strchr(pp+1,'&')) { |
130 | if(strncmp(pp,"&",5)==0) { |
131 | if(strncmp(pp,"&",5)==0) { |
131 |
|
132 | ovlstrcpy(pp+1,pp+5); continue; |
132 | } |
133 | } |
133 | if(strncmp(pp,"<",4)==0) { |
134 | if(strncmp(pp,"<",4)==0) { |
134 | *pp='<'; |
135 | *pp='<'; ovlstrcpy(pp+1,pp+4); continue; |
135 | } |
136 | } |
136 | if(strncmp(pp,">",4)==0) { |
137 | if(strncmp(pp,">",4)==0) { |
137 | *pp='>'; |
138 | *pp='>'; ovlstrcpy(pp+1,pp+4); continue; |
138 | } |
139 | } |
139 | 140 | ||
140 | } |
141 | } |
141 | } |
142 | } |
142 | 143 | ||
Line 175... | Line 176... | ||
175 | if(*pt!='$') return; do pt++; while(*pt=='$'); |
176 | if(*pt!='$') return; do pt++; while(*pt=='$'); |
176 | pv=strchr(pt,'$'); if(pv==NULL) return; |
177 | pv=strchr(pt,'$'); if(pv==NULL) return; |
177 | insmath: if(pv-pt>=MAX_LINELEN-256) return; |
178 | insmath: if(pv-pt>=MAX_LINELEN-256) return; |
178 | memmove(mathbuf,pt,pv-pt); mathbuf[pv-pt]=0; |
179 | memmove(mathbuf,pt,pv-pt); mathbuf[pv-pt]=0; |
179 | if(strstr(mathbuf,"...\n...")!=NULL) { |
180 | if(strstr(mathbuf,"...\n...")!=NULL) { |
180 |
|
181 | ovlstrcpy(mathbuf,"......"); return; |
181 | } |
182 | } |
182 | cutamp(mathbuf); latex2html=1; |
183 | cutamp(mathbuf); latex2html=1; |
183 | for(p1=strstr(mathbuf,"\\mathbb");p1;p1=strstr(p1+1,"\\mathbb")) { |
184 | for(p1=strstr(mathbuf,"\\mathbb");p1;p1=strstr(p1+1,"\\mathbb")) { |
184 | char c,*d; |
185 | char c,*d; |
185 | p2=find_word_start(p1+strlen("\\mathbb")); c=0; |
186 | p2=find_word_start(p1+strlen("\\mathbb")); c=0; |
Line 197... | Line 198... | ||
197 | if(p1>mathbuf && isalpha(*(p1-1))) continue; |
198 | if(p1>mathbuf && isalpha(*(p1-1))) continue; |
198 | for(p2=p1+2; p2<p1+24 && isalpha(*p2); p2++); |
199 | for(p2=p1+2; p2<p1+24 && isalpha(*p2); p2++); |
199 | if(*p2!='}' || isalnum(*(p2+1))) continue; |
200 | if(*p2!='}' || isalnum(*(p2+1))) continue; |
200 | memmove(buf,p1+1,p2-p1-1); buf[p2-p1-1]='\\'; buf[p2-p1]=0; |
201 | memmove(buf,p1+1,p2-p1-1); buf[p2-p1-1]='\\'; buf[p2-p1]=0; |
201 | if(strstr(hmsame,buf)==NULL) continue; |
202 | if(strstr(hmsame,buf)==NULL) continue; |
202 |
|
203 | ovlstrcpy(p2,p2+1); ovlstrcpy(p1,p1+1); |
203 | } |
204 | } |
204 | if(strstr(mathbuf,"\\begin{")!=NULL) return; |
205 | if(strstr(mathbuf,"\\begin{")!=NULL) return; |
205 | for(p1=strchr(mathbuf,'{'); p1; p1=strchr(p1+1,'{')) { |
206 | for(p1=strchr(mathbuf,'{'); p1; p1=strchr(p1+1,'{')) { |
206 | if((p1>mathbuf && isalpha(*(p1-1))) || |
207 | if((p1>mathbuf && isalpha(*(p1-1))) || |
207 | !isalnum(*(p1+1)) || *(p1+2)!='}') continue; |
208 | !isalnum(*(p1+1)) || *(p1+2)!='}') continue; |
208 | *p1=*(p1+1); |
209 | *p1=*(p1+1); ovlstrcpy(p1+1,p1+3); |
209 | } |
210 | } |
210 | if(strchr(mathbuf,'[')!=NULL) { |
211 | if(strchr(mathbuf,'[')!=NULL) { |
211 | char mbuf[MAX_LINELEN+1]; |
212 | char mbuf[MAX_LINELEN+1]; |
212 | snprintf(mbuf,sizeof(mbuf),"{%s}",mathbuf); |
213 | snprintf(mbuf,sizeof(mbuf),"{%s}",mathbuf); |
213 |
|
214 | ovlstrcpy(mathbuf,mbuf); |
214 | } |
215 | } |
215 | /* try to simplify */ |
216 | /* try to simplify */ |
216 | if(strchr(mathbuf,'{')==NULL && strchr(mathbuf,'\\')!=NULL) { |
217 | if(strchr(mathbuf,'{')==NULL && strchr(mathbuf,'\\')!=NULL) { |
217 | int i, tt; |
218 | int i, tt; |
218 | tt=0; |
219 | tt=0; |
Line 300... | Line 301... | ||
300 | if(p==NULL || *p==0) return 1; |
301 | if(p==NULL || *p==0) return 1; |
301 | p=find_word_start(p); pp=find_word_end(p); |
302 | p=find_word_start(p); pp=find_word_end(p); |
302 | if(pp<=p || pp-p>sizeof(fn1)-1) return 1; |
303 | if(pp<=p || pp-p>sizeof(fn1)-1) return 1; |
303 | memmove(fn1,p,pp-p); fn1[pp-p]=0; |
304 | memmove(fn1,p,pp-p); fn1[pp-p]=0; |
304 | p=find_word_start(pp); pp=find_word_end(p); |
305 | p=find_word_start(pp); pp=find_word_end(p); |
305 | if(pp<=p || pp-p>sizeof(fn2)-1) |
306 | if(pp<=p || pp-p>sizeof(fn2)-1) ovlstrcpy(fn2,fn1); |
306 | else {memmove(fn2,p,pp-p); fn2[pp-p]=0;} |
307 | else {memmove(fn2,p,pp-p); fn2[pp-p]=0;} |
307 | prepare_file(); |
308 | prepare_file(); |
308 | output(); |
309 | output(); |
309 | fclose(outf); |
310 | fclose(outf); |
310 | return 0; |
311 | return 0; |