소스 검색

Fix the ordering of the args to the compare function.

Manuel Novoa III 23 년 전
부모
커밋
7cbba5f8ce
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      libc/stdlib/bsearch.c

+ 3 - 3
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;