Back to index

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

Go to the source code of this file.

Defines

#define ptypeno   (sizeof(ptype)/sizeof(ptype[0]))

Enumerations

enum  {
  pt_int, pt_rat, pt_real, pt_complex,
  pt_func, pt_text, pt_matrix
}

Functions

void subst (char *p)
void putval (char *p, char *name, int ptype)
void parm (char *p[MAX_PARM], int ptype)
void p_int (char *p[MAX_PARM])
void p_rational (char *p[MAX_PARM])
void p_real (char *p[MAX_PARM])
void p_complex (char *p[MAX_PARM])
void p_func (char *p[MAX_PARM])
void p_text (char *p[MAX_PARM])
void p_matrix (char *p[MAX_PARM])
void p_parm (char *p[MAX_PARM])
void def (char *p)

Variables

int dollar_subst = 1
int prepcnt
struct {
char * name
void(* processor )(char *p[MAX_PARM])
ptype []

Define Documentation

#define ptypeno   (sizeof(ptype)/sizeof(ptype[0]))

Definition at line 165 of file def.c.


Enumeration Type Documentation

anonymous enum
Enumerator:
pt_int 
pt_rat 
pt_real 
pt_complex 
pt_func 
pt_text 
pt_matrix 

Definition at line 56 of file def.c.


Function Documentation

void def ( char *  p)

Definition at line 167 of file def.c.

{
    char *p1,*p2,*pp[2];
    int i;
    p1=find_word_start(p);
    pp[1]=strchr(p1,'='); if(*pp[1]==0) return;
    *pp[1]=0; pp[1]++;
    p2=find_word_start(find_word_end(p1));
    if(*p2==0) {pp[0]=p1; p_parm(pp); return;}
    pp[0]=p2; *find_word_end(p1)=0;
    for(p2=p1; *p2; p2++) *p2=tolower(*p2);
    for(i=0;i<ptypeno;i++) if(strcmp(p1,ptype[i].name)==0) break;
    if(i<ptypeno) ptype[i].processor(pp);
    else p_parm(pp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void p_complex ( char *  p[MAX_PARM])

Definition at line 139 of file def.c.

void p_func ( char *  p[MAX_PARM])

Definition at line 140 of file def.c.

{parm(p,pt_func);}
void p_int ( char *  p[MAX_PARM])

Definition at line 136 of file def.c.

{parm(p,pt_int);}
void p_matrix ( char *  p[MAX_PARM])

Definition at line 142 of file def.c.

void p_parm ( char *  p[MAX_PARM])

Definition at line 144 of file def.c.

{
    parm(p,pt_real);
}

Here is the caller graph for this function:

void p_rational ( char *  p[MAX_PARM])

Definition at line 137 of file def.c.

{parm(p,pt_rat);}
void p_real ( char *  p[MAX_PARM])

Definition at line 138 of file def.c.

{parm(p,pt_real);}
void p_text ( char *  p[MAX_PARM])

Definition at line 141 of file def.c.

{parm(p,pt_text);}
void parm ( char *  p[MAX_PARM],
int  ptype 
)

Definition at line 99 of file def.c.

{
    char *pp, *p2;
    char vbuf[MAX_LINELEN+1];

    setpre="!set ";
    p[0]=find_word_start(p[0]);
    if(*p[0]=='\\') p[0]++;
       /* bad name */
    if(!isalpha(*p[0])) return;
    strip_trailing_spaces(p[0]);
    for(pp=p[0];*pp;pp++) if(!isalnum(*pp) && *pp!='_') {
       /* bad name and security risk */
       if(!isspace(*pp)) return;
       strcpy(pp,pp+1); pp--;
    }
    p[1]=find_word_start(p[1]);
    snprintf(vbuf,sizeof(vbuf),"%s",p[1]); subst(vbuf);
    fprintf(outf,"\n");
    if((pp=strparchr(vbuf,'?'))!=NULL && pp[1]!='?' && check_compare(vbuf)) {
       char buf[MAX_LINELEN+1];
       p2=strparchr(pp,':'); *pp++=0; if(p2!=NULL) *p2++=0;
       snprintf(buf,sizeof(buf),"%s",vbuf);
       prepcnt=0; fprintf(outf,"!ifval %s \n",vbuf);
       snprintf(buf,sizeof(buf),"%s",pp);
       parmprep(buf, ptype); putval(buf,p[0],ptype);
       if(p2!=NULL) {
           snprintf(buf,sizeof(buf),"%s",p2);
           fprintf(outf,"!else\n");
           parmprep(buf, ptype); putval(buf,p[0],ptype);
       }
       fprintf(outf,"!endif\n");return;
    }
    prepcnt=0; parmprep(vbuf, ptype);
    putval(vbuf,p[0],ptype);
}

Here is the call graph for this function:

void putval ( char *  p,
char *  name,
int  ptype 
)

Definition at line 61 of file def.c.

{
    switch(ptype) {
       case pt_int: {
           fprintf(outf,"%sm_%s=$[rint(%s)]\n",setpre,name,p);
           break;
       }
       case pt_real: {
           fprintf(outf,"%sm_%s=$[%s]\n",setpre,name,p);
           break;
       }
       case pt_func: {
           fprintf(outf,"%sm_%s=!rawmath %s \n",setpre,name,p);
           break;
       }
       case pt_complex: {
           fprintf(outf,"%st_=!rawmath %s \n%st_=!exec pari print($t_)\n\
%sm_%s=!mathsubst I=i in $t_\n",
                  setpre,p,setpre,setpre,name);
           break;
       }
       case pt_matrix: {
           fprintf(outf,"%stmp=!trim %s \n\
%sm_%s=!translate internal $       $ to ; in $tmp\n",setpre,p,setpre,name);
           break;
       }
       case pt_rat: {
           fprintf(outf,"%st_=!rawmath %s \n%sm_%s=!exec pari print($t_)\n",
                  setpre,p,setpre,name);
           break;
       }
       default: {
           fprintf(outf,"%sm_%s=%s\n\n",setpre,name,p);
           break;
       }
    }
}

Here is the caller graph for this function:

void subst ( char *  p)

Definition at line 21 of file def.c.

{
    char *pp, *pe;

    for(pp=p;pp-p<MAX_LINELEN && *pp; pp++) {
       if(*pp=='     ') *pp=' ';
       if(*pp=='\n') *pp='  ';
       if(*pp=='$' && dollar_subst) {
           string_modify(p,pp,pp+1,"&#36;");
           pp++; continue;
       }
       if(*pp=='!' && isalnum(*(pp+1)) && dollar_subst) {
           string_modify(p,pp,pp+1,"&#33;");
           pp++; continue;
       }
       if(*pp!='\\') continue;
       if(*(pp+1)=='\\') {
           pp++; continue;
       }
       if(!isalpha(*(pp+1))) continue;
       for(pe=pp+1;isalnum(*pe) || *pe=='_'; pe++);
       if(pe-pp<MAX_NAMELEN && *pe=='[') {
           char *pt;
           pt=find_matching(pe+1,']'); if(pt!=NULL && pt-pe<MAX_LINELEN) {
              string_modify(p,pt+1,pt+1,")");
              string_modify(p,pp,pp+1,"$(m_");
           }
           else goto nobrack;
       }
       else {
           nobrack: string_modify(p,pp,pp+1,"$m_");
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int dollar_subst = 1

Definition at line 18 of file def.c.

int prepcnt

Definition at line 57 of file def.c.

struct { ... } ptype[]