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

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:\.

Both basename variants' documentations only talk about '/'. This is not the place where we should handle windows directory separators. We should either already expect forward slashes as input (with drive names as first path component, as e.g. msys does it), or convert them early on. And the implementation I've given above is the same code as in glibc.

However, I will actually prepare some patches to replace missing functions using gnulib rather than my own implementations.


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