mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [musl] Changes for strcspn(), strspn(), strtok() and strtok_r()
Date: Tue, 13 Jul 2021 13:40:03 -0400	[thread overview]
Message-ID: <20210713174002.GB13220@brightrain.aerifal.cx> (raw)
In-Reply-To: <93626619AB0D496E90CFA1DDAF9915FE@H270>

On Tue, Jul 13, 2021 at 06:31:12PM +0200, Stefan Kanthak wrote:
> Rich Felker wrote:
> 
> > On Tue, Jul 13, 2021 at 02:02:06PM +0200, Stefan Kanthak wrote:
> 
> >>  #include <string.h>
> >>  
> >>  char *strtok_r(char *restrict s, const char *restrict sep, char **restrict p)
> >>  {
> >>          if (!s && !(s = *p)) return NULL;
> >>          s += strspn(s, sep);
> >> -        if (!*s) return *p = 0;
> >> +        if (!*s) return *p = NULL;
> >>          *p = s + strcspn(s, sep);
> >>          if (**p) *(*p)++ = 0;
> >> -        else *p = 0;
> >> +        else *p = NULL;
> >>          return s;
> >>  }
> > 
> > This is a gratuitous style change in the opposite direction of what's
> > preferred in musl.
> 
> Do you REALLY prefer using NULL and 0 in parallel for the null pointer?

No, just 0. I didn't see that NULL also appeared above too; most
places it appears are just leftovers from really old code.

      reply	other threads:[~2021-07-13 17:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13 12:02 Stefan Kanthak
2021-07-13 14:22 ` Érico Nogueira
2021-07-13 14:49 ` Érico Nogueira
2021-07-13 15:45 ` Rich Felker
2021-07-13 16:31   ` Stefan Kanthak
2021-07-13 17:40     ` Rich Felker [this message]

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=20210713174002.GB13220@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --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).