summaryrefslogtreecommitdiff
path: root/console-client/xkb
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-05-23 10:42:36 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-05-23 10:42:36 +0200
commit0df1499b87688d3e9ff6132617dac1631b7733f4 (patch)
treedc761e3017aaa103087bb5524a12f978d7480124 /console-client/xkb
parent805d5bb95aacfaecde4d668beecff31570eaa2ca (diff)
console-client: avoid nested function
* console-client/xkb/kstoucs.c (find_ucs): Previously, this function was a nested function for no reason at all. Turn it into a normal function.
Diffstat (limited to 'console-client/xkb')
-rw-r--r--console-client/xkb/kstoucs.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/console-client/xkb/kstoucs.c b/console-client/xkb/kstoucs.c
index 0211e9e3..81e71b9b 100644
--- a/console-client/xkb/kstoucs.c
+++ b/console-client/xkb/kstoucs.c
@@ -5,6 +5,24 @@ struct ksmap {
#include "kstoucs_map.c"
+/* Binary search through `kstoucs_map'. */
+static unsigned int
+find_ucs (int keysym, struct ksmap *first, struct ksmap *last)
+{
+ struct ksmap *middle = first + (last - first) / 2;
+
+ if (middle->keysym == keysym)
+ return middle->ucs; /* base case: needle found. */
+ else if (middle == first && middle == last)
+ return 0; /* base case: empty search space. */
+ /* recursive cases: halve search space. */
+ else if (middle->keysym < keysym)
+ return find_ucs (keysym, middle+1, last);
+ else if (middle->keysym > keysym)
+ return find_ucs (keysym, first, middle-1);
+ return 0;
+}
+
unsigned int
KeySymToUcs4 (int keysym)
{
@@ -23,23 +41,6 @@ unsigned int doit (int keysym)
if ((keysym & 0xff000000) == 0x01000000)
return (keysym & 0x00ffffff);
- unsigned int
- find_ucs (int keysym, struct ksmap *first, struct ksmap *last)
- {
- struct ksmap *middle = first + (last - first) / 2;
-
- if (middle->keysym == keysym)
- return middle->ucs; /* base case: needle found. */
- else if (middle == first && middle == last)
- return 0; /* base case: empty search space. */
- /* recursive cases: halve search space. */
- else if (middle->keysym < keysym)
- return find_ucs (keysym, middle+1, last);
- else if (middle->keysym > keysym)
- return find_ucs (keysym, first, middle-1);
- return 0;
- }
-
#define NUM_KEYSYMS (sizeof kstoucs_map / sizeof(struct ksmap))
return find_ucs(keysym, &kstoucs_map[0], &kstoucs_map[NUM_KEYSYMS - 1]);
#ifdef XKB_DEBUG