sort: fix -k2M (wasn't skipping leading whitespace)

function                                             old     new   delta
compare_keys                                         848     862     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2022-07-29 16:05:50 +02:00
parent 9b6eb2a8ef
commit 00f2a35b83
2 changed files with 13 additions and 2 deletions

View File

@ -357,9 +357,9 @@ static int compare_keys(const void *xarg, const void *yarg)
int dx;
char *xx, *yy;
xx = strptime(x, "%b", &thyme);
xx = strptime(skip_whitespace(x), "%b", &thyme);
dx = thyme.tm_mon;
yy = strptime(y, "%b", &thyme);
yy = strptime(skip_whitespace(y), "%b", &thyme);
if (!xx)
retval = (!yy) ? 0 : -1;
else if (!yy)

View File

@ -219,4 +219,15 @@ testing "sort -h" \
# testing "description" "command(s)" "result" "infile" "stdin"
testing "sort -k2,2M" \
"sort -k2,2M input" "\
3 March
2 April
1 May
" "\
2 April
1 May
3 March
" ""
exit $FAILCOUNT