public inbox for [email protected]
help / color / mirror / Atom feedFrom: Peter Eisentraut <[email protected]>
To: Ranier Vilela <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: replace strtok()
Date: Sat, 22 Jun 2024 17:04:11 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAEudQApMiHHpx_GA96B8RMWpJ42CEYD4MjtvJpfj7cXrjn8i=Q@mail.gmail.com>
References: <[email protected]>
<CAEudQApMiHHpx_GA96B8RMWpJ42CEYD4MjtvJpfj7cXrjn8i=Q@mail.gmail.com>
On 18.06.24 13:43, Ranier Vilela wrote:
> But I would like to see more const char * where this is possible.
>
> For example, in pg_locale.c
> IMO, the token variable can be const char *.
>
> At least strchr expects a const char * as the first parameter.
This would not be future-proof. In C23, if you pass a const char * into
strchr(), you also get a const char * as a result. And in this case, we
do write into the area pointed to by the result. So with a const char
*token, this whole thing would not compile cleanly under C23.
> I found another implementation of strsep, it seems lighter to me.
> I will attach it for consideration, however, I have not done any testing.
Yeah, surely there are many possible implementations. I'm thinking,
since we already took other str*() functions from OpenBSD, it makes
sense to do this here as well, so we have only one source to deal with.
view thread (3+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: replace strtok()
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox