From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/707 Path: news.gmane.org!not-for-mail From: Isaac Dunham Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] string.h, _BSD_SOURCE, and *index() Date: Thu, 12 Apr 2012 18:45:22 -0700 Message-ID: <20120412184522.6c7b72a3@newbook> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/.YpdyHu9PM0HtYsz5FSeGWS" X-Trace: dough.gmane.org 1334281543 31971 80.91.229.3 (13 Apr 2012 01:45:43 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 13 Apr 2012 01:45:43 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-708-gllmg-musl=m.gmane.org@lists.openwall.com Fri Apr 13 03:45:43 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1SIVZy-0004wf-Iz for gllmg-musl@plane.gmane.org; Fri, 13 Apr 2012 03:45:38 +0200 Original-Received: (qmail 1826 invoked by uid 550); 13 Apr 2012 01:45:37 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 1815 invoked from network); 13 Apr 2012 01:45:37 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=lavabit; d=lavabit.com; b=XhCEl+0GzPOnOI81DasOdj1opcD/PLSbddG8p8jRv4ZzNuzs1beYfdygPmWm8cdNYI4ufQffQM3/8qBZueiOP766NRESFHI8pq8VPn7QzlicQafXTtSuRwzqMiAGu7bn0j6PJCO3ESsoo5wEn7pphp46ivwfZ6XSfwAeWZHPzC8=; h=Date:From:To:Subject:Message-ID:X-Mailer:Mime-Version:Content-Type; X-Mailer: Claws Mail 3.7.4 (GTK+ 2.20.1; i486-pc-linux-gnu) Xref: news.gmane.org gmane.linux.lib.musl.general:707 Archived-At: --MP_/.YpdyHu9PM0HtYsz5FSeGWS Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline I was working on _BSD_SOURCE for string.h. Warning: several of the functions are mislabeled as _GNU_SOURCE in the manpages. Everything in strings.h should be available if _GNU_SOURCE || BSD_SOURCE is defined and string.h is included. Actually, that's slightly an oversimplification-there are two functions (*_l) that should be _GNU_SOURCE only. (r)index was X/Open legacy, and has been dropped. The Open Group recommended using #define index(a,b) strchr((a),(b)) #define rindex(a,b) strrchr((a),(b)) Which will let us remove two more files if we do it (rindex.c & index.c) However, would removing those break the ABI? There are two patches attached: the first (string.diff) will define everything from strings.h if defined _BSD_SOURCE || _GNU_SOURCE The second patch (rindex.diff) applies the second change, but does not remove (r)index.c, to prevent ABI breakage. Isaac Dunham --MP_/.YpdyHu9PM0HtYsz5FSeGWS Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=string.diff diff --git a/include/string.h b/include/string.h index 4aa930e..cd09513 100644 --- a/include/string.h +++ b/include/string.h @@ -14,7 +14,7 @@ extern "C" { #define __NEED_size_t #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define __NEED_locale_t #endif @@ -53,7 +53,7 @@ char *strerror (int); #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) char *strtok_r (char *, const char *, char **); int strerror_r (int, char *, size_t); char *stpcpy(char *, const char *); @@ -67,10 +67,21 @@ int strcoll_l (const char *, const char *, locale_t); size_t strxfrm_l (char *, const char *, size_t, locale_t); #endif -#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) void *memccpy (void *, const void *, int, size_t); #endif +#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) +int bcmp (const void *, const void *, size_t); +void bcopy (const void *, void *, size_t); +void bzero (void *, size_t); +int strcasecmp (const char *, const char *); +int strncasecmp (const char *, const char *, size_t); +char *index (const char *, int); +char *rindex (const char *, int); +int ffs (int); +#endif + #ifdef _BSD_SOURCE size_t strlcat (char *, const char *, size_t); size_t strlcpy (char *, const char *, size_t); @@ -78,8 +89,8 @@ size_t strlcpy (char *, const char *, size_t); #ifdef _GNU_SOURCE int strverscmp (const char *, const char *); -int strcasecmp (const char *, const char *); -int strncasecmp (const char *, const char *, size_t); +int strcasecmp_l (const char *, const char *, locale_t); +int strncasecmp_l (const char *, const char *, size_t, locale_t); char *strchrnul(const char *, int); char *strcasestr(const char *, const char *); char *strsep(char **, const char *); --MP_/.YpdyHu9PM0HtYsz5FSeGWS Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=index.diff diff --git a/include/string.h b/include/string.h index cd09513..ab9ba2d 100644 --- a/include/string.h +++ b/include/string.h @@ -77,8 +77,8 @@ void bcopy (const void *, void *, size_t); void bzero (void *, size_t); int strcasecmp (const char *, const char *); int strncasecmp (const char *, const char *, size_t); -char *index (const char *, int); -char *rindex (const char *, int); +#define index(a,b) strchr((a),(b)) +#define rindex(a,b) strrchr((a),(b)) int ffs (int); #endif diff --git a/include/strings.h b/include/strings.h index 345c651..f8fd255 100644 --- a/include/strings.h +++ b/include/strings.h @@ -17,8 +17,8 @@ void bzero (void *, size_t); int ffs (int); -char *index (const char *, int); -char *rindex (const char *, int); +#define index(a,b) strchr((a),(b)) +#define rindex(a,b) strrchr((a),(b)) int strcasecmp (const char *, const char *); int strncasecmp (const char *, const char *, size_t); --MP_/.YpdyHu9PM0HtYsz5FSeGWS--