From: BVK Chaitanya Date: Thu, 13 May 2010 05:15:16 +0000 (+0530) Subject: pull-in break-cmd branch X-Git-Tag: 1.99~666^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e204c5d5e527aca4eb462e5b88f61b245705d32c;p=thirdparty%2Fgrub.git pull-in break-cmd branch --- e204c5d5e527aca4eb462e5b88f61b245705d32c diff --cc script/execute.c index 88d15495c,a9b3a002c..acce5afe9 --- a/script/execute.c +++ b/script/execute.c @@@ -30,9 -30,14 +30,15 @@@ 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)