This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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] Feature test macros overhaul: string.h and strings.h overlaps


On 04/13/2016 10:55 PM, Yaakov Selkowitz wrote:
> strings.h is the header mandated for these functions in POSIX.1 prior to
> 2008 (when most of these were removed).  The declarations in string.h are
> only for BSD compatibility.  But when both headers are included, avoid
> duplicate declarations.
> 
> Also, mark stpcpy and stpncpy as POSIX.1-2008.
> 
> Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
> ---
>  newlib/libc/include/string.h  | 14 +++++++-------
>  newlib/libc/include/strings.h |  5 +++++
>  2 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h
> index 68ee412..56c7fc2 100644
> --- a/newlib/libc/include/string.h
> +++ b/newlib/libc/include/string.h

> +#if __BSD_VISIBLE /* POSIX declaration is in <strings.h> */
>  int	 _EXFUN(strcasecmp,(const char *, const char *));
>  #endif

POSIX says <string.h> can declare ANY str* function without it being
namespace pollution, so _this_ particular duplicate is not only okay,
but there are programs that have come to rely on it being duplicated
here, the way glibc does it (yes, those programs SHOULD be using
<strings.h>, but it doesn't hurt to copy glibc).

> -#if __BSD_VISIBLE || __POSIX_VISIBLE
> +#if __BSD_VISIBLE /* POSIX declaration is in <strings.h> */
>  int	_EXFUN(strncasecmp,(const char *, const char *, size_t));

Ditto.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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