summaryrefslogtreecommitdiffstats
path: root/text-utils/column.c
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* column: avoid memory overrun and/or use of uninitialized bufferJim Meyering2011-11-161-2/+2
| | | | | * text-utils/column.c (maketbl): Use the right starting point and the right length when zeroing new memory after xrealloc.
* column: fix error reported by smatchSami Kerola2011-09-101-1/+2
| | | | | | column.c:201:2: error: 'for' loop initial declarations are only allowed in C99 mode Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: fix problems with uninitialized variablesKarel Zak2011-05-261-8/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column.c: global variables removedSami Kerola2011-05-191-50/+63
| | | | | | | Variables from global scope are moved to main, and passed as function arguments where ever they are needed. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column.c: validate numeric user inputsSami Kerola2011-05-191-3/+9
| | | | | | | Use strtol_or_err from strutils.h to check numeric user input is sane. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column.c: free memory before exitSami Kerola2011-05-191-0/+13
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column.c: make table function clarificationSami Kerola2011-05-191-14/+17
| | | | | | | Readability enchancement, and few variable type changes to be more proper. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column.c: coding style fixesSami Kerola2011-05-011-23/+17Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column.c: add version printingSami Kerola2011-05-011-2/+7
| | | | | | | The patch makes return value to be non-zero when command line short option is unknown. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column.c: replace emalloc with xcallocSami Kerola2011-05-011-20/+8Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: use xalloc libSami Kerola2011-04-061-10/+6Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* move struct option to .rodataKarel Zak2011-03-031-1/+1
| | | | | | | It does not make sense to have writable large arrays of "struct option" on the stack. Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: provide alternatives for err, errx, warn and warnxFabian Groffen2011-02-141-1/+1
| | | | | | | | Solaris lacks err, errx, warn and warnx. This also means the err.h header doesn't exist. Removed err.h include from all files, and included err.h from c.h instead if it exists, otherwise alternatives are provided. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* column: data type mismatch compiler warning fixesSami Kerola2011-01-251-2/+3
| | | | | | | | | | Following warnings will longer appear when one will compile with gcc flags -Wall -Wextra -pedantic column.c:364:2: warning: comparison of unsigned expression < 0 is always false column.c:369:2: warning: comparison of unsigned expression < 0 is always false Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: segfault on empty inputKarel Zak2010-11-041-2/+4
| | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=579955 Signed-off-by: Karel Zak <kzak@redhat.com>
* column: code readability improvementsSami Kerola2010-10-211-53/+57
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: error messaging & exit codesSami Kerola2010-10-211-8/+12
| | | | | | | Human understandable error messages along with symbolic exit codes to comply with coding standard. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: EOF handling bugSami Kerola2010-10-211-2/+3
| | | | | | | | | | | | | | | | | | For the last line of the file lenght of line should be determined where the EOF is instead of new line. Old output was $ printf "1 2\n3" | column -t column: line too long 1 2 which this commit will change to $ printf "1 2\n3" | column -t 1 2 3 Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* column: getopt_long and new help outputSami Kerola2010-10-071-14/+36
| | | | | | | [kzak@redhat.com: - remove __progname, cleanup usage()] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* column: replace errs.h with libc err.hKarel Zak2007-10-161-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: fix ifdef ENABLE_WIDECHAR usageKarel Zak2007-01-301-3/+3
| | | | | | | | There has been unexpected mix of HAVE_WIDECHAR and ENABLE_WIDECHAR macros. The ENABLE_WIDECHAR is old version and has to be replaced everywhere otherwise we will see bugs with multibyte stuff. Signed-off-by: Karel Zak <kzak@redhat.com>
* Imported from util-linux-2.11t tarball.Karel Zak2006-12-071-16/+15Star
|
* Imported from util-linux-2.11o tarball.Karel Zak2006-12-071-3/+1Star
|
* Imported from util-linux-2.11b tarball.Karel Zak2006-12-071-1/+1
|
* Imported from util-linux-2.10s tarball.Karel Zak2006-12-071-1/+1
|