[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/8] Avoid hashing garbage for short keynames.
From: |
Diego Nieto Cid |
Subject: |
[PATCH 2/8] Avoid hashing garbage for short keynames. |
Date: |
Wed, 4 Aug 2010 04:20:00 -0300 |
---
xkbdata.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/xkbdata.c b/xkbdata.c
index bd23c46..1cba0d5 100644
--- a/xkbdata.c
+++ b/xkbdata.c
@@ -50,6 +50,14 @@ keyname_init ()
/* XXX: error. */
}
+static inline int
+keyname_hash(char *keyname)
+{
+ char tmp[5] = {0, 0, 0, 0, 0};
+ strncpy(tmp, keyname, 4);
+ return tmp[0] + (tmp[1] << 8) + (tmp[2] << 16) + (tmp[3] << 24);
+}
+
/* Assign the name KEYNAME to the keycode KEYCODE. */
error_t
keyname_add (char *keyname, int keycode)
@@ -74,7 +82,7 @@ keyname_add (char *keyname, int keycode)
kn->keycode = keycode;
kn->rmods = 0;
- kn_int = keyname[0] + (keyname[1] << 8) + (keyname[2] << 16) + (keyname[3]
<< 24);
+ kn_int = keyname_hash(keyname);
debug_printf ("add : %d\n", kn_mapping.locp_offset);
hurd_ihash_add (&kn_mapping, kn_int, kn);
@@ -98,7 +106,7 @@ keyname_find (char *keyname)
/* XXX: Abort? */
return 0;
}
- kn_int = keyname[0] + (keyname[1] << 8) + (keyname[2] << 16) + (keyname[3]
<< 24);
+ kn_int = keyname_hash(keyname);
kn = hurd_ihash_find (&kn_mapping, kn_int);
if (kn)
--
1.7.2
- [PATCH 1/8] Update the parser to work with current XKB files., (continued)
- [PATCH 1/8] Update the parser to work with current XKB files., Diego Nieto Cid, 2010/08/04
- Re: [PATCH 1/8] Update the parser to work with current XKB files., olafBuddenhagen, 2010/08/11
- Re: [PATCH 1/8] Update the parser to work, Diego Nieto Cid, 2010/08/11
- [PATCH 1/5] Add type to $$ in mid-rules., Diego Nieto Cid, 2010/08/11
- [PATCH 2/5] Lexer support for keycodes with +/- symbols and arbitrary level numbers., Diego Nieto Cid, 2010/08/11
- [PATCH 3/5] Skip to main file's default section when needed., Diego Nieto Cid, 2010/08/11
- [PATCH 4/5] Update key type assigment routine., Diego Nieto Cid, 2010/08/11
- [PATCH 5/5] Recreate xkb/keymap/hurd from xkeyboard-config-1.8's xfree86 keymap., Diego Nieto Cid, 2010/08/11
- [PATCH 4/8] Remove glue code and use mig to regenerate it., Diego Nieto Cid, 2010/08/04
- [PATCH 3/8] Rule vmod returns an int with the vmod's bit on., Diego Nieto Cid, 2010/08/04
- [PATCH 2/8] Avoid hashing garbage for short keynames.,
Diego Nieto Cid <=
[PATCH 5/8] Update code borrowed from console-client., Diego Nieto Cid, 2010/08/04
[PATCH 6/8] Add missing functions to input_driver_test., Diego Nieto Cid, 2010/08/04
[PATCH 7/8] Argument's default values are set independently., Diego Nieto Cid, 2010/08/04