]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
10 days agonumfmt: ensure fields don't split on nbsp
Pádraig Brady [Tue, 28 Oct 2025 12:18:47 +0000 (12:18 +0000)] 
numfmt: ensure fields don't split on nbsp

* src/numfmt.c (newline_or_blank): Explicitly ensure
we don't match NBSP as on platforms like NetBSD 10 or Solaris 11,
NBSP is considered a blank character.
This should have been part of commit v9.8-39-g8bc11f80a
Solaris 11 test failure reported by Bruno Haible.

10 days agomaint: prefer FTS_ROOTLEVEL when checking the fts_level of an FTSENT
Collin Funk [Mon, 27 Oct 2025 00:00:03 +0000 (17:00 -0700)] 
maint: prefer FTS_ROOTLEVEL when checking the fts_level of an FTSENT

* src/chcon.c (process_file): Use FTS_ROOTLEVEL instead of 0.
* src/chmod.c (process_file): Likewise.
* src/chown-core.c (change_file_owner): Likewise.

10 days agotimeout: use the more efficient posix_spawn to invoke the command
Collin Funk [Sun, 26 Oct 2025 22:33:24 +0000 (15:33 -0700)] 
timeout: use the more efficient posix_spawn to invoke the command

* NEWS: Mention the improvement. Consolidate the posix_spawn
improvements into one item.
* bootstrap.conf (gnulib_modules): Add posix_spawnattr_setsigmask.
* src/timeout.c: Include spawn.h.
(main): Setup signals using a posix_spawnattr_t object. Use posix_spawn
instead of fork and execvp.

10 days agomaint: prefer ckd_add for overflow checks
Collin Funk [Sun, 26 Oct 2025 19:20:01 +0000 (12:20 -0700)] 
maint: prefer ckd_add for overflow checks

* src/cksum.c (cksum_slice8, crc32b_sum_stream): Use ckd_add to check
for overflow.
* src/cksum_avx2.c (cksum_avx2): Likewise.
* src/cksum_avx512.c (cksum_avx512): Likewise.
* src/cksum_pclmul.c (cksum_pclmul): Likewise.
* src/cksum_vmull.c (cksum_vmull): Likewise.

11 days agobuild: don't build chcon or runcon unless selinux is available
Pádraig Brady [Sun, 26 Oct 2025 12:33:42 +0000 (12:33 +0000)] 
build: don't build chcon or runcon unless selinux is available

The build can be force enabled with --with-selinux and vice versa.

* build-aux/gen-lists-of-programs.sh: Move chcon and runcon
to the list of optional programs.
* configure.ac: Only enable chcon and runcon if selinux.h is available.
* NEWS: Mention the Build-related change.
Fixes https://github.com/coreutils/coreutils/issues/121

12 days agosort: use the more efficient posix_spawn to invoke --compress-program
Collin Funk [Fri, 24 Oct 2025 04:27:53 +0000 (21:27 -0700)] 
sort: use the more efficient posix_spawn to invoke --compress-program

* NEWS: Mention the improvement. Mention that 'sort' will continue
without compressing temporary files if the program specified by
--compress-program cannot be executed.
* doc/coreutils.texi (sort invocation): Document the behavior when the
program specified by --compress-program cannot be executed.
* src/sort.c: Include spawn.h.
(MAX_FORK_TRIES_COMPRESS, MAX_FORK_TRIES_DECOMPRESS): Remove definition.
(MAX_TRIES_COMPRESS, MAX_TRIES_DECOMPRESS): New definitions based on
MAX_FORK_TRIES_COMPRESS and MAX_FORK_TRIES_DECOMPRESS.
(async_safe_die): Remove function.
(posix_spawn_file_actions_move_fd): New function.
(pipe_fork): Remove function.
(pipe_child): New function based on pipe_fork. Return an error number
instead of a pid. Use posix_spawnp instead of calling fork and expecting
the caller to exec.
(maybe_create_temp): Call pipe_child instead of pipe_fork. Print a
warning to standard error if --compress-program cannot be executed and
the error is different than the previous call. Remove code for the child
process.
(open_temp): Remove code for the child process. Improve error message.
* tests/sort/sort-compress.sh: Add a test case for when the program
specified by --compress-program does not exist.

2 weeks agomaint: remove unnecessary ignore_value usage
Collin Funk [Thu, 23 Oct 2025 21:40:39 +0000 (14:40 -0700)] 
maint: remove unnecessary ignore_value usage

* src/install.c: Remove ignore-value.h include.
(strip): Don't use ignore_value on posix_spawnattr_destroy since it
isn't declared with the warn_unused_result attribute. Pass the checked
pointer to posix_spawnattr_destroy instead of the variable it points to.

2 weeks agoinstall: enhance error diagnostic when running strip fails
Bernhard Voelker [Thu, 23 Oct 2025 07:33:22 +0000 (09:33 +0200)] 
install: enhance error diagnostic when running strip fails

* src/install.c (strip): Mention explicitly that the strip program
failed in the case the user specified a custom strip program name.

2 weeks agosplit: cleanup after posix_spawn
Collin Funk [Thu, 23 Oct 2025 19:35:37 +0000 (12:35 -0700)] 
split: cleanup after posix_spawn

* boostrap.conf (gnulib_modules): Add posix_spawn_file_actions_destroy.
* src/split.c (cleanup): Call posix_spawnattr_destroy and
posix_spawn_file_actions_destroy after a successful posix_spawn.

2 weeks agosplit: prefer posix_spawn to fork and execl
Collin Funk [Thu, 23 Oct 2025 08:11:50 +0000 (01:11 -0700)] 
split: prefer posix_spawn to fork and execl

* NEWS: Mention the change.
* bootstrap.conf (gnulib_modules): Add posix_spawn,
posix_spawnattr_setsigdefault, posix_spawn_file_actions_addclose,
posix_spawn_file_actions_adddup2, and posix_spawn_file_actions_init.
* src/split.c: Include spawn.h.
(create): Use posix_spawn instead of fork and execl.

2 weeks agotests: date: test --resolution and %-N
Pádraig Brady [Thu, 23 Oct 2025 15:44:14 +0000 (16:44 +0100)] 
tests: date: test --resolution and %-N

* tests/date/resolution.sh: New test for --resolution and %-N.
* tests/local.mk: Reference the new test.

2 weeks agotests: date: test --reference
Pádraig Brady [Thu, 23 Oct 2025 14:25:14 +0000 (15:25 +0100)] 
tests: date: test --reference

* tests/date/reference.sh: Ensure the -r option is tested.
* tests/local.mk: Add the test.

2 weeks agopr: promptly diagnose write errors
Pádraig Brady [Wed, 22 Oct 2025 17:13:48 +0000 (18:13 +0100)] 
pr: promptly diagnose write errors

* src/pr.c (print_page): Exit promptly for `yes | pr`.
(print_clump): Exit promptly for `pr < /dev/zero`.
* tests/misc/write-errors.sh: Enable test cases.
* NEWS: Mention the improvement.

2 weeks agonl: promptly diagnose write errors
Pádraig Brady [Wed, 22 Oct 2025 15:31:15 +0000 (16:31 +0100)] 
nl: promptly diagnose write errors

* NEWS: Mention the improvement.
* src/nl.c (process_file): Exit if error outputting line.
* tests/misc/write-errors.sh: Enable the test case.

2 weeks agofmt: promptly diagnose write errors
Pádraig Brady [Wed, 22 Oct 2025 15:11:53 +0000 (16:11 +0100)] 
fmt: promptly diagnose write errors

* NEWS: Mention the improvement.
* src/fmt.c (put_line): Exit if any error writing line.
(flush_paragraph): Exit if any error writing buffer.
* tests/misc/write-errors.sh: Enable the (flush_paragraph) test case,
and add another to check the put_line() case.

2 weeks agonumfmt: promptly diagnose write errors
Pádraig Brady [Wed, 22 Oct 2025 12:53:46 +0000 (13:53 +0100)] 
numfmt: promptly diagnose write errors

* src/numfmt.c (process line): Inspect the stdio error state when
outputting each line so that we don't have to check each output function
but do eventually exit upon write error, while also remaining buffered.
(main): Also check when outputting a header for the edge case
of very long headers.
* tests/misc/write-errors.sh: Enable the numfmt test case.
* NEWS: Mention the improvement, and reorganize all numfmt improvements.

2 weeks agoinstall: prefer posix_spawnp to fork and execlp
Collin Funk [Sun, 19 Oct 2025 22:22:17 +0000 (15:22 -0700)] 
install: prefer posix_spawnp to fork and execlp

* NEWS: Mention the change.
* bootstrap.conf (gnulib_modules): Add posix_spawnattr_destroy,
posix_spawnattr_init, posix_spawnattr_setflags, and posix_spawnp.
* src/install.c (strip): Use posix_spawnp instead of fork and execlp.

2 weeks agomaint: remove a redundant write after mcel_scan returns an error
Collin Funk [Sun, 19 Oct 2025 03:24:21 +0000 (20:24 -0700)] 
maint: remove a redundant write after mcel_scan returns an error

* gl/lib/mbbuf.h (mbbuf_get_char): Don't set G.len to 1, since mcel_err
has already done it.

2 weeks agotests: numfmt: add non-utf8 multi-byte test
Pádraig Brady [Mon, 20 Oct 2025 11:53:13 +0000 (12:53 +0100)] 
tests: numfmt: add non-utf8 multi-byte test

* tests/numfmt/mb-non-utf8.sh: Test GB18030 delimiter search.
* tests/local.mk: Reference the new test, and move
the existing numfmt.pl test from tests/misc to tests/numfmt.

2 weeks agonumfmt: optimize multi-byte --delimiter search
Pádraig Brady [Sun, 19 Oct 2025 12:11:46 +0000 (13:11 +0100)] 
numfmt: optimize multi-byte --delimiter search

* src/numfmt.c (is_utf8_charset): A new function to efficiently
determine if running with a UTF-8 charset.
(mbsmbchr): A new function to efficiently search for
a (multi-byte) character in a multi-byte string.
(next-field): Use mbsmbchr() rather than mbstr() directly.

2 weeks agonumfmt: support multi-byte --delimiter
Pádraig Brady [Sat, 18 Oct 2025 16:44:49 +0000 (17:44 +0100)] 
numfmt: support multi-byte --delimiter

* bootstrap.conf: Depend on mbsstr() to robustly search for a
multi-byte delimiter character (string) within a multi-byte string.
* src/numfmt.c (main): Accept a valid multi-byte delimiter character.
(next_field): Adjust delimiter search from single byte
to multi-byte aware.  Use mbsstr to find the first match.
* tests/misc/numfmt.pl: Add test case.
* NEWS: Mention the improvement.

2 weeks agonumfmt: use multi-byte aware suffix matching
Pádraig Brady [Sat, 18 Oct 2025 12:02:44 +0000 (13:02 +0100)] 
numfmt: use multi-byte aware suffix matching

* src/numfmt.c (process_suffixed_number): Use gnulib's
mbs_endswith() helper, which is more robust in non UTF-8 locales.
Also always output a devmsg if a suffix is specified.

2 weeks agonumfmt: fix issues with multi-byte blanks
Pádraig Brady [Fri, 17 Oct 2025 18:14:21 +0000 (19:14 +0100)] 
numfmt: fix issues with multi-byte blanks

* src/numfmt.c (process_line): Restore byte overwritten with NUL,
as it may be part of a multi-byte blank.
(process_suffixed_number): Skip multi-byte blanks,
and correctly determine width with mbswidth().
(parse_format_string): Use c_isblank() to explicitly
indicate that's all the format spec supports.
* tests/misc/numfmt.pl: Add test cases.
* NEWS: Mention the bug fix.

2 weeks agonumfmt: add --unit-separator
Pádraig Brady [Thu, 9 Oct 2025 13:24:12 +0000 (14:24 +0100)] 
numfmt: add --unit-separator

Output, accept, or disallow a string between the number and unit
as recommended in <https://physics.nist.gov/cuu/Units/checklist.html>
I.e. support outputting numbers of the form: "1234 M"

* src/numfmt.c (simple_strtod_human): Skip unit separator if present,
or disallow a unit separator if empty.
(double_to_human): Output unit separator if specified.
(main): Accept --unit-separator.
* tests/misc/numfmt.pl: Add test cases.
* doc/coreutils.texi: Describe the new option,
giving examples of interaction with --delimiter.
* NEWS: Mention the new feature.
* THANKS.in: Add Johannes Schauer Marin Rodrigues,
who provided a preliminary patch.

3 weeks agonumfmt: support reading numbers with grouping characters
Pádraig Brady [Tue, 14 Oct 2025 20:06:03 +0000 (21:06 +0100)] 
numfmt: support reading numbers with grouping characters

This does not validate grouping character placement,
and currently just ignores grouping characters.

* src/numfmt.c (simple_strtod_int): Skip grouping chars
that are part of a number.
* tests/misc/numfmt.pl: Add test cases.
* NEWS: Mention the improvement.

3 weeks agonumfmt: support reading numbers with NBSP before unit
Pádraig Brady [Tue, 14 Oct 2025 15:17:56 +0000 (16:17 +0100)] 
numfmt: support reading numbers with NBSP before unit

* src/numfmt.c (simple_strtod_human): Accept (multi-byte)
non-breaking space character between number and unit.
Note we restrict this to a single character between number
and unit, to allow less ambiguous parsing if multiple blanks
are used to delimit fields.
* tests/misc/numfmt.pl: Add test cases.
* doc/coreutils.texi (numfmt invocation): Fix stale description
--delimiter skipping whitespace.
* NEWS: Mention the improvement.

3 weeks agotests: du/bigtime: try harder to find a suitable filesystem
Nicolas Boichat [Sat, 26 Jul 2025 06:58:33 +0000 (14:58 +0800)] 
tests: du/bigtime: try harder to find a suitable filesystem

* tests/du/bigtime.sh: At least on Linux, the ext4 filesystem
doesn't support such large timestamp, while tmpfs does.  Try a bit
harder to look for a filesystem with large timestamp support.

3 weeks agotests: date: check that the hour format of the current locale is used
Collin Funk [Sun, 12 Oct 2025 04:55:31 +0000 (21:55 -0700)] 
tests: date: check that the hour format of the current locale is used

* tests/date/date-locale-hour.sh: New file.
* tests/local.mk (all_tests): Add the new test.

Co-authored-by: Pádraig Brady <P@draigBrady.com>
3 weeks agotests: fix false failure in recent memory limit test
Pádraig Brady [Mon, 13 Oct 2025 12:22:38 +0000 (13:22 +0100)] 
tests: fix false failure in recent memory limit test

* tests/basenc/bounded-memory.sh: Ensure we skip the test
upon failure to determine the memory lower bound.
Reported by Bruno Haible.

3 weeks agonumfmt: fix buffer over-read (CWE-126)
Pádraig Brady [Sat, 11 Oct 2025 11:19:34 +0000 (12:19 +0100)] 
numfmt: fix buffer over-read (CWE-126)

* src/numfmt.c (simple_strtod_human): Check for NULL after pointer
adjustment to avoid Out-of-range pointer offset (CWE-823).
* NEWS: Mention the fix.

3 weeks agotests: basenc: use less redundant naming
Pádraig Brady [Sat, 11 Oct 2025 10:25:27 +0000 (11:25 +0100)] 
tests: basenc: use less redundant naming

Rename to less redundant names, now that we use
a separate test directory per util.

* tests/basenc/basenc-bounded-memory.sh -> .../bounded-memory.sh
* tests/basenc/basenc-large.sh -> .../large-input.sh
* tests/local.mk: Reference new names.

3 weeks agotests: fix memory limit determination in new test
Pádraig Brady [Sat, 11 Oct 2025 10:21:38 +0000 (11:21 +0100)] 
tests: fix memory limit determination in new test

* tests/basenc/basenc-bounded-memory.sh: The passed command
needs to succeed for memory limit determination to work.

3 weeks agotests: basenc: add a test for bounded memory operation
Collin Funk [Sat, 11 Oct 2025 04:13:55 +0000 (21:13 -0700)] 
tests: basenc: add a test for bounded memory operation

* tests/basenc/basenc-bounded-memory.sh: New file.
* tests/local.mk (all_tests): Add the test.

4 weeks agotests: ln -f: ensure existing link replaced
Sylvestre Ledru [Fri, 10 Oct 2025 11:38:33 +0000 (13:38 +0200)] 
tests: ln -f: ensure existing link replaced

Identified here:
<https://github.com/uutils/coreutils/issues/8830>

* tests/ln/misc.sh: Add the check.

4 weeks agotests: cksum: add a test case for robust file name parsing
Pádraig Brady [Tue, 7 Oct 2025 14:24:12 +0000 (15:24 +0100)] 
tests: cksum: add a test case for robust file name parsing

* tests/cksum/cksum-c.sh: Add a test case where the file name
contains tagged format delimiter characters.

4 weeks agomaint: cksum: document a base64/hex parsing ambiguity with untagged
Pádraig Brady [Tue, 7 Oct 2025 13:38:49 +0000 (14:38 +0100)] 
maint: cksum: document a base64/hex parsing ambiguity with untagged

* src/digest.c (split_3): Mention the ambiguity in misinterpreting
base64 characters as hex is not a practical consideration.
Also add an example of both tagged formats which makes it
easier to interpret the parsing logic.

4 weeks agocksum: fix --check with untagged base64 format with tag matches
Pádraig Brady [Mon, 6 Oct 2025 18:41:24 +0000 (19:41 +0100)] 
cksum: fix --check with untagged base64 format with tag matches

* src/digest.c (split_3): Fallback to untagged matching in the
case where -a is specified and we have matched a TAG in
the possibly base64 data.  This might happen in 1 in every 64K files.
Note we remove the modification of string S (and redundant streq) in
the tag matching, as that was not needed since v8.32-223-g217cd278e.
* tests/cksum/cksum-c.sh: Add a test case.
* NEWS: Mention the bug fix.

4 weeks agocksum: fix length validation with SHA2- tagged format
Pádraig Brady [Mon, 6 Oct 2025 15:32:26 +0000 (16:32 +0100)] 
cksum: fix length validation with SHA2- tagged format

* src/digest.c (sha2_sum_stream): Change from unreachable()
to affirm() so that we have defined behavior unless
we configure with --disable-assert.
(sha3_sum_stream): Likewise.
(split_3): Validate SHA2-lengths before passing on.
* tests/cksum/cksum-c.sh: Add a test case.
* NEWS: Mention the bug fix.

4 weeks agocksum: fix --check with --algorithm=sha2
Pádraig Brady [Mon, 6 Oct 2025 12:23:55 +0000 (13:23 +0100)] 
cksum: fix --check with --algorithm=sha2

* src/digest.c (split_3): Look up the provided tag with -a sha2
because there is not a 1:1 mapping between them.
* tests/cksum/cksum-c.sh: Add a test case.
* NEWS: Mention the bug fix.

4 weeks agorm: remove redundant mark_ancestor_dirs call
Paul Eggert [Mon, 6 Oct 2025 20:36:40 +0000 (13:36 -0700)] 
rm: remove redundant mark_ancestor_dirs call

* src/remove.c (rm_fts): Remove unnecessary call.  Since this code
is executed only when not recursive, there are no ancestors to mark.

4 weeks agorm: make ‘rm -d DIR’ more like ‘rmdir DIR’
Paul Eggert [Mon, 6 Oct 2025 20:31:48 +0000 (13:31 -0700)] 
rm: make ‘rm -d DIR’ more like ‘rmdir DIR’

* src/remove.c (rm_fts): When not recursive,
arrange for ‘rm -d DIR’ to behave more like ‘rmdir DIR’.
This works better for Ceph snapshot directories.
Problem reported by Yannick Le Pennec (bug#78245).

4 weeks agocksum: allow -a {blake2b,sha2,sha3} --check to work on base64
Collin Funk [Sun, 5 Oct 2025 00:18:01 +0000 (17:18 -0700)] 
cksum: allow -a {blake2b,sha2,sha3} --check to work on base64

* NEWS: Mention the bug.
* src/digest.c (split_3): Check that the base64 digest matches the
length supported by the algorithm.
(digest_check): Check that the read digest matches the base64 length of
the algorithm's digest. The previous condition would not work for
'cksum -a blake2b -l 8 ...'.
* tests/cksum/cksum-base64-untagged.sh: New file.
* tests/local.mk (all_tests): Add the new test.

4 weeks agomaint: omit trailing white space in config.h
Paul Eggert [Sat, 4 Oct 2025 00:04:01 +0000 (17:04 -0700)] 
maint: omit trailing white space in config.h

* configure.ac (FORTIFY_SOURCE): Don’t indent a line
where the indentation can cause trailing white space in config.h.
Problem reported by Grisha Levit (Bug#79567).

4 weeks agomaint: remove IRIX support
Collin Funk [Fri, 3 Oct 2025 02:15:34 +0000 (19:15 -0700)] 
maint: remove IRIX support

* src/ptx.c (main) [HAVE_SETCHRCLASS]: Remove call to setchrclass.
* src/stty.c (VREPRINT) [!VREPRINT && VRPRNT]: Remove definition.

5 weeks agotests: factor: add suggested large prime tests
Pádraig Brady [Thu, 2 Oct 2025 16:20:39 +0000 (17:20 +0100)] 
tests: factor: add suggested large prime tests

* tests/factor/create-test.sh: Add 2 new large primes from:
https://github.com/coreutils/coreutils/issues/65
* tests/local.mk: Reference the 2 new generated tests.

5 weeks agounexpand: fix heap buffer overflow with --tabs=[+/]NUM
Pádraig Brady [Thu, 2 Oct 2025 11:24:20 +0000 (12:24 +0100)] 
unexpand: fix heap buffer overflow with --tabs=[+/]NUM

This avoids CWE-122: Heap-based Buffer Overflow
where we could write blank characters beyond
the allocated heap buffer.

* src/expand-common.c (set_max_column_width): Refactor function from ...
(add_tab_stop): ... here.
(set_extend_size): Call new function.
(set_increment_size): Likewise.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/79555

5 weeks agodoc: man: consistently format -X[OPTIONAL] form
Pádraig Brady [Wed, 1 Oct 2025 20:20:20 +0000 (21:20 +0100)] 
doc: man: consistently format -X[OPTIONAL] form

This is significant for the date, od, and pr commands
which have options of the form -X[OPTIONAL], which change like:

  diff -r man.orig/date.1 man/date.1
  < \fB\-I[FMT]\fR, \fB\-\-iso\-8601\fR[=\fI\,FMT\/\fR]
  > \fB\-I\fR[\fI\,FMT\/\fR], \fB\-\-iso\-8601\fR[=\fI\,FMT\/\fR]

  diff -r man.orig/od.1 man/od.1
  < \fB\-w[BYTES]\fR, \fB\-\-width\fR[=\fI\,BYTES\/\fR]
  > \fB\-w\fR[\fI\,BYTES\/\fR], \fB\-\-width\fR[=\fI\,BYTES\/\fR]

* man/help2man (convert_options): Support options of the form
-X[PARAM], so that we now consistently format them (in italics).

5 weeks agodoc: man: consistently italicize --option parameters
Pádraig Brady [Wed, 1 Oct 2025 17:38:21 +0000 (18:38 +0100)] 
doc: man: consistently italicize --option parameters

This changes a few pages, but the changes in tail.1
concisely illustrate the resulting man page changes:

  $ diff -r man.orig/tail.1 man/tail.1
  < \fB\-c\fR, \fB\-\-bytes\fR=\fI\,[\/\fR+]NUM
  > \fB\-c\fR, \fB\-\-bytes\fR=\fI\,[+]NUM\/\fR

  < \fB\-f\fR, \fB\-\-follow[=\fR{name|descriptor}]
  > \fB\-f\fR, \fB\-\-follow\fR[=\fI\,{name|descriptor}\/\fR]

  < \fB\-n\fR, \fB\-\-lines\fR=\fI\,[\/\fR+]NUM
  > \fB\-n\fR, \fB\-\-lines\fR=\fI\,[+]NUM\/\fR

* man/help2man: Relax the option match so more --option
variations are supported, and passed through to convert_option().
Specifically more variations after '=' are now supported.
Also split and document the regular expression.
Reported at https://github.com/coreutils/coreutils/issues/84

5 weeks agomaint: prefer unreachable () to NOTREACHED comment
Collin Funk [Thu, 2 Oct 2025 06:44:18 +0000 (23:44 -0700)] 
maint: prefer unreachable () to NOTREACHED comment

* src/tsort.c (search_item): Use unreachable () instead of NOTREACHED.

5 weeks agofold: move multi-byte character reading to a module
Collin Funk [Mon, 29 Sep 2025 03:16:26 +0000 (20:16 -0700)] 
fold: move multi-byte character reading to a module

* gl/modules/mbbuf: New file.
* gl/lib/mbbuf.c: Likewise.
* gl/lib/mbbuf.h: Likewise.
* gl/local.mk (EXTRA_DIST): Add the new files.
* bootstrap.conf (gnulib_modules): Add mbbuf.
* src/fold.c: Include mbbuf.h.
(fold_file): Use the mbbuf functions instead of calling fread and
handling the input buffer ourselves.
* cfg.mk (exclude_file_name_regexp--sc_preprocessor_indentation)
(exclude_file_name_regexp--sc_GPL_version): Match gl/lib/mbbuf.c and
gl/lib/mbbuf.h.

5 weeks agowc: add AVX512 function for line counting
Mathieu Bordere [Wed, 24 Sep 2025 10:41:06 +0000 (12:41 +0200)] 
wc: add AVX512 function for line counting

* configure.ac: Add detection of AVX512 intrinsics for wc.
* src/local.mk: Build AVX512 wc libraries.
* src/wc.c: Add runtime detection of AVX512 intrinsics and call
appropriate function when detected.
* src/wc.h (wc_lines_avx512): Declare function.
* tests/wc/wc-cpu.sh: Add a test that disables AVX512 intrinsics.
* src/wc_avx512.c: New file containing the wc -l implementation using
AVX512. The logic and code is reused from the AVX2 implementation with
slight adaptations. Replaced __builtin_popcount by __builtin_popcountll
and the combination of _mm256_cmpeq_epi8 and _mm256_movemask_epi8 by a
single call to _mm512_cmpeq_epi8_mask.
* NEWS: Mention the improvement.

5 weeks agomaint: update valgrind instructions
Pádraig Brady [Sat, 27 Sep 2025 16:44:48 +0000 (17:44 +0100)] 
maint: update valgrind instructions

* README-valgrind: Adjust to current repo structure,
and give clearer step by step instructions.

5 weeks agomaint: convert some overflow checks to ckd_add and ckd_mul
Collin Funk [Sat, 27 Sep 2025 21:34:44 +0000 (14:34 -0700)] 
maint: convert some overflow checks to ckd_add and ckd_mul

* src/csplit.c (parse_repeat_count): Prefer ckd_add when checking for
overflows.
* src/install.c (get_ids): Likewise.
* src/shred.c (dopass): Likewise.
* src/tr.c (get_spec_stats): Likewise.
* src/sort.c (specify_sort_size): Prefer ckd_mul when checking for
overflows.

5 weeks agotests: test: ensure file operations are covered
Pádraig Brady [Fri, 26 Sep 2025 15:16:20 +0000 (16:16 +0100)] 
tests: test: ensure file operations are covered

A coverage report indicated these weren't tested
(as generally the test shell builtin is used).

* tests/test/test-file.sh: Add a new test.
* tests/local.mk: Reference the new test.

6 weeks agojoin: remove unused #include "argmatch.h"
Bernhard Voelker [Thu, 25 Sep 2025 20:50:01 +0000 (22:50 +0200)] 
join: remove unused #include "argmatch.h"

Prompted by the syntax-check failure:
  maint.mk: the above files include argmatch.h but don't use it
  make: *** [maint.mk:741: sc_prohibit_argmatch_without_use] Error 1

* src/join.c: Remove include, as the previous commit changed from using
ARRAY_CARDINALITY to countof - for which system.h includes the header.

6 weeks agomaint: prefer countof over ARRAY_CARDINALITY
Collin Funk [Wed, 24 Sep 2025 02:17:14 +0000 (19:17 -0700)] 
maint: prefer countof over ARRAY_CARDINALITY

* bootstrap.conf (gnulib_modules): Add stdcountof-h.
* src/system.h: Include stdcountof.h.
(ARRAY_CARDINALITY): Remove definition.
* .gitignore (/lib/stdcountof.h): Ignore Gnulib generated file.
* src/csplit.c: Use countof instead of ARRAY_CARDINALITY.
* src/df.c: Likewise.
* src/digest.c: Likewise.
* src/dircolors.c: Likewise.
* src/factor.c: Likewise.
* src/join.c: Likewise.
* src/ls.c: Likewise.
* src/od.c: Likewise.
* src/sort.c: Likewise.
* src/stdbuf.c: Likewise.
* src/tr.c: Likewise.

6 weeks agotail: fix tailing larger number of lines in regular files
Hannes Braun [Wed, 24 Sep 2025 19:20:49 +0000 (21:20 +0200)] 
tail: fix tailing larger number of lines in regular files

* src/tail.c (file_lines): Seek to the previous block instead of the
beginning (or a little before) of the block that was just scanned.
Otherwise, the same block is read and scanned (at least partially)
again. This bug was introduced by commit v9.7-219-g976f8abc1.
* tests/tail/basic-seek.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: mention the bug fix.

6 weeks agotests: wc: fix hardware acceleration disabling test
Pádraig Brady [Wed, 24 Sep 2025 14:52:36 +0000 (15:52 +0100)] 
tests: wc: fix hardware acceleration disabling test

* tests/wc/wc-cpu.sh: The message is only printed with wc -l.
Reported by Mathieu Borderé.

6 weeks agobuild: copy: add dependency on $(LIB_SMACK)
Pádraig Brady [Wed, 24 Sep 2025 10:18:52 +0000 (11:18 +0100)] 
build: copy: add dependency on $(LIB_SMACK)

* src/local.mk: Due to gnulib adjustments, this explicit
dependency is required with the mold linker at least.
Reported at https://github.com/coreutils/coreutils/issues/113

6 weeks agobasenc: --base58: fix buffer overflow with input > 15MB
Pádraig Brady [Tue, 23 Sep 2025 14:38:51 +0000 (15:38 +0100)] 
basenc: --base58: fix buffer overflow with input > 15MB

base58_length() operated naively on an int
which resulted in an overflow to a negative number
for any input > 2^31-1/138, i.e. 15,561,475 bytes.

* src/basenc.c (base_length): Change input and output
parameter types from int to idx_t since this needs to
cater for the full input size in the base58 case.
(base58_length): Likewise.  Also reorder the calculation
to be less exact, but doing the division first
to minimize the chance of overflow (which now on 64 bit
would only happen for inputs > around 6 Exa bytes).
* tests/basenc/basenc-large.sh: Add a new test,
that triggers with valgrind or ASAN.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.

6 weeks agodoc: document gl_cv_crc_pclmul to control hardware acceleration
Pádraig Brady [Mon, 22 Sep 2025 19:51:49 +0000 (20:51 +0100)] 
doc: document gl_cv_crc_pclmul to control hardware acceleration

doc/coreutils.texi (Harware acceleration configuration):
Sort the list and add "gl_cv_crc_pclmul".

6 weeks agobuild: fix build failure with mismatched pclmul
Pádraig Brady [Mon, 22 Sep 2025 19:46:33 +0000 (20:46 +0100)] 
build: fix build failure with mismatched pclmul

* src/cksum.c (pclmul_supported): In the case where
gnulib has pclmul enabled but coreutils does not,
ensure we don't reference the coreutils pclmul function.
Addresses https://bugs.gnu.org/79491

6 weeks agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 23 Sep 2025 00:43:14 +0000 (17:43 -0700)] 
build: update gnulib submodule to latest

6 weeks agomaint: post-release administrivia
Pádraig Brady [Mon, 22 Sep 2025 17:23:31 +0000 (18:23 +0100)] 
maint: post-release administrivia

* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.

6 weeks agoversion 9.8 v9.8
Pádraig Brady [Mon, 22 Sep 2025 16:50:52 +0000 (17:50 +0100)] 
version 9.8

* NEWS: Record release date.

6 weeks agobuild: update gnulib to latest
Pádraig Brady [Mon, 22 Sep 2025 13:02:23 +0000 (14:02 +0100)] 
build: update gnulib to latest

* gnulib: Update to latest to pull Android build fixes,
and fchownat fixes.

6 weeks agotests: ls: avoid alignment check with non printable characters
Pádraig Brady [Sun, 21 Sep 2025 23:18:28 +0000 (00:18 +0100)] 
tests: ls: avoid alignment check with non printable characters

* tests/ls/block-size.sh: Skip the case where there are
non-printable characters in ls' output, which is the case
with NBSP thousands separators on FreeBSD 11 and 12.
We may drop the MBSW_REJECT_UNPRINTABLE in future from
ls and numfmt, but for now avoid these characters in the test.
Reported by Bruno Haible.

6 weeks agotests: du: avoid false failure in racy test
Pádraig Brady [Sun, 21 Sep 2025 19:14:10 +0000 (20:14 +0100)] 
tests: du: avoid false failure in racy test

* tests/du/move-dir-while-traversing.sh: Expand the work to avoid
a false failure where du completes before the directory is moved.
Also expand the timeout to our more standard 10s to avoid the
"directory mover" being killed before du processes the directory.
This doesn't perceptibly impact the run time of the test.
Reported by Bruno Haible on a CentOS 7 system.

6 weeks agobuild: revert gnulib update
Pádraig Brady [Sun, 21 Sep 2025 23:06:03 +0000 (00:06 +0100)] 
build: revert gnulib update

There is a pending issue with fchownat:
https://lists.gnu.org/r/bug-gnulib/2025-09/msg00282.html

6 weeks agobuild: update gnulib submodule to latest
Collin Funk [Sun, 21 Sep 2025 22:14:12 +0000 (15:14 -0700)] 
build: update gnulib submodule to latest

6 weeks agobuild: fix missing declarations on Android
Collin Funk [Sun, 21 Sep 2025 20:40:18 +0000 (13:40 -0700)] 
build: fix missing declarations on Android

* configure.ac: Check for statx using gl_CHECK_FUNCS_ANDROID since it is
hidden for Android API level <= 30.
* m4/jm-macros.m4 (coreutils_MACROS): Check for syncfs using
gl_CHECK_FUNCS_ANDROID since it is hidden for Android API level <= 28.

6 weeks agomaint: comment spelling fixes
Paul Eggert [Sun, 21 Sep 2025 18:30:40 +0000 (11:30 -0700)] 
maint: comment spelling fixes

6 weeks agotests: fix OMP_NUM_THREADS misspelling
Paul Eggert [Sun, 21 Sep 2025 18:30:12 +0000 (11:30 -0700)] 
tests: fix OMP_NUM_THREADS misspelling

* tests/nproc/nproc-quota.sh: Fix misspelling.

6 weeks agomaint: update bootstrap from Gnulib
Paul Eggert [Sun, 21 Sep 2025 16:47:03 +0000 (09:47 -0700)] 
maint: update bootstrap from Gnulib

6 weeks agotests: avoid false failure on older Linux kernels
Pádraig Brady [Sun, 21 Sep 2025 15:37:26 +0000 (16:37 +0100)] 
tests: avoid false failure on older Linux kernels

* tests/fold/fold-zero-width.sh: Check the shell was able to create
the redirection file, as intermittently on CentOS 5,6,7 this wasn't
the case, with the shell giving an xmalloc failure due to the ulimit.
Reported by William Bader and Bruno Haible.

6 weeks agotests: tail: avoid false failure with overlayfs
Pádraig Brady [Sun, 21 Sep 2025 12:45:54 +0000 (13:45 +0100)] 
tests: tail: avoid false failure with overlayfs

* tests/tail/inotify-dir-recreate.sh: Add an extra check
that inotify is in use, as it's required for this test.
Inotify is avoided with overlayfs for which the
df --local check is not sufficient exclusion for.

6 weeks agotests: fold: avoid false failures on Solaris 10
Pádraig Brady [Sat, 20 Sep 2025 16:10:30 +0000 (17:10 +0100)] 
tests: fold: avoid false failures on Solaris 10

* tests/fold/fold-characters.sh: Ensure we have independent verification
of the width of characters before testing based on those widths.
* tests/fold/fold-zero-width.sh: Likewise.
* tests/fold/fold.pl: Only compare the exit status,
as the error message can be translated.

6 weeks agotests: dd: avoid false failure on Solaris 10
Pádraig Brady [Sat, 20 Sep 2025 16:46:11 +0000 (17:46 +0100)] 
tests: dd: avoid false failure on Solaris 10

* tests/dd/no-allocate.sh: Give some extra space to the
determined vm limit.

6 weeks agotests: avoid false failure on CentOS 5,6,7
Pádraig Brady [Sat, 20 Sep 2025 15:10:16 +0000 (16:10 +0100)] 
tests: avoid false failure on CentOS 5,6,7

* tests/fold/fold-zero-width.sh: Increase vm limit to avoid
failures on CentOS 5,6,7.  Match the limit used in write-errors.sh
as per commit v9.5-255-g0bd149403

6 weeks agodoc: don't capitalize the first letter of cgroup
Collin Funk [Fri, 19 Sep 2025 01:43:54 +0000 (18:43 -0700)] 
doc: don't capitalize the first letter of cgroup

This is the correct way to write it as described in the documentation:
<https://docs.kernel.org/admin-guide/cgroup-v2.html#terminology>.

* doc/coreutils.texi (nproc invocation): Use cgroup instead of Cgroup.

6 weeks agotests: env: skip a few tests if LD_LIBRARY_PATH is set
Collin Funk [Fri, 19 Sep 2025 23:32:52 +0000 (16:32 -0700)] 
tests: env: skip a few tests if LD_LIBRARY_PATH is set

* tests/env/env-null.sh: Skip test if LD_LIBRARY_PATH or platform's
equivalent is set, since 'env -i' will unset it which may prevent
programs from running.
* tests/env/env-S.pl: Likewise.
Issue and suggested fix reported by Bruno Haible.

6 weeks agotouch: fix diagnostic on macOS 26
Grisha Levit [Fri, 19 Sep 2025 00:40:59 +0000 (20:40 -0400)] 
touch: fix diagnostic on macOS 26

* src/touch.c (touch): Do not use open_errno == EEXIST for diagnostic
if file was a directory as macOS 26 sets it for open("/", O_CREAT, ...).

7 weeks agocopy: pacify older clang
Paul Eggert [Fri, 19 Sep 2025 15:55:12 +0000 (08:55 -0700)] 
copy: pacify older clang

* src/copy-file-data.c (copy_file_data):
Redo conditionals for clarity.
This pacifies the clang in FreeBSD 11 and OpenBSD 7.6.
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/coreutils/2025-09/msg00104.html

7 weeks agodd: don't mistakenly use O_EXCL on GNU/Hurd
Collin Funk [Fri, 19 Sep 2025 06:29:02 +0000 (23:29 -0700)] 
dd: don't mistakenly use O_EXCL on GNU/Hurd

* src/dd.c (v): Add the O_EXCL flag to the set of bits that we do not
want to use for our definitions.
* cfg.mk (sc_dd_O_FLAGS): Adjust to pass syntax-check.
* NEWS: Mention the fix.
Reported by Bruno Haible.

7 weeks agomaint: we don’t use Gnulib’s fchownat module
Paul Eggert [Fri, 19 Sep 2025 00:07:38 +0000 (17:07 -0700)] 
maint: we don’t use Gnulib’s fchownat module

* bootstrap.conf (gnulib_modules): Remove fchownat.
It is used only indirectly, via the chownat module.

7 weeks agofmt: eliminate a clang -Wformat-extra-args warning
Bruno Haible [Thu, 18 Sep 2025 21:05:06 +0000 (23:05 +0200)] 
fmt: eliminate a clang -Wformat-extra-args warning

* src/fmt.c (fmt): When not reading from stdin, always mention the
file name in the error message.

7 weeks agomaint: we use Gnulib’s stddef-h module directly
Paul Eggert [Thu, 18 Sep 2025 21:22:39 +0000 (14:22 -0700)] 
maint: we use Gnulib’s stddef-h module directly

* bootstrap.conf (gnulib_modules): Add stddef-h, since the code
uses ‘unreachable’ which is supplied by that module.

7 weeks agotests: tail/overlay-headers.sh: protect against hang
Pádraig Brady [Thu, 18 Sep 2025 18:04:57 +0000 (19:04 +0100)] 
tests: tail/overlay-headers.sh: protect against hang

* tests/tail/overlay-headers.sh: Protect tail invocation with timeout,
and extend the possible running period to 60 seconds like other tests.
Reported by Brudno Haible on T2SDE Linux/alpha

7 weeks agobuild: fix compile error on macOS
Pádraig Brady [Thu, 18 Sep 2025 17:04:57 +0000 (18:04 +0100)] 
build: fix compile error on macOS

* gnulib: Update to latest to pull fix
for localcharset compile failure on macOS.

7 weeks agotests: tests/tail/wait.sh: protect against hang
Pádraig Brady [Thu, 18 Sep 2025 16:47:45 +0000 (17:47 +0100)] 
tests: tests/tail/wait.sh: protect against hang

* tests/tail/wait.sh: This test was seen to hang occasionally
on an Alpine Linux 3.20 system, so protect the tail(1) call
with `timeout 60` as done in similar tests.
Reported by Bruno Haible.

7 weeks agobuild: fix link failure on macOS
Pádraig Brady [Thu, 18 Sep 2025 14:34:23 +0000 (15:34 +0100)] 
build: fix link failure on macOS

* src/local.mk: Explicitly depend on @INTL_MACOS_LIBS@
which may be not implicitly referenced (in LIBINTL) without gettext.
This is a new transitive dependency through localename-unsafe.
We add this globally to ease future maintenance as currently
6 commands require the localename-unsafe dependency:
date, du through show-date() (fprintftime), and
ls, pr, stat, uptime through strftime().

7 weeks agobuild: update gnulib for stringeq adjustment
Pádraig Brady [Wed, 17 Sep 2025 20:44:46 +0000 (21:44 +0100)] 
build: update gnulib for stringeq adjustment

* gnulib: Pull in stringeq adjustment.

7 weeks agotests: write-errors.sh: avoid portability issue with dash
Pádraig Brady [Wed, 17 Sep 2025 20:33:47 +0000 (21:33 +0100)] 
tests: write-errors.sh: avoid portability issue with dash

* tests/misc/write-errors.sh: Use printf rather than echo
since the echo builtin in dash will interpret backslashes.
* tests/misc/read-errors.sh: Likewise for consistency.

7 weeks agocksum,wc: inspect GLIBC_TUNABLES on all architectures
Pádraig Brady [Wed, 17 Sep 2025 19:38:53 +0000 (20:38 +0100)] 
cksum,wc: inspect GLIBC_TUNABLES on all architectures

* gnulib: Update gnulib to latest to pull in change
to inspect GLIBC_TUNABLES on non x86_64 or aarch64 platforms.
This was needed on 32 bit x86, which supports calling into
accelerated code, and so requires inspection of GLIBC_TUNABLES
to pass the disablement verification in tests/cksum/cksum.sh

7 weeks agomaint: prefer memeq to memcmp
Paul Eggert [Wed, 17 Sep 2025 19:12:53 +0000 (12:12 -0700)] 
maint: prefer memeq to memcmp

* gl/modules/randread-tests (Depends-on): Add stringeq.
* gl/tests/test-rand-isaac.c (main):
* src/copy.c (source_is_dst_backup):
* src/digest.c (b64_equal):
* src/install.c (have_same_content):
* src/ls.c (main, parse_ls_color):
* src/nl.c (check_section):
* src/od.c (write_block):
* src/seq.c (seq_fast):
* src/stty.c (eq_mode):
* src/system.h (is_nul):
Prefer memeq to memcmp when either will do.

7 weeks agomaint: STREQ → streq
Paul Eggert [Wed, 17 Sep 2025 16:12:23 +0000 (09:12 -0700)] 
maint: STREQ → streq

Use new Gnulib streq function instead of rolling our own macro.
* bootstrap.conf (gnulib_modules): Add stringeq.
* src/rm.c (main): Don’t assume streq is a macro that expands to (...),
as it is now a function.
* src/system.h:
* tests/df/no-mtab-status.sh, tests/df/skip-duplicates.sh:
(STREQ): Remove.  All uses replaced by streq.

7 weeks agobuild: update gnulib submodule to latest
Paul Eggert [Wed, 17 Sep 2025 15:30:21 +0000 (08:30 -0700)] 
build: update gnulib submodule to latest

7 weeks agotests: fix issues with fold-characters.sh test
Pádraig Brady [Wed, 17 Sep 2025 13:17:39 +0000 (14:17 +0100)] 
tests: fix issues with fold-characters.sh test

This was noticed with:

  trap '' PIPE &&  # Ignore SIGPIPE
  make check TESTS=tests/fold/fold-characters.sh SUBDIRS=.

* tests/fold/fold-characters.sh: Move memory limit test to ...
* tests/misc/write-errors.sh: ... which avoids "write error"
messages on stderr due to the ignored SIGPIPE.  It also protects
the fold invocation with a timeout(1) so that fold implementations
that don't exit promptly upon write error don't hang the test suite
(Like we would have done before commit v9.7-311-gc95c7ee76).

7 weeks agodoc: remove older ChangeLog items
Pádraig Brady [Wed, 17 Sep 2025 12:19:32 +0000 (13:19 +0100)] 
doc: remove older ChangeLog items

* Makefile.am: Update the oldest documented version
to 8.32 which is now about 5 years old.

7 weeks agomaint: remove unnecessary uintmaxtostr usage in printf
Collin Funk [Wed, 17 Sep 2025 02:43:46 +0000 (19:43 -0700)] 
maint: remove unnecessary uintmaxtostr usage in printf

* src/comm.c (compare_files): Use the "%ju" printf directive instead of
"%s" and printing the result of umaxtostr.
* src/df.c (get_header): Likewise.
* src/ls.c (print_long_format): Likewise.
* src/sort.c (check): Likewise.