Commit | Line | Data |
---|---|---|
46285cba | 1 | #ifndef lint |
7edc52ec | 2 | static char sccsid[] = "@(#)error.c 3.11 %G%"; |
46285cba EW |
3 | #endif |
4 | ||
5 | #include "defs.h" | |
1c0ca238 EW |
6 | #include "value.h" |
7 | #include "context.h" | |
0e64e422 | 8 | #include "char.h" |
46285cba | 9 | |
bb94cfe3 | 10 | #define ERRLINES 10 /* number of lines for errwin */ |
46285cba EW |
11 | |
12 | /*VARARGS1*/ | |
13 | error(fmt, a, b, c, d, e, f, g, h) | |
14 | char *fmt; | |
15 | { | |
bb4a0c0b | 16 | register struct context *x; |
3b06703c EW |
17 | register struct ww *w; |
18 | ||
bb4a0c0b EW |
19 | for (x = &cx; x != 0 && x->x_type != X_FILE; x = x->x_link) |
20 | ; | |
21 | if (x == 0) { | |
46285cba | 22 | if (terse) |
7ecf4dca | 23 | wwbell(); |
46285cba | 24 | else { |
b1189050 EW |
25 | wwprintf(cmdwin, fmt, a, b, c, d, e, f, g, h); |
26 | wwputs(" ", cmdwin); | |
46285cba EW |
27 | } |
28 | return; | |
29 | } | |
bb4a0c0b | 30 | if (x->x_noerr) |
46285cba | 31 | return; |
bb4a0c0b | 32 | if ((w = x->x_errwin) == 0) { |
46285cba EW |
33 | char buf[512]; |
34 | ||
bb4a0c0b EW |
35 | (void) sprintf(buf, "Errors from %s", x->x_filename); |
36 | if ((w = x->x_errwin = openiwin(ERRLINES, buf)) == 0) { | |
b1189050 | 37 | wwputs("Can't open error window. ", cmdwin); |
bb4a0c0b | 38 | x->x_noerr = 1; |
46285cba EW |
39 | return; |
40 | } | |
46285cba | 41 | } |
4a972f7c | 42 | if (more(w, 0) == 2) { |
bb4a0c0b | 43 | x->x_noerr = 1; |
4a972f7c EW |
44 | return; |
45 | } | |
bb4a0c0b | 46 | wwprintf(w, "line %d: ", x->x_lineno); |
b1189050 EW |
47 | wwprintf(w, fmt, a, b, c, d, e, f, g, h); |
48 | wwputc('\n', w); | |
46285cba EW |
49 | } |
50 | ||
1c0ca238 | 51 | err_end() |
46285cba | 52 | { |
bb4a0c0b | 53 | if (cx.x_type == X_FILE && cx.x_errwin != 0) { |
4a972f7c EW |
54 | if (!cx.x_noerr) |
55 | waitnl(cx.x_errwin); | |
1c0ca238 EW |
56 | closeiwin(cx.x_errwin); |
57 | cx.x_errwin = 0; | |
46285cba | 58 | } |
46285cba | 59 | } |