Blob Blame Raw
From 80253b05980830416244cc190158435d7fc306b2 Mon Sep 17 00:00:00 2001
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Date: Sun, 3 Mar 2013 15:26:29 +0100
Subject: [PATCH 193/482] 	* grub-core/script/execute.c
 (grub_script_arglist_to_argv): Move 	append out of its parent.

---
 ChangeLog                  |  5 +++++
 grub-core/script/execute.c | 53 +++++++++++++++++++++++-----------------------
 2 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e5e2248..e67ca9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2013-03-03  Vladimir Serbinenko  <phcoder@gmail.com>
 
+	* grub-core/script/execute.c (grub_script_arglist_to_argv): Move
+	append out of its parent.
+
+2013-03-03  Vladimir Serbinenko  <phcoder@gmail.com>
+
 	* grub-core/commands/regexp.c (set_matches): Move setvar out of its
 	parent.
 
diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c
index d6a2c78..a1dcc34 100644
--- a/grub-core/script/execute.c
+++ b/grub-core/script/execute.c
@@ -590,6 +590,29 @@ gettext_append (struct grub_script_argv *result, const char *orig_str)
   return rval;
 }
 
+static int
+append (struct grub_script_argv *result,
+	const char *s, int escape_type)
+{
+  int r;
+  char *p = 0;
+
+  if (escape_type == 0)
+    return grub_script_argv_append (result, s, grub_strlen (s));
+
+  if (escape_type > 0)
+    p = wildcard_escape (s);
+  else if (escape_type < 0)
+    p = wildcard_unescape (s);
+
+  if (! p)
+    return 1;
+
+  r = grub_script_argv_append (result, p, grub_strlen (p));
+  grub_free (p);
+  return r;
+}
+
 /* Convert arguments in ARGLIST into ARGV form.  */
 static int
 grub_script_arglist_to_argv (struct grub_script_arglist *arglist,
@@ -600,28 +623,6 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist,
   struct grub_script_arg *arg = 0;
   struct grub_script_argv result = { 0, 0, 0 };
 
-  auto int append (const char *s, int escape_type);
-  int append (const char *s, int escape_type)
-  {
-    int r;
-    char *p = 0;
-
-    if (escape_type == 0)
-      return grub_script_argv_append (&result, s, grub_strlen (s));
-
-    if (escape_type > 0)
-      p = wildcard_escape (s);
-    else if (escape_type < 0)
-      p = wildcard_unescape (s);
-
-    if (! p)
-      return 1;
-
-    r = grub_script_argv_append (&result, p, grub_strlen (p));
-    grub_free (p);
-    return r;
-  }
-
   for (; arglist && arglist->arg; arglist = arglist->next)
     {
       if (grub_script_argv_next (&result))
@@ -648,7 +649,7 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist,
 		    }
 		  else
 		    {
-		      if (append (values[i], 1))
+		      if (append (&result, values[i], 1))
 			goto fail;
 		    }
 
@@ -694,7 +695,7 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist,
 
 	    case GRUB_SCRIPT_ARG_TYPE_DQSTR:
 	    case GRUB_SCRIPT_ARG_TYPE_SQSTR:
-	      if (append (arg->str, 1))
+	      if (append (&result, arg->str, 1))
 		goto fail;
 	      break;
 	    }
@@ -727,14 +728,14 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist,
       if (! expansions)
 	{
 	  grub_script_argv_next (&result);
-	  append (unexpanded.args[i], -1);
+	  append (&result, unexpanded.args[i], -1);
 	}
       else
 	{
 	  for (j = 0; expansions[j]; j++)
 	    {
 	      failed = (failed || grub_script_argv_next (&result) ||
-			append (expansions[j], 0));
+			append (&result, expansions[j], 0));
 	      grub_free (expansions[j]);
 	    }
 	  grub_free (expansions);
-- 
1.8.2.1