[PATCH 2/2] sort: check global flags on fallback sort
Denys Vlasenko
vda.linux at googlemail.com
Sun Jan 19 08:11:33 UTC 2014
Applied, thanks!
On Sat, Jan 18, 2014 at 3:25 PM, Bartosz Golaszewski
<bartekgola at gmail.com> wrote:
> Sort now performs global reverse on fallback sort if -r is set. Before
> only key local flags were checked.
>
> Signed-off-by: Bartosz Golaszewski <bartekgola at gmail.com>
> ---
> coreutils/sort.c | 7 +++++--
> testsuite/sort.tests | 3 ---
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/coreutils/sort.c b/coreutils/sort.c
> index 0b3b650..a3efe5b 100644
> --- a/coreutils/sort.c
> +++ b/coreutils/sort.c
> @@ -302,10 +302,13 @@ static int compare_keys(const void *xarg, const void *yarg)
> } /* for */
>
> /* Perform fallback sort if necessary */
> - if (!retval && !(option_mask32 & FLAG_s))
> + if (!retval && !(option_mask32 & FLAG_s)) {
> retval = strcmp(*(char **)xarg, *(char **)yarg);
> + if (option_mask32 & FLAG_r) return -retval;
> + } else {
> + if (flags & FLAG_r) return -retval;
> + }
>
> - if (flags & FLAG_r) return -retval;
> return retval;
> }
>
> diff --git a/testsuite/sort.tests b/testsuite/sort.tests
> index 91b282e..68fa3e4 100755
> --- a/testsuite/sort.tests
> +++ b/testsuite/sort.tests
> @@ -47,8 +47,6 @@ egg 1 2 papyrus
> 999 3 0 algebra
> " "$data" ""
>
> -test x"$SKIP_KNOWN_BUGS" = x"" && {
> -# Busybox is definitely doing these wrong. FIXME
> testing "sort key range with numeric option and global reverse" \
> "sort -k2,3n -r input" \
> "egg 1 2 papyrus
> @@ -65,7 +63,6 @@ testing "sort key range with multiple options" "sort -k2,3rn input" \
> 42 1 3 woot
> egg 1 2 papyrus
> " "$data" ""
> -}
>
> testing "sort key range with two -k options" "sort -k 2,2n -k 1,1r input" "\
> d 2
> --
> 1.7.10.4
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list