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