.Xr botch fix
[unix-history] / usr / src / usr.bin / window / wwlabel.c
index 7dbef97..2a90ee6 100644 (file)
@@ -1,8 +1,19 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Edward Wang at The University of California, Berkeley.
+ *
+ * %sccs.include.redist.c%
+ */
+
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwlabel.c   3.7 83/09/15";
-#endif
+static char sccsid[] = "@(#)wwlabel.c  3.17 (Berkeley) %G%";
+#endif /* not lint */
 
 #include "ww.h"
 
 #include "ww.h"
+#include "char.h"
 
 /*
  * Label window w on f,
 
 /*
  * Label window w on f,
@@ -14,50 +25,46 @@ struct ww *w;
 struct ww *f;
 char *l;
 {
 struct ww *f;
 char *l;
 {
-       int i;
+       int row;
        register j;
        register j;
-       register char *p;
+       int jj;
        register char *win;
        register union ww_char *buf;
        register union ww_char *ns;
        register char *fmap;
        register char *win;
        register union ww_char *buf;
        register union ww_char *ns;
        register char *fmap;
-       char *touched;
+       register char *smap;
+       char touched;
+       char *p;
 
        if (f->ww_fmap == 0)
                return;
 
 
        if (f->ww_fmap == 0)
                return;
 
-       i = w->ww_w.t - 1;
-       if (i < f->ww_i.t || i >= f->ww_i.b)
+       row = w->ww_w.t - 1;
+       if (row < f->ww_i.t || row >= f->ww_i.b)
                return;
                return;
-       j = w->ww_i.l + where;
-       win = &f->ww_win[i][j];
-       buf = &f->ww_buf[i][j];
-       fmap = &f->ww_fmap[i][j];
-
-       ns = &wwns[i][j];
-       touched = &wwtouched[i];
+       win = f->ww_win[row];
+       buf = f->ww_buf[row];
+       fmap = f->ww_fmap[row];
+       ns = wwns[row];
+       smap = wwsmap[row];
+       touched = wwtouched[row];
+       mode <<= WWC_MSHIFT;
 
 
-       j = MIN(w->ww_i.r, f->ww_i.r) - j;
-       for (; j > 0 && *l;)
-               for (p = unctrl(*l++); j > 0 && *p; j--) {
+       jj = MIN(w->ww_i.r, f->ww_i.r);
+       j = w->ww_i.l + where;
+       while (j < jj && *l)
+               for (p = unctrl(*l++); j < jj && *p; j++, p++) {
                        /* can't label if not already framed */
                        /* can't label if not already framed */
-                       if (*win & WWM_GLS) {
-                               p++;
-                               buf++;
-                               ns++;
-                               win++;
-                               fmap++;
-                       } else if (*win & WWM_COV) {
-                               buf++->c_w = mode << WWC_MSHIFT | *p++;
-                               *fmap++ |= WWF_LABEL;
-                               ns++;
-                               win++;
-                       } else {
-                               *touched = 1;
-                               ns++->c_w = (buf++->c_w
-                                       = mode << WWC_MSHIFT | *p++)
-                                               ^ *win++ << WWC_MSHIFT;
-                               *fmap++ |= WWF_LABEL;
+                       if (win[j] & WWM_GLS)
+                               continue;
+                       if (smap[j] != f->ww_index)
+                               buf[j].c_w = mode | *p;
+                       else {
+                               ns[j].c_w = (buf[j].c_w = mode | *p)
+                                               ^ win[j] << WWC_MSHIFT;
+                               touched |= WWU_TOUCHED;
                        }
                        }
+                       fmap[j] |= WWF_LABEL;
                }
                }
+       wwtouched[row] = touched;
 }
 }