simplified nesting dynamic scopes
This commit is contained in:
parent
4a2ec49233
commit
01b0317f7b
2 changed files with 11 additions and 11 deletions
|
@ -73,15 +73,6 @@ struct grub_script_arglist
|
||||||
int argcount;
|
int argcount;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Scope for grub script constructs. */
|
|
||||||
struct grub_script_scope
|
|
||||||
{
|
|
||||||
struct grub_script_scope *next;
|
|
||||||
|
|
||||||
char **args;
|
|
||||||
unsigned int argc;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* A single command line. */
|
/* A single command line. */
|
||||||
struct grub_script_cmdline
|
struct grub_script_cmdline
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,12 @@
|
||||||
is sizeof (int) * 3, and one extra for a possible -ve sign. */
|
is sizeof (int) * 3, and one extra for a possible -ve sign. */
|
||||||
#define ERRNO_DIGITS_MAX (sizeof (int) * 3 + 1)
|
#define ERRNO_DIGITS_MAX (sizeof (int) * 3 + 1)
|
||||||
|
|
||||||
|
/* Scope for grub script functions. */
|
||||||
|
struct grub_script_scope
|
||||||
|
{
|
||||||
|
char **args;
|
||||||
|
unsigned int argc;
|
||||||
|
};
|
||||||
static struct grub_script_scope *scope = 0;
|
static struct grub_script_scope *scope = 0;
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
@ -242,15 +248,18 @@ grub_err_t
|
||||||
grub_script_function_call (grub_script_function_t func, int argc, char **args)
|
grub_script_function_call (grub_script_function_t func, int argc, char **args)
|
||||||
{
|
{
|
||||||
grub_err_t ret = 0;
|
grub_err_t ret = 0;
|
||||||
|
struct grub_script_scope *old_scope;
|
||||||
struct grub_script_scope new_scope;
|
struct grub_script_scope new_scope;
|
||||||
|
|
||||||
new_scope.argc = argc;
|
new_scope.argc = argc;
|
||||||
new_scope.args = args;
|
new_scope.args = args;
|
||||||
grub_list_push (GRUB_AS_LIST_P (&scope), GRUB_AS_LIST (&new_scope));
|
|
||||||
|
old_scope = scope;
|
||||||
|
scope = &new_scope;
|
||||||
|
|
||||||
ret = grub_script_execute (func->func);
|
ret = grub_script_execute (func->func);
|
||||||
|
|
||||||
grub_list_pop (GRUB_AS_LIST_P (&scope));
|
scope = old_scope;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue