]> git.ipfire.org Git - thirdparty/util-linux.git/commit
column: fix -l
authorKarel Zak <kzak@redhat.com>
Wed, 2 Aug 2023 10:57:37 +0000 (12:57 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 2 Aug 2023 10:57:37 +0000 (12:57 +0200)
commita6dd313bf2f5bc901ddc65262807075587ecb895
tree755c811bc8c35595f768bddfe6ff9b00083a9e47
parent6112ade968cbe8728ca25fccdafdb1f9599424db
column: fix -l

The original implementation is complicated and broken.

It's possible to calculate the rest of the string (for the last
column) from the current position rather than calculate it
continuously. Use the last wcstok() result also means that it will
work as expected independently on "greedy" mode (skips repeating
separators.

 # printf 'a   b c d\n1 2 3 4\n' | ./column -t -o '|' -l3
 a|b|c d
 1|2|3 4

(see space between 'a' and 'b' on input)

References: 8ac75e31de0ece74515e98e0b22e54cc0a9808bd
Fixes: https://github.com/util-linux/util-linux/issues/1763
Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/column.c