Commit Graph

532 Commits

Author SHA1 Message Date
Karel Zak f1970cc557 docs: improve size arguments description in --help output
Let's add "Arguments:" section to the --help output and describe
{K,M,G...}iB suffixes there.

Addresses: https://github.com/karelzak/util-linux/pull/917
Co-Author: ed <ed@s5h.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-05 11:01:36 +01:00
Bjarni Ingi Gislason 1c4c602427 man pages: Change a HYPHEN-MINUS (-) to a minus (\-) for options and numbers
Change a HYPHEN-MINUS (code 0x55, 2D) to a minus (\-), if in front of

1) a name of an option

2) a negative number to be printed.

  See man-pages(7) [Debian package "manpages"].

  The output from "nroff" is unchanged.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2019-12-17 12:32:43 +01:00
Bjarni Ingi Gislason eb02489380 man pages: Add a comma after "e.g." and "i.e."
Add a comma (,) after "e.g." and "i.e.", or use English words
(man-pages(7) [package "manpages"]).

  Abbreviation points should be protected (usually with the
non-printing, zero width character '\&') from being interpreted as an
end of sentence, if they are not, and that independent of their current
place on the line.

  This is important when typing, as one does not usually know in
advance when the editor jumps to a new line.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2019-12-17 12:32:43 +01:00
Bjarni Ingi Gislason 47da68f1c9 man pages: Make the number of .RS/.RE equal
Add or remove one of the pairs .RS/.RE to make their number equal.

  The output from "nroff" and "groff" is unchanged.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2019-12-17 12:32:43 +01:00
Karel Zak dc626a7586 hexdump: add header file guards [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 16:13:52 +02:00
Sami Kerola 218b1dd6f9
misc: fix typos [codespell]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-09-12 19:41:46 +01:00
Karel Zak d356507207 colcrt: make seek to \n more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-02 11:53:10 +02:00
Sami Kerola dbeb1d733e
docs: try to find broken man references and fix them
Unfortunately methods I used to find and fix were based on quite manual
process that cannot be easily repeated so I do not see how this fix could be
turned into a tools/checkmans.sh addition.  Well, lets hope doing this
manually twice every decade is good enough.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-26 19:43:40 +01:00
Sami Kerola 073abd4ca8 column: pass control struct to local_wcstok()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-21 15:00:16 +02:00
Yousong Zhou 325bfd53e8 column: fix outputing empty column at the end of line
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>
2019-07-29 10:33:58 +02:00
Karel Zak 25b7045e5d misc: replaces atexit(close_stdout) with new close_stdout_atexit()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:46:10 +02:00
Karel Zak 303ff21ea7 rev: be careful with close()
Addresses: https://github.com/karelzak/util-linux/issues/807
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-13 12:59:39 +02:00
Karel Zak b8b7f4745c ul: make sure buffers are zeroized [coverity scan] 2019-05-28 13:33:03 +02:00
Karel Zak dd45b90eef column: make code more robust [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-28 13:25:15 +02:00
Austin English 4b4a780539 column: fix "maybe be" duplication
Signed-off-by: Austin English <austinenglish@gmail.com>
2019-05-15 13:49:20 +02:00
Karel Zak 2c308875a7 misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 15:14:13 +02:00
dana 1ec4c065a2 column: Address fill-order confusion in documentation
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>
2019-02-22 14:42:58 -06:00
Karel Zak cc06250f11 col: improve error message, update regression test
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-05 18:07:26 +01:00
Karel Zak 004356f050 col: make flush_line() a little bit robust
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>
2019-02-05 12:06:00 +01:00
Sami Kerola 577bb86f5b
hexdump: fix potential null pointer dereference warnings
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>
2018-12-10 21:48:00 +00:00
Sami Kerola 275d47c9b7
more: rename functions
This clarifies what various function calls are doing.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-09-02 18:30:12 +01:00
Sami Kerola d910f31110
more: rename variable names
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>
2018-09-02 18:28:09 +01:00
Sami Kerola 1e2cd595eb
more: remove unnecessary ifdef preprosessor directives
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-09-02 18:28:09 +01:00
Sami Kerola d2b540022b
more: do not call fileno() for std{in,out,err} streams
These file descriptor numbers are well known, use them from unistd.h

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-09-02 18:28:08 +01:00
Sami Kerola 0b735ea49e
more: remove 'register' keywords
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>
2018-09-02 18:28:08 +01:00
Sami Kerola 70824899b0
more: remove pointless functions
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>
2018-09-02 18:28:08 +01:00
Sami Kerola f728d8baae
more: return is statement not a function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-09-02 18:28:08 +01:00
Sami Kerola c8b1fa6046
more: remove dead code and useless comments
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>
2018-09-02 18:28:08 +01:00
Karel Zak 2698f9ba88 column: add --table-empty-lines
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>
2018-08-23 13:34:43 +02:00
Jakub Wilk b9c3b903fe Fix man page typos
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2018-08-16 11:09:15 +02:00
Bjarni Ingi Gislason 934a6fa80b man pages: Remove "left" (or change to "l") in the column formats of tables
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>
2018-08-06 08:58:57 +02:00
Sami Kerola bd6a253f69
more: remove function like preprocessor defines
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>
2018-06-18 20:19:33 +01:00
Sami Kerola 7cc31c18d7
more: remove global variables, add struct more_control
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>
2018-06-18 20:19:33 +01:00
Sami Kerola 82cfa6f20f
more: move couple functions
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>
2018-06-18 20:19:33 +01:00
Sami Kerola 25ed963d02 rev: move a global variable to local scope
Mark also file names read-only.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-28 13:36:38 +02:00
Bjarni Ingi Gislason 0bb7e904d7 man: Use the correct macro for a font change of one argument
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>
2018-05-23 10:43:27 +02:00
Sami Kerola a8f98304e6 more: reorder global declarations
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>
2018-05-23 10:41:46 +02:00
Sami Kerola f16ca88d9c more: remove function prototypes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-23 10:41:46 +02:00
Karel Zak 651c5d428c column: fix leading space characters bug
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>
2018-03-27 10:55:27 +02:00
ahmogit 8bd926d9fc column: update column.1
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-19 11:45:53 +01:00
Karel Zak d658091710 column: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-20 14:48:26 +01:00
Karel Zak 5c7b67fbbf column: don't ignore space-char separators at begin of the line
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>
2018-02-12 14:06:02 +01:00
Karel Zak 62fa0883be text-utils: use errexec()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-01 15:40:43 +01:00
Sami Kerola fcf841f8d3 misc: fix typos
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:13 +01:00
Karel Zak dda229c7b2 column: use \x<hex> for invalid multibyte seq.
Addresses: https://github.com/karelzak/util-linux/issues/542
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-22 14:43:36 +01:00
Karel Zak b5de9e6942 column: allow to hide unnamed columns
Addresses: https://github.com/karelzak/util-linux/pull/327
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-13 14:17:23 +01:00
Karel Zak 785e543645 column: add --table-noheadings
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-13 12:56:21 +01:00
Karel Zak 00e8e677e6 column: (-t) disable encoding for non-printable chars
$ 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>
2017-07-31 11:48:38 +02:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
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>
2017-06-29 16:54:33 +02:00
Carlos Santos ccedd0d7b1 column: fix compilation when libc lacks wide-character support
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>
2017-06-29 13:03:43 +02:00