diff options
author | eadler <eadler@FreeBSD.org> | 2011-12-02 15:41:09 +0000 |
---|---|---|
committer | eadler <eadler@FreeBSD.org> | 2011-12-02 15:41:09 +0000 |
commit | bdf8a555586d799896e0aff9adf1ed4749ab120a (patch) | |
tree | 79db9bd23938fe17ea1235cae91996780fe749aa /lib/libc/string/strcasecmp.c | |
parent | e5b89f2d70c0092ae178473393348aa3de7e2745 (diff) | |
download | FreeBSD-src-bdf8a555586d799896e0aff9adf1ed4749ab120a.zip FreeBSD-src-bdf8a555586d799896e0aff9adf1ed4749ab120a.tar.gz |
Revert r227812 and r227808 per discussion
Reviewed by: many
Approved by: des
Diffstat (limited to 'lib/libc/string/strcasecmp.c')
-rw-r--r-- | lib/libc/string/strcasecmp.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/lib/libc/string/strcasecmp.c b/lib/libc/string/strcasecmp.c index 582399d..65e042e 100644 --- a/lib/libc/string/strcasecmp.c +++ b/lib/libc/string/strcasecmp.c @@ -48,9 +48,6 @@ strcasecmp_l(const char *s1, const char *s2, locale_t locale) const u_char *us1 = (const u_char *)s1, *us2 = (const u_char *)s2; - if (s1 == s2) - return (0); - FIX_LOCALE(locale); while (tolower_l(*us1, locale) == tolower_l(*us2++, locale)) @@ -68,22 +65,18 @@ int strncasecmp_l(const char *s1, const char *s2, size_t n, locale_t locale) { FIX_LOCALE(locale); + if (n != 0) { + const u_char + *us1 = (const u_char *)s1, + *us2 = (const u_char *)s2; - const u_char - *us1 = (const u_char *)s1, - *us2 = (const u_char *)s2; - - /* use a bitwise or to avoid an additional branch instruction */ - if ((s1 == s2) | (n == 0)) - return (0); - - - do { - if (tolower_l(*us1, locale) != tolower_l(*us2++, locale)) - return (tolower_l(*us1, locale) - tolower_l(*--us2, locale)); - if (*us1++ == '\0') - break; - } while (--n != 0); + do { + if (tolower_l(*us1, locale) != tolower_l(*us2++, locale)) + return (tolower_l(*us1, locale) - tolower_l(*--us2, locale)); + if (*us1++ == '\0') + break; + } while (--n != 0); + } return (0); } |