Subversion Repositories wimsdev

Rev

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

Rev 8195 Rev 8367
Line 20... Line 20...
20
/* these are patches for rawmath.c */
20
/* these are patches for rawmath.c */
21
/*
21
/*
22
char *getvar(char *p) {return NULL;}
22
char *getvar(char *p) {return NULL;}
23
void setvar(char *p, char *v) {return;}
23
void setvar(char *p, char *v) {return;}
24
*/
24
*/
25
char *exec_if(char *p)
25
char *_exec_if(char *p, int type)
26
{
26
{
27
    char *p1, *p2, *p3, *p4, *p5, *p6, *pp;
27
    char *p1, *p2, *p3, *p4, *p5, *p6, *pp;
28
    char buf[MAX_LINELEN+1];
28
    char buf[MAX_LINELEN+1];
29
    p1=find_word_start(p); if(*p1!='{') return p;
29
    p1=find_word_start(p); if(*p1!='{') return p;
30
    p2=find_matching(p1+1,'}'); if(p2==NULL) return p;
30
    p2=find_matching(p1+1,'}'); if(p2==NULL) return p;
Line 32... Line 32...
32
    p4=find_matching(p3+1,'}'); if(p4==NULL) return p;
32
    p4=find_matching(p3+1,'}'); if(p4==NULL) return p;
33
    *p2=0; snprintf(buf,sizeof(buf),"%s",p1+1);
33
    *p2=0; snprintf(buf,sizeof(buf),"%s",p1+1);
34
    for(pp=strchr(buf,'\\'); pp!=NULL; pp=strchr(pp+1,'\\')) {
34
    for(pp=strchr(buf,'\\'); pp!=NULL; pp=strchr(pp+1,'\\')) {
35
      if(isalnum(*(pp+1))) string_modify(buf,pp,pp+1,"$m_");
35
      if(isalnum(*(pp+1))) string_modify(buf,pp,pp+1,"$m_");
36
    }
36
    }
-
 
37
    switch(type) {
-
 
38
          case 0: fprintf(outf,"\n!if %s \n$()",buf); break;
37
    fprintf(outf," \n!if %s \n$()",buf);
39
          case 1: fprintf(outf,"\n!ifval %s \n$()",buf);
-
 
40
    }
38
    p5=find_word_start(p4+1);
41
    p5=find_word_start(p4+1);
39
    if(*p5=='{' && (p6=find_matching(p5+1,'}'))!=NULL) {
42
    if(*p5=='{' && (p6=find_matching(p5+1,'}'))!=NULL) {
40
      *p4=elsechar; *p5=' '; *p6=endifchar;
43
      *p4=elsechar; *p5=' '; *p6=endifchar;
41
    }
44
    }
42
    else *p4=endifchar;
45
    else *p4=endifchar;
43
    return p3+1;
46
    return p3+1;
44
}
47
}
-
 
48
char *exec_if(char *p) {return _exec_if(p,0);}
-
 
49
char *exec_ifval(char *p) {return _exec_if(p,1);}
45
 
50
 
46
char *exec_for(char *p)
51
char *exec_for(char *p)
47
{
52
{
48
    char *p1, *p2, *p3, *p4, *pp;
53
    char *p1, *p2, *p3, *p4, *pp;
49
    char buf[MAX_LINELEN+1];
54
    char buf[MAX_LINELEN+1];
Line 117... Line 122...
117
/* if */
122
/* if */
118
          if(strncmp(p+1,"if",2)==0 && *find_word_start(p+3)=='{') {
123
          if(strncmp(p+1,"if",2)==0 && *find_word_start(p+3)=='{') {
119
            char *pt;
124
            char *pt;
120
            *p=0; fprintf(outf,"%s",ps); p++; ps=p;
125
            *p=0; fprintf(outf,"%s",ps); p++; ps=p;
121
            pt=exec_if(p+2); if(pt>p+2) {p=pt-1;ps=pt;}
126
            pt=exec_if(p+2); if(pt>p+2) {p=pt-1;ps=pt;}
-
 
127
            continue;
-
 
128
          }
-
 
129
/* ifval */
-
 
130
          if(strncmp(p+1,"ifval",5)==0 && *find_word_start(p+6)=='{') {
-
 
131
            char *pt;
-
 
132
            *p=0; fprintf(outf,"%s",ps); p++; ps=p;
-
 
133
            pt=exec_if(p+5); if(pt>p+5) {p=pt-1;ps=pt;}
122
            continue;
134
            continue;
123
          }
135
          }
124
/* canvasdraw */
136
/* canvasdraw */
125
          if(strncmp(p+1,"canvasdraw",10)==0 && *find_word_start(p+11)=='{') {
137
          if(strncmp(p+1,"canvasdraw",10)==0 && *find_word_start(p+11)=='{') {
126
            pe=pp2=pe2="";
138
            pe=pp2=pe2="";