sort: check global flags on fallback sort
Sort now performs global reverse on fallback sort if -r is set. Before only key local flags were checked. function old new delta compare_keys 712 738 +26 Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
1a4d9f6521
commit
5c13ab41bb
@ -302,10 +302,14 @@ static int compare_keys(const void *xarg, const void *yarg)
|
|||||||
} /* for */
|
} /* for */
|
||||||
|
|
||||||
/* Perform fallback sort if necessary */
|
/* Perform fallback sort if necessary */
|
||||||
if (!retval && !(option_mask32 & FLAG_s))
|
if (!retval && !(option_mask32 & FLAG_s)) {
|
||||||
retval = strcmp(*(char **)xarg, *(char **)yarg);
|
retval = strcmp(*(char **)xarg, *(char **)yarg);
|
||||||
|
flags = option_mask32;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & FLAG_r)
|
||||||
|
return -retval;
|
||||||
|
|
||||||
if (flags & FLAG_r) return -retval;
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +47,6 @@ egg 1 2 papyrus
|
|||||||
999 3 0 algebra
|
999 3 0 algebra
|
||||||
" "$data" ""
|
" "$data" ""
|
||||||
|
|
||||||
test x"$SKIP_KNOWN_BUGS" = x"" && {
|
|
||||||
# Busybox is definitely doing these wrong. FIXME
|
|
||||||
testing "sort key range with numeric option and global reverse" \
|
testing "sort key range with numeric option and global reverse" \
|
||||||
"sort -k2,3n -r input" \
|
"sort -k2,3n -r input" \
|
||||||
"egg 1 2 papyrus
|
"egg 1 2 papyrus
|
||||||
@ -65,7 +63,6 @@ testing "sort key range with multiple options" "sort -k2,3rn input" \
|
|||||||
42 1 3 woot
|
42 1 3 woot
|
||||||
egg 1 2 papyrus
|
egg 1 2 papyrus
|
||||||
" "$data" ""
|
" "$data" ""
|
||||||
}
|
|
||||||
|
|
||||||
testing "sort key range with two -k options" "sort -k 2,2n -k 1,1r input" "\
|
testing "sort key range with two -k options" "sort -k 2,2n -k 1,1r input" "\
|
||||||
d 2
|
d 2
|
||||||
|
Loading…
Reference in New Issue
Block a user