2009-06-11 Pavel Roskin <proski@gnu.org>
* term/i386/pc/serial.c (serial_translate_key_sequence): Avoid casts to short - they are not portable and cause warnings. Fix use of uninitialized values in input_buf. Use ARRAY_SIZE.
This commit is contained in:
parent
63963d17d0
commit
a0c62e4e28
2 changed files with 21 additions and 21 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2009-06-11 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* term/i386/pc/serial.c (serial_translate_key_sequence): Avoid
|
||||||
|
casts to short - they are not portable and cause warnings. Fix
|
||||||
|
use of uninitialized values in input_buf. Use ARRAY_SIZE.
|
||||||
|
|
||||||
2009-06-11 Vladimir Serbinenko <phcoder@gmail.com>
|
2009-06-11 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Drivemap fixes
|
Drivemap fixes
|
||||||
|
|
|
@ -112,6 +112,7 @@ serial_hw_put (const int c)
|
||||||
static void
|
static void
|
||||||
serial_translate_key_sequence (void)
|
serial_translate_key_sequence (void)
|
||||||
{
|
{
|
||||||
|
unsigned int i;
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char key;
|
char key;
|
||||||
|
@ -141,34 +142,27 @@ serial_translate_key_sequence (void)
|
||||||
{('6' | ('~' << 8)), 3}
|
{('6' | ('~' << 8)), 3}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The buffer must start with "ESC [". */
|
if (npending < 3)
|
||||||
if (*((unsigned short *) input_buf) != ('\e' | ('[' << 8)))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (npending >= 3)
|
/* The buffer must start with "ESC [". */
|
||||||
{
|
if (input_buf[0] != '\e' || input_buf[1] != '[')
|
||||||
unsigned int i;
|
return;
|
||||||
|
|
||||||
for (i = 0;
|
for (i = 0; ARRAY_SIZE (three_code_table); i++)
|
||||||
i < sizeof (three_code_table) / sizeof (three_code_table[0]);
|
if (three_code_table[i].key == input_buf[2])
|
||||||
i++)
|
{
|
||||||
if (three_code_table[i].key == input_buf[2])
|
input_buf[0] = three_code_table[i].ascii;
|
||||||
{
|
npending -= 2;
|
||||||
input_buf[0] = three_code_table[i].ascii;
|
grub_memmove (input_buf + 1, input_buf + 3, npending - 1);
|
||||||
npending -= 2;
|
return;
|
||||||
grub_memmove (input_buf + 1, input_buf + 3, npending - 1);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (npending >= 4)
|
if (npending >= 4)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
short key = input_buf[3] | (input_buf[4] << 8);
|
||||||
short key = *((short *) (input_buf + 2));
|
|
||||||
|
|
||||||
for (i = 0;
|
for (i = 0; i < ARRAY_SIZE (four_code_table); i++)
|
||||||
i < sizeof (four_code_table) / sizeof (four_code_table[0]);
|
|
||||||
i++)
|
|
||||||
if (four_code_table[i].key == key)
|
if (four_code_table[i].key == key)
|
||||||
{
|
{
|
||||||
input_buf[0] = four_code_table[i].ascii;
|
input_buf[0] = four_code_table[i].ascii;
|
||||||
|
|
Loading…
Add table
Reference in a new issue