diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2022-07-29 16:40:00 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2022-07-29 16:40:00 +0200 |
commit | 5479c435fde32e720af5e177e95d6364a422885a (patch) | |
tree | 2368af30b56c3be0f8e4a14cc7d09be0ebfa03c1 | |
parent | 00f2a35b835c6f49617f5379073e9063e7e683ce (diff) | |
download | busybox-w32-5479c435fde32e720af5e177e95d6364a422885a.tar.gz busybox-w32-5479c435fde32e720af5e177e95d6364a422885a.tar.bz2 busybox-w32-5479c435fde32e720af5e177e95d6364a422885a.zip |
sort: fix sort -s -u, closes 14871
function old new delta
sort_main 851 856 +5
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/sort.c | 9 | ||||
-rwxr-xr-x | testsuite/sort.tests | 10 |
2 files changed, 15 insertions, 4 deletions
diff --git a/coreutils/sort.c b/coreutils/sort.c index 80b578fc2..01b7c44e5 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c | |||
@@ -652,11 +652,12 @@ int sort_main(int argc UNUSED_PARAM, char **argv) | |||
652 | /* Handle -u */ | 652 | /* Handle -u */ |
653 | if (option_mask32 & FLAG_u) { | 653 | if (option_mask32 & FLAG_u) { |
654 | int j = 0; | 654 | int j = 0; |
655 | /* coreutils 6.3 drop lines for which only key is the same | 655 | /* coreutils 6.3 drop lines for which only key is the same: |
656 | * -- disabling last-resort compare, or else compare_keys() | 656 | * - disabling last-resort compare, or else compare_keys() |
657 | * will be the same only for completely identical lines. | 657 | * will be the same only for completely identical lines |
658 | * - disabling -s (same reasons) | ||
658 | */ | 659 | */ |
659 | option_mask32 |= FLAG_no_tie_break; | 660 | option_mask32 = (option_mask32 | FLAG_no_tie_break) & (~FLAG_s); |
660 | for (i = 1; i < linecount; i++) { | 661 | for (i = 1; i < linecount; i++) { |
661 | if (compare_keys(&lines[j], &lines[i]) == 0) | 662 | if (compare_keys(&lines[j], &lines[i]) == 0) |
662 | free(lines[i]); | 663 | free(lines[i]); |
diff --git a/testsuite/sort.tests b/testsuite/sort.tests index fb2cc91bd..8dbadbdae 100755 --- a/testsuite/sort.tests +++ b/testsuite/sort.tests | |||
@@ -230,4 +230,14 @@ testing "sort -k2,2M" \ | |||
230 | 3 March | 230 | 3 March |
231 | " "" | 231 | " "" |
232 | 232 | ||
233 | testing "sort -s -u" \ | ||
234 | "sort -s -u -k 2 input" "\ | ||
235 | z a | ||
236 | z b | ||
237 | " "\ | ||
238 | z b | ||
239 | a b | ||
240 | z a | ||
241 | a a" "" | ||
242 | |||
233 | exit $FAILCOUNT | 243 | exit $FAILCOUNT |