1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Revert r227812 and r227808 per discussion

Reviewed by:	many
Approved by:	des
This commit is contained in:
Eitan Adler 2011-12-02 15:41:09 +00:00
parent 07042bef45
commit 0f701093d2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=228202
4 changed files with 18 additions and 30 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
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, locale_t locale)
(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, locale_t locale)
}
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());
}

View File

@ -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 -