summaryrefslogtreecommitdiffstats
path: root/text-utils/column.c
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-201-2/+2
| | | | | | | text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be static? Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-9/+9
| | | | | | | | | | text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* build-sys: fix compilation with ncurses and uClibc or musl libcCarlos Santos2017-01-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Compiling util-linux with musl and uClibc-ng toolchains when wide-char support is not enabled in ncurses results in compilation failures with the following message: error: two or more data types in declaration specifiers #define wchar_t char The problem occurs because util-linux #defines its own wchar_t (as char) when configured without widechar support. This conflicts with definition of wchar_t contained in stddef.h. This error can be reproduced running "<toolchain-cc -o test test.c" with the following test program: #include <ctype.h> #define wchar_t char #include <stddef.h> int main() { return 0; } The only way to avoid the problem it to reorder the inclusion of headers in some files under the text-utils directory. Addresses: http://autobuild.buildroot.net/results/3a2f228e0fa7b5cc28a13d49f48f1a6aef8d9d7a http://autobuild.buildroot.net/results/99e96069f652d511c6212a5bb6be29e68fb1747c http://autobuild.buildroot.net/results/2dc5721aef93b7b410153bafad78248fac3db941 http://autobuild.buildroot.net/results/8a9e197ba7a292b18f8c0c36dca974685556a38a Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
* column: rename --columns to --output-widthKarel Zak2017-01-171-11/+12
| | | | | | | | | * rename to use less confusing option name * cleanup usage() * update man page Addresses: https://github.com/karelzak/util-linux/pull/327 Signed-off-by: Karel Zak <kzak@redhat.com>
* Use --help suggestion on invalid optionKarel Zak2016-12-191-1/+1
| | | | | | | | The current default is to print all usage() output. This is overkill in many case. Addresses: https://github.com/karelzak/util-linux/issues/338 Signed-off-by: Karel Zak <kzak@redhat.com>
* column: ignore non-printable charsKarel Zak2016-01-131-7/+36
| | | | | | | | | | | | | | | | | echo -e '\033[33mb\033[mXFoo\n\033[33mbar\033[mXFoo' | column -s X -t old version: b Foo bar Foo fixed version: b Foo bar Foo References: https://github.com/karelzak/util-linux/issues/252 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tty: Pass default width to get_terminal_width()Boris Egorov2016-01-061-3/+1Star
| | | | | | | | | | Almost any code calling get_terminal_width() checks returned width for non-positive values and sets it to some default value (say, 80). So, let's pass this default value directly to the function. [kzak@redhat.com: - get_terminal_width() refactoring] Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+4
| | | | | | | | | This adds a concise description of a tool to its usage text. A first form of this patch was proposed by Steven Honeyman (see http://www.spinics.net/lists/util-linux-ng/msg09994.html). Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: use version printing macro everywhereSami Kerola2014-10-011-3/+2Star
| | | | | | | Only mount, umount, and blkid remains not using the macro because they are print also library references. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: inform user when multibyte conversion error occursSami Kerola2014-05-071-1/+7
| | | | | | | | | The column(1) read input until conversion error, and used incomplete input when outputing, that made at least me to wonder where the rest disappeared without explanation. IMHO it is better to fail immediately rather than do only half of the task. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: fix mem leak [coverity scan]Karel Zak2014-01-141-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: use variable lenght printf field width to wprint blanksSami Kerola2013-08-051-3/+2Star
| | | | | | | This makes program to run a little faster. My test input show about 20% speed improvement. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: dereference of null pointer [clang-analyzer]Sami Kerola2013-07-091-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: fix several typos and angular brackets in messagesBenno Schulenberg2013-06-071-3/+3
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: spell and encode the name of Arkadiusz Miśkiewicz correctlyBenno Schulenberg2013-02-061-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* column: make usage() translator friendlySami Kerola2013-01-251-15/+14Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: add --output-separator optionSami Kerola2012-10-151-5/+15
| | | | | | | | | | The --output-separator option will allow user to define table column separator. This will allow for example to write back same delimeter as which was used as input separator, for example column -t -s : -o : /etc/passwd Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: clarify the --separator optionPádraig Brady2012-10-021-1/+1
| | | | | | Indicate that the string is a set, which also clarifies that it's only significant when parsing the input.
* column: make defined separator to be non-greedySami Kerola2012-10-021-5/+32
| | | | | | | | | | | | | | | | | | | | | | | This patch changes interpretation of subsequent delimeter interpretation. Earlier version merged columns that had null string as content together, which lead to output as visualized below. $ printf "a:b:c\n1::3\n" | column -t -s ':' a b c 1 3 The number 3 has wrong column, which this patch takes care of, and alters the output following way. $ printf "a:b:c\n1::3\n" | column -t -s ':' a b c 1 3 This patch does not alter the default case, e.g., subsequent white spaces are understood as separator of the same field, and the beginning of line white spaces are being ignored together. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: fix typos in messagesYuri Chornoivan2012-09-041-1/+1
|
* column: --separator segfaultsB Watson2012-08-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The --separator and --columns long options in util-linux-2.21.2 and in a git clone from 5 minutes ago, don't work: $ echo foobar | column -s x foobar $ echo foobar | column -c 10 foobar $ echo foobar | column --separator=x column: option '--separator' doesn't allow an argument $ echo foobar | column --separator x Segmentation fault $ echo foobar | column --columns 10 column: bad columns width value: '(null)': Invalid argument $ echo foobar | column --columns=10 column: option '--columns' doesn't allow an argument Looks like a simple case of missing has_arg flag in the "struct option" initialization for these two options. The patch just adds the flag. I haven't done thorough testing of the patched code, but it seems to work OK and it no longer segfaults or tries to dereference a null pointer. Signed-off-by: Karel Zak <kzak@redhat.com>
* text-utils: cleanup strtoxx_or_err()Karel Zak2012-05-151-17/+7Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* text-utils: verify writing to streams was successfulSami Kerola2012-04-041-3/+2Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: don't check result from xmalloc()Karel Zak2012-01-041-2/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: use xalloc libsDave Reisner2012-01-041-1/+1
| | | | Signed-off-by: Dave Reisner <dreisner@archlinux.org>