summaryrefslogtreecommitdiffstats
path: root/input-keys.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-01-07 22:52:33 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-01-07 22:52:33 +0000
commit4846ad16579f7fcf06fe01e03a56815b2d8c4a93 (patch)
treee5266f60bcd3e2fbdb203a10b26c67970ddc45a8 /input-keys.c
parent4924d8e1e2c367b9593a6972e1bcb65ab0cb0a93 (diff)
Introduce nitems() and use it; use bsearch.
Diffstat (limited to 'input-keys.c')
-rw-r--r--input-keys.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/input-keys.c b/input-keys.c
index 69e0f859..cc7e8f8f 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -1,4 +1,4 @@
-/* $Id: input-keys.c,v 1.15 2008-12-22 17:26:51 nicm Exp $ */
+/* $Id: input-keys.c,v 1.16 2009-01-07 22:52:33 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -94,7 +94,6 @@ struct {
{ KEYC_KP4_0, "\033Op", 0 },
{ KEYC_KP4_2, "\033On", 0 },
};
-#define NINPUTKEYS (sizeof input_keys / sizeof input_keys[0])
/* Translate a key code from client into an output key sequence. */
void
@@ -114,7 +113,7 @@ input_key(struct window *w, int key)
return;
}
- for (i = 0; i < NINPUTKEYS; i++) {
+ for (i = 0; i < nitems(input_keys); i++) {
if ((input_keys[i].flags & INPUTKEY_KEYPAD) &&
!(w->screen->mode & MODE_KKEYPAD))
continue;
@@ -124,7 +123,7 @@ input_key(struct window *w, int key)
if (input_keys[i].key == key)
break;
}
- if (i == NINPUTKEYS) {
+ if (i == nitems(input_keys)) {
log_debug2("key 0x%x missing", key);
return;
}