Commit Graph

265 Commits

Author SHA1 Message Date
Karel Zak aef70f5514 libsmartcols: fix docs warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-21 13:23:19 +01:00
Karel Zak 7595bed189 Merge branch 'maybe-for-v2.32' of https://github.com/rudimeier/util-linux
* 'maybe-for-v2.32' of https://github.com/rudimeier/util-linux:
  tests: use pgrep instead of ps --ppid ...
  misc: fix typos using codespell
  lsns: fix clang compiler warning
  tests: add udevadm settle to sfdisk/resize
  build-sys: disable bz2 tarball and fix some am warnings
2018-02-16 11:25:22 +01:00
Ruediger Meier 73afd3f8e8 misc: fix typos using codespell
Some more funny typos, please review carefully.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-02-16 11:12:52 +01:00
taiyu 0f9b4f2f3a libsmartcols: fixes issue with 0 width columns
[kzak@redhat.com: - it's possible that column has zero width when
 minimal width is reduced due to very small terminal. In this case
 make sure that we do not use such column at all.]

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-15 12:27:23 +01:00
Karel Zak 0f9f927b6f libsmartcols: set minimal column width to 1
The default is to use header width or relative width setting as the
minimal column width. The problem are columns where is no header or
relative width. Let's set minimal width to 1 in this case.

Addresses: https://github.com/karelzak/util-linux/pull/577
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-15 12:20:17 +01:00
Karel Zak 19b10b8978 libsmartcols: interpret zero width for pending data as error
The command

 $ column -t -W2 -c11 <<< "cat dog bird"

causes finite loop, because there is no minimal column width (missing
header). The print functions should be robust enough to return -EINVAL
when nonsense is requested.

Addresses: https://github.com/karelzak/util-linux/pull/577
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-15 11:58:41 +01:00
Karel Zak 63c9c05d35 misc: remove %p from debug messages
From libs where suid program may be executed by non-root user.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-01 13:18:57 +01:00
Ruediger Meier af1bc027db build-sys: remove redundant EXTRA_DIST files
The sources of AC_CONFIG_FILES (*.in) are automatically
distributed.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Ruediger Meier 4beacf105e build-sys: avoid using prog_DEPENDENCIES
Use EXTRA_prog_DEPENDENCIES to have the benefit
of automake's automatic prog_DEPENDENCIES.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Ruediger Meier 0da03d4490 build-sys: remove unneeded dependencies on bla.h.in
We have already automakes's automatic dependencies like
  bla.h.in -> bla.h -> foo.o -> bar.la

An explicit direct dependency bla.h.in -> bar.la
is redundant and useless anyways.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Ruediger Meier a459f2ec33 build-sys: automake is able to find headers in builddir ...
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Ruediger Meier 1d667d8849 build-sys: remove generated headers from dist tar ball
Headers should only be listed in either *_HEADERS or
*_SOURCES, especially when we want nodist_*_HEADERS.

Since all the generated headers are made by configure we
don't even need to use BUILT_SOURCES or other tricks.

Also see automake docs 9.4.1 Built Sources Example:
  case "Build bindir.h from configure"

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Karel Zak a15dca2f6d include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()
Let's make it possible to use debug.h without environment variables.

Suggested-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-17 13:58:29 +01:00
Karel Zak 6d00cfb233 include/debug: don't print pointer address for SUID programs
* introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing

* use __UL_DEBUG_FL_NOADDR when SUID

* move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK
  to provide access to the current mask from ul_debugobj(). It's better
  than modify all ul_debugobj() calls and use the global mask as
  argument.

* remove never used UL_DEBUG_DEFINE_FLAG

Reported-by: halfdog <me@halfdog.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-12 11:01:26 +01:00
Karel Zak 3fa48b118a libsmartcols: don't add blank padding after left aligned title
Let's use the same semantic for the title as for the last column in
the table. If aligned on left, table is not "maxout" and title padding
symbol is undefined (or blank) then keep title as short as possible.

Addresses: https://github.com/karelzak/util-linux/issues/549
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 13:19:36 +01:00
Karel Zak 8aeda56b5d sample-scols-title: add left title without padding
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 13:16:54 +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 d1bf0ce5fa libsmartcols: fix mem-leaks in samples
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-23 15:24:59 +01:00
Karel Zak f086478af4 libsmartcols: (sample) cleanup line separator usage
* add comment to explain when nolinesep flag is necessary
* force to print \n before switch to the next line to support

	  ./sample-scols-continuous > file

use case.

Addresses: https://github.com/ignatenkobrain/python-smartcols/issues/18
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-12 12:03:57 +02:00
Karel Zak 1e46776263 libsmartcols: (docs) add note about line separators
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-12 11:33:49 +02:00
Karel Zak a30f2a9b7a libsmartcols: don't call free_buffer() for uninitialized variable [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-11 15:06:41 +02:00
Karel Zak 7928a926a0 libsmartcols: fix scols_line_move_cells() n+1 error [asan]
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-18 10:41:20 +02:00
Karel Zak 1ed968c526 libsmartcols: fix heap-buffer-overflow when move columns
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 13:43:54 +02:00
Karel Zak c43874baa6 libsmartcols: fix comment (to make gtk-docs happy)
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-31 13:33:11 +02:00
Karel Zak 28a3cc83c5 libsmartcols: add scols_table_enable_noencoding()
Now the library encode all output. It seems too strict and difficult
to use the library for some use-cases -- for example if you want to
use the library for already colorized output (by esc.sequences).

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-31 11:45:23 +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
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 1b5042636f misc: fix reassigned values before old ones has been used [cppcheck]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:19:20 +02:00
Ruediger Meier 59879322e6 libsmartcols: fix warning "unused parameter"
Noticed on OSX.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-13 23:39:22 +02:00
Karel Zak f12e437436 libsmartcols: (docs) add new functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-13 11:17:06 +02:00
Karel Zak 36e07cebf1 libsmartcols: add header-repeat feature
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-13 11:11:17 +02:00
Karel Zak 5df8f14c30 libsmartcols: add missing symbols
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-12 16:35:58 +02:00
Karel Zak e33b387483 libsmartcols: add scols_table_{set,get}_termheight()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-12 11:51:36 +02:00
Karel Zak f46a8d7e66 lib/ttyutils: return terminal lines too
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-12 11:38:38 +02:00
Ruediger Meier c0d7b11a3f build-sys: fix library order when linking
We got some errors on Alpine Linux where $LTLIBINTL is non-empty:

./.libs/libcommon.a(libcommon_la-blkdev.o): In function `open_blkdev_or_file':
lib/blkdev.c:282: undefined reference to `libintl_gettext
collect2: error: ld returned 1 exit status

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-01 03:16:48 +02:00
Karel Zak 4ab60277cb libsmartcols: (docs) add missing 'since' tags
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-23 13:27:29 +02:00
Karel Zak 1ce46fcf6b libsmartcols: check scols_table_set_default_symbols() return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17 12:50:36 +02:00
Karel Zak eebf2dd89b libsmartcols: add scols_line_is_ancestor()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-05 12:12:43 +02:00
Karel Zak 7e2a4ef700 libsmartcols: add debug mesg to see width change
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak c8341f418a libsmartcols: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-13 11:47:43 +02:00
Karel Zak 066f46e0ee libsmartcols: add scols_sort_table_by_tree()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-13 11:19:59 +02:00
Karel Zak 14cd0a67a3 libsmartcols: fix relative width interpretation
The non-defined width hint (=0) should not be interpreted as relative width.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-07 14:34:11 +02:00
Karel Zak f691831481 libsmartcols: column width reduction refactoring
The current implementation is unreadable... Let's write it again with
more obvious semantic.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-07 14:34:11 +02:00
Karel Zak 48645e7bbb libsmartcols: add scols_line_move_cells()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-07 14:34:11 +02:00
Karel Zak 7bdefc7fc0 libsmartcols: add scols_table_move_column()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-07 14:34:11 +02:00
Sami Kerola 71f08e9706
tests: do not use plain 0 as NULL [smatch scan]
Likewise commit 8791804065.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-03-17 21:22:26 +00:00
Sami Kerola 4ff3d13b43
libsmartcols: fix test variable shadowing
libsmartcols/samples/fromfile.c:57:16: warning: declaration of 'flags'
shadows a global declaration [-Wshadow]
libsmartcols/samples/fromfile.c:29:33: note: shadowed declaration is here
libsmartcols/samples/fromfile.c:101:8: warning: declaration of 'flags'
shadows a global declaration [-Wshadow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-03-17 21:22:26 +00:00
Karel Zak 1765814521 libsmartcols: allow to add column to already used table
Now it's impossible to add new column if the table already contains
lines with data. This patch forces library to realloc cell array in
the lines to accept a new column.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-03 10:37:37 +01:00
Karel Zak c14224b374 libsmartcols: support columns separators greater than one output cell
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-02 16:56:39 +01:00
Yuri Chornoivan a7349ee315 docs: Fix word repetitions 2017-02-13 14:10:12 +01:00