2009-08-24 Vladimir Serbinenko <phcoder@gmail.com>
Save space by inlining misc.c functions. * kern/misc.c (grub_iswordseparator): Made static. * kern/misc.c (grub_strcat): Moved from here ... * include/grub/misc.h (grub_strcat): ... here. Inlined. * kern/misc.c (grub_strncat): Moved from here ... * include/grub/misc.h (grub_strncat): ... here. Inlined. * kern/misc.c (grub_strcasecmp): Moved from here ... * include/grub/misc.h (grub_strcasecmp): ... here. Inlined. * kern/misc.c (grub_strncasecmp): Moved from here ... * include/grub/misc.h (grub_strncasecmp): ... here. Inlined. * kern/misc.c (grub_isalpha): Moved from here ... * include/grub/misc.h (grub_isalpha): ... here. Inlined. * kern/misc.c (grub_isdigit): Moved from here ... * include/grub/misc.h (grub_isdigit): ... here. Inlined. * kern/misc.c (grub_isgraph): Moved from here ... * include/grub/misc.h (grub_isgraph): ... here. Inlined. * kern/misc.c (grub_tolower): Moved from here ... * include/grub/misc.h (grub_tolower): ... here. Inlined.
This commit is contained in:
parent
48e40bff44
commit
70f1161d13
3 changed files with 127 additions and 111 deletions
108
kern/misc.c
108
kern/misc.c
|
@ -24,6 +24,12 @@
|
|||
#include <grub/term.h>
|
||||
#include <grub/env.h>
|
||||
|
||||
static int
|
||||
grub_iswordseparator (int c)
|
||||
{
|
||||
return (grub_isspace (c) || c == ',' || c == ';' || c == '|' || c == '&');
|
||||
}
|
||||
|
||||
void *
|
||||
grub_memmove (void *dest, const void *src, grub_size_t n)
|
||||
{
|
||||
|
@ -97,42 +103,6 @@ grub_stpcpy (char *dest, const char *src)
|
|||
return d - 1;
|
||||
}
|
||||
|
||||
char *
|
||||
grub_strcat (char *dest, const char *src)
|
||||
{
|
||||
char *p = dest;
|
||||
|
||||
while (*p)
|
||||
p++;
|
||||
|
||||
while ((*p = *src) != '\0')
|
||||
{
|
||||
p++;
|
||||
src++;
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
char *
|
||||
grub_strncat (char *dest, const char *src, int c)
|
||||
{
|
||||
char *p = dest;
|
||||
|
||||
while (*p)
|
||||
p++;
|
||||
|
||||
while ((*p = *src) != '\0' && c--)
|
||||
{
|
||||
p++;
|
||||
src++;
|
||||
}
|
||||
|
||||
*p = '\0';
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
int
|
||||
grub_printf (const char *fmt, ...)
|
||||
{
|
||||
|
@ -250,39 +220,6 @@ grub_strncmp (const char *s1, const char *s2, grub_size_t n)
|
|||
return (int) *s1 - (int) *s2;
|
||||
}
|
||||
|
||||
int
|
||||
grub_strcasecmp (const char *s1, const char *s2)
|
||||
{
|
||||
while (*s1 && *s2)
|
||||
{
|
||||
if (grub_tolower (*s1) != 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++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
|
||||
}
|
||||
|
||||
char *
|
||||
grub_strchr (const char *s, int c)
|
||||
{
|
||||
|
@ -394,12 +331,6 @@ grub_strword (const char *haystack, const char *needle)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_iswordseparator (int c)
|
||||
{
|
||||
return (grub_isspace (c) || c == ',' || c == ';' || c == '|' || c == '&');
|
||||
}
|
||||
|
||||
int
|
||||
grub_isspace (int c)
|
||||
{
|
||||
|
@ -412,33 +343,6 @@ grub_isprint (int c)
|
|||
return (c >= ' ' && c <= '~');
|
||||
}
|
||||
|
||||
int
|
||||
grub_isalpha (int c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||
}
|
||||
|
||||
int
|
||||
grub_isdigit (int c)
|
||||
{
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
int
|
||||
grub_isgraph (int c)
|
||||
{
|
||||
return (c >= '!' && c <= '~');
|
||||
}
|
||||
|
||||
int
|
||||
grub_tolower (int c)
|
||||
{
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
return c - 'A' + 'a';
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
unsigned long
|
||||
grub_strtoul (const char *str, char **end, int base)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue