grub2/0192-grub-core-commands-regexp.c-set_matches-Move-setvar-.patch
Peter Jones f74b50e380 Rebase to upstream, fix a pile of bugs. The usual.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-06-12 15:37:08 -04:00

90 lines
2.5 KiB
Diff

From b5b12db0916b3436e872c23e08ad8627c0e726f1 Mon Sep 17 00:00:00 2001
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Date: Sun, 3 Mar 2013 15:24:02 +0100
Subject: [PATCH 192/482] * grub-core/commands/regexp.c (set_matches):
Move setvar out of its parent.
---
ChangeLog | 5 +++++
grub-core/commands/regexp.c | 27 +++++++++++++++------------
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5f9cde5..e5e2248 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2013-03-03 Vladimir Serbinenko <phcoder@gmail.com>
+ * grub-core/commands/regexp.c (set_matches): Move setvar out of its
+ parent.
+
+2013-03-03 Vladimir Serbinenko <phcoder@gmail.com>
+
* grub-core/kern/env.c, include/grub/env.h: Change iterator through
all vars to a macro. All users updated.
diff --git a/grub-core/commands/regexp.c b/grub-core/commands/regexp.c
index b0706d0..f00b184 100644
--- a/grub-core/commands/regexp.c
+++ b/grub-core/commands/regexp.c
@@ -47,6 +47,18 @@ static const struct grub_arg_option options[] =
};
static grub_err_t
+setvar (char *str, char *v, regmatch_t *m)
+{
+ char ch;
+ grub_err_t err;
+ ch = str[m->rm_eo];
+ str[m->rm_eo] = '\0';
+ err = grub_env_set (v, str + m->rm_so);
+ str[m->rm_eo] = ch;
+ return err;
+}
+
+static grub_err_t
set_matches (char **varnames, char *str, grub_size_t nmatches,
regmatch_t *matches)
{
@@ -56,18 +68,9 @@ set_matches (char **varnames, char *str, grub_size_t nmatches,
grub_err_t err;
unsigned long j;
- auto void setvar (char *v, regmatch_t *m);
- void setvar (char *v, regmatch_t *m)
- {
- char ch;
- ch = str[m->rm_eo];
- str[m->rm_eo] = '\0';
- err = grub_env_set (v, str + m->rm_so);
- str[m->rm_eo] = ch;
- }
-
for (i = 0; varnames && varnames[i]; i++)
{
+ err = GRUB_ERR_NONE;
p = grub_strchr (varnames[i], ':');
if (! p)
{
@@ -75,7 +78,7 @@ set_matches (char **varnames, char *str, grub_size_t nmatches,
if (nmatches < 2 || matches[1].rm_so == -1)
grub_env_unset (varnames[i]);
else
- setvar (varnames[i], &matches[1]);
+ err = setvar (str, varnames[i], &matches[1]);
}
else
{
@@ -87,7 +90,7 @@ set_matches (char **varnames, char *str, grub_size_t nmatches,
if (nmatches <= j || matches[j].rm_so == -1)
grub_env_unset (p + 1);
else
- setvar (p + 1, &matches[j]);
+ err = setvar (str, p + 1, &matches[j]);
}
if (err != GRUB_ERR_NONE)
--
1.8.2.1