← Commit list

00f2a35b8

Denys Vlasenko
Denys Vlasenko
2022-07-29
SUCCESS Duration: 155s

Subject

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

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

coreutils/sort.c+2 -2
@@ -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)
testsuite/sort.tests+11 -0
@@ -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