=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mg/extend.c,v retrieving revision 1.74 retrieving revision 1.75 diff -u -r1.74 -r1.75 --- src/usr.bin/mg/extend.c 2021/03/25 12:46:11 1.74 +++ src/usr.bin/mg/extend.c 2021/05/06 14:16:12 1.75 @@ -1,4 +1,4 @@ -/* $OpenBSD: extend.c,v 1.74 2021/03/25 12:46:11 lum Exp $ */ +/* $OpenBSD: extend.c,v 1.75 2021/05/06 14:16:12 lum Exp $ */ /* This file is in the public domain. */ /* @@ -587,7 +587,7 @@ return (FALSE); llen = strlen(bufp); - return (excline(exbuf, llen)); + return (excline(exbuf, llen, 1)); } /* @@ -600,10 +600,11 @@ { struct line *lp; struct buffer *bp = curbp; - int s, llen; + int s, llen, lnum = 0; static char excbuf[BUFSIZE]; for (lp = bfirstlp(bp); lp != bp->b_headp; lp = lforw(lp)) { + lnum++; llen = llength(lp); if (llen >= BUFSIZE) return (FALSE); @@ -611,7 +612,7 @@ /* make sure the line is terminated */ excbuf[llen] = '\0'; - if ((s = excline(excbuf, llen)) != TRUE) { + if ((s = excline(excbuf, llen, lnum)) != TRUE) { cleanup(); return (s); } @@ -667,7 +668,7 @@ == FIOSUC) { line++; excbuf[nbytes] = '\0'; - if (excline(excbuf, nbytes) != TRUE) { + if (excline(excbuf, nbytes, line) != TRUE) { s = FIOERR; dobeep(); ewprintf("Error loading file %s at line %d", fncpy, line); @@ -676,7 +677,7 @@ } (void)ffclose(ffp, NULL); excbuf[nbytes] = '\0'; - if (s != FIOEOF || (nbytes && excline(excbuf, nbytes) != TRUE)) + if (s != FIOEOF || (nbytes && excline(excbuf, nbytes, ++line) != TRUE)) return (FALSE); return (TRUE); } @@ -685,7 +686,7 @@ * excline - run a line from a load file or eval-expression. */ int -excline(char *line, int llen) +excline(char *line, int llen, int lnum) { PF fp; struct line *lp, *np; @@ -712,7 +713,7 @@ if (*funcp == '\0') return (TRUE); /* No error on blank lines */ if (*funcp == '(') - return (foundparen(funcp, llen)); + return (foundparen(funcp, llen, lnum)); line = parsetoken(funcp); if (*line != '\0') { *line++ = '\0';