From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/711 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] string.h, _BSD_SOURCE, and *index() Date: Thu, 12 Apr 2012 23:31:53 -0400 Message-ID: <20120413033153.GI7281@brightrain.aerifal.cx> References: <20120412184522.6c7b72a3@newbook> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1334287793 2475 80.91.229.3 (13 Apr 2012 03:29:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 13 Apr 2012 03:29:53 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-712-gllmg-musl=m.gmane.org@lists.openwall.com Fri Apr 13 05:29:53 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 1SIXCo-0008TZ-LJ for gllmg-musl@plane.gmane.org; Fri, 13 Apr 2012 05:29:50 +0200 Original-Received: (qmail 30081 invoked by uid 550); 13 Apr 2012 03:29:49 -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 30070 invoked from network); 13 Apr 2012 03:29:49 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:711 Archived-At: On Fri, Apr 13, 2012 at 01:52:27PM +1200, Andre Renaud wrote: > On Fri, Apr 13, 2012 at 1:45 PM, Isaac Dunham wrote: > > (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? > > I'm curious about this - what is the general consensus on using > #define to do these kind of translations, versus using static inline > functions, such as: > static inline char *index(const char *s, int c) {return strchr(s, c);} > static inline char *rindex(const char *s, int c) {return strrchr(s, c);} Both are wrong to do in this header, but the static inline definition is even "more wrong". Non-static inline would be okay, but static inline conflicts with the "correct" (albeit removed) declaration of the function and will actively break code that prototypes the function (and can't be removed with #undef). Rich