Commit Graph

650 Commits

Author SHA1 Message Date
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
Ruediger Meier b305445495 misc: consolidate all --help option descriptions
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>
2017-06-27 12:28:36 +02:00
Ruediger Meier b1a294c448 misc: introduce print_usage_help_options()
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>
2017-06-27 12:26:19 +02:00
Ruediger Meier 86be6a32d3 misc: cosmetics, remove argument from usage(FILE*)
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>
2017-06-26 14:38:24 +02:00
Ruediger Meier fa2cd89aca misc: cosmetics, remove argument from usage(int)
This patch is trivial and changes nothing, because
we were always using usage(0).

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier 6e1eda6f22 misc: never use usage(stderr)
Here we fix all cases where we have usage(FILE*)
functions.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier 9325dbfd20 misc: cleanup and fix --unknownopt issues
Fixed checkusage.sh warnings:

  rtcwake: --unknownopt, non-empty stdout

  rtcwake: --unknownopt, stderr too long: 21
  blockdev: --unknownopt, stderr too long: 28
  lsipc: --unknownopt, stderr too long: 77
  pg: --unknownopt, stderr too long: 23
  renice: --unknownopt, stderr too long: 18
  sulogin: --unknownopt, stderr too long: 17
  write: --unknownopt, stderr too long: 12

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier c1da6d1eec more: add --help and --version
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 21:35:01 +02:00
Ruediger Meier 0caad87fdb misc: remove superfluous null pointer checks for optarg
This is only needed for optional arguments.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 02:56:57 +02:00
Ruediger Meier d0c5e5c241 more: remove unused variable
slow_tty is at least unused since util-linux 2.2.

FYI here is another derived more.c where slow_tty is still used:
https://github.com/sergev/LiteBSD/blob/master/old/more/more.c

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-15 08:55:40 +02:00
Sami Kerola f4d3783867 misc: remove stray semicolons
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:21:29 +02:00
Sami Kerola b1557fe981 misc: fix ggc-7 fallthrough warnings
(Original patch and commit message edited by Rudi.)

gcc-7 adds -Wimplicit-fallthrough=3 to our default flag -Wextra.
This warning can be silenced by using comment /* fallthrough */
which is also recognized by other tools like coverity. There are
also other valid comments (see man gcc-7) but we consolidate this
style now.

We could have also used __attribute__((fallthrough)) but the comment
looks nice and does not need to be ifdef'ed for compatibility.

Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652
Reference: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
Reviewed-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Suggested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 11:48:22 +02:00
Karel Zak d9eddf72a3 column: add --table-header-repeat
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-13 11:14:46 +02:00
Alexander Kuleshov 8bc5195be9 column: add missed semicolons in case of !HAVE_WIDECHAR
In other case we will get:

  error: expected ‘;’ before ‘}’ token

error.

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
2017-06-01 10:56:08 +02:00
Karel Zak 3947ca4ca9 build-sys: ncurses headers cleanup
* assume ncursesw headers in ncursesw/ directory only
* prefer long paths, <term.h> and <ncurses.h> should be last
  possibility
* fix typos

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-31 11:01:46 +02:00
Karel Zak 2ac1bc84d7 text-utils: use proper paths to term.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-30 17:15:37 +02:00
Sami Kerola 2571d74382 docs: make column.1 example to use ascii output
In same go ease reading by having data and arguments in same order.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-10 10:53:28 +02:00
Sami Kerola b6b5272b03 col: avoid extra newline if no input
BSD fix missed for 22 years, and all util-linux releases so far.

Backported-from: 2a15260a2a
Addresses: https://github.com/karelzak/util-linux/issues/422
Reported-by: Pavel Raiskup <praiskup@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-10 10:53:28 +02:00
Karel Zak da06d42197 column: be robust on empty table
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-05 13:56:40 +02:00
Karel Zak cb3fdf2ae9 column: require column names for JSON
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-05 12:49:51 +02:00
Karel Zak c467fdaf80 column: use libsmartcols to avoid circular dependences
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-05 12:13:15 +02:00
Karel Zak 60102db546 column: add note that circular dependencies are ignored
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-05 11:52:04 +02:00
Karel Zak 435846ef99 column: add --tree to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-05 11:47:46 +02:00
Karel Zak b0f00a9471 column: fix --tree id-parent loop crash
The loop is silently ignored.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-05 11:31:47 +02:00
Karel Zak 960ee8e3f1 build-sys: remove column-old.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-03 10:40:46 +02:00
Karel Zak 74cc7c2515 column: parent and child has to be independent
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak bd6b5a6498 column: force to follow specified width
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 838ca70ce7 columns: add note about width
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak c728e00012 column: use NOEXTREMES for the last column
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 90852c3e12 column: add support for trees
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 236092172a column: clean up man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 7e947f48e7 column: clean up usage() and options order
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 166271a90b column: add --table-order
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 2483c4c9da column: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 9624f6157c column: add --table-hide
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 68916af3b9 column: add --table-wrap
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 1ae24ec239 column: add --table-noextreme
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 3ba01db0ab column: add --table-truncate
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 01e335c9e4 column: rename options
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak f05593e100 column: fix greedy initialization
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak dbed2f8c63 column: add --table-colright
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak be03f65232 column: use err_exclusive_options()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 86399c3306 column: make mbs/wcs conversions more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 9dbe8e1c02 column: add --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 11a1092ad6 column: add --table-colnames
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 739e58ffe0 column: rename too generic macro
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 4762ae9d60 column: use libsmartcols for --table
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 8f1be58816 column: clean up multi-byte #ifelse
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 37d84d6d26 column: reorder functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak d6b63b9f1d column: rename functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak 3cc2ade826 column: don't ignore mbs_to_wcs() errors
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:17:59 +02:00
Karel Zak 0784187d14 column: make input() more generic
* 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>
2017-05-02 12:17:59 +02:00
Karel Zak 2593c13998 column: use colntrol struct on more places
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:17:59 +02:00
Karel Zak 7d07df62a2 columns: add control struct
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:17:59 +02:00
Karel Zak 38d691921c column: split old and new code
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:17:59 +02:00
Sami Kerola 70ca1a7772
tailf: remove deprecated utility
March 2017 is gone, it is time to remove this utility as scheduled in
earlier commit, and promised in manual page.

Reference: 3f8478a71c
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-02 16:51:00 +01:00
Sami Kerola c308e2050f misc: stop mixing declarations and code
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-03-13 14:48:04 +01:00
Karel Zak 3e094e5fe2 column: make more obvious what is default behavior
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>
2017-03-01 12:25:16 +01:00
Sami Kerola 2ba641e5f3 misc: add static keyword to where needed [smatch scan]
text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be
static?

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Sami Kerola 8791804065 misc: do not use plain 0 as NULL [smatch scan]
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>
2017-02-20 12:58:49 +01:00
Carlos Santos 9ea8ded37b build-sys: fix compilation with ncurses and uClibc or musl libc
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>
2017-01-20 11:07:46 +01:00
Karel Zak d7a3bf949b column: rename --columns to --output-width
* 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>
2017-01-17 13:14:05 +01:00
Grady Martin 26c91027b2
col: backspacing widechars
Until now, backspace characters have not accounted for characters of widths
other than one.  This single line amends that.

Requsted-by: Grady Martin <admin@nosuck.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-01-04 22:01:40 +00:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
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>
2016-12-19 13:13:34 +01:00
Sébastien Helleu d673b74e9d docs: replace FTP by HTTPS in kernel.org URLs
The links to ftp://ftp.kernel.org/ are replaced by
https://www.kernel.org/.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 11:22:26 +01:00
Karel Zak 0ed2a95471 more: avoid double free() on exit
On 'q' command more(1) calls end_it() function with _exit(). The
_exit() may suspend program execution due to pending I/O on very
loaded server. In this time SIGINT may be delivered due to impatient
user who will press ^C.

And then end_it() cleanup function may be executed by signal handler
too. The result is double free()...

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1403971
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-15 14:40:26 +01:00
Michael Kerrisk (man-pages) 42632a90c1 Correctly format page cross references
Most pages in util-linux follow the standard convention
of formatting page cross references in bold. Fix the
few exceptions that use italic.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-11-29 10:44:19 +01:00
Michael Kerrisk (man-pages) f053ff1e3a Place SEE ALSO entries in order
This patch does only the following:

* Order SEE ALSO entries first by section name, then alphabetically
  within section
* Adds one or two missing commas in SEE ALSO lists
* Removes one or two periods that were (inconsistently) used
  at the end of SEE ALSO lists.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-11-29 10:44:19 +01:00
Ruediger Meier 332123f2b6 misc: fix some compiler warnings
libsmartcols/samples/fromfile.c:59:2: warning: passing argument 3 of 'string_to_bitmask' from incompatible pointer type
  text-utils/pg.c:79:0: warning: "TABSIZE" redefined
  libblkid/src/read.c:455:13: warning: 'debug_dump_dev' defined but not used [-Wunused-function]
  libblkid/src/probe.c:769:13: warning: unused function 'cdrom_size_correction' [-Wunused-function]
  /usr/include/sys/termios.h:3:2: warning: "this file includes <sys/termios.h> which is deprecated, use <termios.h> instead" [-W#warnings]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-10-27 11:03:24 +02:00
Tobias Stoeckmann b56b13684e rev: Avoid out of boundary read
Check if the length of the parsed string is at least 1,
otherwise an out of boundary read would occur.
2016-10-06 14:56:39 +02:00
Tobias Stoeckmann 2571cf0f9b rev: Avoid calling free in a signal handler
free() is not a safe function for a signal handler. The next
line calls _exit() anyway, so there is no need for resource
management.
2016-10-06 14:56:39 +02:00
Tobias Stoeckmann f20b214edc ul: Fix buffer overflow
The text-utility ul can run into a buffer overflow on very long lines.
See this proof of concept how to reproduce the issue:

$ dd if=/dev/zero bs=1M count=10 | tr '\000' '\041' > poc.txt
$ echo -ne '\xe\x5f\x8\x5f\x61\x2\xf\x5f\x8\x5f' | dd of=poc.txt conv=notrunc
$ ul -i poc.txt > /dev/null # output would take ages
Segmentation fault
$ _

The problem manifests by using alloca with "maxcol", which can be as
large as INT_MAX, based on the input line.

A very long line (> 8 MB) with modes must be supplied to ul, as seen in
my proof of concept byte sequence above.

It is rather easy to fix this issue: allocate space on the heap instead.
maxcol could overflow here, but in that case no system will have enough
space to handle the request, properly ending ul through an err() call.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2016-09-29 11:49:08 +02:00
Sami Kerola 74ce680a3e
misc: simplify if clauses [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Tobias Stoeckmann 3f0e7f371a tailf: Fix previously adjusted segfault patch
Casting the value to be checked to size_t renders the check useless.
If st_size is SIZE_MAX+1, it will be truncated to 0 and the check
succeeds. In fact, this check can never be false because every value
stored in a size_t is smaller or equal to SIZE_MAX.

I think this adjustment was meant to fix a compiler warning for 64 bit
systems for which sizeof(off_t) is sizeof(size_t), but the signedness
differs.

Going unconditionally to the greatest possible unsigned int type if
st_size is positive (off_t is signed) will fix this issue.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2016-07-19 11:01:18 +02:00
Tobias Stoeckmann e368476050 tailf: Fix segmentation fault in tailf on 32 bit
tailf crashes with a segmentation fault when used with a file that is
exactly 4GB in size due to an integer overflow between off_t and size_t:

$ dd if=/dev/zero of=tailf.crash bs=1 count=1 seek=4294967295
$ tailf tailf.crash
Segmentation fault
$ _

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-07-14 12:09:51 +02:00
Karel Zak 324e52a5cf more: don't include ncurses.h, fix for non-widechar
It seems our crazy widechar.h is in conflict with ncurses, but it
seems that nothing in more.c requires anything from ncurses. All we
need is probably <term.h>.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-06-03 14:51:01 +02:00
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Sebastian Rasmussen d35df4db5b docs: Fix various typos
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Sami Kerola 962a7dc3b0 colcrt: avoid the command getting hung [afl]
Some inputs make getwc(3) not to progress file descriptor and neither to
report EILSEQ.  Detect such situation and skip the bad input.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-13 12:29:16 +02:00
Benno Schulenberg 49b7f95e43 docs: miscellaneous tiny tweaks of man pages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-17 12:18:54 +01:00
Ruediger Meier fea1cbf748 misc: never cast void* from malloc(3) and friends
Such cast could hide serious compiler warnings in case we are
missing includes (e.g. <stdlib.h> or "xalloc.h").

See
http://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 23:29:27 +01:00
Karel Zak 8f18a9142c Merge branch 'master' of https://github.com/Rufflewind/util-linux 2016-03-07 16:04:27 +01:00
Phil Ruffwind 925ced8353 hexdump: certain long options should not accept arguments
As documented in the manual and the usage info, the long options
--one-byte-char, --canonical, and --two-bytes-octal should not accept
any arguments.

Signed-off-by: Phil Ruffwind <rf@rufflewind.com>
2016-03-06 13:47:32 -05:00
Ruediger Meier eaac9f88f9 misc: fix some includes
features.h:  any glibc header includes this already
libgen.h:    was unused there
sys/uio.h:   for writev(3p)
sys/queue.h  seems like it was never used

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:04:56 +01:00
Ruediger Meier 2013b33f40 build-sys: disable unused parameter warnings for some test progs
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:20:22 +01:00
Ruediger Meier b0b54cc582 build-sys: always add AM_CFLAGS
We were missing our nice compliler warnings for many programs
and libs. See next commits how many trivial and non-trival
warnings have to be fixed.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:17:29 +01:00
Ruediger Meier b0b24b11f8 lib: rename strmode() and setmode()
On BSD they are part of the standard C library.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-18 12:53:48 +01:00
Karel Zak 79c101427f colcrt: minor cosmetic changes
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-11 12:21:22 +01:00
Sami Kerola ea4ccc9ea1
colcrt: reimplementation
This implementation aims to be easier to read, more robust dealing all sorts
of unexpected inputs, and possibly even more correct.  The correctness
refers to last line handling this implementation does differently than the
previous.  With the previous last line that ended to EOF without \n was not
printed.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-02-02 17:27:28 +00:00
Karel Zak bb7803e971 more: remove unnecessary compatibility layer
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-26 11:51:04 +01:00
Sami Kerola b4566a8a8d build-sys: remove libtermcap support
It is unlikely anyone is going to build this project on system where
libtermcap is available.  Fedora project obsoleted libtermcap 2007-12-12 in
favour of ncurses.  Debian made same move 2005.

Reference: https://fedoraproject.org/wiki/Deprecated_packages
Reference: https://www.debian.org/doc/manuals/debian-faq/ch-compat.en.html#s-termcap
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-01-26 11:45:14 +01:00
Karel Zak 683ddbd5c4 column: ignore non-printable chars
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>
2016-01-13 10:08:39 +01:00
Boris Egorov 43b4f7ea5f lib/tty: Pass default width to get_terminal_width()
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>
2016-01-06 12:22:07 +01:00
Karel Zak e03f29b694 line: keep stdin unbuiffered
$ printf 'a\nb\n' | echo $(./line) :: $(./line)

broken version:

 a ::

fixed version:

 a :: b

Addresses: https://github.com/karelzak/util-linux/issues/236
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-02 15:01:23 +01:00
Benno Schulenberg e8cf378e48 hexdump: fix a typo and tweak some wordings in the manpage
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-11-09 10:03:58 +01:00
Sami Kerola 70e3fcf293 colcrt: allocate enough space for data moves [afl & asan]
==2807==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000013a31f0 at pc 0x0000004e3047 bp 0x7fffcb7df8d0 sp 0x7fffcb7df8c8
READ of size 4 at 0x0000013a31f0 thread T0
    #0 0x4e3046 in move /home/src/util-linux/text-utils/colcrt.c:309:13
    #1 0x4e25b1 in pflush /home/src/util-linux/text-utils/colcrt.c:264:3
    #2 0x4e246d in colcrt /home/src/util-linux/text-utils/colcrt.c:157:4
    #3 0x4e17d4 in main /home/src/util-linux/text-utils/colcrt.c:141:3
    #4 0x7fb0cb2ee60f in __libc_start_main (/usr/lib/libc.so.6+0x2060f)
    #5 0x4362c8 in _start (/home/src/util-linux/colcrt+0x4362c8)

0x0000013a31f0 is located 0 bytes to the right of global variable 'page' defined in 'text-utils/colcrt.c:73:9' (0x1380b40) of size 140976
SUMMARY: AddressSanitizer: global-buffer-overflow /home/src/util-linux/text-utils/colcrt.c:309 move

And another crash:

==4578==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000013a3d24 at pc 0x0000004e2510 bp 0x7ffc9257b0e0 sp 0x7ffc9257b0d8
READ of size 4 at 0x0000013a3d24 thread T0
    #0 0x4e250f in colcrt /home/src/util-linux/text-utils/colcrt.c:218:8
    #1 0x4e17d4 in main /home/src/util-linux/text-utils/colcrt.c:141:3
    #2 0x7fe0ac94160f in __libc_start_main (/usr/lib/libc.so.6+0x2060f)
    #3 0x4362c8 in _start (/home/src/util-linux/colcrt+0x4362c8)

0x0000013a3d24 is located 8 bytes to the right of global variable 'page' defined in 'text-utils/colcrt.c:73:9' (0x1381240) of size 142044
SUMMARY: AddressSanitizer: global-buffer-overflow /home/src/util-linux/text-utils/colcrt.c:218 colcrt

Reported-by: Alaa Mubaied <alaamubaied@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-10 21:48:42 +01:00
Sami Kerola d883d64d96 colcrt: avoid writing beyond array bound [afl & asan]
text-utils/colcrt.c:205:10: runtime error: index -1 out of bounds for type 'wchar_t [133]'
SUMMARY: AddressSanitizer: undefined-behavior text-utils/colcrt.c:205
=================================================================
==2357==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000013811b0 at pc 0x0000004e2514 bp 0x7ffdf6ba4450 sp 0x7ffdf6ba4448
READ of size 4 at 0x0000013811b0 thread T0
    #0 0x4e2513 in colcrt /home/src/util-linux/text-utils/colcrt.c:213:8
    #1 0x4e17d4 in main /home/src/util-linux/text-utils/colcrt.c:139:3
    #2 0x7fb77236960f in __libc_start_main (/usr/lib/libc.so.6+0x2060f)
    #3 0x4362c8 in _start (/home/src/util-linux/colcrt+0x4362c8)

Reported-by: Alaa Mubaied <alaamubaied@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-10 21:48:38 +01:00
Sami Kerola 3a41cdd7b5 colcrt: use #define in place of magic constants
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-09 18:59:52 +01:00
Karel Zak 8f2a465073 more: improve ugly macro
no comment, just F*CK YOU to the original author of this crap...

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-05 13:09:12 +02:00
Karel Zak c6556f7ca8 tailf: fix open() return value check [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-05 11:55:56 +02:00
Karel Zak 35d8592cd4 hexdump: fix man page (-x vs. default output)
Reported-by: Reuti <reuti@staff.uni-marburg.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-30 11:49:15 +02:00
Ruediger Meier 3f8478a71c tailf: deprecated
We want to remove it in 2 years, March 2017.

See discussion "tailf, really needed?"
http://thread.gmane.org/gmane.linux.utilities.util-linux-ng/10967

[kzak@redhat.com: - move warning to usage()]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-16 14:26:47 +01:00
Karel Zak e1f7791c81 tailf: use size_t and fwrite()
Let's use size_t for number of output lines and use fwrite() rather
than while() { putchar() };

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-05 11:11:53 +01:00
Sami Kerola 9195eca64d tailf: ensure file argument really is a file
The tailf(1) never worked very well with block or character devices,
sockets, fifos and such.  Now after mmap() is used to find last lines
even the little command used to work for example pipes is broken, so test
the tailf is asked to follow a file and when not fail.  That said
symlinks are OK, as long they point to a file.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-03-05 10:31:18 +01:00
Sami Kerola 16d3d9a04d tailf: do not allow minus signed last lines argument
Before mmap() the command behavior was not completely correct, as
demonstrated below, and after the mmap() it tried to print some eighteen
quintillion lines.

$ tailf -n-1 x
tailf: cannot allocate 18446744073709543424 bytes: Cannot allocate memory

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-03-05 10:31:18 +01:00
Sami Kerola a260b21bdb tailf: count last lines correctly at initial print out
When last lines happen to be greater than string buffer size for fgets()
the number of printed lines resulted to too few.  To avoid miscounts due
insufficient buffer size use mmap() to map the whole file and rewind
until requested number of new lines is found.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-03-05 10:31:18 +01:00
Karel Zak 4310faf950 lib/colors: use libtinfo to check terminal capability
The current implementation assumes that all terminals supports colors
and users are forcet to use terminal-colors.d/ to disable colors for
some terminals.

This patch checks for maximal supported colors for the current
terminal and colors are automatically disabled for terminals like
vt100.

The patch moves lib/colors.c from libcommon.la to libtcolors.la to
avoid collisions with another utils.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-27 13:57:34 +01:00
Karel Zak 5d51dc2a7f colors: cleanup man pages, add hint to usage()
cfdisk, fdisk, calm dmesg and hexdump

Signed-off-by: Karel Zak <kzak@redhat.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-25 12:40:06 +01:00
Benno Schulenberg fc14ceba5e textual: grammarize and harmonize the stat error message
The message "stat failed %s" seems to say that stat() failed to
do something, or failed to pass a test, but of course it means
that the statting of something failed.  So say so.  Also make
two very similar messages equal to this one.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-02-02 11:27:10 +01:00
Sami Kerola bc1ed33881 more: fix repeat search crash
Repeating a search for a pattern that did not found made more(1) to
crash.  To reproduce 'more /etc/services' and search for 'doom'; you will
find a service in port 666 - pressing '.' after that result used to cause
core dump.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-28 08:27:45 +01:00
J William Piggott b06c1ca6f8 docs: restore minus symbols in long opts
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2015-01-20 18:15:30 -05:00
Benno Schulenberg 3a60b1c26b docs: remove obsolete and unneeded comments from man-page files
Transform some of them into copyright lines.
Also fix three header lines and snip some trailing whitespace.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-12 11:03:26 +01:00
Sami Kerola 97d8f180b6 ul: remove unexplained TERM=lpr override
The FIXME item has been in place since 2011-04-30, and the code has never
made sense, so remove it.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-07 21:57:53 +00:00
Benno Schulenberg 331d255261 tailf: slice up the usage text for ease of translation
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:47:25 +01:00
Benno Schulenberg 5f55b39e58 colcrt: slice up the usage text for ease of translation
Also use the standard macros for outputting it.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:44:24 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
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>
2015-01-06 11:27:38 +01:00
Karel Zak 2e28ebff99 more: fix compiler warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-19 14:34:03 +01:00
Sami Kerola 4d9a1969f7 more: blacklist unsigned integer overflow [AddressSanitizer]
The mbrtowc() return values are overflowing by design.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 11:32:38 +01:00
Sami Kerola c2e1ebbe84 line: use util-linux conventions
This change add --help and --version print outs, checking at exit the
stdout write was successful, and as a minor thing the command is made to
use wide char functions to read and write inputs.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-09 09:19:25 +01:00
Sami Kerola 338a6bc55b textual: improve error messages
Use error printing facilities that add command name in front of the error
message, and add explanation that is part of existing translations.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-09 09:19:22 +01:00
Natanael Copa 7235e70391 hexdump: use 'll' format modifier instead of the non-standard 'q'.
The printf(3) man page says about 'q':
("quad". 4.4BSD and Linux libc5 only. Don't use.) This is a synonym for ll.

This fixes hexdump with musl libc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2014-10-31 10:39:18 +01:00
Sami Kerola d07b223788 ul: fix filter() indentation
Content of the while() loop missed one indentation step.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-20 14:07:20 +02:00
Sami Kerola db433bf737 textual: use usage() text element macros
Translating these text elements should happen only once, which is
more likely when the text macros are used properly.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:26 +02:00
Sami Kerola a587cc5520 textual: use manual tail usage() macro
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:24 +02:00
Sami Kerola f627750083 textual: use version printing macro everywhere
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>
2014-10-01 12:33:23 +02:00
Sami Kerola bf60e9f12d hexdump: remove deprecation message
Message 'calling hexdump as od has been deprecated in favor of GNU
coreutils od' has informed the hexdump not to be used like that for three
and half years, and five releases.  It is time to get rid of notice.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:12 +02:00
Sami Kerola 7d2600e2d0 docs: update deprecation banners
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:11 +02:00
Benno Schulenberg 1d23119072 textual: remove some inconsistent periods from error messages
While doing so, also improve translatability and some wordings.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-08-11 14:51:54 +02:00
Steven Honeyman 1b19ea31a3 docs: fix inconsistencies in man pages
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-06 14:50:20 +02:00
HUANG Wei 82233c2a0a hexdump: Fix parse format of "byte count without repetition count" 2014-08-06 12:20:18 +08:00
Lauri Nurmi 140d91471d more: replace ad-hoc support for plurals with gettext plurals. 2014-07-28 11:46:59 +02:00
Benno Schulenberg 07990fdcd4 docs: bring several man pages closer to standard formatting
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-16 12:03:25 +02:00
Benno Schulenberg 1f94a78ce8 docs: improve formatting and wording of a few man pages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-14 16:21:34 +02:00
Karel Zak ee312c654b docs: fix "behaviour" vs. "behavior"
Sometimes we use "behaviour" and "behavior" in the same text, let's
use "behavior" only everywhere.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1011068
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-06 09:49:35 +02:00
Karel Zak cb45354ec6 build-sys: add BUILD_{COL,COLCRT,COLRM,COLUMN,HEXDUMP,REV,TAILF}
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-21 14:09:43 +02:00
Karel Zak 052e512a64 hexdump: add --color to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 12:13:02 +02:00
Karel Zak 58ce71e63e hexdump: use new colors API
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 12:09:03 +02:00
Sami Kerola acb5f9b56e column: inform user when multibyte conversion error occurs
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>
2014-05-07 11:28:48 +02:00
Benno Schulenberg aa06617f6e textual: remove square brackets from around three dots
Also improve some option descriptions here and there.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-05-06 11:12:13 +02:00
Karel Zak b6a8cc0130 Merge branch 'pg-manual-page-long-options' of https://github.com/jaalto/util-linux
* 'pg-manual-page-long-options' of https://github.com/jaalto/util-linux:
  pg.1: Move (plus) options near (minus) option at the beginning
  pg.1: Add -h, --help, -V, --version
2014-04-01 11:37:06 +02:00
Karel Zak 60ec67ff4e lib/colors: add info to man pages, add terminal-colors.d.5
Co-Author: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 10:05:32 +01:00
Ondrej Oprala d0c9ddc3cc lib/colors: check for /etc/terminal-colors.d/[util].disable
[kzak@redhat.com: - move paths to pathnames.h,
                  - use static path buffer]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 09:38:09 +01:00
Benno Schulenberg 01cc21f5b6 docs: fix two command representations in the man page of more
The previous-file command is not :P but :p, and the back-to-where
command is not an acute accent but an apostrophe.  Also condense
some of the descriptions and remove some useless comments.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-03-04 13:52:14 +01:00
Ondrej Oprala 3bf7ede997 hexdump: color unit may now be longer than the corresponding format unit
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-03-04 12:48:59 +01:00
Sami Kerola 5fdd35070c more: fix double free crash
Commit b9579f1f44 moved fclose() to
checkf(), but missed removing file closure in magic().  Ironically the
cause of regression is in previous commit message.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-02-21 13:45:32 +01:00
Benno Schulenberg 4c5a6f3d39 more: improve formatting and wording of man page and help text
Also, slice up the usage text for ease of translation.

Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-02-21 11:57:05 +01:00
Sami Kerola 100af0035e docs: make hexdump.1 color specification easier to understand
Fix also spacing, input line lenghts, and troff table for data that is a
table.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-02-17 14:04:37 +01:00
Ondrej Oprala 098ab0778f hexdump: add highlighting support
[kzak@redhat.com: - fix coding style,
                  - use xalloc in all code,
		  - fix strtol usage]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-10 16:01:37 +01:00
Karel Zak a5bd793996 include/c.h: prefer nanosleep() over usleep()
Let's use nanosleep() although if usleep() exists. The nanosleep
function does no interact with signals and other timers.

The patch introduces xusleep() as replacement to libc (or our fallback)
usleep(). Yes, we don't want to use struct timespec + nanosleep()
everywhere in code as nano-time resolution is useless for us.

The patch also enlarges delays in some busy wait loops. It seems
enough to try read/write 4x per second.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-24 13:04:14 +01:00
Karel Zak cd70a4606a column: fix mem leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-14 17:55:05 +01:00
Karel Zak b9579f1f44 more: fix mem leak [coverity scan]
... the code is so soo ugly.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-14 17:54:57 +01:00
Andrew Vagin 5500c81742 hexdump: convert a variable type according with fmt
hexdump works uncorrectly on Rassberry Pi (raspbian wheezy):
0000000 3200000000 3400000000 3600000000 3800000000 a00000000
000000a

The problem is that the %qx format is used for printing
the (short int) variable.

Here is the output from hexdump with this patch:
0000000 3231 3433 3635 3837 0a39
000000a

Currently raspbian uses hexdump from bsdmainutils.
bsdmainutils: /usr/bin/hexdump

Signed-off-by: Andrew Vagin <avagin@openvz.org>
2014-01-06 14:02:21 +01:00
Andrew Vagin 917c3733f8 hexdump: don't access hex after freeing it
[kzak@redhat.com: - remove unnecessary code]

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-06 14:01:04 +01:00
Karel Zak 2152af7289 hexdump: use xcalloc()
Reported-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-06 13:54:48 +01:00
Ondrej Oprala 1f77e9c3ad hexdump: Create struct hexdump containing previously global variables.
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-12-02 13:44:24 +01:00
Ondrej Oprala 1be6ed6ade hexdump: add __attribute__ ((__noreturn__)) to bad*() functions
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-12-02 13:44:24 +01:00
Ondrej Oprala bb8ae572ef hexdump: rename struct _fs to struct hexdump_fs and remove its typedef
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-12-02 13:44:23 +01:00
Ondrej Oprala 046921da22 hexdump: rename struct _fu to struct hexdump_fu and remove its typedef
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-12-02 13:44:22 +01:00
Ondrej Oprala 4c73d29c06 hexdump: Rename struct _pr to struct hexdump_pr and remove it's typedef
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-12-02 13:44:21 +01:00
Ondrej Oprala 9f399910f2 hexdump: rename rewrite to rewrite_rules
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-12-02 13:44:21 +01:00
Ondrej Oprala 9fa53cebe4 hexdump: rename add to add_fmt
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-12-02 13:44:20 +01:00
Ondrej Oprala d4646ea4b0 hexdump: Merge hexsyntax.c into hexdump.c
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-12-02 13:44:19 +01:00
Ondrej Oprala af324b1f72 hexdump: add the prefix 'hexdump-' to {conv,display,parse}.c
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-12-02 13:44:17 +01:00
Ondrej Oprala d2740b0ef6 hexdump: catch memory leaks
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 14:16:29 +01:00
Ondrej Oprala 3917a95d90 hexdump: make addfile() variable names more hinting of their purpose
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 14:16:04 +01:00
Ondrej Oprala 0acd3f5d0f hexdump: use skip_space() in add()
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 14:15:39 +01:00
Ondrej Oprala d01d144c4b hexdump: rename in() to first_letter()
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-08 13:54:32 +01:00
Ondrej Oprala cb98600831 hexdump: get rid of redundant typecasts
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 13:51:19 +01:00
Ondrej Oprala cda433918e hexdump: minor formatting improvements in display()
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-08 13:49:57 +01:00
Ondrej Oprala f65e62e0ab hexdump: rewrite cluttered case statements
[kzak@redhat.com: - use strchr() for in() macro]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-08 13:42:39 +01:00
Ondrej Oprala 53a9a9939e hexdump: use xasprintf in conv_c()
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 12:54:53 +01:00
Ondrej Oprala 5988eede0d hexdump: delete redundant typecasts
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 12:54:53 +01:00
Ondrej Oprala 961b4cd642 hexdump: use GNU case ranges where possible
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 12:54:53 +01:00
Ondrej Oprala bec2d4582f hexdump: use xstrncpy in add()
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 12:54:53 +01:00
Ondrej Oprala 2f83c8f032 hexdump: simplify newsyntax arguments
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 12:54:53 +01:00
Ondrej Oprala acf74fc29d hexdump: minor formatting improvements
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 12:54:53 +01:00
Ondrej Oprala bbc8c1531f hexdump: rename next{fs,fu,pr} to {fs,fu,pr}list
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 12:54:52 +01:00
Ondrej Oprala 96ea3d3200 hexdump: rewrite addfile() to use getline()
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 12:54:52 +01:00
Ondrej Oprala d6e5614e5d hexdump: formatting and variable name cleanup
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 12:54:52 +01:00
Ondrej Oprala dabfe2ad7c hexdump: rewrite() formatting improvements
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 12:54:52 +01:00
Ondrej Oprala 9c2cb9b0ea hexdump: rewrite escape()
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 12:54:52 +01:00
Ondrej Oprala eef27d32fa hexdump: rewrite rewrite()
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 12:54:52 +01:00
Ondrej Oprala 7e6e290be9 hexdump:rewrite add()
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-11-08 12:54:52 +01:00