Commit Graph

318 Commits

Author SHA1 Message Date
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
Karel Zak 6ffbd28359 libsmartcols: add scols_cell_get_alignment()
Just to hide that we use cell flags (bitwise operations) to define
cell content alignment. The patch also more explicitly specifies the
flags in the header file.

The alignment is evaluated in the order: right, center, left. The
default is left.

Note that SCOLS_CELL_FL_* are used for for table title only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-09 13:28:24 +01:00
Karel Zak efc0795811 Merge branch 'ignatenko/libsmartcols-dead' of https://github.com/ignatenkobrain/util-linux
* 'ignatenko/libsmartcols-dead' of https://github.com/ignatenkobrain/util-linux:
  libsmartcols: remove dead checks
2017-01-09 13:07:37 +01:00
Karel Zak 1f408f0220 libsmartcols: unused parameter [-Wunused-parameter]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-01-05 12:31:26 +01:00
Igor Gnatenko 16e64b6822 libsmartcols: remove dead checks
We initialize them before.

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 23:36:48 +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
Ruediger Meier 12f17a23df misc: fix typos using codespell
# command used was:
 $ ~/src/codespell/codespell \
   -w -D /home/rudi/src/codespell/build/lib/codespell_lib/data/dictionary.txt \
   $(git ls-files | grep -v "^po/\|\.xz$\|\.gz$\|\.bz2$\|\.img$\|^Documentation/releases/")

 BTW some manually grammer fixes:
   s/uses/used/
   s/begin/beginning/

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-12-01 00:01:43 +01:00
Karel Zak 95a528ddbc libsmartcols: make scols_sort_table() usable for trees
We also need to sort children when tree is enabled.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-11-02 14:39:08 +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
Karel Zak 82053f5e3d libsmartcols: add scols_column_add_width()
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-30 11:01:41 +02:00
Karel Zak 68a7f92b94 libsmartcols: custom wrap fixes
Reported-by: Igor Gnatenko <i.gnatenko.brain@gmail.com
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-27 14:16:18 +02:00
Karel Zak 81b176c4da docs: some random fixes
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-27 12:52:47 +02:00
Karel Zak 3f47320a17 libsmartcols: (docs) add missing version notes
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-27 11:35:43 +02:00
Igor Gnatenko 618a1d6dbe libsmartcols: fixes in doc generation
* Add 2.29 symbols index
* Sync argument names between header and implementation

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-09-27 11:19:03 +02:00
Karel Zak 949ea05f1a libsmartcols: support custom wrap and remove SCOLS_FL_WRAPNL
This new API provides full control on multi-line cells, you can wrap
text by new lines (build-in support) or by another way (after words,
commas, etc.) Changes:

* new scols_column_set_wrapfunc() sets pointers to two callback functions

   1/ chunksize() - returns largest data chunk size; used when we
                    calculate columns width
   2/ nextchunk() - terminate the current chunk and returns pointer to
                    the next; used when we print data

* remove SCOLS_FL_WRAPNL and add new functions scols_wrapnl_chunksize()
  and scols_wrapnl_nextchunk() to provide build-in functionality to
  wrap cells on \n

* remove scols_column_is_wrapnl() add scols_column_is_customwrap()
  (returns true if custom wrap functions are defined)

* add scols_column_set_safechars() and scols_column_get_safechars() to
  allow to control output encoding, safe chars are not encoded by \xFOO

* modify "fromfile" test code to use build-in scols_wrapnl_* callbacks
  for "wrapnl" tests

* add new function scols_column_get_table()

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-26 11:20:07 +02:00
Karel Zak 0d71eb9c4b libsmartcols: (docs) add missing functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-23 14:31:06 +02:00
Karel Zak a3b91e82f2 Merge branch 'getters' of https://github.com/ignatenkobrain/util-linux
* 'getters' of https://github.com/ignatenkobrain/util-linux:
  libsmartcols: add scols_table_is_nolinesep()
  libsmartcols: add scols_table_is_nowrap()
  libsmartcols: add scols_table_get_name()
2016-09-23 14:25:37 +02:00
Igor Gnatenko 43e06c67f9 libsmartcols: add scols_table_is_nolinesep()
And save 1 or 0 into tb->no_linesep instead of any value.

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-09-23 14:21:15 +02:00
Igor Gnatenko 8427c2ec9c libsmartcols: add scols_table_is_nowrap()
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-09-23 14:20:41 +02:00
Karel Zak 63168cf9b5 libsmartcols: cleanup scols_table_set_symbols() API
Change behavior:
  * scols_table_set_symbols(tb, NULL) remove reference to the current symbols setting
    and does not set default symbols at all

Add new functions:
  * scols_table_get_symbols()
  * scols_table_set_default_symbols()

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-23 14:20:24 +02:00
Igor Gnatenko 9696071737 libsmartcols: add scols_table_get_name()
Currently we have scols_table_set_name() but don't have getter for it.

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-09-23 14:11:34 +02:00
Igor Gnatenko e0140aa138 libsmartcols: use const qualifier for scols_table_get_termwidth
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-09-23 11:27:35 +02:00
Karel Zak 266eecd54e Merge branch 'api_const' of https://github.com/ignatenkobrain/util-linux
* 'api_const' of https://github.com/ignatenkobrain/util-linux:
  libsmartcols: use const qualifier where it's possible
  debug: use const void * for ul_debugobj()
  libsmartcols: make get_line/column_separator() return const
2016-09-23 11:14:15 +02:00
Karel Zak 02aaba6f9f libsmartcols: keep scols_table_get_termwidth() read-only
Addresses: https://github.com/karelzak/util-linux/issues/356
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-22 13:47:23 +02:00
Igor Gnatenko f7a9ea28ef libsmartcols: use const qualifier where it's possible
Closes: https://github.com/karelzak/util-linux/issues/355
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-09-21 08:36:00 +02:00
Igor Gnatenko 0e0943c15b debug: use const void * for ul_debugobj()
We don't modify data it's pointing out and we should not modify it.

Also remove casting to void * as gcc will do it automatically (before
we had to cast it explicitly to avoid warning on discarding 'const'
qualifier).

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-09-21 08:22:35 +02:00
Igor Gnatenko 6f9377ab81 libsmartcols: make get_line/column_separator() return const
The patch introduces tiny API changes (char * -> const char *) for
    scols_table_get_line_separator
    scols_table_get_column_separator

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-09-21 07:26:44 +02:00
Karel Zak 8f0c12f1c9 Merge branch 'hotfix' of https://github.com/ignatenkobrain/util-linux 2016-09-19 14:21:18 +02:00
Karel Zak ffd1325ddd Merge branch 'typos' of https://github.com/ignatenkobrain/util-linux
* 'typos' of https://github.com/ignatenkobrain/util-linux:
  libsmartcols: fix typos in docs
2016-09-19 14:20:37 +02:00
Igor Gnatenko 4fb899ed77 libsmartcols: be consistent, use 'sy' for symbols
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-09-19 14:13:51 +02:00
Igor Gnatenko bfc6941ae7 libsmartcols: fix typos in docs
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-09-19 14:13:38 +02:00
Karel Zak 4e91ebca3e libsmartcols: be more strict about empty tables
and don't print extra \n for empty table.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-19 14:07:38 +02:00
Karel Zak 166897ceb3 libsmartcols: fix comment
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-19 13:48:42 +02:00
Karel Zak d4275a4bde libsmartcols: cleanup get functions
The patch introduces tiny API changes (int -> size_t) for

	scols_table_get_ncols
	scols_table_get_nlines

Addresses: https://github.com/karelzak/util-linux/issues/349
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-19 13:39:03 +02:00
Karel Zak 695fd479be tests: add columns separator to libsmartcols test
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-16 14:18:01 +02:00
Karel Zak 4a2b50f238 tests: add export and raw to libsmartcols test
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-16 13:49:37 +02:00
Karel Zak 6a82714dbf libsmartcols: add JSON support to sample application
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-16 13:30:29 +02:00
Karel Zak 65f3ebc334 libsmartcols: improve JSON
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-16 13:22:47 +02:00
Karel Zak 346e3a40a0 libsmartcols: cleanup line separator usage
* use line separator only to separate lines, not after last line
 * explicitly print \n after table in scols_print_table()
 * don't terminate table by \n or line separator in scols_print_table_to_string()

Note that the patch is little bit trick due to impact to the trees
printing. Now print_tree_line() should be more readable.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-16 13:00:47 +02:00
Karel Zak 9aca40bbec libsmartcols: fix tree padding
We cannot use cell-padding char with in tree ASCII art, because
tree uses two chars rather than one.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-15 12:22:12 +02:00
Karel Zak 18ff51547d libsmartcols: add support for trees to the sample application
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-15 12:12:18 +02:00
Karel Zak 54c6de3d04 Merge branch 'patch-1' of https://github.com/ignatenkobrain/util-linux 2016-09-15 10:05:15 +02:00
Igor Gnatenko 8e7d9d231e trivial: s/automatical/automatic/g
"Automatical" is archaic form of "automatic".

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-09-14 19:36:51 +02:00
Igor Gnatenko 937e045855 smartcols/symbols: free cell_padding in unref()
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
2016-09-14 17:10:14 +02:00
Karel Zak 36eb51ebb4 tests: add libsmartcols title test
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-14 12:49:46 +02:00
Karel Zak fdf7279849 libsmartcols: fix hidden file usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-14 12:37:53 +02:00
Karel Zak 6db10580ca build-sys: remove dead libsmartcols sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-13 16:50:10 +02:00
Karel Zak a414a17093 tests: improve libsmartcols test
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-13 14:12:11 +02:00
Karel Zak 19055a25ed libsmartcols: add functions to control terminal usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-13 14:06:01 +02:00
Karel Zak fa4691833a libsmartcols: add application to test library features
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-13 13:08:02 +02:00
Karel Zak ef4a34bbb8 libsmartcols: fix WRAPNL on strings without \n
Addresses: https://github.com/karelzak/util-linux/issues/343
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-12 16:12:22 +02:00
Karel Zak 975ed32fd9 libsmartcols: fix WRAPNL crashes
Addresses: https://github.com/karelzak/util-linux/issues/344
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-12 11:58:34 +02:00
Karel Zak 37948503c9 libsmartcols: support LIBSMARTCOLS_DEBUG_PADDING=on
This env.variable forces libsmartcols to use visible padding chars.
The standard debug has to be enabled (to minimize overhead for
non-debug execution).

For example:

 $ LIBSMARTCOLS_DEBUG=all LIBSMARTCOLS_DEBUG_PADDING=on findmnt 2> ~/log

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-07 12:25:06 +02:00
Karel Zak f1f9b71736 libsmartcols: add fallback for symbols
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-07 11:45:35 +02:00
Karel Zak 64ce7cbbc0 libsmartcols: allow to change cell padding char
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-07 11:07:04 +02:00
Karel Zak a2b8ad291f libsmartcols: extend wrapnl sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-06 13:01:45 +02:00
Karel Zak 77a94efb5e libsmartcols: fix padding for non-maxout output
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-06 13:01:09 +02:00
Karel Zak 4f07ff4041 libsmartcols: remove debuging code from sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-06 12:24:49 +02:00
Karel Zak 6cd398642b libsmartcols: commit missing file
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-06 11:18:18 +02:00
Karel Zak ff471d89a1 libsmartcols: support multi-line cells based on line breaks
Now libsmartcols completely control when and how wrap long
lines/cells. This is sometimes user unfriendly and it would be nice to
support multi-line cells where wrap is based on \n (new line char).

This patch add new column flag SCOLS_FL_WRAPNL.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-06 10:51:25 +02:00
Karel Zak b54439cbad libsmartcols: use SCOLS_FL_RIGHT in sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 15:51:03 +02:00
Karel Zak 51962c95e3 libsmartcols: add maxout sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 15:15:28 +02:00
Karel Zak 5e6421ee07 libsmartcols: fix minimal column width calculation
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 15:13:06 +02:00
Karel Zak f067de4495 libsmartcols: fix non-tty output for 'maxout' columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 13:01:48 +02:00
Karel Zak a593128fd0 libsmartcols: fix title output on non-tty
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 12:42:38 +02:00
Karel Zak 066779c67b libsmartcols: fix scols_table_enable_colors() usage in samples
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 12:05:48 +02:00
Karel Zak d7cda881d5 libsmartcols: don't print title color is colors disabled
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-31 12:05:21 +02:00
Karel Zak 1ca2661bb8 libsmartcols: Corrected JSON escaping
Based on patch set https://github.com/karelzak/util-linux/pull/331
from Fordi.

Addresses: https://github.com/karelzak/util-linux/issues/330
Co-Author: Bryan Elliott <fordiman@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-02 12:05:05 +02:00
Karel Zak c191740c28 misc: cleanup non-widechar compilation
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-06-03 14:46:17 +02:00
Karel Zak 8f0ac57921 lib/ttyutils: use stdout for get_terminal_width()
We use the function to be sure with *output* width. Note that the
current code (with STDIN) is broken because in some situations
libsmartcols is not able to detect terminal width and fall back to
default 80.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-06-02 12:31:45 +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
Karel Zak 8fcdce8fff libsmartcols remove duplicate code
For petty long time we have strdup_to_struct_member() macro to avoid
duplicate code when strdup() strings in setter functions. Let's use it
for libmount.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-22 14:17:21 +02:00
Ruediger Meier 18336d16d9 build-sys: use AC_PROG_MKDIR_P and remove a few gnuisms
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-13 21:48:09 +01:00
Ruediger Meier 58c87bd045 misc: fix icc/clang compiler warnings
clang warning:
libmount/src/tab.c:1833:6: warning: variable 'rc' is used uninitialized whenever
      'if' condition is true [-Wsometimes-uninitialized]
        if (!mpc)
            ^~~~

icc printf warnings:
    libmount/src/monitor.c(348): warning #2279: printf/scanf format not a string literal and no format arguments
            DBG(MONITOR, ul_debugobj(mn, status == 1 ? " success" : " nothing"));
            ^
    login-utils/vipw.c(348): warning #2279: printf/scanf format not a string literal and no format arguments
                           : _("You are using shadow passwords on this system.\n"));
                                                                                  ^

icc enum warnings:
    disk-utils/fdisk-menu.c(150): warning #188: enumerated type mixed with another type
            .exclude = FDISK_DISKLABEL_GPT | FDISK_DISKLABEL_BSD,
                       ^
    libsmartcols/src/table_print.c(750): warning #188: enumerated type mixed with another type
                            &width, align,
                                    ^

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-13 21:47:27 +01:00
Karel Zak 5bb1d22e8a build-sys: fix if..endif for *_la_LDFLAGS
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-10 13:54:15 +01:00
Ruediger Meier dc0495166f build-sys: add and use openat build conditionals
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 15:37:25 +01:00
Ruediger Meier beabee7c67 libsmartcols: fix uninitialized variable
This got broken in 2a750b4c.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:04:54 +01:00
Karel Zak b64dc52a53 Merge branch 'ldadd-cflags-warnings' of https://github.com/rudimeier/util-linux
* 'ldadd-cflags-warnings' of https://github.com/rudimeier/util-linux:
  build-sys: disable unused parameter warnings for some test progs
  misc: fix compiler warnungs (unsigned/signed)
  misc: fix warnings "unused parameter" [-Wunused-parameter]
  libfdisk: fix warnings, "redundant redeclaration" [-Wredundant-decls]
  tests: fix compiler warnings [-Wmissing-prototypes]
  libfdisk: fix compiler warnings [-Wmissing-prototypes]
  libfdisk: fix missing symbol
  libblkid: fix compiler warnings [-Wmissing-prototypes]
  libmount: add mnt_fs_set_priority()
  build-sys: always add AM_CFLAGS
  build-sys: always use global LDADD
2016-02-24 13:51:10 +01:00
Karel Zak 1c3ed5bf17 libsmartcols: fix stupid typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-24 13:42:28 +01:00
Karel Zak cbe3e49535 libsmartcols: fix relative column width for maxout
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-24 12:34:37 +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 b9710f1f08 misc: fix compiler warnungs (unsigned/signed)
These ones should be fixed:
libblkid/src/probe.c:393:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/probe.c:907:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/probe.c:1221:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:540:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1043:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1056:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1057:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1061:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1199:27: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/partitions/partitions.c:1410:26: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/partitions/partitions.c:1431:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/superblocks/linux_raid.c:151:8: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
libblkid/src/superblocks/linux_raid.c:155:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
libblkid/src/superblocks/superblocks.c:375:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/superblocks/xfs.c:141:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libsmartcols/src/table.c:333:24: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libsmartcols/src/table.c:344:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libsmartcols/src/table_print.c:753:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/ask.c:364:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/utils.c:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/context.c:435:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/context.c:730:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/script.c:557:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/dos.c:1791:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/gpt.c:813:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:140:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:551:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:640:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:18:27 +01:00
Ruediger Meier 71177ab8f9 misc: fix warnings "unused parameter" [-Wunused-parameter]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:18:24 +01:00
Ruediger Meier 5fde1d9f06 tests: fix compiler warnings [-Wmissing-prototypes]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:18:09 +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 b201f1d86c build-sys: always use global LDADD
This was a major showstopper when building on a system where
LTLIBINTL libs are needed (e.g. OSX). Maybe there are a few test
programs which wouldn't need LDADD ... never mind.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:16:58 +01:00
Karel Zak 334e5eba9e libsmartcols: fix scols_table_print_range() to print header
References: https://github.com/karelzak/util-linux/issues/287
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-22 10:43:25 +01:00
Igor Gnatenko cfa185721e libsmartcols: implement scols_table_print_range_to_string
Reference: https://github.com/karelzak/util-linux/issues/283
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-02-21 21:13:50 +01:00
Karel Zak 12ca9cb1f5 libsmartcols: add sample-scols-continuous
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-19 16:47:38 +01:00
Karel Zak 2981e0fd0e libsmartcols: support continuous printing
This patch allows to disable line-breaks. This feature is usable when
you want to re-print the same line more than once -- move terminal
cursor to the begin of the line and print again and again (aka
progress bar).

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-19 16:43:28 +01:00
Karel Zak 2a750b4c4e libsmartcols: add scols_table_print_range()
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-19 14:43:06 +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
Ruediger Meier 3719bf8de9 build-sys: check linker support for version scripts
The macro AX_CHECK_VSCRIPT was taken from gnu autoconf archive.
http://www.gnu.org/software/autoconf-archive/

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-18 12:53:48 +01:00
Igor Gnatenko d381f70814 libsmartcols: fill wrapped lines with space instead of 'x'
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-02-16 12:57:55 +01:00
Igor Gnatenko f16f28b0fc libsmartcols: print title only with SCOLS_FMT_HUMAN
Reference: https://github.com/karelzak/util-linux/issues/279
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-02-13 16:13:04 +01:00
Karel Zak 20759a42ec libsmartcols: rewrite ./sample-scols-wrap
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-10 15:37:30 +01:00
Karel Zak d94c519877 libsmartcols: support multi-line cells
The initial implementation has been introduced by SCOLS_FL_WRAP columns,
but this patch clean ups all and makes things more elegant.

Note that use SCOLS_FL_TREE | SCOLS_FL_WRAP for a column is bad idea
and I don't think we need to fix it.

References: https://github.com/karelzak/util-linux/issues/269
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-10 15:34:21 +01:00
Karel Zak e865838d6d libsmartcols: use libscols_cell for title
References: https://github.com/karelzak/util-linux/issues/270
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-09 11:21:21 +01:00
Ruediger Meier 3fd1f7711e docs: fix typos found by codespell
Using "codespell" from https://github.com/lucasdemarchi/codespell

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-03 15:10:08 +01:00
Karel Zak e85c8c98e6 libsmartcols: make SCOLS_FL_WRAP usable in tree
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-25 15:31:24 +01:00
Karel Zak 5243e4ebc8 libsmartcols: reduce also SCOLS_FL_WRAP columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-25 15:17:36 +01:00
Karel Zak e90f4b6715 libsmartcols: add wrap.c sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-25 15:17:21 +01:00
Karel Zak 4a51e682bb libsmartcols: fix title sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-25 13:45:34 +01:00
Karel Zak 107ca34a4c libsmartcols: fix samples build, add title.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-25 13:42:51 +01:00
Karel Zak 2f09ae9d5d libsmartcols: add samples directory
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-25 13:17:43 +01:00
Karel Zak d372bcf26e Merge branch 'scols_fl_wrap' of https://github.com/ignatenkobrain/util-linux
* 'scols_fl_wrap' of https://github.com/ignatenkobrain/util-linux:
  libsmartcols: add scols_column_is_wrap to docs
  libsmartcols: don't loose colors when wrapping
  libsmartcols: wrap columns correctly with unicode
  libsmartcols: implement SCOLS_FL_WRAP
2016-01-25 13:03:29 +01:00
Karel Zak 982034c3d1 libsmartcols: document v2.27 symbols
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-25 12:57:14 +01:00
Igor Gnatenko db307d8e96 libsmartcols: add 'Since' tag for gtkdoc for some functions
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-25 00:12:14 +01:00
Igor Gnatenko 703d0196ee libsmartcols: add few methods to get information about title
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-25 00:12:14 +01:00
Igor Gnatenko bfc3d8b48e libsmartcols: position of title in fact unsigned
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-25 00:12:14 +01:00
Karel Zak 57867795aa libsmartcols: support multibyte titles, rename wrap to padding
- let's support multibyte table titles
- use lib/mbalign.c to align the title
- rename title_wrap to title_padding (we already use "wrap" on another
  places for another things)

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-22 16:51:59 +01:00
Igor Gnatenko ad13ab8d66 libsmartcols: add scols_column_is_wrap to docs
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-22 14:48:46 +01:00
Igor Gnatenko 57c7b2a1a5 libsmartcols: don't loose colors when wrapping
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-22 14:30:39 +01:00
Igor Gnatenko e6f89163be libsmartcols: wrap columns correctly with unicode
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-22 14:29:16 +01:00
Karel Zak fd5cbf57e0 libsmartcols: add title to the test application
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-22 13:50:02 +01:00
Karel Zak 6f2737964d libsmartcols: add JSON to the test application
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-22 13:46:29 +01:00
Karel Zak 500a229f51 libsmartcols: add new functions to docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-22 13:40:19 +01:00
Igor Gnatenko 0a69e647fc libsmartcols: set everything once in scols_table_set_title()
Reported-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-22 12:54:02 +01:00
Igor Gnatenko a640409309 libsmartcols: implement SCOLS_FL_WRAP
Reference: https://github.com/karelzak/util-linux/issues/257
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-22 12:51:45 +01:00
Igor Gnatenko 2f62d9fe3e libsmartcols: put new line after title
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-21 17:37:21 +01:00
Igor Gnatenko 7bc451694f libsmartcols: fix title aligning to center
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-21 17:36:53 +01:00
Igor Gnatenko 284ee2a9a4 libsmartcols: don't try to align title if it's more that term
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-21 17:25:15 +01:00
Igor Gnatenko cd32dc248c libsmartcols: use symbols for title wrap
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-21 17:09:16 +01:00
Igor Gnatenko b3256efff2 libsmartcols: implement title of table
Reference: https://github.com/karelzak/util-linux/issues/258
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-21 16:41:12 +01:00
Karel Zak 8afabdb1fa libsmartcols: don't sort if cmpfunc() is not set
Reported-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-18 10:47:22 +01:00
Karel Zak 7ad4b8503c libsmartcols: be sure column is unused
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-18 10:36:31 +01:00
Karel Zak 1bb767f54c Merge branch 'gh/254' of https://github.com/ignatenkobrain/util-linux 2016-01-18 10:24:39 +01:00
Igor Gnatenko d10fa7e6dd libsmartcols: reflect changinging SCOLS_FL_TREE after adding to table
When scols_column_set_flags() is called we will compare before & after
status of SCOLS_FL_TREE flag and appropriately handle tb->ntreecols.

Reference: https://github.com/karelzak/util-linux/issues/254
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-17 09:44:09 +01:00
Igor Gnatenko a229e20478 libsmartcols: add scols_column_is_hidden into sym file
In commit 6d6b6d185e we forgot to
add this function to sym file and now we are getting
undefined symbol: scols_column_is_hidden

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-01-15 23:27:52 +01:00
Karel Zak 7837186515 libsmartcols: allow to set data by reference to libscols_column
References: https://github.com/karelzak/util-linux/issues/251
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-12 11:39:03 +01:00
Karel Zak 19981b07d9 libsmartcols: make output buffer size estimation more robust and elegant
Reported-by: Andreas Henriksson <andreas@fatal.se>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-07 17:36:44 +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
Igor Gnatenko 5e8461a53a scols/table_print: restore old stream after printing to str
Reference: https://github.com/karelzak/util-linux/issues/240
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2015-12-13 15:02:05 +01:00
Karel Zak 6d6b6d185e libsmartcols: add SCOLS_FL_HIDDEN
Export "don't print this column" functionality by public API.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-10 13:02:03 +01:00
Karel Zak 96561604e2 libsmartcols: fix right-aligned logic for last column
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-07 15:10:23 +01:00
Karel Zak 05c1123bc3 libsmartcols: don't use fprintf() when count cells
fprintf("%*s") is based on bytes, no cells.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-07 12:22:29 +01:00
Karel Zak df73852b6e libsmartcols: add scols_table_enable_nowrap()
This allows to use libsmartcols in ncurses programs without any
additional voodoo.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-07 12:03:52 +01:00
Karel Zak c600d82a3a libsmartcols: make sure we have space for ascii art
* more verbose output about columns width counting
* strlen_line() does not care about space between columns and extra
  tree ASCII art. Let's assume that all termwith is possible to use
  for this extra stuff, it means that maximal buffer size is
  biggest_line + termwidth.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-11-30 12:53:42 +01:00
Karel Zak 440f73b7bc libsmartcols: allow to reduce tree columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-11-30 11:43:05 +01:00
Karel Zak 2c6567799d build-sys: add --disable-assert
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-04 13:40:44 +02:00
Karel Zak fdd68e25b5 libsmartcols: make child-parent reference more robust [clang analyze]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-29 14:44:27 +02:00
Karel Zak 5627fcec0e libsmartcols: reduce relative columns more aggressively
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-27 14:29:38 +02:00
Karel Zak 0bef6f759b libsmartcols: don't link with tinfo
Let's move color names to sequence translation to separate file to
make it usable without all the stuff in lib/colors.c.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-24 12:57:46 +02:00
Karel Zak 6a768b5516 libsmartcols: keep JSON field names lower-case
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-05 11:58:42 +02:00
Karel Zak 4827093d4b losetup: add --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-05 10:30:52 +02:00
Karel Zak 2a6cfc1361 libsmartcols: add JSON output format
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-04 15:47:21 +02:00
Karel Zak d5dbd57b22 docs: fix gtk-docs related warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-28 12:28:23 +02: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