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>