Back to index

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

Go to the source code of this file.

Defines

#define gpprompt   "\n? "
#define goodbyestring   "Good bye!"
#define homepage   "http://pari.math.u-bordeaux.fr/"
#define quitstring   "\nquit\n"
#define stringprinter   "print(\"%s\")\n"
#define progname   "pari"

Functions

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

Variables

int fsizelim = 131072
int precision = 28
char * nameofcmd = "gp"
char * gprcenv = "GPRC"
char * gprc = "../.gprc"
char header []
struct {
char * wname
char * defaultval
char * gpset
setups []
char * illegal []
char * illpart []
int pariray = 0

Define Documentation

#define goodbyestring   "Good bye!"

Definition at line 27 of file pari.c.

#define gpprompt   "\n? "

Definition at line 25 of file pari.c.

#define homepage   "http://pari.math.u-bordeaux.fr/"

Definition at line 29 of file pari.c.

#define progname   "pari"

Definition at line 99 of file pari.c.

#define quitstring   "\nquit\n"

Definition at line 31 of file pari.c.

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

Definition at line 33 of file pari.c.


Function Documentation

void about ( void  )

Definition at line 165 of file pari.c.

{
    char *p;

    prepabout("\\v\nquit\n",outputfname,NULL);
    if(readabout()>0) {
       p=strchr(aboutbuf,'\n'); if(p!=NULL) *p=0;
       strip_trailing_spaces(aboutbuf);
       printf("<A HREF=\"%s\">%s</A>",homepage,aboutbuf);
    }
}

Here is the call graph for this function:

void check_parm ( char *  pm)

Definition at line 106 of file pari.c.

{
    char *p;
    for(p=pm;*p!=0;p++) {
         /* Underscore replacement */
       if(*p=='_') {*p='K'; continue;}
         /* no escape commands. */
       if(*p!='\n') continue;
       while(*p!=0 && isspace(*p)) p++;
       if(*p=='\\' && *(p+1)!='\\' && *(p+1)!='v' && *(p+1)!='p') *p='.';
       if(*p=='\\') p++;
    }
    find_illegal(pm);
}

Here is the call graph for this function:

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

Definition at line 177 of file pari.c.

{
    int i;
    char *p, *pp;

    snprintf(ptr,end-ptr,"\nsetrand(%u)\n",seed&(0x7FFFFFFF));
    ptr+=strlen(ptr);
    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].gpset,p);
       ptr+=strlen(ptr);
       if(strstr(setups[i].wname,"pari_precision")!=NULL)
         precision=atoi(p);
       if(precision<0) precision=-precision;
    }
    if(pariray) snprintf(ptr,end-ptr,"\\e0\n");
    else snprintf(ptr,end-ptr,"\\e1\n");
    ptr+=strlen(ptr);
    return ptr;
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 200 of file pari.c.

{
    char *p;

    p=getenv("pari_ray");
    if(p!=NULL && *p!=0) {pariray=1; fsizelim=4*1024*1024;}
    setenv(gprcenv,gprc,1);
    prepare1();
    setenv("GPTMPDIR",tmp_dir,1);
    run();
    return 0;    
}

Here is the call graph for this function:

void output ( char *  p)

Definition at line 122 of file pari.c.

{
    int i,n;
    char *pp, *pe, *pt;
    
    if(pariray) {puts(p); return;}
    pp=strstr(p,gpprompt); if(pp==NULL) return;
    pe=strstr(pp,goodbyestring);
    if(pe>=pp) *pe=0;
    while(pp!=NULL) {
       pp++;
       pe=strstr(pp,gpprompt);
       if(pe>=pp) *pe=0;
       pp=strchr(pp,'\n');
       if(pp==NULL) {
           emptyline:
           puts(""); pp=pe; continue;
       }
       pp++; n=strlen(pp);
       if(n==0) goto emptyline;
              /* make every output one-line */
       for(i=0;i<n;i++) {
           if(*(pp+i)=='\n') {
              if(*(pp+i+1)!='%') *(pp+i)=' ';
              else {*(pp+i)=0; break;}
           }
       }
         /* strip leading and trailing spaces */
       while(isspace(*pp) && pp<pe) pp++;
       pt=pp+strlen(pp)-1;
       while(isspace(*pt) && pt>pp) *pt--=0;
         /* remove parentheses of matrix output */
       if(memcmp(pp,"Mat(",4)==0 && *pt==')' && find_matching(pp+4,')')==pt) {
           *(pt--)=0; pp+=4;
       }
       if(*pp=='[' && *pt==']' && find_matching(pp+1,']')==pt) {
           *(pt--)=0; pp++;
       }
       strip_zeros(pp);
       puts(pp); pp=pe;
    }
}

Here is the call graph for this function:


Variable Documentation

int fsizelim = 131072

Definition at line 35 of file pari.c.

char* gprc = "../.gprc"

Definition at line 40 of file pari.c.

char* gprcenv = "GPRC"

Definition at line 39 of file pari.c.

char header[]

Definition at line 41 of file pari.c.

char* illegal[]
Initial value:
{
       "alias","allocatemem","default","extern",
      "getrand","getstack","input","psdraw",
      "read","system","install"
}

Definition at line 86 of file pari.c.

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

Definition at line 93 of file pari.c.

char* nameofcmd = "gp"

Definition at line 38 of file pari.c.

int pariray = 0

Definition at line 103 of file pari.c.

int precision = 28

Definition at line 36 of file pari.c.

struct { ... } setups[]