remove cmdblock merged
This commit is contained in:
commit
fea6e1e94b
5 changed files with 31 additions and 52 deletions
|
@ -82,15 +82,6 @@ struct grub_script_cmdline
|
||||||
struct grub_script_arglist *arglist;
|
struct grub_script_arglist *arglist;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A block of commands, this can be used to group commands. */
|
|
||||||
struct grub_script_cmdblock
|
|
||||||
{
|
|
||||||
struct grub_script_cmd cmd;
|
|
||||||
|
|
||||||
/* A chain of commands. */
|
|
||||||
struct grub_script_cmd *cmdlist;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* An if statement. */
|
/* An if statement. */
|
||||||
struct grub_script_cmdif
|
struct grub_script_cmdif
|
||||||
{
|
{
|
||||||
|
@ -234,8 +225,6 @@ grub_script_add_arglist (struct grub_parser_param *state,
|
||||||
struct grub_script_cmd *
|
struct grub_script_cmd *
|
||||||
grub_script_create_cmdline (struct grub_parser_param *state,
|
grub_script_create_cmdline (struct grub_parser_param *state,
|
||||||
struct grub_script_arglist *arglist);
|
struct grub_script_arglist *arglist);
|
||||||
struct grub_script_cmd *
|
|
||||||
grub_script_create_cmdblock (struct grub_parser_param *state);
|
|
||||||
|
|
||||||
struct grub_script_cmd *
|
struct grub_script_cmd *
|
||||||
grub_script_create_cmdif (struct grub_parser_param *state,
|
grub_script_create_cmdif (struct grub_parser_param *state,
|
||||||
|
@ -262,9 +251,9 @@ grub_script_create_cmdmenu (struct grub_parser_param *state,
|
||||||
int options);
|
int options);
|
||||||
|
|
||||||
struct grub_script_cmd *
|
struct grub_script_cmd *
|
||||||
grub_script_add_cmd (struct grub_parser_param *state,
|
grub_script_append_cmd (struct grub_parser_param *state,
|
||||||
struct grub_script_cmdblock *cmdblock,
|
struct grub_script_cmd *list,
|
||||||
struct grub_script_cmd *cmd);
|
struct grub_script_cmd *last);
|
||||||
struct grub_script_arg *
|
struct grub_script_arg *
|
||||||
grub_script_arg_add (struct grub_parser_param *state,
|
grub_script_arg_add (struct grub_parser_param *state,
|
||||||
struct grub_script_arg *arg,
|
struct grub_script_arg *arg,
|
||||||
|
@ -301,7 +290,7 @@ void grub_script_yyerror (struct grub_parser_param *, char const *);
|
||||||
|
|
||||||
/* Commands to execute, don't use these directly. */
|
/* Commands to execute, don't use these directly. */
|
||||||
grub_err_t grub_script_execute_cmdline (struct grub_script_cmd *cmd);
|
grub_err_t grub_script_execute_cmdline (struct grub_script_cmd *cmd);
|
||||||
grub_err_t grub_script_execute_cmdblock (struct grub_script_cmd *cmd);
|
grub_err_t grub_script_execute_cmdlist (struct grub_script_cmd *cmd);
|
||||||
grub_err_t grub_script_execute_cmdif (struct grub_script_cmd *cmd);
|
grub_err_t grub_script_execute_cmdif (struct grub_script_cmd *cmd);
|
||||||
grub_err_t grub_script_execute_cmdfor (struct grub_script_cmd *cmd);
|
grub_err_t grub_script_execute_cmdfor (struct grub_script_cmd *cmd);
|
||||||
grub_err_t grub_script_execute_cmdwhile (struct grub_script_cmd *cmd);
|
grub_err_t grub_script_execute_cmdwhile (struct grub_script_cmd *cmd);
|
||||||
|
|
|
@ -269,13 +269,13 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
|
||||||
|
|
||||||
/* Execute a block of one or more commands. */
|
/* Execute a block of one or more commands. */
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_script_execute_cmdblock (struct grub_script_cmd *cmd)
|
grub_script_execute_cmdlist (struct grub_script_cmd *list)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct grub_script_cmdblock *cmdblock = (struct grub_script_cmdblock *) cmd;
|
struct grub_script_cmd *cmd;
|
||||||
|
|
||||||
/* Loop over every command and execute it. */
|
/* Loop over every command and execute it. */
|
||||||
for (cmd = cmdblock->cmdlist; cmd; cmd = cmd->next)
|
for (cmd = list->next; cmd; cmd = cmd->next)
|
||||||
ret = grub_script_execute_cmd (cmd);
|
ret = grub_script_execute_cmd (cmd);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -96,9 +96,7 @@ script: newlines0
|
||||||
}
|
}
|
||||||
| script statement delimiter newlines0
|
| script statement delimiter newlines0
|
||||||
{
|
{
|
||||||
struct grub_script_cmdblock *cmdblock;
|
$$ = grub_script_append_cmd (state, $1, $2);
|
||||||
cmdblock = (struct grub_script_cmdblock *) $1;
|
|
||||||
$$ = grub_script_add_cmd (state, cmdblock, $2);
|
|
||||||
}
|
}
|
||||||
| error
|
| error
|
||||||
{
|
{
|
||||||
|
@ -183,13 +181,11 @@ command: grubcmd { $$ = $1; }
|
||||||
/* A list of commands. */
|
/* A list of commands. */
|
||||||
commands1: newlines0 command
|
commands1: newlines0 command
|
||||||
{
|
{
|
||||||
$$ = grub_script_add_cmd (state, 0, $2);
|
$$ = grub_script_append_cmd (state, 0, $2);
|
||||||
}
|
}
|
||||||
| commands1 delimiters1 command
|
| commands1 delimiters1 command
|
||||||
{
|
{
|
||||||
struct grub_script_cmdblock *cmdblock;
|
$$ = grub_script_append_cmd (state, $1, $3);
|
||||||
cmdblock = (struct grub_script_cmdblock *) $1;
|
|
||||||
$$ = grub_script_add_cmd (state, cmdblock, $3);
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -291,46 +291,40 @@ grub_script_create_cmdmenu (struct grub_parser_param *state,
|
||||||
return (struct grub_script_cmd *) cmd;
|
return (struct grub_script_cmd *) cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a block of commands. CMD contains the command that should
|
/* Create a chain of commands. LAST contains the command that should
|
||||||
be added at the end of CMDBLOCK's list. If CMDBLOCK is zero, a new
|
be added at the end of LIST's list. If LIST is zero, a new list
|
||||||
cmdblock will be created. */
|
will be created. */
|
||||||
struct grub_script_cmd *
|
struct grub_script_cmd *
|
||||||
grub_script_add_cmd (struct grub_parser_param *state,
|
grub_script_append_cmd (struct grub_parser_param *state,
|
||||||
struct grub_script_cmdblock *cmdblock,
|
struct grub_script_cmd *list,
|
||||||
struct grub_script_cmd *cmd)
|
struct grub_script_cmd *last)
|
||||||
{
|
{
|
||||||
struct grub_script_cmd *ptr;
|
struct grub_script_cmd *ptr;
|
||||||
|
|
||||||
grub_dprintf ("scripting", "cmdblock\n");
|
grub_dprintf ("scripting", "append command\n");
|
||||||
|
|
||||||
if (!cmd)
|
if (! last)
|
||||||
return (struct grub_script_cmd *) cmdblock;
|
return list;
|
||||||
|
|
||||||
if (!cmdblock)
|
if (! list)
|
||||||
{
|
{
|
||||||
cmdblock = grub_script_malloc (state, sizeof (*cmdblock));
|
list = grub_script_malloc (state, sizeof (*list));
|
||||||
if (!cmdblock)
|
if (! list)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cmdblock->cmd.exec = grub_script_execute_cmdblock;
|
list->exec = grub_script_execute_cmdlist;
|
||||||
cmdblock->cmd.next = 0;
|
list->next = last;
|
||||||
cmdblock->cmdlist = cmd;
|
|
||||||
cmd->next = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!cmdblock->cmdlist)
|
ptr = list;
|
||||||
cmdblock->cmdlist = cmd;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ptr = cmdblock->cmdlist;
|
|
||||||
while (ptr->next)
|
while (ptr->next)
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
ptr->next = cmd;
|
|
||||||
}
|
ptr->next = last;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (struct grub_script_cmd *) cmdblock;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd __attribute__ ((unused)
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_script_execute_cmdblock (struct grub_script_cmd *cmd __attribute__ ((unused)))
|
grub_script_execute_cmdlist (struct grub_script_cmd *cmd __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue