diff options
author | Mark Lumsden <lum@cvs.openbsd.org> | 2019-07-05 14:51:00 +0000 |
---|---|---|
committer | Mark Lumsden <lum@cvs.openbsd.org> | 2019-07-05 14:51:00 +0000 |
commit | 0bbe573718a75af0a21c8a945e58d394a4c71863 (patch) | |
tree | 2db82bb51968f5f3d80b040b0a272c03d7ed5f14 | |
parent | 694c4f60d2572891d989e0d17e2df3170004b239 (diff) |
Make mg display the correct file name in the minibuffer if you load
another file in a startup file (e.g via find-file), then experience
another unrelated error with one of the lines being evaluated.
-rw-r--r-- | usr.bin/mg/extend.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/mg/extend.c b/usr.bin/mg/extend.c index 34d9b29bff8..2061bb3a358 100644 --- a/usr.bin/mg/extend.c +++ b/usr.bin/mg/extend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: extend.c,v 1.65 2019/06/22 15:38:15 lum Exp $ */ +/* $OpenBSD: extend.c,v 1.66 2019/07/05 14:50:59 lum Exp $ */ /* This file is in the public domain. */ @@ -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) @@ -671,6 +671,8 @@ load(const char *fname) return (FALSE); } + /* keep a note of fname incase of errors in loaded file. */ + (void)strlcpy(fncpy, fname, sizeof(fncpy)); line = 0; while ((s = ffgetline(ffp, excbuf, sizeof(excbuf) - 1, &nbytes)) == FIOSUC) { @@ -679,7 +681,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; } } |