summaryrefslogtreecommitdiff
path: root/libc/stdlib
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2001-02-08 02:57:48 +0000
committerManuel Novoa III <mjn3@codepoet.org>2001-02-08 02:57:48 +0000
commit7cbba5f8ce986851c4a3764ceee4cda3f3cd156f (patch)
treeae61120a6616b745dff02a2359a70b254c30fedc /libc/stdlib
parentd63b6766dbd3ca3c713a3f142b09e750af067dc2 (diff)
Fix the ordering of the args to the compare function.
Diffstat (limited to 'libc/stdlib')
-rw-r--r--libc/stdlib/bsearch.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libc/stdlib/bsearch.c b/libc/stdlib/bsearch.c
index 04d5ab68b..c5a78959a 100644
--- a/libc/stdlib/bsearch.c
+++ b/libc/stdlib/bsearch.c
@@ -27,10 +27,10 @@ register int (*cmp) (); /* comparison function */
b = num - 1;
while (a <= b) {
c = (a + b) >> 1; /* == ((a + b) / 2) */
- if ((dir = (*cmp) ((base + (c * size)), key))) {
- if (dir > 0)
+ if ((dir = (*cmp) (key, (base + (c * size))))) {
+ if (dir < 0)
b = c - 1;
- else /* (dir < 0) */
+ else /* (dir > 0) */
a = c + 1;
} else {
_bsearch = c;