[syslinux] Final line of menu selectable even if it is disabled
Matt Fleming
matt at console-pimps.org
Fri Oct 12 04:57:24 PDT 2012
On Fri, 2012-10-12 at 02:46 +0200, Ady wrote:
> I have tested ldlinux.sys 4.06pre13 with menu.c32 and a cfg file with
> several entries; the last one being disabled.
>
> There is still one way to "select" (but not act on) the last menu
> entry even if it has a MENU DISABLE directive: press [END] :).
>
> Other keys I tested (and they successfully won't allow me to select
> the last disabled menu entry): arrows, PageDown, space bar.
>
> So it seems [END] is the last one that needs correction for this
> case.
Thanks for testing this! You're right, I didn't handle the KEY_END case
and reading the code carefully I think there's also a 'PGDN/RIGHT/>'
case that isn't handled. The same logic is split into multiple code
paths, and that makes me cry.
Commit c823574f53c1 ("menu: Don't highlight disabled entries") goes some
way to fixing the issue, but as you've pointed out, doesn't fix every
case. Close, but no cigar.
I wrote a bunch more tests and the following patch seems to work with
all the cases I tried,
diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c
index 7c58979..8573901 100644
--- a/com32/menu/menumain.c
+++ b/com32/menu/menumain.c
@@ -806,7 +806,7 @@ static const char *run_menu(void)
while (entry < cm->nentries && is_disabled(cm->menu_entries[entry]))
entry++;
}
- if (entry >= cm->nentries) {
+ if (entry >= cm->nentries - 1) {
entry = cm->nentries - 1;
while (entry > 0 && is_disabled(cm->menu_entries[entry]))
entry--;
@@ -958,7 +958,8 @@ static const char *run_menu(void)
case KEY_DOWN:
case KEY_CTRL('N'):
- while (++entry < cm->nentries) {
+ while (entry < cm->nentries - 1) {
+ entry++;
if (entry >= top + MENU_ROWS)
top += MENU_ROWS;
if (!is_disabled(cm->menu_entries[entry]))
It basically reverts commit c823574f53c1 and moves the fix to the
beginning of the while loop so that it fixes all keys. Now, I know that
neither you nor Matt are in a position to apply this patch and build
your own release, so we'll have to do a -pre14 early next week with this
applied and attempt another round of testing.
--
Matt Fleming, Intel Open Source Technology Center
More information about the Syslinux
mailing list