Back to index

wims  3.65+svn20090927
Defines | Functions | Variables
sp.c File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define specialfn_no   (sizeof(specialfn)/sizeof(specialfn[0]))

Functions

void sp_asis (char *p, int ptype)
void sp_evalue (char *p, int ptype)
void sp_solve (char *p, int ptype)
void sp_diff (char *p, int ptype)
void sp_det (char *p, int ptype)
void sp_int (char *p, int ptype)
void sp_htmlmath (char *p, int ptype)
void sp_texmath (char *p, int ptype)
void sp_maxima (char *p, int ptype)
void sp_yacas (char *p, int ptype)
void sp_pari (char *p, int ptype)
void sp_simplify (char *p, int ptype)
void sp_slib (char *p, int ptype)
void sp_draw (char *p, int ptype)
void sp_shuffle (char *p, int ptype)
void sp_positionof (char *p, int ptype)
void sp_random (char *p, int ptype)
void sp_pickone (char *p, int ptype)
void sp_item (char *p, int ptype)
void sp_items (char *p, int ptype)
void sp_randitem (char *p, int ptype)
void sp_column (char *p, int ptype)
void sp_row (char *p, int ptype)
void sp_rows (char *p, int ptype)
void sp_randrow (char *p, int ptype)
void sp_mathexp_cut (char *p, int ptype)
void sp_wims (char *p, int ptype)
void parmprep (char *p, int ptype)

Variables

char * setpre = ""
struct {
char * name
void(* processor )(char *p, int ptype)
specialfn []

Define Documentation

#define specialfn_no   (sizeof(specialfn)/sizeof(specialfn[0]))

Definition at line 318 of file sp.c.


Function Documentation

void parmprep ( char *  p,
int  ptype 
)

Definition at line 321 of file sp.c.

{
    char *pp, *p2, *pn, namebuf[32], buf[MAX_LINELEN+1];
    int i;

    while((pp=strchr(p,'\n'))!=NULL) *pp='       ';
    for(pp=p;*pp && pp-p<MAX_LINELEN;pp++) {
       /* function names */
       if(isalpha(*pp)) {
           for(i=0;i<30 && (isalnum(pp[i]) || pp[i]=='_');i++) namebuf[i]=pp[i];
           namebuf[i]=0; p2=find_word_start(pp+i);
           if((pp>p && isalnum(*(pp-1))) || *p2!='(') {
              /* if(*p2=='\\' && *(p2+1)=='(') strcpy(p2,p2+1); */
              pp=p2-1; continue;
           }
           pn=pp; pp=p2+1; p2=find_matching(pp,')');
           if(p2==NULL) {
              error("unmatched_parentheses");
              pp=p2; continue;
           }
           i=search_list(specialfn,specialfn_no,sizeof(specialfn[0]),namebuf);
           if(i<0) {
              pp--; continue;
           }
           *p2=0;
           snprintf(buf,sizeof(buf),"%s",pp);
           if(specialfn[i].processor!=sp_asis) parmprep(buf,ptype);
           specialfn[i].processor(buf,ptype);
           string_modify(p, pn, p2+1, "$(tmp%d)",prepcnt); prepcnt++;
           pp=pn+6;
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sp_asis ( char *  p,
int  ptype 
)

Definition at line 20 of file sp.c.

{
    fprintf(outf,"%stmp%d=!nosubst %s\n\n",setpre,prepcnt,p);
}

Here is the caller graph for this function:

void sp_column ( char *  p,
int  ptype 
)

Definition at line 209 of file sp.c.

{
    char *pp, *p2, buf[MAX_LINELEN+1];
    pp=strparchr(p,',');
    if(pp==NULL) pp=""; else *pp++=0;
    strncpy(buf,p,MAX_LINELEN);buf[MAX_LINELEN]=0;
    strip_enclosing_par(buf);
    if((p2=strstr(buf,".."))!=NULL) string_modify(buf,p2,p2+2," to ");
    fprintf(outf,"%stmp=!translate internal $    $ to ; in %s\n\n\
%stmp=!column %s of $tmp\n\
%stmp%d=!translate internal $\\\n$ to ; in $tmp\n",
           setpre,pp,setpre, buf, setpre, prepcnt);
}

Here is the call graph for this function:

void sp_det ( char *  p,
int  ptype 
)

Definition at line 70 of file sp.c.

{
    fprintf(outf,"%stmp=!translate $      $ to ; in %s\n\n\
%stmp%d=!exec pari matdet([$tmp])\n",
           setpre,p,setpre,prepcnt);
}
void sp_diff ( char *  p,
int  ptype 
)

Definition at line 61 of file sp.c.

{
    fprintf(outf,"%stmp=!translate ;\";': to $     $ in %s\n\n\
%stmp=!lower $tmp\n\
%stmp%d=!exec maxima diff($tmp);\n",
           setpre,p,setpre,setpre,prepcnt);
}
void sp_draw ( char *  p,
int  ptype 
)

Definition at line 138 of file sp.c.

{
    char *p2;
    p2=strchr(p,'    '); if(p2==NULL) p2=strchr(p,'\n');
    if(p2==NULL) return; *p2++=0;
    fprintf(outf,"!readproc %s/draw.phtml %s \\\n%s \n\
%stmp%d=$ins_url\n", primitive_dir, p, p2, setpre,prepcnt);
}
void sp_evalue ( char *  p,
int  ptype 
)

Definition at line 25 of file sp.c.

{
    char *p1, *p2, *pe;
    
    p1=strparchr(p,',');
    if(p1==NULL) {
       fprintf(outf,"%stmp%d=%s\n\n",setpre,prepcnt,p);
       return;
    }
    *p1++=0; fprintf(outf,"%sevaltmp=%s\n\n", setpre,p);
    for(; p1!=NULL; p1=p2){
       p1=find_word_start(p1);
       p2=strparchr(p1,',');
       if(p2!=NULL) *p2++=0;
       pe=strchr(p1,'=');
       if(pe==NULL) continue;
       *pe++=0; *find_word_end(p1)=0;
       if(*p1==0) continue;
       fprintf(outf,"%sevaltmp=!mathsubst %s=(%s) in $evaltmp\n",
              setpre,p1,pe);
    }
    fprintf(outf,"%stmp%d=($evaltmp)\n",setpre,prepcnt);
}

Here is the call graph for this function:

void sp_htmlmath ( char *  p,
int  ptype 
)

Definition at line 92 of file sp.c.

{
    fprintf(outf,"%stmp%d=!htmlmath %s\n\n",setpre,prepcnt,p);
}
void sp_int ( char *  p,
int  ptype 
)

Definition at line 79 of file sp.c.

{
    char *s;
 
    if((s=strchr(p,'='))!=NULL) *s=',';
    if((s=strstr(p,".."))!=NULL) {*s=','; *(s+1)=' ';}
    fprintf(outf,"%stmp=!translate ;\";': to $     $ in %s \n\
%stmp=!lower $tmp\n\
!readproc slib/function/integrate $tmp\n\
%stmp%d=$slib_out\n",
           setpre,p,setpre,setpre,prepcnt);
}
void sp_item ( char *  p,
int  ptype 
)

Definition at line 187 of file sp.c.

{
    char *pp, *p2, buf[MAX_LINELEN+1];
    pp=strparchr(p,',');
    if(pp==NULL) pp=""; else *pp++=0;
    strncpy(buf,p,MAX_LINELEN);buf[MAX_LINELEN]=0;
    strip_enclosing_par(buf);
    if((p2=strstr(buf,".."))!=NULL) string_modify(buf,p2,p2+2," to ");
    fprintf(outf,"%stmp%d=!item %s of %s\n\n",setpre,prepcnt,buf,pp);
}

Here is the call graph for this function:

void sp_items ( char *  p,
int  ptype 
)

Definition at line 198 of file sp.c.

{
    fprintf(outf,"%stmp%d=!itemcnt %s\n\n",setpre,prepcnt,p);
}
void sp_mathexp_cut ( char *  p,
int  ptype 
)

Definition at line 258 of file sp.c.

{
    char *p2;
    p2=find_word_end(find_word_start(p)); if(isspace(*p2)) *p2++=0;
    p2=find_word_start(p2);
    fprintf(outf,"%stmp%d=!exec mathexp cut %s\\\n%s\n\n",
           setpre,prepcnt,p,p2);
}

Here is the call graph for this function:

void sp_maxima ( char *  p,
int  ptype 
)

Definition at line 102 of file sp.c.

{
    fprintf(outf,"%st_=!replace internal \\( by ( in %s\n\
%stmp%d=!exec maxima $t_\n\n",setpre,p,setpre,prepcnt);
}
void sp_pari ( char *  p,
int  ptype 
)

Definition at line 114 of file sp.c.

{
    fprintf(outf,"%st_=!replace internal \\( by ( in %s\n\
%stmp%d=!exec pari $t_\n\n",setpre,p,setpre,prepcnt);
}
void sp_pickone ( char *  p,
int  ptype 
)

Definition at line 182 of file sp.c.

{
    sp_random(p,pt_int);
}

Here is the call graph for this function:

void sp_positionof ( char *  p,
int  ptype 
)

Definition at line 152 of file sp.c.

{
    char *p1;
    p1=strparchr(p,','); if(p1==NULL) {
       fprintf(outf,"%stmp%d=%s\n\n",setpre,prepcnt,p); return;
    }
    *p1++=0;
    fprintf(outf,"%stmp%d=!positionof item %s in %s\n\n",setpre,prepcnt,p, p1);
}

Here is the call graph for this function:

void sp_randitem ( char *  p,
int  ptype 
)

Definition at line 203 of file sp.c.

{
    fprintf(outf,"%stmp=!nonempty items %s\n\n\
%stmp%d=!randitem $tmp\n",setpre,p,setpre,prepcnt);
}
void sp_random ( char *  p,
int  ptype 
)

Definition at line 162 of file sp.c.

{
    char *pr, *p2, buf[MAX_LINELEN+1];
    snprintf(buf,sizeof(buf),"%s",p);
    for(p2=buf; *p2 && p2-buf<MAX_LINELEN; p2++) {
       if(*p2=='(') {
           p2=find_matching(p2+1,')'); continue;
       }
       if(*p2==',' || (*p2=='.' && *(p2+1)=='.')) break;
    }
    if(*p2==',') pr="randitem";
    else {
       if(*p2=='.') {
           *p2=','; *(p2+1)=' ';
       }
       if(ptype==pt_int) pr="randint"; else pr="random";
    }
    fprintf(outf,"%stmp%d=!%s %s\n\n",setpre,prepcnt,pr,buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sp_randrow ( char *  p,
int  ptype 
)

Definition at line 249 of file sp.c.

{
    fprintf(outf,"%stmp=!translate internal $    $ to ; in %s\n\n\
%stmp=!nonempty rows $tmp\n\
%stmp=!randrow $tmp\n\
%stmp%d=!translate internal $\\\n$ to ; in $tmp\n",
           setpre,p,setpre,setpre,setpre,prepcnt);
}
void sp_row ( char *  p,
int  ptype 
)

Definition at line 223 of file sp.c.

{
    char *pp, *p2, buf[MAX_LINELEN+1];
    pp=strparchr(p,',');
    if(pp==NULL) pp=""; else *pp++=0;
    strncpy(buf,p,MAX_LINELEN);buf[MAX_LINELEN]=0;
    strip_enclosing_par(buf);
    fprintf(outf,"%stmp=!translate internal $    $ to ; in %s\n\n",
           setpre,pp);
    if(strstr(buf,"column")!=NULL) {
       fprintf(outf,"%stmp%d=!select $tmp where %s\n\n",setpre,prepcnt,buf);
       return;
    }
    while((p2=strstr(buf,".."))!=NULL) 
      string_modify(buf,p2,p2+2," to ");
    fprintf(outf,"%stmp=!row %s of $tmp\n\
%stmp%d=!translate internal $\\\n$ to ; in $tmp\n",
           setpre, buf, setpre, prepcnt);
}

Here is the call graph for this function:

void sp_rows ( char *  p,
int  ptype 
)

Definition at line 243 of file sp.c.

{
    fprintf(outf,"%stmp=!translate internal $    $ to ; in %s\n\n\
%stmp%d=!rowcnt $tmp\n",setpre,p,setpre,prepcnt);
}
void sp_shuffle ( char *  p,
int  ptype 
)

Definition at line 147 of file sp.c.

{
    fprintf(outf,"%stmp%d=!shuffle %s\n\n",setpre,prepcnt,p);
}
void sp_simplify ( char *  p,
int  ptype 
)

Definition at line 120 of file sp.c.

{
    fprintf(outf,"%stmp=!translate \";': to $     $ in %s\n\n\
%stmp=!lower $tmp\n\
%stmp%d=!exec maxima fullratsimp($tmp);\n",
           setpre,p,setpre,setpre,prepcnt);
}
void sp_slib ( char *  p,
int  ptype 
)

Definition at line 128 of file sp.c.

{
    char *p2;
    p=find_word_start(p);
    for(p2=p;*p2!=0 && !isspace(*p2) && *p2!=',' && *p2!=';';p2++);
    if(*p2!=0 && !isspace(*p2)) *p2=' ';
    fprintf(outf,"!readproc slib/%s \n\
%stmp%d=$slib_out\n",p,setpre,prepcnt);
}

Here is the call graph for this function:

void sp_solve ( char *  p,
int  ptype 
)

Definition at line 50 of file sp.c.

{
    fprintf(outf,"%stmp=!replace internal .. by , in %s \n\n\
!distribute items $tmp into tmp1,tmp2,tmp3\n\
%stmp2=!replace internal = by , in $tmp2\n\
!distribute items $tmp2 into tmp4,tmp5\n\
%stmp%d=!solve $tmp1 for $tmp4 = $tmp5 to $tmp3 \n",
           setpre,p,setpre,setpre,prepcnt);
}
void sp_texmath ( char *  p,
int  ptype 
)

Definition at line 97 of file sp.c.

{
    fprintf(outf,"%stmp%d=!texmath %s\n\n",setpre,prepcnt,p);
}
void sp_wims ( char *  p,
int  ptype 
)

Definition at line 267 of file sp.c.

{
    p=find_word_start(p);
    if(!isalpha(*p) || strncasecmp(p,"ins",3)==0)
      fprintf(outf,"%stmp%d=%s\n\n",setpre,prepcnt,p);
    else
      fprintf(outf,"%stmp%d=!%s\n\n",setpre,prepcnt,p);
}

Here is the call graph for this function:

void sp_yacas ( char *  p,
int  ptype 
)

Definition at line 108 of file sp.c.

{
    fprintf(outf,"%st_=!replace internal \\( by ( in %s\n\
%stmp%d=!exec yacas $t_\n\n",setpre,p,setpre,prepcnt);
}

Variable Documentation

char* setpre = ""

Definition at line 18 of file sp.c.

struct { ... } specialfn[]