From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1S3tPs-0001uT-9n for mharc-grub-devel@gnu.org; Sat, 03 Mar 2012 13:10:48 -0500 Received: from eggs.gnu.org ([208.118.235.92]:40654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3tPp-0001th-Cy for grub-devel@gnu.org; Sat, 03 Mar 2012 13:10:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S3tPn-0000ej-Kg for grub-devel@gnu.org; Sat, 03 Mar 2012 13:10:44 -0500 Received: from wp191.webpack.hosteurope.de ([80.237.132.198]:53206) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3tPn-0000eW-AH for grub-devel@gnu.org; Sat, 03 Mar 2012 13:10:43 -0500 Received: from p54ba694b.dip.t-dialin.net ([84.186.105.75] helo=neptun.omega.ssw.de); authenticated by wp191.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) id 1S3tPl-0006u6-JU; Sat, 03 Mar 2012 19:10:41 +0100 Received: from localhost (localhost [127.0.0.1]) by neptun.omega.ssw.de (Postfix) with ESMTP id BF78FE180A8 for ; Sat, 3 Mar 2012 19:10:40 +0100 (CET) X-Virus-Scanned: amavisd-new at omega.ssw.de Received: from neptun.omega.ssw.de ([127.0.0.1]) by localhost (neptun.omega.ssw.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d3b+S70QG7GY for ; Sat, 3 Mar 2012 19:10:29 +0100 (CET) Received: from [192.168.2.43] (p640.fritz.box [192.168.2.43]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by neptun.omega.ssw.de (Postfix) with ESMTP id D8EA3E180A7 for ; Sat, 3 Mar 2012 19:10:29 +0100 (CET) Message-ID: <4F525E94.2080304@anvo-it.de> Date: Sat, 03 Mar 2012 19:10:28 +0100 From: Andreas Vogel User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: The development of GNU GRUB Subject: Re: default menuentry matching similar entries is broken References: In-Reply-To: X-Enigmail-Version: 1.3.5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-bounce-key: webpack.hosteurope.de; andreas.vogel@anvo-it.de; 1330798243; 439b530a; X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.237.132.198 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Mar 2012 18:10:48 -0000 > 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