blob: 47b18ba71400aeb3f6d25d192e76b3d7ec20b5fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
--- skey-1.1.5-orig/put.c 2008-09-21 10:12:06.000000000 +0200
+++ skey-1.1.5/put.c 2008-09-21 10:19:54.000000000 +0200
@@ -2206,27 +2206,17 @@
{
int i, j;
- for (;;) {
+ while (low <= high) {
i = (low + high) / 2;
if ((j = strncmp(w, Wp[i], 4)) == 0)
return i; /* Found it */
- if (high == low + 1)
- {
- /* Avoid effects of integer truncation in /2 */
- if (strncmp(w, Wp[high], 4) == 0)
- return high;
- else
- return -1;
- }
-
- if (low >= high)
- return -1; /* I don't *think* this can happen... */
if (j < 0)
- high = i; /* Search lower half */
+ high = i - 1; /* Search lower half */
else
- low = i; /* Search upper half */
+ low = i + 1; /* Search upper half */
}
+ return -1;
}
static void insert(char *s, int x, int start, int length)
|