]> 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, 16 Aug 2023 09:35:51 +0000 (11:35 +0200)
commit140404e1fd22705c3a6972378b17af5e5ea87432
treee9025021427e24fca731b952af86635bef99eb3b
parent1632bd6d484400a1d7a578d30251689b93fcd34e
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