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