Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210713174002.GB13220@brightrain.aerifal.cx>
Date: Tue, 13 Jul 2021 13:40:03 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: Changes for strcspn(), strspn(), strtok() and strtok_r()

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.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.