grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: default menuentry matching similar entries is broken


From: Andreas Vogel
Subject: Re: default menuentry matching similar entries is broken
Date: Sat, 03 Mar 2012 19:10:28 +0100
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

> Hi,
>
>   This code in menu.c::menuentry_eq() looks wrong:
>
> {
>   const char *ptr1, *ptr2;
>   ptr1 = title;
>   ptr2 = spec;
>   while (1)
>     {
>       if (*ptr2 == '>' && ptr2[1] != '>' && *ptr1 == 0)
>         return 1;
>       if (*ptr2 == '>' && ptr2[1] != '>')
>         return 0;
>       if (*ptr2 == '>')
>         ptr2++;
>       if (*ptr1 != *ptr2)
>         return 0;
>       if (*ptr1 == 0)   <----
>         return 1;
>       ptr1++;
>       ptr2++;
>     }
> }
>
>
>   Specifically, if there are two menuentries that differ by adding 
> characters, this function will match the wrong one, i.e.:
>
> set default='entry a with more words'
>
> menuentry "entry a" {
> }
>
> menuentry "entry a with more words" {
> }
As far as I understand the code, using submenu references in the default
variable for automatic booting is not working at all.
This is due to the dynamic loading of submenus. When a menu is opened
and run, only the direct menu entries are known. Searching for menu
entries deeper in the menu tree is not done.

Let's consider this scenario:

set default="b>c>c1"

menuentry a { ... }
submenu b {
    submenu c {
        menuentry c1 { ... }
    }
}

When the toplevel menu is run, the code just knows about entries a and b
(entries c and c1 are not know at this moment).
Searching and booting the menu entry according to the default variable
doesn't work. Actually I didn't try this, that's just from code reading
so i might be wrong.

IMHO, right now the menuentry_eq() function is overkill as a normal
strcmp() would be sufficient.

Furthermore it's strange that calling
    menuentry_eq ("a>b", "a>b")
returns 0. I didn't expect this result.


Andreas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]