new FreeBSD port maintainer
Matthias Andree
mandree at FreeBSD.org
Sat Sep 10 20:30:45 UTC 2011
Am 10.09.2011 20:33, schrieb Laurent Bercot:
>>> #if !defined __FreeBSD__
>>> char *dirname(char *path);
>>> #endif
>>> Can you confirm that it helps?
>> It's bogus because ours is const char *.
>
> FreeBSD defines dirname as a different function from the standard
> and then *busybox* is bogus ?
> Please.
>
> This is the exact kind of bullshit incompatibilities that application
> developers should not have to care about, ever. FreeBSD has no business
> redefining dirname's prototype; if it's not char *dirname (char *),
> it's not conformant, period.
FreeBSD's dirname is conforming. Note:
* Applications (busybox) have no business redeclaring library
functions. Instead, they are supposed to include the corresponding
headers, dirname.h in this case.
* POSIX conforming applications using dirname() need not be changed
for use with FreeBSD's dirname() implementation.
* It is safe to pass a char * or char [] argument to a function
expecting const char *.
* Advertising "const" can enable optimizing compilers generate better
code.
Quoting POSIX:
"The dirname() function may modify the string pointed to by path, and
may return a pointer to static storage that may then be overwritten by
subsequent calls to dirname()."
FreeBSD waives the former and implements the latter. And because it
does not modify the string, it advertises so through its header by
adding the const keyword. The standard cannot do that because it
permits modification of the string.
More information about the busybox
mailing list