return arg count from grub_script_execute_arglist_to_argv
This commit is contained in:
parent
345dd552ad
commit
1fb08ed515
2 changed files with 7 additions and 10 deletions
|
@ -300,6 +300,6 @@ int grub_script_function_call (grub_script_function_t func,
|
||||||
int argc, char **args);
|
int argc, char **args);
|
||||||
|
|
||||||
char **
|
char **
|
||||||
grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist);
|
grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist, int *count);
|
||||||
|
|
||||||
#endif /* ! GRUB_NORMAL_PARSER_HEADER */
|
#endif /* ! GRUB_NORMAL_PARSER_HEADER */
|
||||||
|
|
|
@ -37,7 +37,7 @@ grub_script_execute_cmd (struct grub_script_cmd *cmd)
|
||||||
|
|
||||||
/* Expand arguments in ARGLIST into multiple arguments. */
|
/* Expand arguments in ARGLIST into multiple arguments. */
|
||||||
char **
|
char **
|
||||||
grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist)
|
grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist, int *count)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int oom;
|
int oom;
|
||||||
|
@ -162,7 +162,6 @@ grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist)
|
||||||
if (!empty)
|
if (!empty)
|
||||||
push (0);
|
push (0);
|
||||||
}
|
}
|
||||||
push (0); /* Ensure argv[argc] == 0. */
|
|
||||||
|
|
||||||
if (oom)
|
if (oom)
|
||||||
{
|
{
|
||||||
|
@ -172,6 +171,9 @@ grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist)
|
||||||
argv = 0;
|
argv = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argv)
|
||||||
|
*count = argc - 1;
|
||||||
|
|
||||||
return argv;
|
return argv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +192,7 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
|
||||||
char *cmdname;
|
char *cmdname;
|
||||||
|
|
||||||
/* Lookup the command. */
|
/* Lookup the command. */
|
||||||
args = grub_script_execute_arglist_to_argv (cmdline->arglist);
|
args = grub_script_execute_arglist_to_argv (cmdline->arglist, &argcount);
|
||||||
if (!args)
|
if (!args)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
|
@ -228,9 +230,6 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Count argv size. */
|
|
||||||
for (argcount = 0; args[argcount]; argcount++);
|
|
||||||
|
|
||||||
/* Execute the GRUB command or function. */
|
/* Execute the GRUB command or function. */
|
||||||
if (grubcmd)
|
if (grubcmd)
|
||||||
ret = (grubcmd->func) (grubcmd, argcount - 1, args + 1);
|
ret = (grubcmd->func) (grubcmd, argcount - 1, args + 1);
|
||||||
|
@ -296,11 +295,9 @@ grub_script_execute_menuentry (struct grub_script_cmd *cmd)
|
||||||
|
|
||||||
if (cmd_menuentry->arglist)
|
if (cmd_menuentry->arglist)
|
||||||
{
|
{
|
||||||
args = grub_script_execute_arglist_to_argv (cmd_menuentry->arglist);
|
args = grub_script_execute_arglist_to_argv (cmd_menuentry->arglist, &argcount);
|
||||||
if (!args)
|
if (!args)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
for (argcount = 0; args[argcount]; argcount++);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_normal_add_menu_entry (argcount, (const char **) args,
|
grub_normal_add_menu_entry (argcount, (const char **) args,
|
||||||
|
|
Loading…
Reference in a new issue