* [PATCH] GSoC #05 Menu entry class attribute
@ 2008-08-31 6:52 Colin D Bennett
2008-10-05 10:07 ` Vesa Jääskeläinen
0 siblings, 1 reply; 5+ messages in thread
From: Colin D Bennett @ 2008-08-31 6:52 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1.1: Type: text/plain, Size: 480 bytes --]
This patch adds support for a 'class' attribute on menu entries. It is
somewhat of a kludge, however since currently you just append
"|class=this,that" to the menu entry title to specify the classes.
Classes are used to provide a simple and flexible way for the best
available icon to be used in a graphical menu, but there are other
possible uses for them as well. The idea originates from the CSS
(cascading style sheets) and HTML 'class' concept.
Regards,
Colin
[-- Attachment #1.2: 05_ChangeLog.txt --]
[-- Type: text/plain, Size: 506 bytes --]
2008-08-30 Colin D Bennett <colin@gibibit.com>
Support classes for menu entries by adding '|classes=x,y' to the
title.
* include/grub/menu.h (grub_menu_entry_class): New struct type.
(grub_menu_entry): Added 'classes' field.
* normal/main.c (free_menu_entry_classes): New function.
(entry_class_attr_tag): New string constant.
(ENTRY_ATTR_SEPARATOR_CHAR): New macro.
(get_classes_from_entry_title): New function.
(grub_normal_menu_addentry): Parse '|classes=x,y' from entry titles.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 05_menu-entry-class.patch --]
[-- Type: text/x-patch; name=05_menu-entry-class.patch, Size: 5883 bytes --]
=== modified file 'include/grub/menu.h'
--- include/grub/menu.h 2008-08-30 19:20:13 +0000
+++ include/grub/menu.h 2008-08-31 05:47:00 +0000
@@ -20,12 +20,24 @@
#ifndef GRUB_MENU_HEADER
#define GRUB_MENU_HEADER 1
+struct grub_menu_entry_class
+{
+ char *name;
+ struct grub_menu_entry_class *next;
+};
+
/* The menu entry. */
struct grub_menu_entry
{
/* The title name. */
const char *title;
+ /* The classes associated with the menu entry:
+ used to choose an icon or other style attributes.
+ This is a dummy head node for the linked list, so for an entry E,
+ E.classes->next is the first class if it is not NULL. */
+ struct grub_menu_entry_class *classes;
+
/* The commands associated with this menu entry. */
struct grub_script *commands;
=== modified file 'normal/main.c'
--- normal/main.c 2008-08-30 19:20:13 +0000
+++ normal/main.c 2008-08-31 05:47:00 +0000
@@ -148,14 +148,132 @@
grub_env_unset_data_slot ("menu");
}
+static void
+free_menu_entry_classes (struct grub_menu_entry_class *head)
+{
+ /* Free all the classes. */
+ while (head)
+ {
+ struct grub_menu_entry_class *next;
+
+ grub_free (head->name);
+ next = head->next;
+ grub_free (head);
+ head = next;
+ }
+}
+
+/* The tag that can be added to a menu entry's title to specify a class
+ for the UI to use in selecting an icon or other visual attributes. */
+static const char entry_class_attr_tag[] = "|class=";
+
+#define ENTRY_ATTR_SEPARATOR_CHAR ','
+
+/* Parse and strip a possible "class" attribute in the title.
+ This code is not designed to support other attributes than "class"
+ in the title since, we are planning to use a better method of
+ specifying this information in the future. The parameter TITLE is
+ modified by storing a '\0' at the appropriate location to strip the
+ class information, if it exists. The class list is stored into *HEAD. */
+static struct grub_menu_entry_class *
+get_classes_from_entry_title (char *title)
+{
+ struct grub_menu_entry_class *head;
+ char *attr_start;
+
+ head = grub_malloc (sizeof (struct grub_menu_entry_class));
+ if (! head)
+ return 0;
+ head->name = 0;
+ head->next = 0;
+
+ attr_start = grub_strstr (title, entry_class_attr_tag);
+ if (attr_start)
+ {
+ struct grub_menu_entry_class *tail;
+ const char *p;
+
+ /* Trim the properties off of the title. */
+ *attr_start = '\0';
+
+ /* Move the pointer to the beginning of the first class name. */
+ attr_start += grub_strlen (entry_class_attr_tag);
+
+ tail = head;
+ p = attr_start;
+ while (p && *p)
+ {
+ const char *q;
+ const char *end;
+ const char *next_start;
+
+ /* Skip any leading whitespace. */
+ while (*p && grub_isspace (*p))
+ p++;
+
+ /* Find the comma terminating this one ... */
+ q = grub_strchr (p, ENTRY_ATTR_SEPARATOR_CHAR);
+ /* ... or if it's the last one, find the '\0' terminator. */
+ if (q)
+ {
+ end = q - 1;
+ next_start = q + 1;
+ }
+ else
+ {
+ /* For the last class, extend it to the end. */
+ end = p + grub_strlen (p);
+ next_start = 0;
+ }
+
+ /* Trim any trailing whitespace. */
+ while (end > p && grub_isspace (*end))
+ end--;
+
+ grub_size_t len = end - p + 1;
+ /* Copy the class name into a new string. */
+ char *class_name = grub_malloc (len + 1);
+ if (! class_name)
+ {
+ free_menu_entry_classes (head);
+ return 0;
+ }
+ grub_memcpy (class_name, p, len);
+ class_name[len] = '\0';
+
+ /* Create a new class and add it at the tail of the list. */
+ struct grub_menu_entry_class *new_class;
+ new_class = grub_malloc (sizeof (struct grub_menu_entry_class));
+ if (! new_class)
+ {
+ grub_free (class_name);
+ free_menu_entry_classes (head);
+ return 0;
+ }
+ /* Fill in the new class node. */
+ new_class->name = class_name;
+ new_class->next = 0;
+ /* Link the tail to it, and make it the new tail. */
+ tail->next = new_class;
+ tail = new_class;
+
+ /* Advance the character pointer. */
+ p = next_start;
+ }
+ }
+
+ return head;
+}
+
grub_err_t
grub_normal_menu_addentry (const char *title, struct grub_script *script,
const char *sourcecode)
{
- const char *menutitle;
+ char *menutitle;
const char *menusourcecode;
grub_menu_t menu;
grub_menu_entry_t *last;
+ struct grub_menu_entry_class *classes;
menu = grub_env_get_data_slot("menu");
if (! menu)
@@ -174,6 +292,14 @@
return grub_errno;
}
+ classes = get_classes_from_entry_title (menutitle);
+ if (! classes)
+ {
+ grub_free ((void *) menutitle);
+ grub_free ((void *) menusourcecode);
+ return grub_errno;
+ }
+
/* Add the menu entry at the end of the list. */
while (*last)
last = &(*last)->next;
@@ -181,6 +307,7 @@
*last = grub_malloc (sizeof (**last));
if (! *last)
{
+ free_menu_entry_classes (classes);
grub_free ((void *) menutitle);
grub_free ((void *) menusourcecode);
return grub_errno;
@@ -188,6 +315,7 @@
(*last)->commands = script;
(*last)->title = menutitle;
+ (*last)->classes = classes;
(*last)->next = 0;
(*last)->sourcecode = menusourcecode;
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] GSoC #05 Menu entry class attribute
2008-08-31 6:52 [PATCH] GSoC #05 Menu entry class attribute Colin D Bennett
@ 2008-10-05 10:07 ` Vesa Jääskeläinen
2008-10-13 16:35 ` [PATCH] GSoC #05 Menu entry class attribute (v2) Colin D Bennett
0 siblings, 1 reply; 5+ messages in thread
From: Vesa Jääskeläinen @ 2008-10-05 10:07 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 604 bytes --]
Colin D Bennett wrote:
> This patch adds support for a 'class' attribute on menu entries. It is
> somewhat of a kludge, however since currently you just append
> "|class=this,that" to the menu entry title to specify the classes.
>
> Classes are used to provide a simple and flexible way for the best
> available icon to be used in a graphical menu, but there are other
> possible uses for them as well. The idea originates from the CSS
> (cascading style sheets) and HTML 'class' concept.
Here is the patch snipped for using menuentry --class foo "title" { }.
Please try it out and see if it fits.
[-- Attachment #2: grub2-menuarguments.patch --]
[-- Type: text/plain, Size: 6455 bytes --]
Index: normal/parser.y
===================================================================
--- normal/parser.y (revision 1885)
+++ normal/parser.y (working copy)
@@ -204,7 +204,7 @@
;
/* A menu entry. Carefully save the memory that is allocated. */
-menuentry: "menuentry" argument
+menuentry: "menuentry" arguments
{
grub_script_lexer_ref (state->lexerstate);
} newlines '{'
Index: normal/main.c
===================================================================
--- normal/main.c (revision 1885)
+++ normal/main.c (working copy)
@@ -148,13 +148,15 @@
}
grub_err_t
-grub_normal_menu_addentry (const char *title, struct grub_script *script,
+grub_normal_menu_addentry (int argc, char **args, struct grub_script *script,
const char *sourcecode)
{
- const char *menutitle;
+ const char *menutitle = 0;
const char *menusourcecode;
grub_menu_t menu;
grub_menu_entry_t *last;
+ int failed = 0;
+ int i;
menu = grub_env_get_data_slot("menu");
if (! menu)
@@ -166,10 +168,59 @@
if (! menusourcecode)
return grub_errno;
- menutitle = grub_strdup (title);
- if (! menutitle)
+ /* Parse menu arguments. */
+ for (i = 0; i < argc; i++)
{
- grub_free ((void *) menusourcecode);
+ /* Capture arguments. */
+ if (grub_strncmp ("--", args[i], 2) == 0)
+ {
+ char *arg = &args[i][2];
+ char *value = 0;
+
+ /* Handle menu class. */
+ if (grub_strcmp(arg, "class") == 0)
+ {
+ i++;
+ value = args[i];
+ continue;
+ }
+ else
+ {
+ /* Handle invalid argument. */
+ failed = 1;
+ grub_error (GRUB_ERR_MENU, "invalid argument for menuentry: %s", args[i]);
+ break;
+ }
+
+ }
+
+ /* Capture title. */
+ if (! menutitle)
+ {
+ menutitle = grub_strdup (args[i]);
+ }
+ else
+ {
+ failed = 1;
+ grub_error (GRUB_ERR_MENU, "too many titles for menuentry: %s", args[i]);
+ break;
+ }
+ }
+
+ /* Validate arguments. */
+ if ((! failed) && (! menutitle))
+ {
+ grub_error (GRUB_ERR_MENU, "menuentry is missing title");
+ failed = 1;
+ }
+
+ /* If argument parsing failed, free any allocated resources. */
+ if (failed)
+ {
+ grub_free ((void *)menutitle);
+ grub_free ((void *)menusourcecode);
+
+ /* Here we assume that grub_error has been used to specify failure details. */
return grub_errno;
}
Index: normal/script.c
===================================================================
--- normal/script.c (revision 1885)
+++ normal/script.c (working copy)
@@ -206,7 +206,7 @@
The options for this entry are passed in OPTIONS. */
struct grub_script_cmd *
grub_script_create_cmdmenu (struct grub_parser_param *state,
- struct grub_script_arg *title,
+ struct grub_script_arglist *arglist,
char *sourcecode,
int options)
{
@@ -232,9 +232,9 @@
cmd->cmd.next = 0;
/* XXX: Check if this memory is properly freed. */
cmd->sourcecode = sourcecode;
- cmd->title = title;
+ cmd->arglist = arglist;
cmd->options = options;
-
+
return (struct grub_script_cmd *) cmd;
}
Index: normal/execute.c
===================================================================
--- normal/execute.c (revision 1885)
+++ normal/execute.c (working copy)
@@ -216,16 +216,33 @@
grub_script_execute_menuentry (struct grub_script_cmd *cmd)
{
struct grub_script_cmd_menuentry *cmd_menuentry;
- char *title;
+ struct grub_script_arglist *arglist;
struct grub_script *script;
+ char **args = 0;
+ int argcount = 0;
+ int i = 0;
cmd_menuentry = (struct grub_script_cmd_menuentry *) cmd;
- /* The title can contain variables, parse them and generate a string
- from it. */
- title = grub_script_execute_argument_to_string (cmd_menuentry->title);
- if (! title)
- return grub_errno;
+ if (cmd_menuentry->arglist)
+ {
+ argcount = cmd_menuentry->arglist->argcount;
+
+ /* Create argv from the arguments. */
+ args = grub_malloc (sizeof (char *) * argcount);
+
+ if (! args)
+ {
+ return grub_errno;
+ }
+
+ for (arglist = cmd_menuentry->arglist; arglist; arglist = arglist->next)
+ {
+ char *str;
+ str = grub_script_execute_argument_to_string (arglist->arg);
+ args[i++] = str;
+ }
+ }
/* Parse the menu entry *again*. */
script = grub_script_parse ((char *) cmd_menuentry->sourcecode, 0);
@@ -230,15 +247,19 @@
/* Parse the menu entry *again*. */
script = grub_script_parse ((char *) cmd_menuentry->sourcecode, 0);
- if (! script)
+ /* Add new menu entry. */
+ if (script)
{
- grub_free (title);
- return grub_errno;
+ grub_normal_menu_addentry (argcount, args,
+ script, cmd_menuentry->sourcecode);
}
- /* XXX: When this fails, the memory should be freed? */
- return grub_normal_menu_addentry (title, script,
- cmd_menuentry->sourcecode);
+ /* Free arguments. */
+ for (i = 0; i < argcount; i++)
+ grub_free (args[i]);
+ grub_free (args);
+
+ return grub_errno;
}
\f
Index: include/grub/script.h
===================================================================
--- include/grub/script.h (revision 1885)
+++ include/grub/script.h (working copy)
@@ -113,8 +113,8 @@
{
struct grub_script_cmd cmd;
- /* The title of the menu entry. */
- struct grub_script_arg *title;
+ /* The arguments for this menu entry. */
+ struct grub_script_arglist *arglist;
/* The sourcecode the entry will be generated from. */
const char *sourcecode;
@@ -204,7 +204,7 @@
struct grub_script_cmd *
grub_script_create_cmdmenu (struct grub_parser_param *state,
- struct grub_script_arg *title,
+ struct grub_script_arglist *arglist,
char *sourcecode,
int options);
Index: include/grub/normal.h
===================================================================
--- include/grub/normal.h (revision 1885)
+++ include/grub/normal.h (working copy)
@@ -152,7 +152,7 @@
char *grub_normal_do_completion (char *buf, int *restore,
void (*hook) (const char *item, grub_completion_type_t type, int count));
grub_err_t grub_normal_print_device_info (const char *name);
-grub_err_t grub_normal_menu_addentry (const char *title,
+grub_err_t grub_normal_menu_addentry (int argc, char **args,
struct grub_script *script,
const char *sourcecode);
char *grub_env_write_color_normal (struct grub_env_var *var, const char *val);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] GSoC #05 Menu entry class attribute (v2)
2008-10-05 10:07 ` Vesa Jääskeläinen
@ 2008-10-13 16:35 ` Colin D Bennett
2009-01-31 9:19 ` Vesa Jääskeläinen
0 siblings, 1 reply; 5+ messages in thread
From: Colin D Bennett @ 2008-10-13 16:35 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1.1: Type: text/plain, Size: 927 bytes --]
On Sun, 05 Oct 2008 13:07:32 +0300
Vesa Jääskeläinen <chaac@nic.fi> wrote:
> Colin D Bennett wrote:
> > This patch adds support for a 'class' attribute on menu entries.
> > It is somewhat of a kludge, however since currently you just append
> > "|class=this,that" to the menu entry title to specify the classes.
> >
> > Classes are used to provide a simple and flexible way for the best
> > available icon to be used in a graphical menu, but there are other
> > possible uses for them as well. The idea originates from the CSS
> > (cascading style sheets) and HTML 'class' concept.
>
> Here is the patch snipped for using menuentry --class foo "title" { }.
>
> Please try it out and see if it fits.
Hi Vesa,
Thanks for the argument parsing improvement. I'm glad to rip out the
'|class=' title kludge. Here is the result of merging your patch into
the menu entry class code.
Regards,
Colin
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 05_menu-entry-class_v2.patch --]
[-- Type: text/x-patch; name=05_menu-entry-class_v2.patch, Size: 10182 bytes --]
2008-10-13 Colin D Bennett <colin@gibibit.com>
Support classes for menu entries via the '--class CLASSNAME' argument
to the menuentry command. Argument list parsing functionality by Vesa
Jääskeläinen <chaac@nic.fi>.
* include/grub/menu.h (grub_menu_entry_class): New struct type.
(grub_menu_entry): Added 'classes' field.
* include/grub/normal.h (grub_normal_menu_addentry): Changed signature
to take a list of arguments instead of just a title.
* include/grub/script.h (grub_script_cmd_menuentry): Replaced title
with arglist.
(grub_script_create_cmdmenu): Changed signature to take an arglist
instead of just a single arg (title).
* normal/execute.c (grub_script_execute_menuentry): Parse arguments to
the 'menuentry' script command.
* normal/main.c (free_menu_entry_classes): New function.
(grub_normal_menu_addentry): Take and process a list of arguments;
handle '--class CLASSNAME' arguments and store the list of class names
in the menu entry.
* normal/parser.y (menuentry): Take a list of arguments.
* normal/script.c (grub_script_create_cmdmenu): Take an argument list,
store it in the command.
=== modified file 'include/grub/menu.h'
--- include/grub/menu.h 2008-08-30 19:20:13 +0000
+++ include/grub/menu.h 2008-10-13 16:15:06 +0000
@@ -20,12 +20,24 @@
#ifndef GRUB_MENU_HEADER
#define GRUB_MENU_HEADER 1
+struct grub_menu_entry_class
+{
+ char *name;
+ struct grub_menu_entry_class *next;
+};
+
/* The menu entry. */
struct grub_menu_entry
{
/* The title name. */
const char *title;
+ /* The classes associated with the menu entry:
+ used to choose an icon or other style attributes.
+ This is a dummy head node for the linked list, so for an entry E,
+ E.classes->next is the first class if it is not NULL. */
+ struct grub_menu_entry_class *classes;
+
/* The commands associated with this menu entry. */
struct grub_script *commands;
=== modified file 'include/grub/normal.h'
--- include/grub/normal.h 2008-10-03 14:26:41 +0000
+++ include/grub/normal.h 2008-10-13 16:15:06 +0000
@@ -141,7 +141,7 @@
char *grub_normal_do_completion (char *buf, int *restore,
void (*hook) (const char *item, grub_completion_type_t type, int count));
grub_err_t grub_normal_print_device_info (const char *name);
-grub_err_t grub_normal_menu_addentry (const char *title,
+grub_err_t grub_normal_menu_addentry (int argc, const char **args,
struct grub_script *script,
const char *sourcecode);
char *grub_env_write_color_normal (struct grub_env_var *var, const char *val);
=== modified file 'include/grub/script.h'
--- include/grub/script.h 2008-05-30 02:26:56 +0000
+++ include/grub/script.h 2008-10-13 16:15:06 +0000
@@ -113,8 +113,8 @@
{
struct grub_script_cmd cmd;
- /* The title of the menu entry. */
- struct grub_script_arg *title;
+ /* The arguments for this menu entry. */
+ struct grub_script_arglist *arglist;
/* The sourcecode the entry will be generated from. */
const char *sourcecode;
@@ -204,7 +204,7 @@
struct grub_script_cmd *
grub_script_create_cmdmenu (struct grub_parser_param *state,
- struct grub_script_arg *title,
+ struct grub_script_arglist *arglist,
char *sourcecode,
int options);
=== modified file 'normal/execute.c'
--- normal/execute.c 2008-01-15 15:32:17 +0000
+++ normal/execute.c 2008-10-13 16:15:06 +0000
@@ -216,29 +216,50 @@
grub_script_execute_menuentry (struct grub_script_cmd *cmd)
{
struct grub_script_cmd_menuentry *cmd_menuentry;
- char *title;
+ struct grub_script_arglist *arglist;
struct grub_script *script;
+ char **args = 0;
+ int argcount = 0;
+ int i = 0;
cmd_menuentry = (struct grub_script_cmd_menuentry *) cmd;
- /* The title can contain variables, parse them and generate a string
- from it. */
- title = grub_script_execute_argument_to_string (cmd_menuentry->title);
- if (! title)
- return grub_errno;
+ if (cmd_menuentry->arglist)
+ {
+ argcount = cmd_menuentry->arglist->argcount;
+
+ /* Create argv from the arguments. */
+ args = grub_malloc (sizeof (char *) * argcount);
+
+ if (! args)
+ {
+ return grub_errno;
+ }
+
+ for (arglist = cmd_menuentry->arglist; arglist; arglist = arglist->next)
+ {
+ char *str;
+ str = grub_script_execute_argument_to_string (arglist->arg);
+ args[i++] = str;
+ }
+ }
/* Parse the menu entry *again*. */
script = grub_script_parse ((char *) cmd_menuentry->sourcecode, 0);
- if (! script)
+ /* Add new menu entry. */
+ if (script)
{
- grub_free (title);
- return grub_errno;
+ grub_normal_menu_addentry (argcount, args,
+ script, cmd_menuentry->sourcecode);
}
- /* XXX: When this fails, the memory should be freed? */
- return grub_normal_menu_addentry (title, script,
- cmd_menuentry->sourcecode);
+ /* Free arguments. */
+ for (i = 0; i < argcount; i++)
+ grub_free (args[i]);
+ grub_free (args);
+
+ return grub_errno;
}
\f
=== modified file 'normal/main.c'
--- normal/main.c 2008-08-30 19:20:13 +0000
+++ normal/main.c 2008-10-13 16:15:06 +0000
@@ -148,14 +148,41 @@
grub_env_unset_data_slot ("menu");
}
+static void
+free_menu_entry_classes (struct grub_menu_entry_class *head)
+{
+ /* Free all the classes. */
+ while (head)
+ {
+ struct grub_menu_entry_class *next;
+
+ grub_free (head->name);
+ next = head->next;
+ grub_free (head);
+ head = next;
+ }
+}
+
grub_err_t
-grub_normal_menu_addentry (const char *title, struct grub_script *script,
+grub_normal_menu_addentry (int argc, const char **args, struct grub_script *script,
const char *sourcecode)
{
- const char *menutitle;
+ const char *menutitle = 0;
const char *menusourcecode;
grub_menu_t menu;
grub_menu_entry_t *last;
+ int failed = 0;
+ int i;
+ struct grub_menu_entry_class *classes_head; /* Dummy head node for list. */
+ struct grub_menu_entry_class *classes_tail;
+
+ /* Allocate dummy head node for class list. */
+ classes_head = grub_malloc (sizeof (struct grub_menu_entry_class));
+ if (! classes_head)
+ return grub_errno;
+ classes_head->name = 0;
+ classes_head->next = 0;
+ classes_tail = classes_head;
menu = grub_env_get_data_slot("menu");
if (! menu)
@@ -167,10 +194,81 @@
if (! menusourcecode)
return grub_errno;
- menutitle = grub_strdup (title);
- if (! menutitle)
- {
+ /* Parse menu arguments. */
+ for (i = 0; i < argc; i++)
+ {
+ /* Capture arguments. */
+ if (grub_strncmp ("--", args[i], 2) == 0)
+ {
+ const char *arg = &args[i][2];
+
+ /* Handle menu class. */
+ if (grub_strcmp(arg, "class") == 0)
+ {
+ char *class_name;
+ struct grub_menu_entry_class *new_class;
+
+ i++;
+ class_name = grub_strdup (args[i]);
+ if (! class_name)
+ {
+ failed = 1;
+ break;
+ }
+
+ /* Create a new class and add it at the tail of the list. */
+ new_class = grub_malloc (sizeof (struct grub_menu_entry_class));
+ if (! new_class)
+ {
+ grub_free (class_name);
+ failed = 1;
+ break;
+ }
+ /* Fill in the new class node. */
+ new_class->name = class_name;
+ new_class->next = 0;
+ /* Link the tail to it, and make it the new tail. */
+ classes_tail->next = new_class;
+ classes_tail = new_class;
+ continue;
+ }
+ else
+ {
+ /* Handle invalid argument. */
+ failed = 1;
+ grub_error (GRUB_ERR_MENU, "invalid argument for menuentry: %s", args[i]);
+ break;
+ }
+ }
+
+ /* Capture title. */
+ if (! menutitle)
+ {
+ menutitle = grub_strdup (args[i]);
+ }
+ else
+ {
+ failed = 1;
+ grub_error (GRUB_ERR_MENU, "too many titles for menuentry: %s", args[i]);
+ break;
+ }
+ }
+
+ /* Validate arguments. */
+ if ((! failed) && (! menutitle))
+ {
+ grub_error (GRUB_ERR_MENU, "menuentry is missing title");
+ failed = 1;
+ }
+
+ /* If argument parsing failed, free any allocated resources. */
+ if (failed)
+ {
+ free_menu_entry_classes (classes_head);
+ grub_free ((void *) menutitle);
grub_free ((void *) menusourcecode);
+
+ /* Here we assume that grub_error has been used to specify failure details. */
return grub_errno;
}
@@ -181,6 +279,7 @@
*last = grub_malloc (sizeof (**last));
if (! *last)
{
+ free_menu_entry_classes (classes_head);
grub_free ((void *) menutitle);
grub_free ((void *) menusourcecode);
return grub_errno;
@@ -188,6 +287,7 @@
(*last)->commands = script;
(*last)->title = menutitle;
+ (*last)->classes = classes_head;
(*last)->next = 0;
(*last)->sourcecode = menusourcecode;
=== modified file 'normal/parser.y'
--- normal/parser.y 2008-07-02 00:00:37 +0000
+++ normal/parser.y 2008-10-13 16:15:06 +0000
@@ -204,7 +204,7 @@
;
/* A menu entry. Carefully save the memory that is allocated. */
-menuentry: "menuentry" argument
+menuentry: "menuentry" arguments
{
grub_script_lexer_ref (state->lexerstate);
} newlines '{'
=== modified file 'normal/script.c'
--- normal/script.c 2007-12-30 08:52:06 +0000
+++ normal/script.c 2008-10-13 16:15:06 +0000
@@ -206,7 +206,7 @@
The options for this entry are passed in OPTIONS. */
struct grub_script_cmd *
grub_script_create_cmdmenu (struct grub_parser_param *state,
- struct grub_script_arg *title,
+ struct grub_script_arglist *arglist,
char *sourcecode,
int options)
{
@@ -232,9 +232,9 @@
cmd->cmd.next = 0;
/* XXX: Check if this memory is properly freed. */
cmd->sourcecode = sourcecode;
- cmd->title = title;
+ cmd->arglist = arglist;
cmd->options = options;
-
+
return (struct grub_script_cmd *) cmd;
}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] GSoC #05 Menu entry class attribute (v2)
2008-10-13 16:35 ` [PATCH] GSoC #05 Menu entry class attribute (v2) Colin D Bennett
@ 2009-01-31 9:19 ` Vesa Jääskeläinen
2009-01-31 17:49 ` Colin D Bennett
0 siblings, 1 reply; 5+ messages in thread
From: Vesa Jääskeläinen @ 2009-01-31 9:19 UTC (permalink / raw)
To: The development of GRUB 2
Colin D Bennett wrote:
> Thanks for the argument parsing improvement. I'm glad to rip out the
> '|class=' title kludge. Here is the result of merging your patch into
> the menu entry class code.
Hi Colin,
I combined your menu entry and menu viewer patches and committed them in
with slight modifications. See if you are happy with it :)
Oh. And btw. I think I am out of sync what is still missing. So let me
know if you think there is something critical that needs to be there in
order to integrate your gfxmenu.
As you have now commit access please be free to consult list and commit
small changes yourself.
Thanks,
Vesa Jääskeläinen
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] GSoC #05 Menu entry class attribute (v2)
2009-01-31 9:19 ` Vesa Jääskeläinen
@ 2009-01-31 17:49 ` Colin D Bennett
0 siblings, 0 replies; 5+ messages in thread
From: Colin D Bennett @ 2009-01-31 17:49 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 948 bytes --]
On Sat, 31 Jan 2009 11:19:51 +0200
Vesa Jääskeläinen <chaac@nic.fi> wrote:
> I combined your menu entry and menu viewer patches and committed them in
> with slight modifications. See if you are happy with it :)
Looks good.
> Oh. And btw. I think I am out of sync what is still missing. So let me
> know if you think there is something critical that needs to be there in
> order to integrate your gfxmenu.
There are a few features that are still needed:
- multiple fallback entries
- VBE double buffering
- bitmap scaling
- videotest enhancements (useful for testing, but also provides
'grub_rect_t' type used by gfxmenu)
I just synchronized my patch stack with the latest GRUB (SVN trunk rev
1964). I will post separately with these updated patches for
discussion and consideration.
> As you have now commit access please be free to consult list and commit
> small changes yourself.
OK.
Regards,
Colin
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-01-31 17:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-31 6:52 [PATCH] GSoC #05 Menu entry class attribute Colin D Bennett
2008-10-05 10:07 ` Vesa Jääskeläinen
2008-10-13 16:35 ` [PATCH] GSoC #05 Menu entry class attribute (v2) Colin D Bennett
2009-01-31 9:19 ` Vesa Jääskeläinen
2009-01-31 17:49 ` Colin D Bennett
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.