diff mbox

[7/10] prom_getchar eats characters

Message ID 20100411040559.GD11751@kryten
State Changes Requested
Headers show

Commit Message

Anton Blanchard April 11, 2010, 4:05 a.m. UTC
This bug has been annoying me for a long time. If you copy and paste a
string into the yaboot prompt, or even type too fast, characters get
dropped.

It turns out we were asking OF for 4 characters, but only using the first one.
There is strange logic to look for \e[, and then oring the third character with
0x100. I haven't been able to find anyone that knows why that was there in the
first place, so just remove it and fix this bug once and for all.

Automated test infrastructures the world over will thank us for fixing this
bug!

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Comments

Olof Johansson April 11, 2010, 3:15 p.m. UTC | #1
On Sun, Apr 11, 2010 at 02:05:59PM +1000, Anton Blanchard wrote:
> 
> This bug has been annoying me for a long time. If you copy and paste a
> string into the yaboot prompt, or even type too fast, characters get
> dropped.
> 
> It turns out we were asking OF for 4 characters, but only using the first one.
> There is strange logic to look for \e[, and then oring the third character with
> 0x100. I haven't been able to find anyone that knows why that was there in the
> first place, so just remove it and fix this bug once and for all.

My guess? To just silently drop vt100 arrow key codes. I don't think it'll
be missed, especially since it still doesn't handle the 4-character ones.

> Automated test infrastructures the world over will thank us for fixing this
> bug!

:)


-Olof
jschopp@austin.ibm.com April 12, 2010, 5:28 p.m. UTC | #2
> Automated test infrastructures the world over will thank us for fixing this
> bug!
>   
You are my new hero!
diff mbox

Patch

Index: yaboot/second/prom.c
===================================================================
--- yaboot.orig/second/prom.c	2010-04-11 11:17:21.000000000 +1000
+++ yaboot/second/prom.c	2010-04-11 11:31:05.000000000 +1000
@@ -387,16 +387,14 @@  prom_readblocks (prom_handle dev, int bl
 int
 prom_getchar ()
 {
-     char c[4];
+     char c;
      int a;
 
-     while ((a = (int)call_prom ("read", 3, 1, prom_stdin, c, 4)) == 0)
+     while ((a = (int)call_prom ("read", 3, 1, prom_stdin, &c, 1)) == 0)
 	  ;
      if (a == -1)
 	  prom_abort ("EOF on console\n");
-     if (a == 3 && c[0] == '\e' && c[1] == '[')
-	  return 0x100 | c[2];
-     return c[0];
+     return c;
 }
 
 int
@@ -511,8 +509,6 @@  prom_readline (char *prompt, char *buf, 
 
      while (i < len-1 && (c = prom_getchar ()) != '\r')
      {
-	  if (c >= 0x100)
-	       continue;
 	  if (c == 8)
 	  {
 	       if (i > 0)