+ {
+ register char *t1 = wwtouched + top, *t2 = wwtouched + bot;
+ register n;
+
+ while (!*t1++)
+ if (t1 == t2)
+ return;
+ while (!*--t2)
+ ;
+ scan_top = top = t1 - wwtouched - 1;
+ scan_bot = bot = t2 - wwtouched + 1;
+ if (scan_bot - scan_top > 1 &&
+ (tt.tt_clreos != 0 || tt.tt_clear != 0)) {
+ int st = tt.tt_clreos != 0 ? scan_top : 0;
+
+ /*
+ * t1 is one past the first touched row,
+ * t2 is on the last touched row.
+ */
+ for (t1--, n = 1; t1 < t2;)
+ if (*t1++)
+ n++;
+ /*
+ * If we can't clreos then we try for clearing
+ * the whole screen.
+ */
+ if (check_clreos = n * 10 > (wwnrow - st) * 9) {
+ scan_top = st;
+ scan_bot = wwnrow;
+ }
+ }
+ }
+ if (tt.tt_clreol == 0 && !check_clreos)
+ goto simple;
+ for (i = scan_top, touched = &wwtouched[i], upd = &wwupd[i];
+ i < scan_bot;
+ i++, touched++, upd++) {
+ register gain = 0;
+ register best_gain = 0;
+ register best_col;
+ register union ww_char *ns, *os;
+
+ if (wwinterrupt())
+ return;
+ if (!check_clreos && !*touched)