2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Edward Wang at The University of California, Berkeley.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 static char sccsid[] = "@(#)wwdelete.c 8.1 (Berkeley) 6/6/93";
46 * Pull w free from the cover list.
49 register struct ww *w;
53 for (i = w->ww_i.t; i < w->ww_i.b; i++) {
55 register char *smap = wwsmap[i];
56 register union ww_char *ns = wwns[i];
57 register int nchanged = 0;
59 for (j = w->ww_i.l; j < w->ww_i.r; j++)
60 if (smap[j] == w->ww_index) {
66 wwtouched[i] |= WWU_TOUCHED;
70 register struct ww *wp;
72 for (wp = w->ww_forw; wp != &wwhead; wp = wp->ww_forw)
76 if (w->ww_forw != &wwhead)
78 w->ww_i.t, w->ww_i.b, w->ww_i.l, w->ww_i.r);
80 w->ww_back->ww_forw = w->ww_forw;
81 w->ww_forw->ww_back = w->ww_back;
82 w->ww_forw = w->ww_back = 0;
85 wwdelete1(w, t, b, l, r)
86 register struct ww *w;
94 tt = MAX(t, w->ww_i.t);
95 bb = MIN(b, w->ww_i.b);
96 ll = MAX(l, w->ww_i.l);
97 rr = MIN(r, w->ww_i.r);
98 if (tt >= bb || ll >= rr) {
99 if ((w = w->ww_forw) == &wwhead)
103 for (i = tt; i < bb; i++) {
105 register char *smap = wwsmap[i];
106 register union ww_char *ns = wwns[i];
107 register char *win = w->ww_win[i];
108 register union ww_char *buf = w->ww_buf[i];
109 int nvis = w->ww_nvis[i];
112 for (j = ll; j < rr; j++) {
113 if (smap[j] != WWX_NOBODY)
115 if (win[j] & WWM_GLS) {
119 smap[j] = w->ww_index;
120 ns[j].c_w = buf[j].c_w ^ win[j] << WWC_MSHIFT;
126 wwtouched[i] |= WWU_TOUCHED;
127 w->ww_nvis[i] = nvis;
129 if ((w = w->ww_forw) == &wwhead)
134 wwdelete1(w, t, tt, l, r);
136 wwdelete1(w, bb, b, l, r);
138 wwdelete1(w, tt, bb, l, ll);
140 wwdelete1(w, tt, bb, rr, r);