summaryrefslogtreecommitdiffstats
path: root/text-utils
Commit message (Collapse)AuthorAgeFilesLines
* column: fix outputing empty column at the end of lineYousong Zhou2019-07-291-1/+1
| | | | | | | | | | | | | The following commands manifests the problem. In old versions before commit 4762ae9d60 ("column: use libsmartcols for --table"), both of them should output with 2 "|" echo '||' | column -o '|' -s '|' -t echo '|| ' | column -o '|' -s '|' -t Fixes: 4762ae9d60 ("column: use libsmartcols for --table") Signed-off-by: Yousong Zhou <zhouyousong@yunionyun.com> Reviewed-by: Sami Kerola <kerolasa@iki.fi>
* misc: replaces atexit(close_stdout) with new close_stdout_atexit()Karel Zak2019-06-171-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* rev: be careful with close()Karel Zak2019-06-131-1/+2
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/807 Signed-off-by: Karel Zak <kzak@redhat.com>
* ul: make sure buffers are zeroized [coverity scan]Karel Zak2019-05-281-2/+2
|
* column: make code more robust [coverity scan]Karel Zak2019-05-281-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: fix "maybe be" duplicationAustin English2019-05-151-1/+1
| | | | Signed-off-by: Austin English <austinenglish@gmail.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-1610-38/+31Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: Address fill-order confusion in documentationdana2019-02-221-1/+10
| | | | | | | | | | | | | | | | | | Historical versions of column have described the default fill order as rows-then-columns and the -x order as columns-then-rows. This was misleading at best, and the util-linux implementation was updated to clarify the actual behaviour in 3e094e5fe2 (March 2017). However, the other implementations (used by *BSD, macOS, Debian, &al.) continue to use the previous wording, and a user comparing them could easily get the false impression that util-linux column has exactly the opposite fill behaviour from BSD column. To address this, a note is added to the man page explaining the change and clarifying that, despite what the BSD documentation says, the two implementations behave identically in this regard. Signed-off-by: dana <dana@dana.is>
* col: improve error message, update regression testKarel Zak2019-02-051-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* col: make flush_line() a little bit robustKarel Zak2019-02-051-6/+7
| | | | | | | | | | | | | | The code is horrible. The core of the problem are signed integers and no check for the limits. This patch fixes c->c_column = cur_col; where c_column is "short" and "cur_col" is int. Let's use "int" for all the variables. It's really not perfect as for bigger lines it can segfault again... The patch also removes some unnecessary static variables. Addresses: https://github.com/karelzak/util-linux/issues/749 Signed-off-by: Karel Zak <kzak@redhat.com>
* hexdump: fix potential null pointer dereference warningsSami Kerola2018-12-101-5/+7
| | | | | | | | | | | | | | | First three fixes on lines 133, 151, and 280 are cosmetic. Because there was unobvious null check compiler thought variable might be null, and warned when after pointer adjustment it was followed without null check. Perhaps this will not happen sometime in future when compiler is made more smart, meanwhile lets give better hints to avoid false positive. The last change addresses issue that is possible, at least in theory. text-utils/hexdump-parse.c:465:12: warning: potential null pointer dereference [-Wnull-dereference] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: rename functionsSami Kerola2018-09-021-85/+86
| | | | | | This clarifies what various function calls are doing. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: rename variable namesSami Kerola2018-09-021-558/+556Star
| | | | | | | | Try to make variable names to tell what they do. Earlier names have been in more(1) since the command was first wrote, and it looks like coding practices has changed since late 70's. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: remove unnecessary ifdef preprosessor directivesSami Kerola2018-09-021-8/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: do not call fileno() for std{in,out,err} streamsSami Kerola2018-09-021-6/+6
| | | | | | These file descriptor numbers are well known, use them from unistd.h Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: remove 'register' keywordsSami Kerola2018-09-021-29/+29
| | | | | | | | One can only assume someone tried to make more(1) to run quicker. More up to date assumption is that compilers are fully capable optimizing binaries without these sort of hints. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: remove pointless functionsSami Kerola2018-09-021-61/+34Star
| | | | | | | The curs_terminfo(3X) defines putp() as tputs(str, 1, putchar), so all of these five functions can be replaced with putp(). Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: return is statement not a functionSami Kerola2018-09-021-20/+20
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: remove dead code and useless commentsSami Kerola2018-09-021-74/+24Star
| | | | | | | | | | | Removal of STOP requires explanation. Looking unix-history-repo getline() function in first BSD-3 version could return STOP. By next tag BSD-4 the return STOP had disappeared. If I read this correctly that was a partial removal, and second part has waited to be completed since 1980-11-16 when BSD-4 was released. Reference: https://github.com/dspinellis/unix-history-repo/blob/BSD-3-Snapshot-Development/usr/src/cmd/more.c#L501 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: add --table-empty-linesKarel Zak2018-08-232-2/+25
| | | | | | | | | | | | | | | | | | | | | The option allows to add empty line to the table. The default behavior is to ignore empty lines at all. echo -e "A\nAA\nAAA\n\nAAAA" | ./column --table A AA AAA AAAA $ echo -e "A\nAA\nAAA\n\nAAAA" | ./column --table --table-empty-lines A AA AAA AAAA Addresses: https://github.com/karelzak/util-linux/issues/593 Signed-off-by: Karel Zak <kzak@redhat.com>
* Fix man page typosJakub Wilk2018-08-161-1/+1
| | | | Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
* man pages: Remove "left" (or change to "l") in the column formats of tablesBjarni Ingi Gislason2018-08-061-1/+1
| | | | | | | | | A developmental version of "groff" issued a warning, for example with "test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z": troff: <logger.1>:299: warning: can't find font 't' Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
* more: remove function like preprocessor definesSami Kerola2018-06-181-104/+134
| | | | | | | | | Inlining code using preprocessor function like macros is bad for readability, and prone to errors. Besides this is a pager, who cares if code is few milliseconds slower. Requestee-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: remove global variables, add struct more_controlSami Kerola2018-06-181-639/+671
| | | | | | | | 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>
* more: move couple functionsSami Kerola2018-06-181-123/+123
| | | | | | | | 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: a8f98304e6d2f4627ca31f6c661934c92b1095f7 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rev: move a global variable to local scopeSami Kerola2018-05-281-3/+2Star
| | | | | | Mark also file names read-only. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* man: Use the correct macro for a font change of one argumentBjarni Ingi Gislason2018-05-232-4/+4
| | | | | | | | 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>
* more: reorder global declarationsSami Kerola2018-05-231-48/+48
| | | | | | | 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>
* more: remove function prototypesSami Kerola2018-05-231-998/+968Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: fix leading space characters bugKarel Zak2018-03-271-33/+3Star
| | | | | | | | | | | | | | | | | | 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 5c7b67fbbf41c973ca8d49b1e8bdba22dbb917aa (alter), but this solution is unnecessary and too complex. Changes: * don't ignore leading space * remove unnecessary stuff introduced by 5c7b67fbbf41c973ca8d49b1e8bdba22dbb917aa * 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>
* column: update column.1ahmogit2018-03-191-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: fix memory leak [coverity scan]Karel Zak2018-02-201-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: don't ignore space-char separators at begin of the lineKarel Zak2018-02-121-1/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* text-utils: use errexec()Karel Zak2018-02-012-4/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix typosSami Kerola2017-11-281-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* column: use \x<hex> for invalid multibyte seq.Karel Zak2017-11-222-3/+15
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/542 Signed-off-by: Karel Zak <kzak@redhat.com>
* column: allow to hide unnamed columnsKarel Zak2017-11-132-2/+35
| | | | | Addresses: https://github.com/karelzak/util-linux/pull/327 Signed-off-by: Karel Zak <kzak@redhat.com>
* column: add --table-noheadingsKarel Zak2017-11-132-2/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* column: (-t) disable encoding for non-printable charsKarel Zak2017-07-311-1/+3
| | | | | | | | | $ 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>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-2910-18/+18
| | | | | | | | | 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>
* column: fix compilation when libc lacks wide-character supportCarlos Santos2017-06-291-0/+8
| | | | | | | | | | | | | | | | 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>
* misc: consolidate all --help option descriptionsRuediger Meier2017-06-272-4/+6
| | | | | | | | 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>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-278-16/+8Star
| | | | | | | | | | | | 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>
* misc: cosmetics, remove argument from usage(FILE*)Ruediger Meier2017-06-267-20/+25
| | | | | | | | | | | | | | 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>
* misc: cosmetics, remove argument from usage(int)Ruediger Meier2017-06-261-4/+4
| | | | | | | This patch is trivial and changes nothing, because we were always using usage(0). Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: never use usage(stderr)Ruediger Meier2017-06-261-5/+8
| | | | | | | Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: cleanup and fix --unknownopt issuesRuediger Meier2017-06-261-6/+7
| | | | | | | | | | | | | | | | 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>
* more: add --help and --versionRuediger Meier2017-06-222-7/+28
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: remove superfluous null pointer checks for optargRuediger Meier2017-06-221-1/+1
| | | | | | This is only needed for optional arguments. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* more: remove unused variableRuediger Meier2017-06-151-2/+1Star
| | | | | | | | | 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>