Commit | Line | Data |
---|---|---|
60de5df9 | 1 | /* |
ad787160 C |
2 | * Copyright (c) 1983, 1993 |
3 | * The Regents of the University of California. All rights reserved. | |
46e9ea25 | 4 | * |
3dd3a9e5 KB |
5 | * This code is derived from software contributed to Berkeley by |
6 | * Edward Wang at The University of California, Berkeley. | |
7 | * | |
c0567266 KB |
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. | |
23 | * | |
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. | |
60de5df9 EW |
35 | */ |
36 | ||
46e9ea25 | 37 | #ifndef lint |
ad787160 | 38 | static char sccsid[] = "@(#)mloop.c 8.1 (Berkeley) 6/6/93"; |
46e9ea25 KB |
39 | #endif /* not lint */ |
40 | ||
45723d81 | 41 | #include <sys/param.h> |
3e02121b EW |
42 | #include "defs.h" |
43 | ||
44 | mloop() | |
45 | { | |
3e02121b | 46 | while (!quit) { |
ffa20db4 | 47 | if (incmd) { |
3e02121b | 48 | docmd(); |
b1189050 | 49 | } else if (wwcurwin->ww_state != WWS_HASPROC) { |
2422abab EW |
50 | if (!wwcurwin->ww_keepopen) |
51 | closewin(wwcurwin); | |
ffa20db4 | 52 | setcmd(1); |
b1189050 EW |
53 | if (wwpeekc() == escapec) |
54 | (void) wwgetc(); | |
55 | error("Process died."); | |
56 | } else { | |
3fdb475b | 57 | register struct ww *w = wwcurwin; |
b1189050 EW |
58 | register char *p; |
59 | register n; | |
60 | ||
2c279448 EW |
61 | if (wwibp >= wwibq) |
62 | wwiomux(); | |
21e9e78d | 63 | for (p = wwibp; p < wwibq && wwmaskc(*p) != escapec; |
2c279448 EW |
64 | p++) |
65 | ; | |
66 | if ((n = p - wwibp) > 0) { | |
67 | if (!w->ww_ispty && w->ww_stopped) | |
68 | startwin(w); | |
45723d81 CT |
69 | #if defined(sun) && !defined(BSD) |
70 | /* workaround for SunOS pty bug */ | |
0926efed EW |
71 | while (--n >= 0) |
72 | (void) write(w->ww_pty, wwibp++, 1); | |
73 | #else | |
2c279448 EW |
74 | (void) write(w->ww_pty, wwibp, n); |
75 | wwibp = p; | |
0926efed | 76 | #endif |
2c279448 EW |
77 | } |
78 | if (wwpeekc() == escapec) { | |
79 | (void) wwgetc(); | |
80 | setcmd(1); | |
3e02121b EW |
81 | } |
82 | } | |
83 | } | |
84 | } |