]> git.saurik.com Git - apple/libc.git/blobdiff - stdlib/FreeBSD/radixsort.c
Libc-498.1.7.tar.gz
[apple/libc.git] / stdlib / FreeBSD / radixsort.c
index 7f149669df1907e4941b2142ee41d35b7cd0c98b..5f9eaebc6ec47c69e09094706016d11ac9901caa 100644 (file)
@@ -38,7 +38,7 @@
 static char sccsid[] = "@(#)radixsort.c        8.2 (Berkeley) 4/28/95";
 #endif /* LIBC_SCCS and not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/stdlib/radixsort.c,v 1.6 2002/03/22 09:18:34 obrien Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/radixsort.c,v 1.7 2003/11/11 04:59:23 kientzle Exp $");
 
 /*
  * Radixsort routines.
@@ -176,6 +176,17 @@ r_sort_a(a, n, i, tr, endch)
                        }
                }
 
+               /*
+                * Special case: if all strings have the same
+                * character at position i, move on to the next
+                * character.
+                */
+               if (nc == 1 && count[bmin] == n) {
+                       push(a, n, i+1);
+                       nc = count[bmin] = 0;
+                       continue;
+               }
+
                /*
                 * Set top[]; push incompletely sorted bins onto stack.
                 * top[] = pointers to last out-of-place element in bins.