Back to index

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

Go to the source code of this file.

Functions

char * find_mathvar_start (char *p)
char * find_mathvar_end (char *p)
void mathvarlist (char *p)

Function Documentation

char* find_mathvar_end ( char *  p)

Definition at line 30 of file math.c.

{
    int i; char *pp;
    if(!isalnum(*p) && *p!='.') return p;
    if(isalpha(*p)) {
       for(i=0; *p!=0 && (isalnum(*p) || *p=='.' || *p=='\'')
           && i<MAX_LINELEN;p++,i++);
       return p;
    }
    else {
       int t=0;
       expon:
       for(i=0; (isdigit(*p) || *p=='.') && i<MAX_LINELEN;p++,i++);
       pp=p; if(t) return pp;
       while(isspace(*p)) p++;
       if(*p=='e' || *p=='E'){
           t=1; p++; while(isspace(*p)) p++;
           if(isdigit(*p)) goto expon;
           if((*p=='-' || *p=='+') && isdigit(*(p+1))) {
              p++; goto expon;
           }
       }
       return pp;
    }
}

Here is the caller graph for this function:

char* find_mathvar_start ( char *  p)

Definition at line 22 of file math.c.

{
    int i;
    for(i=0;!isalnum(*p) && *p!='.' && *p!=0 && i<MAX_LINELEN; p++,i++);
    return p;
}

Here is the caller graph for this function:

void mathvarlist ( char *  p)

Definition at line 58 of file math.c.

{
    char buf[MAX_LINELEN+1], *pb, *pe, *pp;
    char *l[10240];
    int i,j,len, nofn=0;

    pb=find_word_start(p);pe=find_word_end(pb);
    if(pe-pb==strlen("nofn") && memcmp(pb,"nofn",strlen("nofn"))==0) {
       nofn=1; pb=find_word_start(pe);
    }
    snprintf(buf,sizeof(buf),"%s",pb);
    len=strlen(buf);
    for(i=0,pb=buf;pb<buf+len;pb++) {
       if(!isalpha(*pb)) continue;
       if(pb>buf && isalnum(*(pb-1))) {
           pb=find_mathvar_end(pb); continue;
       }
       pe=find_mathvar_end(pb); pp=find_word_start(pe);
       if(nofn && *pp=='(') {
           pb=pe; continue;
       }
       *pe=0;
       if(i<10240) {
           for(j=0;j<i;j++) if(strcmp(pb,l[j])==0) goto nextp;
           l[i++]=pb;
       }
       nextp:
       pb=pe;
    }
    for(*p=0,j=0;j<i;j++) {
       strcat(p,l[j]);
       if(j<i-1) strcat(p,",");
    }
}

Here is the call graph for this function: