Am 10.09.2011 22:57, schrieb Rich Felker:
> On Sat, Sep 10, 2011 at 10:30:45PM +0200, Matthias Andree wrote:
>> 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:
> 
> No it is not. The standard specifies the prototype.

Even if, it bears no practical consequence to conformings applications.

>>  * Applications (busybox) have no business redeclaring library
>>    functions.  Instead, they are supposed to include the corresponding
>>    headers, dirname.h in this case.
> 
> False. 2.1.1 statement 4 reads:
> 
> "Provided that a function can be declared without reference to any
> type defined in a header, it is also permissible to declare the
> function explicitly and use it without including its associated
                     =============================================
> header."
==========

Please view with monospaced/fixed-character-width font to see my
underlines above at the right location.

> POSIX explicitly blesses the practice of manually declaring the
> functions you wish to use.

Yes, provided that you "use it without including its associated header".
Reason quoted below.

>>  * POSIX conforming applications using dirname() need not be changed
>>    for use with FreeBSD's dirname() implementation.
> 
> The following application is a strictly conforming POSIX application:
> 
> #define _POSIX_C_SOURCE 200809L
> #include <libgen.h>
> char *dirname(char *);

The application is nonconforming because the permission to declare the
functions yourself applies if you do NOT include the header.

Mind statement 2 from the same section that you cited, which begins:

"Any function declared in a header may also be implemented as a macro
defined in the header, so a function should not be declared explicitly
if its header is included. (...)".

> It will not compile on FreeBSD due to a BUG IN FREEBSD!

False. It does not compile because is nonconforming.

>> 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.
> 
> Implementation choices are irrelevant to the requirements on the
> function signature.

Possibly - presumably FreeBSD's implementation predates The Open Group
Base Specifications Issue 5 that was the first to change the prototype
from const char * to char *.

Let's not forget that the underlying bug was that some compilation units
were using dirname() without either declaring it first or #include
<libgen.h>.
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to