mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: [PATCH] string.h, _BSD_SOURCE, and *index()
Date: Thu, 12 Apr 2012 23:31:53 -0400	[thread overview]
Message-ID: <20120413033153.GI7281@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAPfzE3YzB-JFK8KwBMtupn4jP=Vov_xfmfyLNOXQ=AiBnNvN8w@mail.gmail.com>

On Fri, Apr 13, 2012 at 01:52:27PM +1200, Andre Renaud wrote:
> On Fri, Apr 13, 2012 at 1:45 PM, Isaac Dunham <idunham@lavabit.com> 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


  reply	other threads:[~2012-04-13  3:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-13  1:45 Isaac Dunham
2012-04-13  1:52 ` Andre Renaud
2012-04-13  3:31   ` Rich Felker [this message]
2012-04-13  3:30 ` Rich Felker
2012-04-13  4:31   ` Isaac Dunham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120413033153.GI7281@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).