simplified nesting dynamic scopes

This commit is contained in:
BVK Chaitanya 2010-05-11 10:52:10 +05:30
parent 4a2ec49233
commit 01b0317f7b
2 changed files with 11 additions and 11 deletions

View File

@ -73,15 +73,6 @@ struct grub_script_arglist
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. */
struct grub_script_cmdline
{

View File

@ -30,6 +30,12 @@
is sizeof (int) * 3, and one extra for a possible -ve sign. */
#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 char *
@ -242,15 +248,18 @@ grub_err_t
grub_script_function_call (grub_script_function_t func, int argc, char **args)
{
grub_err_t ret = 0;
struct grub_script_scope *old_scope;
struct grub_script_scope new_scope;
new_scope.argc = argc;
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);
grub_list_pop (GRUB_AS_LIST_P (&scope));
scope = old_scope;
return ret;
}