[comp.windows.x] fix for resize

sources@GLACIER.ICS.UCI.EDU (ICS Sources, agent: Gary Scott Erickson) (03/22/89)

			  X Window System Bug Report
			    xbugs@expo.lcs.mit.edu




VERSION:
    R3

CLIENT MACHINE and OPERATING SYSTEM:
    Sequent Symmetry
    DYNIX(R) V3.0.12 NFS

DISPLAY:
    all

WINDOW MANAGER:
    all

AREA:
    xterm

SYNOPSIS:
    resize core dumps if rows or columns of tty are zero.

DESCRIPTION:
    If the tty is set up so that the rows or columns are zero,
    then the appropriate value should be grabbed from the TERMCAP
    entry.  resize does not check this.

REPEAT BY:
    Set your tty to have zero columns or zero rows.  (We have a
	program to do this on our Sequents.  Or, you can try
	stty(1).)
    Type (to csh) "set noglob; eval `resize`"
    Watch the core dump.

SAMPLE FIX:
*** clients/xterm/_resize.c	Tue Sep  6 14:08:31 1988
--- clients/xterm/resize.c	Tue Mar 21 09:27:55 1989
***************
*** 328,333
  	       our best by computing the font height and width from the "old"
  	       struct winsize values, and multiplying by these ratios...*/
  	    if (ws.ws_xpixel != 0)
  	        ws.ws_xpixel = cols * (ws.ws_xpixel / ws.ws_col);
  	    if (ws.ws_ypixel != 0)
  	        ws.ws_ypixel = rows * (ws.ws_ypixel / ws.ws_row);

--- 328,337 -----
  	       our best by computing the font height and width from the "old"
  	       struct winsize values, and multiplying by these ratios...*/
  	    if (ws.ws_xpixel != 0)
+ #ifdef USE_TERMCAP
+                 if (ws.ws_col == 0 && (ws.ws_col = tgetnum("co")) <= 0)
+ 		    ws.ws_col = 1;	/* give it a safe value */
+ #endif /* USE_TERMCAP */
  	        ws.ws_xpixel = cols * (ws.ws_xpixel / ws.ws_col);
  	    if (ws.ws_ypixel != 0)
  #ifdef USE_TERMCAP
***************
*** 330,335
  	    if (ws.ws_xpixel != 0)
  	        ws.ws_xpixel = cols * (ws.ws_xpixel / ws.ws_col);
  	    if (ws.ws_ypixel != 0)
  	        ws.ws_ypixel = rows * (ws.ws_ypixel / ws.ws_row);
  	    ws.ws_row = rows;
  	    ws.ws_col = cols;

--- 334,343 -----
  #endif /* USE_TERMCAP */
  	        ws.ws_xpixel = cols * (ws.ws_xpixel / ws.ws_col);
  	    if (ws.ws_ypixel != 0)
+ #ifdef USE_TERMCAP
+                 if (ws.ws_row == 0 && (ws.ws_row = tgetnum("li")) <= 0)
+ 		    ws.ws_row = 1;	/* give it a safe value */
+ #endif /* USE_TERMCAP */
  	        ws.ws_ypixel = rows * (ws.ws_ypixel / ws.ws_row);
  	    ws.ws_row = rows;
  	    ws.ws_col = cols;