]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
pull-in break-cmd branch
authorBVK Chaitanya <bvk.groups@gmail.com>
Thu, 13 May 2010 05:15:16 +0000 (10:45 +0530)
committerBVK Chaitanya <bvk.groups@gmail.com>
Thu, 13 May 2010 05:15:16 +0000 (10:45 +0530)
1  2 
script/execute.c

index 88d15495cd676a9251affb67c1996d97ed6b267e,a9b3a002c488c65a6c0b4bebedf2a3ab3b8f594f..acce5afe955a983c08b1ea7cb26c2e78ea9ae0ca
     is sizeof (int) * 3, and one extra for a possible -ve sign.  */
  #define ERRNO_DIGITS_MAX  (sizeof (int) * 3 + 1)
  
 +static unsigned long is_continue;
  static unsigned long active_loops;
  static unsigned long active_breaks;
+ /* Scope for grub script functions.  */
+ struct grub_script_scope
+ {
+   struct grub_script_argv argv;
+ };
  static struct grub_script_scope *scope = 0;
  
  grub_err_t
@@@ -49,9 -54,7 +54,8 @@@ grub_script_break (grub_command_t cmd, 
           (*p != '\0'))
      return grub_error (GRUB_ERR_BAD_ARGUMENT, "bad break");
  
-   active_breaks = count;
 +  is_continue = grub_strcmp (cmd->name, "break") ? 1 : 0;
+   active_breaks = grub_min (active_loops, count);
    return GRUB_ERR_NONE;
  }
  
@@@ -408,17 -387,13 +388,16 @@@ grub_script_execute_cmdfor (struct grub
  
    active_loops++;
    result = 0;
-   for (i = 0; i < argcount; i++)
+   for (i = 0; i < argv.argc; i++)
      {
 +      if (is_continue && active_breaks == 1)
 +      active_breaks = 0;
 +
        if (! active_breaks)
        {
-         grub_script_env_set (cmdfor->name->str, args[i]);
+         grub_script_env_set (cmdfor->name->str, argv.args[i]);
          result = grub_script_execute_cmd (cmdfor->list);
        }
-       grub_free (args[i]);
      }
  
    if (active_breaks)