Subversion Repositories wimsdev

Rev

Rev 8859 | Rev 8947 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8859 Rev 8882
Line 83... Line 83...
83
      }
83
      }
84
    }
84
    }
85
    fprintf(outf,"\n!insmath %s\n$()",bf);
85
    fprintf(outf,"\n!insmath %s\n$()",bf);
86
}
86
}
87
 
87
 
-
 
88
int _matchit3(char **p, char **ps, char *name, int type)
-
 
89
{
-
 
90
  char *pp = find_word_start(*p+strlen(name)+1);
-
 
91
  if(strncmp(*p+1,name,strlen(name))==0 && *pp=='{') {
-
 
92
    char *pp2, *pe2, *pt;
-
 
93
    char *pe=find_matching(pp+1,'}');
-
 
94
    if(pe) pp2=find_word_start(pe+1); else return 1;
-
 
95
    if(pp2) pe2=find_matching(pp2+1,'}'); else return 1;
-
 
96
    if(pe2 && *pp2=='{' && *pe2=='}') {
-
 
97
      pp++; pp2++; **p=*pe=*pe2=0;
-
 
98
      switch(type) {
-
 
99
     /* $val1 is $imagedir supprime s'il se trouve dans le code de draw */
-
 
100
          case 0: while((pt=strstr(pp2,"$val1/"))!=NULL) ovlstrcpy(pt,pt+strlen("$val1/")); break;
-
 
101
      }
-
 
102
      fprintf(outf,"%s \n\
-
 
103
!read oef/%s.phtml %s \\\n%s \n$()", *ps,name,pp,pp2);
-
 
104
     *ps=*p=pe2; (*ps)++; return 1;
-
 
105
     }
-
 
106
  }
-
 
107
  return 0;
-
 
108
}
-
 
109
 
-
 
110
/* deux accolades la deuxième non obligatoire */
-
 
111
int _matchit2(char **p, char **ps, char *name)
-
 
112
{
-
 
113
  char *pp = find_word_start(*p+strlen(name)+1);
-
 
114
  if(strncmp(*p+1,name,strlen(name))==0 && *pp=='{') {
-
 
115
    char *pp2, *pe2;
-
 
116
    char *pe=find_matching(pp+1,'}');
-
 
117
    if(pe) pp2=find_word_start(pe+1); else return 1;
-
 
118
    pe2=pe;
-
 
119
    if(*pp2=='{') {
-
 
120
      pe2=find_matching(++pp2,'}');
-
 
121
      if(pe2) *pe2=0;
-
 
122
    }
-
 
123
    else pp2="";
-
 
124
    if(*pp=='{' && *pe=='}') {
-
 
125
      pp++; **p=*pe=0;
-
 
126
      fprintf(outf,"%s \n\
-
 
127
!read oef/%s.phtml %s %s \n$()", *ps,name,pp,pp2);
-
 
128
      *ps=*p=pe2; (*ps)++; return 1;
-
 
129
    }
-
 
130
  }
-
 
131
  return 0;
-
 
132
}
-
 
133
/* une seule accolade  + compteur embedcnt ne fonctionne pas comme avant */
-
 
134
int _matchit1(char **p, char **ps, char *name)
-
 
135
{
-
 
136
  char *pp = find_word_start(*p+strlen(name)+1);
-
 
137
  if(strncmp(*p+1,name,strlen(name))==0 && *pp=='{') {
-
 
138
    char *pe=find_matching(pp+1,'}');
-
 
139
    if(pe && *pp=='{' && *pe=='}') {
-
 
140
         pp++; **p=*pe=0;
-
 
141
         fprintf(outf,"%s \n\
-
 
142
!read oef/%s.phtml %s \n$()", *ps,name,pp);
-
 
143
         *ps=*p=pe; (*ps)++; embedcnt++; return 1;
-
 
144
     }
-
 
145
  }
-
 
146
  return 0;
-
 
147
}
88
 
148
 
89
void out_exec(char *s1, char *s2)
149
void out_exec(char *s1, char *s2)
90
{
150
{
91
    char *ps, *p, *pp, *pe, *pp2, *pe2, *pt, c;
-
 
92
    char *p2, *p3;
151
    char *ps, *p, c, *p2, *p3;
93
    if(s2) fprintf(outf,"\n!exit\n\n:%s\n$()",s2);
152
    if(s2) fprintf(outf,"\n!exit\n\n:%s\n$()",s2);
94
    ps=s1;
153
    ps=s1;
95
    for(p=ps;*p;p++) {
154
    for(p=ps;*p;p++) {
96
      if(*p==nextchar) {
155
      if(*p==nextchar) {
97
          *p=0;
156
          *p=0;
98
          fprintf(outf,"%s \n!next\n$()",ps); ps=p+1; continue;
157
          fprintf(outf,"%s \n!next\n$()",ps); ps=p+1; continue;
99
      }
158
      }
100
      if(*p==elsechar) {
159
      if(*p==elsechar) {
101
          *p=0;
160
          *p=0;
102
          fprintf(outf,"%s \n!else\n$()",ps); ps=p+1; continue;
161
          fprintf(outf,"%s \n!else\n$()",ps); ps=p+1; continue;
Line 123... Line 182...
123
/* if */
182
/* if */
124
          if(strncmp(p+1,"if",strlen("if"))==0 && *find_word_start(p+strlen("if")+1)=='{') {
183
          if(strncmp(p+1,"if",strlen("if"))==0 && *find_word_start(p+strlen("if")+1)=='{') {
125
            char *pt;
184
            char *pt;
126
            *p=0; fprintf(outf,"%s",ps); p++; ps=p;
185
            *p=0; fprintf(outf,"%s",ps); p++; ps=p;
127
            pt=exec_if(p+2); if(pt>p+strlen("if")) {p=pt-1;ps=pt;}
186
            pt=exec_if(p+2); if(pt>p+strlen("if")) {p=pt-1;ps=pt;}
128
            continue;
187
            continue;
129
          }
188
          }
130
/* ifval */
189
/* ifval */
131
          if(strncmp(p+1,"ifval",strlen("ifval"))==0 && *find_word_start(p+strlen("ifval")+1)=='{') {
190
          if(strncmp(p+1,"ifval",strlen("ifval"))==0 && *find_word_start(p+strlen("ifval")+1)=='{') {
132
            char *pt;
191
            char *pt;
133
            *p=0; fprintf(outf,"%s",ps); p++; ps=p;
192
            *p=0; fprintf(outf,"%s",ps); p++; ps=p;
134
            pt=exec_if(p+strlen("ifval")); if(pt>p+strlen("ifval")) {p=pt-1;ps=pt;}
193
            pt=exec_if(p+strlen("ifval")); if(pt>p+strlen("ifval")) {p=pt-1;ps=pt;}
135
            continue;
194
            continue;
136
          }
195
          }
137
/* canvasdraw */
-
 
138
          if(strncmp(p+1,"canvasdraw",strlen("canvasdraw"))==0 && *find_word_start(p+strlen("canvasdraw")+1)=='{') {
-
 
139
            pe=pp2=pe2="";
-
 
140
            pp=find_word_start(p+strlen("canvasdraw")+1);
-
 
141
            if(*pp) pe=find_matching(pp+1,'}');
-
 
142
            if(pe) pp2=find_word_start(pe+1); else continue;
-
 
143
            if(pp2) pe2=find_matching(pp2+1,'}'); else continue;
196
          if (_matchit2(&p, &ps, "img")) continue;
144
            if(pe2 && *pp2=='{' && *pe2=='}') {
-
 
145
                pp++; pp2++; *p=*pe=*pe2=0;
-
 
146
                fprintf(outf,"%s \n\
-
 
147
!read oef/canvasdraw.phtml %s \\\n%s \n$()", ps,pp,pp2);
-
 
148
                ps=p=pe2; ps++; continue;
-
 
149
            }
-
 
150
          }
-
 
151
 
-
 
152
/* draw */
-
 
153
          if(strncmp(p+1,"draw",strlen("draw"))==0 && *find_word_start(p+strlen("draw")+1)=='{') {
-
 
154
            pe=pp2=pe2="";
-
 
155
            pp=find_word_start(p+strlen("draw")+1);
-
 
156
            if(*pp) pe=find_matching(pp+1,'}');
-
 
157
            if(pe) pp2=find_word_start(pe+1); else continue;
-
 
158
            if(pp2) pe2=find_matching(pp2+1,'}'); else continue;
197
          if (_matchit2(&p, &ps, "audio")) continue;
159
            if(pe2 && *pp2=='{' && *pe2=='}') {
-
 
160
                pp++; pp2++; *p=*pe=*pe2=0;
-
 
161
                while((pt=strstr(pp2,"$val1/"))!=NULL)
-
 
162
                  ovlstrcpy(pt,pt+strlen("$val1/"));
-
 
163
                fprintf(outf,"%s \n\
-
 
164
!read oef/draw.phtml %s \\\n%s \n$()", ps,pp,pp2);
-
 
165
                ps=p=pe2; ps++; continue;
-
 
166
            }
-
 
167
          }
-
 
168
/* img */
-
 
169
          if(strncmp(p+1,"img",strlen("img"))==0 && *find_word_start(p+strlen("img")+1)=='{') {
-
 
170
            pe=pp2=NULL;
-
 
171
            pp=find_word_start(p+strlen("img")+1);
-
 
172
            if(*pp=='{') pe=find_matching(pp+1,'}');
-
 
173
            if(pe) pp2=find_word_start(pe+1); else continue;
-
 
174
            pe2=pe;
-
 
175
            if(*pp2=='{') {
-
 
176
                pe2=find_matching(++pp2,'}');
-
 
177
                if(pe2) *pe2=0;
-
 
178
            }
-
 
179
            else pp2="";
-
 
180
            if(*pp=='{' && *pe=='}') {
-
 
181
                pp++; *p=*pe=0;
-
 
182
                fprintf(outf,"%s \n\
-
 
183
!read oef/img.phtml %s %s \n$()", ps,pp,pp2);
-
 
184
                ps=p=pe2; ps++; continue;
198
          if (_matchit1(&p, &ps, "embed")) continue;
185
            }
-
 
186
          }
-
 
187
/* audio */
-
 
188
          if(strncmp(p+1,"audio",strlen("audio"))==0 && *find_word_start(p+strlen("audio")+1)=='{') {
-
 
189
            pe=pp2=NULL;
-
 
190
            pp=find_word_start(p+strlen("audio")+1);
-
 
191
            if(*pp=='{') pe=find_matching(pp+1,'}');
-
 
192
            if(pe) pp2=find_word_start(pe+1); else continue;
-
 
193
            pe2=pe;
-
 
194
            if(*pp2=='{') {
-
 
195
                pe2=find_matching(++pp2,'}');
-
 
196
                if(pe2) *pe2=0;
-
 
197
            }
-
 
198
            else pp2="";
-
 
199
            if(*pp=='{' && *pe=='}') {
-
 
200
                pp++; *p=*pe=0;
-
 
201
                fprintf(outf,"%s \n\
-
 
202
!read oef/audio.phtml %s %s \n$()", ps,pp,pp2);
-
 
203
                ps=p=pe2; ps++; continue;
199
          if (_matchit1(&p, &ps, "special")) continue;
204
            }
-
 
205
          }
-
 
206
/* embed */
-
 
207
 
-
 
208
          if(strncmp(p+1,"embed",strlen("embed"))==0 && *find_word_start(p+strlen("embed")+1)=='{') {
-
 
209
            pe=pp2=pe2="";
-
 
210
            pp=find_word_start(p+strlen("embed")+1);
-
 
211
            if(*pp) pe=find_matching(pp+1,'}');
-
 
212
            if(pe && *pp=='{' && *pe=='}') {
-
 
213
                pp++; *p=*pe=0;
-
 
214
                fprintf(outf,"%s \n\
-
 
215
!read oef/embed.phtml %s \n$()", ps,pp);
-
 
216
                ps=p=pe; ps++; embedcnt++; continue;
200
          if (_matchit3(&p, &ps, "draw",1)) continue;
217
            }
-
 
218
          }
-
 
219
/* special */
-
 
220
          if(strncmp(p+1,"special",strlen("special"))==0 && *find_word_start(p+strlen("special")+1)=='{') {
-
 
221
            pe=pp2=pe2="";
-
 
222
            pp=find_word_start(p+strlen("special")+1);
-
 
223
            if(*pp) pe=find_matching(pp+1,'}');
-
 
224
            if(pe && *pp=='{' && *pe=='}') {
-
 
225
                pp++; *p=*pe=0;
-
 
226
                fprintf(outf,"%s \n\
-
 
227
!read oef/special.phtml %s \n$()", ps,pp);
-
 
228
                ps=p=pe; ps++; embedcnt++; continue;
201
          if (_matchit3(&p, &ps, "canvasdraw",0)) continue;
229
            }
-
 
230
          }
-
 
231
          *p++=0; fprintf(outf,"%s$m_",ps); ps=p; continue;
202
          *p++=0; fprintf(outf,"%s$m_",ps); ps=p; continue;
232
      }
203
      }
233
      if(c=='\\') {
204
      if(c=='\\') {
234
          ovlstrcpy(p,p+1); continue;
205
          ovlstrcpy(p,p+1); continue;
235
      }
206
      }