Karim Belabas on Tue, 18 Nov 1997 23:26:37 +0100


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

patch 1


Hi all,

  Here's patch number 1 for the 2.0.alpha release of PARI/GP. This patch and
all subsequent ones (as well as some hints as to how to apply them) will be
archived on the PARI Web pages, hosted by Gerhard Niklasch at

  http://hasse.mathematik.tu-muenchen.de/ntsw/pari/

They can also be found on the PARI main ftp server:

  ftp://megrez.math.u-bordeaux.fr/pub/pari/patches/

All critical patches will be posted on this list (as well as non critical 
ones, which have been discussed here). Of course, bug reports, patches 
and (preferably technical) suggestions are welcome here as well !

Cheers,

    Karim.

=========================   patch 1 (2.0.alpha)  ===========================

* GP did not always come up with a reasonable size for the terminal, esp. over
telnet connection. As a result, in version 2.0.alpha, GP could end up believing
the screen was 0 columns wide. As a lesser evil, he would then proceed to print
help messages with only one word per line (reported by G. Niklasch).

* This patch sets the terminal size correctly. This is achieved first
by an ioctl() call, then a look at $ROW / $COLUMN environment variables, 
then relying on a default 80 x 20 if nothing sensible came up.

*** src/gp/gp.c.orig	Fri Nov 14 04:53:34 1997
--- src/gp/gp.c	Mon Nov 17 13:26:14 1997
***************
*** 1381,1410 ****
    return (strcmp (*s1, *s2));
  }
  
! #define MAX_TERM_WIDTH 255
! #define DFT_TERM_WIDTH  80
! #define DFT_TERM_HEIGHT 20
! 
! static long
! term_width()
  { 
  #ifdef HAS_TIOCGWINSZ
    struct winsize s;
    if (!under_emacs && !ioctl(0, TIOCGWINSZ, &s)) return s.ws_col;
  #endif
!   return DFT_TERM_WIDTH;
  }
  
! static long
! term_height()
  { 
  #ifdef HAS_TIOCGWINSZ
    struct winsize s;
    if (!under_emacs && !ioctl(0, TIOCGWINSZ, &s)) return s.ws_row;
  #endif
!   return DFT_TERM_HEIGHT;
  }
  
  /* Print all elements of list in columns, pausing every nbli lines
   * if nbli is non-zero.
   *
--- 1381,1432 ----
    return (strcmp (*s1, *s2));
  }
  
! static int
! term_width_intern()
  { 
+   char *str;
  #ifdef HAS_TIOCGWINSZ
    struct winsize s;
    if (!under_emacs && !ioctl(0, TIOCGWINSZ, &s)) return s.ws_col;
  #endif
! #ifdef UNIX
!   if ((str = getenv("COLUMNS"))) return atoi(str);
! #endif
!   return 0;
  }
  
! static int
! term_height_intern()
  { 
+   char *str;
  #ifdef HAS_TIOCGWINSZ
    struct winsize s;
    if (!under_emacs && !ioctl(0, TIOCGWINSZ, &s)) return s.ws_row;
  #endif
! #ifdef UNIX
!   if ((str = getenv("ROWS"))) return atoi(str);
! #endif
!   return 0;
  }
  
+ #define MAX_TERM_WIDTH 255
+ #define DFT_TERM_WIDTH  80
+ #define DFT_TERM_HEIGHT 20
+ 
+ static int
+ term_width()
+ {
+   int n = term_width_intern();
+   return (n>1)? n: DFT_TERM_WIDTH;
+ }
+ 
+ static int
+ term_height()
+ {
+   int n = term_height_intern();
+   return (n>1)? n: DFT_TERM_HEIGHT;
+ }
+ 
  /* Print all elements of list in columns, pausing every nbli lines
   * if nbli is non-zero.
   *
--
Karim Belabas                          e-mail:
Max-Planck-Institut fuer Mathematik       karim@mpim-bonn.mpg.de
Gottfried-Claren-Str. 26               tel:
53225 Bonn (Germany)                      (00 49 228) 402-245