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