diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-01-07 22:52:33 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-01-07 22:52:33 +0000 |
commit | 4846ad16579f7fcf06fe01e03a56815b2d8c4a93 (patch) | |
tree | e5266f60bcd3e2fbdb203a10b26c67970ddc45a8 /key-string.c | |
parent | 4924d8e1e2c367b9593a6972e1bcb65ab0cb0a93 (diff) |
Introduce nitems() and use it; use bsearch.
Diffstat (limited to 'key-string.c')
-rw-r--r-- | key-string.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/key-string.c b/key-string.c index 5e45d301..981ba21d 100644 --- a/key-string.c +++ b/key-string.c @@ -1,4 +1,4 @@ -/* $Id: key-string.c,v 1.8 2008-12-16 08:25:48 nicm Exp $ */ +/* $Id: key-string.c,v 1.9 2009-01-07 22:52:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -193,7 +193,6 @@ struct { { "KP0", KEYC_KP4_0 }, { "KP.", KEYC_KP4_2 }, }; -#define NKEYSTRINGS (sizeof key_string_table / sizeof key_string_table[0]) int key_string_lookup_string(const char *string) @@ -236,7 +235,7 @@ key_string_lookup_string(const char *string) return (KEYC_ADDESCAPE(key)); } - for (i = 0; i < NKEYSTRINGS; i++) { + for (i = 0; i < nitems(key_string_table); i++) { if (strcasecmp(string, key_string_table[i].string) == 0) return (key_string_table[i].key); } @@ -274,7 +273,7 @@ key_string_lookup_key(int key) return (tmp); } - for (i = 0; i < NKEYSTRINGS; i++) { + for (i = 0; i < nitems(key_string_table); i++) { if (key == key_string_table[i].key) return (key_string_table[i].string); } |