tags 729436 fixed-upstream
thanks
On 05/05/2014 05:53 PM, Aurelien Jarno wrote:
> reassign 729436 manpages-dev
> retitle 729436 manpages-dev: please explain why strcasecmp(3) is defined in
> both <string.h> and <strings.h>
> thanks
>
>
> On Tue, Nov 12, 2013 at 10:26:56PM +0200, Török Edwin wrote:
>> Package: libc6-dev
>> Version: 2.17-93
>> Severity: normal
>>
>> --- Please enter the report below this line. ---
>>
>> According to strcasecmp(3) and strcasecmp(3p) the function strcasecmp should
>> be declared in strings.h.
>>
>> However it is actually declared both in string.h and strings.h:
>> /usr/include/string.h:extern int strcasecmp (const char *__s1, const char
>> *__s2)
>> /usr/include/string.h:extern int strcasecmp_l (const char *__s1, const char
>> *__s2,
>> /usr/include/strings.h:extern int strcasecmp (const char *__s1, const char
>> *__s2)
>> /usr/include/strings.h:extern int strcasecmp_l (const char *__s1, const char
>> *__s2, __locale_t __loc)
>>
>> If the declaration in string.h is a typo, please remove it.
>
> This is not a typo, but there for historical reasons. The strcasecmp()
> and strncasecmp() functions first appeared in 4.4BSD and have been
> introduced the same way in the GNU libc. Their prototypes existed
> previously in <string.h> before they were moved to <strings.h> for
> IEEE Std 1003.1-2001 (POSIX.1) compliance, as <string.h> is supposed to
> be for ISO C functions, and strcasecmp() is not an ISO C function. The
> prototype in <string.h> has been kept for compatibility reasons.
>
>> Otherwise please update the manpage to mention that on Linux the function is
>> actually declared in both string.h and strings.h, and you should check
>> yourself that you included strings.h because you won't get any warning from
>> the compiler about implicit declarations.
>>
>
> I am therefore reassigning this bug to the manpages-dev package to
> update the corresponding manpage.
Fair enough. Upstream, I have added the following text under NOTES:
The strcasecmp() and strncasecmp() functions first appeared
in 4.4BSD, where they were declared in <string.h>. Thus, for
reasons of historical compatibility, the glibc <string.h>
header file also declares these functions, if the
_DEFAULT_SOURCE (or, in glibc 2.19 and earlier, _BSD_SOURCE)
feature test macro is defined.
Okay?
Thanks,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]