On Tue, Apr 9, 2013 at 11:10 AM, Stefan Sperling <[email protected]> wrote: >> + size_t lus1 = strlen(us1); >> + size_t lus2 = strlen(us2);
These strlen() calls are also wrong, because they could read past the n bytes allowed for strncasecmp(). > It seems strncasecmp() cannot return errors according to POSIX. > Only the _l variants have errors defined. The convention for methods like these to return errors is the caller is required to set "errno = 0;" before the call, and then check for "errno != 0" after the call. :( > While I recognize that POSIX mandates the current locale to be used for > case conversion, I'm not sure this change is worth the extra complexity. > As you point out, the standard seems to throw its hands up in the air > when the question about conversion errors with strcasecmp() and strncasecmp() > is raised, possibly because these functions are older than the locale concept. The definition of strncasecmp() has actually been a pretty contentious topic on the POSIX mailing list for the past few weeks, albeit mostly focused on whether LC_CTYPE=POSIX allows for UTF-8 or not. E.g., http://austingroupbugs.net/view.php?id=663 I'm inclined to leave the functions as is for now.
