Hi Kevin, > Date: 2026-08-04 12:38:46+0800 > From: "Kevin J. McCarthy" <[email protected]> > [...] > > #define CTYPE_LOWER_C "abcdefghijklmnopqrstuvwxyz" > > #define CTYPE_UPPER_C "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > > #define CTYPE_DIGIT_C "0123456789" > > #define CTYPE_ALPHA_C CTYPE_LOWER_C CTYPE_UPPER_C > > #define CTYPE_ALNUM_C CTYPE_ALPHA_C CTYPE_DIGIT_C > > #define CTYPE_PFCHAR_C CTYPE_ALNUM_C "._-" // portable > > filename character set > > Thanks Alex. I'll add a pre-patch with this to the series and send it out > later today for feedback.
You're welcome! :)
[...]
> > > + while (*from)
> > > + {
> > > + if (*from == '@' && !has_at)
> > > + has_at = 1;
> > > + else if (!strchr(ALLOWED_FROM_CHARS, *from))
> >
> > And then here I suggest adding another API, inspired by isascii(3):
> >
> > // isascii_c - is [:ascii:] C-locale
> > #define ispfchar_c(c) (!streq(strchrnul(CTYPE_PFCHAR_C, c), ""))
> >
> > #define streq(s1, s2) (!strcmp(s1, s2))
> >
> > To be able to write it as
> >
> > else if (!ispfchar_c(*from))
>
> I remember the earlier discussion on mutt-dev about this. I'm going to hold
> off on this suggestion, as I remember strchrnul() is not standardized, and
> the fallback suggestions relied on non-standard ?: operators, etc.
Hmmm, you could provide a fallback implementation of strchrnul(3) for
systems that lack it:
char *
strchrnul(const char *s, int c)
{
char reject[2] = {c, '\0'};
return s + strcspn(s, reject);
}
> The nul's are explicitly checked for in this case, so I don't think it's
> worth it to dig into that for this case. (But of course I'll swap out to
> use CTYPE_PFCHAR_C)
Sounds reasonable.
> > > + *from = '_';
> > > + from++;
> > > + }
> > > +}
> >
> > In any case, the above seems okay.
>
> Thanks again!
Have a lovely day!
Alex
--
<https://www.alejandro-colomar.es>
signature.asc
Description: PGP signature
