Commit | Line | Data |
---|---|---|
46285cba EW |
1 | #ifndef lint |
2 | static char *sccsid = "@(#)error.c 1.1 83/07/28"; | |
3 | #endif | |
4 | ||
5 | #include "defs.h" | |
6 | ||
7 | struct ww *openwin(); | |
8 | ||
9 | extern int lineno; /* line number in source file */ | |
10 | ||
11 | static char *filename; /* source file name */ | |
12 | static struct ww *errwin; /* window for error reporting */ | |
13 | static int errlineno; /* lineno in errwin */ | |
14 | static char baderror; /* can't open the error window */ | |
15 | ||
16 | #define ERRLINES 10 /* number of lines in errwin */ | |
17 | ||
18 | /*VARARGS1*/ | |
19 | error(fmt, a, b, c, d, e, f, g, h) | |
20 | char *fmt; | |
21 | { | |
22 | if (filename == 0) { | |
23 | if (terse) | |
24 | Ding(); | |
25 | else { | |
26 | wwprintf(cmdwin, fmt, a, b, c, d, e, f, g, h); | |
27 | wwputs(" ", cmdwin); | |
28 | } | |
29 | return; | |
30 | } | |
31 | if (baderror) | |
32 | return; | |
33 | if (errwin == 0) { | |
34 | char buf[512]; | |
35 | ||
36 | (void) sprintf(buf, "Errors from %s", filename); | |
37 | if ((errwin = openwin(ERRLINES, buf)) == 0) { | |
38 | wwprintf(cmdwin, "Can't open error window. "); | |
39 | baderror++; | |
40 | return; | |
41 | } | |
42 | errlineno = 0; | |
43 | } | |
44 | if (errlineno++ > ERRLINES - 4) { | |
45 | waitnl(errwin); | |
46 | errlineno = 0; | |
47 | } | |
48 | if (lineno != 0) | |
49 | wwprintf(errwin, "line %d: ", lineno); | |
50 | wwprintf(errwin, fmt, a, b, c, d, e, f, g, h); | |
51 | wwprintf(errwin, "\r\n"); | |
52 | } | |
53 | ||
54 | beginerror(fn) | |
55 | char *fn; | |
56 | { | |
57 | filename = fn; | |
58 | } | |
59 | ||
60 | enderror() | |
61 | { | |
62 | if (errwin != 0) { | |
63 | waitnl(errwin); | |
64 | closewin(errwin); | |
65 | errwin = 0; | |
66 | } | |
67 | baderror = 0; | |
68 | filename = 0; | |
69 | } |