summaryrefslogtreecommitdiffstats
path: root/text-utils/column.c
Commit message (Collapse)AuthorAgeFilesLines
* column: fix outputing empty column at the end of lineYousong Zhou2019-07-291-1/+1
| | | | | | | | | | | | | The following commands manifests the problem. In old versions before commit 4762ae9d60 ("column: use libsmartcols for --table"), both of them should output with 2 "|" echo '||' | column -o '|' -s '|' -t echo '|| ' | column -o '|' -s '|' -t Fixes: 4762ae9d60 ("column: use libsmartcols for --table") Signed-off-by: Yousong Zhou <zhouyousong@yunionyun.com> Reviewed-by: Sami Kerola <kerolasa@iki.fi>
* column: make code more robust [coverity scan]Karel Zak2019-05-281-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-7/+6Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: add --table-empty-linesKarel Zak2018-08-231-2/+22
| | | | | | | | | | | | | | | | | | | | | The option allows to add empty line to the table. The default behavior is to ignore empty lines at all. echo -e "A\nAA\nAAA\n\nAAAA" | ./column --table A AA AAA AAAA $ echo -e "A\nAA\nAAA\n\nAAAA" | ./column --table --table-empty-lines A AA AAA AAAA Addresses: https://github.com/karelzak/util-linux/issues/593 Signed-off-by: Karel Zak <kzak@redhat.com>
* column: fix leading space characters bugKarel Zak2018-03-271-33/+3Star
| | | | | | | | | | | | | | | | | | The bug has been introduced during column(1) rewrite. The function read_input() need to skip leading space only temporary to detect empty lines, but the rest of the code has to use the original buffer (line). I've tried to fix one of the symptoms by 5c7b67fbbf41c973ca8d49b1e8bdba22dbb917aa (alter), but this solution is unnecessary and too complex. Changes: * don't ignore leading space * remove unnecessary stuff introduced by 5c7b67fbbf41c973ca8d49b1e8bdba22dbb917aa * fix regression test with incorrect separator Addresses: https://github.com/karelzak/util-linux/issues/575 Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1560283 Signed-off-by: Karel Zak <kzak@redhat.com>
* column: fix memory leak [coverity scan]Karel Zak2018-02-201-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: don't ignore space-char separators at begin of the lineKarel Zak2018-02-121-1/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | Non-space separator: $ echo -e ",col1,col2\nrow,1,2" | column -t -s "," --table-columns A,B,C A B C col1 col2 row 1 2 Space-char (\t) separator: $ echo -e "\tcol1\tcol2\nrow\t1\t2" | column -t -s "$(echo -e '\t')" --table-columns A,B,C A B C col1 col2 row 1 2 Fixed version: $ echo -e "\tcol1\tcol2\nrow\t1\t2" | column -t -s "$(echo -e '\t')" --table-columns A,B,C A B C col1 col2 row 1 2 Addresses: https://github.com/karelzak/util-linux/issues/575 Signed-off-by: Karel Zak <kzak@redhat.com>
* column: use \x<hex> for invalid multibyte seq.Karel Zak2017-11-221-2/+14
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/542 Signed-off-by: Karel Zak <kzak@redhat.com>
* column: allow to hide unnamed columnsKarel Zak2017-11-131-1/+26
| | | | | Addresses: https://github.com/karelzak/util-linux/pull/327 Signed-off-by: Karel Zak <kzak@redhat.com>
* column: add --table-noheadingsKarel Zak2017-11-131-2/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: (-t) disable encoding for non-printable charsKarel Zak2017-07-311-1/+3
| | | | | | | | | $ echo -e '\033[34mBLUE{1\n\033[31mRED{2\n' | ./column -s '{' -t BLUE 1 RED 2 Addresses: https://github.com/karelzak/util-linux/issues/490 Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* column: fix compilation when libc lacks wide-character supportCarlos Santos2017-06-291-0/+8
| | | | | | | | | | | | | | | | Commit 4762ae9d removed mtsafe_strtok() but left behind calls to wcstok and wcspbrk. This leads to build failures when libc does not have the wide-character functions, like some uClibc builds. Solve the problem by using strtok_r and strpbrk when HAVE_WIDECHAR is not defined. Fixes: http://autobuild.buildroot.net/results/fd8a1a8e0cef3aeed9588540e8e663664f6b43aa http://autobuild.buildroot.net/results/5ad73ea8b471321988c50d80a5e50d4504151dd6 http://autobuild.buildroot.net/results/04411b7280dc51ecd51236967981a42352bbeb3e Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: cosmetics, remove argument from usage(int)Ruediger Meier2017-06-261-4/+4
| | | | | | | This patch is trivial and changes nothing, because we were always using usage(0). Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: remove stray semicolonsSami Kerola2017-06-141-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: add --table-header-repeatKarel Zak2017-06-131-2/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: add missed semicolons in case of !HAVE_WIDECHARAlexander Kuleshov2017-06-011-2/+2
| | | | | | | | | | In other case we will get: error: expected ‘;’ before ‘}’ token error. Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
* column: be robust on empty tableKarel Zak2017-05-051-2/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: require column names for JSONKarel Zak2017-05-051-1/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: use libsmartcols to avoid circular dependencesKarel Zak2017-05-051-4/+3Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: fix --tree id-parent loop crashKarel Zak2017-05-051-1/+5
| | | | | | The loop is silently ignored. Signed-off-by: Karel Zak <kzak@redhat.com>
* column: parent and child has to be independentKarel Zak2017-05-021-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: force to follow specified widthKarel Zak2017-05-021-2/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: use NOEXTREMES for the last columnKarel Zak2017-05-021-0/+24
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: add support for treesKarel Zak2017-05-021-1/+77
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: clean up usage() and options orderKarel Zak2017-05-021-37/+46
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: add --table-orderKarel Zak2017-05-021-1/+35
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: fix typoKarel Zak2017-05-021-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: add --table-hideKarel Zak2017-05-021-1/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: add --table-wrapKarel Zak2017-05-021-2/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: add --table-noextremeKarel Zak2017-05-021-6/+14
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: add --table-truncateKarel Zak2017-05-021-13/+32
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: rename optionsKarel Zak2017-05-021-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: fix greedy initializationKarel Zak2017-05-021-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: add --table-colrightKarel Zak2017-05-021-9/+60
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: use err_exclusive_options()Karel Zak2017-05-021-3/+14
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: make mbs/wcs conversions more robustKarel Zak2017-05-021-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: add --jsonKarel Zak2017-05-021-3/+22
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: add --table-colnamesKarel Zak2017-05-021-10/+36
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: rename too generic macroKarel Zak2017-05-021-6/+5Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: use libsmartcols for --tableKarel Zak2017-05-021-154/+121Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: clean up multi-byte #ifelseKarel Zak2017-05-021-25/+10Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: reorder functionsKarel Zak2017-05-021-136/+139
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: rename functionsKarel Zak2017-05-021-7/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: don't ignore mbs_to_wcs() errorsKarel Zak2017-05-021-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: make input() more genericKarel Zak2017-05-021-62/+53Star
| | | | | | | | * remove line size limit * use multi-byte rather than wchar when read input * prepare for future libsmartcols use in input() for table Signed-off-by: Karel Zak <kzak@redhat.com>
* column: use colntrol struct on more placesKarel Zak2017-05-021-58/+61
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* columns: add control structKarel Zak2017-05-021-21/+35
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: make more obvious what is default behaviorKarel Zak2017-03-011-6/+6
| | | | | | | | | | | | | | | | | | | | The man page contains mistakes. The default is to fill columns before lines: $ printf 'aaaaaaaaaaaaaaaaaaaaaa\nBBBBBBBBBBBBBBBBBBBBB\nXXXXXXX\nYYYYYYYYYYY\nZZZZZ' > data $ column --columns 80 < data aaaaaaaaaaaaaaaaaaaaaa XXXXXXX ZZZZZ BBBBBBBBBBBBBBBBBBBBB YYYYYYYYYYY $ column --fillrows --columns 80 < data aaaaaaaaaaaaaaaaaaaaaa BBBBBBBBBBBBBBBBBBBBB XXXXXXX YYYYYYYYYYY ZZZZZ The patch also rename functions in the code to make it more obvious for code readers. Signed-off-by: Karel Zak <kzak@redhat.com>