On Fri, Jun 19, 2026 at 13:02 +0800, Kevin J. McCarthy wrote:
However, this "utility" function is pretty lousy, and as Ian mentions
I can't think of any reason to copy b over to a tmp[] array.
Agreed.
If we're going to rewrite it, why don't we just compute length of a,
grab the strcpn() retval as length of b, and if they match then just
use ascii_strncmp()?
That ought to work.
First thing I thought of was to combine everything in a single loop:
caseless compare of a pair of characters, with a terminated by NUL, and
b terminated by either NUL or whitespace. (Also, this function doesn't
have to return strcmp()-style < == or >; can just return boolean, match
or not.)
Is there some reason not to code a caseless compare of two characters
in this function? Some reason we have to use ascii_strncmp() or whatever?