diff -pru H:\get\pari/Changes libPARI/Changes
--- H:/get/pari/Changes	Tue Nov 21 02:39:52 1995
+++ libPARI/Changes	Thu Oct 30 13:37:22 1997
@@ -93,8 +93,8 @@ Currently supported under gnuplot only.
 work if gnuplot is not built, though there are some provisions to build it.
 48) testouts modified to reflect changed memory allocation due to new
 rectangles.
-49) new functions rpoints, rlines, rpointtype, rlinetype, plotrawlines,
-rploth, rcopy added to interpreter.
+49) new functions rpoints, rlines, rpointtype, rlinetype, plothrawlines,
+rploth, rplothraw, rcopy added to interpreter.
 50) The logic in identifier and skipidentifier is changed to use the
 ep->code field if present.
 51) all code uses ep->help instead of helpmessages (time to move
diff -pru H:\get\pari/gencom.h libPARI/gencom.h
--- H:/get/pari/gencom.h	Fri Feb 16 18:33:28 1996
+++ libPARI/gencom.h	Sat Sep 20 17:53:58 1997
@@ -266,13 +266,27 @@ extern	void	(*foreignFuncFree)(entree *)
   #ifdef __cplusplus
     }
   #endif
+  #define exp2l exp2
+  #define flog2(x) floor(log2(x))
 #else
   #ifdef __cplusplus
-    inline double exp2(double x) {return exp(x*LOG2);}
-    inline double log2(double x) {return log(x)/LOG2;}
+    static inline double exp2l(long x) {return exp(x*LOG2);}
+    static inline double flog2(double x) {return floor(log(x)/LOG2);}
   #else
-    #define exp2(x) (exp((double)(x)*LOG2))
-    #define log2(x) (log((double)(x))/LOG2)
+    #if defined(__i386__) && defined(__GNUC__)
+      static inline long flog2(double x) {
+	  unsigned long *p = (unsigned long*)&x;
+	  unsigned long l = (p[1] >> (52 - 32)) & 0x7FF; /* Remove sign bit */
+	  return (((long)l) - 1023);	/* Bias */
+      }
+    #else
+      #define flog2(x) floor(log((double)(x))/LOG2)
+    #endif 
+    #if defined(__i386__) && defined(__GNUC__)
+      static inline double exp2l(long x) {long e[2]; e[0]=0; e[1] = (x+1023)<<(52-32);return *(double*)e;}
+    #else
+      #define exp2l(x) (exp(((double)x)*LOG2))
+    #endif
   #endif
 #endif
 
diff -pru H:\get\pari/Gnuplot.h libPARI/Gnuplot.h
--- H:/get/pari/Gnuplot.h	Fri Sep  1 23:50:56 1995
+++ libPARI/Gnuplot.h	Tue Oct 14 19:28:06 1997
@@ -12,30 +12,31 @@
 /* STRINGIFY:
  *      This macro surrounds its token with double quotes.
  */
-#if 42 == 1
-#define CAT2(a,b)a/**/b
-#define CAT3(a,b,c)a/**/b/**/c
-#define CAT4(a,b,c,d)a/**/b/**/c/**/d
-#define CAT5(a,b,c,d,e)a/**/b/**/c/**/d/**/e
-#define STRINGIFY(a)"a"
-                /* If you can get stringification with catify, tell me how! */
-#endif
-#if 42 == 42
-#define CAT2(a,b)a ## b
-#define CAT3(a,b,c)a ## b ## c
-#define CAT4(a,b,c,d)a ## b ## c ## d
-#define CAT5(a,b,c,d,e)a ## b ## c ## d ## e
-#define StGiFy(a)# a
-#define STRINGIFY(a)StGiFy(a)
-#define SCAT2(a,b)StGiFy(a) StGiFy(b)
-#define SCAT3(a,b,c)StGiFy(a) StGiFy(b) StGiFy(c)
-#define SCAT4(a,b,c,d)StGiFy(a) StGiFy(b) StGiFy(c) StGiFy(d)
-#define SCAT5(a,b,c,d,e)StGiFy(a) StGiFy(b) StGiFy(c) StGiFy(d) StGiFy(e)
-#endif
 #ifndef CAT2
-#include "Bletch: How does this C preprocessor catenate tokens?"
-#endif
- 
+# if 42 == 1
+#  define CAT2(a,b)a/**/b
+#  define CAT3(a,b,c)a/**/b/**/c
+#  define CAT4(a,b,c,d)a/**/b/**/c/**/d
+#  define CAT5(a,b,c,d,e)a/**/b/**/c/**/d/**/e
+#  define STRINGIFY(a)"a"
+                /* If you can get stringification with catify, tell me how! */
+# endif
+# if 42 == 42
+#  define CAT2(a,b)a ## b
+#  define CAT3(a,b,c)a ## b ## c
+#  define CAT4(a,b,c,d)a ## b ## c ## d
+#  define CAT5(a,b,c,d,e)a ## b ## c ## d ## e
+#  define StGiFy(a)# a
+#  define STRINGIFY(a)StGiFy(a)
+#  define SCAT2(a,b)StGiFy(a) StGiFy(b)
+#  define SCAT3(a,b,c)StGiFy(a) StGiFy(b) StGiFy(c)
+#  define SCAT4(a,b,c,d)StGiFy(a) StGiFy(b) StGiFy(c) StGiFy(d)
+#  define SCAT5(a,b,c,d,e)StGiFy(a) StGiFy(b) StGiFy(c) StGiFy(d) StGiFy(e)
+# endif
+# ifndef CAT2
+#   include "Bletch: How does this C preprocessor catenate tokens?"
+# endif
+#endif /* CAT2 */
 
 
 
@@ -103,9 +104,9 @@ struct TERMENTRY {
 };
 
 #ifdef _Windows
-#define termentry TERMENTRY far
+#  define termentry TERMENTRY far
 #else
-#define termentry TERMENTRY
+#  define termentry TERMENTRY
 #endif
 
 extern struct termentry term_tbl[];
@@ -143,7 +144,7 @@ extern struct termentry term_tbl[];
        (term<=0) ? (						\
 	 croak("No terminal specified") returnval		\
        ) :							\
-       (*(CAT2(F_,mult))term_tbl[term].method)args		\
+       (*(CAT2(F_,mult))my_term_tbl[term].method)args		\
      )
 
 #define init()	CALL_G_METH0(init)
@@ -160,9 +161,55 @@ extern struct termentry term_tbl[];
 #define point(x,y,p)	CALL_G_METH3(point,x,y,p)
 #define arrow(sx,sy,ex,ey,head)	CALL_G_METH5(arrow,sx,sy,ex,ey,head)
 
-#define termprop(prop) (term_tbl[term].prop)
-#define termset(term) change_term(term,strlen(term))
+#define termprop(prop) (my_term_tbl[term].prop)
+#define termset(term) my_change_term(term,strlen(term))
 int change_term(char*,int);
+
+#ifdef DYNAMIC_PLOTTING			/* Can load plotting DLL later */
+
+UNKNOWN_null()
+{
+    err(talker,"gnuplot-like plotting environment not loaded yet");
+}
+
+static FUNC_PTR change_term_p;
+
+int 
+my_change_term(char*s,int l) 
+{
+    if (!change_term_p)
+	UNKNOWN_null();
+    term = (*change_term_p)(s,l);
+}
+
+#  define change_term(p,l) my_change_term(p,l)
+#  define term_tbl (my_term_tbl)
+
+static struct termentry dummy_term_tbl[] = {
+    {"unknown", "Unknown terminal type - not a plotting device",
+	  100, 100, 1, 1,
+	  1, 1, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, 
+	  UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, 
+	  UNKNOWN_null, UNKNOWN_null, UNKNOWN_null,
+     UNKNOWN_null, UNKNOWN_null, UNKNOWN_null},
+};
+static struct termentry *my_term_tbl = dummy_term_tbl;
+
+/* This function should be called before any graphic code can be used... */
+set_term_funcp(FUNC_PTR change_p, struct termentry *term_p)
+{
+    my_term_tbl = term_p;
+    change_term_p = change_p;
+}
+
+#else /* !DYNAMIC_PLOTTING */
+
+#  define my_change_term change_term
+#  define my_term_tbl term_tbl
+
+#endif /* DYNAMIC_PLOTTING */
+
+
 
 #ifdef __cplusplus
   }
diff -pru H:\get\pari/gphelp libPARI/gphelp
--- H:/get/pari/gphelp	Wed May  3 01:02:08 1995
+++ libPARI/gphelp	Mon Sep 22 03:23:28 1997
@@ -6,7 +6,10 @@
 # The manual file can compressed. Sometimes you need to change the
 # name of the compression program in the %compress = ... statement below.
 #
+
+# $parifile="f:/pari/doc/usersch3.tex.gz";
 $parifile="/opt/src/pari-1.39/doc/usersch3.tex.gz";
+
 die "Usage: $0 functionName\n" unless @ARGV==1;
 $help=shift;
 %transl=(
@@ -19,11 +22,11 @@ $help=shift;
 	 '%',  '\%',
 	 'min',  'max',
 	 'log',  'ln',
-	);
-%compress = ('.gz', 'zcat',
-	     '.z', 'zcat',
-	     '.Z', 'zcat',
-	    );
+);
+%compress = ('.gz', 'gzip -cd',
+	   '.z', 'gzip -cd',
+	   '.Z', 'zcat',
+	  );
 if    ($transl{$help}) {$help=$transl{$help}}
 if ($help =~ /^[<>=!]=?|[|&]{1,2}$/) 
       {$help='comparison and \ref{boolean operators}'}
@@ -55,8 +58,10 @@ if (eof(DOC)) {
   }
 }
 if ($pipe) {
-  # Would get 'illegal seek' otherwise?
-  1 while <DOC>;
+  if ($^O eq 'os2') {
+    # Would get 'illegal seek' otherwise?
+    1 while <DOC>;
+  }
   close(DOC) || die "Cannot close pipe `$pipe $parifile': $!, stopped";
 } else {
   close(DOC) || die "Cannot close file $parifile: $!, stopped";
diff -pru H:\get\pari/i386.c libPARI/i386.c
--- H:/get/pari/i386.c	Wed May  3 01:09:34 1995
+++ libPARI/i386.c	Tue Sep 23 03:09:16 1997
@@ -10,7 +10,7 @@
 
 /* written by Bruno Haible 14.11.1992 */
 
-#if defined(__EMX__) || defined(__DJGCC__) || defined(__GO32__) || defined(linux) || defined(__386BSD__) || defined(__NetBSD__)
+#if defined(__EMX__) || defined(__DJGCC__) || defined(__GO32__) || defined(linux) && !defined(__ELF__) || defined(__386BSD__) || defined(__NetBSD__)
 /* GNU assembler */
 #ifdef __STDC__
 /* ANSI C concatenation */
diff -pru H:\get\pari/mp.c libPARI/mp.c
--- H:/get/pari/mp.c	Sun May 14 21:10:30 1995
+++ libPARI/mp.c	Sat Sep 20 17:53:46 1997
@@ -1327,16 +1327,16 @@ rtodbl(GEN x)
 {
   double y,ma;
 #ifdef LONG_IS_64BIT
-  double co=64.0;
+  int co=64;
 #else
-  double co=32.0;
+  int co=32;
 #endif
   long ex,s=signe(x);
   
   if((!s)||((ex=expo(x))< -1023)) return 0.0;
   if(ex>=0x3ff) err(rtodber);
-  ma=(uLong)x[2]+(uLong)x[3]/exp2(co);
-  y=exp2(ex+1-co);
+  ma=(uLong)x[2]+(uLong)x[3]/exp2l(co);
+  y=exp2l(ex+1-co);
   return (s<0) ? -y*ma : y*ma;
 }
 
@@ -1346,9 +1346,9 @@ dbltor(double x)
   GEN z;
 
 #ifdef LONG_IS_64BIT
-  double co=64.0;
+  int co=64;
 #else
-  double co=32.0;
+  int co=32;
 #endif
   uLong y;
   long ex;
@@ -1362,11 +1362,11 @@ dbltor(double x)
 #endif
 
 
-  if(x<0) {ex=(long)floor(log2(-x));z[1]=evalexpo(ex)+evalsigne(-1);x= -x;}
-  else {ex=(long)floor(log2(x));z[1]=evalexpo(ex)+evalsigne(1);}
-  x=x*exp2(-ex+co-1);y=(uLong)x;z[2]=y;
+  if(x<0) {ex=(long)flog2(-x);z[1]=evalexpo(ex)+evalsigne(-1);x= -x;}
+  else {ex=(long)flog2(x);z[1]=evalexpo(ex)+evalsigne(1);}
+  x=x*exp2l(-ex+co-1);y=(uLong)x;z[2]=y;
 #ifndef LONG_IS_64BIT
-  x-=y;y=(uLong)(exp2(co)*x);z[3]=y;
+  x-=y;y=(uLong)(exp2l(co)*x+0.5);z[3]=y;
 #endif
   if(!(z[2]&HIGHBIT))
   {
diff -pru H:\get\pari/mpin.c libPARI/mpin.c
--- H:/get/pari/mpin.c	Sun May 14 21:10:52 1995
+++ libPARI/mpin.c	Sat Sep 20 02:09:28 1997
@@ -1327,16 +1327,16 @@ rtodbl(GEN x)
 {
   double y,ma;
 #ifdef LONG_IS_64BIT
-  double co=64.0;
+  int co=64;
 #else
-  double co=32.0;
+  int co=32;
 #endif
   long ex,s=signe(x);
   
   if((!s)||((ex=expo(x))< -1023)) return 0.0;
   if(ex>=0x3ff) err(rtodber);
-  ma=(uLong)x[2]+(uLong)x[3]/exp2(co);
-  y=exp2(ex+1-co);
+  ma=(uLong)x[2]+(uLong)x[3]/exp2l(co);
+  y=exp2l(ex+1-co);
   return (s<0) ? -y*ma : y*ma;
 }
 
@@ -1346,9 +1346,9 @@ dbltor(double x)
   GEN z;
 
 #ifdef LONG_IS_64BIT
-  double co=64.0;
+  int co=64;
 #else
-  double co=32.0;
+  int co=32;
 #endif
   uLong y;
   long ex;
@@ -1362,11 +1362,11 @@ dbltor(double x)
 #endif
 
 
-  if(x<0) {ex=(long)floor(log2(-x));z[1]=evalexpo(ex)+evalsigne(-1);x= -x;}
-  else {ex=(long)floor(log2(x));z[1]=evalexpo(ex)+evalsigne(1);}
-  x=x*exp2(-ex+co-1);y=(uLong)x;z[2]=y;
+  if(x<0) {ex=(long)flog2(-x);z[1]=evalexpo(ex)+evalsigne(-1);x= -x;}
+  else {ex=(long)flog2(x);z[1]=evalexpo(ex)+evalsigne(1);}
+  x=x*exp2l(-ex+co-1);y=(uLong)x;z[2]=y;
 #ifndef LONG_IS_64BIT
-  x-=y;y=(uLong)(exp2(co)*x);z[3]=y;
+  x-=y;y=(uLong)(exp2l(co)*x);z[3]=y;
 #endif
   if(!(z[2]&HIGHBIT))
   {
diff -pru H:\get\pari/plotgnuplot.c libPARI/plotgnuplot.c
--- H:/get/pari/plotgnuplot.c	Fri Sep  1 22:23:08 1995
+++ libPARI/plotgnuplot.c	Tue Oct 14 19:32:50 1997
@@ -133,6 +133,7 @@ PARI_get_plot()
   term_set( DEF_TERM );
 }
 
+
 long
 term_set(char *s)
 {
diff -pru H:\get\pari/plotport.c libPARI/plotport.c
--- H:/get/pari/plotport.c	Sat Oct 28 13:23:36 1995
+++ libPARI/plotport.c	Thu Oct 30 12:03:40 1997
@@ -138,9 +138,17 @@ recplothraw(long drawrect, GEN frame, GE
 GEN
 recplothmultin(long graphrect, entree *ep, GEN a, GEN b, char *ch, long prec, uLong flags, long testpoints)
 {
-  long av = avma,av2,i,j,sig,nc, offset = 0, lbot, points;
+  long av = avma,av2,i,j,sig,nc, offset = 0, points;
   GEN p1,p2,ysml,ybig,xsml,xbig,x,ydiff,xdiff,dx,y,dr,res;
 
+  ysml=cgetr(3);ybig=cgetr(3);
+  xsml=cgetr(3);xbig=cgetr(3);
+  res = cgetg(5,17);
+  res[1] = (long)xsml;
+  res[2] = (long)xbig;
+  res[3] = (long)ysml;
+  res[4] = (long)ybig;
+
   if (!testpoints) {
     points = 2 * (rectgraph[graphrect]->sizex +
 		  rectgraph[graphrect]->sizey + 2);
@@ -152,8 +160,6 @@ recplothmultin(long graphrect, entree *e
 
   newvalue(ep,cgetr(prec)); x=(GEN)(ep->value);
   gaffect(a,x);p1=lisexpr(ch);
-  ysml=cgetr(3);ybig=cgetr(3);
-  xsml=cgetr(3);xbig=cgetr(3);
   if (flags & PLOT_PARAMETRIC) {
     dx=gdivgs(gsub(b,a), testpoints - 1);
   } else {
@@ -239,16 +245,10 @@ recplothmultin(long graphrect, entree *e
 
   rectplothrawin(graphrect, xsml, xbig, ysml, ybig, y, prec, flags);
 
-  avma = av;
   killvalue(ep);
+  avma = (long)res;
 
-  lbot = avma;
-  res = cgetg(5,17);
-  res[1] = (long)xsml;
-  res[2] = (long)xbig;
-  res[3] = (long)ysml;
-  res[4] = (long)ybig;
-  return gerepile(av,lbot,res);
+  return res;
 }
 
 /* 
diff -pru H:\get\pari/version68k.c libPARI/version68k.c
--- H:/get/pari/version68k.c	Wed May  3 01:09:38 1995
+++ libPARI/version68k.c	Sat Sep 20 02:09:28 1997
@@ -187,13 +187,13 @@ gerepilc(GEN l, GEN p, GEN q)
 double
 rtodbl(GEN x)
 {
-  double y,ma,co=32.0;
-  long ex,s=signe(x);
+  double y,ma;
+  long ex,s=signe(x),co=32;
   
   if((!s)||((ex=expo(x))< -1023)) return 0.0;
   if(ex>=0x3ff) err(rtodber);
-  ma=(uLong)x[2]+(uLong)x[3]/exp2(co);
-  y=exp2(ex+1-co);
+  ma=(uLong)x[2]+(uLong)x[3]/exp2l(co);
+  y=exp2l(ex+1-co);
   return (s<0) ? -y*ma : y*ma;
 }
 
@@ -201,15 +201,15 @@ GEN
 dbltor(double x)
 {
   GEN z;
-  double co=32.0;
+  long co=32;
   uLong y;
   long ex;
   int n;
   
   if(x==0) {z=cgetr(3);z[2]=0;z[1]=0x800000-308;return z;}
   z=cgetr(4);if(x<0) {setsigne(z,-1);x= -x;} else setsigne(z,1);
-  ex=(long)floor(log2(x));setexpo(z,ex);x=x*exp2(-ex+co-1);y=(uLong)x;x-=y;z[2]=y;
-  y=(long)(exp2(co)*x);z[3]=y;
+  ex=(long)flog2(x);setexpo(z,ex);x=x*exp2l(-ex+co-1);y=(uLong)x;x-=y;z[2]=y;
+  y=(long)(exp2l(co)*x);z[3]=y;
 
   if(!(z[2]&(1<<31)))
   {
