Commit Graph

43 Commits

Author SHA1 Message Date
Benno Schulenberg b50945d4ac textual: spell and encode the name of Arkadiusz Miśkiewicz correctly
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-02-06 11:15:02 +01:00
Sami Kerola 3eed42f342 column: make usage() translator friendly
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 16:40:05 +01:00
Sami Kerola 47bd8ddc5b column: add --output-separator option
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>
2012-10-15 16:19:35 +02:00
Pádraig Brady a38dc987ca column: clarify the --separator option
Indicate that the string is a set,
which also clarifies that it's only
significant when parsing the input.
2012-10-02 10:24:55 +02:00
Sami Kerola 732e3dec7d column: make defined separator to be non-greedy
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🅱️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🅱️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>
2012-10-02 10:24:48 +02:00
Yuri Chornoivan bbac757b1e textual: fix typos in messages 2012-09-04 17:26:31 +02:00
B Watson 43f8915c51 column: --separator segfaults
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>
2012-08-14 18:27:09 +02:00
Karel Zak 3b56eea7c9 text-utils: cleanup strtoxx_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 17:46:20 +02:00
Sami Kerola b87cbe8486 text-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:45:41 +02:00
Karel Zak 5be926fac1 column: don't check result from xmalloc()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-04 14:29:26 +01:00
Dave Reisner cce4d25aed column: use xalloc libs
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-01-04 13:53:40 +01:00
Jim Meyering 26ae00a72b column: avoid memory overrun and/or use of uninitialized buffer
* text-utils/column.c (maketbl): Use the right starting point
and the right length when zeroing new memory after xrealloc.
2011-11-16 23:51:33 +01:00
Sami Kerola 6a41edfa5b column: fix error reported by smatch
column.c:201:2: error: 'for' loop initial declarations are only allowed in C99 mode

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-10 16:48:12 +02:00
Karel Zak a46e644e5c column: fix problems with uninitialized variables
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-26 10:23:50 +02:00
Sami Kerola daf093d264 column.c: global variables removed
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>
2011-05-19 21:09:24 +02:00
Sami Kerola 02b77f7b2b column.c: validate numeric user inputs
Use strtol_or_err from strutils.h to check numeric user input is
sane.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-05-19 21:09:24 +02:00
Sami Kerola dcbca568f7 column.c: free memory before exit
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-05-19 21:09:24 +02:00
Sami Kerola 4eaeb0ef25 column.c: make table function clarification
Readability enchancement, and few variable type changes to be
more proper.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-05-19 21:09:23 +02:00
Sami Kerola 1df29104d0 column.c: coding style fixes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-05-01 19:15:21 +02:00
Sami Kerola 4ef21375ec column.c: add version printing
The patch makes return value to be non-zero when command line
short option is unknown.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-05-01 19:09:54 +02:00
Sami Kerola 12bef81286 column.c: replace emalloc with xcalloc
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-05-01 19:08:08 +02:00
Sami Kerola a29e40cad5 column: use xalloc lib
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-04-06 10:59:17 +02:00
Karel Zak 6c7d5ae9a2 move struct option to .rodata
It does not make sense to have writable large arrays of "struct
option" on the stack.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-03 15:00:30 +01:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
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>
2011-02-14 17:45:24 +01:00
Sami Kerola 395801be43 column: data type mismatch compiler warning fixes
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>
2011-01-25 10:40:36 +01:00
Karel Zak 3f7fc4d43b column: segfault on empty input
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=579955
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-04 22:22:49 +01:00
Sami Kerola 1ae90932bd column: code readability improvements
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2010-10-21 09:41:38 +02:00
Sami Kerola bf90b8a6af column: error messaging & exit codes
Human understandable error messages along with symbolic exit
codes to comply with coding standard.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2010-10-21 09:41:38 +02:00
Sami Kerola 80fa094c90 column: EOF handling bug
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>
2010-10-21 09:38:17 +02:00
Sami Kerola a4cc8dfe7d column: getopt_long and new help output
[kzak@redhat.com: - remove __progname, cleanup usage()]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-10-07 10:12:34 +02:00
Karel Zak e42dd65bc3 column: replace errs.h with libc err.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-10-16 12:31:10 +02:00
Karel Zak 06b04b23cd build-sys: fix ifdef ENABLE_WIDECHAR usage
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>
2007-01-30 13:49:50 +01:00
Karel Zak 63cccae468 Imported from util-linux-2.11t tarball. 2006-12-07 00:25:58 +01:00
Karel Zak ffc4374869 Imported from util-linux-2.11o tarball. 2006-12-07 00:25:53 +01:00
Karel Zak c07ebfa1e0 Imported from util-linux-2.11b tarball. 2006-12-07 00:25:46 +01:00
Karel Zak 66ee8158b6 Imported from util-linux-2.10s tarball. 2006-12-07 00:25:44 +01:00
Karel Zak 22853e4a82 Imported from util-linux-2.10m tarball. 2006-12-07 00:25:43 +01:00
Karel Zak eb63b9b8f4 Imported from util-linux-2.10f tarball. 2006-12-07 00:25:41 +01:00
Karel Zak 7eda085c41 Imported from util-linux-2.9v tarball. 2006-12-07 00:25:39 +01:00
Karel Zak 5c36a0eb7c Imported from util-linux-2.9i tarball. 2006-12-07 00:25:37 +01:00
Karel Zak 2b6fc908bc Imported from util-linux-2.8 tarball. 2006-12-07 00:25:35 +01:00
Karel Zak fd6b7a7ffc Imported from util-linux-2.7.1 tarball. 2006-12-07 00:25:34 +01:00
Karel Zak 6dbe3af945 Imported from util-linux-2.2 tarball. 2006-12-07 00:25:32 +01:00