From owner-svn-src-all@FreeBSD.ORG Fri Dec 2 15:41:10 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3B90A106566B; Fri, 2 Dec 2011 15:41:10 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 210358FC08; Fri, 2 Dec 2011 15:41:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB2Ff9kx098503; Fri, 2 Dec 2011 15:41:09 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB2Ff9xm098498; Fri, 2 Dec 2011 15:41:09 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201112021541.pB2Ff9xm098498@svn.freebsd.org> From: Eitan Adler Date: Fri, 2 Dec 2011 15:41:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228202 - head/lib/libc/string X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Dec 2011 15:41:10 -0000 Author: eadler (ports committer) Date: Fri Dec 2 15:41:09 2011 New Revision: 228202 URL: http://svn.freebsd.org/changeset/base/228202 Log: Revert r227812 and r227808 per discussion Reviewed by: many Approved by: des Modified: head/lib/libc/string/strcasecmp.c head/lib/libc/string/strcmp.c head/lib/libc/string/strcoll.c head/lib/libc/string/strncmp.c Modified: head/lib/libc/string/strcasecmp.c ============================================================================== --- head/lib/libc/string/strcasecmp.c Fri Dec 2 15:24:39 2011 (r228201) +++ head/lib/libc/string/strcasecmp.c Fri Dec 2 15:41:09 2011 (r228202) @@ -48,9 +48,6 @@ strcasecmp_l(const char *s1, const char 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); - - 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); + if (n != 0) { + const u_char + *us1 = (const u_char *)s1, + *us2 = (const u_char *)s2; + + 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); } Modified: head/lib/libc/string/strcmp.c ============================================================================== --- head/lib/libc/string/strcmp.c Fri Dec 2 15:24:39 2011 (r228201) +++ head/lib/libc/string/strcmp.c Fri Dec 2 15:41:09 2011 (r228202) @@ -44,9 +44,6 @@ __FBSDID("$FreeBSD$"); int strcmp(const char *s1, const char *s2) { - if (s1 == s2) - return (0); - while (*s1 == *s2++) if (*s1++ == '\0') return (0); Modified: head/lib/libc/string/strcoll.c ============================================================================== --- head/lib/libc/string/strcoll.c Fri Dec 2 15:24:39 2011 (r228201) +++ head/lib/libc/string/strcoll.c Fri Dec 2 15:41:09 2011 (r228202) @@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$"); #include int -strcoll_l(const char *s1, const char *s2, locale_t locale) +strcoll_l(const char *s, const char *s2, locale_t locale) { int len, len2, prim, prim2, sec, sec2, ret, ret2; const char *t, *t2; @@ -50,16 +50,16 @@ strcoll_l(const char *s1, const char *s2 (struct xlocale_collate*)locale->components[XLC_COLLATE]; if (table->__collate_load_error) - return strcmp(s1, s2); + return strcmp(s, s2); len = len2 = 1; ret = ret2 = 0; if (table->__collate_substitute_nontrivial) { - t = tt = __collate_substitute(table, s1); + t = tt = __collate_substitute(table, s); t2 = tt2 = __collate_substitute(table, s2); } else { tt = tt2 = NULL; - t = s1; + t = s; t2 = s2; } while(*t && *t2) { @@ -95,8 +95,8 @@ strcoll_l(const char *s1, const char *s2 } int -strcoll(const char *s1, const char *s2) +strcoll(const char *s, const char *s2) { - return strcoll_l(s1, s2, __get_locale()); + return strcoll_l(s, s2, __get_locale()); } Modified: head/lib/libc/string/strncmp.c ============================================================================== --- head/lib/libc/string/strncmp.c Fri Dec 2 15:24:39 2011 (r228201) +++ head/lib/libc/string/strncmp.c Fri Dec 2 15:41:09 2011 (r228202) @@ -39,10 +39,8 @@ int strncmp(const char *s1, const char *s2, size_t n) { - /* use a bitwise or to avoid an additional branch instruction */ - if ((n == 0) | (s1 == s2)) + if (n == 0) return (0); - do { if (*s1 != *s2++) return (*(const unsigned char *)s1 -