diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-02-22 10:54:55 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-02-22 10:54:55 +0100 |
commit | 427ae18348a908719ff60383b33041bce5e5393e (patch) | |
tree | 1bc7edff1e32f5740bb187d687c3fab19be89fe5 | |
parent | 2af5e3fac394a922bcf7752be25128879405a21a (diff) | |
download | busybox-w32-427ae18348a908719ff60383b33041bce5e5393e.tar.gz busybox-w32-427ae18348a908719ff60383b33041bce5e5393e.tar.bz2 busybox-w32-427ae18348a908719ff60383b33041bce5e5393e.zip |
sort: in -s handling, return 1/-1, not 1/0 compare result
function old new delta
compare_keys 794 795 +1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/sort.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/coreutils/sort.c b/coreutils/sort.c index 8ffd0cf44..c24b62681 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c | |||
@@ -345,7 +345,7 @@ static int compare_keys(const void *xarg, const void *yarg) | |||
345 | /* So far lines are "the same" */ | 345 | /* So far lines are "the same" */ |
346 | 346 | ||
347 | if (option_mask32 & FLAG_s) { | 347 | if (option_mask32 & FLAG_s) { |
348 | /* "Stable sort": later line is "smaller", | 348 | /* "Stable sort": later line is "greater than", |
349 | * IOW: do not allow qsort() to swap equal lines. | 349 | * IOW: do not allow qsort() to swap equal lines. |
350 | */ | 350 | */ |
351 | uint32_t *p32; | 351 | uint32_t *p32; |
@@ -362,7 +362,8 @@ static int compare_keys(const void *xarg, const void *yarg) | |||
362 | p32 = (void*)(line + len); | 362 | p32 = (void*)(line + len); |
363 | y32 = *p32; | 363 | y32 = *p32; |
364 | 364 | ||
365 | retval = x32 > y32; | 365 | /* If x > y, 1, else -1 */ |
366 | retval = (x32 > y32) * 2 - 1; | ||
366 | } else | 367 | } else |
367 | if (!(option_mask32 & FLAG_no_tie_break)) { | 368 | if (!(option_mask32 & FLAG_no_tie_break)) { |
368 | /* fallback sort */ | 369 | /* fallback sort */ |