2006-16-04 Marco Gerards <marco@gnu.org>

* normal/command.c (grub_command_init): Remove the title command.

	* normal/lexer.c (grub_script_yylex): Renamed from this...
	(grub_script_yylex2): ... to this.
	(grub_script_yylex): New function.  Temporary
	introduced to filter some tokens.
	(grub_script_yyerror): Print a newline.

	* normal/main.c (read_config_file): Output information about the
	lines that contain errors.  Wait for a key after all lines have
	been processed.  Don't return an empty menu.

	* normal/parser.y (func_mem): Don't initialize.
	(menu_entry): Likewise.
	(err): New variable.
	(script): Don't return anything when an error was encountered.
	(ws, returns): Removed rules.
	(argument): Disabled concatenated variable support.
	(arguments): Remove explicit separators.
	(grubcmd): Likewise.
	(function): Likewise.
	(menuentry): Likewise.
	(if): Likewise.
	(commands): Likewise.  Add error handling.

	* normal/script.c (grub_script_create_cmdline): If
	`grub_script_parsed' is 0, assume the parser encountered an error.
This commit is contained in:
marco_g 2006-04-16 18:02:42 +00:00
parent b7d9f5fdea
commit 6de2ee9903
6 changed files with 113 additions and 60 deletions

View file

@ -164,6 +164,7 @@ read_config_file (const char *config)
grub_file_t file;
auto grub_err_t getline (char **line);
int currline = 0;
int errors = 0;
grub_err_t getline (char **line)
{
@ -201,21 +202,18 @@ read_config_file (const char *config)
while (get_line (file, cmdline, sizeof (cmdline)))
{
struct grub_script *parsed_script;
int startline;
currline++;
startline = ++currline;
/* Execute the script, line for line. */
parsed_script = grub_script_parse (cmdline, getline);
if (! parsed_script)
{
/* Wait until the user pushes any key so that the user can
see what happened. */
grub_printf ("\nPress any key to continue...");
(void) grub_getkey ();
grub_file_close (file);
return 0;
grub_printf ("(line %d-%d)\n", startline, currline);
errors++;
continue;
}
/* Execute the command(s). */
@ -226,6 +224,22 @@ read_config_file (const char *config)
}
grub_file_close (file);
if (errors > 0)
{
/* Wait until the user pushes any key so that the user can
see what happened. */
grub_printf ("\nPress any key to continue...");
(void) grub_getkey ();
}
/* If the menu is empty, just drop it. */
if (current_menu->size == 0)
{
grub_free (current_menu);
return 0;
}
return newmenu;
}