118737Sedward /* 233514Sbostic * Copyright (c) 1983 Regents of the University of California. 333514Sbostic * All rights reserved. 433514Sbostic * 5*42954Sbostic * This code is derived from software contributed to Berkeley by 6*42954Sbostic * Edward Wang at The University of California, Berkeley. 7*42954Sbostic * 842835Sbostic * %sccs.include.redist.c% 918737Sedward */ 1018737Sedward 1133514Sbostic #ifndef lint 12*42954Sbostic static char sccsid[] = "@(#)error.c 3.16 (Berkeley) 06/06/90"; 1333514Sbostic #endif /* not lint */ 1433514Sbostic 1514194Sedward #include "defs.h" 1615580Sedward #include "value.h" 1715580Sedward #include "context.h" 1816309Sedward #include "char.h" 1914194Sedward 2014418Sedward #define ERRLINES 10 /* number of lines for errwin */ 2114194Sedward 2214194Sedward /*VARARGS1*/ 2314194Sedward error(fmt, a, b, c, d, e, f, g, h) 2414194Sedward char *fmt; 2514194Sedward { 2616445Sedward register struct context *x; 2715681Sedward register struct ww *w; 2815681Sedward 2916445Sedward for (x = &cx; x != 0 && x->x_type != X_FILE; x = x->x_link) 3016445Sedward ; 3116445Sedward if (x == 0) { 3214194Sedward if (terse) 3316313Sedward wwbell(); 3414194Sedward else { 3516121Sedward wwprintf(cmdwin, fmt, a, b, c, d, e, f, g, h); 3616121Sedward wwputs(" ", cmdwin); 3714194Sedward } 3814194Sedward return; 3914194Sedward } 4016445Sedward if (x->x_noerr) 4114194Sedward return; 4216445Sedward if ((w = x->x_errwin) == 0) { 4314194Sedward char buf[512]; 4414194Sedward 4516445Sedward (void) sprintf(buf, "Errors from %s", x->x_filename); 4616445Sedward if ((w = x->x_errwin = openiwin(ERRLINES, buf)) == 0) { 4716121Sedward wwputs("Can't open error window. ", cmdwin); 4816445Sedward x->x_noerr = 1; 4914194Sedward return; 5014194Sedward } 5114194Sedward } 5215857Sedward if (more(w, 0) == 2) { 5316445Sedward x->x_noerr = 1; 5415857Sedward return; 5515857Sedward } 5616445Sedward wwprintf(w, "line %d: ", x->x_lineno); 5716121Sedward wwprintf(w, fmt, a, b, c, d, e, f, g, h); 5816121Sedward wwputc('\n', w); 5914194Sedward } 6014194Sedward 6115580Sedward err_end() 6214194Sedward { 6316445Sedward if (cx.x_type == X_FILE && cx.x_errwin != 0) { 6415857Sedward if (!cx.x_noerr) 6515857Sedward waitnl(cx.x_errwin); 6615580Sedward closeiwin(cx.x_errwin); 6715580Sedward cx.x_errwin = 0; 6814194Sedward } 6914194Sedward } 70