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