Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

setting window size



-----BEGIN PGP SIGNED MESSAGE-----

On some systems, in some circumstances, TIOCGWINSZ will return values
of zero for the window size.  Bits of zsh don't currently handle that
properly, and can divide by zero.  This patch fixes that.

The calls to setintenv() are replaced by setiparam().  I don't see what
the point of setintenv() was, actually: it wasn't used for anything
else, and wouldn't do anything if the parameters weren't exported.
setiparam() itself is also changed, to call the sets.ifn() method,
as it always should have done.  (This was the only function bypassing
this mechanism.)  The proper setting of columns and lines in init.c is
delegated to adjustwinsize().

 -zefram

      *** Src/init.c	1997/03/29 23:35:55	1.48
      --- Src/init.c	1997/03/30 18:42:50
      ***************
      *** 518,530 ****
            createnameddirtable();  /* create hash table for named directories */
            createparamtable();     /* create paramater hash table             */
        
      - #ifdef TIOCGWINSZ
      -     setintenv("COLUMNS", shttyinfo.winsize.ws_col);
      -     setintenv("LINES", shttyinfo.winsize.ws_row);
      - #else
            columns = 80;
            lines = 24;
      ! #endif
        
        #ifdef HAVE_GETRLIMIT
            for (i = 0; i != RLIM_NLIMITS; i++) {
      --- 518,526 ----
            createnameddirtable();  /* create hash table for named directories */
            createparamtable();     /* create paramater hash table             */
        
            columns = 80;
            lines = 24;
      !     adjustwinsize();
        
        #ifdef HAVE_GETRLIMIT
            for (i = 0; i != RLIM_NLIMITS; i++) {
      ***************
      *** 684,690 ****
        
            if (interact && isset(RCS))
        	readhistfile(getsparam("HISTFILE"), 0);
      -     adjustwinsize();   /* check window size and adjust if necessary */
        }
        
        /* source a file */
      --- 680,685 ----
      *** Src/params.c	1997/03/30 00:49:16	1.42
      --- Src/params.c	1997/03/30 18:19:28
      ***************
      *** 881,900 ****
        
        /**/
        void
      - setintenv(char *s, long val)
      - {
      -     Param pm;
      -     char buf[DIGBUFSIZE];
      - 
      -     if ((pm = (Param) paramtab->getnode(paramtab, s)) && pm->env) {
      - 	(pm->sets.ifn)(pm, val);
      - 	sprintf(buf, "%ld", val);
      - 	pm->env = replenv(pm->env, buf);
      -     }
      - }
      - 
      - /**/
      - void
        setarrvalue(Value v, char **val)
        {
            if (v->pm->flags & PM_READONLY) {
      --- 881,886 ----
      ***************
      *** 1085,1091 ****
            if (!(v = getvalue(&s, 1))) {
        	pm = createparam(t, PM_INTEGER);
        	DPUTS(!pm, "BUG: parameter not created");
      ! 	pm->u.val = val;
        	return pm;
            }
            setintvalue(v, val);
      --- 1071,1077 ----
            if (!(v = getvalue(&s, 1))) {
        	pm = createparam(t, PM_INTEGER);
        	DPUTS(!pm, "BUG: parameter not created");
      ! 	pm->sets.ifn(pm, val);
        	return pm;
            }
            setintvalue(v, val);
      *** Src/utils.c	1997/03/27 01:57:52	1.70
      --- Src/utils.c	1997/03/30 18:43:10
      ***************
      *** 787,805 ****
        	return;
        
            ioctl(SHTTY, TIOCGWINSZ, (char *)&shttyinfo.winsize);
      !     if (shttyinfo.winsize.ws_col)
      ! 	columns = shttyinfo.winsize.ws_col;
      !     if (shttyinfo.winsize.ws_row)
      ! 	lines = shttyinfo.winsize.ws_row;
      !     if (oldcols != columns || oldrows != lines) {
      ! 	if (oldcols != columns)
      ! 	    setintenv("COLUMNS", columns);
      ! 	if (oldrows != lines)
      ! 	    setintenv("LINES", lines);
      ! 	if (zleactive) {
      ! 	    resetneeded = winchanged = 1;
      ! 	    refresh();
      ! 	}
            }
        #endif   /*  TIOCGWINSZ */
            if (isset(SINGLELINEZLE) || termflags || lines < 3) /* safety */
      --- 787,799 ----
        	return;
        
            ioctl(SHTTY, TIOCGWINSZ, (char *)&shttyinfo.winsize);
      !     HEAPALLOC {
      ! 	setiparam("COLUMNS", shttyinfo.winsize.ws_col);
      ! 	setiparam("LINES", shttyinfo.winsize.ws_row);
      !     } LASTALLOC;
      !     if (zleactive && (oldcols != columns || oldrows != lines)) {
      ! 	resetneeded = winchanged = 1;
      ! 	refresh();
            }
        #endif   /*  TIOCGWINSZ */
            if (isset(SINGLELINEZLE) || termflags || lines < 3) /* safety */

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: ascii

iQCVAwUBMz62i3D/+HJTpU/hAQFzNAQAimzPO92wmayRrgPwWxPLRlRl9buvxrpE
FKn5NNFvHK/OlQX/LnEMVaNY5AOtyZqgFKJODpa9AHn/upuosO/yRIBDTHy61jcn
CJZe+EXiA27ITUZbhaRIabIPuJ9hoABe7IWZktw4FZvVbE81L3I7fVPPJQs4L8aq
SyAc6sRg1Pc=
=YE0D
-----END PGP SIGNATURE-----



Messages sorted by: Reverse Date, Date, Thread, Author