[PATCH] Check for existence of asprintf and vasprintf

Mike Frysinger vapier@gentoo.org
Thu Feb 23 18:51:00 GMT 2017

On 23 Feb 2017 10:39, Ulf Hermann wrote:
> > basename() is in the dirname module
> That's the POSIX variant. We're using the GNU variant everywhere

looking closer, it's not either.  POSIX doesn't guarantee that the input
is not modified, while GNU guarantees that it is left alone.  the gnulib
one makes the same guarantee as GNU, but it also returns a new buffer.

seems like getting a new basename module into gnulib wouldn't be *too*
difficult to pull off.

> and the GNU variant is a whopping two lines of code:
> char *base = strrchr(path, '/');
> return base ? base + 1 : (char *)path;

and we get straight to an example of why your solutions don't scale.
your replacement is wrong.  and ironically, it's wrong on Windows,
which is the whole point of your work.  '/' is not the path sep used
on every system out there.  it also does not properly handle systems
(such as Windows) that have filesystem prefixes like C:\.

> > you're correct that GNU strerror_r is not handled by gnulib.
> > that doesn't look like it's too hard to deal with, but it is
> > something that'd have to be considered.
> We're using strerror_r in exactly one place and my proposal is to just return a fixed string if we hit that on platforms where GNU strerror_r is not available.

i don't have an opinion on that
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/elfutils-devel/attachments/20170223/18e64f2c/attachment.sig>

More information about the Elfutils-devel mailing list