nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0192-grub-core-commands-regexp.c-set_matches-Move-setvar-.patch

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