]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/kern/parser.c (grub_parser_split_cmdline): Remove nested
authorVladimir Serbinenko <phcoder@gmail.com>
Thu, 7 Nov 2013 01:53:43 +0000 (02:53 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Thu, 7 Nov 2013 01:53:43 +0000 (02:53 +0100)
function.

ChangeLog
grub-core/kern/parser.c

index ab8c568a34112d6207767a52969711c2e1f1802c..13d9d5e03b431aac6650a7ab512c95250d0cc7fd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-07  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/kern/parser.c (grub_parser_split_cmdline): Remove nested
+       function.
+
 2013-11-07  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/kern/misc.c (grub_vsnprintf_real): Remove nested functions.
index b261fa0e3c40a1a4a7d9480e50a185f1845548c4..b9bd12352dbdc95fae98ca54ec9d7b4f1adaee7b 100644 (file)
@@ -106,6 +106,29 @@ check_varstate (grub_parser_state_t s)
          || s == GRUB_PARSER_STATE_QVARNAME2);
 }
 
+
+static void
+add_var (char *varname, char **bp, char **vp,
+        grub_parser_state_t state, grub_parser_state_t newstate)
+{
+  const char *val;
+
+  /* Check if a variable was being read in and the end of the name
+     was reached.  */
+  if (!(check_varstate (state) && !check_varstate (newstate)))
+    return;
+
+  *((*vp)++) = '\0';
+  val = grub_env_get (varname);
+  *vp = varname;
+  if (!val)
+    return;
+
+  /* Insert the contents of the variable in the buffer.  */
+  for (; *val; val++)
+    *((*bp)++) = *val;
+}
+
 grub_err_t
 grub_parser_split_cmdline (const char *cmdline,
                           grub_reader_getline_t getline, void *getline_data,
@@ -122,28 +145,6 @@ grub_parser_split_cmdline (const char *cmdline,
   char *args;
   int i;
 
-  auto void add_var (grub_parser_state_t newstate);
-
-  void add_var (grub_parser_state_t newstate)
-  {
-    const char *val;
-
-    /* Check if a variable was being read in and the end of the name
-       was reached.  */
-    if (!(check_varstate (state) && !check_varstate (newstate)))
-      return;
-
-    *(vp++) = '\0';
-    val = grub_env_get (varname);
-    vp = varname;
-    if (!val)
-      return;
-
-    /* Insert the contents of the variable in the buffer.  */
-    for (; *val; val++)
-      *(bp++) = *val;
-  }
-
   *argc = 0;
   do
     {
@@ -168,7 +169,7 @@ grub_parser_split_cmdline (const char *cmdline,
          /* If a variable was being processed and this character does
             not describe the variable anymore, write the variable to
             the buffer.  */
-         add_var (newstate);
+         add_var (varname, &bp, &vp, state, newstate);
 
          if (check_varstate (newstate))
            {
@@ -198,7 +199,7 @@ grub_parser_split_cmdline (const char *cmdline,
 
   /* A special case for when the last character was part of a
      variable.  */
-  add_var (GRUB_PARSER_STATE_TEXT);
+  add_var (varname, &bp, &vp, state, GRUB_PARSER_STATE_TEXT);
 
   if (bp != buffer && *(bp - 1))
     {