added "more" command
[unix-history] / usr / src / usr.bin / window / wwinschar.c
index a3b0cf8..9fa6fd7 100644 (file)
@@ -1,7 +1,13 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwinschar.c 3.9 83/09/15";
+static char sccsid[] = "@(#)wwinschar.c        3.14 %G%";
 #endif
 
 #endif
 
+/*
+ * Copyright (c) 1983 Regents of the University of California,
+ * All rights reserved.  Redistribution permitted subject to
+ * the terms of the Berkeley Software License Agreement.
+ */
+
 #include "ww.h"
 #include "tt.h"
 
 #include "ww.h"
 #include "tt.h"
 
@@ -43,36 +49,33 @@ short c;
                register char *win;
                register union ww_char *ns;
                register char *smap;
                register char *win;
                register union ww_char *ns;
                register char *smap;
-               char *touched;
+               char touched;
 
                nvis = 0;
                smap = &wwsmap[row][col];
 
                nvis = 0;
                smap = &wwsmap[row][col];
-               for (i = w->ww_i.r - col; i > 0 && *smap++ != w->ww_index; i--)
-                       col++;
-               if (i <= 0)
+               for (i = col; i < w->ww_i.r && *smap++ != w->ww_index; i++)
+                       ;
+               if (i >= w->ww_i.r)
                        return;
                        return;
-               buf = &w->ww_buf[row][col];
-               win = &w->ww_win[row][col];
-               ns = &wwns[row][col];
-               touched = &wwtouched[row];
-               c = buf->c_w ^ *win << WWC_MSHIFT;
-               for (; --i >= 0;) {
-                       if (*win) {
-                               if ((*win & (WWM_COV|WWM_GLS)) != 0) {
-                                       ns++;
-                                       buf++;
-                               } else {
-                                       *touched = 1;
-                                       ns++->c_w = buf++->c_w
-                                               ^ *win++ << WWC_MSHIFT;
-                               }
-                       } else {
-                               *touched = 1;
-                               *ns++ = *buf++;
-                               win++;
+               col = i;
+               buf = w->ww_buf[row];
+               win = w->ww_win[row];
+               ns = wwns[row];
+               smap = &wwsmap[row][i];
+               touched = wwtouched[row];
+               for (; i < w->ww_i.r; i++) {
+                       if (*smap++ != w->ww_index)
+                               continue;
+                       touched |= WWU_TOUCHED;
+                       if (win[i])
+                               ns[i].c_w =
+                                       buf[i].c_w ^ win[i] << WWC_MSHIFT;
+                       else {
                                nvis++;
                                nvis++;
+                               ns[i] = buf[i];
                        }
                }
                        }
                }
+               wwtouched[row] = touched;
        }
 
        /*
        }
 
        /*