diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2001-02-08 02:57:48 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2001-02-08 02:57:48 +0000 |
commit | 7cbba5f8ce986851c4a3764ceee4cda3f3cd156f (patch) | |
tree | ae61120a6616b745dff02a2359a70b254c30fedc /libc/stdlib | |
parent | d63b6766dbd3ca3c713a3f142b09e750af067dc2 (diff) |
Fix the ordering of the args to the compare function.
Diffstat (limited to 'libc/stdlib')
-rw-r--r-- | libc/stdlib/bsearch.c | 6 |
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; |