Ignore machine-check MSRs
[freebsd-src/fkvm-freebsd.git] / usr.bin / window / wwdelete.c
blobef2912b16995e744bfa26b239657d77e4f126c1e
1 /*
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
10 * are met:
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
34 * SUCH DAMAGE.
37 #ifndef lint
38 static char sccsid[] = "@(#)wwdelete.c 8.1 (Berkeley) 6/6/93";
39 static char rcsid[] =
40 "$FreeBSD$";
41 #endif /* not lint */
43 #include "ww.h"
46 * Pull w free from the cover list.
48 wwdelete(w)
49 register struct ww *w;
51 register i;
53 for (i = w->ww_i.t; i < w->ww_i.b; i++) {
54 register j;
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) {
61 smap[j] = WWX_NOBODY;
62 ns[j].c_w = ' ';
63 nchanged++;
65 if (nchanged > 0)
66 wwtouched[i] |= WWU_TOUCHED;
70 register struct ww *wp;
72 for (wp = w->ww_forw; wp != &wwhead; wp = wp->ww_forw)
73 wp->ww_order--;
76 if (w->ww_forw != &wwhead)
77 wwdelete1(w->ww_forw,
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;
88 int i;
89 int tt, bb, ll, rr;
90 char hasglass;
92 again:
93 hasglass = 0;
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)
100 return;
101 goto again;
103 for (i = tt; i < bb; i++) {
104 register j;
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];
110 int nchanged = 0;
112 for (j = ll; j < rr; j++) {
113 if (smap[j] != WWX_NOBODY)
114 continue;
115 if (win[j] & WWM_GLS) {
116 hasglass = 1;
117 continue;
119 smap[j] = w->ww_index;
120 ns[j].c_w = buf[j].c_w ^ win[j] << WWC_MSHIFT;
121 nchanged++;
122 if (win[j] == 0)
123 nvis++;
125 if (nchanged > 0)
126 wwtouched[i] |= WWU_TOUCHED;
127 w->ww_nvis[i] = nvis;
129 if ((w = w->ww_forw) == &wwhead)
130 return;
131 if (hasglass)
132 goto again;
133 if (tt > t)
134 wwdelete1(w, t, tt, l, r);
135 if (bb < b)
136 wwdelete1(w, bb, b, l, r);
137 if (ll > l)
138 wwdelete1(w, tt, bb, l, ll);
139 if (rr < r)
140 wwdelete1(w, tt, bb, rr, r);