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:
parent
f4448a0792
commit
fda6cb987f
8 changed files with 304 additions and 280 deletions
|
@ -37,7 +37,7 @@ grub_script_execute_cmd (struct grub_script_cmd *cmd)
|
|||
|
||||
/* Parse ARG and return the textual representation. Add strings are
|
||||
concatenated and all values of the variables are filled in. */
|
||||
static char *
|
||||
char *
|
||||
grub_script_execute_argument_to_string (struct grub_script_arg *arg)
|
||||
{
|
||||
int size = 0;
|
||||
|
@ -93,20 +93,22 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
|
|||
int argcount = 0;
|
||||
grub_script_function_t func = 0;
|
||||
char errnobuf[6];
|
||||
char *cmdname;
|
||||
|
||||
/* Lookup the command. */
|
||||
grubcmd = grub_command_find (cmdline->cmdname);
|
||||
cmdname = grub_script_execute_argument_to_string (cmdline->arglist->arg);
|
||||
grubcmd = grub_command_find (cmdname);
|
||||
if (! grubcmd)
|
||||
{
|
||||
/* Ignore errors. */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
/* It's not a GRUB command, try all functions. */
|
||||
func = grub_script_function_find (cmdline->cmdname);
|
||||
func = grub_script_function_find (cmdname);
|
||||
if (! func)
|
||||
{
|
||||
/* As a last resort, try if it is an assignment. */
|
||||
char *assign = grub_strdup (cmdline->cmdname);
|
||||
char *assign = grub_strdup (cmdname);
|
||||
char *eq = grub_strchr (assign, '=');
|
||||
|
||||
if (eq)
|
||||
|
@ -123,14 +125,15 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
grub_free (cmdname);
|
||||
|
||||
if (cmdline->arglist)
|
||||
if (cmdline->arglist->next)
|
||||
{
|
||||
argcount = cmdline->arglist->argcount;
|
||||
argcount = cmdline->arglist->argcount - 1;
|
||||
|
||||
/* Create argv from the arguments. */
|
||||
args = grub_malloc (sizeof (char *) * argcount);
|
||||
for (arglist = cmdline->arglist; arglist; arglist = arglist->next)
|
||||
for (arglist = cmdline->arglist->next; arglist; arglist = arglist->next)
|
||||
{
|
||||
char *str;
|
||||
str = grub_script_execute_argument_to_string (arglist->arg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue