[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 02/15: console-client: avoid nested function
From: |
Samuel Thibault |
Subject: |
[hurd] 02/15: console-client: avoid nested function |
Date: |
Sun, 05 Jul 2015 00:41:59 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 0df1499b87688d3e9ff6132617dac1631b7733f4
Author: Justus Winter <address@hidden>
Date: Sat May 23 10:42:36 2015 +0200
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.
---
console-client/xkb/kstoucs.c | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/console-client/xkb/kstoucs.c b/console-client/xkb/kstoucs.c
index 0211e9e..81e71b9 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
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] branch upstream updated (eef94c4 -> 3dc2076), Samuel Thibault, 2015/07/04
- [hurd] 01/15: console-client: fix build with -O0, Samuel Thibault, 2015/07/04
- [hurd] 02/15: console-client: avoid nested function,
Samuel Thibault <=
- [hurd] 09/15: libdiskfs: do not print a message on ENOMEM, Samuel Thibault, 2015/07/04
- [hurd] 15/15: Merge remote-tracking branch 'upstream/master' into upstream, Samuel Thibault, 2015/07/04
- [hurd] 08/15: Check AWK usability when XKB is enabled, Samuel Thibault, 2015/07/04
- [hurd] 07/15: console-client: Fix lower range of binary search, Samuel Thibault, 2015/07/04
- [hurd] 04/15: utils/rpctrace: fix build with -O0, Samuel Thibault, 2015/07/04
- [hurd] 06/15: console-client: assert precondition, Samuel Thibault, 2015/07/04
- [hurd] 05/15: utils/vmstat: fix integer overflow, Samuel Thibault, 2015/07/04
- [hurd] 03/15: console-client: fix binary search, Samuel Thibault, 2015/07/04
- [hurd] 11/15: Cope with scripts which chmod -x directories, Samuel Thibault, 2015/07/04
- [hurd] 10/15: Fix ps -o %r infinite loop, Samuel Thibault, 2015/07/04