On 2023/03/30 20:09:21 +0200, Theo Buehler <t...@theobuehler.org> wrote: > > Index: main.c > [...] > > @@ -159,8 +162,10 @@ main(int argc, char **argv) > > update(CMODE); > > > > /* user startup file. */ > > - if ((cp = startupfile(NULL, conffile)) != NULL) > > - (void)load(cp); > > + if (ffp) { > > Could you check this against NULL > > if (ffp != NULL) { > > Then it's ok.
Thanks! load now has an unnecessary copy of the file path for no reason, ok to drop? Index: extend.c =================================================================== RCS file: /home/cvs/src/usr.bin/mg/extend.c,v retrieving revision 1.78 diff -u -p -r1.78 extend.c --- extend.c 30 Mar 2023 19:00:02 -0000 1.78 +++ extend.c 30 Mar 2023 20:22:52 -0000 @@ -649,10 +649,8 @@ load(FILE *ffp, const char *fname) { int s = TRUE, line; int nbytes = 0; - char excbuf[BUFSIZE], fncpy[NFILEN]; + char excbuf[BUFSIZE]; - /* keep a note of fname in case of errors in loaded file. */ - (void)strlcpy(fncpy, fname, sizeof(fncpy)); line = 0; while ((s = ffgetline(ffp, excbuf, sizeof(excbuf) - 1, &nbytes)) == FIOSUC) { @@ -661,7 +659,7 @@ load(FILE *ffp, const char *fname) if (excline(excbuf, nbytes, line) != TRUE) { s = FIOERR; dobeep(); - ewprintf("Error loading file %s at line %d", fncpy, line); + ewprintf("Error loading file %s at line %d", fname, line); break; } }