114194Sedward #ifndef lint 2*18737Sedward static char sccsid[] = "@(#)error.c 3.12 04/24/85"; 314194Sedward #endif 414194Sedward 5*18737Sedward /* 6*18737Sedward * Copyright (c) 1983 Regents of the University of California, 7*18737Sedward * All rights reserved. Redistribution permitted subject to 8*18737Sedward * the terms of the Berkeley Software License Agreement. 9*18737Sedward */ 10*18737Sedward 1114194Sedward #include "defs.h" 1215580Sedward #include "value.h" 1315580Sedward #include "context.h" 1416309Sedward #include "char.h" 1514194Sedward 1614418Sedward #define ERRLINES 10 /* number of lines for errwin */ 1714194Sedward 1814194Sedward /*VARARGS1*/ 1914194Sedward error(fmt, a, b, c, d, e, f, g, h) 2014194Sedward char *fmt; 2114194Sedward { 2216445Sedward register struct context *x; 2315681Sedward register struct ww *w; 2415681Sedward 2516445Sedward for (x = &cx; x != 0 && x->x_type != X_FILE; x = x->x_link) 2616445Sedward ; 2716445Sedward if (x == 0) { 2814194Sedward if (terse) 2916313Sedward wwbell(); 3014194Sedward else { 3116121Sedward wwprintf(cmdwin, fmt, a, b, c, d, e, f, g, h); 3216121Sedward wwputs(" ", cmdwin); 3314194Sedward } 3414194Sedward return; 3514194Sedward } 3616445Sedward if (x->x_noerr) 3714194Sedward return; 3816445Sedward if ((w = x->x_errwin) == 0) { 3914194Sedward char buf[512]; 4014194Sedward 4116445Sedward (void) sprintf(buf, "Errors from %s", x->x_filename); 4216445Sedward if ((w = x->x_errwin = openiwin(ERRLINES, buf)) == 0) { 4316121Sedward wwputs("Can't open error window. ", cmdwin); 4416445Sedward x->x_noerr = 1; 4514194Sedward return; 4614194Sedward } 4714194Sedward } 4815857Sedward if (more(w, 0) == 2) { 4916445Sedward x->x_noerr = 1; 5015857Sedward return; 5115857Sedward } 5216445Sedward wwprintf(w, "line %d: ", x->x_lineno); 5316121Sedward wwprintf(w, fmt, a, b, c, d, e, f, g, h); 5416121Sedward wwputc('\n', w); 5514194Sedward } 5614194Sedward 5715580Sedward err_end() 5814194Sedward { 5916445Sedward if (cx.x_type == X_FILE && cx.x_errwin != 0) { 6015857Sedward if (!cx.x_noerr) 6115857Sedward waitnl(cx.x_errwin); 6215580Sedward closeiwin(cx.x_errwin); 6315580Sedward cx.x_errwin = 0; 6414194Sedward } 6514194Sedward } 66