stdio.h defines BUFSIZ
[unix-history] / usr / src / usr.bin / window / wwadd.c
... / ...
CommitLineData
1/*
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Edward Wang at The University of California, Berkeley.
7 *
8 * %sccs.include.redist.c%
9 */
10
11#ifndef lint
12static char sccsid[] = "@(#)wwadd.c 3.14 (Berkeley) %G%";
13#endif /* not lint */
14
15#include "ww.h"
16
17/*
18 * Stick w1 behind w2.
19 */
20wwadd(w1, w2)
21register struct ww *w1;
22struct ww *w2;
23{
24 register i;
25 register struct ww *w;
26
27 w1->ww_order = w2->ww_order + 1;
28 w1->ww_back = w2;
29 w1->ww_forw = w2->ww_forw;
30 w2->ww_forw->ww_back = w1;
31 w2->ww_forw = w1;
32
33 for (w = w1->ww_forw; w != &wwhead; w = w->ww_forw)
34 w->ww_order++;
35 for (i = w1->ww_i.t; i < w1->ww_i.b; i++) {
36 register j;
37 register char *smap = wwsmap[i];
38 register char *win = w1->ww_win[i];
39 union ww_char *ns = wwns[i];
40 union ww_char *buf = w1->ww_buf[i];
41 int nvis = 0;
42 int nchanged = 0;
43
44 for (j = w1->ww_i.l; j < w1->ww_i.r; j++) {
45 w = wwindex[smap[j]];
46 if (w1->ww_order > w->ww_order)
47 continue;
48 if (win[j] & WWM_GLS)
49 continue;
50 if (w != &wwnobody && w->ww_win[i][j] == 0)
51 w->ww_nvis[i]--;
52 smap[j] = w1->ww_index;
53 if (win[j] == 0)
54 nvis++;
55 ns[j].c_w = buf[j].c_w ^ win[j] << WWC_MSHIFT;
56 nchanged++;
57 }
58 if (nchanged > 0)
59 wwtouched[i] |= WWU_TOUCHED;
60 w1->ww_nvis[i] = nvis;
61 }
62}