PATCH: checkkey returns boolean
Hello,
This patch makes the grub_checkkey() function return a boolean value (1 = a key is available, 0 = none).
I have tested it with play.mod, and it works OK.
Note that the grub_console_checkkey() function in term/efi/console.c already (erroneously) assumed a boolean value, so this patch automatically fixes that.
Cheers,
--
Andrew Apted <[email protected]>
Index: ChangeLog
===================================================================
RCS file: /sources/grub/grub2/ChangeLog,v retrieving revision 1.262
ChangeLog +13 -0
@@ -1,3 +1,16 @@ +2006-05-12 Andrew Apted <[email protected]> + + * include/grub/term.h: changed API of grub_checkkey() to + return a boolean value (1 = key available, 0 = none). + + * commands/i386/pc/play.c (grub_cmd_play): Likewise. + * kern/i386/pc/startup.S (grub_console_checkkey): Likewise. + * normal/menu.c (run_menu): Likewise. + * term/i386/pc/serial.c (grub_serial_checkkey): Likewise. + (serial_hw_init): Likewise. + * term/ieee1275/ofconsole.c (grub_ofconsole_checkkey): Likewise. + * util/console.c (grub_ncurses_checkkey): Likewise. + 2006-05-09 Vesa Jaaskelainen <[email protected]> * video/i386/pc/vbe.c (grub_video_vbe_fill_rect): Corrected bounds
Index: commands/i386/pc/play.c
===================================================================
RCS file: /sources/grub/grub2/commands/i386/pc/play.c,v retrieving revision 1.1
i386/pc/play.c +3 -3
@@ -186,7 +186,7 @@while (grub_file_read (file, (void *) &buf,sizeof (struct note )) ==sizeof (struct note ) - && buf.pitch !=T_FINE &&grub_checkkey () <0 ) + && buf.pitch !=T_FINE && !grub_checkkey ()) { grub_dprintf ("play", "pitch = %d, duration = %d\n", buf.pitch,
@@ -204,7 +204,7 @@ } to =grub_get_rtc () +BASE_TEMPO * buf.duration / tempo; -while (((unsigned int )grub_get_rtc () <= to) && (grub_checkkey () <0 )) +while (((unsigned int )grub_get_rtc () <= to) && !grub_checkkey ()) ; }
@@ -213,7 +213,7 @@grub_file_close (file); -while (grub_checkkey () >0 ) +while (grub_checkkey ())grub_getkey ();return 0 ;
Index: include/grub/term.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/term.h,v retrieving revision 1.10
grub/term.h +2 -1
@@ -140,7 +140,8 @@encoded in Unicode. */ grub_ssize_t (*getcharwidth) (grub_uint32_t c); -/* Check if any input character is available. */ +/* Check if any input character is available. +The return value is boolean (1 = available, 0 = none). */ int (*checkkey) (void );/* Get a character. */
Index: kern/i386/pc/startup.S
===================================================================
RCS file: /sources/grub/grub2/kern/i386/pc/startup.S,v retrieving revision 1.22
i386/pc/startup.S +3 -7
@@ -1446,7 +1446,7 @@ /* * int grub_console_checkkey (void) - * if there is a character pending, return it; otherwise return -1 + * if there is a character pending, return 1; otherwise return 0 * BIOS call "INT 16H Function 01H" to check whether a character is pending * Call with %ah = 0x1 * Return:
@@ -1467,15 +1467,11 @@ movb $0x1, %ah int $0x16 - jz notpending + jz notpending - movw %ax, %dx - DATA32 jmp pending + incl %edx notpending: - decl %edx - -pending: DATA32 call real_to_prot .code32
Index: normal/menu.c
===================================================================
RCS file: /sources/grub/grub2/normal/menu.c,v retrieving revision 1.16
menu.c +1 -1
@@ -340,7 +340,7 @@return default_entry; } -if (grub_checkkey () >=0 || timeout <0 ) +if (grub_checkkey () || timeout <0 ) { c =GRUB_TERM_ASCII_CHAR (grub_getkey ());
Index: term/i386/pc/serial.c
===================================================================
RCS file: /sources/grub/grub2/term/i386/pc/serial.c,v retrieving revision 1.2
i386/pc/serial.c +2 -5
@@ -254,10 +254,7 @@static int grub_serial_checkkey (void ) { -if (fill_input_buf (1 )) -return input_buf[0 ]; -else -return -1 ; +return (fill_input_buf (1 ) >0 ); }/* The serial version of getkey. */
@@ -310,7 +307,7 @@outb (serial_settings.port +UART_MCR ,UART_ENABLE_MODEM );/* Drain the input buffer. */ -while (grub_serial_checkkey () !=-1 ) +while (grub_serial_checkkey ()) (void )grub_serial_getkey ();/* FIXME: should check if the serial terminal was found. */
Index: term/ieee1275/ofconsole.c
===================================================================
RCS file: /sources/grub/grub2/term/ieee1275/ofconsole.c,v retrieving revision 1.9
ieee1275/ofconsole.c +1 -1
@@ -196,7 +196,7 @@return 1 ; } -return -1 ; +return 0 ; } static int
Index: util/console.c
===================================================================
RCS file: /sources/grub/grub2/util/console.c,v retrieving revision 1.13
console.c +3 -3
@@ -131,7 +131,7 @@/* Check for SAVED_CHAR. This should not be true, because this means checkkey is called twice continuously. */ if (saved_char !=ERR ) -return saved_char; +return 1 ;wtimeout (stdscr,100 ); c =getch ();
@@ -139,10 +139,10 @@if (c !=ERR ) { saved_char = c; -return c; +return 1 ; } -return -1 ; +return 0 ; } static int