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. */
struct grub_script_cmdif
{
struct grub_script_cmd *
grub_script_create_cmdline (struct grub_parser_param *state,
struct grub_script_arglist *arglist);
-struct grub_script_cmd *
-grub_script_create_cmdblock (struct grub_parser_param *state);
struct grub_script_cmd *
grub_script_create_cmdif (struct grub_parser_param *state,
int options);
struct grub_script_cmd *
-grub_script_add_cmd (struct grub_parser_param *state,
- struct grub_script_cmdblock *cmdblock,
- struct grub_script_cmd *cmd);
+grub_script_append_cmd (struct grub_parser_param *state,
+ struct grub_script_cmd *list,
+ struct grub_script_cmd *last);
struct grub_script_arg *
grub_script_arg_add (struct grub_parser_param *state,
struct grub_script_arg *arg,
/* 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_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_cmdfor (struct grub_script_cmd *cmd);
grub_err_t grub_script_execute_cmdwhile (struct grub_script_cmd *cmd);
/* Execute a block of one or more commands. */
grub_err_t
-grub_script_execute_cmdblock (struct grub_script_cmd *cmd)
+grub_script_execute_cmdlist (struct grub_script_cmd *list)
{
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. */
- for (cmd = cmdblock->cmdlist; cmd; cmd = cmd->next)
+ for (cmd = list->next; cmd; cmd = cmd->next)
ret = grub_script_execute_cmd (cmd);
return ret;
}
| script statement delimiter newlines0
{
- struct grub_script_cmdblock *cmdblock;
- cmdblock = (struct grub_script_cmdblock *) $1;
- $$ = grub_script_add_cmd (state, cmdblock, $2);
+ $$ = grub_script_append_cmd (state, $1, $2);
}
| error
{
/* A list of commands. */
commands1: newlines0 command
{
- $$ = grub_script_add_cmd (state, 0, $2);
+ $$ = grub_script_append_cmd (state, 0, $2);
}
| commands1 delimiters1 command
{
- struct grub_script_cmdblock *cmdblock;
- cmdblock = (struct grub_script_cmdblock *) $1;
- $$ = grub_script_add_cmd (state, cmdblock, $3);
+ $$ = grub_script_append_cmd (state, $1, $3);
}
;
return (struct grub_script_cmd *) cmd;
}
-/* Create a block of commands. CMD contains the command that should
- be added at the end of CMDBLOCK's list. If CMDBLOCK is zero, a new
- cmdblock will be created. */
+/* Create a chain of commands. LAST contains the command that should
+ be added at the end of LIST's list. If LIST is zero, a new list
+ will be created. */
struct grub_script_cmd *
-grub_script_add_cmd (struct grub_parser_param *state,
- struct grub_script_cmdblock *cmdblock,
- struct grub_script_cmd *cmd)
+grub_script_append_cmd (struct grub_parser_param *state,
+ struct grub_script_cmd *list,
+ struct grub_script_cmd *last)
{
struct grub_script_cmd *ptr;
- grub_dprintf ("scripting", "cmdblock\n");
+ grub_dprintf ("scripting", "append command\n");
- if (!cmd)
- return (struct grub_script_cmd *) cmdblock;
+ if (! last)
+ return list;
- if (!cmdblock)
+ if (! list)
{
- cmdblock = grub_script_malloc (state, sizeof (*cmdblock));
- if (!cmdblock)
+ list = grub_script_malloc (state, sizeof (*list));
+ if (! list)
return 0;
- cmdblock->cmd.exec = grub_script_execute_cmdblock;
- cmdblock->cmd.next = 0;
- cmdblock->cmdlist = cmd;
- cmd->next = 0;
+ list->exec = grub_script_execute_cmdlist;
+ list->next = last;
}
else
{
- if (!cmdblock->cmdlist)
- cmdblock->cmdlist = cmd;
- else
- {
- ptr = cmdblock->cmdlist;
- while (ptr->next)
- ptr = ptr->next;
- ptr->next = cmd;
- }
+ ptr = list;
+ while (ptr->next)
+ ptr = ptr->next;
+
+ ptr->next = last;
}
- return (struct grub_script_cmd *) cmdblock;
+ return list;
}
\f
}
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;
}