- smap = &wwsmap[srow][scol];
- s = &wwns[srow][scol];
- touched = &wwtouched[srow];
- win = &w->ww_win[row][col];
- buf = &w->ww_buf[line][col];
- ncleared = nblank = 0;
- for (i = w->ww_w.nc - col; --i >= 0;) {
- buf++->c_w = ' ';
- if (*smap++ != w->ww_index) {
- if (s++->c_w == ' ')
+
+ /*
+ * If can't see it, just return.
+ */
+ if (srow < w->ww_i.t || srow >= w->ww_i.b
+ || w->ww_i.r <= 0 || w->ww_i.r <= scol)
+ return;
+
+ if (scol < w->ww_i.l)
+ scol = w->ww_i.l;
+ col = scol - w->ww_w.l;
+
+ /*
+ * Now find out how much is actually cleared, and fix wwns.
+ */
+ {
+ register union ww_char *s;
+ register char *smap, *win;
+ register char *touched;
+
+ smap = &wwsmap[srow][scol];
+ s = &wwns[srow][scol];
+ touched = &wwtouched[srow];
+ win = &w->ww_win[row][col];
+ ncleared = nblank = 0;
+
+ for (i = w->ww_i.r - scol; --i >= 0;) {
+ if (*smap++ != w->ww_index) {
+ if (s++->c_w == ' ')
+ nblank++;
+ win++;
+ continue;
+ }
+ ncleared++;
+ *touched = 1;
+ if (*win == 0) {