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