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.

--
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA

Attachment: signature.asc
Description: PGP signature

Reply via email to