diff options
Diffstat (limited to 'src/lib/libc/stdlib/merge.c')
-rw-r--r-- | src/lib/libc/stdlib/merge.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/lib/libc/stdlib/merge.c b/src/lib/libc/stdlib/merge.c index 381fdc0830..1826acc369 100644 --- a/src/lib/libc/stdlib/merge.c +++ b/src/lib/libc/stdlib/merge.c | |||
@@ -13,11 +13,7 @@ | |||
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the |
15 | * documentation and/or other materials provided with the distribution. | 15 | * documentation and/or other materials provided with the distribution. |
16 | * 3. All advertising materials mentioning features or use of this software | 16 | * 3. Neither the name of the University nor the names of its contributors |
17 | * must display the following acknowledgement: | ||
18 | * This product includes software developed by the University of | ||
19 | * California, Berkeley and its contributors. | ||
20 | * 4. Neither the name of the University nor the names of its contributors | ||
21 | * may be used to endorse or promote products derived from this software | 17 | * may be used to endorse or promote products derived from this software |
22 | * without specific prior written permission. | 18 | * without specific prior written permission. |
23 | * | 19 | * |
@@ -35,8 +31,7 @@ | |||
35 | */ | 31 | */ |
36 | 32 | ||
37 | #if defined(LIBC_SCCS) && !defined(lint) | 33 | #if defined(LIBC_SCCS) && !defined(lint) |
38 | /*static char sccsid[] = "from: @(#)merge.c 8.2 (Berkeley) 2/14/94";*/ | 34 | static char *rcsid = "$OpenBSD: merge.c,v 1.6 2003/06/02 20:18:38 millert Exp $"; |
39 | static char *rcsid = "$Id: merge.c,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $"; | ||
40 | #endif /* LIBC_SCCS and not lint */ | 35 | #endif /* LIBC_SCCS and not lint */ |
41 | 36 | ||
42 | /* | 37 | /* |
@@ -59,8 +54,8 @@ static char *rcsid = "$Id: merge.c,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $"; | |||
59 | #include <stdlib.h> | 54 | #include <stdlib.h> |
60 | #include <string.h> | 55 | #include <string.h> |
61 | 56 | ||
62 | static void setup __P((u_char *, u_char *, size_t, size_t, int (*)())); | 57 | static void setup(u_char *, u_char *, size_t, size_t, int (*)()); |
63 | static void insertionsort __P((u_char *, size_t, size_t, int (*)())); | 58 | static void insertionsort(u_char *, size_t, size_t, int (*)()); |
64 | 59 | ||
65 | #define ISIZE sizeof(int) | 60 | #define ISIZE sizeof(int) |
66 | #define PSIZE sizeof(u_char *) | 61 | #define PSIZE sizeof(u_char *) |
@@ -100,7 +95,7 @@ mergesort(base, nmemb, size, cmp) | |||
100 | void *base; | 95 | void *base; |
101 | size_t nmemb; | 96 | size_t nmemb; |
102 | register size_t size; | 97 | register size_t size; |
103 | int (*cmp) __P((const void *, const void *)); | 98 | int (*cmp)(const void *, const void *); |
104 | { | 99 | { |
105 | register int i, sense; | 100 | register int i, sense; |
106 | int big, iflag; | 101 | int big, iflag; |
@@ -148,7 +143,7 @@ mergesort(base, nmemb, size, cmp) | |||
148 | sense = 0; | 143 | sense = 0; |
149 | } | 144 | } |
150 | if (!big) { /* here i = 0 */ | 145 | if (!big) { /* here i = 0 */ |
151 | LINEAR: while ((b += size) < t && cmp(q, b) >sense) | 146 | while ((b += size) < t && cmp(q, b) >sense) |
152 | if (++i == 6) { | 147 | if (++i == 6) { |
153 | big = 1; | 148 | big = 1; |
154 | goto EXPONENTIAL; | 149 | goto EXPONENTIAL; |
@@ -169,7 +164,7 @@ EXPONENTIAL: for (i = size; ; i <<= 1) | |||
169 | goto FASTCASE; | 164 | goto FASTCASE; |
170 | } else | 165 | } else |
171 | b = p; | 166 | b = p; |
172 | SLOWCASE: while (t > b+size) { | 167 | while (t > b+size) { |
173 | i = (((t - b) / size) >> 1) * size; | 168 | i = (((t - b) / size) >> 1) * size; |
174 | if ((*cmp)(q, p = b + i) <= sense) | 169 | if ((*cmp)(q, p = b + i) <= sense) |
175 | t = p; | 170 | t = p; |
@@ -258,7 +253,7 @@ COPY: b = t; | |||
258 | void | 253 | void |
259 | setup(list1, list2, n, size, cmp) | 254 | setup(list1, list2, n, size, cmp) |
260 | size_t n, size; | 255 | size_t n, size; |
261 | int (*cmp) __P((const void *, const void *)); | 256 | int (*cmp)(const void *, const void *); |
262 | u_char *list1, *list2; | 257 | u_char *list1, *list2; |
263 | { | 258 | { |
264 | int i, length, size2, tmp, sense; | 259 | int i, length, size2, tmp, sense; |
@@ -333,7 +328,7 @@ static void | |||
333 | insertionsort(a, n, size, cmp) | 328 | insertionsort(a, n, size, cmp) |
334 | u_char *a; | 329 | u_char *a; |
335 | size_t n, size; | 330 | size_t n, size; |
336 | int (*cmp) __P((const void *, const void *)); | 331 | int (*cmp)(const void *, const void *); |
337 | { | 332 | { |
338 | u_char *ai, *s, *t, *u, tmp; | 333 | u_char *ai, *s, *t, *u, tmp; |
339 | int i; | 334 | int i; |