]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Use normal parser for menu entries.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 28 Jun 2010 10:42:50 +0000 (12:42 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 28 Jun 2010 10:42:50 +0000 (12:42 +0200)
Reported by: Thomas Frauendorfer

* include/grub/parser.h (grub_parser_execute): Don't export.
* normal/menu.c (grub_menu_execute_entry_real): New function.
(grub_menu_execute_entry): Use grub_menu_execute_entry_real.

ChangeLog
include/grub/parser.h
normal/menu.c

index b9f4544b3e4149015940f74f5af03c6888f946b1..bccc55dea728bbf67be66715ff8547a25699d5dd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-06-28  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Use normal parser for menu entries.
+       Reported by: Thomas Frauendorfer
+
+       * include/grub/parser.h (grub_parser_execute): Don't export.
+       * normal/menu.c (grub_menu_execute_entry_real): New function.
+       (grub_menu_execute_entry): Use grub_menu_execute_entry_real.
+
 2010-06-28  Colin Watson  <cjwatson@ubuntu.com>
 
        * docs/grub.texi (Embedded configuration): New section (replacing
index 064f73fcb9b16fc59168cba44820a903577f7655..de4da05ad103b7515805aa181f4649cdd1409099 100644 (file)
@@ -83,7 +83,7 @@ struct grub_parser
 };
 typedef struct grub_parser *grub_parser_t;
 
-grub_err_t EXPORT_FUNC(grub_parser_execute) (char *source);
+grub_err_t grub_parser_execute (char *source);
 
 grub_err_t
 grub_rescue_parse_line (char *line, grub_reader_getline_t getline);
index 09c5fd1ebb516e0a9bf6b9653bfb4975fada1ba4..f98cfed663aa5b255ff84abf0d18aa805c8cd1e8 100644 (file)
@@ -29,6 +29,7 @@
 #include <grub/auth.h>
 #include <grub/i18n.h>
 #include <grub/term.h>
+#include <grub/script_sh.h>
 
 /* Time to delay after displaying an error message about a default/fallback
    entry failing to boot.  */
@@ -141,6 +142,44 @@ get_and_remove_first_entry_number (const char *name)
   return entry;
 }
 
+static void
+grub_menu_execute_entry_real (grub_menu_entry_t entry)
+{
+  const char *source;
+
+  auto grub_err_t getline (char **line, int cont);
+  grub_err_t getline (char **line, int cont __attribute__ ((unused)))
+  {
+    const char *p;
+
+    if (!source)
+      {
+       *line = 0;
+       return 0;
+      }
+
+    p = grub_strchr (source, '\n');
+
+    if (p)
+      *line = grub_strndup (source, p - source);
+    else
+      *line = grub_strdup (source);
+    source = p ? p + 1 : 0;
+    return 0;
+  }
+
+  source = entry->sourcecode;
+
+  while (source)
+    {
+      char *line;
+
+      getline (&line, 0);
+      grub_normal_parse_line (line, getline);
+      grub_free (line);
+    }
+}
+
 /* Run a menu entry.  */
 void
 grub_menu_execute_entry(grub_menu_entry_t entry)
@@ -159,7 +198,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry)
 
   grub_env_set ("chosen", entry->title);
 
-  grub_parser_execute ((char *) entry->sourcecode);
+  grub_menu_execute_entry_real (entry);
 
   if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ())
     /* Implicit execution of boot, only if something is loaded.  */