[hackers] [sbase] sort: Consider end field in keydef when additional fields are present || Michael Forney

From: <git_AT_suckless.org>
Date: Thu, 2 Jan 2020 06:46:03 +0100 (CET)

commit e9bfb97808dea513901338a46cbd2966ddc0f231
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Wed Jan 1 12:16:16 2020 -0800
Commit: Michael Forney <mforney_AT_mforney.org>
CommitDate: Wed Jan 1 12:23:48 2020 -0800

    sort: Consider end field in keydef when additional fields are present
    
    Currently, if the delimiter is found after the last field of a keydef,
    only up to the beginning of the field is considered. This breaks `sort
    -k N,N`, as well as whenever the sorted order comes down to that last
    field.
    
    Thanks to Richard Ipsum for the bug report and proposed patch.

diff --git a/sort.c b/sort.c
index dfc383f..a51997f 100644
--- a/sort.c
+++ b/sort.c
_AT_@ -66,11 +66,10 @@ skipcolumn(struct line *a, int skip_to_next_col)
 
         if (fieldsep) {
                 if ((s = memmem(a->data, a->len, fieldsep, fieldseplen))) {
- if (skip_to_next_col) {
+ if (skip_to_next_col)
                                 s += fieldseplen;
- a->len -= s - a->data;
- a->data = s;
- }
+ a->len -= s - a->data;
+ a->data = s;
                 } else {
                         a->data += a->len - 1;
                         a->len = 1;
Received on Thu Jan 02 2020 - 06:46:03 CET

This archive was generated by hypermail 2.3.0 : Thu Jan 02 2020 - 06:48:25 CET