Subversion Repositories wimsdev

Rev

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

Rev 9378 Rev 11125
Line 401... Line 401...
401
{
401
{
402
    char *rep;
402
    char *rep;
403
    int i;
403
    int i;
404
    rep=wordchr(p,"repeat"); if(rep==NULL) return 1;
404
    rep=wordchr(p,"repeat"); if(rep==NULL) return 1;
405
    *rep=0; rep+=strlen("repeat"); i=evalue(rep);
405
    *rep=0; rep+=strlen("repeat"); i=evalue(rep);
-
 
406
    if(i<1) i=1;
406
    if(i<1) i=1; if(i>MAX_VALUE_LIST) i=MAX_VALUE_LIST;
407
    if(i>MAX_VALUE_LIST) i=MAX_VALUE_LIST;
407
    return i;
408
    return i;
408
}
409
}
409
 
410
 
410
/* integer random */
411
/* integer random */
411
void calc_randint(char *p)
412
void calc_randint(char *p)
Line 637... Line 638...
637
    if(*pp==0) pp=strparstr(p,"..");
638
    if(*pp==0) pp=strparstr(p,"..");
638
    if(*pp!=0) {
639
    if(*pp!=0) {
639
     int t=len_fn(buf);
640
     int t=len_fn(buf);
640
     *pp=0; pe=find_word_start(pp+2);
641
     *pp=0; pe=find_word_start(pp+2);
641
     i=evalue(p); j=evalue(pe); pnext=buf;
642
     i=evalue(p); j=evalue(pe); pnext=buf;
642
     if(i<0) i=t+i+1; if(i<1) i=1;
643
     if(i<0) i=t+i+1;
-
 
644
     if(i<1) i=1;
643
     if(j<0) j=t+j+1; if(j>t) j=t;
645
     if(j<0) j=t+j+1;
-
 
646
     if(j>t) j=t;
644
     for(; i<=j; i++) {
647
     for(; i<=j; i++) {
645
         if(started==0 || fnd_fn==datafile_fnd_record)
648
         if(started==0 || fnd_fn==datafile_fnd_record)
646
           pp=_blockof_one(buf,t,fnd_fn,i,bbuf);
649
           pp=_blockof_one(buf,t,fnd_fn,i,bbuf);
647
         else
650
         else
648
           pp=_blockof_one(pnext,1,fnd_fn,1,bbuf);
651
           pp=_blockof_one(pnext,1,fnd_fn,1,bbuf);
Line 1125... Line 1128...
1125
    }
1128
    }
1126
    b=getvar("ins_border");
1129
    b=getvar("ins_border");
1127
    at=getvar("ins_attr");
1130
    at=getvar("ins_attr");
1128
    al=getvar("ins_align");
1131
    al=getvar("ins_align");
1129
    if(at==NULL) at="";
1132
    if(at==NULL) at="";
-
 
1133
    if(al==NULL) al="";
1130
    if(al==NULL) al="";al=find_word_start(al);
1134
    al=find_word_start(al);
1131
    if(*al!=0) snprintf(buf2,sizeof(buf2),"vertical-align:%s",al); else buf2[0]=0;
1135
    if(*al!=0) snprintf(buf2,sizeof(buf2),"vertical-align:%s",al); else buf2[0]=0;
1132
    if(b==NULL || *b==0) border=0;
1136
    if(b==NULL || *b==0) border=0;
1133
    else border=atoi(b);
1137
    else border=atoi(b);
-
 
1138
    if(border<0) border=0;
1134
    if(border<0) border=0; if(border>100) border=100;
1139
    if(border>100) border=100;
1135
    if(instex_ready(p2,urlbuf)) goto prt;
1140
    if(instex_ready(p2,urlbuf)) goto prt;
1136
    if(stat(nbuf,&st)!=0 || st.st_mtime<stc.st_mtime || st.st_size<45) {
1141
    if(stat(nbuf,&st)!=0 || st.st_mtime<stc.st_mtime || st.st_size<45) {
1137
     setenv("texgif_style",instex_style,1);
1142
     setenv("texgif_style",instex_style,1);
1138
     setenv("texgif_src",p2,1);
1143
     setenv("texgif_src",p2,1);
1139
     setenv("texgif_outfile",nbuf,1);
1144
     setenv("texgif_outfile",nbuf,1);
Line 1573... Line 1578...
1573
         if(!isfinite(d3)) goto next;
1578
         if(!isfinite(d3)) goto next;
1574
         if((d1>0 && d3>0) || (d1<0 && d3<0)) {d1=d3; v1=v3;}
1579
         if((d1>0 && d3>0) || (d1<0 && d3<0)) {d1=d3; v1=v3;}
1575
         else {v2=v3;}
1580
         else {v2=v3;}
1576
     }
1581
     }
1577
     float2str(v3,vbuf); if(pp-p+strlen(vbuf)<MAX_LINELEN-1) {
1582
     float2str(v3,vbuf); if(pp-p+strlen(vbuf)<MAX_LINELEN-1) {
1578
         if(pp>p) *pp++=','; ovlstrcpy(pp,vbuf);
1583
         if(pp>p) *pp++=',';
-
 
1584
         ovlstrcpy(pp,vbuf);
1579
         pp+=strlen(pp);
1585
         pp+=strlen(pp);
1580
     }
1586
     }
1581
     else break;
1587
     else break;
1582
     next: ;
1588
     next: ;
1583
    }
1589
    }
Line 1596... Line 1602...
1596
    if(forp==NULL) { syntax: module_error("syntax_error"); *p=0; return; }
1602
    if(forp==NULL) { syntax: module_error("syntax_error"); *p=0; return; }
1597
    *forp=0; forp+=strlen("for"); forp=find_word_start(forp);
1603
    *forp=0; forp+=strlen("for"); forp=find_word_start(forp);
1598
    fp=find_word_start(p); strip_trailing_spaces(fp);
1604
    fp=find_word_start(p); strip_trailing_spaces(fp);
1599
    if(*fp==0) goto syntax;
1605
    if(*fp==0) goto syntax;
1600
    if(type<5) i=cutfor(forp,NULL); else i=cutfor(forp,tbuf);
1606
    if(type<5) i=cutfor(forp,NULL); else i=cutfor(forp,tbuf);
-
 
1607
    if(i<0) goto syntax;
1601
    if(i<0) goto syntax; if(i>0) {*p=0; return;}
1608
    if(i>0) {*p=0; return;}
1602
    start=forstruct.from; stop=forstruct.to; step=forstruct.step;
1609
    start=forstruct.from; stop=forstruct.to; step=forstruct.step;
1603
    forp=forstruct.var;
1610
    forp=forstruct.var;
1604
    mystrncpy(buf,fp,sizeof(buf)); substitute(buf);
1611
    mystrncpy(buf,fp,sizeof(buf)); substitute(buf);
1605
    for(fp=varchr(buf,forp); fp!=NULL; fp=varchr(fp,forp)) {
1612
    for(fp=varchr(buf,forp); fp!=NULL; fp=varchr(fp,forp)) {
1606
     string_modify(buf,fp,fp+strlen(forp),EV_X); fp+=strlen(EV_X);
1613
     string_modify(buf,fp,fp+strlen(forp),EV_X); fp+=strlen(EV_X);
Line 1649... Line 1656...
1649
         else ps=forstruct.pos[i];
1656
         else ps=forstruct.pos[i];
1650
         ovlstrcpy(buf2,buf); l=strlen(ps);ln=strlen(EV_X);
1657
         ovlstrcpy(buf2,buf); l=strlen(ps);ln=strlen(EV_X);
1651
         for(pt=varchr(buf2,EV_X);pt!=NULL;pt=varchr(pt+l,EV_X))
1658
         for(pt=varchr(buf2,EV_X);pt!=NULL;pt=varchr(pt+l,EV_X))
1652
           string_modify(buf2,pt,pt+ln,"%s",ps);
1659
           string_modify(buf2,pt,pt+ln,"%s",ps);
1653
         if(pp-p+strlen(buf2)>=MAX_LINELEN-1) return;
1660
         if(pp-p+strlen(buf2)>=MAX_LINELEN-1) return;
1654
         if(pp>p) *pp++=','; ovlstrcpy(pp,buf2);
1661
         if(pp>p) *pp++=',';
-
 
1662
         ovlstrcpy(pp,buf2);
1655
         pp+=strlen(pp);
1663
         pp+=strlen(pp);
1656
     }
1664
     }
1657
     return;
1665
     return;
1658
    }
1666
    }
1659
    for(i=0,v=start; i<MAX_VALUE_LIST && v*step<=stop*step; v+=step, i++) {
1667
    for(i=0,v=start; i<MAX_VALUE_LIST && v*step<=stop*step; v+=step, i++) {
Line 1664... Line 1672...
1664
         dd=checked_eval(f[k]);
1672
         dd=checked_eval(f[k]);
1665
         switch(type) {
1673
         switch(type) {
1666
          case 1: { /* values */
1674
          case 1: { /* values */
1667
              float2str(dd,vbuf);
1675
              float2str(dd,vbuf);
1668
              if(pp-p+strlen(vbuf)<MAX_LINELEN-1) {
1676
              if(pp-p+strlen(vbuf)<MAX_LINELEN-1) {
1669
               if(pp>p) *pp++=','; ovlstrcpy(pp,vbuf);
1677
               if(pp>p) *pp++=',';
-
 
1678
               ovlstrcpy(pp,vbuf);
1670
               pp+=strlen(pp);
1679
               pp+=strlen(pp);
1671
              }
1680
              }
1672
              v0=dd; break;
1681
              v0=dd; break;
1673
          }
1682
          }
1674
          case 2: { /* sum */
1683
          case 2: { /* sum */
Line 1760... Line 1769...
1760
     if(pp-p+strlen(buf)<MAX_LINELEN-1) {
1769
     if(pp-p+strlen(buf)<MAX_LINELEN-1) {
1761
         if(pp>p) *pp++=';'; ovlstrcpy(pp,buf); pp+=strlen(pp);
1770
         if(pp>p) *pp++=';'; ovlstrcpy(pp,buf); pp+=strlen(pp);
1762
     }
1771
     }
1763
     float2str(ld.ydata[i],buf);
1772
     float2str(ld.ydata[i],buf);
1764
     if(pp-p+strlen(buf)<MAX_LINELEN-1) {
1773
     if(pp-p+strlen(buf)<MAX_LINELEN-1) {
-
 
1774
         if(pp>p) *pp++=',';
1765
         if(pp>p) *pp++=','; ovlstrcpy(pp,buf); pp+=strlen(pp);
1775
         ovlstrcpy(pp,buf); pp+=strlen(pp);
1766
     }
1776
     }
1767
    }
1777
    }
1768
}
1778
}
1769
 
1779
 
1770
/* internal routine with no security check */
1780
/* internal routine with no security check */
Line 1998... Line 2008...
1998
 
2008
 
1999
    p1=find_word_start(p); p2=find_word_end(p1);
2009
    p1=find_word_start(p); p2=find_word_end(p1);
2000
    if(*p2==0) {*p=0; return;}
2010
    if(*p2==0) {*p=0; return;}
2001
    *p2++=0; p2=find_word_start(p2);
2011
    *p2++=0; p2=find_word_start(p2);
2002
    mystrncpy(buf,p2,sizeof(buf)); substit(buf);
2012
    mystrncpy(buf,p2,sizeof(buf)); substit(buf);
2003
    if(p1>p) ovlstrcpy(p,p1); substit(p);
2013
    if(p1>p) ovlstrcpy(p,p1);
-
 
2014
    substit(p);
2004
    if(strcmp(p,"randitem")==0) {_embraced(buf,calc_randitem); goto end;}
2015
    if(strcmp(p,"randitem")==0) {_embraced(buf,calc_randitem); goto end;}
2005
    if(strcmp(p,"extract")==0) {
2016
    if(strcmp(p,"extract")==0) {
2006
     p1=strchr(buf,'{'); if(p1!=NULL) {
2017
     p1=strchr(buf,'{'); if(p1!=NULL) {
2007
         p2=find_matching(++p1,'}');
2018
         p2=find_matching(++p1,'}');
2008
         if(p2!=NULL) {
2019
         if(p2!=NULL) {