Use normal parser for menu entries.

Reported by: Thomas Frauendorfer

	* include/grub/parser.h (grub_parser_execute): Don't export.
	* normal/menu.c (grub_menu_execute_entry_real): New function.
	(grub_menu_execute_entry): Use grub_menu_execute_entry_real.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-06-28 12:42:50 +02:00
parent bca58c7bb6
commit 4045dee1b9
3 changed files with 50 additions and 2 deletions

View file

@ -1,3 +1,12 @@
2010-06-28 Vladimir Serbinenko <phcoder@gmail.com>
Use normal parser for menu entries.
Reported by: Thomas Frauendorfer
* include/grub/parser.h (grub_parser_execute): Don't export.
* normal/menu.c (grub_menu_execute_entry_real): New function.
(grub_menu_execute_entry): Use grub_menu_execute_entry_real.
2010-06-28 Colin Watson <cjwatson@ubuntu.com> 2010-06-28 Colin Watson <cjwatson@ubuntu.com>
* docs/grub.texi (Embedded configuration): New section (replacing * docs/grub.texi (Embedded configuration): New section (replacing

View file

@ -83,7 +83,7 @@ struct grub_parser
}; };
typedef struct grub_parser *grub_parser_t; typedef struct grub_parser *grub_parser_t;
grub_err_t EXPORT_FUNC(grub_parser_execute) (char *source); grub_err_t grub_parser_execute (char *source);
grub_err_t grub_err_t
grub_rescue_parse_line (char *line, grub_reader_getline_t getline); grub_rescue_parse_line (char *line, grub_reader_getline_t getline);

View file

@ -29,6 +29,7 @@
#include <grub/auth.h> #include <grub/auth.h>
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub/term.h> #include <grub/term.h>
#include <grub/script_sh.h>
/* Time to delay after displaying an error message about a default/fallback /* Time to delay after displaying an error message about a default/fallback
entry failing to boot. */ entry failing to boot. */
@ -141,6 +142,44 @@ get_and_remove_first_entry_number (const char *name)
return entry; return entry;
} }
static void
grub_menu_execute_entry_real (grub_menu_entry_t entry)
{
const char *source;
auto grub_err_t getline (char **line, int cont);
grub_err_t getline (char **line, int cont __attribute__ ((unused)))
{
const char *p;
if (!source)
{
*line = 0;
return 0;
}
p = grub_strchr (source, '\n');
if (p)
*line = grub_strndup (source, p - source);
else
*line = grub_strdup (source);
source = p ? p + 1 : 0;
return 0;
}
source = entry->sourcecode;
while (source)
{
char *line;
getline (&line, 0);
grub_normal_parse_line (line, getline);
grub_free (line);
}
}
/* Run a menu entry. */ /* Run a menu entry. */
void void
grub_menu_execute_entry(grub_menu_entry_t entry) grub_menu_execute_entry(grub_menu_entry_t entry)
@ -159,7 +198,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry)
grub_env_set ("chosen", entry->title); grub_env_set ("chosen", entry->title);
grub_parser_execute ((char *) entry->sourcecode); grub_menu_execute_entry_real (entry);
if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ()) if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ())
/* Implicit execution of boot, only if something is loaded. */ /* Implicit execution of boot, only if something is loaded. */