114194Sedward #ifndef lint 2*16445Sedward static char *sccsid = "@(#)error.c 3.10 84/05/06"; 314194Sedward #endif 414194Sedward 514194Sedward #include "defs.h" 615580Sedward #include "value.h" 715580Sedward #include "context.h" 816309Sedward #include "char.h" 914194Sedward 1014418Sedward #define ERRLINES 10 /* number of lines for errwin */ 1114194Sedward 1214194Sedward /*VARARGS1*/ 1314194Sedward error(fmt, a, b, c, d, e, f, g, h) 1414194Sedward char *fmt; 1514194Sedward { 16*16445Sedward register struct context *x; 1715681Sedward register struct ww *w; 1815681Sedward 19*16445Sedward for (x = &cx; x != 0 && x->x_type != X_FILE; x = x->x_link) 20*16445Sedward ; 21*16445Sedward if (x == 0) { 2214194Sedward if (terse) 2316313Sedward wwbell(); 2414194Sedward else { 2516121Sedward wwprintf(cmdwin, fmt, a, b, c, d, e, f, g, h); 2616121Sedward wwputs(" ", cmdwin); 2714194Sedward } 2814194Sedward return; 2914194Sedward } 30*16445Sedward if (x->x_noerr) 3114194Sedward return; 32*16445Sedward if ((w = x->x_errwin) == 0) { 3314194Sedward char buf[512]; 3414194Sedward 35*16445Sedward (void) sprintf(buf, "Errors from %s", x->x_filename); 36*16445Sedward if ((w = x->x_errwin = openiwin(ERRLINES, buf)) == 0) { 3716121Sedward wwputs("Can't open error window. ", cmdwin); 38*16445Sedward x->x_noerr = 1; 3914194Sedward return; 4014194Sedward } 4114194Sedward } 4215857Sedward if (more(w, 0) == 2) { 43*16445Sedward x->x_noerr = 1; 4415857Sedward return; 4515857Sedward } 46*16445Sedward wwprintf(w, "line %d: ", x->x_lineno); 4716121Sedward wwprintf(w, fmt, a, b, c, d, e, f, g, h); 4816121Sedward wwputc('\n', w); 4914194Sedward } 5014194Sedward 5115580Sedward err_end() 5214194Sedward { 53*16445Sedward if (cx.x_type == X_FILE && cx.x_errwin != 0) { 5415857Sedward if (!cx.x_noerr) 5515857Sedward waitnl(cx.x_errwin); 5615580Sedward closeiwin(cx.x_errwin); 5715580Sedward cx.x_errwin = 0; 5814194Sedward } 5914194Sedward } 60