Don't treat timeouts or the return key as an invalid choice; spotted by

Andreas Gustafsson.
This commit is contained in:
jmcneill 2009-09-14 10:42:42 +00:00
parent 2d48ac808c
commit 1b3357e5de
1 changed files with 10 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: bootmenu.c,v 1.7 2009/09/13 23:53:36 jmcneill Exp $ */
/* $NetBSD: bootmenu.c,v 1.8 2009/09/14 10:42:42 jmcneill Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -261,11 +261,15 @@ parsebootconf(const char *conf)
static int
getchoicefrominput(char *input, int def)
{
int choice;
int choice, usedef;
choice = -1;
if (*input == '\0' || *input == '\r' || *input == '\n')
usedef = 0;
if (*input == '\0' || *input == '\r' || *input == '\n') {
choice = def;
else if (*input >= 'A' && *input < bootconf.nummenu + 'A')
usedef = 1;
} else if (*input >= 'A' && *input < bootconf.nummenu + 'A')
choice = (*input) - 'A';
else if (*input >= 'a' && *input < bootconf.nummenu + 'a')
choice = (*input) - 'a';
@ -275,7 +279,8 @@ getchoicefrominput(char *input, int def)
choice = -1;
}
if (bootconf.menuformat != MENUFORMAT_LETTER && !isnum(*input))
if (bootconf.menuformat != MENUFORMAT_LETTER &&
!isnum(*input) && !usedef)
choice = -1;
return choice;