The getwchar(3) will choke and exit if invalid character is encountered.
This change will make col(1) to print broken multibyte characters as
\x{hex} string.
Reported-by: Vitaly Lipatov <lav@etersoft.ru>
Addresses: https://github.com/karelzak/util-linux/issues/1198
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Before this change the error message about directory was not informative,
and a little bit out of place.
$ touch empty ; ./more ./empty /
::::::::::::::
./empty
::::::::::::::
magic failed: cannot read fd 4 (Is a directory)
::::::::::::::
/
::::::::::::::
After the change messaging is reverted back to what it used to be.
$ ./more ./empty /
::::::::::::::
./empty
::::::::::::::
*** /: directory ***
And while on it lets remove repeated fstat() call.
Fixes: 09070e1a65
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Short options had all sortss of characters listed, that were clearly copied
from col(1) command getopt_long() invocation. Luckily both -V and -h were
part of the short options, but lets get rid of the unnecessary ones.
Fixes: 1647d032a7
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
As mentioned in 'Generating optimal glyphs' title in the manual page
mentioned in reference:
Where a proper caret (^) that renders well in both a terminal and PDF is
required, use "\(ha".
Using a naked "~" character results in a poor rendering in PDF. Instead
use "\(ti".
Reference: https://man7.org/linux/man-pages/man7/man-pages.7.html#STYLE_GUIDE
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
When calling variadic functions, NULL must be explicitly cast to a
desired type.
This is noted in the exec(3) manpage.
The call in newgrp.c was changed for consistency.
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
The size_t is the type libc memory allocation functions use. The size_t
also provides allocation range that is enough not to a simple tool like this
to perform paranoia size checks. Just let the realloc(3) fail if there is
not enough memory available to handle the requested line size. That is a
lot more straightforward.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
First two are are ISO/IEC 2022 graphic character sets G0 (normal) and G1
(alternative), that one has to Switch In (SI) and Switch Out (SO). The rest
are about how ul(1) is interacting with various text emphasis.
Reference: https://tldp.org/HOWTO/Keyboard-and-Console-HOWTO-6.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The #ifdef HAVE_WIDECHAR can be removed, because the command already is
using wide character functions elsewhere without fallbacks.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The col(1) is using unusual -H as --help short option. The -h is used for
--tabs (horizontal tab?) in this implementation.
Fixes: 62dee0176a
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The macro FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION does not have to
enabled in all cases (e.g. default travis-ci, local tests, ...). It
seems more robust also check for __SANITIZE_ADDRESS__ too.
Addresses: https://github.com/karelzak/util-linux/pull/1115
Signed-off-by: Karel Zak <kzak@redhat.com>
- remove extra line about stdout in usage() output
- use our macros to print int about --help and --version
- remove uint8_t bit-field from struct col_ctl (it seems fragile for
future code changes).
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'col-refactor' of https://github.com/kerolasa/util-linux:
col: replace LINE and CHAR typedefs with structs
col: free memory before exit [LeakSanitizer]
col: tidy up sources a little bit
col: add defaults to switch case clauses
col: flip all comparisions to numerical order
col: use size_t when dealing with numbers that buffer sizes
col: add structure to hold line variables
col: add update_cur_line() function
col: add handle_not_graphic() function
col: initialize variables when they are declared
col: move option handling to separate function
col: move global variables to a control structure
col: use inline function rather than function like define
col: use typedef and enum to clarify struct
col: remove function prototypes
col: add more tests
Karel Zak said; typedef is evil, see reference. I don't know are they evil,
but it is fair comment structs without hiding what is the data type is
easier and quicker understand when reading the code.
Reference: https://github.com/karelzak/util-linux/pull/1115#discussion_r481971317
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Left side is always smaller or equal to right side. This makes reading code
quicker when not having to constantly swap where is the greater value.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The size (3rd) argument should be ignored if the 1st *dest is NULL, but it seems gcc & glibc headers
are more pedantic now:
ext-utils/pg.c:456:13: error: argument 1 is null but the corresponding size argument 3 value is 2048 [-Werror=nonnull]
Signed-off-by: Karel Zak <kzak@redhat.com>
When invoking hexdump as hd enable the "Canonical" format to by
default, implying the -C option.
This is historic behaviour on Debian and apparently also on FreeBSD.
Some Debian users have asked for this to be restored, after Debian
switched to util-linux' hexdump and hd.
Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
The wording "allow(s) to" is not grammatical English. Reword various
pages to use a more correct form such "can be use to" or "allows
the [noun] of".
Aklong the way, fix a few nearby wording errors in some pages.
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
Commit I made while back and has been part of util-linux v2.30 to v2.35 made
col(1) not to output anything when first line did not have newline character.
printf "gone from output" | col
This commit fixes the issue. Admittedly the col source code is unnecessarily
hard to work with. It could be a good idea to refactor the col(1) as low
priority task, Assuming refactoring is done the first commit to get that done
should add tests that exhaust all possible input handling including all command
line option directives.
Addresses: https://github.com/karelzak/util-linux/issues/422
Fixes: b6b5272b03
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
In several pages, there is a consistent wording problem: "another"
where "other" should be used. This wording problem can be
surprisingly confusing for native speakers, especially those
unaware that in some other languages, "another" and "other" can be
expressed with the same word.
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
Earlier, I patched various pages to consistently use EXAMPLE as a
section heading, rather than EXAMPLES. (At that time, both headings
occurred in util-linux, with roughly equal frequency.)
Since then, I've observed that EXAMPLES is the more common usage
across a large corpus of manual pages. So, in Linux the man-pages
project, I switched to using EXAMPLES also. This patch makes the same
change for util-linux.
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
My earlier change that took libmagic in use to identify mime-type of an input
file caused empty files to be marked binary. Before the change empty files
were simply displayed as empty. This change will restore that behavior.
Addresses: 09070e1a65
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.
In this patch, we ensure that the NOTES, HISTORY, BUGS, and EXAMPLE
sections are always placed near the end of the page, just above
AUTHORS, COPYRIGHT, SEE ALSO, and AVAILABILITY.
One page is not fixed by this patch: term-utils/agetty.8. This page
is a mess of unusual section names, and probably requires an individual
edit.
Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
[Apply patch]
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
$ diff a b
$ echo $?
0
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>