On Fri, Jun 19, 2026 at 01:29:21AM -0400, Kurt Hackenberg wrote:
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?

Ah, sorry, that's right.  I meant to propose ascii_strncasecmp()

--
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA

Attachment: signature.asc
Description: PGP signature

Reply via email to