Ilya Zakharevich on Tue, 29 Feb 2000 17:19:43 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PATCH 2.0.18] \x upgraded


This patch does not try to correct %d to %ld (used thoughout PARI
source), but the added code has them correct.

This patch fixes handling of t_SMALLINT which IMO could lead to a segfault.

But the main difference is that all the special flags are put near the
memory words which contain the pertinent info, and that *all* the info
contained in the special words is put out (as far as I understand).

Keep in mind that I do not know what is t_VECSMALL, so I did not
change the way it is output.

Here is an example of the new output:

? x+y^3
%1 = x + y^3
? \x
[&=0067ef24] (HEAP) POL(len=4,CLONE):15000004  (+)(varn=0,eff-len=4):40000004  0067ef34  0067ef70  
  coef of degree 0 = [&=0067ef34] (HEAP) POL(len=6):14000006  (+)(varn=1,eff-len=6):40010006  0067ef4c  0067ef54  0067ef5c  0067ef64  
    coef of degree 0 = [&=0067ef4c] (HEAP) INT(len=2):02000002  ZERO(eff-len=2):00000002  
    coef of degree 1 = [&=0067ef54] (HEAP) INT(len=2):02000002  ZERO(eff-len=2):00000002  
    coef of degree 2 = [&=0067ef5c] (HEAP) INT(len=2):02000002  ZERO(eff-len=2):00000002  
    coef of degree 3 = [&=0067ef64] (HEAP) INT(len=3):02000003  (+)(eff-len=3):40000003  00000001  
  coef of degree 1 = [&=0067ef70] (HEAP) INT(len=3):02000003  (+)(eff-len=3):40000003  00000001  

--- ./src/language/es.c~	Mon Dec 13 08:24:24 1999
+++ ./src/language/es.c	Tue Feb 29 17:10:35 2000
@@ -923,28 +923,56 @@ voir2(GEN x, long nb, long bl)
 {
   long tx=typ(x),i,j,e,dx,lx=lg(x);
 
+  if (tx == t_SMALL) {
+    pariputs("[SMALL ");
+    sorstring(VOIR_STRING2,(long)x);
+    pariputs("]\n"); return;
+  }
   sorstring(VOIR_STRING1,(ulong)x);
-  if (tx!=t_POL && tx!=t_SER)
-    pariputsf("%s%c", type_name(tx)+2, isclone(x)?'!':'|');
+  if (!isonstack(x))
+    pariputs("(HEAP) ");
+  
+  pariputsf("%s(len=%ld%s):",type_name(tx)+2,lx,isclone(x)? ",CLONE" : "");
+  sorstring(VOIR_STRING2,x[0]);
+  if (signe(x))
+      pariputs(signe(x) > 0 ? "(+)" : "(-)" );
   else
-    pariputsf("%s %d%c", type_name(tx)+2, varn(x), isclone(x)?'!':'|');
+      pariputs("ZERO");
+/*  if (tx == t_POL || tx == t_LIST || tx == t_INT || tx == t_REAL)
+    lx = lgef(x); */
   if (! is_recursive_t(tx)) /* t_SMALL, t_INT, t_REAL, t_STR, t_VECSMALL */
   {
+    if (tx == t_STR)
+	pariputs("chars:");
+    else if (tx == t_INT)
+	pariputsf("(eff-len=%ld):", lgefint(x));
+    else if (tx == t_REAL)
+	pariputsf("(expo=%ld):", expo(x));
+    /* XXXX How to handle t_VECSMALL? */
     if (nb<0) nb = (tx==t_INT)? lgefint(x): lx;
-    if (tx == t_SMALL) x = (GEN)&x;
-    for (i=0; i<nb; i++) sorstring(VOIR_STRING2,x[i]);
+    for (i=1; i < nb; i++) sorstring(VOIR_STRING2,x[i]);
     pariputc('\n'); return;
   }
 
+  if (tx == t_PADIC)
+    pariputsf("(precp=%ld,valp=%ld):", precp(x), valp(x));
+  else if (tx == t_POL)
+    pariputsf("(varn=%ld,eff-len=%ld):", varn(x), lgef(x));
+  else if (tx == t_SER)
+    pariputsf("(varn=%ld,ser-prec=%ld,valp=%ld):", varn(x),lg(x)-2, valp(x));
+  else if (tx == t_LIST)
+    pariputsf("(eff-len=%ld):", lgef(x));
+  
   if (tx == t_POL || tx == t_LIST) lx = lgef(x);
-  for (i=0; i<lx; i++) sorstring(VOIR_STRING2,x[i]);
+  for (i=1; i<lx; i++) sorstring(VOIR_STRING2,x[i]);
   bl+=2; pariputc('\n');
   switch(tx)
   {
     case t_INTMOD: case t_POLMOD:
     {
       char *s = (tx==t_INTMOD)? "int = ": "pol = ";
-      if (isonstack(x[1])) blancs(bl); else { blancs(bl-2); pariputs("* "); }
+
+      blancs(bl);
       pariputs("mod = "); voir2((GEN)x[1],nb,bl);
       blancs(bl); pariputs(s);        voir2((GEN)x[2],nb,bl);
       break;
@@ -960,9 +988,7 @@ voir2(GEN x, long nb, long bl)
       break;
 
     case t_PADIC:
-      blancs(bl-2); pariputsf("precp : %d   valp : %d\n", precp(x), valp(x));
-      if (isonstack(x[2])) blancs(bl); else { blancs(bl-2); pariputs("* "); }
-      pariputs("  p : "); voir2((GEN)x[2],nb,bl);
+      blancs(bl); pariputs("  p : "); voir2((GEN)x[2],nb,bl);
       blancs(bl); pariputs("p^l : "); voir2((GEN)x[3],nb,bl);
       blancs(bl); pariputs("  I : "); voir2((GEN)x[4],nb,bl);
       break;
@@ -974,10 +1000,6 @@ voir2(GEN x, long nb, long bl)
       break;
 
     case t_POL: case t_SER:
-      if (tx == t_SER)
-      {
-	blancs(bl); pariputsf("prec : %d   valp : %d\n", lg(x)-2, valp(x));
-      }
       e = (tx==t_SER)? valp(x): 0;
       for (i=2; i<lx; i++)
       {