Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/sort Fix sort -u, PR/42094
details: https://anonhg.NetBSD.org/src/rev/f3afdab195ca
branches: trunk
changeset: 747539:f3afdab195ca
user: dsl <dsl%NetBSD.org@localhost>
date: Sat Sep 19 16:18:00 2009 +0000
description:
Fix sort -u, PR/42094
diffstat:
usr.bin/sort/radix_sort.c | 42 ++++++++++++++++++++++--------------------
1 files changed, 22 insertions(+), 20 deletions(-)
diffs (66 lines):
diff -r 32213858ebcc -r f3afdab195ca usr.bin/sort/radix_sort.c
--- a/usr.bin/sort/radix_sort.c Sat Sep 19 14:57:27 2009 +0000
+++ b/usr.bin/sort/radix_sort.c Sat Sep 19 16:18:00 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: radix_sort.c,v 1.3 2009/09/10 22:02:40 dsl Exp $ */
+/* $NetBSD: radix_sort.c,v 1.4 2009/09/19 16:18:00 dsl Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)radixsort.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: radix_sort.c,v 1.3 2009/09/10 22:02:40 dsl Exp $");
+__RCSID("$NetBSD: radix_sort.c,v 1.4 2009/09/19 16:18:00 dsl Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -184,27 +184,29 @@
s_len = akh->keylen;
for (ai = ak; ;) {
ai--;
- t = (*ai)->data;
t_len = (*ai)->keylen;
- for (i = data_index; ; i++) {
- if (i >= s_len || i >= t_len) {
- r = s_len - t_len;
+ if (t_len != -1) {
+ t = (*ai)->data;
+ for (i = data_index; ; i++) {
+ if (i >= s_len || i >= t_len) {
+ r = s_len - t_len;
+ break;
+ }
+ r = s[i] - t[i];
+ if (r != 0)
+ break;
+ }
+ if (r >= 0) {
+ if (r == 0 && UNIQUE) {
+ /* Put record below existing */
+ ai[1] = ai[0];
+ /* Mark as duplicate - ignore */
+ akh->keylen = -1;
+ } else {
+ ai++;
+ }
break;
}
- r = s[i] - t[i];
- if (r != 0)
- break;
- }
- if (r >= 0) {
- if (r == 0 && UNIQUE) {
- /* Put record below existing */
- ai[1] = ai[0];
- /* Mark so ignored by output() */
- akh->keylen = -1;
- } else {
- ai++;
- }
- break;
}
ai[1] = ai[0];
if (ai == a)
Home |
Main Index |
Thread Index |
Old Index