Hi Ian, On 2026-02-18T23:42:28+0000, Ian Collier via Mutt-dev wrote: > On Wed, Feb 18, 2026 at 09:58:24PM +0000, Crystal Kolipe via Mutt-dev wrote: > > On Wed, Feb 18, 2026 at 03:29:57PM +0100, Alejandro Colomar via Mutt-dev > > wrote: > > > #define isspace_c(c) (!streq(strchrnul(MUTT_CTYPE_SPACE_C, > > > c), "")) > > > #define isspace_rfc5322_fws(c) > > > (!streq(strchrnul(MUTT_CTYPE_RFC5322_FWS, c), "")) > > > Note that strchrnul() is not available natively on OpenBSD. > > I do not understand why strchrnul and strcmp are even being invoked here.
Because they are necessary. (Well, strcmp(3) is not, as you could do
manual byte operations, but it's simple, more readable, and optimized
out.) strchrnul(3) is necessary.
>
> Yes, strchrnul(str,c) will be not equal to "" iff c is in the string, and
> yes the C compiler will probably optimize out the strcmp call, but isn't
>
> NULL != strchr(str,c)
>
> easier and shorter?
strchr(s, '\0') != NULL
would evaluate to true, which is a misbehavior: it would treat '\0' as
white space, while it is not. But
!streq(strchrnul(s, '\0'), "")
would work correctly, evaluating to false.
See <https://github.com/shadow-maint/shadow/pull/1471>.
> (And apparently more portable.)
Apparently, some libc implementations make it difficult to implement
isspace()-like APIs correctly.
>
> imc
Have a lovely night!
Alex
--
<https://www.alejandro-colomar.es>
signature.asc
Description: PGP signature
