parser: fix unrecognized keysym handling

Integer may be negative, so also need to test >= 0.
Also, $$ was left uninitialized if the keysym wasn't recognized.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2014-02-07 21:12:53 +02:00
parent 5dbd136435
commit 5547a82f2a
1 changed files with 9 additions and 3 deletions

View File

@ -710,14 +710,20 @@ KeySym : IDENT
| SECTION { $$ = XKB_KEY_section; } | SECTION { $$ = XKB_KEY_section; }
| Integer | Integer
{ {
if ($1 < 10) { /* XKB_KEY_0 .. XKB_KEY_9 */ if ($1 < 0) {
$$ = XKB_KEY_0 + $1; parser_warn(param, "unrecognized keysym");
$$ = XKB_KEY_NoSymbol;
}
else if ($1 < 10) { /* XKB_KEY_0 .. XKB_KEY_9 */
$$ = XKB_KEY_0 + (xkb_keysym_t) $1;
} }
else { else {
char buf[17]; char buf[17];
snprintf(buf, sizeof(buf), "0x%x", $1); snprintf(buf, sizeof(buf), "0x%x", $1);
if (!resolve_keysym(buf, &$$)) if (!resolve_keysym(buf, &$$)) {
parser_warn(param, "unrecognized keysym"); parser_warn(param, "unrecognized keysym");
$$ = XKB_KEY_NoSymbol;
}
} }
} }
; ;