chris@umcp-cs.UUCP (07/04/83)
Naturally, there was a bug in the source I distributed. The 'Wsize' function could generate garbage in the newly-expanded window. I thought I had fixed that, but it turned out I was fixing the wrong thing, which wasn't really broken. Here's a corrected version of size.c, with the real bug really fixed (honest, I tested it). - Chris : Run this shell script with "sh" not "csh" PATH=:/bin:/usr/bin:/usr/ucb export PATH all=FALSE if [ $1x = -ax ]; then all=TRUE fi /bin/echo 'Extracting size.c' /bin/echo ' (window-expansion bug fixed)' sed 's/^X//' <<'//go.sysin dd *' >size.c X#include "win.h" X#include "display.h" X X/* Copyright (c) 1983 University of Maryland Computer Science Department */ X X/* Change the size of an existing window */ XWsize (w, xext, yext) Xregister Win *w; Xregister xext, yext; X{ X register Buf *b; X register Ch *c; X X if (xext < 1 || yext < 1) X return -1; X if (w -> OXO + xext > ScreenWidth || w -> OYO + yext > ScreenLength) X return -1; X b = w -> w_textbuf; X if (b -> b_ncols < xext || b -> b_nrows < yext) { X if (Wsetbuf (w, xext, yext)) X return -1; X } X if ((w -> w_status & WHIDDEN) == 0) { X WErase (w); /* Erase visible portions */ X WRemoveCoverList (w); /* Uncover everything */ X } X X /* Get new winbuf */ X c = (Ch *) malloc (sizeof (Ch) * xext * yext); X if (c == 0) { X if ((w -> w_status & WHIDDEN) == 0) X WComputeCover (w); X return -1; X } X free (w -> w_winbuf); X w -> w_winbuf = c; X w -> w_outside.xextent = xext; /* Change size */ X w -> w_outside.yextent = yext; X X /* If the window has grown such that the bottom of the winbuf sticks X out over the bottom of the textbuf, it must be moved upward. The X distance to be moved is [real_bstart - max_bstart], or, in the y X direction, [w -> w_bstart.row - (b -> b_nrows - yext)]. */ X if (w -> w_bstart.row + yext > b -> b_nrows) { X /* Want cursor to stick to buffer, so must move down X relative to window */ X w -> w_cursor.row += w -> w_bstart.row - b -> b_nrows + yext; X w -> w_bstart.row = b -> b_nrows - yext;/* max_bstart.row */ X MajorUpdate = 1; X } X /* Similarly for the x direction */ X if (w -> w_bstart.col + xext > b -> b_ncols) { X w -> w_cursor.col += w -> w_bstart.col - b -> b_ncols + xext; X w -> w_bstart.col = b -> b_ncols - xext;/* max_bstart.col */ X } X X /* Make inside whole thing (sigh) */ X for (c = w -> w_winbuf + xext * yext; c > w -> w_winbuf;) X (--c) -> ch_all = ' ' | (WBUF<<NBPB); X WFixCursor (w); X if ((w -> w_status & WHIDDEN) == 0) X WComputeCover (w); /* Recompute cover with new size */ X return Wsetmargins (w, 0, 0, xext, yext); X} //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 size.c /bin/echo -n ' '; /bin/ls -ld size.c fi -- UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris.umcp-cs@UDel-Relay