1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-27 02:56:18 -04:00

Merge branch 'elinks-0.12' into elinks-0.13

This commit is contained in:
Kalle Olavi Niemitalo 2008-11-02 22:38:22 +02:00 committed by Kalle Olavi Niemitalo
commit 88315a7112
2 changed files with 23 additions and 70 deletions

View File

@ -245,79 +245,32 @@ elinks_strlcasecmp(const unsigned char *s1, size_t n1,
}
}
/* c_strcasecmp
* Taken from GNU coreutils (version 6.9)
* File name: lib/c-strcasecmp.c
* Copyright (C) 1998-1999, 2005-2006 Free Software Foundation, Inc.
* Licensed under the GPL version 2 or any later version.
*/
int c_strcasecmp (const char *s1, const char *s2)
int
c_strcasecmp(const char *s1, const char *s2)
{
register const unsigned char *p1 = (const unsigned char *) s1;
register const unsigned char *p2 = (const unsigned char *) s2;
unsigned char c1, c2;
if (p1 == p2)
return 0;
do
{
c1 = c_tolower (*p1);
c2 = c_tolower (*p2);
if (c1 == '\0')
break;
++p1;
++p2;
}
while (c1 == c2);
if (UCHAR_MAX <= INT_MAX)
return c1 - c2;
else
/* On machines where 'char' and 'int' are types of the same size, the
difference of two 'unsigned char' values - including the sign bit -
doesn't fit in an 'int'. */
return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
for (;; s1++, s2++) {
unsigned char c1 = c_tolower(*(const unsigned char *) s1);
unsigned char c2 = c_tolower(*(const unsigned char *) s2);
if (c1 != c2)
return (c1 < c2) ? -1: +1;
if (c1 == '\0')
return 0;
}
}
/* c_strncasecmp
* Taken from GNU coreutils (version 6.9)
* File name: lib/c-strncasecmp.c
* ^ (note the "n")
* Copyright (C) 1998-1999, 2005-2006 Free Software Foundation, Inc.
* Licensed under the GPL version 2 or any later version.
*/
int c_strncasecmp (const char *s1, const char *s2, size_t n)
int c_strncasecmp(const char *s1, const char *s2, size_t n)
{
register const unsigned char *p1 = (const unsigned char *) s1;
register const unsigned char *p2 = (const unsigned char *) s2;
unsigned char c1, c2;
if (p1 == p2 || n == 0)
return 0;
do
{
c1 = c_tolower (*p1);
c2 = c_tolower (*p2);
if (--n == 0 || c1 == '\0')
break;
++p1;
++p2;
}
while (c1 == c2);
if (UCHAR_MAX <= INT_MAX)
return c1 - c2;
else
/* On machines where 'char' and 'int' are types of the same size, the
difference of two 'unsigned char' values - including the sign bit -
doesn't fit in an 'int'. */
return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
for (; n > 0; n--, s1++, s2++) {
unsigned char c1 = c_tolower(*(const unsigned char *) s1);
unsigned char c2 = c_tolower(*(const unsigned char *) s2);
if (c1 != c2)
return (c1 < c2) ? -1: +1;
if (c1 == '\0')
return 0;
}
return 0;
}
/* c_strcasestr - adapted from src/osdep/stub.c */

View File

@ -107,7 +107,7 @@ int elinks_strlcasecmp(const unsigned char *s1, size_t n1,
const int locale_indep);
/* strcasecmp and strncasecmp which work as if they are
* in the C locale - both taken from GNU coreutils */
* in the C locale */
int c_strcasecmp(const char *s1, const char *s2);
int c_strncasecmp(const char *s1, const char *s2, size_t n);