Re: mutt_buffer_concat_path is broken [PATCH: 1/1] Version 2

Alejandro Colomar via Mutt-dev <[email protected]> Fri, 8 May 2026 14:42:26 +0200
Newsgroups gmane.mail.mutt.devel
Message-ID <af3aCPg7Z8pc5clA@devuan>
On 2026-05-08T13:58:36+0800, Kevin J. McCarthy wrote:
> On Fri, May 08, 2026 at 12:57:09PM +0800, Kevin J. McCarthy wrote:
> > On Fri, May 08, 2026 at 06:08:37AM +0200, Rene Kita wrote:
> > > If we don't care about adding empty strings we could just do (untested):
> > > #v+
> > > void mutt_buffer_concat_path(BUFFER *d, const char *dir, const char *fname)
> > > {
> > > mutt_buffer_clear(d);
> > > mutt_buffer_addstr(d, dir);
> > > 
> > > if (*dir && dir[strlen(dir)-1 != '/')
> > >   mutt_buffer_addch(d, '/');
> > > while (*fname && *fname == '/') fname++;
> > > mutt_buffer_addstr(d, fname);
> > > }
> > > #v-
> > 
> > I like this version (subject to testing).
> 
> Ah, sorry, this version isn't the same, since it inverts the dir trailing
> slash check.
> 
> It fails the test: "" + "/baz" =>   "/baz"
> 
> I think fixing it while keeping it concise would just devolve to the same
> logic as with Alex's one line patch.  So I vote for just using that one-line
> fix in both the buffer and non-buffer version.

Yup, makes sense.  If you send the patch including both places, I'll
have a look, but I trust that.


Cheers,
Alex



-- 
<https://www.alejandro-colomar.es>
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmn92jIACgkQ64mZXMKQ
wqn0oA/8D9fHl2DhMajTIB8GX6IyIlNLu9/dwykXZvzrrGZkaYLvLUtSouvMA8Rt
9u/kHJ4LJVefFdAUQjpOYNZmNqeL5vy+4qN1Q59aj6NNVuCFAkeq/szMRR2w+Ig1
AjHMn/KB6MfTuY7Ux9OLTVdJCJximY3rJ0v9vELYt36Iy3Sz2VfQbwHab3Ajw/17
rU+iLRXWJ2S6UnlZ1ykX/tU1e6ZKMoP9H3nHekvDCZVx77ABR/jnXE4WjBMomYPv
RYNx1VPRppRYGnXXThz4FL+EcDK9JDTbSPeoEoXkypbuX2GLN9H3hu+kNVauTH31
+AmBrQesCx5BwYx8Z12O40i9600duB8s63QIZyqea35/zvzuh5QE/1mOP2aU/oJs
P9jLVxu3ByynMRFuzpCD1l7BnUc5SChupw5r88IG026ZXvW8ePheoZ8pC0zxXa0C
+3YNdAxuWbfwgCDJEjJzHPGa2/plXadMuzl83HJEW265oOE87VWa2PXNd5mPlsnR
Uj9UazM+sDR2wapHITRHMJhW6RwB5npfTsRlzuzMujIfDvx8jZPxgdnYmQiGLpPZ
s1vZQbPiCn/ccygqPpaAgkKOkZbuj+nAhvpJ7VKgFAL0pXgTeNW/YG5+ZLVHinEX
Tj2vL2rO+fqXhuTAXhJOvm8GsiDffPEGFDKhroW4K7IBaa9cMOs=
=ql+C
-----END PGP SIGNATURE-----