diff options
| author | David Schultz <das@FreeBSD.org> | 2008-01-14 09:21:34 +0000 |
|---|---|---|
| committer | David Schultz <das@FreeBSD.org> | 2008-01-14 09:21:34 +0000 |
| commit | ac48ad2e5e553248a7a5991659a68ecdcacf8ef3 (patch) | |
| tree | 3137383c3994f8c968e34bf433390de9341541f0 /lib/libc/stdlib/qsort.c | |
| parent | 8b7399ad30cab008c489af8064ea984eb67b1c8c (diff) | |
Notes
Diffstat (limited to 'lib/libc/stdlib/qsort.c')
| -rw-r--r-- | lib/libc/stdlib/qsort.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c index 0958cd3f0fcf..3687b0579ffd 100644 --- a/lib/libc/stdlib/qsort.c +++ b/lib/libc/stdlib/qsort.c @@ -112,6 +112,7 @@ qsort(void *a, size_t n, size_t es, cmp_t *cmp) { char *pa, *pb, *pc, *pd, *pl, *pm, *pn; size_t d, r; + int cmp_result; int swaptype, swap_cnt; loop: SWAPINIT(a, es); @@ -141,16 +142,16 @@ loop: SWAPINIT(a, es); pc = pd = (char *)a + (n - 1) * es; for (;;) { - while (pb <= pc && (r = CMP(thunk, pb, a)) <= 0) { - if (r == 0) { + while (pb <= pc && (cmp_result = CMP(thunk, pb, a)) <= 0) { + if (cmp_result == 0) { swap_cnt = 1; swap(pa, pb); pa += es; } pb += es; } - while (pb <= pc && (r = CMP(thunk, pc, a)) >= 0) { - if (r == 0) { + while (pb <= pc && (cmp_result = CMP(thunk, pc, a)) >= 0) { + if (cmp_result == 0) { swap_cnt = 1; swap(pc, pd); pd -= es; |
