2009-01-26 Daniel Mierswa <impulze@impulze.org>
* kern/misc.c (grub_strcasecmp): New function. (grub_strcasecmp): Use grub_size_t instead of int for length. Fix return value. * include/grub/misc.h: Update function prototypes.
This commit is contained in:
parent
ef257b36a6
commit
1806b56e2b
3 changed files with 33 additions and 10 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2009-01-26 Daniel Mierswa <impulze@impulze.org>
|
||||||
|
|
||||||
|
* kern/misc.c (grub_strcasecmp): New function.
|
||||||
|
(grub_strcasecmp): Use grub_size_t instead of int for length.
|
||||||
|
Fix return value.
|
||||||
|
* include/grub/misc.h: Update function prototypes.
|
||||||
|
|
||||||
2009-01-26 Robert Millan <rmh@aybabtu.com>
|
2009-01-26 Robert Millan <rmh@aybabtu.com>
|
||||||
|
|
||||||
* configure.ac: Fix cross-compilation check.
|
* configure.ac: Fix cross-compilation check.
|
||||||
|
|
|
@ -45,7 +45,8 @@ void *EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n);
|
||||||
int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n);
|
int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n);
|
||||||
int EXPORT_FUNC(grub_strcmp) (const char *s1, const char *s2);
|
int EXPORT_FUNC(grub_strcmp) (const char *s1, const char *s2);
|
||||||
int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n);
|
int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n);
|
||||||
int EXPORT_FUNC(grub_strncasecmp) (const char *s1, const char *s2, int c);
|
int EXPORT_FUNC(grub_strcasecmp) (const char *s1, const char *s2);
|
||||||
|
int EXPORT_FUNC(grub_strncasecmp) (const char *s1, const char *s2, grub_size_t n);
|
||||||
char *EXPORT_FUNC(grub_strchr) (const char *s, int c);
|
char *EXPORT_FUNC(grub_strchr) (const char *s, int c);
|
||||||
char *EXPORT_FUNC(grub_strrchr) (const char *s, int c);
|
char *EXPORT_FUNC(grub_strrchr) (const char *s, int c);
|
||||||
int EXPORT_FUNC(grub_strword) (const char *s, const char *w);
|
int EXPORT_FUNC(grub_strword) (const char *s, const char *w);
|
||||||
|
|
33
kern/misc.c
33
kern/misc.c
|
@ -194,7 +194,7 @@ grub_strcmp (const char *s1, const char *s2)
|
||||||
while (*s1 && *s2)
|
while (*s1 && *s2)
|
||||||
{
|
{
|
||||||
if (*s1 != *s2)
|
if (*s1 != *s2)
|
||||||
return (int) *s1 - (int) *s2;
|
break;
|
||||||
|
|
||||||
s1++;
|
s1++;
|
||||||
s2++;
|
s2++;
|
||||||
|
@ -212,7 +212,7 @@ grub_strncmp (const char *s1, const char *s2, grub_size_t n)
|
||||||
while (*s1 && *s2 && --n)
|
while (*s1 && *s2 && --n)
|
||||||
{
|
{
|
||||||
if (*s1 != *s2)
|
if (*s1 != *s2)
|
||||||
return (int) *s1 - (int) *s2;
|
break;
|
||||||
|
|
||||||
s1++;
|
s1++;
|
||||||
s2++;
|
s2++;
|
||||||
|
@ -222,21 +222,36 @@ grub_strncmp (const char *s1, const char *s2, grub_size_t n)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
grub_strncasecmp (const char *s1, const char *s2, int c)
|
grub_strcasecmp (const char *s1, const char *s2)
|
||||||
{
|
{
|
||||||
int p = 1;
|
while (*s1 && *s2)
|
||||||
|
|
||||||
while (grub_tolower (*s1) && grub_tolower (*s2) && p < c)
|
|
||||||
{
|
{
|
||||||
if (grub_tolower (*s1) != grub_tolower (*s2))
|
if (grub_tolower (*s1) != grub_tolower (*s2))
|
||||||
return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
|
break;
|
||||||
|
|
||||||
|
s1++;
|
||||||
|
s2++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
grub_strncasecmp (const char *s1, const char *s2, grub_size_t n)
|
||||||
|
{
|
||||||
|
if (n == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while (*s1 && *s2 && --n)
|
||||||
|
{
|
||||||
|
if (grub_tolower (*s1) != grub_tolower (*s2))
|
||||||
|
break;
|
||||||
|
|
||||||
s1++;
|
s1++;
|
||||||
s2++;
|
s2++;
|
||||||
p++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) *s1 - (int) *s2;
|
return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
|
Loading…
Reference in a new issue