Commit Graph
31833 Commits
Author SHA1 Message Date
Pádraig Brady 445105045d build: consolidate smack avoidance to --without-libsmack
configure accepted (and needed) both --without-libsmack
and --disable-libsmack specified, to fully disable support.

* gl/modules/smack: Require gl_FUNC_ACL_ARG so we
use a consistent and single --without-libsmack option.
This also better aligns with --without-selinux.
* NEWS: Mention the Build-related change.
2026-10-13 11:32:44 +01:00
Pádraig Brady 402bce6637 ls: fix missing ACL indicators or capability colors
On systems where the security context reports as unsupported,
and we encountered a file without ACLs, no further lookups
would be performed.  Introduced in commit v9.5-156-gb857d66b5.
This fix is along similar lines as commit v9.6-40-gcb2abbac7.

* src/ls.c (file_has_aclinfo_cache): Don't mark file system as
unsupported if there might be ACLs or capabilities present.
* tests/ls/acl-cache.sh: Add a new test.
* tests/local.mk: Reference the new test.
* tests/ls/acl.sh: Add a check.
* NEWS: Mention the bug fix.
2026-10-13 11:32:41 +01:00
Pádraig Brady 19cc2bad3c env: avoid an ioctl() call when not outputting
* src/env.c (main): Avoid an isatty() call
(introduced in commit v9.12-10-g782a1e5bc) when
invoking a command, and not outputting.
2026-10-12 20:55:24 +01:00
Pádraig Brady e1bb670aff tests: fix currently always skipped test
* tests/misc/tty-quoting.sh: Since commit v9.12-10-g782a1e5bc,
env(1) calls isatty() and thus induces another ioctl()
which causes the test to skip.  The env(1) is redundant anyway
as strace will avoid shell builtins, so just remove the redundant
env calls.
2026-10-12 20:55:24 +01:00
Pádraig Brady 2950a3d53d ls: avoid redundant xattr lookups for directory arguments
* src/ls.c (gobble_file): Directory args don't have their
ACL or security context displayed, so avoid to the lookup.
E.g. this results in the same number of xattr calls with
`ls -l .` and `ls -l`.
2026-10-12 20:55:24 +01:00
Pádraig Brady ce0f62f608 tests: avoid skipping a test on non SELinux builds
* tests/ls/getxattr-speedup.sh: Add listxattr calls into the list
to trace/fail so that the test also works on non-SELinux builds.
Also adjust the test to compare call counts with varying number
of files, rather than checking a particular call count limit,
as that is a bit coupled with the implementation.

Link: https://github.com/coreutils/coreutils/pull/368
2026-10-12 20:55:24 +01:00
Collin Funk 338e04d1e1 maint: remove unnecessary configure checks for libdl and dlopen
Since commit bff0e5412 (build: sort: explicitly tag libcrypto
dependency, 2026-09-06), which added a dependency on Gnulib's sd-dlopen
module, this check has been unnecessary. This can be seen by the
separate variables in Makefile.in, which have the same purpose.

    $ grep -E '^LIB_?DL' Makefile.in
    LIBDL = @LIBDL@
    LIB_DL = @LIB_DL@

* src/local.mk (src_sort_LDADD): Use $(LIBDL) instead of $(LIB_DL).
* configure.ac: Likewise. Don't check for dlopen and libdl, which Gnulib
has already done for us.
2026-10-11 13:57:19 -07:00
Pádraig Brady 887f0a64b2 pr: improve error message for -e,-i,-n character parsing
`pr -e=-1` gives a confusing error relating to just the "-1" portion,
when in fact "=" might have been inadvertently treated as a param.
Also one gets confusing errors in the case of mishandled
multi-byte characters, if the whole argument is not diagnosed.

* src/pr.c (getoptarg): Output the complete passed argument,
to avoid the confusion with "=" being used with a short option.
* tests/pr/options.sh: Adjust accordingly.

Link: https://github.com/coreutils/coreutils/issues/375
2026-10-11 15:25:16 +01:00
Collin Funk 4e7ea3638c timeout: don't fail to build with non-Linux prctl implementations
Linux 2.1.57 introduced both prctl(2) and PR_SET_PDEATHSIG(2), so the
condition before this patch is correct there. However, other systems
have a prctl function but not PR_SET_PDEATHSIG, e.g., Irix and
SerenityOS.

* src/timeout.c (main): Check that PR_SET_PDEATHSIG is defined before
using it.
2026-10-10 21:44:39 -07:00
Pádraig Brady 700d8235a3 all: only markup --help when outputting to tty
Since v9.10 (Feb 2026) --help always outputs bold and hyperlinks
even when output was not a tty, as this was thought more useful
with pagers and grep etc.  This change makes the more conservative
choice of only outputting markup to tty so that users who do not
have less setup to display color (-R), or users who enable color
by default in grep, get improved output (though without URLs etc.)

* src/system.h (oputs_): Call isatty() when not
forcing markup with $IN_HELP2MAN.  Also reverse the
double negatives to a more natural form.
* man/local.mk: Remove redundant assignment of $TERM.
* doc/coreutils.texi (common options): Mention that --help markup
requires output to be a tty, and that $IN_HELP2MAN overrides that.
* NEWS: Mention the change in behavior.
2026-10-10 21:02:48 +01:00
Pádraig Brady a40b8d1191 tr: accept undocumented -u for FreeBSD / macOS compat
* src/tr.c (main): Accept -u to set stdout to unbuffered.
* NEWS: Mention the new feature.

Link: https://github.com/coreutils/coreutils/issues/374
2026-10-10 21:02:40 +01:00
Collin Funk 9c7cf20c3c doc: NEWS: mention the fix from the previous commit
* NEWS: Mention the crash when invoking various programs --help option
when configured with --disable-bold-man-page-references and
--disable-manual-url.
2026-10-08 21:17:26 -07:00
Nick Bowler d66cf56e25 chroot,head,shred,sort,split,tail: fix crash when emitting --help
This crash only occurs when configured with both
--disable-bold-man-page-references and --disable-manual-url.

* src/system.h (oprintf_): Add a va_start and va_end call surrounding
the call to vprintf.
Copyright-paperwork-exempt: Yes
2026-10-08 21:16:23 -07:00
Collin Funk c2dd4d5d34 tests: wc: simplify construction of the input file
* tests/wc/page-size.sh: Prefer 'truncate' redirecting 'head /dev/zero'.
Suggested by Andreas Schwab.
2026-10-08 17:49:14 -07:00
oech3 19ebb3e1a7 tests: ls: replace LD_PRELOAD of getxattr-speedup.sh with strace
* tests/ls/getxattr-speedup.sh: Replace LD_PRELOAD by strace
to support static executables.

Link: https://github.com/coreutils/coreutils/pull/368
2026-10-08 19:27:42 +01:00
Pádraig Brady f23566441f basenc: improve base58 encoding performance without gmplib
$ ./configure --without-libgmp --quiet
  $ dd bs=64k count=1 if=/dev/urandom of=58.in

  $ time src/basenc-before --base58 58.in >/dev/null
  real	0m6.588s

  $ time src/basenc-after --base58 58.in >/dev/null
  real	0m3.463s

* src/basenc.c (base58_encode): Remove an affirm that is very expensive
in the minigmp implementation.  Essentially the same affirm was done
at the start of the function anyway.
* NEWS: Mention the improvement (including the impending similar
mpz_sizeinbase() removal from mini-gmp).
2026-10-08 13:45:41 +01:00
Pádraig Brady f2d996bd1b tests: avoid NULs in test log
* tests/wc/page-size.sh: Remove NULs from logs,
also change from using Heredocs which are overkill.
2026-10-08 13:14:44 +01:00
Collin Funk 77e7674add tests: wc: add a test for the fix in the previous commit
* tests/wc/page-size.sh: New file.
* tests/local.mk (all_tests): Add the new test.
2026-10-08 00:39:50 -07:00
Paul Eggert c3709a88f2 wc: fix buffer boundary calculations
Problem reported by Scott Orme (Bug#82013).
* src/wc.c (wc): Fix calculations of file sizes vs page size
vs block size.
2026-10-07 23:26:45 -07:00
Pádraig Brady c00f9f8f99 maint: fold: remove persistent character width handling
This is now possible due to the previous changes
as default mode subtracts one column, and
-c subtracts one character, and every character counts as one,
so there is no need to track the last_character_width
(which is problematic anyway in the presence of
multiple backspaces).

* src/old.c (adjust_column): Just use the locally determined width.
2026-10-07 12:40:21 +01:00
Pádraig Brady d454017b5d fold: restrict whole character backspace to -c
With POSIX (and the LI18NUX2000 patch) backspaces back up by 1 column.
This matches terminal output.  Note less(1) and thus grotty(1)
use per character backup accounting for their legacy bold/underline
markup format, so we'll keep --characters to enable that mode if needed.
This also avoids the issue of multiple backspaces
using the width of a single previous character.

* src/fold.c (adjust_column): Without -c,
have backspace back up by 1 column.
* doc/coreutils.texi (fold invocation): Mention that --characters
does per character width backspace accounting.
* tests/fold/fold-characters.sh: Add/Adjust test cases.
* NEWS: Mention the change in behavior.
2026-10-07 12:40:05 +01:00
Pádraig Brady e7d10e546a fold: fix backspace accounting after TAB
* src/fold.c (adjust_column): Ensure BS goes back
1 column after a TAB.
* tests/fold/fold-characters.sh: Add test cases.
* NEWS: Mention the bug fix.
2026-10-07 12:40:05 +01:00
Pádraig Brady 1af1bbf33b fold: fix backspace handling with multi-cell characters
* src/fold.c (adjust_column): Clamp the column decrement to 0.
* tests/fold/fold-characters.sh: Add a test case.
* NEWS: Mention the bug fix.
2026-10-07 12:40:05 +01:00
Devel 329e1fc3f4 fmt: improve --goal error message
* src/fmt.c (main): Since -w and -g can both be specified,
provide a distinguishing validation message for --goal.

Link: https://github.com/coreutils/coreutils/pull/364
2026-10-07 12:33:44 +01:00
Ismail Ramzi b9776257e8 chroot: prefer the in-chroot primary group with --userspec=USER
* src/chroot.c (main): When the primary group was inferred from the
uid outside the chroot, let a successful getpwuid() inside the chroot
replace it, as is already done for the uid and supplemental groups.
Previously the gid found outside persisted, so for example
'chroot --userspec=alice NEWROOT' ran with alice's uid from NEWROOT
but alice's gid from the host.
* NEWS: Mention the bug fix.

Link: https://github.com/coreutils/coreutils/pull/363
2026-10-07 12:33:14 +01:00
Collin Funk 9a38bb9186 tests: misc: skip a test if the absolute top build dir is unsafe
Without this change, this test would fail during 'make distcheck', for
example.

* tests/misc/exec-bad-unicode.sh: Skip the test if $abs_top_builddir has
spaces or special characters.
* cfg.mk (_tb_misc): Also match tests/misc/exec-bad-unicode.sh.
Reported by Bruno Haible.
2026-10-06 20:21:43 -07:00
Vidya m d5ee8b245c maint: basenc: use the COUNTED_BY attribute for the base58 buffer
* src/basenc.c (struct base58_context): Declare capacity before the buf
member and annotate buf with COUNTED_BY.
(base58_encode_ctx_finalize, base58_decode_ctx_finalize): Reset size and
capacity to zero when freeing buf and setting it to NULL, so the
counted-by invariant holds.
Copyright-paperwork-exempt: Yes

Link: https://github.com/coreutils/coreutils/pull/362
2026-10-06 18:54:10 -07:00
Collin Funk a0cec995fa tests: sum,cp: disable Unicode when executing Perl
* tests/local.mk (TESTS_ENVIRONMENT): Set PERL_UNICODE to 0.
* tests/cksum/sum-sysv.sh: Call binmode on STDOUT.
* tests/cp/copy-FMR.sh: Likewise.
* tests/cp/sparse-extents-2.sh: Likewise.
Fixes https://bugs.gnu.org/81994
2026-10-05 19:56:44 -07:00
Pádraig Brady e6c09ec0b1 tests: fix false failure on SELinux disabled systems
* tests/misc/no-fork.sh: Use an "unused" placeholder
so runcon is invoked with the correct number of arguments
where `id -Z` doesn't return anything.
This is needed since commit v9.12-53-g8555a51f2
2026-10-05 12:37:08 +01:00
Collin Funk 98c8b158b6 tests: make checks for $LOCALE_FR and $LOCALE_FR_UTF8 consistent
* tests/cp/non-utf8-name.sh: Check for $LOCALE_FR and $LOCALE_FR_UTF8
being empty or the string "none".
* tests/date/percent-percent.sh: Likewise.
* tests/du/block-size.sh (test_unit): Likewise.
* tests/ls/non-utf8-hidden.sh: Likewise.
* tests/mktemp/bad-unicode.sh: Likewise.
* tests/sort/sort-unique.sh: Likewise.
* tests/df/problematic-chars.sh:  Check for $LOCALE_FR_UTF8 being empty
or the string "none".
* tests/expand/mb.sh: Likewise.
* tests/fold/fold-characters.sh: Likewise.
* tests/fold/fold-nbsp.sh: Likewise.
* tests/fold/fold-spaces.sh: Likewise.
* tests/fold/fold-zero-width.sh: Likewise.
* tests/join/join-utf8.sh: Likewise.
* tests/misc/sleep.sh: Likewise.
* tests/nl/multibyte.sh: Likewise.
* tests/paste/multi-byte.sh: Likewise.
* tests/printf/printf-mb.sh: Likewise.
* tests/printf/printf-quote.sh: Likewise.
* tests/sort/sort-debug-keys.sh: Likewise.
* tests/unexpand/mb.sh: Likewise.
2026-10-04 15:31:59 -07:00
Collin Funk cf98d8e8ca tests: misc: test programs can execute invalid Unicode program names
* tests/misc/exec-bad-unicode.sh: New file.
* tests/local.mk (all_tests): Add the new test.
2026-10-04 14:31:04 -07:00
Collin Funk 8555a51f2d tests: misc: avoid an unnecessary 'eval'
* tests/misc/no-fork.sh: Adjust the quoting of the printf call instead
of using 'eval'.
2026-10-04 11:24:08 -07:00
Collin Funk a2415242cb maint: ptx: silence -Wimplicit-fallthrough with clang
* src/ptx.c (matcher_error): Mark with _Noreturn.
2026-10-03 23:22:36 -07:00
Collin Funk 7fc7cf3a31 maint: pwd: use the COUNTED_BY attribute on the constructed file name
* src/pwd.c (struct file_name): Use COUNTED_BY on the buf member.
2026-10-03 15:40:46 -07:00
Collin Funk a940d3c920 maint: factor: use the COUNTED_BY attribute for the list of factors
* src/factor.c (struct mp_factors): Use COUNTED_BY on the f member.
(mp_no_factors): Use 0 instead of NULL when initializing the return
value.
2026-10-03 15:40:46 -07:00
Pádraig Brady b64df1ef3d all: fix U+0085 (next line) being considered a separator
cut, expand, fold, join, numfmt, unexpand, uniq, on non-GLIBC platforms
treated the \u0085 (next line) character as a blank character.

src/system.h (c32isvertspace): Include 0x0085 so c32issep() excludes it.
Also split out to ...
(c32isnewline): ... a new function, in case we need to
consider unicode newlines in isolation in future.
* tests/unexpand/mb.sh: Add a test case to both ensure
processing of \u0085 characters does not overflow a buffer,
and that those characters are not treated as separators.
* NEWS: Mention the fix.

Link: https://github.com/coreutils/coreutils/pull/361
2026-10-03 23:31:54 +01:00
Ismail Ramzi 52e5694f41 unexpand: fix heap overflow on negative-width whitespace
* src/unexpand.c (unexpand): Clamp a negative c32width() to 1 when
accumulating a blank, matching the sibling non-blank path and expand
and fold.  A separator whose display width is negative (e.g. U+0085
where c32issep() accepts it) left 'column' un-advanced, so the pending
blank buffer, sized for one byte of advance per blank, grew without
bound.
* NEWS: Mention the bug fix.

Link: https://github.com/coreutils/coreutils/pull/361
2026-10-03 23:31:49 +01:00
Pádraig Brady 3aae63af9a wc: optimize ASCII and UTF8 character counting
Generate ASCII and UTF-8 data:
  $ yes $(yes eeeaae | head -n10K | paste -s -d,) | head -n10K > ll.in
  $ yes $(yes éééááé | head -n9 | paste -s -d,) | head -n1M > mb.in

ASCII is 14x faster:
  $ time src/wc-before -m < ll.in
  real	0m1.801s
  $ time src/wc-after -m < ll.in
  real	0m0.123s

UTF-8 is 7x faster:
  $ time src/wc-before -m < mb.in
  real	0m1.399s
  $ time src/wc-after -m < mb.in
  real	0m0.189s

* src/wc.c (wc): Use the u8_count() routine like cut(1),
to optimize counting valid UTF-8 characters.
* tests/wc/wc.pl: Add a test case.
* NEWS: Mention the improvement.
2026-10-03 15:47:15 +01:00
Pádraig Brady 6c2dda15e0 maint: move utf8 specific routines to a new utf8 module
* bootstrap.conf: Reference the new "utf8" module.
* cfg.mk: Adjust checks as per mbbuf.
* gl/lib/utf8.c: Include the implementation.
* gl/lib/utf8.h: Add is_utf8_charset() and u8_count().
Note we don't give is_utf8_charset external-linkage
due to its static cache.
* gl/local.mk: Reference the new module files.
* gl/modules/utf8: Add the module definition and dependencies.
* src/cut.c: Use is_utf8_charset() and u8_count().
* src/numfmt.c: Use is_utf8_charset().
* src/system.h: Remove is_utf8_charset() definition.
2026-10-03 15:47:15 +01:00
Pádraig Brady 5ef76b9ac8 wc: fix handling of multi-byte chars spanning buffers
Commit v9.4-43-ga6064bb86 introduced this edge case
in handling multi-byte characters spanning the input buffer.

* src/wc.c (wc): Ensure we include the bytes previously read
but as yet unprocessed.
* tests/wc/mb-non-utf8.sh: Add a new test for miscounted GB118030 chars.
* tests/local.mk: Reference the new test.
* tests/wc/wc.pl: Add a new check for word count with a
UTF-8 space spanning a buffer boundary.
* NEWS: Mention the bug fix.
2026-10-03 15:47:15 +01:00
Collin Funk f46ebfaa41 maint: od: fix -Wformat when DEBUG is defined
* src/od.c (main): Use %td instead of %d when printing an idx_t using
printf.
2026-10-02 21:46:20 -07:00
Collin Funk 6f36b64689 tests: readlink: add tests for the symbolic link infinite loop
* tests/readlink/rl-1.sh: Add tests for the 'readlink' invocations that
would cause an infinite loop before commit b66f3e4e2 (realpath: fix an
infinite loop when resolving symbolic links, 2026-09-25). Also test the
behavior without an option, which would not cause the infinite loop.
2026-09-29 20:43:15 -07:00
Pádraig Brady 0bbf12284a doc: NEWS: mention readlink also had an infinite loop bug
* NEWS: Mention the readlink and realpath options
that trigger the infinite loop bug.
2026-09-29 20:35:50 -07:00
Collin Funk 40e0b385b7 tests: realpath: add some additional tests for symlink loops
* tests/misc/realpath.sh: Test the flags supported by 'realpath' that
would previously infinite loop before commit b66f3e4e2 (realpath: fix an
infinite loop when resolving symbolic links, 2026-09-25). Test an
invocation which would avoid the infinite loop by not touching the file.
2026-09-29 20:10:24 -07:00
Collin Funk c4b0996ee7 maint: join: use the COUNTED_BY attribute
* src/join.c (struct line): Use the COUNTED_BY attribute on the fields
member.
(struct seq): Use the COUNTED_BY attribute on the lines member.
(freeline): When setting a pointer using the COUNTED_BY attribute to
NULL, set its counter to zero.
2026-09-29 18:47:27 -07:00
Pádraig Brady d97b6827c7 cut: -f -w: optimize no delimiters in uni-byte locales
Increases throughput when no delimiters found by up to 15x.

  $ yes | head -n10M > sl.in

  $ time LC_ALL=C src/cut-before -f10 -w sl.in >/dev/null
  real	0m0.171s

  $ time LC_ALL=C src/cut-after -f10 -w sl.in >/dev/null
  real	0m0.011s

* src/cut.c (cut_fields_bytesearch): Also add a byte search
shortcut for the -w case in uni-byte locales.
2026-09-29 13:34:32 +01:00
Pádraig Brady 08236d3b9b cut: -f -w: optimize short fields in uni-byte locales
Avoiding calling memchr2() for fields less than 16 bytes,
results in a 40% performance boost.

  $ yes $(yes eeeaae | head -n9 | paste -s -d' ') | head -n1M > asw.in

  $ time LC_ALL=C src/cut-before -f10 -w asw.in >/dev/null
  real	0m0.254s

  $ time LC_ALL=C src/cut-after -f10 -w asw.in >/dev/null
  real	0m0.151s

* src/cut.c (find_c_blank): A wrapper around memchr2()
to avoid its significant setup cost.
2026-09-29 13:34:04 +01:00
Pádraig Brady f1101ce852 cut: -c: optimize ASCII and UTF-8 processing
These are the most common input encodings so worth optimizing for.

Performance was tested with GCC 16 on an i7-5600U with
CFLAGS='-march=native -O3 -flto' with the following setup:

$ yes | head -n10M > sl.in
$ yes $(yes eeeaae | head -n10K | paste -s -d' ') | head -n10K > llw.in
$ yes $(yes eeeaae | head -n9 | paste -s -d' ') | head -n1M > asw.in
$ yes $(yes éééááé | head -n9 | paste -s -d$'\xe2\x80\x83') |
   head -n1M > mbw.in

for type in sl llw asw mbw; do
  cat $type.in >/dev/null;
  for imp in '-before' '-after'; do
    echo ============ "${imp:-base}" $type ==============;
    for d in -c; do
      fields='-f1 -f10 -f100'
      test "$d" = "-c" && { fields='-c1 -c10 -c100000'; d=''; }
      for f in $fields; do
        for loc in C.UTF-8; do
          # Skip -b for UTF-8 as no different
          test "$loc" = C.UTF-8 && echo "$f" | grep -q -- -b \
           && continue
          # Skip multi-byte delimiter for C and not allowed
          test "$loc" = C && test $(echo -n "$d" | wc -c) -ge 4 \
           && continue
          bin=src/cut${imp}
          LC_ALL=$loc $bin $f $d /dev/null 2>/dev/null &&
          hyperfine --warmup=2 -m2 -M6 \
           "LC_ALL=$loc $bin $f $d $type.in >/dev/null" ||
          printf 'Benchmark 1: %s\n  unsupported\n\n' \
           "LC_ALL=$loc $bin $f $d $type.in >/dev/null"
        done;
      done;
    done;
  done;
done

After a little post-processing of the results, we get:

-- src/cut-before

| command         |       sl |      llw |      asw |      mbw |
| --------------- | -------- | -------- | -------- | -------- |
| UTF8 -c1        |  70.7 ms | 103.5 ms |  26.9 ms |  48.6 ms |
| UTF8 -c10       |  55.1 ms | 103.9 ms |  48.6 ms | 127.3 ms |
| UTF8 -c100000   |  54.7 ms |  1.585 s | 156.9 ms | 555.9 ms |

-- src/cut-after

| command         |       sl |      llw |      asw |      mbw |
| --------------- | -------- | -------- | -------- | -------- |
| UTF8 -c1        |  90.1 ms | 103.6 ms |  28.0 ms |  50.9 ms |
| UTF8 -c10       |  39.7 ms | 103.2 ms |  40.0 ms | 127.5 ms |
| UTF8 -c100000   |  39.0 ms | 104.4 ms |  18.5 ms |  30.3 ms |

* bootstrap.conf: Explicitly depend on unistr/u8-check.
* src/cut.c (cut_characters_mode): Quickly skip over unselected
ASCII/UTF-8 data.
* tests/cut/cut.pl: Add test cases.
2026-09-29 13:34:04 +01:00
Pádraig Brady 45cdd85366 cut: -c: optimize extracting the start of a line
Performance was tested with GCC 16 on an i7-5600U with
CFLAGS='-march=native -O3 -flto' with the following setup:

$ yes | head -n10M > sl.in
$ yes $(yes eeeaae | head -n10K | paste -s -d' ') | head -n10K > llw.in
$ yes $(yes eeeaae | head -n9 | paste -s -d' ') | head -n1M > asw.in
$ yes $(yes éééááé | head -n9 | paste -s -d$'\xe2\x80\x83') |
   head -n1M > mbw.in

for type in sl llw asw mbw; do
  cat $type.in >/dev/null;
  for imp in '-before' '-after'; do
    echo ============ "${imp:-base}" $type ==============;
    for d in -c; do
      fields='-f1 -f10 -f100'
      test "$d" = "-c" && { fields='-c1 -c10 -c100000'; d=''; }
      for f in $fields; do
        for loc in C.UTF-8; do
          # Skip -b for UTF-8 as no different
          test "$loc" = C.UTF-8 && echo "$f" | grep -q -- -b \
           && continue
          # Skip multi-byte delimiter for C and not allowed
          test "$loc" = C && test $(echo -n "$d" | wc -c) -ge 4 \
           && continue
          bin=src/cut${imp}
          LC_ALL=$loc $bin $f $d /dev/null 2>/dev/null &&
          hyperfine --warmup=2 -m2 -M6 \
           "LC_ALL=$loc $bin $f $d $type.in >/dev/null" ||
          printf 'Benchmark 1: %s\n  unsupported\n\n' \
           "LC_ALL=$loc $bin $f $d $type.in >/dev/null"
        done;
      done;
    done;
  done;
done

After a little post-processing of the results, we get:

-- src/cut-before

| command       |       sl |      llw |      asw |      mbw |
| ------------- | -------- | -------- | -------- | -------- |
| UTF8 -c1      |  60.7 ms |  1.244 s | 123.5 ms | 515.2 ms |
| UTF8 -c10     |  39.3 ms |  1.248 s | 127.4 ms | 526.0 ms |
| UTF8 -c100000 |  39.4 ms |  1.242 s | 121.4 ms | 514.3 ms |

-- src/cut-after

| command       |       sl |      llw |      asw |      mbw |
| ------------- | -------- | -------- | -------- | -------- |
| UTF8 -c1      |  70.9 ms | 105.5 ms |  27.0 ms |  47.6 ms |
| UTF8 -c10     |  55.7 ms | 105.7 ms |  48.2 ms | 126.8 ms |
| UTF8 -c100000 |  55.2 ms |  1.596 s | 158.8 ms | 555.1 ms |

* src/cut.c (cut_characters_mode): Shortcut the line delimiter
search if finished processing characters.
* tests/cut/cut.pl: Add a test case.
2026-09-29 13:34:00 +01:00
Iván Ezequiel Rodriguez 0e8455a8e2 maint: drop stale chmod/printf TODO items and clarify ls
* TODO: Remove chmod ctime and printf %a entries.
Replace ls --format with ls --printf.
2026-09-28 21:29:16 -07:00