]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
simplified nesting dynamic scopes
authorBVK Chaitanya <bvk.groups@gmail.com>
Tue, 11 May 2010 05:22:10 +0000 (10:52 +0530)
committerBVK Chaitanya <bvk.groups@gmail.com>
Tue, 11 May 2010 05:22:10 +0000 (10:52 +0530)
include/grub/script_sh.h
script/execute.c

index 730aa30050e85670d054d70cbcfa559e58f09109..e1edbec156c7f7e57135d5eac1baab425a3e0424 100644 (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
 {
index 571b6785bfc13de1c49f4555463b515bb8f95eca..573dab4cb2990740d876e12af4a9b25eeff515d6 100644 (file)
    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;
 }