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