Historical versions of column have described the default fill order as
rows-then-columns and the -x order as columns-then-rows. This was
misleading at best, and the util-linux implementation was updated to
clarify the actual behaviour in 3e094e5fe2 (March 2017).
However, the other implementations (used by *BSD, macOS, Debian, &al.)
continue to use the previous wording, and a user comparing them could
easily get the false impression that util-linux column has exactly the
opposite fill behaviour from BSD column.
To address this, a note is added to the man page explaining the change
and clarifying that, despite what the BSD documentation says, the two
implementations behave identically in this regard.
Signed-off-by: dana <dana@dana.is>
The code is horrible. The core of the problem are signed integers
and no check for the limits.
This patch fixes c->c_column = cur_col; where c_column is "short"
and "cur_col" is int. Let's use "int" for all the variables. It's
really not perfect as for bigger lines it can segfault again...
The patch also removes some unnecessary static variables.
Addresses: https://github.com/karelzak/util-linux/issues/749
Signed-off-by: Karel Zak <kzak@redhat.com>
First three fixes on lines 133, 151, and 280 are cosmetic. Because there
was unobvious null check compiler thought variable might be null, and warned
when after pointer adjustment it was followed without null check. Perhaps
this will not happen sometime in future when compiler is made more smart,
meanwhile lets give better hints to avoid false positive.
The last change addresses issue that is possible, at least in theory.
text-utils/hexdump-parse.c:465:12: warning: potential null pointer
dereference [-Wnull-dereference]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Try to make variable names to tell what they do. Earlier names have been in
more(1) since the command was first wrote, and it looks like coding
practices has changed since late 70's.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
One can only assume someone tried to make more(1) to run quicker. More up
to date assumption is that compilers are fully capable optimizing binaries
without these sort of hints.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The curs_terminfo(3X) defines putp() as tputs(str, 1, putchar), so all of
these five functions can be replaced with putp().
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Removal of STOP requires explanation. Looking unix-history-repo getline()
function in first BSD-3 version could return STOP. By next tag BSD-4 the
return STOP had disappeared. If I read this correctly that was a partial
removal, and second part has waited to be completed since 1980-11-16 when
BSD-4 was released.
Reference: https://github.com/dspinellis/unix-history-repo/blob/BSD-3-Snapshot-Development/usr/src/cmd/more.c#L501
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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>
A developmental version of "groff" issued a warning, for example with
"test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z":
troff: <logger.1>:299: warning: can't find font 't'
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Inlining code using preprocessor function like macros is bad for
readability, and prone to errors. Besides this is a pager, who cares if
code is few milliseconds slower.
Requestee-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This is rather big change, but that is the only way to do this sort job. To
keep this change relatively understandable only moves global variables to a
state structure.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier commit moved lots of functions to work without declarations, but to
be able to get rid of global variables few more moves is needed.
Reference: a8f98304e6
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Use the correct macro (I, B) for the font change of one argument, not
those that are used for alternating two fonts, like "BR", "IR", "RB",
or "RI".
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Group include, defines and such together, and move items inbetween functions
on top of the source file so that everything can be seen easily.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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 5c7b67fbbf
(alter), but this solution is unnecessary and too complex.
Changes:
* don't ignore leading space
* remove unnecessary stuff introduced by 5c7b67fbbf
* 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>
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>
Now we are always using the same text also for commands
which had still hardcoded descriptions or where we can't
use the standard print_usage_help_options macro.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
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>
This patch is trivial and changes nothing, because
we were always using usage(stdout)
Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>