Back to index

wims  3.65+svn20090927
Defines | Functions | Variables
mup.c File Reference
#include "common.h"
#include "common.c"

Go to the source code of this file.

Defines

#define fsizelim   2621440
#define quitstring   "\nquit;\n"
#define stringprinter   "print(\"%s\");\n"
#define libpath   "lib"
#define helppath   "doc/ascii"
#define homepage   "http://www.mupad.de/"
#define progname   "mupad"

Functions

void check_parm (char *p)
void output (char *p)
void about (void)
char * dynsetup (char *ptr, char *end)
int main (int argc, char *argv[])

Variables

char * nameofcmd = "/usr/local/lib/mupad/share/bin/mupad"
int precision = 20
char header []
struct {
char * wname
char * defaultval
char * setname
setups []
char * illegal []
char * illpart []
int patch_tex

Define Documentation

#define fsizelim   2621440

Definition at line 23 of file mup.c.

#define helppath   "doc/ascii"

Definition at line 34 of file mup.c.

#define homepage   "http://www.mupad.de/"

Definition at line 35 of file mup.c.

#define libpath   "lib"

Definition at line 33 of file mup.c.

#define progname   "mupad"

Definition at line 72 of file mup.c.

#define quitstring   "\nquit;\n"

Definition at line 25 of file mup.c.

#define stringprinter   "print(\"%s\");\n"

Definition at line 27 of file mup.c.


Function Documentation

void about ( void  )

Definition at line 181 of file mup.c.

{
    char *p, *pp;

    prepabout(quitstring,outputfname,NULL);
    if(readabout()>0) {
        for(p=aboutbuf;*p!=0 && memcmp(p,"MuPAD",5)!=0;
           p=find_word_start(find_word_end(p)));
       if(*p!=0) {
           pp=find_word_start(find_word_end(p));
           pp=find_word_end(pp); *pp=0;
           printf("<A HREF=\"%s\">%s</A>",homepage,p);
       }
    }
}

Here is the call graph for this function:

void check_parm ( char *  p)

Definition at line 79 of file mup.c.

{
    char *pp, *p3;
    
       /* the character ! allows escaping into operating system */
    for(pp=strchr(p,'!');pp!=NULL; pp=strchr(pp+1,'!')) {
       if(pp<=p) {
           bad: fprintf(stderr,"Illegal under WIMS.\n");  exit(1);
       }
       for(p3=pp-1;p3>=p && isspace(*p3); p3--);
       if(p3<p || *p3=='(' || *p3==';' || *p3=='[') goto bad;
    }
    find_illegal(p);
}

Here is the call graph for this function:

char* dynsetup ( char *  ptr,
char *  end 
)

Definition at line 197 of file mup.c.

{
    int i;
    char *p, *pp;
    for(i=0;i<SETUP_NO;i++) {
       p=getenv(setups[i].wname);
       if(p!=NULL) for(pp=p;*pp;pp++) if(!isspace(*pp) && !isalnum(*pp)) p="";
       if(p==NULL || *p==0) p=setups[i].defaultval;
       snprintf(ptr,end-ptr,"%s:=%s;\n",setups[i].setname,p);
       ptr+=strlen(ptr);
       if(strstr(setups[i].wname,"mupad_precision")!=NULL)
         precision=atoi(p);
       if(precision<0) precision=-precision;
    }
    return ptr;
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 214 of file mup.c.

{
    char *p;
    
    p=getenv("w_mupad_tex_patch");
    if(p!=NULL && *p!=0) patch_tex=1; else patch_tex=0;
    prepare1();
    run();
    if(!isabout) setenv("w_mupad_tex_patch","",1);
    return 0;    
}

Here is the call graph for this function:

void output ( char *  p)

Definition at line 95 of file mup.c.

{
    int n;
    char *pp, *pe, *p2, *p3;
    pp=strstr(p,"\n>>"); if(pp==NULL) return;
    pp++;
    while(pp-1!=NULL) {
       pe=strstr(pp,"\n>>");
       if(pe>=pp) *pe=0;
       p2=strchr(pp,'\n');
       if(p2==NULL) p2=pp+strlen(pp); else p2++;
       pp=p2;
       n=strlen(pp); if(n==0) {pp=pe+1; continue;}
              /* take off warning and error messages,
               * and make every output one-line */
       p2=pp; do {
           p3=strchr(p2,'\n');
             /* patch for stupidities in mupad tex output */
           if(p3>pp && *(p3-1)=='\\' && (p3==pp+1 || *(p3-2)!='\\')) {
              strcpy(p3-1,p3+1); continue;
           }
           if(p3!=NULL) *p3=0;
           if(strstr(p2,"Warning")!=NULL || strstr(p2,"Error")!=NULL) {
              fprintf(stderr,"%s\n",p2);
              if(p3!=NULL) {
                  memmove(p2,p3+1,strlen(p3+1)+1); continue;
              }
              else {
                  *p2=0; break;
              }
           }
           if(p3!=NULL) {
              *p3=' '; p2=p3+1;
           }
       }
       while(p3!=NULL);
       
       /* translating array to pmatrix; should be done in script. */
       for(p3=strstr(pp,"\\begin{array}"); p3!=NULL; p3=strstr(p3,"\\begin{array}")) {
           memmove  (p3,"\\pmatrix{       ",strlen("\\begin{array}"));
           p3+=strlen  ("\\begin{array}");
           while(*p3!='}') *p3++=' '; *p3=' ';
       }
       for(p3=strstr(pp,"\\end{array}"); p3!=NULL; p3=strstr(p3,"\\end{array}")) {
           memmove  (p3,"}             ",strlen("\\end{array}"));
       }
             
       if(*pp=='[' && *(pp+strlen(pp)-1)==']') {
           *(pp+strlen(pp)-1)=0; pp++;
       }
       /* patch latex output of \sqrt[n] */
       for(p3=strstr(pp,"\\sqrt["); p3!=NULL; p3=strstr(p3+1,"\\sqrt[")) {
           char *p4;
           memmove(p3,"\\ROOT{",strlen("\\ROOT{"));
           p4=strchr(p3,']'); if(p4!=NULL) *p4='}';
       }
       /* patch of the superscript bug of mupad tex generation. */
       if(patch_tex) {
           char *p4, *p5, c;
           while((p4=strchr(pp,'^'))!=NULL) {
              c=*(p4+1);
              if(c=='{') {
                  *(p4+1)=0; printf("%s%c",pp,c);
                  pp=p4+2;continue;
              }
              if(c=='(') {
                  p5=find_matching(p4+2,')');
                  if(p5!=NULL) {
                     *(p4+1)='{'; *p5=0;
                     printf("%s}",pp);pp=p5+1;
                  }
                  else {
                     *(p4+1)=0; printf("%s",pp); pp=p4+2;
                  }
                  continue;
              }
              *(p4+1)=0; p4+=2;
              printf("%s{%c",pp,c);
              while(isdigit(*p4) || *p4=='.') printf("%c",*p4++);
              printf("}");pp=p4;
           }
       }
       puts(find_word_start(pp)); pp=pe+1;
    }
}

Here is the call graph for this function:


Variable Documentation

char header[]
Initial value:
"log:=ln;Pi:=PI;pi:=PI;e:=E;euler:=EULER;Euler:=EULER;\n\
log10:=proc(x) begin ln(x)/ln(10); end_proc: lg:=log10;\n\
log2:=proc(x) begin ln(x)/ln(2); end_proc: \n\
i:=I;sgn:=sign;ch:=cosh;sh:=sinh;th:=tanh;\n\
arcsin:=asin;arccos:=acos;tg:=tan;arctan:=atan;arctg:=atan;\n\
Argch:=acosh;Argsh:=asinh;Argth:=atanh;argch:=acosh;argsh:=asinh;argth:=atanh;\n\
cotan:=cot;ctg:=cot;rint:=round;factorial:=fact;\n\
PRETTYPRINT:=PRETTY_PRINT;\n"

Definition at line 37 of file mup.c.

char* illegal[]
Initial value:
{
      "manual","help",
      "fclose","fopen","fprint","fread","ftextinput",
      "input","pathname","protocol",
      "read","system","write"
}

Definition at line 58 of file mup.c.

char* illpart[]
Initial value:
{
    "plot", "PATH"
}

Definition at line 66 of file mup.c.

char* nameofcmd = "/usr/local/lib/mupad/share/bin/mupad"

Definition at line 30 of file mup.c.

int patch_tex

Definition at line 76 of file mup.c.

int precision = 20

Definition at line 31 of file mup.c.

struct { ... } setups[]