If you have something like this in your .mg file:
find-file /home/lum/test
imaginary-command
When you open mg you will see an error:
Error loading file /home/lum/test at line 2
If you open files in your .mg file, but then have any kind of error with
the evaluation of lines afterwards (even non file opening/closing errors),
mg uses the last filename opened in the error message. Hence, the error
should have said:
Error loading file /home/lum/.mg at line 2
..since 'imaginary-command' IS imaginary.
Comments/oks?
Mark
Index: extend.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/extend.c,v
retrieving revision 1.65
diff -u -p -u -p -r1.65 extend.c
--- extend.c 22 Jun 2019 15:38:15 -0000 1.65
+++ extend.c 3 Jul 2019 21:25:00 -0000
@@ -657,7 +657,7 @@ load(const char *fname)
{
int s = TRUE, line, ret;
int nbytes = 0;
- char excbuf[128];
+ char excbuf[128], fncpy[NFILEN];
FILE *ffp;
if ((fname = adjustname(fname, TRUE)) == NULL)
@@ -670,7 +670,8 @@ load(const char *fname)
(void)ffclose(ffp, NULL);
return (FALSE);
}
-
+ /* keep a copy of fname incase of evaluation errors in excline. */
+ (void)strlcpy(fncpy, fname, sizeof(fncpy));
line = 0;
while ((s = ffgetline(ffp, excbuf, sizeof(excbuf) - 1, &nbytes))
== FIOSUC) {
@@ -679,7 +680,7 @@ load(const char *fname)
if (excline(excbuf) != TRUE) {
s = FIOERR;
dobeep();
- ewprintf("Error loading file %s at line %d", fname,
line);
+ ewprintf("Error loading file %s at line %d", fncpy,
line);
break;
}
}