Re: mg: don't access(conffile), just open it

2023-03-30 Thread Omar Polo
On 2023/03/30 20:09:21 +0200, Theo Buehler 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) {

Re: mg: don't access(conffile), just open it

2023-03-30 Thread Theo Buehler
> I've also noticed that since startupfile() returns static memory > errors in -u would report the wrong path (ttykeymapinit() calls > startupfile() itself) so I'm changing it to use a caller provided > buffer for the path. tbf i don't completely like it and it also > causes some churn in the

Re: mg: don't access(conffile), just open it

2023-03-30 Thread Omar Polo
On 2023/03/30 18:11:32 +0200, Theo Buehler wrote: > On Thu, Mar 30, 2023 at 03:47:24PM +0200, Omar Polo wrote: > > - else if (bufp[0] == '\0') > > + if (bufp[0] == '\0') > > return (FALSE); > > - return (load(fname)); > > + if ((bufp = adjustname(fname, TRUE)) == NULL) > > +

Re: mg: don't access(conffile), just open it

2023-03-30 Thread Theo Buehler
On Thu, Mar 30, 2023 at 03:47:24PM +0200, Omar Polo wrote: > There's this "pattern" in mg where it first access(2) a path, then > does a buch of other things and finally opens it. It can do better. > > Diff below removes the access() calls for conffile handling. > startupfile() now does an

mg: don't access(conffile), just open it

2023-03-30 Thread Omar Polo
There's this "pattern" in mg where it first access(2) a path, then does a buch of other things and finally opens it. It can do better. Diff below removes the access() calls for conffile handling. startupfile() now does an ffropen() (fopen() wrapper) instead of access() and returns the file via