Commit | Line | Data |
---|---|---|
60de5df9 | 1 | /* |
46e9ea25 KB |
2 | * Copyright (c) 1983 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
3dd3a9e5 KB |
5 | * This code is derived from software contributed to Berkeley by |
6 | * Edward Wang at The University of California, Berkeley. | |
7 | * | |
87f529ec | 8 | * %sccs.include.redist.c% |
60de5df9 EW |
9 | */ |
10 | ||
46e9ea25 | 11 | #ifndef lint |
3dd3a9e5 | 12 | static char sccsid[] = "@(#)error.c 3.16 (Berkeley) %G%"; |
46e9ea25 KB |
13 | #endif /* not lint */ |
14 | ||
46285cba | 15 | #include "defs.h" |
1c0ca238 EW |
16 | #include "value.h" |
17 | #include "context.h" | |
0e64e422 | 18 | #include "char.h" |
46285cba | 19 | |
bb94cfe3 | 20 | #define ERRLINES 10 /* number of lines for errwin */ |
46285cba EW |
21 | |
22 | /*VARARGS1*/ | |
23 | error(fmt, a, b, c, d, e, f, g, h) | |
24 | char *fmt; | |
25 | { | |
bb4a0c0b | 26 | register struct context *x; |
3b06703c EW |
27 | register struct ww *w; |
28 | ||
bb4a0c0b EW |
29 | for (x = &cx; x != 0 && x->x_type != X_FILE; x = x->x_link) |
30 | ; | |
31 | if (x == 0) { | |
46285cba | 32 | if (terse) |
7ecf4dca | 33 | wwbell(); |
46285cba | 34 | else { |
b1189050 EW |
35 | wwprintf(cmdwin, fmt, a, b, c, d, e, f, g, h); |
36 | wwputs(" ", cmdwin); | |
46285cba EW |
37 | } |
38 | return; | |
39 | } | |
bb4a0c0b | 40 | if (x->x_noerr) |
46285cba | 41 | return; |
bb4a0c0b | 42 | if ((w = x->x_errwin) == 0) { |
46285cba EW |
43 | char buf[512]; |
44 | ||
bb4a0c0b EW |
45 | (void) sprintf(buf, "Errors from %s", x->x_filename); |
46 | if ((w = x->x_errwin = openiwin(ERRLINES, buf)) == 0) { | |
b1189050 | 47 | wwputs("Can't open error window. ", cmdwin); |
bb4a0c0b | 48 | x->x_noerr = 1; |
46285cba EW |
49 | return; |
50 | } | |
46285cba | 51 | } |
4a972f7c | 52 | if (more(w, 0) == 2) { |
bb4a0c0b | 53 | x->x_noerr = 1; |
4a972f7c EW |
54 | return; |
55 | } | |
bb4a0c0b | 56 | wwprintf(w, "line %d: ", x->x_lineno); |
b1189050 EW |
57 | wwprintf(w, fmt, a, b, c, d, e, f, g, h); |
58 | wwputc('\n', w); | |
46285cba EW |
59 | } |
60 | ||
1c0ca238 | 61 | err_end() |
46285cba | 62 | { |
bb4a0c0b | 63 | if (cx.x_type == X_FILE && cx.x_errwin != 0) { |
4a972f7c EW |
64 | if (!cx.x_noerr) |
65 | waitnl(cx.x_errwin); | |
1c0ca238 EW |
66 | closeiwin(cx.x_errwin); |
67 | cx.x_errwin = 0; | |
46285cba | 68 | } |
46285cba | 69 | } |