fix for grub-script-check to handle empty lines
This commit is contained in:
commit
1136ac2632
3 changed files with 19 additions and 10 deletions
|
@ -1,3 +1,8 @@
|
|||
2010-01-28 BVK Chaitanya <bvk.groups@gmail.com>
|
||||
|
||||
* include/grub/script_sh.h (sourcecode): Add const qualifier.
|
||||
* util/grub-script-check.c (getline): Fix empty lines case.
|
||||
|
||||
2010-01-28 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* Makefile.in (check): Exit with fail status when one of the tests
|
||||
|
|
|
@ -112,7 +112,7 @@ struct grub_script_cmd_menuentry
|
|||
struct grub_script_arglist *arglist;
|
||||
|
||||
/* The sourcecode the entry will be generated from. */
|
||||
char *sourcecode;
|
||||
const char *sourcecode;
|
||||
|
||||
/* Options. XXX: Not used yet. */
|
||||
int options;
|
||||
|
|
|
@ -82,16 +82,8 @@ grub_script_execute_cmdif (struct grub_script_cmd *cmd __attribute__ ((unused)))
|
|||
}
|
||||
|
||||
grub_err_t
|
||||
grub_script_execute_menuentry (struct grub_script_cmd *cmd)
|
||||
grub_script_execute_menuentry (struct grub_script_cmd *cmd __attribute__ ((unused)))
|
||||
{
|
||||
struct grub_script_cmd_menuentry *menu;
|
||||
menu = (struct grub_script_cmd_menuentry *)cmd;
|
||||
|
||||
if (menu->sourcecode)
|
||||
{
|
||||
grub_free (menu->sourcecode);
|
||||
menu->sourcecode = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -146,6 +138,7 @@ main (int argc, char *argv[])
|
|||
auto grub_err_t get_config_line (char **line, int cont);
|
||||
grub_err_t get_config_line (char **line, int cont __attribute__ ((unused)))
|
||||
{
|
||||
int i;
|
||||
char *cmdline = 0;
|
||||
size_t len = 0;
|
||||
ssize_t read;
|
||||
|
@ -164,6 +157,17 @@ main (int argc, char *argv[])
|
|||
if (verbose)
|
||||
grub_printf("%s", cmdline);
|
||||
|
||||
for (i = 0; cmdline[i] != '\0'; i++)
|
||||
{
|
||||
/* Replace tabs and carriage returns with spaces. */
|
||||
if (cmdline[i] == '\t' || cmdline[i] == '\r')
|
||||
cmdline[i] = ' ';
|
||||
|
||||
/* Replace '\n' with '\0'. */
|
||||
if (cmdline[i] == '\n')
|
||||
cmdline[i] = '\0';
|
||||
}
|
||||
|
||||
*line = grub_strdup (cmdline);
|
||||
|
||||
free (cmdline);
|
||||
|
|
Loading…
Reference in a new issue