From 7cbba5f8ce986851c4a3764ceee4cda3f3cd156f Mon Sep 17 00:00:00 2001 From: Manuel Novoa III Date: Thu, 8 Feb 2001 02:57:48 +0000 Subject: Fix the ordering of the args to the compare function. --- libc/stdlib/bsearch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libc') 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; -- cgit v1.2.3