This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Check for existence of asprintf and vasprintf

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

Attachment: signature.asc
Description: Digital signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]