mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-21 23:02:40 +00:00
2009-06-04 Vladimir Serbinenko <phcoder@gmail.com>
Script fixes
* include/grub/script_sh.h (grub_script_cmdline): remove cmdline
(grub_lexer_param): add tokenonhold
(grub_script_create_cmdline): remove cmdline. All callers updated
(grub_script_function_create): make functionname
grub_script_arg. All callers updated
(grub_script_execute_argument_to_string): new prototype
* kern/parser.c (state_transitions): reorder
(grub_parser_cmdline_state): fix a bug and make more compact
* script/sh/execute.c (grub_script_execute_argument_to_string):
make global
(grub_script_execute_cmdline): use new format
* script/sh/function.c (grub_script_function_create): make functionname
grub_script_arg. All callers updated
* script/sh/lexer.c (grub_script_lexer_init): initilaize tokenonhold
(grub_script_yylex): remove
(grub_script_yylex2): renamed to ...
(grub_script_yylex): ...renamed
parse the expressions like a${b}c
* script/sh/parser.y (GRUB_PARSER_TOKEN_ARG): new typed terminal
(GRUB_PARSER_TOKEN_VAR): remove
(GRUB_PARSER_TOKEN_NAME): likewise
("if"): declare as typeless
("while"): likewise
("function"): likewise
("else"): likewise
("then"): likewise
("fi"): likewise
(text): remove
(argument): likewise
(script): accept empty scripts and make exit on error
(arguments): use GRUB_PARSER_TOKEN_ARG
(function): likewise
(command): move error handling to script
(menuentry): move grub_script_lexer_ref before
* script/sh/script.c (grub_script_create_cmdline): remove cmdline
argument. All callers updated
This commit is contained in:
1 parent
f4448a0792
commit
fda6cb987f
8 files changed
+304
-280
No files matched your search
+13
-17
@@ -47,8 +47,8 @@ static struct grub_parser_state_transition state_transitions[] =
|
||||
|
||||
{ GRUB_PARSER_STATE_QVAR, GRUB_PARSER_STATE_QVARNAME2, '{', 0},
|
||||
{ GRUB_PARSER_STATE_QVAR, GRUB_PARSER_STATE_QVARNAME, 0, 1},
|
||||
{ GRUB_PARSER_STATE_QVARNAME, GRUB_PARSER_STATE_DQUOTE, ' ', 1},
|
||||
{ GRUB_PARSER_STATE_QVARNAME, GRUB_PARSER_STATE_TEXT, '\"', 0},
|
||||
{ GRUB_PARSER_STATE_QVARNAME, GRUB_PARSER_STATE_DQUOTE, ' ', 1},
|
||||
{ GRUB_PARSER_STATE_QVARNAME2, GRUB_PARSER_STATE_DQUOTE, '}', 0},
|
||||
|
||||
{ 0, 0, 0, 0}
|
||||
@@ -60,9 +60,7 @@ grub_parser_state_t
|
||||
grub_parser_cmdline_state (grub_parser_state_t state, char c, char *result)
|
||||
{
|
||||
struct grub_parser_state_transition *transition;
|
||||
struct grub_parser_state_transition *next_match = 0;
|
||||
struct grub_parser_state_transition default_transition;
|
||||
int found = 0;
|
||||
|
||||
default_transition.to_state = state;
|
||||
default_transition.keep_value = 1;
|
||||
@@ -70,26 +68,24 @@ grub_parser_cmdline_state (grub_parser_state_t state, char c, char *result)
|
||||
/* Look for a good translation. */
|
||||
for (transition = state_transitions; transition->from_state; transition++)
|
||||
{
|
||||
if (transition->from_state != state)
|
||||
continue;
|
||||
/* An exact match was found, use it. */
|
||||
if (transition->from_state == state && transition->input == c)
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
if (transition->input == c)
|
||||
break;
|
||||
|
||||
if (transition->input == ' ' && ! grub_isalpha (c)
|
||||
&& ! grub_isdigit (c) && c != '_')
|
||||
break;
|
||||
|
||||
/* A less perfect match was found, use this one if no exact
|
||||
match can be found. */
|
||||
if (transition->from_state == state && transition->input == 0)
|
||||
next_match = transition;
|
||||
if (transition->input == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (! found)
|
||||
{
|
||||
if (next_match)
|
||||
transition = next_match;
|
||||
else
|
||||
transition = &default_transition;
|
||||
}
|
||||
if (! transition->from_state)
|
||||
transition = &default_transition;
|
||||
|
||||
if (transition->keep_value)
|
||||
*result = c;
|
||||
|
||||
Reference in new issue
Block a user