128 |
return ret; |
return ret; |
129 |
} |
} |
130 |
|
|
131 |
|
void |
132 |
|
grub_real_dprintf(const char *file, const int line, const char *condition, |
133 |
|
const char *fmt, ...) |
134 |
|
{ |
135 |
|
va_list args; |
136 |
|
const char *debug = grub_env_get ("debug"); |
137 |
|
if (! debug) |
138 |
|
return; |
139 |
|
if (grub_strword (debug, "all") || grub_strword (debug, condition)) |
140 |
|
{ |
141 |
|
grub_printf ("%s,%d : ", file, line); |
142 |
|
va_start (args, fmt); |
143 |
|
grub_vprintf (fmt, args); |
144 |
|
va_end (args); |
145 |
|
} |
146 |
|
} |
147 |
|
|
148 |
int |
int |
149 |
grub_vprintf (const char *fmt, va_list args) |
grub_vprintf (const char *fmt, va_list args) |
150 |
{ |
{ |
255 |
} |
} |
256 |
|
|
257 |
int |
int |
258 |
|
grub_strword (const char *haystack, const char *needle) |
259 |
|
{ |
260 |
|
const char *n_pos = needle; |
261 |
|
|
262 |
|
while (grub_iswordseparator (*haystack)) |
263 |
|
haystack++; |
264 |
|
|
265 |
|
while (*haystack) |
266 |
|
{ |
267 |
|
/* Crawl both the needle and the haystack word we're on. */ |
268 |
|
while(*haystack && !grub_iswordseparator (*haystack) |
269 |
|
&& *haystack == *n_pos) |
270 |
|
{ |
271 |
|
haystack++; |
272 |
|
n_pos++; |
273 |
|
} |
274 |
|
|
275 |
|
/* If we reached the end of both words at the same time, the word |
276 |
|
is found. If not, eat everything in the haystack that isn't the |
277 |
|
next word (or the end of string) and "reset" the needle. */ |
278 |
|
if ( (!*haystack || grub_iswordseparator (*haystack)) |
279 |
|
&& (!*n_pos || grub_iswordseparator (*n_pos))) |
280 |
|
return 1; |
281 |
|
else |
282 |
|
{ |
283 |
|
n_pos = needle; |
284 |
|
while (*haystack && !grub_iswordseparator (*haystack)) |
285 |
|
haystack++; |
286 |
|
while (grub_iswordseparator (*haystack)) |
287 |
|
haystack++; |
288 |
|
} |
289 |
|
} |
290 |
|
|
291 |
|
return 0; |
292 |
|
} |
293 |
|
|
294 |
|
int |
295 |
|
grub_iswordseparator (int c) |
296 |
|
{ |
297 |
|
return (grub_isspace (c) || c == ',' || c == ';' || c == '|' || c == '&'); |
298 |
|
} |
299 |
|
|
300 |
|
int |
301 |
grub_isspace (int c) |
grub_isspace (int c) |
302 |
{ |
{ |
303 |
return (c == '\n' || c == '\r' || c == ' ' || c == '\t'); |
return (c == '\n' || c == '\r' || c == ' ' || c == '\t'); |