2005-05-08 Vincent Pelletier <subdino2004@yahoo.fr>
* include/grub/misc.h (grub_dprintf): New macro. (grub_real_dprintf): New prototype. (grub_strword): Likewise. (grub_iswordseparator): Likewise. * kern/misc.c (grub_real_dprintf): New function. (grub_strword): Likewise. (grub_iswordseparator): Likewise.
This commit is contained in:
parent
f4c5e67ca4
commit
708b345f74
3 changed files with 77 additions and 0 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2005-05-08 Vincent Pelletier <subdino2004@yahoo.fr>
|
||||||
|
|
||||||
|
* include/grub/misc.h (grub_dprintf): New macro.
|
||||||
|
(grub_real_dprintf): New prototype.
|
||||||
|
(grub_strword): Likewise.
|
||||||
|
(grub_iswordseparator): Likewise.
|
||||||
|
* kern/misc.c (grub_real_dprintf): New function.
|
||||||
|
(grub_strword): Likewise.
|
||||||
|
(grub_iswordseparator): Likewise.
|
||||||
|
|
||||||
2005-04-30 Hollis Blanchard <hollis@penguinppc.org>
|
2005-04-30 Hollis Blanchard <hollis@penguinppc.org>
|
||||||
|
|
||||||
* boot/powerpc/ieee1275/cmain.c: Don't include grub/machine/init.h.
|
* boot/powerpc/ieee1275/cmain.c: Don't include grub/machine/init.h.
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
|
|
||||||
|
#define grub_dprintf(condition, fmt, args...) grub_real_dprintf(__FILE__, __LINE__, condition, fmt, ## args);
|
||||||
/* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */
|
/* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */
|
||||||
#define grub_memcpy(d,s,n) grub_memmove ((d), (s), (n))
|
#define grub_memcpy(d,s,n) grub_memmove ((d), (s), (n))
|
||||||
|
|
||||||
|
@ -46,6 +47,8 @@ int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, int c);
|
||||||
int EXPORT_FUNC(grub_strncasecmp) (const char *s1, const char *s2, int c);
|
int EXPORT_FUNC(grub_strncasecmp) (const char *s1, const char *s2, int c);
|
||||||
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_iswordseparator) (int c);
|
||||||
int EXPORT_FUNC(grub_isspace) (int c);
|
int EXPORT_FUNC(grub_isspace) (int c);
|
||||||
int EXPORT_FUNC(grub_isprint) (int c);
|
int EXPORT_FUNC(grub_isprint) (int c);
|
||||||
int EXPORT_FUNC(grub_isalpha) (int c);
|
int EXPORT_FUNC(grub_isalpha) (int c);
|
||||||
|
@ -58,6 +61,10 @@ char *EXPORT_FUNC(grub_strndup) (const char *s, grub_size_t n);
|
||||||
void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n);
|
void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n);
|
||||||
grub_size_t EXPORT_FUNC(grub_strlen) (const char *s);
|
grub_size_t EXPORT_FUNC(grub_strlen) (const char *s);
|
||||||
int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||||
|
void EXPORT_FUNC(grub_real_dprintf) (const char *file,
|
||||||
|
const int line,
|
||||||
|
const char *condition,
|
||||||
|
const char *fmt, ...) __attribute__ ((format (printf, 4, 5)));
|
||||||
int EXPORT_FUNC(grub_vprintf) (const char *fmt, va_list args);
|
int EXPORT_FUNC(grub_vprintf) (const char *fmt, va_list args);
|
||||||
int EXPORT_FUNC(grub_sprintf) (char *str, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
int EXPORT_FUNC(grub_sprintf) (char *str, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||||
int EXPORT_FUNC(grub_vsprintf) (char *str, const char *fmt, va_list args);
|
int EXPORT_FUNC(grub_vsprintf) (char *str, const char *fmt, va_list args);
|
||||||
|
|
60
kern/misc.c
60
kern/misc.c
|
@ -128,6 +128,23 @@ grub_printf (const char *fmt, ...)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_real_dprintf(const char *file, const int line, const char *condition,
|
||||||
|
const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
const char *debug = grub_env_get ("debug");
|
||||||
|
if (! debug)
|
||||||
|
return;
|
||||||
|
if (grub_strword (debug, "all") || grub_strword (debug, condition))
|
||||||
|
{
|
||||||
|
grub_printf ("%s,%d : ", file, line);
|
||||||
|
va_start (args, fmt);
|
||||||
|
grub_vprintf (fmt, args);
|
||||||
|
va_end (args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
grub_vprintf (const char *fmt, va_list args)
|
grub_vprintf (const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
|
@ -237,6 +254,49 @@ grub_strrchr (const char *s, int c)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
grub_strword (const char *haystack, const char *needle)
|
||||||
|
{
|
||||||
|
const char *n_pos = needle;
|
||||||
|
|
||||||
|
while (grub_iswordseparator (*haystack))
|
||||||
|
haystack++;
|
||||||
|
|
||||||
|
while (*haystack)
|
||||||
|
{
|
||||||
|
/* Crawl both the needle and the haystack word we're on. */
|
||||||
|
while(*haystack && !grub_iswordseparator (*haystack)
|
||||||
|
&& *haystack == *n_pos)
|
||||||
|
{
|
||||||
|
haystack++;
|
||||||
|
n_pos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we reached the end of both words at the same time, the word
|
||||||
|
is found. If not, eat everything in the haystack that isn't the
|
||||||
|
next word (or the end of string) and "reset" the needle. */
|
||||||
|
if ( (!*haystack || grub_iswordseparator (*haystack))
|
||||||
|
&& (!*n_pos || grub_iswordseparator (*n_pos)))
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
n_pos = needle;
|
||||||
|
while (*haystack && !grub_iswordseparator (*haystack))
|
||||||
|
haystack++;
|
||||||
|
while (grub_iswordseparator (*haystack))
|
||||||
|
haystack++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
grub_iswordseparator (int c)
|
||||||
|
{
|
||||||
|
return (grub_isspace (c) || c == ',' || c == ';' || c == '|' || c == '&');
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
grub_isspace (int c)
|
grub_isspace (int c)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue