]> git.ipfire.org Git - thirdparty/coreutils.git/commit
fold: add the --characters option
authorCollin Funk <collin.funk1@gmail.com>
Thu, 21 Aug 2025 04:13:52 +0000 (21:13 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Sat, 23 Aug 2025 05:09:50 +0000 (22:09 -0700)
commit7d0d9658f9da211c42abdc0ef45434ce5fc0fe8e
tree9ebd96129b2f769f9c0846900adc1a1c088f587a
parent39f22fe687ea0c226e3fb35e86cd5ea329180b80
fold: add the --characters option

* src/fold.c: Include mcel.h.
(count_bytes): Remove variable.
(counting_mode, last_character_width): New variables.
(shortopts, long_options): Add the option.
(adjust_column): If --characters is in used account for number of
characters instead of their width.
(fold_file): Use getline and iterate over the result with mcel functions
to handle multibyte characters.
(main): Check for the option.
* src/local.mk (src_fold_LDADD): Add $(LIBC32CONV), $(LIBUNISTRING), and
$(MBRTOWC_LIB).
* tests/fold/fold-characters.sh: New file.
* tests/fold/fold-spaces.sh: New file.
* tests/fold/fold-nbsp.sh: New file.
* tests/local.mk (all_tests): Add the tests.
* NEWS: Mention the new option.
* doc/coreutils.texi (fold invocation): Likewise.
NEWS
doc/coreutils.texi
src/fold.c
src/local.mk
tests/fold/fold-characters.sh [new file with mode: 0755]
tests/fold/fold-nbsp.sh [new file with mode: 0755]
tests/fold/fold-spaces.sh [new file with mode: 0755]
tests/local.mk