[syslinux:elflink] ldlinux: Fix detection of function keys

syslinux-bot for Matt Fleming matt.fleming at intel.com
Mon Mar 26 15:36:04 PDT 2012


Commit-ID:  65377fc66c4e0877a9bcc511cdc92b5a05e23822
Gitweb:     http://www.syslinux.org/commit/65377fc66c4e0877a9bcc511cdc92b5a05e23822
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Thu, 1 Mar 2012 11:54:13 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Fri, 23 Mar 2012 16:34:41 +0000

ldlinux: Fix detection of function keys

__get_key() directly calls getchar() but doesn't properly detect when
a function key such as F1, F2, etc has been entered. Despite the
previous commit to cli.c which read,

    ldlinux: Accept commands from the serial console

    To mimic the old (pre-elflink) command-line interface behaviour let's
    use getchar() instead of reading from stdin. This way, if the user
    types a command on the serial console it will actually be executed.

I can't see how get_key() fails to detect input on the serial
console. So let's revert to calling get_key() because it actually
handles the detection of function keys.

Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 com32/elflink/ldlinux/cli.c |   29 ++---------------------------
 1 files changed, 2 insertions(+), 27 deletions(-)

diff --git a/com32/elflink/ldlinux/cli.c b/com32/elflink/ldlinux/cli.c
index 7b2da88..8be8c17 100644
--- a/com32/elflink/ldlinux/cli.c
+++ b/com32/elflink/ldlinux/cli.c
@@ -29,31 +29,6 @@ void clear_screen(void)
     fputs("\033e\033%@\033)0\033(B\1#0\033[?25l\033[2J", stdout);
 }
 
-static int __get_key(void)
-{
-    unsigned char buffer[KEY_MAXLEN];
-    int another;
-    int nc, rv;
-    int code;
-
-    nc = 0;
-    do {
-	buffer[nc++] = getchar();
-
-	another = 0;
-	rv = get_key_decode(buffer, nc, &code);
-	if (!rv)
-		return code;
-	else if (rv == 1)
-		another = 1;
-
-    } while (another);
-
-    /* We got an unrecognized sequence; return the first character */
-    /* We really should remember this and return subsequent characters later */
-    return buffer[0];
-}
-
 int mygetkey(clock_t timeout)
 {
     clock_t t0, t;
@@ -62,14 +37,14 @@ int mygetkey(clock_t timeout)
 
     //dprintf("enter");
     if (!totaltimeout)
-	return __get_key();
+	return get_key(stdin, 0);
 
     for (;;) {
 	tto = min(totaltimeout, INT_MAX);
 	to = timeout ? min(tto, timeout) : tto;
 
 	t0 = 0;
-	key = __get_key();
+	key = get_key(stdin, 0);
 	t = 0 - t0;
 
 	if (totaltimeout <= t)


More information about the Syslinux-commits mailing list