]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
merge with setparams branch
authorBVK Chaitanya <bvk@dbook>
Sun, 15 Aug 2010 06:41:07 +0000 (12:11 +0530)
committerBVK Chaitanya <bvk@dbook>
Sun, 15 Aug 2010 06:41:07 +0000 (12:11 +0530)
1  2 
include/grub/script_sh.h
script/argv.c
script/execute.c
script/main.c
util/grub-script-check.c

index ae435ff1ea90afa3b3c5eb93a4eccd7c9c5ebc3e,e0ed5c005cc1bcad05f2b1409990ac9c11772c8f..de5f625a247f89dbec622e46c0cf90b2c7793836
@@@ -224,8 -226,8 +224,9 @@@ struct grub_parser_para
  void grub_script_init (void);
  void grub_script_fini (void);
  
 +void grub_script_mem_free (struct grub_script_mem *mem);
  void grub_script_argv_free    (struct grub_script_argv *argv);
+ int grub_script_argv_make     (struct grub_script_argv *argv, int argc, char **args);
  int grub_script_argv_next     (struct grub_script_argv *argv);
  int grub_script_argv_append   (struct grub_script_argv *argv, const char *s);
  int grub_script_argv_split_append (struct grub_script_argv *argv, char *s);
diff --cc script/argv.c
index 92449138bc25e04f47fa3853784b5334e6b3a8b0,c642ea9c59594fa7d59eb1a153dccf78a77c6865..911989d0b8abef5e3afb4f607548a0fc676db7da
@@@ -56,9 -55,25 +56,26 @@@ grub_script_argv_free (struct grub_scri
  
    argv->argc = 0;
    argv->args = 0;
 +  argv->script = 0;
  }
  
 -  struct grub_script_argv r = { 0, 0};
+ /* Make argv from argc, args pair.  */
+ int
+ grub_script_argv_make (struct grub_script_argv *argv, int argc, char **args)
+ {
+   int i;
++  struct grub_script_argv r = { 0, 0, 0 };
+   for (i = 0; i < argc; i++)
+     if (grub_script_argv_next (&r) || grub_script_argv_append (&r, args[i]))
+       {
+       grub_script_argv_free (&r);
+       return 1;
+       }
+   *argv = r;
+   return 0;
+ }
  /* Prepare for next argc.  */
  int
  grub_script_argv_next (struct grub_script_argv *argv)
index c36d4e44bb3d58bbff456fcb9a62986721f8980d,b911163f7bd67f4f38e1b0b828f5eaea89dffbdb..3962b6ba525c825a9265918a1dcbaf382f98bcf4
@@@ -91,6 -113,35 +114,35 @@@ grub_script_shift (grub_command_t cmd _
    return GRUB_ERR_NONE;
  }
  
 -  struct grub_script_argv argv = { 0, 0 };
+ grub_err_t
+ grub_script_setparams (grub_command_t cmd __attribute__((unused)),
+                      int argc, char **args)
+ {
+   struct grub_script_scope *new_scope;
++  struct grub_script_argv argv = { 0, 0, 0 };
+   if (! scope)
+     return GRUB_ERR_INVALID_COMMAND;
+   new_scope = grub_malloc (sizeof (*new_scope));
+   if (! new_scope)
+     return grub_errno;
+   if (grub_script_argv_make (&argv, argc, args))
+     {
+       grub_free (new_scope);
+       return grub_errno;
+     }
+   new_scope->shifts = 0;
+   new_scope->argv = argv;
+   new_scope->flags = GRUB_SCRIPT_SCOPE_MALLOCED |
+     GRUB_SCRIPT_SCOPE_ARGS_MALLOCED;
+   replace_scope (new_scope);
+   return GRUB_ERR_NONE;
+ }
  static int
  grub_env_special (const char *name)
  {
  static char **
  grub_script_env_get (const char *name, grub_script_arg_type_t type)
  {
 -  struct grub_script_argv result = { 0, 0 };
+   unsigned i;
 +  struct grub_script_argv result = { 0, 0, 0 };
  
    if (grub_script_argv_next (&result))
      goto fail;
diff --cc script/main.c
Simple merge
Simple merge