mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Bug 1004: Rewrite FSF code to avoid GPLv2 2. c)
c_strcasecmp and c_strncasecmp were taken from GNU coreutils 6.9, which is copyrighted by the Free Software Foundation and licensed under GNU GPL version 2 or later. It seems the programs in coreutils do not normally read commands interactively. So, including coreutils code in an interactive program such as ELinks could trigger GPLv2 section 2. c), which would require ELinks to display a copyright notice and a warranty disclaimer each time it is started. Rewrite those functions to remove the FSF-copyrighted code and make ELinks not a work based on GNU coreutils. Avoiding FSF code has the additional benefit that we won't have to ask FSF for permission if we want to add a licence exception that allows linking ELinks with OpenSSL. So it seems a good idea even if my interpretation of GPLv2 2. c) is overly strict. I haven't checked though whether there are other FSF-copyrighted portions in ELinks.
This commit is contained in:
parent
ffffa763e4
commit
c56f3928ec
@ -245,79 +245,32 @@ elinks_strlcasecmp(const unsigned char *s1, size_t n1,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* c_strcasecmp
|
int
|
||||||
* Taken from GNU coreutils (version 6.9)
|
c_strcasecmp(const char *s1, const char *s2)
|
||||||
* 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)
|
|
||||||
{
|
{
|
||||||
register const unsigned char *p1 = (const unsigned char *) s1;
|
for (;; s1++, s2++) {
|
||||||
register const unsigned char *p2 = (const unsigned char *) s2;
|
unsigned char c1 = c_tolower(*(const unsigned char *) s1);
|
||||||
unsigned char c1, c2;
|
unsigned char c2 = c_tolower(*(const unsigned char *) s2);
|
||||||
|
|
||||||
if (p1 == p2)
|
if (c1 != c2)
|
||||||
return 0;
|
return (c1 < c2) ? -1: +1;
|
||||||
|
if (c1 == '\0')
|
||||||
do
|
return 0;
|
||||||
{
|
}
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* c_strncasecmp
|
int c_strncasecmp(const char *s1, const char *s2, size_t n)
|
||||||
* 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)
|
|
||||||
{
|
{
|
||||||
register const unsigned char *p1 = (const unsigned char *) s1;
|
for (; n > 0; n--, s1++, s2++) {
|
||||||
register const unsigned char *p2 = (const unsigned char *) s2;
|
unsigned char c1 = c_tolower(*(const unsigned char *) s1);
|
||||||
unsigned char c1, c2;
|
unsigned char c2 = c_tolower(*(const unsigned char *) s2);
|
||||||
|
|
||||||
if (p1 == p2 || n == 0)
|
if (c1 != c2)
|
||||||
return 0;
|
return (c1 < c2) ? -1: +1;
|
||||||
|
if (c1 == '\0')
|
||||||
do
|
return 0;
|
||||||
{
|
}
|
||||||
c1 = c_tolower (*p1);
|
return 0;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* c_strcasestr - adapted from src/osdep/stub.c */
|
/* c_strcasestr - adapted from src/osdep/stub.c */
|
||||||
|
@ -107,7 +107,7 @@ int elinks_strlcasecmp(const unsigned char *s1, size_t n1,
|
|||||||
const int locale_indep);
|
const int locale_indep);
|
||||||
|
|
||||||
/* strcasecmp and strncasecmp which work as if they are
|
/* 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_strcasecmp(const char *s1, const char *s2);
|
||||||
int c_strncasecmp(const char *s1, const char *s2, size_t n);
|
int c_strncasecmp(const char *s1, const char *s2, size_t n);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user