summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko2018-02-22 10:54:55 +0100
committerDenys Vlasenko2018-02-22 10:54:55 +0100
commit427ae18348a908719ff60383b33041bce5e5393e (patch)
tree1bc7edff1e32f5740bb187d687c3fab19be89fe5 /coreutils
parent2af5e3fac394a922bcf7752be25128879405a21a (diff)
downloadbusybox-427ae18348a908719ff60383b33041bce5e5393e.zip
busybox-427ae18348a908719ff60383b33041bce5e5393e.tar.gz
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>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/sort.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/coreutils/sort.c b/coreutils/sort.c
index 8ffd0cf..c24b626 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -345,7 +345,7 @@ static int compare_keys(const void *xarg, const void *yarg)
/* So far lines are "the same" */
if (option_mask32 & FLAG_s) {
- /* "Stable sort": later line is "smaller",
+ /* "Stable sort": later line is "greater than",
* IOW: do not allow qsort() to swap equal lines.
*/
uint32_t *p32;
@@ -362,7 +362,8 @@ static int compare_keys(const void *xarg, const void *yarg)
p32 = (void*)(line + len);
y32 = *p32;
- retval = x32 > y32;
+ /* If x > y, 1, else -1 */
+ retval = (x32 > y32) * 2 - 1;
} else
if (!(option_mask32 & FLAG_no_tie_break)) {
/* fallback sort */