Compare commits

...

611 Commits
v9.5 ... master

Author SHA1 Message Date
Collin Funk
1ba065b5be maint: cleanup libraries unnecessarily added to fold
* src/local.mk (src_fold_LDADD): Remove $(MBRTOWC_LIB) since it is
already added to LDADD. Remove $(LIBC32CONV) and $(LIBUNISTRING) which
were for an uncommitted patch which used Gnulib's mbfile module.
2025-09-09 20:39:37 -07:00
Pádraig Brady
2ed207cb1f nohup: avoid FORTIFY runtime failure on Bionic libc
The meaning of non-file permission umask bits is implementation defined.
On Bionic libc, attempting to set them triggers a FORTIFY runtime check.

  $ nohup true
  FORTIFY: umask: called with invalid mask -601
  Aborted                    nohup true

* src/nohup.c: (main) Avoid setting non-permission bits in umask.
Just clear the umask to ensure we create nohup.out with u+rw,
as we restore the original umask before the exec().
* tests/misc/nohup.sh: Add a test case.
* NEWS: Mention the bug fix.
2025-09-09 12:21:41 +01:00
Pádraig Brady
d9b68362ed basenc: ensure partial padding with newlines induces an error
* src/basenc.c (has_padding): A more robust helper to
identify padding in the presence of trailing newlines.
(do_decode): Use has_padding() rather than just looking
at the last character.
* tests/basenc/base64.pl: Fully test commit v9.4-53-g378dc38f4
by ensuring partially padded data is diagnosed.
baddecode9 is the case fixed in this commit.
* NEWS: Mention the bug fix.
2025-09-08 19:39:47 +01:00
Pádraig Brady
42c4578b49 tests: ensure option aliases are supported
This implicitly tests the previous commit to
adjust how date(1) handles multiple named format options.
Currrently it tests the following are supported:

  chown  --quiet  --silent
  date  --rfc-email  --rfc-822  --rfc-2822
  date  --uct  --utc  --universal
  dircolors  --bourne-shell  --sh
  dircolors  --csh  --c-shell
  head  --quiet  --silent

* tests/misc/option-aliases.sh: A new test to ensure all
option aliases supported by a command are supported.
* Reference the new test.
2025-09-07 13:53:22 +01:00
Pádraig Brady
9eddec7866 date: support overriding named formats
* src/date.c (main): Allow specifying different named formats,
with the last specified taking precedence.
* NEWS: Mention the bug fix.
2025-09-07 13:02:48 +01:00
Collin Funk
a777b99ffe cksum: don't leak memory using -a sha3 with OpenSSL
* gnulib: Update to the latest commit for latest changes to the
crypto/sha3-buffer and crypto/sha3 modules.
2025-09-06 17:14:47 -07:00
Collin Funk
0114629e0c maint: prefer c32isspace to iswspace
* src/wc.c (wc): Replace call to iswspace with c32isspace.
2025-09-04 21:18:51 -07:00
Collin Funk
24fb014092 tests: fold: check if multi-byte spaces are treated as blank
This avoids a test failure on FreeBSD 14, MacOS 15, and musl.
Fix suggested by Pádraig Brady in:
<https://bugs.gnu.org/79301#32>.
* tests/fold/fold-spaces.sh (isblank): New function. Only run the tests
if the character is treated as blank.
Fixes https://bugs.gnu.org/79301
2025-09-04 19:48:37 -07:00
Pádraig Brady
07eedce2d3 doc: update the md5/sha1 "weak hash" advisory
* doc/coreutils.texi: Adjust advisory for md5sum and sha1sum
to include "sha3", and also the more general `cksum -a` interface.
2025-09-04 18:19:15 +01:00
Pádraig Brady
a43a17f216 tests: cksum: check more length variants
* tests/cksum/cksum-raw.sh: Adjust to non legacy naming,
and also check various length variations.
* tests/misc/read-errors.sh: Likewise.
2025-09-04 14:52:21 +01:00
Pádraig Brady
31ed9a30c0 doc: NEWS: expand on the fold multi-byte enhancements
* NEWS: Mention all of fold(1) got multi-byte enhancement,
with -c being an ancillary part of that.
2025-09-04 14:49:09 +01:00
Pádraig Brady
aba9800995 cksum: prefer -a sha2 -l ###, to -a sha###
To make the interface more concise and consistent,
while being backwards compatible.

* src/digest.c (main): Continue to support -a "sha###" but
also support -a "sha2" and treat it like "sha3", except in...
(output_file): ... maintain the legacy tags for better compatability.
* doc/coreutils.texi (cksum invocation): Document the -a sha2 option.
* tests/cksum/cksum-base64.pl: Adjust as per modified --help.
* tests/cksum/cksum-c.sh: Add new supported SHA2-### tagged variant.
* NEWS: Mention the new feature.
2025-09-04 14:49:07 +01:00
Collin Funk
403d82a0bf cksum: add support for SHA-3
* src/digest.c: Include sha3.h.
(BLAKE2B_MAX_LEN): Rename to
DIGEST_MAX_LEN since it is also used for SHA-3.
(sha3_sum_stream): New function.
(enum Algorithm, algorithm_args, algorithm_args, algorithm_types)
algorithm_tags, algorithm_bits, cksumfns, cksum_output_fns): Add entries
for SHA-3.
(usage): Mention that SHA-3 is supported. Mention requirements for
--length with SHA-3.
(split_3): Use DIGEST_MAX_LEN instead of BLAKE2B_MAX_LEN. Determine the
length of the digest for SHA-3. Make sure it is 224, 256, 384, or 512.
(digest_file): Set the digest length in bytes. Use DIGEST_MAX_LEN
instead of BLAKE2B_MAX_LEN. Always append the digest length to SHA3 in
the output.
(main): Allow the use of --length with 'cksum -a sha3'.  Use
DIGEST_MAX_LEN instead of BLAKE2B_MAX_LEN. Make sure it is 224, 256,
384, or 512.
* tests/cksum/cksum-base64.pl (@pairs): Add expected sha3 output.
(fmt): Modify the output to use SHA3-512 since that is the default.
(@Tests): Modify arguments for sha3 to use --length=512.
* tests/cksum/cksum-sha3.sh: New test, based on tests/cksum/b2sum.sh.
* tests/local.mk (all_tests): Add the test.
* bootstrap.conf: Add crypto/sha3.
* gnulib: Update to latest commit.
* NEWS: Mention the change.
* doc/coreutils.texi (cksum general options): Mention sha3 as a
supported argument to the -a option. Mention that 'cksum -a sha3'
supports the --length option. Mention that SHA-3 is considered secure.
2025-09-03 22:29:33 -07:00
Collin Funk
022673367b maint: avoid syntax-check failure from previous commit
* src/df.c: Don't include uchar.h.
* src/ls.c: Likewise.
* src/wc.c: Likewise.
2025-09-03 19:15:49 -07:00
Collin Funk
3a81d44d43 fold: check that characters are not non-breaking spaces when -s is used
NetBSD 10 and Solaris 11.4 treat non-breaking spaces as blank
characters unlike glibc.

* src/system.h: Include uchar.h.
(c32isnbspace): New function based on iswnbspace from src/wc.c.
* src/fold.c (fold_file): Use it.
* src/wc.c (iswnbspace): Remove function.
(maybe_c32isnbspace): New function.
(wc, main): Use it.
Fixes https://bugs.gnu.org/79300
2025-09-03 19:12:18 -07:00
Collin Funk
e09f2bc611 maint: prefer issymlink to readlink with a small buffer
* bootstrap.conf (gnulib_modules): Add issymlink and issymlinkat.
* src/copy.c: Include issymlink.h.
(copy_reg): Use issymlink instead of readlinkat.
* src/rmdir.c: Include issymlink.h.
(main): Use issymlink instead of readlink.
* src/tail.c: Include issymlink.h.
(recheck, any_symlinks): Use issymlink instead of readlink.
* src/test.c: Include issymlink.h.
(unary_operator): Use issymlink instead of readlink.
2025-09-03 18:31:08 -07:00
Paul Eggert
1b2f629d96 build: update gnulib submodule to latest 2025-09-03 18:08:53 -07:00
Bruno Haible
db04fc2a09 build: Update after gnulib changed
* gnulib-tests/Makefile.am: Move the AM_CFLAGS assignment before the
'include gnulib.mk'.
2025-09-03 18:08:53 -07:00
Collin Funk
8f6430666f maint: avoid syntax-check failure from previous commit
* tests/seq/seq-long-double.sh: Place comma after "I.e.".
2025-09-02 21:14:34 -07:00
Pádraig Brady
701416709d seq: be more accurate with large integer start values
* src/seq.c (main): Avoid possibly innacurate conversion
to long double, for all digit start values.
* tests/seq/seq-long-double.sh: Add a test case.
* NEWS: Mention the improvement.
Fixes https://bugs.gnu.org/79369
2025-09-02 20:51:55 +01:00
Paul Eggert
c6397d0872 df: pacify static analysis
Problem reported by Yubiao Hu <https://bugs.gnu.org/79336>.
* src/df.c (get_dev): Assume MOUNT_POINT is non-null.
2025-09-01 10:03:14 -07:00
Pádraig Brady
ebd670e7eb ls: fix alignment with locale formatted --size
Fix allocated size alignment in locales with multi-byte grouping chars.
Tested with: LC_ALL=sv_SE.utf8 ls --size --block-size=\'k

* src/ls.c (print_file_name_and_frills): Don't rely on
printf("%*s", width, string) to pad multi-byte strings appropriately.
Instead work out the padding required and use:
printf("%*s%s", padding, "", string) to pad multi-byte appropriately.
* tests/ls/block-size.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/79347
2025-08-31 19:25:38 +01:00
Pádraig Brady
735a4a27f3 b2sum: --length: fix upper bound check
* src/digest.c (main): Don't saturate -l to BLAKE2B_MAX_LEN,
so that the subsequent bounds check is performed.
* tests/cksum/b2sum.sh: Add a test case.
* NEWS: Mention the fix introduced in commit v9.5-71-gf2c84fe63
2025-08-30 12:44:29 +01:00
Collin Funk
89b9115da6 fold: fix handling of invalid multi-byte characters
* src/fold.c (fold_file): Continue the loop when we have buffered bytes
but nothing left to read from the file.
(adjust_column): Don't assume that the character is printable.
* tests/fold/fold-characters.sh: Add a new test case.
(bad_unicode): New function.
2025-08-28 18:57:13 -07:00
Pádraig Brady
4b35a3b920 tests: fold: add tests for multi-byte width
* tests/fold/fold.pl: The i18n patch didn't actually test folding
of multi-byte characters, so add tests for various multi-byte forms.
2025-08-27 16:41:07 +01:00
Pádraig Brady
0001bbc3e2 tests: fold: copy i18n patch tests
* tests/fold/fold.pl: Copy tests from Fedora,
removing copy & pasted logic that was
extraneous to either the i18n patch or upstream.
2025-08-27 14:36:16 +01:00
Pádraig Brady
cbf6a27810 tests: parameterize IO_BUFSIZE
* src/getlimits.c (main): Output IO_BUFSIZE, useful for
sizing data for tests.
* tests/fold/fold-characters.sh: Use it rather than hardcoding.
2025-08-27 12:03:46 +01:00
Pádraig Brady
aec4f85476 build: fold: fix build failure with C99
GCC 10.2 gave the following error:
"error: label at end of compound statement"

* src/fold.c (fold_file): Add a ";" to avoid C2X specific syntax.
2025-08-27 11:50:01 +01:00
Collin Funk
ae89cd646a fold: don't truncate multibyte characters at the end of the buffer
* src/fold.c (fold_file): Replace invalid characters with the original
byte read. Copy multibyte sequences that may not yet be read to the
start of the buffer before reading more bytes.
* tests/fold/fold-characters.sh: Add a test case.
2025-08-26 16:59:32 -07:00
Pádraig Brady
01646ccd64 tests: fold: consolidate all fold tests in tests/fold
* tests/misc/fold.pl: Move from here to ...
* tests/fold/fold.pl: ... here.
* tests/local.mk: Adjust accordingly.
2025-08-26 16:49:56 +01:00
Pádraig Brady
17be45b952 tests: fold: add a memory constraint test
Enforcing this interface behavior is worthwhile
irrespective of our current implementation,
to ensure future or other implementations conform.

* tests/fold/fold-characters.sh: Ensure the fold implementation
uses bounded memory.
2025-08-26 16:48:31 +01:00
Collin Funk
fb9016d505 fold: use fread instead of getline
* src/fold.c: Include ioblksize.h.
(fold_file): Use two IO_BUFSIZE-sized buffers. Use fread instead of
getline. Check for if we reached the end of file.
2025-08-24 13:42:40 -07:00
Pádraig Brady
4bfcf62f74 tests: nproc: fix false failure on some systems
* tests/nproc/nproc-quota.sh: Also simulate sched_getscheduler()
as this will not be called on older or non linux, or
may return ENOSYS on Alpine.
Fixes https://bugs.gnu.org/79299
2025-08-24 11:48:52 +01:00
Collin Funk
11a31296fa maint: prefer STRUCT_UTMP to struct gl_utmp
* cfg.mk (sc_prohibit-struct-gl_utmp): New rule for 'make syntax-check'.
* src/pinky.c (time_string, print_entry, scan_entries, short_pinky):
Use STRUCT_UTMP instead of struct gl_utmp.
* src/uptime.c (print_uptime, print_uptime, uptime): Likewise.
* src/users.c (list_entries_users, users): Likewise.
* src/who.c (time_string, print_user, print_boottime, print_deadprocs)
(print_login, print_initspawn, print_clockchange, print_runlevel)
list_entries_who, scan_entries, who): Likewise.
2025-08-23 18:10:07 -07:00
Pádraig Brady
6c668dc133 tests: cp: ensure copy offload is not disabled for sparse files
Related to commits v9.1-109-g879d2180d and v9.7-248-g306de6c26

* tests/cp/sparse-perf.sh: This edge case was missed a couple of times,
so add a test to ensure we attempt copy offload.
2025-08-23 18:55:46 +01:00
Collin Funk
7d0d9658f9 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.
2025-08-22 22:09:50 -07:00
Paul Eggert
39f22fe687 cp: improve hole handling on squashfs
Better fix for problem reported by Jeremy Allison
<https://bugs.gnu.org/79267>.
* src/copy.c (struct scan_inference): New type, replacing
union scan_inference.  All uses changed.  This is so
infer_scantype can report the first hole's offset when known.
(lseek_copy): 5th arg is now struct scan_inference const *,
not just off_t.  All uses changed.
(infer_scantype): If SEEK_SET+SEEK_HOLE do not find a hole,
fall back on ZERO_SCANTYPE.
2025-08-22 17:40:30 -07:00
Paul Eggert
306de6c261 cp: go back to copy_file_range optimization
This reverts part of the previous change.
* src/copy.c (lseek_copy): When calling sparse_copy, do not
ask it to scan for zeros unless --sparse=always, so that it
can use copy_file_range which can be far more efficient.
2025-08-22 17:40:29 -07:00
Paul Eggert
b7fc76269b cp: always punch holes that we make
Problem reported by Jeremy Allison <https://bugs.gnu.org/79267>.
* src/copy.c (create_hole, sparse_copy): Omit arg PUNCH_HOLES,
as we always punch holes now.  All uses changed.
(lseek_copy): When calling sparse_copy, scan for holes when
sparse_mode == SPARSE_AUTO, as that means we are making holes.
(copy_reg): Always punch any hole made at end.
2025-08-21 15:58:21 -07:00
Pádraig Brady
61a7382c8f tests: nproc: add a test for cgroup quotas
* tests/nproc/nproc-quota.sh: New root only test.
* tests/local.mk: Reference the new test.
2025-08-21 00:04:03 +01:00
Collin Funk
238855dd4e maint: prefer https to http
* doc/sort-version.texi (Other version/natural sort implementations):
Use https in documentation link.
* tests/chmod/symlinks.sh: Use https in license text.
2025-08-19 11:41:17 -07:00
Pádraig Brady
c4df55be7f nproc: honor cgroup v2 CPU quotas
* NEWS: Mention the new feature.
* doc/coreutils.texi (nproc invocation): Mention that
cgroup CPU quotas can limit the reported number.
* gnulib: Update to new nproc gnulib implementation:
https://github.com/coreutils/gnulib/commit/9b07115f4a
2025-08-19 17:24:21 +01:00
Collin Funk
37bca77c4d logname: list David MacKenzie as the author
* src/logname.c (AUTHORS): List David as the author.
* AUTHORS: Likewise.
2025-08-18 20:42:48 -07:00
Paul Eggert
ae6fd2b4a1 realpath: improve doc and NEWS 2025-08-14 21:08:44 -07:00
Collin Funk
c9ae3b553d maint: avoid syntax-check failure from previous commit
* src/tsort.c: Don't include long-options.h since the previous commit
removed the call to parse_gnu_standard_options_only. This avoids a
sc_prohibit_long_options_without_use syntax-check failure.
2025-08-14 19:43:52 -07:00
Paul Eggert
39eec70f7b tsort: add do-nothing -w option
This is for conformance to POSIX.1-2024
* src/tsort.c: Include getopt.h.
(main): Accept and ignore -w.  Do not bother altering
the usage message, as the option is useless.
* tests/misc/tsort.pl (cycle-3): New test.
2025-08-14 17:35:23 -07:00
Pádraig Brady
2543c0052c maint: use short form bug URLs
* cfg.mk (sc_prohibit-long-form-bug-urls): Disallow long form in code.
* scripts/git-hooks/commit-msg: Disallow long form in commit messages.
* NEWS: Shorten long urls.
* bootstrap.conf: Likewise.
* configure.ac: Likewise.
* scripts/git-hooks/commit-msg: Likewise.
* src/csplit.c: Likewise.
* src/fmt.c: Likewise.
* src/make-prime-list.c: Likewise.
* src/nohup.c: Likewise.
* tests/od/od-float.sh: Likewise.
* tests/rm/r-root.sh: Likewise.
* tests/tail/inotify-race.sh: Likewise.
* tests/tail/inotify-race2.sh: Likewise.
2025-08-12 17:50:40 +01:00
Bruno Haible
f4d339c934 basenc: Don't trigger undefined behaviour in mini-gmp
* src/basenc.c (base58_encode): Avoid calling mpz_import on an empty
limb sequence.
2025-08-11 18:07:20 -07:00
Collin Funk
2a092e80e2 realpath: support the -E option required by POSIX
* src/realpath.c (longopts): Add the option.
(main): Likewise.
(usage): Add the option to the --help message.
* tests/misc/realpath.sh: Add a simple test.
* doc/coreutils.texi (realpath invocation): Mention the new option.
* NEWS: Likewise.
2025-08-10 11:41:56 -07:00
Pádraig Brady
192e09042f doc: --base58: add example usage to info
* doc/coreutils.texi (basenc invocation): Add an example
using --base58 to generate a unique ID.  This also demonstrates
compound usage of the basenc command, to convert to/from binary.
2025-08-10 16:21:42 +01:00
Pádraig Brady
d7774907db doc: rearrange NEWS to more standard ordering
* NEWS: Also move items to more appropriate sections.
Also use more consistent quoting.
2025-08-09 22:32:18 +01:00
Pádraig Brady
02c3d43e3a basenc: add base58 support
A 58 character encoding that:
 - avoids visually ambiguous 0OIl characters
 - uses only alphanumeric characters
Described at:
 - https://tools.ietf.org/html/draft-msporny-base58-03

This implementation uses GMP (or gnulib's gmp fallback).
Performance is good in comparison to other implementations.
For example when using libgmp on an i7-5600U system,
encoding is 530 times faster, and decoding 830 times faster
than the implementation using arbitrary precision ints in cpython 3.13.

Memory use is proportional to the size of input.

Encoding benchmarks:

  $ time yes | head -c65535 | src/basenc --base58 -w0 >file.enc
  real    0m0.018s

  ./configure --quiet --without-libgmp && make -j $(nproc)
  $ time yes | head -c65535 | src/basenc --base58 -w0 >file.enc
  real    0m3.431s

  # dnf install python3-base58
  $ time yes | head -c65535 | base58 >file.enc  # cpython 3.13
  real    0m9.700s

Decoding benchmarks:

  $ time src/basenc --base58 -d <file.enc >/dev/null
  real    0m0.010s

  $ ./configure --without-libgmp && make  # gnulib gmp
  $ time src/basenc --base58 -d <file.enc >/dev/null
  real    0m0.145s

  $ time base58 -d <file.enc >/dev/null  # cpython 3.13
  real    0m8.302s

* src/basenc.c (base_decode_ctx_finalize, base_encode_ctx_init,
base_encode_ctx, base_encode_ctx_finalize): New functions to
provide more general processing functionality.
(base58_{de,en}code_ctx{_init,,_finalize}): New functions to
accumulate all input before calling ...
(base58_{de,en}code): ... the GMP based encoding/decoding routines.
(do_encode, do_decode): Call the ctx variants if enabled.
* doc/coreutils.texi (basenc invocation): Describe the new option,
and indicate the main use case being interactive user use.
* src/local.mk: Link basenc with GMP.
* tests/basenc/basenc.pl: Add test cases.
* NEWS: Mention the new feature.
2025-08-09 22:10:27 +01:00
Pádraig Brady
c480428e37 basenc: fix stripping of '=' chars in some encodings
* src/basenc.c (do_decode): With -i ensure we strip '=' chars
if there is no padding for the chosen encoding.
* tests/basenc/basenc.pl: Add a test case.
* NEWS: Mention the bug fix.
2025-08-09 09:59:00 +01:00
Collin Funk
13202995ba maint: prefer attribute.h in .c files
* src/basenc.c (base16_encode, z85_encoding, do_decode): Use
ATTRIBUTE_NONSTRING instead of ATTRIBUTE_NONSTRING.
* src/basenc.c (sc_prohibit-_gl-attributes): New rule for
'make syntax-check'.
2025-08-08 20:49:29 -07:00
Paul Eggert
26bf557e3f cp: omit some needless lseek calls
The sparse code sometimes issued multiple lseeks against the
same file without doing anything in betwee.  Optimize them away
by keeping track of the last hole output, in a way that
crosses the sparse_copy function call boundary.
* src/copy.c (sparse_copy): New arg hole_size, replacing old args
scan_holes and last_write_made_hole.  All callers changed.
(sparse_copy, lseek_copy): Do not create hole at
end; let the caller deal with it.  All callers changed.
(lseek_copy): New args hole_size and total_n_read.  Caller changed.
(copy_reg): Create hole at end for both lseek_copy and sparse_copy.
2025-08-07 20:20:04 -07:00
Paul Eggert
2f2adb294e cp: --sparse=always was missing some holes
The sparse code assumed that st_blksize was the minimum hole size.
However, st_blksize is an optimum I/O buffer size, not the file
system fundamental block size.  Use ST_NBLOCKSIZE instead;
although it may underestimate the true block size that just slows
‘cp’ down a bit, without introducing bugs.
* src/copy.c (sparse_copy): Arg scan_holes replaces
the old hole_size arg.  All callers changed.
(lseek_copy): Remove hole_size arg; no longer needed.
Caller changed.
2025-08-07 20:20:04 -07:00
Collin Funk
c9a30d6781 maint: use consistent references to standard files in messages
* cfg.mk (sc_standard_outputs): Add a grep command for source files.
* src/du.c (main): Use standard input instead of stdin, standard output
instead of stdout, and standard error instead of stderr in messages.
* src/nohup.c (main): Likewise.
* src/sort.c (main): Likewise.
* src/split.c (main): Likewise.
* src/stdbuf.c (main): Likewise.
* src/wc.c (main): Likewise.
* tests/du/files0-from.pl (@Tests): Adjust test case to new messages.
* tests/sort/sort-files0-from.pl: Likewise.
* tests/wc/wc-files0-from.pl: Likewise.
2025-08-05 18:46:04 -07:00
Bernhard Voelker
257efe1ec4 maint: remove now-unused include of 'safe-read.h'
'make syntax-check' complains:
  src/tail.c
  maint.mk: the above files include safe-read.h but don't use it
  make: *** [maint.mk:737: sc_prohibit_safe_read_without_use] Error 1

The removal was missed for tail.c in recent commit d3c7072a09.

* src/tail.c (safe-read.h): Remove include.
2025-08-04 10:53:49 +01:00
Paul Eggert
5c822f4dac maint: prefer same-inode.h
This does not change behavior on POSIX platforms; it’s mostly to
make it clearer when we’re looking for file identity.
* src/cat.c (main):
* src/copy.c (struct dir_list, is_ancestor, copy_internal):
* src/tail.c (struct File_spec, record_open_fd, recheck)
(tail_forever_inotify, tail_file):
* src/test.c (binary_operator):
Use psame_inode, PSAME_INODE, or SAME_INODE instead of comparing
device and inode numbers by hand.
2025-08-03 19:48:06 -07:00
Paul Eggert
01e4d2983a tail: refactor ‘failable’
* src/tail.c (recheck, tail_file): Do not mark a file as tailable
merely because --retry is not in effect.  Simplify internal logic.
This should not change behavior; it’s just for clarity and to
make the code match the comments better.
2025-08-03 19:48:06 -07:00
Paul Eggert
e0100ac746 tail: fix race between read and fstat
* src/tail.c (get_file_status): Remove, since after the changes
described below it would be called in just one place and it’s a
bit clearer to inline by hand.
(tail_file): Don’t call fstat after reading the file, as that
misses changes arriving between read and fstat.  Instead, reuse
the fstat done before reading the file.
2025-08-03 19:48:06 -07:00
Paul Eggert
3655a8cced tail: track errno more accurately
This matters only in some obscure cases hard to test for.
* src/tail.c (file_lines, pipe_lines, pipe_bytes, start_bytes)
(start_lines, tail_bytes, tail_lines, tail): New return
convention, which reports errno.  All callers changed.
(recheck): Don’t lose track of errno if a regular file is
replaced by a symlink.
(get_file_status): Set errno to 0 on success.
(tail_file): Be more careful about f->errnum.
It is now -1 only if the failure was not due to
a system call failing.
2025-08-03 19:48:06 -07:00
Paul Eggert
0b2080f2fa tail: omit redundant assignment
* src/tail.c (recheck): f->remote must be true already,
so don’t set it to true.
2025-08-03 19:48:06 -07:00
Paul Eggert
2d386993e2 tail: prefer readlink to lstat+S_ISLNK
When not already calling lstat for some other reason,
prefer readlink to lstat+S_ISLNK,
as readlink does not suffer from EOVERFLOW issues.
* src/rmdir.c (main):
* src/tail.c (recheck, any_symlinks):
* src/test.c (unary_operator):
2025-08-03 19:48:06 -07:00
Paul Eggert
93805484c5 tail: fix unlikely races with >=2 --pids
Also, fix commentary to talk about “nonexistent” rather than
“dead” processes, since the code looks for the former not the
latter and the difference matters for zombies.
* src/tail.c (some_writers_exist): Rename from writers_are_dead,
negate the sense, don’t have a special and counterintuitive case
for !nbpids, remove PIDs found not to exist, and avoid some
though not all unlikely races when kernels reuse PIDs.
(tail_forever): Optimize via blocking I/O even if --pid was used,
so long as all the writers no longer exist.
(tail_forever, tail_forever_inotify): Simplify the writers_dead
logic; there is no need to have a local var to track this, since
we can use pids and nbpids now.
(parse_options): Also free and clear pids if !forever.
2025-08-03 19:48:06 -07:00
Paul Eggert
15c67b79af tail: prefer < 0 to == -1
* src/tail.c (valid_file_spec, recheck, writers_are_dead)
(tail_forever, check_fspec, tail_forever_inotify, tail_file)
(parse_options, main): Be a bit more systematic about checking
for sign, rather than for exact equality or inequality,
when the sign is enough.  Makes the code a bit clearer
now that -2 sometimes means success.
2025-08-03 19:48:06 -07:00
Paul Eggert
976f8abc19 tail: record file offset more carefully
* src/tail.c (struct File_spec): New member read_pos, replacing
size, since the value was really a read position not a size.
All uses changed.
(xlseek): Move defn up.
(record_open_fd): If the read_pos (formerly) size arg is unknown,
compute it here if it is a regular file.
(file_lines): Return the resulting read pos (or -1 on failure)
instead of storing it via a pointer.  Caller changed.
Simplify by using SEEK_CUR instead of SEEK_SET when that is easy.
Avoid reading the same data twice when there are not enough
lines in the file.
(pipe_lines): Return -2 on success, -1 on failure, rather than
updating a read pos via a pointer (which was weird for pipes anyway).
Caller changed.
(pipe_bytes, tail_bytes, tail_lines, tail):
Return -1 on failure, a file offset if known, and < -1 otherwise,
instead of storing a file offset via a pointer.  Caller changed.
(pipe_bytes): Take initial file offset as an arg, or -1 if unknown.
(start_bytes, start_lines): Return -1 (not 1) on error, -2 (not
-1) on EOF, and do not accept pointer to read pos as an arg since
neither we nor our caller know the read pos.  Callers changed.
(recheck): Do not assume a newly-opened file is at offset zero,
as this is not always true on Solaris.
(tail_forever, check_fspec): Use dump_remainder result only
on regular files, to prevent (very unlikely) overflow.
(tail_file): Remove no-longer-needed TAIL_TEST_SLEEP code.
2025-08-03 19:48:06 -07:00
Paul Eggert
d3c7072a09 maint: prefer 'read' to 'safe_read'
In the old days, safe_read acted more like what full_read does now.
When that went away, some code that invoked safe_read should
have gone back to plain 'read' but I guess we never got around to it.
Simplify this code by going back to plain 'read'.
Use safe_read only in csplit.c, which has a signal handler
and where 'read' can therefore fail with EINTR.
Although safe_read also checks for oversize buffers,
that is better done via io_blksize.
* src/cat.c (simple_cat, cat):
* src/head.c (copy_fd, elide_tail_lines_pipe)
* src/tac.c (tac_seekable, copy_to_temp):
(elide_tail_lines_seekable, head_lines):
* src/tail.c (dump_remainder, file_lines, pipe_lines)
(pipe_bytes, start_bytes, start_lines, tail_forever_inotify):
* src/tr.c (plain_read):
Use plain 'read', not safe_read, since there is no
need to worry about signals or oversize requests.
Also, there is no longer a need to include safe-read.h.
* src/ioblksize.h: Include sys-limits.h, for SYS_BUFSIZE_MAX.
(io_blksize): Max out at SYS_BUFSIZE_MAX.
2025-08-03 19:48:05 -07:00
Paul Eggert
3820447667 tail: prefer signed types to size_t, blksize_t
* src/tail.c (struct File_spec, xwrite_stdout, file_lines)
(pipe_lines, pipe_bytes, start_bytes, any_live_files)
(tail_forever, any_remote_file, any_non_remote_file)
(any_symlinks, any_non_regular_fifo, tailable_stdin)
(tail_forever_inotify, ignore_fifo_and_pipe, main):
Prefer a signed type to size_t, if possible.
Ordinarily this is idx_t, but use int when the value
must fit in int anyway.
(file_lines): Similarly for blksize_t, which had no business
being here anyway.
(main): Check for overflow in the oddball case where ptrdiff_t is
narrower than int.
2025-08-03 19:48:05 -07:00
Paul Eggert
0625370b7a tail: prefer intmax_t to uintmax_t
Signed types let us debug better, by using -fsanitize=undefined.
* doc/local.mk (doc/constants.texi):
Adjust change from macro to enum.
* src/tail.c (COPY_TO_EOF, COPY_A_BUFFER)
(DEFAULT_MAX_N_UNCHANGED_STATS_BETWEEN_OPENS):
Now enum constants, not macros.
(COPY_TO_EOF, COPY_A_BUFFER): Now negative, not positive.
(count_t): New typedef.  Use it instead of uintmax_t.
(COUNT_MAX): New macro; use it instead of UINTMAX_MAX.
(struct File_spec, max_n_unchanged_stats_between_opens)
(dump_remainder, file_lines, pipe_lines, pipe_bytes)
(start_bytes, start_lines, tail_forever, check_fspec)
(tail_forever_inotify, tail_bytes, tail_lines, tail, tail_file)
(parse_obsolete_option, parse_options, main):
Prefer count_t to uintmax_t.
2025-08-03 19:48:05 -07:00
Paul Eggert
fee8859750 tail: don’t output more lines than requested
* src/tail.c (file_lines): Fix an unlikely bug where ‘tail -n N’
could output more than N lines if standard input is a largish
regular file with large initial offset that starts with (say) N-1
lines after the initial offset, but grows to N+1 lines between the
fstat and read calls.  In this case ‘tail -n N’ now outputs N-1
lines, not N+1; that is, it pretends the file grew after ‘tail’
read it.  That is better than outputting more than N lines.
2025-08-03 19:48:05 -07:00
Paul Eggert
eb0086669f tail: xlseek switch → table
* src/tail.c (xlseek): Turn a switch statement into a table.
2025-08-03 19:48:05 -07:00
Paul Eggert
d584545299 tail: prettyname cleanup
* src/tail.c: Use ‘prettyname’ consistently as the identifier
for a prettified file name, as opposed to ‘pretty_filename’,
‘pretty_name’, and ‘name’.  This makes the code easier to follow.
(struct File_spec): New member prettyname.
(pretty_name): Remove.
All uses of pretty_name (f) replaced by f->prettyname.
(close_fd, fremote): Accept struct File_spec, not name.
All callers changed.
(main): Initialize the new prettyname member.
This is simpler/smaller than calling pretty_name everywhere.
2025-08-03 19:48:05 -07:00
Paul Eggert
10aa908ebd tail: optimize tail -n +2**63
* src/tail.c (tail_lines): Also optimize ‘tail -n +N’
on a seekable file, where OFF_T_MAX <= N < UINTMAX_MAX.
Of course this is very unlikely.
2025-08-03 19:48:05 -07:00
Paul Eggert
3918655d4b tail: refactor SEEK_END and lines
* src/tail.c (tail_lines): Refactor to simplify the confusing
code for using SEEK_END when counting lines.  The old code
had a ‘end_pos != 0’ expression that was always true.
2025-08-03 19:48:05 -07:00
Paul Eggert
09fc945b37 tail: refactor to skip stat call on failure
* src/tail.c (tail_bytes): New function.
(tail_bytes, tail_lines, tail): Accept struct stat pointer from
caller instead of calling fstat ourselves.  All callers changed.
(tail_file): Skip a call to fstat if fstat already failed.
* tests/tail/follow-stdin.sh: Adjust to match new behavior
on failure, which omits a redundant diagnostic.
2025-08-03 19:48:05 -07:00
Paul Eggert
d58aa27d06 tail: speed up -c N for huge N
When the user specifies -c N where 2**63 <= N, don’t give
up and use the slow method (which will exhaust memory if
the file is large).  Instead, treat it as N = 2**63 - 1,
since that has equivalent effect.
* src/tail.c (tail_bytes): With -c N and large N, adjust
the code so that lseeks can still be used without
affecting correctness.  Formerly the code gave up and
did a sequential pass through the whole input, which
could easily exhaust memory.
2025-08-03 19:48:05 -07:00
Paul Eggert
6439858056 tail: allow >=2**64 in traditional form
This better matches the treatment of POSIX form,
e.g., ‘tail +Nc’ is now like ‘tail -c +N’ even when N is large.
* src/tail.c: Don’t include xstrtol.h.
(parse_obsolete_option): Treat numbers greater than UINTMAX_MAX as
if they are UINTMAX_MAX.  Parse the number by hand with saturating
arithmetic; nowadays that’s simpler than using xstrtoumax.  There
is no need for a diagnostic now, as the error cannot happen any more.
* tests/tail/tail.pl (obs-plus-c3): New test.
2025-08-03 19:48:04 -07:00
Paul Eggert
ae37265727 tail: check OFF_T_MAX vs COPY_A_BUFFER
* src/tail.c: Document an otherwise-unstated assumption.
2025-08-03 19:48:04 -07:00
Paul Eggert
468f821150 tail: fix SEEK_END typo
* src/tail.c (tail_lines): Fix embarrassing SEEK_END typo.
Luckily this matters only in never-used (though valid) invocations.
2025-08-03 19:48:04 -07:00
Paul Eggert
c667ca229f tail: simplify -c+ on regular files
* src/tail.c (tail_bytes): Simplify the -c+N case by treating
regular files like other files; if the lseek fails for whatever
reason, fall back on the unoptimized version instead of reporting
a fatal error.
2025-08-03 19:48:04 -07:00
Paul Eggert
938035b9b4 maint: don’t lseek memory objects
This affects behavior only on memory objects, which are not in Linux.
Formerly the code would use lseek on these objects,
but POSIX says the result of lseek is unspecified on them,
and in QNX lseek has undefined behavior on typed memory objects.
* src/head.c (elide_tail_bytes_file, elide_tail_lines_file):
Omit unnecessary uses of presume_input_pipe.
Improve some out-of-date comments.
(head): Do not assume a file is seekable merely because its
st_size is usable.  Instead, seek only on regular files.
* src/od.c (skip): Do not seek on memory objects.
2025-08-03 19:48:04 -07:00
Paul Eggert
dfe4df5694 wc: don’t assume opening a file puts you at start
This is not true on Solaris when opening /dev/stdin; it could be
at a nonzero file offset.  Arguably Linux should do likewise.
* src/wc.c (wc): Omit last arg, and act as if it is always -1.
All uses changed.
2025-08-03 19:48:04 -07:00
Paul Eggert
c9e2dd531d head: simplify head_bytes
* src/head.c (diagnose_read_failure): New function.
Use it when possible, to simplify callers.
(head_bytes): Use copy_fd and diagnose_copy_fd_failure instead of
reinventing the wheel.
2025-08-03 19:48:04 -07:00
Paul Eggert
ca30c06e4c head: omit unnecessary lseek
* src/head.c (elseek_diagnostic): New function.
(elseek): Use it.
(head_lines): Use it to avoid an unnecessary lseek.
2025-08-03 19:48:04 -07:00
Collin Funk
2ff3c65e94 readlink: improve documentation for POSIXLY_CORRECT in --help
* NEWS: Improve wording to not imply POSIXLY_CORRECT=1 readlink -q will
be verbose.
* src/readlink.c (usage): Mention the affect of POSIXLY_CORRECT on
-s (--silent), -q (--quiet), and -v (--verbose) in the help message.
(main): Remove spurious newline added by previous commit.
* doc/coreutils.texi (readlink invocation): Mention that -s (--silent)
and -q (--quiet) are not the default when POSIXLY_CORRECT is set.
2025-08-03 12:33:55 -07:00
Collin Funk
ecd803805d readlink: emit errors when POSIXLY_CORRECT is set
* src/readlink.c (main): Set verbose if the POSIXLY_CORRECT environment
variable is set.
* tests/readlink/readlink-posix.sh: New file.
* tests/local.mk (all_tests): Add it.
* NEWS: Mention the change.
* doc/coreutils.texi (readlink invocation): Document the behavior of
POSIXLY_CORRECT.
2025-08-03 10:55:54 -07:00
Pádraig Brady
79206bbfbe doc: mention copy_file_range data corruption avoidance
* NEWS: Mention this important data corruption issue.
2025-08-02 09:52:17 +01:00
Paul Eggert
336cd700c0 build: update gnulib submodule to latest 2025-08-01 17:02:22 -07:00
Bruno Haible
0142856e7b maint: date: refactor to be entirely bottom-up
* src/date.c (show_date_helper): Move function. Remove forward
declaration.
2025-08-01 13:31:28 +01:00
Bruno Haible
4d03487bbb date: fix calendar-related test failures on macOS and OpenBSD
* bootstrap.conf (gnulib_modules): Add xsetenv.
* src/date.c: Include xsetenv.h.
(set_LC_TIME): New function.
(show_date_helper): Call set_LC_TIME instead of setlocale.
* po/POTFILES.in: Add lib/xsetenv.c.
Fixes https://bugs.gnu.org/79118
2025-07-31 21:54:49 -07:00
Collin Funk
5bdd466c68 build: update gnulib submodule to latest 2025-07-31 21:43:55 -07:00
Collin Funk
6c2117ab80 build: fix previous commit
* src/local.mk (src/speedlist.h): Pass correct arguments $(COMPILE). Use
tabs consistently.
2025-07-31 17:57:59 -07:00
Collin Funk
72d483dab7 build: don't use '$<' in non-suffix rules
* src/local.mk (src/speedlist.h): Use the file name instead of '$<'
which is not supported by OpenBSD make.
2025-07-30 16:33:24 -07:00
Pádraig Brady
a7c63296c1 du: improve diagnostics for --time-style
* src/system.h (x_timestyle_args): A new function refactored from ...
* src/ls.c (decode_switches): ... here.
* src/du.c: Use refactored x_timestyle_args() to output a custom error.
Addresses https://bugs.gnu.org/79113
2025-07-29 11:43:09 +01:00
Pádraig Brady
69f21c5d46 doc: use consistent references to standard files
* cfg.mk (sc_standard_outputs): A new syntax check to
enforce standard references.
* doc/coreutils.texi: s/stderr/standard error/ etc.
* src/date.c: Likewise.
* src/dd.c: Likewise.
* src/env.c: Likewise.
* src/sort.c: Likewise.
* src/split.c: Likewise.
* src/stty.c: Likewise.
* src/timeout.c: Likewise.
* src/who.c: Likewise.
2025-07-29 11:43:09 +01:00
Collin Funk
afd899cb47 doc: update git version documented in HACKING
* HACKING: Mention that git version 1.6.4 or later is required since
'./bootstrap' will fail otherwise.
2025-07-27 11:53:42 -07:00
Paul Eggert
4a2402dcfa doc: mention 2025 speedup on large composites 2025-07-27 07:30:49 -07:00
Pádraig Brady
798a35a7b3 maint: avoid :> pattern in tests
This was seen to trigger the EXIT trap on cygwin

* cfg.mk (sc_prohibit_colon_redirection): Disallow all
cases of :> in tests/
* tests/cksum/md5sum-bsd.sh: Adjust to avoid more
stringent syntax check.
2025-07-26 20:06:42 +01:00
Collin Funk
93304acc10 tests: avoid a false failure on Cygwin
* tests/cksum/md5sum-bsd.sh: Use 'echo' instead of ':' to redirect to
the file. Otherwise 'Exit $fail' is not called on Cygwin.
2025-07-26 11:29:02 -07:00
Collin Funk
ba8e55ea95 maint: avoid syntax-check failure from previous commit
* src/test.c (binary_operator): Place string argument on a separate line
to avoid sc_error_quotes syntax-check failure.
2025-07-26 00:17:16 -07:00
Paul Eggert
3c40470c5d test: simplify for clarity
This should help avoid further audit confusion,
such as was just fixed by removing a FIXME.
* src/test.c (enum binop): New type.
(get_mtime): Return a struct timespec instead of returning
a bool and storing a struct timespec.  All callers changed.
(binop): Return an int recording either success (an enum binop)
or failure (-1).  All callers changed.
(binary_operator): Accept an enum binop, so that we need
not recompute the op type.  All callers changed.  Simplify.
2025-07-25 12:27:39 -07:00
Harry Fellowes
ecde78e1df test: removed dead code for unrecognised binary operators
the fallback error in binary_operator() was unreachable, since invalid
binary operators are rejected in three_arguments() via binop() which
returns false and prevents entry into binary_operator().

this dead code was unreachable and safe to remove

ref: line 636 where "binary operator expected" is generated.

Signed-off-by: Harry Fellowes <harryfellowes1@gmail.com>
Copyright-paperwork-exempt: Yes
2025-07-25 12:27:39 -07:00
Collin Funk
56eaa4ffc3 tests: date: add tests for the Ethiopian calendar
* tests/date/date-ethiopia.sh: New file.
* tests/local.mk (all_tests): Add the test.
2025-07-23 07:49:49 -07:00
Collin Funk
a9cd174811 tests: date: add tests for the Solar Hijri calendar
* tests/date/date-iran.sh: New file.
* tests/local.mk (all_tests): Add the test.
2025-07-23 07:49:49 -07:00
Pádraig Brady
5a106af2d6 install: with -d, use more accurate diagnostics
* gnulib: Update to latest to get the fix to
propagate the appropriate error message.
* tests/install/basic-1.sh: Add a test case.
* NEWS: Mention the bug fix.
Addresses https://bugs.gnu.org/79072
2025-07-22 21:15:17 +01:00
Collin Funk
5ab05e5a36 tests: date: add tests for the Thai solar calendar
* tests/date/date-thailand.sh: New file.
* tests/local.mk (all_tests): Add the test.
2025-07-21 21:25:58 -07:00
Collin Funk
027855dcad doc: NEWS: mention that 'date' now supports non-Gregorian calendars
Suggested by Bruno Haible in:
<https://lists.gnu.org/r/bug-gnulib/2025-07/msg00091.html>.

* NEWS: Mention the improvement.
2025-07-21 15:04:53 -07:00
Collin Funk
1b98590037 build: update gnulib submodule to latest
* bootstrap: Update using './bootstrap --bootstrap-sync'.
2025-07-21 14:43:59 -07:00
Bruno Haible
4a3eb45d72 date: update documentation regarding non-Gregorian calendars
* doc/coreutils.texi (Calendars): New section.
2025-07-21 21:18:25 +01:00
Bruno Haible
c3cea90de3 date: force a Gregorian calendar for options --iso-8601 and --rfc-3339
* src/date.c (show_date_helper): Add a use_c_locale parameter.
(batch_convert): Add a format_in_c_locale parameter.
(main): Set format_in_c_locale to true if any of the options --rfc-3339,
--iso-8601, -R is seen.
2025-07-21 21:16:03 +01:00
Pádraig Brady
083f89528e tests: sort: add a test for equivalent floats
* tests/sort/sort-float.sh: Ensure equivalent floats
are treated as such.
2025-07-12 19:58:06 +01:00
Paul Eggert
3a9ec02138 tests: fix fraction comparison in sort-float
Problem reported by Cosima Neidahl <https://bugs.gnu.org/78985#13>.
* tests/sort/sort-float.sh: At top level, use C locale at first.
(dbl_minima_order): Assume C locale.
Use string comparison for the fractional parts.

2025-07-10  Paul Eggert  <eggert@cs.ucla.edu>

tests: fix integer overflow in sort-float
Problem reported by Cosima Neidahl <https://bugs.gnu.org/78985>.
* tests/sort/sort-float.sh (dbl_minima_order):
Use expr instead of test, to avoid problems with integers
too large for the shell.
2025-07-11 14:45:04 -07:00
Paul Eggert
8f9fc8f08c tests: fix integer overflow in sort-float
Problem reported by Cosima Neidahl <https://bugs.gnu.org/78985>.
* tests/sort/sort-float.sh (dbl_minima_order):
Use expr instead of test to compare fractions,
to avoid problems with integers too large for the shell.
2025-07-10 10:18:06 -07:00
Paul Eggert
1dda42fa58 factor: remove SINGLE_WORKS
* src/factor.c (SINGLE_WORKS): Remove, and remove its use,
as the buggy code that it is referring to has been removed.
2025-07-09 22:27:29 -07:00
Paul Eggert
5b2ddab2d3 factor: use 64-bit internal counters
* src/factor.c (factor_using_pollard_rho)
(factor_using_pollard_rho2, mp_factor_using_pollard_rho):
Use int_fast64_t for internal counters rather than int, as int
could overflow on some somewhat-practical examples.  Problem
discovered on a hypothetical platform where W_TYPE_SIZE is neither
32 nor 64, when factoring 0x7ffffffffffffeab7fffffffffff7369 ==
170141183460469225450570946617781744489, causing k to overflow in
mp_factor_using_pollard_rho.  Presumably a similar problem exists
in the previous stable coreutils 9.7, too, on 32-bit platforms
with somewhat-larger test cases, though I haven’t take the
somewhat-extensive CPU time to discover it.
2025-07-09 22:01:42 -07:00
Paul Eggert
4171ca3353 factor: fix mp_factor_using_pollard_rho aliasing
* src/factor.c (mp_factor_using_pollard_rho):
Fix recently-introduced aliasing bug by computing q
before g gets updated in place.  Problem discovered
on a hypothetical platform where W_TYPE_SIZE
is neither 32 nor 64.
2025-07-09 22:01:42 -07:00
Paul Eggert
5fde9ad14b maint: fix apostrophe in old NEWS 2025-07-09 17:12:40 -07:00
Paul Eggert
bbca1c106c factor: speed up converting strings to uuint
* src/factor.c: Do not include c-ctype.h.
(strtouuint): Don’t bother generating a number on
error; just return a strtol_error value other than LONGINT_OK.
Speed up overflow checking.
2025-07-09 17:12:40 -07:00
Paul Eggert
035b837146 factor: simplify primes table
* src/factor.c (primes_ptab): New table of primes, replacing
primes_diff and primes_diff8.  All uses changed.  This is simpler
and should improve performance slightly.  Although this limits the
table’s primes to 2**15 instead of to 668221, the limit can easily
grow to 2**32 by changing the type of ‘prime’, without hurting
performance significantly compared to the primes_diff and
primes_diff8 approach.
* src/make-prime-list.c (output_primes):
For each prime p, output p instead of two differences.
2025-07-09 17:12:40 -07:00
Paul Eggert
b754d14117 factor: prefer false for boolean 0
* src/factor.c: Prefer false to 0 for booleans.
2025-07-09 17:12:40 -07:00
Paul Eggert
d658d121c3 maint: port speedgen to FreeBSD 15
* src/speedgen: Avoid ‘trap 'command' ERR’, as ERR
does not conform to POSIX and does not work in
FreeBSD 15 sh.
2025-07-09 17:12:40 -07:00
Paul Eggert
ef456bef37 factor: speed up Pollard-rho loop counters
* src/factor.c (factor_using_pollard_rho)
(factor_using_pollard_rho2, mp_factor_using_pollard_rho):
Use int, not unsigned long int, for counters that won’t go above
2**31 on practical platforms.  This yields a significant speedup
on GCC 15 x86-64, and using signed values allows for automatic
checks for overflow when using gcc -fsanitize=undefined.
2025-07-09 17:12:40 -07:00
Paul Eggert
033a50af8b factor: avoid an mpz init+clear
* src/factor.c (mp_factor_insert_ui): Rename fom
mp_factor_insert_ui, and change arg type from unsigned long int to
mp_limb_t.  All uses changed.  This avoids creating and freeing a
small mpz_t.
(mp_factor_using_division): Add a static assert requiring that
that mp_limb_t be wide enough, which it should be (and is in
standard GMP).
2025-07-09 17:12:40 -07:00
Paul Eggert
2ba4216441 factor: Pollard-rho a is now mp_limb_t
* src/factor.c (factor_using_pollard_rho)
(factor_using_pollard_rho2): Use mp_limb_t, not unsigned long int,
for a parameter.  This avoids some casts, and avoids a theoretical
bug where converting to mp_limb_t loses info.
2025-07-09 17:12:40 -07:00
Paul Eggert
d4cff38776 factor: redo ge2 in terms of lt2
lt2 a bit more natural, given the current implementation.
* src/factor.c (lt2): New function.
(ge2): Rewrite in terms of lt2.
(gt2): Remove.  All callers changed to use lt2.
2025-07-09 17:12:40 -07:00
Paul Eggert
d70e07668c factor: speed up umul_ppmm when !USE_LONGLONG_H
* src/factor.c (umul_ppmm): When !USE_LONGLONG_H so we need to
define this, speed things up if there is an unsigned type uuroom_t
wide enough to hold two words.  Do not make a similar change for
udiv_qrnnd, as it is not performance critical and anyway on GCC 15
x86-64 that would mean a subroutine call.
2025-07-09 17:12:40 -07:00
Paul Eggert
e16d3f38f3 factor: streamline gcd2_odd
* src/factor.c (gcd2_odd): Omit a gt2 and adjusts other
tests accordingly.  Omit duplicate code that makes A odd.
2025-07-09 17:12:40 -07:00
Paul Eggert
37fbbc5373 factor: faster gcd_odd since 2nd is odd
* src/factor.c (gcd_odd, gcd2_odd): Speed up, given that the
second argument is always odd.
(gcd_odd): Avoid recomputing a temporary.
(gcd2_odd): Test for zero only if a multiple of B.
This saves an ‘assume’.
2025-07-09 17:12:40 -07:00
Paul Eggert
2ce3fc0c1b doc: update ‘factor’ benchmarks 2025-07-09 17:12:40 -07:00
Paul Eggert
3ee25abfd3 factor: prefer exact division
* src/factor.c (mp_factor_using_division, mp_factor_using_pollard_rho):
Use exact division when it suffices, as it’s typically faster.
2025-07-09 17:12:40 -07:00
Paul Eggert
73bb62f7df factor: tune submod2
* src/factor.c (submod2): Use ckd_sub to subtract by hand rather
than using sub_ddmmss plus a compare.  This speeds things up a
bit, on x86-64 with GCC 15 anyway.
2025-07-09 17:12:40 -07:00
Paul Eggert
b0c58a8b29 factor: DELIM and DIVBLOCK no longer macros
* src/factor.c (DELIM): Now a constant, not a macro.
(divblock): Now a static inline function, not a macro DIVBLOCK.
All uses changed.
2025-07-09 17:12:40 -07:00
Paul Eggert
d4bc32a5ff factor: simplify by assuming !PROVE_PRIMALITY
* src/factor.c (PROVE_PRIMALITY, mp_millerrabin): Remove.
All uses removed, and surrounding code simplified.
2025-07-09 17:12:40 -07:00
Paul Eggert
a29d128162 factor: simplify by assuming USE_BAILLIE_PSW
* src/factor.c (make_uuint2, powm, powm2, millerrabin)
(millerrabin2, USE_BAILLIE_PSW): Remove; no longer used.
(prime_p, prime2_p): Simplify by assuming USE_BAILLIE_PSW.
2025-07-09 17:12:40 -07:00
Paul Eggert
5bab674646 factor: prime comments
* src/factor.c: Add comments re prime functions.
2025-07-09 17:12:40 -07:00
Paul Eggert
fb20a7d3e4 factor: no ferror+fclose
* src/make-prime-list.c (main): Avoid parallel calls
to ferror and fclose.
2025-07-09 17:12:40 -07:00
Paul Eggert
86bddb0d53 factor: define SQUARE_OF_FIRST_OMITTED_PRIME
* src/make-prime-list.c (output_primes): Output
SQUARE_OF_FIRST_OMITTED_PRIME, not FIRST_OMITTED_PRIME.  All uses
changed.  This way, the uses don’t need to worry about casts to
avoid overflow.
2025-07-09 17:12:40 -07:00
Paul Eggert
a9a8e0db47 factor: simplify add_ssaaaa default
* src/factor.c (add_ssaaaa): Simplify default implementation.
2025-07-09 17:12:40 -07:00
Paul Eggert
7cbc6c55cc factor: speed up ge2, gt2
* src/factor.c (ge2, gt2): Now branchless static functions.
2025-07-09 17:12:40 -07:00
Paul Eggert
097760c3de factor: improve millerrabin2 API
* src/factor.c (make_uuint2): New function.
(powm2, millerrabin2): Pass two-word args as uuints,
not as mp_limb_t const [2] pointers.  All uses changed.
(prime2_p): Rework to use the new API, fixing a FIXME.
2025-07-09 17:12:40 -07:00
Paul Eggert
d3db83b879 factor: put FACTORS first
* src/factor.c (factor_using_division, mp_finish_up_in_single)
(mp_finish_in_single, factor_using_pollard_rho)
(factor_using_pollard_rho2, factor_up, factor):
Put FACTORS arg first, for consistency.
This is just a refactoring and should not affect speed.
2025-07-09 17:12:40 -07:00
Paul Eggert
4e2aeb31e0 factor: use 1-word code only when tested
* src/factor.c (print_factors): Use single-precision code only
when word size is 32 or 64, as it isn't tested for other sizes and
is known to not work when it the size is 128.  This change does
not affect any known practical platforms.
2025-07-09 17:12:40 -07:00
Paul Eggert
8eb114f080 factor: decrement Miller-Rabin tests from 25 to 24
This avoids some seemingly-unnecessary code in mpz_probab_prime_p.
* src/factor.c (MR_REPS): Shrink from 25 to 24, and add commentary.
2025-07-09 17:12:40 -07:00
Paul Eggert
5037ce930c factor: don’t prove primality
Suggested for consideration by Torbjörn Granlund in:
https://lists.gnu.org/r/coreutils/2025-01/msg00000.html
* src/factor.c (PROVE_PRIMALITY): Now defaults to false.
(mp_prime_p): Help the compiler by telling it mpz_prob_prime_p
returns nonnegative.
* tests/factor/create-test.sh (bigprime): Test 2^400 - 593,
since that’s now practical.
* tests/local.mk (factor_tests): Add new test.
2025-07-09 17:12:40 -07:00
Paul Eggert
f726827e1f factor: add comments to factor.c 2025-07-09 17:12:39 -07:00
Paul Eggert
30b7851cdf factor: always use Baillie-PSW
* src/factor.c (USE_BAILLIE_PSW): New constant.
(prime_p, prime2_p): Use it, i.e., always use Baillie-PSW.
Do so by using mp_prime_p.  Do not tell GCC these functions
are pure; the pure mark was present only to pacify GCC
and is no longer needed now that thes functions call mp_prime_p.
2025-07-09 17:12:39 -07:00
Paul Eggert
3d442fd824 build: update gnulib submodule to latest 2025-07-09 17:12:39 -07:00
Paul Eggert
a76600cda2 factor: use mpz_probab_prime_p
Inspired by a proposal by Torbjörn Granlund in:
https://lists.gnu.org/r/coreutils/2025-01/msg00000.html
* src/factor.c (mp_prime_p): Use mpz_probab_prime_p rather than doing
it by hand, as mpz_probab_prime_p uses Baillie-PSW which is a win.
This removes the need for the ret2 label and goto.
2025-07-09 17:12:39 -07:00
Paul Eggert
5d3fdfd04b factor: don’t give up before last prime in table
* src/factor.c (prime_p, prime2_p, mp_prime_p): Do not skip the
flag_prove_primality test for the last prime in the table, i.e.,
when r == PRIMES_PTAB_ENTRIES - 1.
(mp_prime_p): There is no longer a need for the ret1 label or goto.
2025-07-09 17:12:39 -07:00
Paul Eggert
38c63d58d0 factor: move prime_p local in
* src/factor.c (mp_prime_p): Refactor by moving local further in.
2025-07-09 17:12:39 -07:00
Paul Eggert
bdd13ff8c0 factor: port back to mini-gmp
mini-gmp lacs mpn_tdiv_qr, so supply an emulation of it
when using mini-gmp.
* src/factor.c (copy_mpn_from_mpz, mpn_tdiv_qr) [!mpn_tdiv_qr]:
New functions.
2025-07-09 17:12:39 -07:00
Paul Eggert
442c164ae0 factor: speed up multiprecision Pollard’s rho
These changes are taken from a proposal by Torbjörn Granlund in:
https://lists.gnu.org/r/coreutils/2025-01/msg00000.html
On my x86-64 platform, they improve speed by more than 8× when
factoring 340282366920938463463374607431768211457.
* src/factor.c (mp_modadd, mp_modsub, mp_modadd_1, mp_mulredc):
New functions.
(MP_FACTOR_USING_POLLARD_RHO_N_MAX): New macro.
(mp_factor_using_pollard_rho): Act on mpn not mpz, and on
mp_limb_t not unsigned long int.  Reorder args.  All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
54a2d18b1f factor: use function for binv
* src/factor.c (binv_limb): New function, replacing the old
binv macro.  All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
20beab12df factor: use a more functional style
This is mostly to make the code a bit easier to read.
It shrinks the size of factor.o by 0.7% on my x86-64 platform
though it doesn’t affect CPU performance significantly.
* src/factor.c (mp_no_factors): Rename from mp_factor_init.
(mp_no_factors, mp_factor_using_division, mp_factor):
Return struct mp_factors rather than modifying one passed by reference.
All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
d16059e375 factor: use single vector in struct mp_factors
* src/factor.c (struct mp_factor): New type.
(struct mp_factors): Use it to replace P and E with F.
All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
6e87c9b3a3 factor: omit unnecessary divisions by small primes
* src/factor.c (mp_factor_using_division):
When continuing in single precision, don’t divide by primes that
were already cast out in multiple precision.
On my platform this gave a 2.5% speedup when factoring
2**128 + 172261 = 4999 * 68070087401668026297934508388031283,
as W_TYPE_SIZE == 64 and 4999 is the last prime in the primes table.
2025-07-09 17:12:39 -07:00
Paul Eggert
f7d295d941 factor: use primes_diff more consistently
* src/factor.c (mp_factor_using_division): Use index into
primes_diff consistently with other uses.  This is mostly just a
style change, and likely doesn’t change the generated machine code.
2025-07-09 17:12:39 -07:00
Paul Eggert
748d03ca12 factor: refactor to for later performance speedup
This does not affect performance much, but it should allow future
performance improvements.
* src/factor.c (factor_using_division): Two new args I and P,
which generalize this function.  All uses changed.
(mp_finish_up_in_single, factor_up): New functions, like the
non-*_up* versions but with two new args PRIME_IDX and PRIME.
They mostly just have the old body of the old non-*_up_ versions.
(mp_finish_in_single, factor): Rewrite in terms of the new functions.
2025-07-09 17:12:39 -07:00
Paul Eggert
831623ba66 factor: switch from mp to single when doable
This significantly improves performance when a number exceeds
2**(W_TYPE_SIZE - 1) and is the product of a prime less than
FIRST_OMITTED_PRIME and another prime less than 2**(W_TYPE_SIZE - 1).
On my platform, for example, it doubled the speed of factoring
4999 * (2**128 - 159).
* src/factor.c (mp_size, mp_finish_in_single): New functions.
(mp_factor_using_division, mp_factor_using_pollard_rho):
Finish using single precision when possible.
* tests/factor/factor.pl (lt-5000-times-128-bit): New test.
2025-07-09 17:12:39 -07:00
Paul Eggert
845f3a6158 factor: primes_diff idx type consistency
* src/factor.c (factor_insert_refind):
Use idx_t for indexes into primes_diff,
for consistency with other indexes into primes_diff.
This has no practical effect unless the primes_diff
table becomes unreasonably large.
2025-07-09 17:12:39 -07:00
Paul Eggert
fd458798fe factor: omit q from mp_factor_using_division
* src/factor.c (mp_factor_using_division): Remove unused local.
2025-07-09 17:12:39 -07:00
Paul Eggert
64b860c2f7 factor: mp insert multiplicity too
Support a multiplicity argument in the mp case, too.
This helps keeps the two cases in sync, for maintenance.
* src/factor.c (mp_factor_insert, mp_factor_insert_ui):
New arg M, for multiplicity.  All callers changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
258392808c factor: prefer non-macros
Use something other than a macro when that is easy and won’t hurt
performance.
* src/factor.c (__ll_B, __ll_lowpart, _ll_highpart) [!USE_LONGLONG_H]:
(MAX_NFACTS, highbit_to_mask, factor_insert, PRIMES_PTAB_ENTRIES):
Make these enums, or constants, or static functions instead of macros.
(highbit_to_mask): Rename from HIGHBIT_TO_MASK.  All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
fe136a9800 factor: let builder specify MR_REPS
* src/factor.c (MR_REPS): Let the builder specify it
with -DMR_REPS=whatever.
2025-07-09 17:12:39 -07:00
Paul Eggert
3e438e369c factor: add comments 2025-07-09 17:12:39 -07:00
Paul Eggert
77717f597e factor: factor insertion simplifications
* src/factor.c (factor_insert_multiplicity):
Adjust to keep in sync with mp_factor_insert changes below,
by adding 1 to the index and using memmove to move.
(mp_factor_insert): Omit redundant call to mpz_cmp.
Prefer idx_t (always nonnegative) to ptrdiff_t,
by adding 1 to the indexes.
Prefer mpz_init_set to mpz_init+mpz_set.
Use memmove to move, rather than doing it by hand.
2025-07-09 17:12:39 -07:00
Paul Eggert
374f5fdcc1 factor: check unsigned char counts
* src/factor.c (MAX_NFACTS): Allow word size of 128 bits,
even if this is only theoretical now.
Check that struct factors’s unsigned char counts won’t overflow.
2025-07-09 17:12:39 -07:00
Paul Eggert
5ae141ae14 factor: fix comment 2025-07-09 17:12:39 -07:00
Paul Eggert
a25d188098 factor: paren cleanup
* src/factor.c (umul_ppmm, udiv_qrnnd, addmod, addmod2, submod2)
(binv, divexact_21, redcify2, div_smallq): Omit unnecessary parens.
2025-07-09 17:12:39 -07:00
Paul Eggert
f14ddcb1ef factor: simplify longlong.h setup
* src/factor.c (USE_LONGLONG_H):
Default to false on unusual (but standard-conforming)
platforms that lack int64_t etc.
(UWtype, UHWtype): Now typedefs, not macros.
(UQItype): Remove.
(SItype, USItype, DItype, UDItype): Use standard C types.
2025-07-09 17:12:39 -07:00
Paul Eggert
0a5d071967 factor: prefer uuint to two words in a couple of places
This simplifies things slightly by using uuint for
some two-word integers.
* src/factor.c (strtouuint): Accept uuint *, not two mp_limb_t *.
All callers changed.
(print_factors_single): Accept uuint, not two limbs.
All callers changed.
(print_factors): Use simpler test for high bit,
one that need not worry about promoting to int.
2025-07-09 17:12:39 -07:00
Paul Eggert
59421d373b factor: FALLTHROUGH instead of break
* src/factor.c (print_factors): Use FALLTHROUGH
to make it clear that the "Use GMP" comment also applies here.
2025-07-09 17:12:39 -07:00
Paul Eggert
e7c1abfe79 factor: remove wide_uuint
Simplify by using GMP’s word type instead of pretending to roll our own.
* src/factor.c (wide_uuint): Remove.  All uses replaced by mp_limb_t.
(umul_ppmm) [!umul_ppmm]: Don’t assume unsigned long is at least half
as wide as mp_limb_t.  This simpler anyway.
(strtouuint): Rename from strto2wide_uint.  All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
d6ee61e407 factor: use same word size as GMP
Remove experimental code for 128-bit words as it does not work and
we lack time to figure out why.  Instead, ensure that words are
the same size as with GMP.
* src/factor.c (USE_INT128): Remove.  All uses removed.
(wide_uint, W_TYPE_SIZE): Define to be the same as GMP.
(MP_LIMB_MAX): New macro.  Check that it matches W_TYPE_SIZE.
(USE_LONGLONG_H): Default to true.
(UHWtype) [USE_LONGLONG_H]: Define to unsigned int, same as GMP.
(prime_p): Go back to not worrying about 128-bit words,
since GMP doesn’t worry and doesn’t use them.
(lbuf_putbitcnt): New function, since we cannot assume
that bitcnt_t fits into mp_limb_t.
(print_factors): Use it.
* src/make-prime-list.c (output_primes):
Don’t assume that wide_uint’s maximum is UINTMAX_MAX.
2025-07-09 17:12:39 -07:00
Paul Eggert
c8af57b5b8 factor: unsigned long → mp_bitcnt_t
* src/factor.c (struct mp_factors): e (multiplicity) member
is now of type mp_bitcnt_t, not unsigned long int, since
its value is at most a bit count.  All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
badc24c30c factor: fix test case name
* tests/factor/factor.pl (bug-gmp-plus_2_sup_127_plus_1):
Rename from bug-gmp-plus_2_sup_128_plus_1, so that
it accurately reflects the test case.
2025-07-09 17:12:39 -07:00
Paul Eggert
bdccb27ca6 factor: generalize BIG_POWER_OF_10
* src/factor.c (BIG_POWER_OF_10, LOG_BIG_POWER_OF_10):
Place fewer restrictions on BIG_POWER_OF_10.
This is only for currently-theoretical hosts;
it shouldn’t affect machine code on practical platforms.
2025-07-09 17:12:39 -07:00
Paul Eggert
88cca5d5fc factor: remove wide_int
* src/factor.c (wide_int): Remove, since it gets in the
way of using mp_limb_t for words.  All uses removed.
(submod2, HIGHBIT_TO_MASK, divexact_21):
Rewrite without using wide_int.
This shouldn't change the machine code these days,
as compilers are pretty smart about isolating the
top bit of an unsigned int.
2025-07-09 17:12:39 -07:00
Paul Eggert
397d9b02a3 factor: add platform sanity check
* src/factor.c: Check against theoretical platform.
2025-07-09 17:12:39 -07:00
Paul Eggert
8ff11d626b factor: squfof cleanup
* src/factor.c (USE_SQUFOF, STAT_SQUFOF):
Assume these are always false, and simplify the code accordingly.
We can bring it back later if needed be.
2025-07-09 17:12:39 -07:00
Paul Eggert
d7fd90d22d factor: don’t used uninitialized uu[0]
In practice there’s no bug but we might as well avoid the
undefined behavior.
* src/factor.c (hi_is_set): New static function.
(factor_insert_large, prime2_p, print_factors_single): Use it.
2025-07-09 17:12:39 -07:00
Pádraig Brady
fd59e4a955 build: avoid make distcheck error
* src/local.mk: Similarly to commit v8.22-156-g09937e9d0
track speedlist.h with nodist_src_stty_SOURCES and DISTCLEANFILES
to ensure the make distcheck manifest comparison passes.
Addresses https://bug.gnu.org/78960
2025-07-05 22:14:08 +01:00
Collin Funk
2230933f84 doc: fix a dead link
* doc/coreutils.texi (Block Size): Use an updated link to SI prefixes.
2025-07-05 09:57:29 -07:00
Pádraig Brady
1485eabfdd build: fix non parallel VPATH builds
* src/local.mk: Use the coarser BUILT_SOURCES mechanism
to generate speedlist.h, rather than a specific dependency
(which did seem to work for parallel builds).
Fixes https://bugs.gnu.org/78960
2025-07-05 12:49:02 +01:00
Collin Funk
e34a79a034 maint: prefer endian.h macros to WORDS_BIGENDIAN, part 2
* src/blake2/blake2-impl.h: Include endian.h. Use BYTE_ORDER and
LITTLE_ENDIAN instead of WORDS_BIGENDIAN.
2025-07-04 20:52:37 -07:00
Collin Funk
991934d9c9 maint: prefer endian.h macros to WORDS_BIGENDIAN
* src/od.c: Include endian.h.
(WORDS_BIGENDIAN): Remove definition.
(main): Use BYTE_ORDER, BIG_ENDIAN, LITTLE_ENDIAN instead of
WORDS_BIGENDIAN. Fix formatting.
2025-07-04 10:59:39 -07:00
Collin Funk
4db08f928e maint: add files generated by 'make ps' to .gitignore
* doc/.gitignore (/coreutils.ps, /coreutils.t2d/): Add entries.
2025-07-02 19:01:27 -07:00
Collin Funk
9cb89ff084 doc: remove outdated TODO/FIXME items
* TODO: Remove note about missing documentation for 'pinky' and '['.
* doc/coreutils.texi: Likewise.
2025-07-02 18:51:02 -07:00
Pádraig Brady
8771957703 tests: cat: add test for O_APPEND bug fix
* tests/cat/cat-self.sh: Add a test case
for commit v9.6-19-g7386c291b
2025-07-01 23:32:31 +01:00
Pádraig Brady
ab21f2e95e doc: remove extraneous double quotes within @samp{}
* doc/coreutils.texi (df invocation): @samp{} items
are suitably quoted already.
2025-07-01 12:02:08 +01:00
Collin Funk
1535ac272e doc: use ``...'' instead of "..."
* doc/coreutils.texi (split invocation): Use ``...'' for quoting text.
(cksum common options): Likewise.
(Control): Likewise.
2025-06-30 19:50:58 -07:00
Pádraig Brady
0512608a44 tests: avoid false failure due to varied ERANGE errors
* tests/od/od.pl: Use the system error string for ERANGE,
rather than hardcoding a particular one.
Fixes https://bugs.gnu.org/78934
2025-07-01 00:03:30 +01:00
Paul Eggert
48281e56a3 od: port to Apple clang 14
* src/od.c (print_function_type): New type.  Use it for convenience.
(width_bytes): Omit duplicate entries, such as ‘double’ vs ‘long
double’ on macOS.  Problem reported by Bruno Haible
<https://bugs.gnu.org/78933>.
(decode_one_format): Cast null pointer to print_function_type
to pacify Apple clang-1400.0.29.202.
2025-06-30 15:41:47 -07:00
Pádraig Brady
017fc50bb6 build: fix VPATH builds with --enable-single-binary
* src/local.mk: Adjust the dependency so that speedlist.h
is built irrespective of the object file name.
Note we could use BUILT_SOURCES for this,
but it's better to have this more accurate dependency.
2025-06-30 16:03:44 +01:00
Pádraig Brady
87dcd447b1 od: reinstate half float validation check
Reinstate check removed in commit 56aa549a0 so that we
disallow -f2 when configured with utils_cv_ieee_16_bit_supported=no.
Otherwise the output routines will consume floats,
i.e. 4 bytes at a time.  Without this extra check
the tests/od/od-endian.sh will fail with this configuration.

* src/od.c (decode_one_format): Reinstate the explicit check
for this configuration edge case.
2025-06-30 14:34:55 +01:00
Pádraig Brady
9075b2b8d2 maint: avoid sc_prohibit-quotearg failure
* src/od.c (parse_old_offset): s/quotearg_colon/quotef/.
2025-06-30 13:10:59 +01:00
Paul Eggert
5c5f069a4c od: add test cases for recent fix
* tests/od/od.pl: New tests for the offset issues
2025-06-29 22:32:05 -07:00
Paul Eggert
9002c04ccc od: more minor fixes for offsets
* src/od.c (parse_old_offset): Reject invalid offsets like "++0".
Treat overflowing offsets as errors, not as file names.
2025-06-29 22:26:14 -07:00
Paul Eggert
617220e970 od: refactor parse_old_offset
* src/od.c (parse_old_offset): Refactor for brevity and clarity.
2025-06-29 22:26:14 -07:00
Paul Eggert
3eb731e8ab maint: fix version in NEWS
* NEWS: Update version number as per Jim Meyering
<https://bugs.gnu.org/78880#46>.
2025-06-29 17:14:48 -07:00
Paul Eggert
dcdb2550c4 od: pacify gcc -Wduplicated-cond
Problem reported by Pádraig Brady <https://bugs.gnu.org/78880#43>.
This patch doesn’t fix any bugs; it merely pacifies GCC.
* src/od.c (ispec_to_format): New function, replacing
the old ISPEC_TO_FORMAT macro.  All uses changed.
This part of the change is just refactoring.
(decode_one_format): Pacify à la ispec_to_format.
2025-06-29 17:14:48 -07:00
Paul Eggert
25454fa34d od: be more consistent re sizeof
* src/od.c (width_bytes, decode_one_format): Don’t assume a signed
type has the same size as the corresponding unsigned type.
This has no effect on practical platforms; it’s just for
consistency there.
2025-06-28 21:00:41 -07:00
Paul Eggert
d5ea5e8aed od: fix integer overflow with large pseudos
* src/od.c (format_address_label): Diagnose overflow.
2025-06-28 21:00:41 -07:00
Paul Eggert
667be269ed od: speed up -S
* src/od.c (read_char): Use getc, not fgetc.
2025-06-28 21:00:41 -07:00
Paul Eggert
984dcc37f2 od: check sign bit more often
* src/od.c (read_char, dump_strings, main):
Instead of testing for an exact negative number,
just look at the sign bit.  This is a very minor tweak.
2025-06-28 21:00:41 -07:00
Paul Eggert
9aab4fb287 od: simplify away one loop copy
* src/od.c (dump): Coalesce two loops into one.
2025-06-28 21:00:41 -07:00
Paul Eggert
34b5043c6e od: simpler static initialization
* src/od.c (address_base, address_pad_len, format_address):
Initialize statically rather than dynamically.
(limit_bytes_to_format): Remove.  All uses replaced by
checking sign of end_offset.
(max_bytes_to_format): Remove static var.  Now local to ‘main’.
(end_offset): -1 now means no limit.  All uses changed.
2025-06-28 21:00:41 -07:00
Paul Eggert
0e104647a7 od: minor lcm tuning
* src/od.c (dump, main): Redo lcm calcuations to avoid a multiply.
2025-06-28 21:00:41 -07:00
Paul Eggert
56aa549a06 od: omit some duplicate code
On x86-64 (for example) print_long, print_long_long, and
print_intmax all behave identically, so give GCC enough info so
that it generates code for just one of these functions.
* src/od.c (enum size_spec): Arrange for enum values to
be the same if they represent types that behave the same.
(width_bytes, ISPEC_TO_FORMAT, decode_one_format):
Match the enum size_spec changes.
2025-06-28 21:00:41 -07:00
Paul Eggert
3ad59e19bc od: replace lookup tables with simple arithmetic
* src/od.c (FMT_BYTES_ALLOCATED): Use a simpler formula.
Although slightly too generous, the storage wasted is very small
and it pacifies gcc -Wformat-overflow=2.
(bytes_to_oct_digits, bytes_to_signed_dec_digits)
(bytes_to_unsigned_dec_digits, bytes_to_hex_digoits): Remove.
All uses replaced by algorithmic calculations, which are good
enough: they are valid for integers up to 2620 bits (!) and might
be slightly conservative for wider integers.  Remove related
static_asserts, which are no longer needed.
2025-06-28 21:00:41 -07:00
Paul Eggert
274226dbff od: support uintmax_t too
This has practical effect only on hypothetical platforms where
uintmax_t is wider than unsigned long long int.
* src/od.c (enum size_spec): New constant INTMAX.
(MAX_INTEGRAL_TYPE_WIDTH): Now equals UINTMAX_WIDTH.
(FMT_BYTES_ALLOCATED): Allow for the extra "l" in "%lld".
Also, fix off-by-two error in size calculation.
(width_bytes, integral_type_size): Add entries for uintmax_t.
(print_intmax): New function.
(decode_one_function): Use it.
(ISPEC_TO_FORMAT): New arg Max_fmt. All uses changed.
2025-06-28 21:00:41 -07:00
Paul Eggert
d8aaafc094 od: initialize type-size tables statically
* src/od.c (NO_SIZE): Make it explicitly 0, as the
initializers now rely on this.
(MAX_INTEGRAL_TYPE_SIZE): Remove.  All uses replaced by
ARRAY_CARDINALITY (integral_type_size) - 1.
Move static assertion down to where this can be used.
(integral_type_size, fp_type_size): Make them const,
and initialize them statically.
(main): Omit no-longer-needed initialization code.
2025-06-28 21:00:41 -07:00
Paul Eggert
4d527dda58 od: prefer intmax_t to uintmax_t
* src/od.c (MAX_ADDRESS_LENGTH, pseudo_offset, n_bytes_to_skip)
(max_bytes_to_format, end_offset, skip, format_address_none)
(format_address_std, format_address_paren, format_address_label)
(write_block, parse_old_offset, dump, dump_strings, main):
Prefer intmax_t to uintmax_t.  This makes no practical difference,
and lets -fsanitize=undefined check for signed integer overflow.
(skip, dump): Remove no-longer-needed casts.
(xstr2nonneg): New static function.  All callers of xstrtoumax
now call this function instead.
(main): Use ckd_add to detect signed integer overflow, since
the unsigned trick no longer works reliably.
Let xstrtol_fatal report the overflow, instead of doing
it by hand ourselves.
2025-06-28 21:00:41 -07:00
Paul Eggert
66464e61f5 od: fix '+N.' bug
* src/od.c (parse_old_offset): First arg is now char *,
not char const *.  If a decimal number, temporarily
modify the string so that xstrtoumax does not complain
about the '.'.
* tests/od/od.pl: Test for the bug.
2025-06-28 21:00:41 -07:00
Paul Eggert
88f30ee0a5 od: fix some unlikely integer overflows
* src/od.c (print_n_spaces, pad_at, pad_at_overflow):
New static functions.
(struct tspec, PRINT_FIELDS, print_named_ascii, print_ascii)
(decode_one_format, write_block, main):
Use idx_t, not int, for counts that depend on the number
of bytes in an object.
(decode_one_format): Use print_n_spaces to output spaces.
(PRINT_FIELDS, print_named_ascii, print_ascii):
Use pad_at to avoid integer overflow.
(write_block): Do not use %*s to pad, as the total pad might
exceed INT_MAX.  Instead, pad by hand with putchar (' ').
(main): Use pad_at_overflow to report integer overflow due to
oversize -w.  Use better way to tell whether -w is used,
without needing IF_LINT.
* tests/od/big-w.sh: New test.
* tests/local.mk (all_tests): Add it.
2025-06-28 21:00:41 -07:00
Paul Eggert
35d9bf6915 od: prefer idx_t to size_t
This helps find overflow bugs when compiling with -fsanitize=undefined.
* src/od.c (struct tspec, bytes_per_block, PRINT_FIELDS)
(PRINT_TYPE, print_named_ascii, print_ascii, decode_one_format)
(skip, write_block, read_block, dump, main):
Use idx_t, not size_t.
2025-06-28 21:00:41 -07:00
Paul Eggert
dbe4e2f428 od: don’t assume no holes in wide unsigned
Also, fix minor related typos.
* src/od.c (MAX_INTEGRAL_TYPE_SIZE, MAX_ADDRESS_LENGTH):
Now a constant, not a macro.
(MAX_INTEGRAL_TYPE_WIDTH): New constant.  Use it instead of
CHAR_BIT, so as not to assume that uintmax_t and unsigned long
long int are hole-free.  This doesn’t matter on practical porting
targets, though there is still a mainframe or two that have holes.
(FMT_BYTES_ALLOCATED): Fix typo by changing "jd" to "jo".
Fix off-by-one typo in static assertion.
2025-06-28 21:00:41 -07:00
Paul Eggert
671d79a0b7 maint: assume long long int
It’s long been safe to assume C99+ support for long long int.
* .gitignore: Remove m4/longlong.m4.
* bootstrap.conf (buildreq): Boost git prereq from 1.4.4 to 1.5.5,
syncing with Gnulib.
(bootstrap_post_import_hook): Remove m4/longlong.m4.
* m4/jm-macros.m4 (gl_CHECK_ALL_TYPES):
No need to require AC_TYPE_UNSIGNED_LONG_LONG_INT.
* src/factor.c (DItype, UDItype):
* src/od.c (main):
Assume HAVE_LONG_LONG_INT.
* src/od.c: (unsigned_long_long_int):
Remove.  All uses replaced with unsigned long long int.
2025-06-28 21:00:41 -07:00
Paul Eggert
69b07cc58d od: fix another off-by-one issue with --strings
* src/od.c (main): Fix off-by-one error in string_min limit.
2025-06-28 21:00:41 -07:00
Paul Eggert
0d1c25d1cb od: fix theoretical size_t malloc overflow
* src/od.c (dump, dump_strings): Use idx_t allocators
rather than size_t allocators, to avoid unchecked integer
overflow on theoretical platforms where SIZE_MAX < IDX_MAX.
2025-06-28 21:00:40 -07:00
Collin Funk
2a08ab2bd5 doc: list signals added by POSIX.1-2024
* doc/coreutils.texi (Signal specifications): Mention that POSIX.1-2024
added SIGWINCH.
2025-06-27 22:15:28 -07:00
Collin Funk
cc01e72491 doc: mention that POSIX.1-2024 added dd iflag=fullblock
* doc/coreutils.texi (dd invocation): Document that POSIX.1-2024 added
iflag=fullblock.
2025-06-27 20:10:09 -07:00
Pádraig Brady
7c2729cb58 doc: cksum: --check: improve supported formats description
* doc/coreutils.texi (cksum common options): Reorder and tweak the info
to make it clearer that --check does not support the legacy crc output
from the cksum command.
Reported at https://bugs.debian.org/1108363
2025-06-27 19:50:51 +01:00
Collin Funk
5a5b4a7810 maint: prefer UINTMAX_MAX to TYPE_MAXIMUM (uintmax_t)
* src/df.c (get_dev): Use UINTMAX_MAX.
* src/shred.c (dopass): Likewise.
2025-06-25 09:08:35 +01:00
Pádraig Brady
2b7f3621f8 od: output standard diagnostics for invalid -w arguments
* src/od.c (main): Don't pass LONGINT_OK to xstrtol_fatal(),
as otherwise it will abort().
* tests/od/od.pl: Add test cases.
* NEWS: Mention the bug fix.

Addresses https://bugs.gnu.org/78879
2025-06-24 16:37:01 +01:00
Pádraig Brady
44809c3379 od: fix various off-by-one issues with --strings with -N
* src/od.c (dump_strings): There are three related issues here
due to not accounting for the terminating NUL char appropriately.

1. Ensure BUF always has enough space for the terminating NUL.
This avoids CWE-122: Heap-based Buffer Overflow,
where we wrote a single NUL byte directly after the allocated buffer.
I.e., there should be no buffer overflow with:
  printf '%100s' | od -N100 -S1

2. Ensure we support -S == -N (END_OFFSET - STRING_MIN == ADDRESS):
I.e., there should be output with:
  printf '%100s' | od -N10 -S10

3. Ensure we always output a valid address by ensuring
the ADDRESS and I variables are kept in sync.
I.e., this should output address 0000000 not 1777777777777777777777:
  printf '%100s' | od -N10 -S1

As well as fixing these we simplify by using a single loop
to read the data, rather than two.

* doc/coreutils.texi (od invocation): Clarify that -N
implicitly NUL terminates strings.
* tests/od/od-N.sh: Add test cases.
* NEWS: Mention the bug fixes.

Fixes https://bugs.gnu.org/78880
2025-06-24 16:21:00 +01:00
Bruno Haible
63c040b879 build: fix compilation error on OpenBSD and Solaris
* src/speedgen: Use 'printf', not 'sed', to emit code with newlines.
2025-06-23 22:56:36 +01:00
H. Peter Anvin
7f82aef54e maint: make it clear when to add speeds to the speedgen list
Add a comment making it clear that it is perfectly safe to add
additional speeds to the canned list in the speedgen script, and under
what conditions it is appropriate to do so.

Signed-off-by: "H. Peter Anvin" (Intel) <hpa@zytor.com>
2025-06-23 22:15:27 +01:00
H. Peter Anvin
8c47af9be5 stty: support baud rate macro extraction on more compilers
For generating src/speedtest.h, try a sequence of command-line options
until (or unless) one of them works:

  -dM: gcc, clang and derived compilers, icc classic
  -xdumpmacros: Sun Studio (writes to stderr!)
  -qshowmacros: IBM XL classic
  -PD: MSVC (usable with a wrapper such as cccl from the SWIG project)

Because Sun Studio -xdumpmacros unconditionally writes to stderr,
capture stderr output instead of sending it to /dev/null. This is
perfectly safe, even in the presence of stray stderr output, because:

  1. speedgen ignores input that is not of the form #define B<number>
  2. even if a line of that format would somehow spuriously appear,
     the only outcome is that the generated C code will probe for a few
     more macros.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-06-23 22:13:51 +01:00
Collin Funk
c326f71230 stdbuf: support AIX
* src/stdbuf.c (set_LD_PRELOAD): Use the AIX specific environment
variables LDR_PRELOAD or LDR_PRELOAD64.
* NEWS: Mention the bugfix.
2025-06-23 13:16:32 +01:00
Pádraig Brady
3d35b3c0e5 stty: stricter floating point parsing
* src/stty.c (string_to_baud): Disallow extraneous characters
after floating point numbers.
* tests/stty/stty-invalid.sh: Add test cases.
2025-06-22 17:00:02 +01:00
Pádraig Brady
8b05eca972 doc: stty: adjust description of supported speeds
* doc/coreutils.texi (stty invocation): Remove now imprecise
list of speeds given we may now support higher or arbitrary speeds.
Mention that we may support higher or arbitrary speeds.
2025-06-22 15:01:21 +01:00
Collin Funk
b7db775783 build: add src/termios.c to the tarball
* src/local.mk (EXTRA_DIST): Add src/termios.c.
2025-06-22 11:33:16 +01:00
Collin Funk
1f6186b82c maint: use _GL_CMP instead of handwriting three-valued comparisons
* src/comm.c (compare_files): Use _GL_CMP.
* src/join.c (keycmp): Likewise.
* src/ls.c (off_cmp): Likewise.
* src/ptx.c (compare_words, compare_occurs): Likewise.
* src/set-fields.c (compare_ranges): Likewise.
* src/sort.c (compare_random, diff_reversed, compare): Likewise.
2025-06-22 11:33:11 +01:00
H. Peter Anvin
c00e4e2657 doc: NEWS: improve recent stty details
* src/NEWS: Fix grammar error,
and indicate baud rate probing is opportunistic.
2025-06-21 11:01:01 +01:00
Pádraig Brady
f40438900b tty: translate new error
* src/tty.c (main): Translate and adjust new ttyname() error
diagnostic, to be clearer and avoid a syntax check failure.
2025-06-21 10:59:46 +01:00
Paul Eggert
aec89a3e7d tty: better fix for Bug#26371
* src/tty.c (TTY_USAGE): Rename from TTY_FAILURE, since this
is used only for usage failures.  All uses changed.
(TTY_TTYNAME_FAILURE): New constant.
(main): Remove no-longer-needed assignment of ENOENT to errno.
Make status-setting clearer too.
Report an error if ttyname fails even though stdin is a terminal,
instead of silently pretending that stdin is not a terminal.
* tests/tty/tty.sh: Test for this issue.  This should fix Bug#78244.
2025-06-20 12:15:27 -07:00
Pádraig Brady
efaec80781 tests: stty: adjust tests for arbitary speeds
* tests/stty/stty-invalid.sh: Adjust to what is now invalid.
* tests/stty/stty.sh: Add checks for valid speed variants.
* tests/stty/bad-speed.sh: New test to ensure unsupported speeds
are diagnosed.
2025-06-18 14:21:30 +01:00
H. Peter Anvin
357fda90d1 stty: arbitrary or non-a priori known speed_t support
Support the case where speed_t is simply a number, and in that case
assume that arbitrary values can be passed.  This is assumed to be the
case when all known speed_t macros equal their own value.

Try to probe for a variety of speed_t constants by trying to coax
$(CC) into emitting macro definitions (-E -dM).  If this is not
supported, use a fairly extensive list of constants as a
fallback.  This both improves the test for arbitrary speed support, as
well as allowing proper operation in the case where the constants are
not plain numbers and allows for handing enumerated speed constants
that were not known a priori when the source code was written.

A simple shell script (mostly using sed) is used to turn the list of
constants (probed and predefined) into a pair of conversion functions,
baud_to_value() and value_to_baud(); string_to_baud() is then
reimplemented as a wrapper around the latter.

* src/.gitignore: Add generated speedlist.h.
* src/local.mk: Generate speedlist.h.
* src/speedgen: Portable shell script to generate speedlist.h.
* src/stty.c: Adjust string_to_baud to
convert from arbitrary numeric values.
* src/termios.c: A helper used when generating speedlist.h
* NEWS: Mention the improvement.
2025-06-18 14:20:17 +01:00
Paul Eggert
5c5e8b4a98 date: port test to NetBSD 10
Problem reported by Collin Funk in:
https://lists.gnu.org/r/bug-gnulib/2025-06/msg00094.html
* tests/date/date-debug.sh: Also allow NetBSD 10 mktime behavior.
Although NetBSD contradicts POSIX, POSIX is likely wrong here and
I vaguely recall that there’s a POSIX correction in progress
that will allow the NetBSD behavior.
2025-06-10 13:03:40 -07:00
Paul Eggert
276c04905f build: update gnulib submodule to latest
* tests/date/date-debug.sh: Update to match current behavior
of Gnulib's parse-datetime module.
2025-06-08 23:56:27 -07:00
Pádraig Brady
2f6a74920b doc: cp --help: mention --reflink=auto is now the default
* src/cp.c (usage): Reword the REFLINK description to
indicate that --reflink=auto is the default.
Fixes https://github.com/coreutils/coreutils/issues/103
2025-06-07 18:53:43 +01:00
Pádraig Brady
037b931061 doc: make command synopsis more consistent
* doc/coreutils.texi: Use @dots{} after [OPTION],
to be consistent with man pages.
* src/printenv.c (Usage): Remove unneeded "...".
* src/timeout.c (Usage): Add needed "...",
and also remove redundant [OPTION] only form.
* src/chroot.c (Usage): Likewise.
Fixes https://bugs.gnu.org/78628
2025-06-03 23:11:44 +01:00
Paul Eggert
4eb2ff1c89 cksum: port to Apple LLVM version 10.0.0
This compiler lacks support for the x86-64 VPCLMULQDQ instruction;
compiles fail with "error: invalid cpu feature string for builtin".
Problem reported by Peter Dyballa, and fix suggested by
Pádraig Brady <https://bugs.gnu.org/78562#8>.
* configure.ac (USE_AVX512_CRC32):
Also check that __builtin_cpu_supports ("vpclmulqdq") compiles.
2025-05-29 09:06:34 -07:00
Pádraig Brady
21a662b1ee tests: sort: expand multiple output testing
* tests/sort/sort.pl: Ensure duplicate
output strings are supported.
2025-05-28 21:11:34 +01:00
Paul Eggert
c8d75786b2 maint: assume O_DIRECTORY
Recent changes in Gnulib guarantee O_DIRECTORY != 0.
* gl/lib/targetdir.c (target_directory_operand):
* src/dd.c (usage):
* src/ln.c (main):
Simplify now that O_DIRECTORY must be nonzero.
2025-05-28 12:49:17 -07:00
Paul Eggert
c82b1f01ba build: update gnulib submodule to latest 2025-05-28 12:49:17 -07:00
Pádraig Brady
d3133bd38d maint: avoid a sc_system_h_headers failure
* cfg.mk: Also exclude libstdbuf.c from this check.
2025-05-24 22:01:44 +01:00
Paul Eggert
2b54fe97ff stdbuf: don’t allocate more than SIZE_MAX / 2
* src/libstdbuf.c (apply_mode): Be more conservative about
sizes passed to malloc, since we can’t rely on Gnulib malloc.
2025-05-24 13:02:31 -07:00
Paul Eggert
610725919c stdbuf: simplify apply_mode + getenv
* src/libstdbuf.c (apply_mode): Take getenv arg, not result.
All callers changed.  This is simpler.
2025-05-24 13:02:31 -07:00
Paul Eggert
69b1893585 stdbuf: port better to Mac OS X 10.4.11
Do not link to fchownat, fchmodat, xreallocarray.
While we’re at it, depend as little as possible on problematic
functions like fileno, strtoumax.  Use only functions that
were around in C89.
Problem reported by Peter Dyballa <https://bugs.gnu.org/78509#59>.
* src/libstdbuf.c: Include stddef.h, stdlib.h, gettext.h.
Do not include stdint.h or system.h.
(_): New macro, since we no longer include system.h.
Undef strtoul, not strtoumax.
(fileno_to_name): Remove.  All uses removed.
(apply_mode): New arg STREAM_NAME, so that we no longer need
to depend on fileno which might run into a Gnulib workaround.
Don’t allocate more than ULONG_MAX - 1 bytes, as that’s
not helpful in the real world and this lessens dependency
on newer features like strtoumax.
2025-05-24 13:02:31 -07:00
Pádraig Brady
dc4e6b6703 tests: avoid hung tests on older macOS
These tests were seen to hang on PPC Mac OS X 10.4.11

* tests/cp/existing-perm-race.sh: Protect fifo interactions
with a 1 minute timeout.
* tests/cp/file-perm-race.sh: Likewise.
Reported in https://bugs.gnu.org/78509
2025-05-21 21:22:08 +01:00
Pádraig Brady
8c9602e3a1 sort: fix buffer under-read (CWE-127)
* src/sort.c (begfield): Check pointer adjustment
to avoid Out-of-range pointer offset (CWE-823).
(limfield): Likewise.
* tests/sort/sort-field-limit.sh: Add a new test,
which triggers with ASAN or Valgrind.
* tests/local.mk: Reference the new test.
* NEWS: Mention bug fix introduced in v7.2 (2009).
Fixes https://bugs.gnu.org/78507
2025-05-20 19:36:00 +01:00
Paul Eggert
4469576154 maint: omit -Wmissing-variable-declarations from tests
* configure.ac (GNULIB_WARN_CFLAGS):
Omit -Wmissing-variable-declarations; needed for
gcc (GCC) 15.1.1 20250425 (Red Hat 15.1.1-1).
2025-05-18 23:34:51 -07:00
Pádraig Brady
1be322fd3e maint: avoid sc_preprocessor_indentation failure
* src/factor.c: Tweak preprocessor indentation.
2025-05-18 10:37:35 +01:00
Collin Funk
d8a7220142 build: generate src/crctab.c when building from git
* src/crctab.c: Remove file.
* src/cksum.c [!CRCTAB]: Include config.h.
* src/local.mk: Generate src/crctab.c in a temporary directory.
(EXTRA_DIST): Add src/crctab.c.
* .gitignore (/src/crctab.c): Add entry.
2025-05-18 09:49:29 +01:00
Collin Funk
dc6ce1d0c6 build: fix 'make distcheck'
* src/local.mk (EXTRA_DIST): Distribute src/make-prime-list.c
to satisfy the new make dependency.
2025-05-18 09:41:02 +01:00
Paul Eggert
fe51b33859 factor: fix bug with 128-bit uintmax_t
On so-far-only-theoretical platforms with 128-bit uintmax_t,
'factor' would misbehave by not factoring enough.
Work around the bug (at a performance cost)
and document the issue.  I hope someone with
more time and expertise can fix the performance cost
that this introduces.
To reproduce the correctness bug, build with
'gcc -DUSE_INT128 -DEXHIBIT_INT128_BUG';
'make check' should fail due to the new test case.
* src/factor.c (USE_INT128): New macro.
(wide_uint, wide_int, W_TYPE_SIZE, WIDE_UINT_MAX):
Define to proper values if USE_INT128.
(prime_p) [!EXHIBIT_INT128_BUG]: Work around bug
with 128-bit wide_uint, at some performance cost.
* tests/factor/factor.pl (bug-with-128-bit-uintmax_t):
New test.
2025-05-17 21:49:22 -07:00
Paul Eggert
c4fdbd95bd factor: refactor to allow non-uintmax_t ints
This prepares for using unsigned __int128 instead of uintmax_t.
It doesn’t change behavior.
* src/factor.c (wide_uint, wide_int):
New typedefs, replacing all uses of uintmax_t, intmax_t.
(WIDE_UINT_MAX): New macro, replacing all uses of UINTMAX_MAX.
(USE_LONGLONG_H): Don’t use LONG_MAX and INTMAX_MAX (which
should have been ULONG_MAX and UINTMAX_MAX anyway).
Instead, use W_TYPE_SIZE and ULONG_WIDTH, as that will be
easier to work with if we use unsigned __int128.
(binv): Also unroll for the 128-bit case.
* src/make-prime-list.c (print_wide_uint):
Print "wide_uint" not "uintmax_t".
2025-05-17 21:49:22 -07:00
Collin Funk
3844c15934 build: support cross-compiling directly from git checkout
* src/local.mk: Compile the make-prime-list in a temporary directory
using $(BUILD_CC) so it can be run even when $(CC) is a cross-compiler.
Add some comments.
(noinst_PROGRAMS): Remove src/make-prime-list.
(src_make_prime_list_LDADD): Remove variable.
* src/make-prime-list.c: Don't include config.h and attributes.h.
Remove unnecessary #undefs
(ATTRIBUTE_CONST, ATTRIBUTE_MALLOC): Define for the host compiler.
Fixes https://bugs.gnu.org/78377
2025-05-17 09:17:12 +01:00
Paul Eggert
c8cbb321d9 maint: --help now outputs bug reporting address
This changes the tail of "cat --help" output from:

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Full documentation <https://www.gnu.org/software/coreutils/cat>
or available locally via: info '(coreutils) cat invocation'

to:

Report bugs to: bug-coreutils@gnu.org
GNU coreutils home page: <https://www.gnu.org/software/coreutils/>
General help using GNU software: <https://www.gnu.org/gethelp/>
Full documentation <https://www.gnu.org/software/coreutils/cat>
or available locally via: info '(coreutils) cat invocation'

* src/system.h (emit_bug_reporting_address): Don’t #define.
(emit_ancillary_info): Call emit_bug_reporting_address
instead of doing it by hand, which omitted the bug reporting address.
2025-05-15 09:00:18 -07:00
Pádraig Brady
bd8be6b99e maint: avoid sc_gitignore_missing failure
* .gitignore: Add the soon to be generated lib/fts_.h
* cfg.mk (sc_gitignore_missing): Special case the mapping
of fts.in.h to fts_.h.
Fixes https://bugs.gnu.org/78398
2025-05-12 23:20:43 +01:00
Pádraig Brady
a11c7dcaaf doc: NEWS: fix introduced version of a bug
* NEWS: The NFSv4 trivial ACL ENOTSUP issue was introduced in 9.6.
2025-05-12 11:53:31 +01:00
Pádraig Brady
63e657e877 maint: avoid sc_GPL_version failure
* cfg.mk (VC_LIST_ALWAYS_EXCLUDE_REGEX): Exclude longlong.h also.
2025-05-12 11:51:16 +01:00
Collin Funk
d314730ea4 doc: suggest GNULIB_REFDIR instead of GNULIB_SRCDIR
* README-hacking: Use GNULIB_REFDIR instead of GNULIB_SRCDIR since that
is the correct way to have ./bootstrap do 'git clone --reference'.
2025-05-12 11:37:18 +01:00
Paul Eggert
8dd5b91d2c factor: check overflow with ckd_add etc
* src/factor.c (umul_ppmm, add_ssaaaa, sub_ddmmss, submod)
(mulredc, strto2wide_uint): Prefer ckd_add etc. to doing
overflow checking by hand.
2025-05-12 01:28:48 -07:00
Paul Eggert
229ddeb36a maint: pacify GCC when selinux is missing
* src/selinux.h (restorecon, defaultcon): Use MAYBE_UNUSED.
2025-05-12 01:28:48 -07:00
Paul Eggert
5e35f0e770 factor: be more cautious about C compiler versions
* src/factor.c (__GMP_GNUC_PREREQ): Define compatibly with GMP.
2025-05-12 01:28:48 -07:00
Paul Eggert
c1424ea25e maint: sync longlong.h from gmp
* .x-update-copyright: Add src/longlong.h.
* src/longlong.h: Sync from gmp.
2025-05-12 01:28:48 -07:00
Paul Eggert
4274ff6eee factor: omit incorrect affirms in mulredc2
* src/factor.c (mulredc2): Remove two ‘affirm’ calls that didn’t
match the accompanying comment, and one of which has a false
positive if UINTMAX_WIDTH == 128 and we factor 2**128 + 1.
2025-05-12 01:28:48 -07:00
Collin Funk
4ebc75a36f build: update gnulib submodule to latest
* bootstrap: Update using './bootstrap --bootstrap-sync'.
2025-05-11 10:20:59 -07:00
Paul Eggert
6bd4b1936e maint: update NEWS from Gnulib update 2025-05-09 22:36:19 -07:00
Paul Eggert
75258a69e9 build: update gnulib submodule to latest 2025-05-09 22:12:45 -07:00
Paul Eggert
36e83a6bcd maint: minor followon touchup of GCC warnings
* configure.ac (GNULIB_TEST_WARN_CFLAGS):
Do not use -Wsuggest-attribute=cold, -Wsuggest-attribute=const,
-Wsuggest-attribute=format as they produce false positives with
GCC 15 x86-64.  Use -Wmissing-variable-declarations, as it no
longer seems to hurt.
2025-05-09 21:02:56 -07:00
Paul Eggert
dbdb44de56 maint: modernize GCC warning configuration
* configure.ac: Simplify the setup of GCC’s -W... options,
by removing options no longer needed for GCC 15 (when
configuring with --enable-gcc-warnings) or GCC 12 (without).
I hope this is good enough nowadays.
Add GCC 15’s -Wtrailing-whitespace, since that works for us.
2025-05-09 15:57:13 -07:00
Paul Eggert
1fef50d07b maint: use MAYBE_UNUSED more consistently
* src/basenc.c (no_required_padding):
* gl/lib/smack.h (smack_new_label_from_self)
(smack_set_label_for_self):
* src/cksum.c (output_crc):
* src/digest.c (md5_sum_stream, sha1_sum_stream)
(sha224_sum_stream, sha256_sum_stream, sha384_sum_stream)
(sha512_sum_stream, sm3_sum_stream, output_file):
* src/stat.c (print_statfs, print_stat):
* src/sum.c (output_bsd, output_sysv):
* src/timeout.c (chld):
Mark possibly-unused parameters with MAYBE_UNUSED.
2025-05-09 15:57:13 -07:00
Paul Eggert
16d5cf3e66 maint: fix Automake warning
* Makefile.am (prologue): Remove macro, as \# is not portable here
and Automake complains.  Replace its only use with its definiens.
2025-05-09 15:57:13 -07:00
Pádraig Brady
6218cb18b0 tests: avoid false failures in user namespaces
* init.cfg (require_membership_in_two_groups_): Skip
overflow gids used in user namespaces, as one can't
chgrp() to these.
Fixes https://bugs.gnu.org/78225
2025-05-03 09:59:16 +01:00
Pádraig Brady
e7699b17b5 build: update to latest gnulib
* bootstrap.conf: Adjust for hash-triple module renaming.
* src/copy.c: Likewise.
* src/ln.c: Likewise.
* gnulib: Update to latest.
2025-05-01 14:05:59 +01:00
Pádraig Brady
3a5c9c5537 tests: add a test case for negative relative date
* tests/date/date.pl: To exercise option processing.
2025-04-23 12:47:54 +01:00
Pádraig Brady
948f4713fd tests: fix false failure with constrained setfacl
* tests/ls/acl.sh: In constrained environments, like with
setxattr() disabled for example, require_acl_ does not
check for the required functionality, so use the more
stringent require_setfacl_ instead.
Reported at https://github.com/NixOS/nixpkgs/issues/394953
2025-04-21 11:48:33 +01:00
Pádraig Brady
ca863e3f63 maint: map Jim's new email address
.mailmap: Add meta.com as an alias.
2025-04-19 13:46:23 +01:00
Paul Eggert
0d04b985d6 ls: omit a static var
* src/ls.c (file_has_aclinfo_cache): No need for unsupported_cached;
we can use unsupported_scontext.  Also, improve comments.
2025-04-12 13:00:24 -07:00
Pádraig Brady
356e40ff8e maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2025-04-09 12:14:12 +01:00
Pádraig Brady
8e075ff8ee version 9.7
* NEWS: Record release date.
2025-04-09 11:44:57 +01:00
Pádraig Brady
9ccabd8df3 tests: adjust csplit VM limit for CheriBSD
* tests/misc/csplit-heap.sh: More memory is required to avoid
a false failure on CheriBSD with its heap accounting overhead.
This is confirmed to still trigger with the original memory leak
being tested.
2025-04-08 16:07:06 +01:00
Pádraig Brady
7007c018de ls: support capabilities with device 0,0
* src/ls.c (has_capability_cache): Don't assume
a device major,minor of 0,0 never occurs.
2025-04-08 12:17:19 +01:00
Bruno Haible
0954e91fcf ls: fix crash of "ls -Z ." on OpenBSD's /dev/wd0a disk
* src/ls.c (file_has_aclinfo_cache): Add new static variable
'unsupported_cached'. Don't assume that device 0 never occurs.
2025-04-08 12:02:13 +01:00
Jim Meyering
42f6201aa5 build: use _GL_ATTRIBUTE_NONSTRING attribute to avoid new warnings
Avoid warnings like this from GCC 15:
src/basenc.c:1139:20: error: initializer-string for array of 'char'
truncates NUL terminator but destination lacks 'nonstring' attribute
(9 chars into 8 available) [-Werror=unterminated-string-initialization]
* src/basenc.c (z85_encoding, do_decode): Mark two more variables as
non-terminated.
2025-04-07 18:47:43 +01:00
Pádraig Brady
dcfe04eab5 maint: avoid syntax-check failures from recent commit
* gl/lib/dtimespec-bound.h: Indent, Spellcheck.
* gl/local.mk: Add new gl files.
2025-04-07 18:42:12 +01:00
Paul Eggert
f1df3e703f doc: mention workaround for combining hex floats with suffixes
* doc/coreutils.texi (hexDuration): Mention the p style exponent trick.
2025-04-07 18:40:29 +01:00
Paul Eggert
905afc91a5 build: update gnulib submodule to latest 2025-04-07 01:48:28 -07:00
Paul Eggert
cb7c210d30 timeout: don’t sleep less than requested
Also, change sleep and tail to not sleep less than requested.
* bootstrap.conf (gnulib_modules): Add dtimespec-bound.
* gl/lib/dtimespec-bound.c, gl/lib/dtimespec-bound.h:
* gl/modules/dtimespec-bound: New files.
* src/sleep.c, src/tail.c, src/timeout.c: Include dtimespec-bound.h.
* src/sleep.c, src/tail.c: Don’t include xstrtod.h.
* src/sleep.c (apply_suffix, main):
* src/tail.c (parse_options):
* src/timeout.c (apply_time_suffix):
Don’t sleep less than the true number of seconds.
* src/timeout.c: Don’t include ctype.h.
(is_negative): Remove; no longer needed.
(parse_duration): Use a slightly looser bound on the timeout, one
that doesn’t need -lm on GNU/Linux.  Clear errno before calling
cl_strtod.
2025-04-07 00:59:27 -07:00
Jim Meyering
0311d45d5b maint: silence a -Wunterminated-string-initialization warning
* src/basenc.c (base16_encode): Mark BASE16 as not NUL-terminated.
2025-04-06 08:14:06 +01:00
Pádraig Brady
14af8e34c9 build: update gnulib submodule to latest 2025-04-06 00:07:49 +01:00
Pádraig Brady
dce566553c timeout: remove dependence on libm
This was seen to add about 100,000 ns to the startup time,
on a 2.6 GHz i7-5600U with glibc 2.40.

* .gitignore: Remove /lib/fenv.h.
* bootstrap.conf: Remove fenv-rounding and signbit deps.
* src/local.mk: Remove fenv lib dependency.
* src/timeout.c (is_negative): A new helper function to
be equivalent of signbit in the underflow case.
(parse_duration): Remove the rounding up logic,
as a nanosecond here or there has no significance.
2025-04-06 00:07:49 +01:00
Pádraig Brady
65b694257f doc: mention the edge case of hex durations with 'd' suffix
* doc/coreutils.texi (sleep invocation): Mention that suffixes are
best avoided with hex arguments.
(timeout invocation): Likewise.
* tests/misc/sleep.sh: Ensure 'd' is not interpreted as "day".
2025-04-06 00:07:37 +01:00
Pádraig Brady
4368d21fbd maint: adjustments to recent timeout change
* .gitignore: Add /lib/fenv.h to ignore list.
* tests/timeout/timeout-parameters.sh: Use a sleep length of 10s
to be consistent with the pattern where we use this larger time
when it does not slow down a test, but also provides protection
against a hung test, and better avoidance of false failures due
to races on very loaded systems.  Also fix the setting of FAIL.
* tests/timeout/timeout-large-parameters.sh: Remove duplicated test.
2025-04-05 11:37:58 +01:00
Paul Eggert
a3b862ece2 timeout: round timeouts up
This handles timeouts like 16777216.000000001 correctly;
formerly the subsecond part of that timeout was ignored.
* bootstrap.conf (gnulib_modules): Add fenv-rounding, signbit.
* src/local.mk (src_timeout_LDADD): Append $(FENV_ROUNDING_LIBM).
* src/timeout.c: Include fenv.h, math.h.
Don’t include xstrtod.h, as xstrtod’s checking now gets in the way.
(parse_duration): Round up when calling cl_strtod.
Check for -1e-1000.  Don’t double-round 1e-9.
* tests/timeout/timeout-parameters.sh: Test for -0.1,
-1e-1000, 1e-1000.
2025-04-05 00:58:58 -07:00
Collin Funk
43873a660d maint: ensure that new "make syntax-check"-run sc_codespell passes
* cfg.mk (codespell_ignore_words_list): Ignore false-positives.
(exclude_file_name_regexp--sc_codespell): Skip some file names.
* doc/coreutils.texi (mktemp invocation): Use "alphanumeric" which is
consistent with the rest of the documentation.
* src/expand-common.c: Fix typo.
* src/ls.c: Likewise.
* tests/split/l-chunk-root.sh: Likewise.
2025-04-04 21:14:29 +01:00
Pádraig Brady
026d0d7c40 timeout: ensure infinitesimal timeouts timeout quickly
* src/timeout.c (parse_duration): Clamp infinitesimal values to 1ns.
* tests/timeout/timeout-large-parameters.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/77535
2025-04-04 20:52:32 +01:00
Pádraig Brady
9ed5770b5e tests: fix false failure with multi-byte thousands separators
* tests/sort/sort-h-thousands-sep.sh: sv_SE defaults to UTF-8
on macOS 18, so avoid the test for multi-byte separators.
Fixes https://bugs.gnu.org/77509
2025-04-04 12:00:24 +01:00
Pádraig Brady
8d44319fa1 ls: suppress ENOENT errors when reading ACL info
* src/ls.c (gobble_file): Indicating unknown ACL info with '?'
suffices for the edge case of a file being removed while reading,
or older cygwin when reading through dangling symlinks.
Reported by Corinna Vinschen.
2025-03-31 17:17:01 +01:00
Pádraig Brady
31c97c31ff ls: print correct xattr error on all platforms
* src/ls.c (gobble_file): Output errno, as u.err
is not populated by file_has_aclinfo() on all platforms.
* NEWS: Mention the bug fix.
2025-03-30 15:12:52 +01:00
Paul Eggert
47204301f1 mv: port test to OpenBSD 7.5
Problem reported by Bruno Haible <https://bugs.gnu.org/75685>.
* tests/mv/sticky-to-xpart.sh: Also allow OpenBSD behavior.
2025-03-23 12:01:18 -07:00
Pádraig Brady
3160f8bfa8 doc: id: be direct about valid options with -nr
* src/id.c (usage): State what options are valid with -nr,
rather than just stating the default format is invalid.
Fixes https://bugs.gnu.org/77163
2025-03-22 12:35:15 +00:00
Pádraig Brady
446a4c95f9 doc: id: make option combinations more searchable
* src/id.c (usage): Add commas to make options more searchable.
Don't add spaces since that would overflow 80 cols.
Fixes https://bugs.gnu.org/77162
2025-03-22 12:35:04 +00:00
Pádraig Brady
cb2abbac7f ls: fix crash on systems with SELinux but without xattr support
This was seen on termux on Android with ./configure --disable-xattr
where listxattr() and getxattr() returned ENOTSUP.
Then the valid security context obtained by file_has_aclinfo()
was discounted, and problematically then freed multiple times.
Reported at https://github.com/termux/termux-packages/issues/23752

* src/ls.c (file_has_aclinfo_cache): Only discount the returned
acl info when all components are defaulted due to being unsupported.
2025-03-21 12:13:12 +00:00
Pádraig Brady
76b8121d62 dircolors: add vt220 as a color capable terminal
This isn't strictly historically accurate
but most practical these days, especially since
systemd uses this as its default TERM type.
See https://github.com/coreutils/coreutils/issues/96

Tested with:
  $ LS_COLORS= COLORTERM= TERM=vt220 src/ls --color
  $ COLORTERM= TERM=vt220 src/dircolors

* src/dircolors.hin: Add vt220.
2025-03-15 12:57:53 +00:00
Pádraig Brady
2b0887fdd5 tests: dd: ensure posix_fadvise errors are handled
* tests/dd/nocache_fail.sh: Add a test case for the recent fix.
2025-03-10 12:46:14 +00:00
Frédéric Yhuel
37b085e567 dd: fix error detection with "nocache" flag
* NEWS: Mention the bug fix.
* src/dd.c (invalidate_cache): Adjust to the unusual
error propagation sematics of posix_fadvise().
2025-03-10 12:32:08 +00:00
Paul Eggert
66ee9f568b build: update gnulib submodule to latest 2025-03-09 20:08:36 -07:00
Pádraig Brady
dcfe6b2064 doc: mention logname improvement in NEWS
* NEWS: Mention the improvement in gnulib commit 90840606.
Addresses https://bugs.gnu.org/76876
2025-03-09 12:46:46 +00:00
Grisha Levit
afc41505e9 build: fix LIBCRYPTO_SONAME value with config cache
* configure.ac (LIBCRYPTO_SONAME): Store library name in cache so we
do not end up with an empty value for it when a cache file is used.
The configure variable name is changed from utils_cv_dlopen_libcrypto
to utils_cv_libcrypto_soname.
2025-02-26 15:53:36 +00:00
Lukáš Zaoral
24450e5eec who: fix -m with guessed tty names
* who.c (scan_entries): Account for guessed tty names (e.g.
'sshd pts/1') from the readutmp module when using the systemd backend.
* bootstrap.conf (gnulib_modules): Add str_endswith.
* News: Mention the bug fix.
Addresses https://bugzilla.redhat.com/2343998
2025-02-24 15:33:17 +00:00
Pádraig Brady
0a03735c71 build: update gnulib submodule to latest
* gnulib: Update to 757345e8.
* src/who.c: Adjust to new defines.
2025-02-20 13:03:18 +00:00
Pádraig Brady
4696724eb1 maint: fix sc_tight_scope failure
This reverts commit 83fb600a21.
2025-02-20 12:56:20 +00:00
Pádraig Brady
4a6ebb4613 maint: fix sc_preprocessor_indentation failure
* src/cksum.h: Indent appropriately.
2025-02-20 12:56:16 +00:00
Paul Eggert
3324344820 sort: improve -u brief doc
* src/sort.c (usage): Reword -u help (Bug#76290).
2025-02-19 13:18:31 -08:00
Paul Eggert
9c89359324 du: update debug option setup
Current Gnulib arranges for fts debugging if GNULIB_FTS_DEBUG
is defined, so key off that rather than off DU_DEBUG.
* src/du.c (fts_debug): Remove decl, as Gnulib does this now.
(FTS_CROSS_CHECK): Remove; all uses removed.
(FTS_DEBUG) [!GNULIB_FTS_DEBUG]: Remove.
(long_options) [GNULIB_FTS_DEBUG]: Add a ---debug option.
(du_files): Call fts_cross_check only if fts_debug and GNULIB_FTS_DEBUG.
(main): Set fts_debug if GNULIB_FTS_DEBUG, not DU_DEBUG.
2025-02-18 20:10:19 -08:00
Paul Eggert
83fb600a21 maint: omit function defn extern
* src/chown-core.c, src/copy.c, src/cp-hash.c, src/csplit.c:
* src/expand-common.c, src/find-mount-point.c, src/force-link.c:
* src/group-list.c, src/iopoll.c, src/operand2sig.c:
* src/show-date.c, src/wc_avx2.c:
Omit unnecessary ‘extern ’ at the start of function defns.
This is less wordy, makes it a bit easier to grep for issues such
as the missing consistency checking in cksum.
2025-02-18 20:10:19 -08:00
Paul Eggert
0ed8b6f9de cksum: check API better
* src/cksum_avx2.c, src/cksum_avx512.c, src/cksum_pclmul.c:
* src/cksum_vmull.c:
Include cksum.h instead of copying its decls/includes by hand.
This is a better way to ensure consistency among defns and uses.
2025-02-18 20:10:19 -08:00
Paul Eggert
6ac924f319 cksum: minor crctab generation cleanups
* src/cksum.c [CRCTAB]: Include only config.h and stdio.h,
to simplify the crctab-generating code.
[!CRCTAB]: Do not include stdint.h or stdio.h, as cksum.h does it now.
(BIT, r, crc_remainder, main) [CRCTAB]: Use unsigned int, not
uint_fast32_t or uint32_t, as this is good enough for GNU where
unsigned int is guaranteed to be at least 32 bits, and this way we
needn’t worry about mismatches between %08x formats and uint_fast32_t.
(main) [CRCTAB]: Prefer more-local decls.  Do not output
unnecessary directives to include stdint.h or stdio.h.
No need for ‘return EXIT_SUCCESS;’ nowadays.
* src/crctab.c: Regenerate.
2025-02-18 20:10:19 -08:00
Paul Eggert
785ba51591 cksum: make cksum.h standalone
* src/cksum.h: Include stdint.h, stdio.h so that this file
can be included in any order, after config.h.
Add a copyright notice.
2025-02-18 20:10:19 -08:00
Paul Eggert
50aa67f6a1 build: update gnulib submodule to latest 2025-02-18 20:10:19 -08:00
Paul Eggert
7eada35b4f cksum: port to 32-bit uint_fast32_t
* src/cksum_vmull.c (cksum_vmull): Don’t assume
uint_fast32_t can hold 64 bits.
Problem reported by Alyssa Ross (Bug#76360).
2025-02-17 02:31:50 -08:00
Paul Eggert
c98e90b074 cksum: fix test for missing
* tests/cksum/cksum.sh: Don’t output confusing diagnostic.
Problem reported by Alyssa Ross (Bug#76360).
2025-02-17 02:31:50 -08:00
Mike Swanson
f2e3234301 dircolors: recognize “jxl” (JPEG XL) files 2025-02-15 22:56:32 -08:00
Paul Eggert
7386c291be cat: fix plain ‘cat’ bug
* src/cat.c (main): Do not fail with plain ‘cat’ where input and
output are both /dev/tty, if the output happens to have O_APPEND set.
Problem reported by lilydjwg <https://bugs.gnu.org/76255>.
Also, don’t report an error if the seek position is at or after EOF,
even if O_APPEND is set.
2025-02-14 13:13:08 -08:00
Paul Eggert
dff821d3e3 cat: omit unnecessary lseek
* src/cat.c (main): Don’t bother to try lseek on a fifo or socket,
as it will fail.
2025-02-14 13:13:08 -08:00
Paul Eggert
a6a8f687f8 cat: port to platforms with shm, tmo
* src/cat.c (main): Work even on platforms that have shared memory
objects and typed memory objects, which means st_dev and st_ino do
not work.
2025-02-14 13:13:08 -08:00
Pádraig Brady
3f7c36cbbb doc: remove extraneous new lines in some man pages
* local.mk: Add the --loose-indent option, which results in help2man
avoiding extraneous new lines in expr.1, id.1, numfmt.1, shred.1,
tail.1, and timeout.1.
Fixes https://bugs.gnu.org/74107
2025-02-05 12:50:53 +00:00
Pádraig Brady
32125782a6 doc: sync help2man to latest version
* man/help2man: sync changes to commit 8fe02612
The main change here is to Use \f(CR for monospace text
when using groff in troff mode.
Previously \f(CW was used, but that's not portable.
2025-02-05 12:41:36 +00:00
Pádraig Brady
90a2a43935 tests: du: avoid intermittent false failure
* tests/du/long-sloop.sh: Avoid failure due to
intermittent reception of FTS_DNR, seen on BTRFS at least.
2025-02-05 11:21:49 +00:00
Paul Eggert
a7defc41ec build: update gnulib submodule to latest 2025-02-04 11:11:04 -08:00
Paul Eggert
008bb4732b maint: pacify ‘gcc -Wswitch-enum’
I thought of a way to pacify -Wswitch-enum without much trouble.
Either add all the enums, or if that’s too verbose use ‘switch (+E)’
to indicate to the reader that there need not be a case for
every enum value.  Since this approach improves static checking,
make the change everywhere and check it with -Wswitch-enum.
* configure.ac: Compile with -Wswitch-enum if it works and
--enable-gcc-warnings.  No need to remove -Wswitch-default
since Gnulib no longer adds it.
* src/chmod.c (describe_change):
* src/chown-core.c (describe_change):
* src/copy.c (copy_debug_string, copy_debug_sparse_string):
* src/df.c (decode_output_arg, get_dev):
* src/du.c (main):
* src/factor.c (print_factors):
* src/head.c (diagnose_copy_fd_failure):
* src/ls.c (time_type_to_statx, calc_req_mask)
(decode_line_length, get_funky_string, parse_ls_color)
(gobble_file, print_long_format):
* src/split.c (main):
* src/sync.c (sync_arg):
* src/tr.c (is_char_class_member):
* src/wc.c (main):
Add switch cases to pacify -Wswitch-enum.
* src/copy.c (copy_debug_string, copy_debug_sparse_string):
Add unreachable () for unreachable cases.
* src/digest.c (main):
* src/od.c (decode_one_format):
* src/tr.c (get_next, get_spec_stats):
switch (E) → switch (+E).
* src/digest.c (main):
* src/tr.c (get_next):
Omit unnecessary ‘default: break;’ that merely pacified GCC,
as the new pacification style is better.
* src/ls.c (decode_line_length):
Add default unreachable case to prevent warning that function
might not return a value.
(gobble_file): Distinguish DEREF_NEVER from unreachable cases.
2025-02-02 22:09:52 -08:00
Paul Eggert
d7c6f85189 build: update gnulib submodule to latest 2025-02-02 22:09:52 -08:00
Pádraig Brady
63b780afce doc: ls: clarify --format options
* src/ls.c (usage): Use parentheses to be less ambiguous as
to what are WORDs and equivalent short options.  This is also
consistent with the description of --sort and --indicator-style.
Fixes https://bugs.gnu.org/75916
2025-01-29 11:33:25 +00:00
Pádraig Brady
f45202b7e0 doc: support --with-packager-bug-reports
* src/system.h (emit_ancillary_info): Output
PACKAGE_PACKAGER_BUG_REPORTS if the build is configured
--with-packager-bug-reports.
Reported by Bruno Haible.
2025-01-28 18:35:44 +00:00
Pádraig Brady
fbfd886e59 sort: drop "note" from a --debug message
* src/sort.c (key_warnings): Remove "note " from the start
of a usually informational message, as this simplifies translation.
* tests/sort/sort-debug-warn.sh": Adjust accordingly.
Fixes https://bugs.gnu.org/75763
2025-01-22 17:55:54 +00:00
Pádraig Brady
d10cc94399 tests: avoid ENAMETOOLONG ERROR on some systems
* tests/du/long-from-unreadable.sh: Relax to a skip_ for now,
as this was seen to error on ext4 on Debian 11 in a docker container.
2025-01-20 17:26:20 +00:00
Collin Funk
91d5a51236 maint: tests: remove duplicate uses of 'my' in Perl
* tests/env/env-S.pl (cf): Remove uses of 'my' after the variable has
been declared.
* tests/factor/factor.pl (t): Likewise.
* tests/misc/fold.pl (prog): Remove duplicate assignment.
2025-01-20 15:45:03 +00:00
Pádraig Brady
dcc896e6c3 tests: remove use of unprotected 'set'
* cfg.mk (sc_prohibit_bare_set): A new syntax check to
ensure we protect use of set with '--', so that args
beginning with '-' are not interpreted as options,
and if no args are present, all existing args are cleared.
* tests/cp/symlink-slash.sh: Add -- to unprotected use of set.
* tests/ls/ls-time.sh: Likewise.
* tests/ls/symlink-slash.sh: Likewise.
* tests/mkdir/perm.sh: Likewise.
* tests/mkdir/selinux.sh: Likewise.
* tests/mkdir/smack-no-root.sh: Likewise.
* tests/mkdir/smack-root.sh: Likewise.
* tests/mv/part-hardlink.sh: Likewise.
* tests/nice/nice.sh: Likewise.
* tests/stty/stty-row-col.sh: Likewise.
2025-01-20 15:21:58 +00:00
Daniel Hofstetter
e6117526c3 tests: fix typo in tests/ls/ls-time.sh
* tests/ls/ls-time.sh: s/--sort-name -t/-t --sort=name/.
2025-01-19 16:36:59 +00:00
G. Branden Robinson
3189c08cb7 doc: fix superscript in Texinfo manual's math
The numeral "3" in the exponent was set at full size on the baseline.
2025-01-18 23:46:52 -08:00
Pádraig Brady
915004f403 ls: fix crash with --context
* src/ls.c (main): Flag that we need to stat()
if we're going to get security context (call file_has_aclinfo_cache).
(file_has_aclinfo_cache): Be defensive and only lookup the device
for the file if the stat has been performed.
(has_capability_cache): Likewise.
* tests/ls/selinux-segfault.sh: Add a test case.
* NEWS: Mention the bug fix.
Reported by Bruno Haible.
2025-01-18 13:14:29 +00:00
Pádraig Brady
23fcbeff42 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2025-01-17 15:22:34 +00:00
Pádraig Brady
e2a405981f version 9.6
* NEWS: Record release date.
2025-01-17 14:43:22 +00:00
Pádraig Brady
797f11e8dc build: update gnulib submodule to latest
Mainly to avoid make dist-check failure with --disable-nls
2025-01-17 13:33:39 +00:00
Bruno Haible
354cf4a410 build: fix compilation error on CentOS 8 Stream
* configure.ac (USE_AVX512_CRC32): Set to false if the function
_mm512_set_epi8 does not exist.
2025-01-16 22:16:53 +00:00
Pádraig Brady
700690ebc3 tests: tail-c.sh: avoid failure on Linux kernels <= 2
tests/tail/tail-c.sh: Exclude older kernels from timeout failure.
2025-01-16 21:05:34 +00:00
Bruno Haible
0c195b63ea ls: Fix compilation error on CentOS 6
* src/ls.c (XATTR_NAME_CAPS): Define fallback.
2025-01-16 12:11:14 -08:00
Paul Eggert
e07161d4af sort: fix --debug buffer overrun
* src/sort.c (debug_key): Fix undefined behavior when a key ends
before it starts.  Problem reported by Bruno Haible
<https://bugs.gnu.org/75606>.
2025-01-16 09:21:42 -08:00
Pádraig Brady
9c068dae76 tests: avoid false failure with replaced readdir
* tests/rm/rm-readdir-fail.sh: Simulate EIO rather than ENOENT,
as gnulib absorbs the latter since commit 5a2d28df.
2025-01-16 14:58:02 +00:00
Pádraig Brady
039c355f71 ls: suppress ENOTSUP errors on virtiofs
* gnulib: Update to latest to pick up commit caf76886.
* NEWS: Mention the bug fix.
2025-01-16 12:09:43 +00:00
Pádraig Brady
0bd149403d tests: misc/write-errors.sh: increase memory limit
* tests/head/head-c.sh: Use a larger VM limit to avoid
mem allocation failures, which were seen on CheriBSD.
2025-01-15 22:50:05 +00:00
Pádraig Brady
678281539b tests: head: avoid false failure on some systems
* tests/head/head-c.sh: Pass a more similar operation
to get_min_ulimit_v_, so we get a more appropriate limit.
This was seen to be significant with CheriBSD.
2025-01-15 22:43:18 +00:00
Pádraig Brady
261f13bcf8 yes: avoid failure on CHERI protected systems
* src/yes.c (main): Don't reuse the argv array as CHERI's
capability bounds do not allow for that, failing like:
  $ yes $(seq 156) | head -n1
  In-address space security exception (core dumped)
2025-01-15 22:16:30 +00:00
Pádraig Brady
d60e550ed0 tac: avoid out of bounds access
This was flagged on CheriBSD on ARM Morello with the error:
"In-address space security exception (core dumped)"
triggered with: tac -s '' /dev/null

* src/tac.c (main): Ensure we don't read beyond the
end of the supplied optarg.
2025-01-15 17:42:55 +00:00
Pádraig Brady
c56890470e tests: avoid ERRORs with no mntent.h
* tests/df/skip-duplicates.sh: Just skip this test if we fail
to build the shared lib.  This fails on Solaris 11 at least
due to no HAVE_MNTENT_H.  Note HAVE_SYS_MNTENT_H does not
suffice for this wrapper code.
* tests/df/no-mtab-status.sh: Likewise.
2025-01-15 17:07:19 +00:00
Pádraig Brady
4bb1fc2445 tests: avoid false failure with many mountpoints
* tests/ls/readdir-mountpoint-inode.sh: Only take the first 64.
2025-01-15 17:07:19 +00:00
Pádraig Brady
868cd727df tests: printf: avoid false failure
* tests/printf/printf-surprise.sh: Increase the VM limit
to avoid false failures in rare cases.
2025-01-15 17:07:19 +00:00
Pádraig Brady
61d4935802 tests: avoid slow ulimit -v behavior
* init.cfg (ulimit_supported_): skip_ if the ulimit -v
takes too long, which was seen with bash 5.2 on Solaris 11,
where fork() returned EAGAIN under memory constraints,
and bash retried for about 16 seconds.
(get_min_ulimit_v_): Break early if skipped.
* tests/misc/write-errors.sh: Be more conservative and
skip on failure to determine min ulimit.
2025-01-15 17:07:13 +00:00
Pádraig Brady
c12baacddc tests: use more portable timeout presence check
* init.cfg: timeout(1) on FreeBSD doesn't support --version
(or --help with success status), so use syntax compatible
with both FreeBSD and GNU.
2025-01-15 12:07:52 +00:00
Pádraig Brady
1555bcec6a tests: tail: avoid failure on Solaris 11
* tests/tail/tail-c.sh: On Solaris 11, tail -c 4096 /dev/urandom,
will induce an lseek(,-4096,SEEK_END) which returns -4096 without
setting errno, and a subsequent read() then gives EINVAL.
Since tailing the end of a psuedo device is an edge case,
we just verify that we don't spin reading the device forever.
2025-01-15 12:07:52 +00:00
Pádraig Brady
8b05659ede maint: avoid syntax-check failure
* src/cksum.c: Use spaces to indent, not tabs.
2025-01-15 12:07:52 +00:00
Paul Eggert
b852461476 cksum: port to Oracle Developer Studio 12.6
* src/cksum.c (cksum_fp_t): New typedef.
(pclmul_supported, avx2_supported, avx512_supported)
(vmull_supported): Return this new type instead of bool.
All callers changed.  That way, callers do not need to
refer to functions like cksum_avx512 that might not
exist on this platform.  Although GCC optimizes such
references away, the C standard does not require this
optimization.
2025-01-14 19:44:24 -08:00
Paul Eggert
bf44993fb9 build: update gnulib submodule to latest 2025-01-14 19:44:24 -08:00
Collin Funk
75e2224ae2 tests: env-S.pl: unset GNU/Hurd env vars
* tests/misc/env-S.pl: Unset LD_ORIGIN_PATH.
2025-01-14 12:33:52 +00:00
Paul Eggert
0032e336e5 ls: readdir errno fixes
* src/ls.c (print_dir): Fix bug: file_failure can set errno to
something other than EOVERFLOW but the code assumed it didn’t.
Also, omit ENOENT bug workaround with glibc 2.3 and later,
for consistency with Gnulib.
2025-01-13 10:44:18 -08:00
Pádraig Brady
527d331af4 tail: fix regression in open() flags used
* src/tail.c (tail_file): Fix precedence issue introduced
in commit v9.5-231-g177fcec66 so that we pass correct flags to open().
Effectively this meant we would have dropped the O_BINARY flag
on windows, since O_RDONLY is generally 0.
Issue spotted by coverity.
2025-01-13 17:24:16 +00:00
Pádraig Brady
a83615427b build: update to latest gnulib
Ensure WCOREDUMP is always defined,
and ensure --enable-silent-rules is honored with crc code generation.
2025-01-13 10:59:11 +00:00
Pádraig Brady
1e59fbf722 all: fix program name with --enable-single-binary=shebangs
* gnulib: Pick up gnulib commit f11caad4fd which ensures
we diagnose the actual utility name, and not just "coreutils"
when in single binary mode.  This adjustment is required
since gnulib commit 959152ba37 which enforced use of gnulib's
error() once verror is used, and gnulib's error() always
outputs the base name of the command, which the new gnulib
commit now keeps up to date.
2025-01-12 21:49:04 +00:00
Pádraig Brady
e6a1f5a4b0 tests: make misc/write-errors.sh immune to default signal disposition
* tests/misc/write-errors.sh: Reset SIGPIPE to the default (terminate)
disposition, so that the test doesn't erroneously fail due to an
ignored SIGPIPE in the test environment.
2025-01-12 12:44:37 +00:00
Pádraig Brady
5da2acc5e8 ls: fix inaccurate indication of ACLs on NFS
* gnulib: Update to latest to pick up gnulib commit 05c63bc908
which ensures accurate determination of the presence of NFSv4 ACLs.
* NEWS: Adjust accordingly.
Related to https://bugs.gnu.org/74692
2025-01-11 21:31:06 +00:00
Pádraig Brady
8482cb9451 csplit: avoid extraenous output files given empty input
* src/csplit.c (get_first_line_in_buffer): Don't exit here
upon empty input, rather indicate no input in the return
to let callers handle in a more consistent fashion.
* NEWS: Mention the bug fix.
* tests/csplit/csplit.sh: Add a test case.
Reported by Daniel Hofstetter.
2025-01-10 14:46:48 +00:00
Pádraig Brady
b58e321c8d ls: suppress "Permission denied" errors on NFS
NFS (on Linux 6.12 at least) was seen to return EACCES
from listxattr() for files without read access.
We started using listxattr() in coreutils 9.4.

* src/ls.c (gobble_file): Map EACCES from file_has_aclinfo()
to '?', rather than displaying the error.
* doc/coreutils.texi (ls invocation): Document the '?' flag.
* NEWS: Mention the bug fix.
Addresses https://bugs.gnu.org/74692
2025-01-10 14:46:40 +00:00
Paul Eggert
6b9e601a97 build: update gnulib submodule to latest 2025-01-09 20:42:59 -08:00
Paul Eggert
f169dc8b68 ls: update comment
* src/ls.c (file_has_aclinfo_cache): Fix comment.
2025-01-08 11:13:54 -08:00
Pádraig Brady
177fcec66d tail: honor --pid with fifos
* src/tail.c (tail_file): Open files with O_NONBLOCK
if we might need async processing.
(pipe_bytes): Ignore EAGAIN read() errors.
(pipe_lines): Likewise.
* tests/tail/pid-pipe.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Reported by Berhard Voelker.
2025-01-08 12:11:43 +00:00
Pádraig Brady
10406103b8 cp,mv: decouple --update from -f,-i,-n options
* src/copy.h: Change update member from bool to enum.
* src/copy.c: s/interactive == I_ALWAYS_NO/update == UPDATE_NONE_FAIL/;
              s/interactive == I_ALWAYS_SKIP/update == UPDATE_NONE/;
              s/update/update == UPDATE_OLDER/;
* src/install.c: Init with UPDATE_ALL, rather than false.
* src/cp.c: Likewise.  Simply parse -f,-i,-n to x.interactive,
and parse --update to x.update.
* src/mv.c: Likewise.
* tests/cp/cp-i.sh: Add a test case where -n --update -i
honors the --update option, which would previously have been
ignored due to the preceding -n.
2025-01-07 17:28:49 +00:00
Pádraig Brady
a6ab944e19 cp,mv: ensure -i,f are not overridden by -u
Since coreutils 9.3 we had --update={all,older} override -i.
In coreutils 9.5 this was expanded to -u
(to make it consistent with --update=older).

This patch reinstates things so that -i combines with -u instead.
I.e. have -i be protective, rather than selective (like -u).

The -f option of mv is similarly adjusted in this patch,
so now --update does not override any of -f,-i,-n.

* NEWS: Mention the bug fix.
* src/cp.c (main): Don't have -u disable prompting.
* src/mv.c (main): Likewise.
* tests/cp/cp-i.sh: Add a test case for -i.
* tests/mv/update.sh: Likewise.
* tests/mv/i-3.sh. Add a test case for -f.
Fixes https://bugs.gnu.org/70887
2025-01-06 14:46:21 +00:00
Pádraig Brady
5572896137 doc: clarify mv -f operation in texinfo
* doc/coreutils.texi (mv invocation): Be less ambiguous,
in that -f is significant for any replacement operation
on the destination, not just unlinking.
2025-01-06 13:30:27 +00:00
Pádraig Brady
28b176085f maint: update all copyright year number ranges
Update to latest gnulib with new copyright year.
Run "make update-copyright" and then...

* gnulib: Update included in this commit as copyright years
are the only change from the previous gnulib commit.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
2025-01-01 09:33:08 +00:00
Pádraig Brady
45bcc6aaaf pwd: fix erroneous leading slash on some systems
* gnulib: Pull in the fix to getcwd() from gnulib.
* NEWS: Mention the fix.
2025-01-01 09:11:38 +00:00
Pádraig Brady
6229ac946e numfmt: don't require a suffix with --from=iec-i
* src/numfmt.c (simple_strtod_human): Only look for 'i'
after detecting a suffix.
* tests/misc/numfmt.pl: Add a test case.
* NEWS: Mention the bug fix.
Reported at https://bugs.debian.org/1091758
2024-12-30 22:49:31 +00:00
Pádraig Brady
02a24f8aad maint: fix syntax-check error
* src/seq.c: Adjust line length.
2024-12-30 20:34:23 +00:00
Paul Eggert
36e656390d maint: adjust to Gnulib module renaming
* bootstrap.conf, gl/modules/buffer-lcm, gl/modules/randperm:
* gl/modules/randread, gl/modules/strnumcmp, gl/modules/targetdir:
* gl/modules/xdectoint, gl/modules/xfts:
Adjust to recent renaming of Gnulib modules, e.g., stdbool → bool,
inttypes → inttypes-h.
2024-12-30 11:53:18 -08:00
Paul Eggert
e83385b526 build: update gnulib submodule to latest 2024-12-30 11:53:18 -08:00
Paul Eggert
a0c3e5648b date: improve doc for ambiguous formats
Problem reported by Tim Connors <https://bugs.gnu.org/75208>.
* doc/coreutils.texi (Date conversion specifiers):
* src/date.c (usage):
Warn about ambiguous formats like %D.
2024-12-30 11:53:17 -08:00
Paul Eggert
9eb131e530 maint: ISDIGIT → c_isdigit
* gl/lib/strnumcmp-in.h (ISDIGIT):
* src/system.h (ISDIGIT): Remove.  All uses replaced by c_isdigit,
with appropriate inclusions of c-ctype.h.  This is more regular,
and is more portable to existing (but unlikely) platforms where
INT_MAX == UINT_MAX.
2024-12-30 10:55:23 -08:00
Sylvestre Ledru
ff55921c43 tests: improve the chmod/symlinks.sh test
The variable of the loop isn't passed to the command making
it less interesting

* tests/chmod/symlinks.sh: Fix the test case.
2024-12-30 14:21:47 +00:00
Pádraig Brady
7e5b6b6f07 kill: with -l,-t list signal 0
The 0 (EXIT) signal is valid as input
(and useful to determine existence of a pid),
so list it along with other signals.

* doc/coreutils.texi (signal specifications): Document 0, "EXIT".
* src/kill.c (list_signals): Start loops at 0, not 1.
* tests/misc/kill.sh: Add a test case.
* NEWS: Mention the change in behavior.
2024-12-23 11:49:10 +00:00
Pádraig Brady
c11d52f19a maint: correct © dates for hardware optimized crc routines
* src/cksum_pclmul.c: 2021-2024.
* src/cksum_avx2.c: 2024.
* src/cksum_avx512.c: 2024.
* src/cksum_vmull.c: 2024.
2024-12-21 12:20:03 +00:00
Pádraig Brady
8b9fa9d074 tail: always fail when followed files become inaccessible
* src/tail.c (tail_forever): Without --retry, exit with failure
status like we do for the inotify case (since v8.11-15-g61de57cd2).
This is also consistent with the failure exit if no file was
accessible at tail startup.
* tests/tail/follow-stdin.sh: Tweak due to earlier exit.
* tests/tail/follow-name.sh: Test with and without inotify.
* NEWS: Mention the bug fix.
2024-12-21 12:10:04 +00:00
Pádraig Brady
c8bb7afcfb cksum: update to pclmul optimized crc32b from gnulib
* bootstrap.conf: Depend on crc-x86_64 rather than crc.
* gnulib: Update to latest.
* src/cksum.c (crc32b_sum_stream): Add --debug info.
* NEWS: Mention the performance improvement.
2024-12-20 14:47:54 +00:00
Daniel Hofstetter
e331dcbc81 maint: tests: update deprecated perl backreference syntax
* tests/basenc/basenc.pl: perl warns that $1 is better than \1,
so update to the preferred form.
2024-12-16 18:14:36 +00:00
Paul Eggert
f5e1dfa122 maint: sync help2man to latest version
* man/help2man: sync changes from version 1.48.5 through 1.49.3.
This doesn't materially change the generated man pages.
2024-12-11 20:10:12 -08:00
Sam Russell
d155be4a22 cksum: use ARMv8 SIMD extensions
* configure.ac: Add check for ARMv8 VMULL support.
* src/cksum.c: Add ARMv8 VMULL detection function.
* src/cksum.h: Add ARMv8 VMULL implementation declaration.
* src/cksum_vmull.c: ARMv8 VMULL implementation.
* src/local.mk: Add build flags for ARMv8 VMULL.
* NEWS: Mention the ARMv8 SIMD improvement.
2024-12-05 20:47:30 +00:00
Pádraig Brady
fd01fc8075 tail: ensure --follow=name unfollows renamed files
Require --retry to continue to track files upon rename.
We already unfollowed a file if it was renamed
to another file system (unlinked), so this makes the behavior
consistent if renaming to a file in the same file system.
I.e. --follow=name without --retry, means unfollow if the
name is unlinked or moved, so this change ensures that
behavior for all rename cases.
Related commits: v8.0-121-g3b997a9bc, v8.23-161-gd313a0b24

* src/tail.c (tail_forever_notify): Remove watch for a renamed file
if --retry is not specified.
* tests/tail/F-vs-rename.sh: Related test cleanup.
* tests/tail/follow-name.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/74653
2024-12-05 12:53:13 +00:00
Sam Russell
df71ac8343 cksum: use AVX2 and AVX512 for speedup
* configure.ac: Add checks for avx2 and avx512 support.
* src/cksum_avx2.c: AVX2 implementation.
* src/cksum_avx512.c: AVX512 implementation.
* src/local.mk: Add build flags for avx2 and avx512.
* src/cksum.c: Add avx2 and avx512 detection functions.
* src/cksum.h: Add avx2 and avx512 implementation declarations.
* NEWS: Mention the AVX2 and AVX512 improvement.
2024-11-26 18:01:54 +00:00
Pádraig Brady
205e7e4585 tail,tee: fix broken pipe detection on darwin 9
* src/iopoll.c (): Restrict use of poll() on macOS
to >= 11 (darwin 20), as it was seen to fail on macOS 10.5.
Fixes https://bugs.gnu.org/74503
2024-11-26 16:02:01 +00:00
Pádraig Brady
cb2774501d tests: avoid false failure with unicode decomposed file systems
* tests/ls/dired.sh: macOS normalizes unicode characters to decomposed
(NFD) form when storing names in the file system, which breaks the
round-trip comparison employed by the test.  So instead use a character
which does not decompose; verified with:
  echo æ | uconv -f utf8 -t utf8 -x nfd | od -Ax -tx1z
2024-11-24 12:59:42 +00:00
Paul Eggert
cc58b65736 dd: port big-offset test to macOS 12.6
* tests/dd/skip-seek-past-file.sh: Do not assume that
seek to exactly OFF_T_MAX should fail; it works on macOS 12.6
and POSIX allows this.  Come to think of it, it should work
on Solaris too, if someone ever comes across a Solaris host
with a file system that allows such files.
2024-11-20 11:11:54 -08:00
Collin Funk
96954f37a9 maint: update .gitignore
* .gitignore (/lib/crc-sliceby8.h): Add file generated by Gnulib.
2024-11-20 10:02:18 +00:00
Collin Funk
1a27008fe2 maint: prefer mbszero over memset
* src/df.c (replace_invalid_chars): Use mbszero.
2024-11-20 10:02:14 +00:00
Paul Eggert
38823913e3 ls: port to Oracle Developer Studio 12.6
Oracle Developer Studio 12.6 for sparc mishandles
‘sizeof ((char []) {'x', 'y'})’: it says
“warning: null dimension: sizeof()” and then generates
the wrong length in data.  Work around the compiler bug
by counting sizes by hand, which may be a bit clearer anyway,
if a bit more error-prone.
* src/ls.c (BIN_STR): Remove.
(color_indicator): Spell out instead of using BIN_STR.
2024-11-19 22:55:48 -08:00
Paul Eggert
d92df29a21 factor: fix ‘return’ typo
* src/factor.c (lbuf_putint): Don’t use ‘return E;’ in
a void function’s body, fixing a recently-introduced typo.
2024-11-19 22:22:57 -08:00
Paul Eggert
6c69fd16bc doc: mention "printf %d ''" change 2024-11-19 14:01:32 -08:00
Pádraig Brady
c6be9649a7 tests: fix inconsistent use of getlimits_
* tests/dd/skip-seek-past-file.sh: s/eval $(getlimits)/getlimits_/
2024-11-19 20:03:01 +00:00
Pádraig Brady
ede23f4427 tests: printf: avoid iconv issues on macOS
* tests/printf/printf-cov.pl: Since gnulib commit v1.0-1103-ge5b82978e2
we avoid iconv() on ASCII range 0x32 - 0x7F inclusive, so adjust
this test to fall within that range.
Addresses https://bugs.gnu.org/74428
2024-11-19 19:57:53 +00:00
Paul Eggert
2a49f56906 chown: port test to macOS 12.6 nogroup user
* tests/chown/preserve-root.sh (id_g): Set to empty if id -gn
reports that it is nogroup, and skip that part of the test.
2024-11-19 09:53:55 -08:00
Paul Eggert
e3ccd26aca maint: omit unnecessary to_uchar
* src/df.c (replace_control_chars):
* src/dircolors.c (parse_line):
* src/printf.c (print_esc):
* src/ptx.c (unescape_string):
* src/stat.c (print_it):
* src/tr.c (star_digits_closebracket):
Omit to_uchar calls that aren’t needed, because the parent
expression works with ‘char’ as well as with ‘unsigned char’.
2024-11-19 09:53:55 -08:00
Paul Eggert
60995c36f3 tests: Remove stray ‘i’ 2024-11-19 09:53:55 -08:00
Paul Eggert
91e95f1f86 printf: diagnose empty args correctly
Also, port better to macOS.
* src/printf.c (verify_numeric): Don’t assume that when s == end
then errno is zero; it is EINVAL on macOS, and POSIX allows this.
(print_direc): Treat missing arg as zero for numeric conversions,
and as an empty string for the others.
(print_formatted): Use null pointer, not an empty string,
to represent missing arg.
* tests/printf/printf.sh: Test empty and space widths and precisions.
2024-11-19 08:41:34 -08:00
Paul Eggert
a665aa4f6d printf: do n$ overflow checking by hand
* src/printf.c (get_curr_arg): Mark as pure to pacify GCC 14.
Do overflow checking by hand rather than relying on strspn
and strtoimax.
2024-11-19 08:41:34 -08:00
Paul Eggert
00a5f3dd83 printf: refactor macros to function
* src/printf.c (struct arg_cursor): New struct.
(get_curr_arg): New function.
(print_formatted): Use it instead of ...
(GET_CURR_ARG, SET_CURR_ARG): ... these removed macros.
This makes the code a bit easier to follow, and any efficiency
cost should be minimal.
2024-11-19 08:41:34 -08:00
Pádraig Brady
c41ca2814d maint: avoid a syntax-check failure
This was also updated in gnulib.

* bootstrap: s/can not/cannot/
2024-11-18 16:26:19 +00:00
Pádraig Brady
ea69c67796 doc: describe "New programs" consistently in NEWS
* NEWS: s/New commands/New programs/
2024-11-18 16:13:12 +00:00
Paul Eggert
1875e5c05d build: update gnulib submodule to latest
Also, copy bootstrap from gnulib/build-aux/bootstrap.
2024-11-17 23:05:10 -08:00
Paul Eggert
f21c74b48c factor: pacify -Wunused-macros
* src/factor.c: Also use __GMP_GNUC_PREREQ
2024-11-17 23:05:10 -08:00
Paul Eggert
1f0bf8d7c4 ls: refactor gobble_file get_scontext
* src/ls.c (gobble_file): Simplify by pulling get_scontext
out of ‘if’.
2024-11-14 17:36:47 -08:00
Pádraig Brady
fc0ea5cb87 tests: ls: also test security context output for symlinks
* tests/ls/selinux.sh: Test symlinks as well as files.
2024-11-12 11:43:45 +00:00
Pádraig Brady
8f4fce1751 tests: avoid false failure with --disable-selinux
* tests/ls/selinux-segfault.sh: Move recent addition to ...
* tests/ls/selinux.sh: ... this new test that uses require_selinux_
to skip appropriately when we've built without selinux support.
Also add a non root test that checks we output '.' along with the
mode for files, to indicate a security context is present.
* tests/local.mk (Reference the new test).
2024-11-12 11:20:47 +00:00
Pádraig Brady
00c45be787 ls: fix security context indication in --long mode
* src/ls.c (gobble_file): Always get the security context with -l
so that we can indicate a context with '.' if present.
2024-11-11 18:55:19 +00:00
Paul Eggert
87b887f968 build: update gnulib submodule to latest
This also fixes a problem with ls -Z when configured with
--disable-acl, reported by Pádraig Brady
<https://bugs.gnu.org/73418#52>.
* src/ls.c (gobble_file): Pass ACL_GET_SCONTEXT to
file_has_aclinfo, if -Z is used.
2024-11-11 08:59:58 -08:00
Pádraig Brady
64a5d1092c build: update gnulib to latest
* NEWS: Mention the fix to nproc honoring the affinity mask
on systems with more than 1024 processors.
2024-11-11 14:54:03 +00:00
Paul Eggert
45ba6c6f54 ls: add test case for ls -Z bug
Problem reported by Pádraig Brady <https://bugs.gnu.org/73418#35>.
This bug was fixed by the recent gnulib update.
* tests/ls/selinux-segfault.sh:
Also test for ls -Z on broken symlinks.
2024-11-09 16:51:26 -08:00
Paul Eggert
b048c4d37f build: update gnulib submodule to latest 2024-11-09 16:51:26 -08:00
Pádraig Brady
f7c53095d2 tests: avoid false failure on older valgrind
* src/shuf.c (main): In dev mode call randint_all_free()
to avoid false failure with valgrind 3.16.1 at least.
Note this partially reinstates commit v9.0-109-g0106b5a4b.
This was noticed on a debian 11 system running CI tests.
2024-11-09 17:16:30 +00:00
Paul Eggert
6db4b33eb9 seq: seq_fast always exits now
* src/seq.c (seq_fast): Always exit.  Don’t bother freeing
just before exit.
2024-11-08 23:41:18 -08:00
Paul Eggert
ab397c475a seq: simplify cmp calls
* src/seq.c (seq_fast): Call cmp in just one place, not two.
Redo loop structure to make it work.
2024-11-08 23:41:18 -08:00
Paul Eggert
807c51e4fb seq: use full_write instead of fwrite
* src/seq.c: Include full-write.h.
(seq_fast): Since we’re doing all the buffering work anyway,
we might as well use syscalls instead of stdio to write.
Use full_write instead of fwrite.
2024-11-08 23:41:18 -08:00
Paul Eggert
8ba5c3493d seq: simplify output buffer management
* src/seq.c (seq_fast): Simplify by using an output buffer of
known size (BUFSIZ) on the stack, rather than a heap buffer that
might grow.  For the number buffer, don’t bother appending NUL
since nobody uses the NUL, and xpalloc from nullptr not p0 since
we need to move the buffer data by hand anyway.
2024-11-08 23:41:18 -08:00
Paul Eggert
96e101d03f seq: omit unnecessary malloc for upper bound
* src/seq.c (seq_fast): Speed up test for "inf".
Do not allocate and free a copy of B, as it is fine as-is.
2024-11-08 23:41:18 -08:00
Paul Eggert
59bfd5b53d seq: simplify cmp
* src/seq.c (cmp): Simplify, and change some size_t to idx_t.
(INITIAL_ALLOC_DIGITS): Now a constant, not a macro.
2024-11-08 23:41:18 -08:00
Paul Eggert
ecb157940d seq: explicate incr
* src/seq.c (incr): Change API to make the code easier to follow,
and also to avoid undefined behavior on hypothetical platforms
where '9' == INT_MAX (!).  Caller changed.
2024-11-08 23:41:18 -08:00
Paul Eggert
ddb6f5f442 env: prefer xpalloc to xrealloc
* src/env.c (extract_varname): Prefer free+xpalloc to
xrealloc, since the old buffer contents don’t matter.
2024-11-08 23:41:18 -08:00
Paul Eggert
cd340ab21f shuf: prefer xpalloc to xnrealloc
* src/shuf.c (RESERVOIR_LINES_INCREMENT): Remove.
All uses removed.
(read_input_reservoir_sampling, main):
Prefer idx_t to size_t for sizes related to xpalloc.
(read_input_reservoir_sampling): Prefer xpalloc to xnrealloc.
2024-11-08 23:41:18 -08:00
Paul Eggert
61ab25c355 pwd: prefer xpalloc to xnrealloc
* src/pwd.c (struct file_name, file_name_prepend):
Prefer idx_t to size_t for sizes related to xpalloc,
(file_name_init): Don’t overflow if PATH_MAX == INT_MAX.
(file_name_prepend): Prefer xpalloc to by-hand resizing.
Simplify by using memcpy return value.
2024-11-08 23:41:18 -08:00
Paul Eggert
ba034afa6c du: prefer xpalloc to xnrealloc
* src/du.c (prev_level, process_file):
Prefer idx_t to size_t for sizes related to xpalloc,
and to nesting levels (since that’s what fts_level does anyway).
(process_file): Prefer xpalloc to xnrealloc.
2024-11-08 23:41:18 -08:00
Paul Eggert
c52553997d df: prefer xpalloc to xnrealloc
* src/df.c (ncolumns, nrows, print_table, get_header, get_dev):
Prefer idx_t to size_t for sizes related to xpalloc.
(ncolumns_alloc, nrows_alloc): New static vars.
(alloc_table_row, alloc_field): Prefer xpalloc to xnrealloc.
2024-11-08 23:41:18 -08:00
Paul Eggert
d00ab4d110 basenc: prefer xpalloc to xnrealloc
* src/basenc.c (prepare_inbuf): Prefer xpalloc to xnrealloc.
2024-11-08 23:41:18 -08:00
Paul Eggert
4cb726e4a6 ls: prefer xpalloc to xnrealloc
* src/ls.c (cwd_n_alloc, cwd_n_used, clear_files)
(extract_dirs_from_files, initialize_ordering_vector)
(update_current_files_info, sort_files, print_current_files)
(print_many_per_line, print_horizontal, print_with_separator)
(init_column_info, calculate_columns):
Prefer idx_t to size_t for sizes related to xpalloc.
(main): Let the compiler fold constants.
(gobble_file, init_column_info): Use xpalloc, not xnrealloc.
(print_many_per_line): Fix very-unlikely integer overflow.
2024-11-08 23:41:18 -08:00
Paul Eggert
612e64e132 df: simplify via xasprintf
* src/df.c: Include xvasprintf.h.
(get_header, get_dev): Simplify by using xasprintf and xstrdup
rather than doing the error checking ourselves.
2024-11-08 23:41:18 -08:00
Paul Eggert
3e1c94d273 csplit: port to IDX_MAX < INT_MAX
* src/csplit.c (max_out): Defend against unlikely IDX_MAX < INT_MAX.
2024-11-08 23:41:18 -08:00
Paul Eggert
bd39f96581 pr: prefer xpalloc to x2realloc
* src/pr.c (buff_allocated, main):
Prefer idx_t to size_t for sizes.
(main, store_char): Use xpalloc, not x2realloc.
(init_store_cols): Check for multiplication overflow ourselves
and use ximalloc, not xnmalloc.  This is a bit simpler.
* src/system.h (X2REALLOC): Remove; no longer used.
2024-11-08 23:41:18 -08:00
Paul Eggert
91a743bb85 od: prefer xpalloc to x2realloc
* src/od.c (string_min, dump_strings): Prefer idx_t to size_t for
sizes.  Use xpalloc, not x2realloc.
2024-11-08 23:41:18 -08:00
Paul Eggert
901ba87ed5 fold: prefer xpalloc to x2realloc
* src/fold.c (fold_file): Prefer idx_t to size_t for sizes.
Use xpalloc, not x2realloc.
2024-11-08 23:41:18 -08:00
Paul Eggert
9f017b69f3 sort: prefer xpalloc to x2nrealloc
* src/sort.c (struct buffer, temp_dir_count, temp_dir_alloc)
(create_temp_file, add_temp_dir, fillbuf):
Prefer idx_t to ptrdiff_t/size_t for nonnegative directory counts.
(add_temp_dir, fillbuf): Use xpalloc, not x2nrealloc.
* src/system.h (X2NREALLOC): Remove; no longer used.
2024-11-08 23:41:18 -08:00
Paul Eggert
3aaadf281f cut,numfmt: prefer xpalloc to x2nrealloc
* src/set-fields.c (n_frp, n_frp_allocated, complement_rp, set_fields):
Prefer idx_t to ptrdiff_t/size_t for nonnegative sizes.
(add_range_pair): Use xpalloc, not x2nrealloc.
2024-11-08 23:41:18 -08:00
Paul Eggert
1932ca94d3 ptx: prefer xpalloc to x2nrealloc
* src/ptx.c (line_width, gap_size, WORD, WORD_TABLE)
(maximum_word_length, reference_max_width, occurs_alloc)
(number_of_occurs, half_line_width, truncation_string_length)
(compare_words, search_table, digest_word_file)
(find_occurs_in_text, fix_output_parameters)
(generate_all_output, main, find_occurs_in_text)
(fix_output_parameters, generate_all_output):
Prefer idx_t to ptrdiff_t/size_t for nonnegative sizes.
(first, second): Remove macros, replacing them with locals.
(search_table): Use hi (for highest + 1) to simplify.
Avoid unlikely overflow by not computing lo + hi.
(digest_word_file, find_occurs_in_text): Use xpalloc, not x2nrealloc.
2024-11-08 23:41:18 -08:00
Paul Eggert
a824f50d96 od: prefer xpalloc to x2nrealloc
* src/od.c (n_specs, n_specs_allocated, write_block, get_lcm, main):
Use idx_t instead of size_t for some sizes, so that we can
use xpalloc.
(decode_format_string): Prefer xpalloc to X2NREALLOC.
2024-11-08 23:41:18 -08:00
Paul Eggert
7572abed94 expand: check for colno overflow
* src/expand-common.c (get_next_tab_column): Check for tab
stop overflow here.  All callers changed to not check.
* src/expand.c (expand): Use colno for column number.
2024-11-08 23:41:18 -08:00
Paul Eggert
b857d66b51 ls: fix aclinfo cache bug
Found when testing on a new platform with a new file system.
* src/ls.c (file_has_aclinfo_cache): For failures, also cache
return value, scontext, and scontext_err, and when using cached
values make sure buf and size have reasonable values for
aclinfo_free etc.
2024-11-08 23:41:18 -08:00
Paul Eggert
e9d294afb9 ls: use Gnulib’s unsupported errno list
* bootstrap.conf (gnulib_modules): Add acl-permissions, which
supplies acl_errno_valid, and which we are already using
indirectly via file-has-acl.
* src/ls.c (errno_unsupported): Remove.  All calls replaced
by !acl_errno_valid.
2024-11-08 23:41:18 -08:00
Paul Eggert
6e297e8855 expand: use signed colno
* src/expand-common.h (colno): Now intmax_t, not uintmax_t.
2024-11-08 23:41:18 -08:00
Paul Eggert
e4edd48a2a expand: refactor to introduce ‘colno’
* src/expand-common.h (colno): New typedef.
All uses of uintmax_t for column numbers replaced by colno.
* src/expand-common.c (add_tab_stop): Use xpalloc
instead of X2NREALLOC, and use ckd_add to check for overflow.
2024-11-08 23:41:18 -08:00
Paul Eggert
97807bff17 expand: prefer xpalloc to x2nrealloc
* src/expand-common.c (max_column_width, n_tabs_allocated)
(first_free_tab, add_tab_stop, parse_tab_stops, validate_tab_stops)
(get_next_tab_column):
Use idx_t for sizes.  All uses changed.
(add_tab_stop): Use xpalloc instead of X2NREALLOC.
Use ckd_add to check for overflow, instead of doing it by hand.
2024-11-08 23:41:18 -08:00
Paul Eggert
7e86be8dbb env: prefer xpalloc to x2nrealloc
* src/env.c (usvars_alloc): Use idx_t for size.
(append_unset_var): Use xpalloc instead of x2nrealloc.
2024-11-08 23:41:18 -08:00
Paul Eggert
ff9b85970b chroot: expand heap a bit less aggressively
* src/chroot.c (parse_additional_groups, main):
Prefer idx_t to size_t for sizes.
(parse_additional_groups): Use xpalloc instead of x2nrealloc.
2024-11-08 23:41:18 -08:00
Paul Eggert
5af1b2662b maint: expand heap a bit less aggressively
* gl/lib/heap.c (struct heap, heap_alloc, heap_insert)
(heapify_down, heapify_up): Prefer idx_t to size_t for sizes.
(heap_insert): Use xpalloc instead of x2nrealloc.
(heapify_down): Return void since no caller cares about value.
* gl/modules/heap: Depend on idx.
2024-11-08 23:41:18 -08:00
Bruno Haible
fbfda4df1a build: Regenerate distributed built files in $(top_srcdir)
* src/local.mk (src/dircolors.h, src/fs-is-local.h, src/fs.h): Generate
in $(top_srcdir).
2024-11-03 15:52:32 -08:00
Pádraig Brady
a94929715c cksum: add support for --algorithm=crc32b
$ echo -n '123456789' | cksum --raw -a crc32b | basenc --base16
  CBF43926

* bootstrap.conf: Explicitly depend on the crc module.
* doc/coreutils.texi (cksum): Add "crc32b" as an argument to -a.
* src/cksum.c (crc32b_sum_stream): A new function similar to
crc_sum_stream, but which does not include the length in
the CRC calculation.
* src/cksum.h: Add crc32b_sum_stream prototype.
* src/digest.c: Add "crc32b" as an argument to -a.
* tests/cksum/cksum.sh: Refactor to test both crc and crc32b.
* tests/cksum/cksum-a.sh: Add "crc32b" case.
* tests/cksum/cksum-base64.pl: Likewise.
* tests/misc/read-errors.sh: Likewise.
* NEWS: Mention the new feature.
2024-11-02 19:57:35 +00:00
Collin Funk
ee231019e1 test: add string operators added by POSIX 2024
* src/test.c (binop): Recognize the ">" and "<" operators.
(three_arguments): Likewise.
(binary_operator): Implement the "<" and ">" operators.
(usage): Add operators to --help output.
* tests/test/test.pl (@Tests): Add functionality tests.
* doc/coreutils.texi (test invocation, String tests): Document new
operators.
* NEWS: Mention the new feature.
2024-11-02 14:03:49 +00:00
Pádraig Brady
f48123ef27 doc: mention new timeout short options in NEWS
* NEWS: Mention the timeout -f and -p options.
2024-11-01 15:58:42 +00:00
Collin Funk
0c670beed9 stty: adjust --help to match POSIX 2024
* src/stty.c (usage): Mark cols, rows, and size as standardized by
POSIX.
* doc/coreutils.texi (Special): Likewise.
2024-11-01 12:49:50 +00:00
Pádraig Brady
69aaec486f doc: fix timeout --help for -p
* src/timeout.c (usage): Fix typo of period with comma.
* tests/timeout/timeout.sh: Only test a single option variant,
as tests/misc/usage_vs_getopt.sh suffices for basic option validation.
2024-11-01 12:49:44 +00:00
Pádraig Brady
f4fbc1a9f9 timeout: add -f and -p short options as per POSIX 2024
* src/timeout.c: Support -f and -p short options, corresponding to
--foreground and --preserve-status respectively.  This adds
compatability with POSIX 2024 and OpenBSD.
(usage): Separate translations, and reorder the option descriptions.
* doc/coreutils.texi (timeout invocation): Adjust accordingly,
and also reorder the option descriptions alphabetically.
* tests/timeout/timeout.sh: Also test short option variants.
2024-10-30 12:49:26 +00:00
Sylvestre Ledru
0c9d372c96 tests: cksum: verify --check with comments
* tests/cksum/cksum-c.sh: Add a test case with a comment.
2024-10-20 14:11:38 +01:00
Sylvestre Ledru
f082cb8284 tests: improve ls --dired with symlink testing
* tests/ls/dired.sh: Verify ls --dired with symlink.
2024-10-20 14:10:30 +01:00
Pádraig Brady
58a88f30f8 maint: add syntax-check to ensure all gl/ files are distributed
* cfg.mk (sc_gldist_missing): Add a new target to ensure we don't
forget to distribute any new gl/ files.
* gl/local.mk: Remove generation comment since it's
now encapsulated in the syntax-check, which outputs a consumable
diff to make any future adjustments.
Also adjust ordering to that of the C locale used in the syntax check.
2024-10-14 13:12:03 +01:00
Bruno Haible
0b5bcaed95 build: distribute the gl/ directory in the tarballs
Suggested by Michael Pratt in
<https://mail.gnu.org/archive/html/coreutils/2024-10/msg00010.html>.

* gl/local.mk: New file, based on gettext/gnulib-local/Makefile.am.
* Makefile.am: Include it.
2024-10-14 11:26:15 +01:00
Masatake YAMATO
03a7242fc6 cp,mv: align the descriptions of long options
* src/cp.c (usage): Adjust white spaces for --update.
* src/mv.c (usage): Ditto.
Fixes https://bugs.gnu.org/73772
2024-10-12 17:47:13 +01:00
Collin Funk
8083944484 chroot,whoami: use uintmax_t for printing uids
* src/chroot.c (main): Cast the uid to uintmax_t instead of int.
* src/whoami.c (main): Cast the uid to uintmax_t instead of unsigned
long int.
2024-10-07 11:47:57 +01:00
Bernhard Voelker
0911361e79 maint: adjust check-ls-dircolors to recent change in ls.c
'make distcheck' would fail since commit 75b34c77e4, because the
comparison by check-ls-dircolors fails.

* Makefile.am (check-ls-dircolors): Adjust sed(1) expression to the
changed data initialization.
2024-10-06 16:09:26 +02:00
Pádraig Brady
a94a551ee0 ls: fix spurious output with -Z
* src/ls.c (gobble_file): Only output an error if there actually
was an error.
2024-10-03 15:17:17 +01:00
Pádraig Brady
96100139fc tests: ls: don't always skip a capability test
* tests/ls/no-cap.sh: Move to being a root only test, since
commit v9.5-132-g2a6bed933 we now need to call setcap
to make the test effective.  Otherwise we would have always
just skipped the test.
2024-10-03 12:41:37 +01:00
Paul Eggert
2a6bed9332 ls: tune usage of getxattr/stat syscalls
Update gnulib submodule to latest.  This changes the file_has_aclinfo
API, so at the same time do the following changes to ls.c, which
adjusts to these changes among other things.
* src/ls.c (filetype_d_type, d_type_filetype): New static constants.
(format_needs_capability): New static var.
(main): Set and use it.  Don’t set format_needs_stat merely
because print_scontext, as we needn’t call stat to get the
scontext.  Instead, set format_needs_type if print_scontext but
not format_needs_stat.
(print_dir): Use new static tables to determine filetype
more efficiently.
(file_has_aclinfo_cache): Adjust to Gnulib file_has_aclinfo API change.
(gobble_file): Check stat if format_needs_type but the type is
unknown.  Be conservative, and when deciding whether to check stat
but the type is unknown, assume it might be directory.  Similarly
for normal files when classifying; if the type is unknown assume
it might be normal.  Use new static constants and IFTODT to
compute filetype more straightforwardly.  Get ACLs and check for
capability less often.
(get_color_indicator): Omit unnecessary call to is_colored (C_CAP),
since f->has_capability can be true only if is_colored (C_CAP).
2024-10-02 23:03:04 -07:00
Paul Eggert
8fbb1076d5 ls: omit cast from gobble_file
* src/ls.c (gobble_file): Minor refactoring.  Last arg is now null
pointer, not "", for no directory.  All callers changed.
Avoid need for cast from char const * to char *.
2024-10-02 23:03:04 -07:00
Paul Eggert
a89896f8e7 ls: check FILETYPE_INDICATORS cardinality
* src/ls.c (filetype_cardinality): New constant.
(filetype_letter): Omit unnecessary trailing NUL.
(FILETYPE_INDICATORS): Remove, moving definiens to ...
(get_color_indicator): ... here, and check its cardinality too.
2024-10-02 23:03:04 -07:00
Paul Eggert
75b34c77e4 ls: tune indicator_name
* src/ls.c (indicator_name): Simplify type; it is now merely
a 2-dimensional array of char.  All uses changed.
2024-10-02 23:03:04 -07:00
Paul Eggert
8121021d05 ls: omit some unnecessary NULs
* src/ls.c (BIN_STR): New macro, replacing LEN_STR_PAIR.
All uses changed.  This avoids the need to store the
trailing \0 in each string.  This change is more for clarity,
to make it clear the \0 is not needed.
2024-10-02 23:03:04 -07:00
Paul Eggert
ec0fe0d2b8 ls: tune is_colored
* src/ls.c (is_colored): Tune.
This shrinks the machine code considerably on x86-64.
2024-10-02 23:03:04 -07:00
Paul Eggert
65c58007f7 ls: omit unnecessary test
* src/ls.c (gobble_file): Omit redundant test of variable that
must be false here.
2024-10-02 23:03:04 -07:00
Pádraig Brady
647a8b8cf9 ls: reinstate capability checking in more cases
The recent commit v9.5-119-g4ce432ad8 restricted capability checking
to only files with XATTR_NAME_CAPS set.  If this is done then we need
to adjust tests/ls/no-cap.sh so that it doesn't always skip.  More
problematically XATTR_NAME_CAPS was only determined in long listing
mode, thus breaking capability coloring in short listing mode
as evidenced by the failing tests/ls/capability.sh test.

Note capability checking does have a large overhead, but we've
disabled capability checking by default anyway through the default
color configuration since v9.0-187-g6b5134770

So for these reasons revert to checking capabilities as before.

* src/ls.c (gobble_file): Check for capabilities in all modes
if enabled in color config.
2024-10-02 23:17:48 +01:00
Lukáš Zaoral
2606f5a043 doc: ls: fix regression in -k description
The description of -k regressed in coreutils 9.0

* doc/coreutils.texi (ls invocation): Fix incomplete paragraph
describing -k introduced by a mistake in commit v8.32-180-g1625916a1.
2024-10-02 22:26:59 +01:00
Pádraig Brady
851064b4c7 tests: df: avoid false failure due to fuse.portal
* tests/df/skip-rootfs.sh: Explicitly exclude "fuse.portal"
file systems as these give EPERM errors from statfs().
2024-10-02 16:43:34 +01:00
Pádraig Brady
6f1ec80f31 tests: fix skipping of mtab simulation tests
Where rpl_fopen() is used rather than fopen(),
wrapping fopen() is ineffective.
Note rpl_fopen() is used as of glibc-2.39 at least
(due to fflush and fclose being replaced).

* tests/df/no-mtab-status.sh: Wrap open() rather than fopen().
* tests/df/skip-duplicates.sh: Likewise.
2024-10-02 16:33:42 +01:00
Bernhard Voelker
e71b24cedc maint: avoid sc_preprocessor_indentation failure in factor.c
Prompted by the following 'make syntax-check' failure:
  cppi: src/factor.c: line 175: not properly indented
  cppi: src/factor.c: line 176: not properly indented
  maint.mk: incorrect preprocessor indentation
  make: *** [cfg.mk:750: sc_preprocessor_indentation] Error 1

* src/factor.c: Filter through 'cppi -a'.
2024-09-30 10:07:23 +02:00
Bernhard Voelker
4d62d46a41 tests: add fold(1) test for --bytes option
Inspired by:
- https://access.redhat.com/solutions/3459791
- https://src.fedoraproject.org/rpms/coreutils/c/8080f5a15a20362c

* tests/misc/fold.pl (bw1, bw2): Add tests for 'fold -b'.
2024-09-30 10:07:19 +02:00
Paul Eggert
4ce432ad87 ls: use fewer xattr-related syscalls
* src/ls.c: Do not include <selinux/selinux.h> or "smack.h".
Include <linux/attr.h> if HAVE_LINUX_ATTR_H, for XATTR_NAME_CAPS.
(free_ent): Use aclinfo_scontext_free to free f->scontext.
(getfilecon_cache): Remove; no longer needed.
(file_has_aclinfo_cache): Rename from file_has_acl_cache,
and use file_has_aclinfo instead of file_has_acl.  All uses changed.
(gobble_file): Use file_has_aclinfo instead of file_has_acl, so
that we get more info about the file before deciding whether to
issue further syscalls for it.  Let file_has_aclinfo worry about
smack and SELinux.  Call has_capability only if the xattr list
mentions XATTR_NAME_CAPS.
2024-09-29 22:08:45 -07:00
Paul Eggert
218001187b build: update gnulib submodule to latest 2024-09-29 22:08:45 -07:00
Paul Eggert
0619c4a491 factor: eliminate print_uuint recursion
* src/factor.c (lbuf_putint_append): New function, with
most of the old lbuf_putint body.  Do the umaxtostr stuff
by hand so that we needn’t worry about the trailing NUL.a
Do the string copy by hand since the string is so short.
(lbuf_putint): Reimplement in terms of lbuf_putint_append.
Omit last arg, which is no longer needed.  All callers changed.
(print_uuint): Rewrite to avoid recursion, using
lbuf_putint_append for the usual case.
2024-09-27 17:42:59 -07:00
Paul Eggert
d84afaa0a7 factor: lessen print_uuint recursion
* src/factor.c (BIG_POWER_OF_10, LOG_BIG_POWER_OF_10):
New constants.
(print_uuint): Use them to lessen recursion depth.
2024-09-27 17:42:59 -07:00
Paul Eggert
92902de118 factor: print_uuint accepts uuint
* src/factor.c (print_uuint): Rename from print_uintmaxes
and accept a uuint rather than two uintmax_t values.
Alll uses changed.
2024-09-27 17:42:59 -07:00
Paul Eggert
335f6fa2ec factor: simplify table count
* src/factor.c (PRIMES_PTAB_ENTRIES): Simplify.
2024-09-27 17:42:59 -07:00
Paul Eggert
74d791c4b0 factor: macro refactoring
* src/factor.c (W_TYPE_SIZE): Simplify by always defining
to UINTMAX_WIDTH.
(W): Remove.  All uses replaced by W_TYPE_SIZE.
We no longer need one of its static_asserts.
2024-09-27 17:42:59 -07:00
Paul Eggert
d598ef7a6c factor: improve gmp-related buffering
Previously, the code used stdio buffers for gmp numbers,
and did its own buffering for smaller numbers.  This meant
for more flushing than was needed.  The code now uses its
own buffering for all standard output, which makes for
less flushing and fewer writes.
* src/factor.c (lbuf_half_flush): New function, taken from the
body of lbuf_putnl.
(lbuf_putnl): Use it.
(lbuf_putmpz): New function, to output an mpz without using stdio.
(print_factors): Output via functions instead of via stdio.
2024-09-27 17:42:59 -07:00
Paul Eggert
666e226994 factor: buffer stdout like other progs do
* src/factor.c (lbuf_putnl): Don’t worry about whether
stdin is a tty when deciding whether to buffer stdout.
2024-09-27 17:42:59 -07:00
Paul Eggert
2bd3db74d5 factor: improve fd buffering
* src/factor.c (struct lbuf_, lbuf, lbuf_alloc): Remove.
All uses removed.
(FACTOR_PIPE_BUF): Now a constant instead of a macro.
Increase to PIPE_BUF if available.
(lbuf_buf, lbuffered): New static vars, replacing lbuf.
All uses changed.
(lbuf_flush): Avoid unlikely recursion on write failure.
(lbuf_putc): Now simply adds a byte to the buffer.
(lbuf_putnl): Do the work of the old lbuf_putc ('\n').
Use changed.  Use memrchr to find the newline.
(lbuf_putint): Widths are now int, not size_t.
2024-09-27 17:42:59 -07:00
Paul Eggert
7c1149359a factor: powm2 returns uuint
* src/factor.c (powm2): Return uuint rather than half via
pointer. All callers changed.
2024-09-27 17:42:59 -07:00
Paul Eggert
d875200bbf factor: factor_using_division returns uuint
* src/factor.c (factor_using_division): Return uuint rather than
half via pointer. All callers changed.
2024-09-27 17:42:59 -07:00
Paul Eggert
b74ba189e8 factor: gcd2_odd returns uuint
* src/factor.c (gcd2_odd): Return uuint rather than half via pointer.
All callers changed.
2024-09-27 17:42:59 -07:00
Paul Eggert
6314313935 factor: mod2 now returns uuint
* src/factor.c (uuset): New function.
(mod2): Return uuint rather than having half the returned value
stored via a pointer.  This makes the code a bit easier to read
and can help the compiler avoid aliasing issues.  All callers changed.
2024-09-27 17:42:58 -07:00
Paul Eggert
bb2a973fdc factor: new type uuint
This refactors to add a new type, a uintmax_t pair, which
can simplify some code without slowing it down.
* src/factor.c (uuint): New type.
(lo, hi, hiset, make_uuint): New functions.
(struct factors.plarge): Use the new type.  All uses changed.
2024-09-27 17:42:58 -07:00
Paul Eggert
2da88ed179 factor: tweak prime_p zero counting
* src/factor.c (prime_p): Use stdc_trailing_zero here too.
This doesn’t make much of a performance difference but
we might as well be consistent.
2024-09-27 17:42:58 -07:00
Paul Eggert
f678de6f0e factor: tweak gcd2_odd performance
* src/factor.c (gcd2_odd): Use stdc_trailing_zeros here too.
2024-09-27 17:42:58 -07:00
Paul Eggert
9cc3e786e6 factor: tweak gcd_odd performance
* src/factor.c (gcd_odd): Use stdc_trailing_zeros instead of
counting zeros by hand.
2024-09-27 17:42:58 -07:00
Paul Eggert
e3f3670c7e factor: switch to stdc_leading_zeros etc
* bootstrap.conf (gnulib_modules): Add stdc_trailing_zeros.
* cfg.mk (_gl_TS_unmarked_extern_vars): Remove factor_clz_tab,
as it’s no longer present.
* src/factor.c: Include stdbit.h.
(__clz_tab, factor_clz_tab): Remove.
(ASSERT, UHWtype, __GMP_DECLSPEC): Use simpler way to pacify
-Wunused-macros.
(count_leading_zeros, count_trailing_zeros):
Remove.  All uses replaced by stdc_leading_zeros, stdc_trailing_zeros.
(factor_using_division, prime2_p): Add a couple of ‘assume’s
so that GCC knows the stdc_* calls are nonzero and can
optimize accordingly.
2024-09-27 17:42:58 -07:00
Paul Eggert
5867465510 factor: port to platforms
* src/factor.c (mod2): Work even if cntd <= cnta.  The old version
of the code assumed that shifts by N had unspecified behavior
unless 0 <= N < wordsize.  Although this assumption is portable to
all known practical platforms, the C standard says these shifts
have undefined behavior and some pedantic platforms check this.
* tests/factor/create-test.sh:
* tests/local.mk (factor_tests): New test t37.
2024-09-27 17:42:58 -07:00
Pádraig Brady
ac5213acba doc: remove extraneous periods from option --help
* src/df.c (usage): Remove period from --help description.
* src/cksum.c (usage): Likewise.
* src/cp.c (usage): Likewise.
* src/mkdir.c (usage): Likewise.
* src/mv.c (usage): Likewise.
* src/tee.c (usage): Likewise.
2024-09-23 22:12:37 +01:00
Pádraig Brady
9e5274cd1b doc: sort: be more descriptive than 'manual'
* src/sort.c (usage): Don't mention the ambiguous "manual",
rather "full documentation", echoing the language at the
bottom of each coreutils man page.
Fixes https://bugs.gnu.org/72914
2024-09-23 21:31:59 +01:00
Pádraig Brady
4da7daa01f doc: env: simplify extra info in the man page
* man/env.x: Avoid confusion in the [OPTIONS] section
by renaming to [SCRIPT OPTION HANDLING], and removing info
regarding default signal handling, which is best
restricted to the full info manual.
Addresses https://bugs.gnu.org/72914
2024-09-23 21:17:28 +01:00
Pádraig Brady
7337076ecf doc: improve printf(1) reference in echo man page
* src/echo.c (usage): Use printf(1) rather than 'printf',
which is marked up more appropriately, and can be
referenced by some man page readers.
Fixes https://bugs.gnu.org/72914
2024-09-23 20:53:25 +01:00
Pádraig Brady
afab48f23f doc: fix option markup in chgrp, chown, chmod man pages
* src/system.h (emit_symlink_recurse_options): Remove quotes
so that help2man markup is applied to the option.
Fixes https://bugs.gnu.org/72914
2024-09-23 20:50:04 +01:00
Pádraig Brady
5cecd703e5 printf: add indexed argument support
* src/printf.c (print_formatted): Add support for %i$ indexed args.
* tests/printf/printf-indexed.sh: Add a new file of test cases.
* tests/local.mk: Reference the new test file.
* doc/coreutils.texi (printf invocation): Mention how mixed
processing of indexed and sequential references are supported,
unlike the printf(2) library function.
* NEWS: Mention the new (POSIX:2024) feature.
Addresses https://bugs.gnu.org/73068
2024-09-13 17:29:02 +01:00
Collin Funk
408301e4bc maint: assume C89 escape sequences
* src/ptx.c (unescape_string) [!__STDC__]: Assume compiler supports '\a'
and '\v' escape sequences.
2024-09-04 11:40:44 +01:00
Pádraig Brady
a4617a5bc1 build: update gnulib submodule to latest 2024-08-29 02:17:59 +01:00
Pádraig Brady
9b9763e6a7 all: fix error checking in gl/lib/xdectoint.c
This issue was noticed with -flto on GCC 14.2.1

* gl/lib/xdectoint.c (__xnumtoint): Only inspect the
returned value if LONGINT_INVALID is not set,
as the returned value is uninitialized in that case.
Fixes https://bugs.gnu.org/72842
2024-08-28 12:35:07 +01:00
Pádraig Brady
ffc7b6a6e9 maint: avoid a syntax check failure
* tests/df/no-mtab-status.sh: mntent.h is always provided now by gnulib.
* tests/df/skip-duplicates.sh: Likewise.
2024-08-25 09:15:43 +01:00
Collin Funk
781b55cb57 maint: adjust to Gnulib acl changes
* src/copy.c (copy_reg, copy_interal): Use xcopy_acl instead of
copy_acl.  Use xset_acl instead of set_acl.
* src/cp.c (re_protect): Likewise.
2024-08-25 08:54:14 +01:00
Collin Funk
eefd1c087b build: update gnulib submodule to latest
* bootstrap: Update from Gnulib.
2024-08-25 08:53:45 +01:00
Pádraig Brady
403cb48413 install: dereference source symlinks when comparing
* NEWS: Mention the change in behavior.
* src/install.c (need_copy): s/lstat/stat/ for the source.
* tests/install/install-C.sh: Add test cases
(and improve existing test case which wan't valid
due to the existing non standard modes on test files).
Addresses https://bugs.gnu.org/72707
2024-08-19 14:47:07 +01:00
Paul Eggert
9e60f2db90 maint: adjust to recent removal of verror.c
* po/POTFILES.in: Remove lib/verror.c
2024-08-15 15:12:38 -07:00
Paul Eggert
8271864537 build: update gnulib submodule to latest
* boostrap.conf (gnulib.modules): Add xvasprintf, which
had been omitted by mistake.
* src/copy.c, src/dd.c, src/test.c: Don't include verror.h,
as Gnulib removed it.
2024-08-15 00:35:09 -07:00
Pádraig Brady
84f8202287 ls: add support for explicit file name sorting
Support overriding previous sorting options
with an explicit --sort=name option.

* doc/coreutils.texi (ls invocation): Document the new option.
* src/ls.c (usage): Likewise.
(sort_args): Add the "name" entry, and sort to be consistent
with the ordering presented in --help.
* tests/ls/ls-time.sh: Add test cases.
* NEWS: Mention the new feature.
Suggested by: Tzvetelin Katchov
2024-08-11 20:40:15 +01:00
Pádraig Brady
9e448e8a51 maint: fix syntax-check failure
* gl/lib/xdectoint.h: Reinstate indentation enforced with cppi.
* src/head.c: Remove now redundant inclusion of "quote.h".
2024-08-11 15:13:04 +01:00
Pádraig Brady
296cc3ed96 doc: printf %b: clarify octal processing
* src/printf.c: Remove redundant comment.
State explicitly that the leading 0 is the exception
from normal escape processing.  Remove a full stop for consistency.
* doc/coreutils.texi (printf invocation): Add a reference
to C99 string escapes since these are not mentioned
in the referenced glibc printf info. Also explicitly state
the leading 0 exception.  Also use NNN rather than OOO
to be consistent with the --help documentation.
Also remove and extraneous '\' and fix grammar in the info
regarding the ninth bit.
Addresses https://bugs.gnu.org/72657
2024-08-11 15:11:03 +01:00
Paul Eggert
586dfa995a maint: adjust to Gnulib safe_read etc. changes
Although these patches don’t affect user-visible behavior,
they do clean up the source code a bit, and the
machine code should be a tiny bit more efficient.
* src/cat.c (simple_cat, cat):
* src/csplit.c (read_input):
* src/head.c (copy_fd, elide_tail_bytes_pipe)
(elide_tail_lines_pipe, elide_tail_lines_seekable, head_bytes)
(head_lines):
* src/install.c (have_same_content):
* src/tac-pipe.c (buf_init_from_stdin):
* src/tac.c (tac_seekable, copy_to_temp):
* src/tail.c (dump_remainder, file_lines, pipe_lines)
(pipe_bytes, start_bytes, start_lines, tail_forever_inotify):
* src/tr.c (plain_read):
Adjust to recent Gnulib changes by using new types
for safe_read, safe_write, full_read, full_write.
2024-08-10 23:00:33 -07:00
Paul Eggert
5b4741dbc2 maint: list Gnulib sys_types directly
* bootstrap.conf (gnulib_modules): Add sys_types.
Although it’s already brought in indirectly, coreutils
code includes <sys/types.h> directly.
2024-08-10 23:00:33 -07:00
Paul Eggert
7633e82c88 build: update gnulib submodule to latest 2024-08-10 23:00:33 -07:00
Paul Eggert
8fe800a06e head: fix overflows in elide_tail_bytes_pipe
Not clear that the overflows could be exploited,
but they made the code confusing.
* src/head.c (elide_tail_bytes_pipe): Don’t convert uintmax_t
to size_t first thing; wait until it’s known the value will fit,
and then use idx_t rather than size_t to prefer signed types.
Prefer idx_t in nearby code, too.
Rename locals n_elide_0 to n_elide (for consistency elsewhere)
and n_elide to in_elide.
Remove bogus (SIZE_MAX < n_elide + READ_BUFSIZE) test;
in the typical case where n_elide’s type was the same as
that of SIZE_MAX, the test never succeeded, and in the
less-common case where n_elide was wider than size_t,
the addition could silently overflow, causing the test
to fail when it should succeed.  The test is not needed anyway now.
Add static asserts to document code assumptions.
Redo the ! (n_elide <= HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD) case
so that it works with enormous values of n_elide even on
32-bit platforms; for example, n_bufs is now uintmax_t not size_t.
Simplify by using xpalloc instead of by-hand code.
Remove bogus ‘if (rem)’ test, as rem is always nonzero.
2024-08-10 22:19:44 -07:00
Paul Eggert
91657204c1 head: new test for big count
* tests/head/head-c.sh: Also test head -c with a number
much bigger than UINTMAX_MAX.
2024-08-10 19:30:01 -07:00
Paul Eggert
cb11d2ab5e tail: support counts > 2**64
* src/tail.c (tail_lines): If skipping all input, use lseek if
possible.
(parse_options): Allow counts to exceed 2**64.
(main): Don’t subtract 1 from UINTMAX_MAX, since it stands
for infinity in this context.
(main): Also don’t read anything when given infinite elisions.
* tests/tail/tail.pl: Adjust to match new behavior.  Rename err-5
test to big-c and expect the invocation to succeed, since ‘tail
-c99999999999999999999’ now succeeds instead of (unnecessarily)
failing.
2024-08-10 19:30:01 -07:00
Paul Eggert
0f9e2719e0 head: off_t not uintmax_t for file offset
* src/head.c (elide_tail_lines_pipe):
Use off_t, not uintmax_t, for a local var that is
a file offset.
2024-08-10 19:30:01 -07:00
Paul Eggert
ad094f20ed nproc: support --ignore counts > 2**64
* src/nproc.c (main): Allow --ignore arg to exceed 2**64.
2024-08-10 19:30:01 -07:00
Paul Eggert
67eff6359d nl: support -l counts > 2**64
* src/nl.c (main): Allow -l arg to exceed 2**64.
2024-08-10 19:30:01 -07:00
Paul Eggert
22ac54858c head: support counts > 2**64
* src/head.c (head): Optimize for -n-HUGE, where HUGE exceeds
2**64 - 2.
(string_to_integer): Return UINTMAX_MAX for too-large numbers,
instead of failing.
(main): Omit no-lnger-necessary test for byte count overflow.
2024-08-10 19:30:01 -07:00
Paul Eggert
f2c84fe630 digest: improve -l overflow diagnostic
* src/digest.c (main): Use better diagnostic for -l overflow,
by using XTOINT_MAX_QUIET to suppress the worse diagnostic.
2024-08-10 19:30:01 -07:00
Paul Eggert
495a35311c maint: distinguish EOVERFLOW vs ERANGE better
Also, prepare for allowing some arguments to overflow
without that being an error.
* gl/lib/xdectoint.c: Do not include stddef.h,
since we no longer use ‘unreachable’.
(xnumtoimax, xnumtoumax, __xnumtoint):
New arg FLAGS.  All callers changed.
Stop using __xdectoint_signed.  All definers removed.
* gl/lib/xdectoint.h (XTOINT_MIN_QUIET, XTOINT_MAX_QUIET)
(XTOINT_MIN_RANGE, XTOINT_MAX_RANGE): New flag constants.
* src/fmt.c (main):
* src/fold.c (main):
* src/nl.c (main):
* src/pr.c (getoptnum):
* src/split.c (main):
Use XTOINT_MIN_RANGE and XTOINT_MAX_RANGE if appropriate.
* src/pr.c (getoptnum): Return int rather than returning void
and storing through int *.
* src/stty.c (apply_settings):
Use ckd_add to check for overflow instead of doing it by hand.
(integer_arg): Accept and return uintmax_t, not unsigned long.
2024-08-10 19:30:01 -07:00
Richard Purdie
c5725c8c4b tests: df-P.sh: fix intermittent false failure
The test writes to the disk and means the space used changes. If this
crosses a number boundary, the heading spacing can change:

-Filesystem     1024-blocks  Used Available Capacity Mounted on
+Filesystem     1024-blocks   Used Available Capacity Mounted on

* tests/df/df-P.sh: Squash spaces with tr to avoid alignment variations.
2024-08-08 18:37:48 +01:00
Paul Eggert
4e98e95df2 build: modernize AC_CHECK_TYPE usage
* m4/jm-macros.m4 (gl_CHECK_ALL_TYPES):
Use current form of AC_CHECK_TYPE instead of the
no-longer-documented obsolescent form.
2024-08-04 15:33:05 -07:00
Pádraig Brady
e397d3f1d3 maint: avoid warning on older GCC compilers
* src/shuf.c: Avoid -Werror=maybe-uninitialized on GCC 10.2.1 at least.
This issue does seem to be addressed on GCC 12.
2024-08-04 12:14:25 +01:00
Pádraig Brady
1bb31793c2 tests: limit mem usage on potentially expensive test
* tests/misc/write-errors.sh: Limit mem usage if possible,
as some implementations may use unbounded memory for
the tests cases used here.
2024-08-04 10:58:31 +01:00
Pádraig Brady
440b40eece tests: ensure utils support writing to a closed pipe
* tests/misc/write-errors.sh: A closed pipe is a common scenario,
and should not induce an error.  The general case is discussed at:
https://www.pixelbeat.org/programming/sigpipe_handling.html
2024-08-04 10:58:31 +01:00
Pádraig Brady
bead5b05d0 doc: reference 'dircolors invocation' from ls --color info
* doc/coreutils.texi: Reference how to configure colors,
from the ls --color description.
2024-08-04 10:58:31 +01:00
Pádraig Brady
801792c698 doc: clarify which ls color attributes don't apply to dirs
* src/dircolors.hin: Clarify that SETUID, SETGID, CAPABILITY, and EXEC
coloring, only apply to regular files.
2024-08-04 10:58:31 +01:00
Paul Eggert
0e5fe9e019 shuf: tiny simplification
* src/shuf.c (main): Omit redundant assignment.
2024-08-03 23:22:53 -07:00
Paul Eggert
1ea7255f8b shuf: avoid integer overflow on huge inputs
* gl/lib/randperm.c: Include <stdckdint.h>.
(randperm_bound): Return SIZE_MAX if the multiplication overflows.
Do not overflow when converting bit count to byte count.
2024-08-03 23:22:53 -07:00
Paul Eggert
bfbb3ec7f7 shuf: fix randomness bug
Problem reported by Daniel Carpenter <https://bugs.gnu.org/72445>.
* gl/lib/randread.c (randread_new): Fill the ISAAC buffer
instead of storing at most BYTES_BOUND bytes into it.
2024-08-03 23:22:53 -07:00
Collin Funk
1ae98dbda7 maint: remove unnecessary inttostr usage in printf
* src/cksum.c (output_crc): Use '%ju' instead of umaxtostr.
* src/shred.c (dopass): Likewise.
* src/csplit.c (handle_line_error, regexp_error, close_output_file)
(parse_patterns): Use '%jd' instead of offtostr.
* src/tail.c (xlseek): Likewise.
* src/head.c (elseek): Likewise.
* src/group-list.c (gidtostr_ptr): Remove function.
(gidtostr): Remove macro.
(print_group): Use '%ju' instead of umaxtostr.
* src/id.c (gidtostr_ptr, uidtostr_ptr): Remove functions.
(gidtostr, uidtostr): Remove macros.
(print_user, print_full_info): Use '%ju' instead of umaxtostr.
* src/sort.c (specify_nmerge): Use '%u' instead of uinttostr.
2024-07-30 08:53:59 +01:00
Pádraig Brady
83ec7a706a build: support creating reproducible tarball contents
We already support reproducible builds since commit v8.24-99-gc1b3d6587,
and this adjusts that change to also support reproducible
tarball contents with subsequent runs of `make dist`.

* Makefile.am: Don't create a varying .timestamp file, instead ...
* man/local.mk: Rely on the timestamp of the .tarball-version file.
Fixes https://bugs.gnu.org/72232
2024-07-22 17:47:24 +01:00
Paul Eggert
65a46e9e21 tests: port to noatime file systems
On these file systems the atime is always zero.
Problem found with ZFS on Ubuntu 24.04 LTS.
* tests/stat/stat-birthtime.sh (check_timestamps_updated):
* tests/stat/stat-nanoseconds.sh:
Work even if atimes are always zero.
* tests/stat/stat-nanoseconds.sh:
Fix typo: print_ver_ called before init.sh sourced.
2024-07-16 01:54:20 +00:00
Paul Eggert
10aabce247 maint: update bootstrap from Gnulib 2024-07-16 01:54:20 +00:00
Paul Eggert
94e8f2b012 maint: adjust to Gnulib -Wsystem-headers change
* configure.ac: Don’t suppress -Wsystem-headers since Gnulib no
longer enables it.
2024-07-16 01:54:20 +00:00
Paul Eggert
ea1fe48b91 build: update gnulib submodule to latest 2024-07-16 01:54:20 +00:00
Bernhard Voelker
74ef0ac8a5 tests: add fold(1) test for non-existent files
* tests/misc/fold.pl: Add 'enoent' test.
2024-07-10 14:33:37 +02:00
Collin Funk
b655c09743 maint: import tests/init.sh from Gnulib during bootstrap
* bootstrap.conf (bootstrap_post_import_hook): Use gnulib-tool
--copy-file to import tests/init.sh.
* tests/init.sh: Remove file.
* .gitignore (/tests/init.sh): Add entry.
2024-07-04 09:35:49 +01:00
Pádraig Brady
50e85d4812 doc: remove 'proposed' in regard to $'' descriptions
$'' is POSIX standard syntax as of POSIX.1-2024, as per:
https://www.austingroupbugs.net/view.php?id=249

* doc/coreutils.texi (quotingStyles): Remove 'proposed'.
* src/printf.c: Likewwise.
Reported at https://bugs.debian.org/1074776
2024-07-03 00:01:53 +01:00
Pádraig Brady
2582db55f3 tests: fix improper use of grep -v
* tests/cksum/cksum-c.sh: Remove improper use of `grep -v`.
2024-07-02 09:53:46 +01:00
Sylvestre Ledru
d3b4bc3080 tests: cksum: check when several files are missing or incorrect
* tests/cksum/cksum-c.sh: Add test cases when several files with errors
2024-07-02 09:11:14 +01:00
Collin Funk
7b3535388c maint: silence deprecated module warning
* bootstrap.conf (gnulib_modules): Use putenv-gnu instead of putenv.
2024-07-01 12:23:19 +01:00
Collin Funk
fe7208b90d maint: prefer endian.h for byte order conversions
* bootstrap.conf (gnulib_modules): Remove byteswap. Add endian.
* src/cksum.c: Include endian.h instead of byteswap.h.
(SWAP): Remove macro.
(cksum_slice8): Use htobe32 instead of SWAP.
(output_crc): Likewise.
* src/sum.c: Include endian.h instead of byteswap.h.
(SWAP): Remove macro.
(output_bsd): Use htobe16 instead of SWAP.
(output_sysv): Use htobe16 instead of SWAP.
* .gitignore: Add /lib/endian.h.
2024-06-29 16:11:23 +01:00
Collin Funk
7cd5143819 build: update gnulib submodule to latest
* gnulib: Update to latest
2024-06-29 16:10:21 +01:00
Pádraig Brady
b95c6ac7d2 ls: treat --time=mtime consistently with other time selectors
* src/ls.c: Track if --time=mtime is explicitly specified,
so that we can apply the GNU extension of sorting by the
specified time, when not displaying (-l not specified),
and not explicitly sorting (-t not specified).
* tests/ls/ls-time.sh: Add / Update test cases.
Fixes https://bugs.gnu.org/71803
2024-06-27 18:37:23 +01:00
Pádraig Brady
72588b2915 doc: document the c-maybe quoting style
* doc/coreutils.texi (ls invocation): Document the "c-maybe"
--quoting-style, which was added as an option in 2008.
Reported at https://bugs.debian.org/1074334
2024-06-26 23:17:12 +01:00
Bruno Haible
28951eaa41 stat: reactivate a translator comment (lost on 2012-01-09)
* src/stat.c (default_format): Move translator comment to immediately
precede the _() invocation.
2024-06-25 12:22:17 +01:00
Bernhard Voelker
bbc972bc82 maint: improve ERE in sc_tests_list_consistency
The ERE used lacks the grouping of the extensions and therefore would
also match files where the first two patterns are not at the end of
the line:
  grep -E '\.sh|\.pl|\.xpl$'

* cfg.mk (sc_tests_list_consistency): Add grouping (...) around the
sub-patterns.  While at it, also remove the redundant escaping, i.e.,
\$$ -> $$ to be consistent with the rest of this file.
2024-06-01 16:59:07 +02:00
Pádraig Brady
3ce31e6f19 stat,tail: sync with latest Linux file systems
* src/stat.c (human_fstype): Rename "FUSEBLK" to "FUSE" to sync with
kernel adjustments.  Add "bcachefs", and "pidfs".  Both are local,
with the latter being similar to "proc" which is also local.
* NEWS: Mention the change in behavior, and the improvement.
2024-05-28 13:38:34 +01:00
Paul Eggert
9290066de0 ls: improve sorting doc
Problem reported by Dan Jaobson (Bug#71171).
* doc/coreutils.texi: Clarify that directory entries are sorted,
not command-line arguments.
* src/ls.c (usage): Be less chatty about -U and
about --group-directories-first.
2024-05-24 08:43:32 -07:00
Sylvestre Ledru
2a72cf1e99 tests: cksum: extend with --status, --ignore-missing and --warn
* tests/cksum/cksum-c.sh: Add test cases for these option combinations.
2024-05-22 11:24:07 +01:00
Pádraig Brady
5691ff399e build: fix build failure in --enable-single-binary mode
* src/local.mk: Avoid overriding automake generated DEPENDENCIES,
so that it applies its adjustments to LDADD to avoid propagating
flags (like -Wl,-rpath) into make targets.  This was seen on FreeBSD
where LIBINTL is set to:
/usr/local/lib/libintl.so -Wl,-rpath -Wl,/usr/local/lib
Instead let automake generate a sanitized src_coreutils_DEPENDENCIES
(based on LDADD), which we then augment with the EXTRA_... variable.
2024-05-21 13:49:04 +01:00
Pádraig Brady
451de5d28a maint: add lib/stdbit.h to .gitignore
Following recent gnulib update
2024-05-21 10:13:22 +01:00
Paul Eggert
afb6ba4d2c stty: port test to Alpine Linux
* tests/stty/stty.sh: Port to Alpine Linux 3.20.0_rc1, whose musl
implementation’s printf invokes ioctl on stdout, so --version
does an ioctl.
2024-05-20 15:15:05 -07:00
Paul Eggert
52e024b7b7 dd: skip some alloc tests on ZFS
* tests/dd/sparse.sh: Skip some tests on ZFS.
2024-05-16 23:30:55 -07:00
Paul Eggert
26ba820157 maint: prefer stdbit.h to count-leading-zeros.h
<stdbit.h> is in C23 and should be more portable in the long run,
now that Gnulib supports it.
* bootstrap.conf (gnulib_modules): Remove count-leading-zeros.
Add stdc_leading_zeros.
* gl/lib/randperm.c, src/ioblksize.h:
Include stdbit.h instead of count-leading-zeros.h.
* gl/lib/randperm.c (floor_lg): Remove; no longer needed.
(randperm_bound): Use stdc_bit_width instead of floor_lg;
* gl/modules/randperm (Depends-on): Remove count-leading-zeros.
Add stdc_bit_width.
* src/ioblksize.h (io_blksize): Use stdc_leading_zeros_ull
instead of count_leading_zeros_ll.
2024-05-16 23:09:32 -07:00
Paul Eggert
23bf614e46 maint: port test warnings to GCC 14
* configure.ac: Disable GCC 14’s -Wmissing-variable-declarations
in the test directory, as it’s not worth the aggravation there.
Likewise for GCC's -Wsuggest-attribute=cold.
2024-05-16 23:09:32 -07:00
Paul Eggert
7b87c5c310 maint: update bootstrap from Gnulib 2024-05-16 23:09:32 -07:00
Paul Eggert
ed65a08f9b build: update gnulib submodule to latest 2024-05-16 23:09:32 -07:00
Paul Eggert
e9744ba058 sort: better -Wmissing-variable-declarations
* src/sort.c: Ignore -Wmissing-variable-declarations only
with GCC 14 and newer, since it didn’t exist earlier.
Ignore the warning only when including md5.h, where it
needs to be ignored, as the warning might be useful elsewhere.
2024-05-16 23:09:32 -07:00
Paul Eggert
44084a3ac2 cksum: improve API consistency checking
* src/cksum.c (main) [CRCTAB]: Generate updated crctab.c (see below).
* src/crctab.c: Include cksum.h, to check consistency
between decl and defn.  Include stdio.h since cksum.h needs it.
2024-05-16 23:09:32 -07:00
Nikolaos Chatzikonstantinou
684db6cb9b doc: improve the man page for sleep
This patch is part of work done for a project from Google Summer of
Code, see the project details at
<https://summerofcode.withgoogle.com/programs/2024/projects/E9Jp7RUx>.

* src/sleep.c (usage): Directly mention the floating-point option,
which is typical for sleeping milliseconds.
Also reorganize the text to be 3 lines rather than 4.
2024-05-15 09:16:38 +01:00
Sylvestre Ledru
b5ce9fb177 tests: cksum: add incorrect data to verify --check & --strict
* tests/cksum/cksum-c.sh: Add test cases.
2024-05-11 11:27:30 +01:00
Pádraig Brady
ccf47cad93 wc: increase I/O size from 16 KiB to 256KiB
Similarly to commit v9.4-143-gfcfba90d0,
and enabled for AVX by commit v9.5-25-g0e4450103.

This was seen to improve AVX performance by about 10%
on an AMD 7800X3D (Ryzen 7 (2023)) CPU,
while having neutral AVX performance,
on an Intel i7-5600U (Broadwell-U (2015)) CPU.
With avx not enabled, this gives about a 3% performance boost,
on an Intel i7-5600U.

* src/wc.c: Use the centrally configured optimum buffer size.
* src/wc_avx2.c: Likewise.
* NEWS: Mention the change in performance.
2024-05-09 15:03:56 +01:00
Evgeny Nizhibitsky
dd976cae23 wc: simplify and generalize AVX code
* src/wc_avx2.c (wc_lines_avx2): Change from
_mm256_sub_epi8() + _mm256_sad_epu8() to
_mm256_movemask_epi8() + __builtin_popcount().
This will allow adjusting the I/O size above 16KiB.
* configure.ac: Align check with routines used in wc_avx2.c.
2024-05-09 14:27:57 +01:00
Bruce Jerrick
6480d59263 doc: pwd: improve the -P help description
* src/pwd.c (usage): Say that symlinks are resolved,
rather than the somewhat ambiguous "avoided".
2024-05-07 13:34:01 +01:00
Nikolay Nechaev
def6b33bf6 maint: rename octhexdigits macros
isodigit -> isoct; octtobin -> fromoct; hextobin -> fromhex.
* src/octhexdigits.h: Rename macros.
* src/stat.c, src/printf.c: Use new macros.
2024-05-05 17:50:28 +01:00
Nikolay Nechaev
f069bb710a maint: factor out common macros of stat and printf
* src/octhexdigits.h: isodigit, hextobin, octtobin macros.
* src/stat.c, src/printf.c: Use octhexdigits.h.
* src/local.mk: Corresponding adjustments.
2024-05-05 17:50:22 +01:00
Nikolay Nechaev
292cf89545 maint: factor out the common show_date functionality
* src/show-date.{h,c}: Declaration and definition of show_date.
* src/du.c: Wse the common show_date instead of the previous local
function.
* src/date.c: Wse the common show_date via a wrapper show_date_helper.
* src/local.mk: Corresponding adjustments.
2024-05-05 17:50:14 +01:00
Sylvestre Ledru
ecf7d12937 cksum: add tests to verify the presence of "*"
* tests/cksum/cksum-a.sh: Add a test case.
2024-05-04 14:08:29 +01:00
Pádraig Brady
de49e993ea cp: actually support --update=none-fail
* src/cp.c: Add the entries for the --update=none-fail option.
* tests/mv/update.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/70727
2024-05-03 10:18:50 +01:00
Collin Funk
ba8a43c24d maint: pacify GCC 14 -Wmissing-variable-declarations
* src/local.mk: Include extern decl for 'Version'.
* src/crctab.c (crctab): Add an extern decl.
* src/cksum.c: Generate an extern decl.
2024-05-01 14:37:18 +01:00
Pádraig Brady
c06d767ada maint: pacify GCC 14 -Wmissing-variable-declarations wrt md5.h
* src/sort.c: Use pragmas to avoid warnings with our
openssl adjustment and to minimize coupling with openssl.
2024-05-01 14:32:26 +01:00
Pádraig Brady
11fd227d95 maint: avoid syntax check failure with long lines
* cfk.mk: Exclude bootstrap from sc_long_lines
as it comes from gnulib.
2024-05-01 14:32:26 +01:00
Pádraig Brady
49f84ecee7 build: bootstrap with python gnulib-tool by default
* gnulib: Update to support bootstrapping with python by default.
* bootstrap: Sync with gnulib.
* cfg.mk: Don't force python implementation with `make world`,
rather rely on the auto selection of python if appropriate.
2024-04-27 13:03:45 +01:00
Pádraig Brady
adb6338bb5 doc: sort: give example for sorting on the last field
* doc/coreutils.texi (sort invocation): Give a DSU example
for sorting names which may have a variable number of fields.
Addresses https://bugs.gnu.org/70532
2024-04-23 21:29:33 +01:00
Pádraig Brady
555f9061ee build: provide way to bootstrap with python gnulib-tool
* cfg.mk: Add a new "world" default target so that one
can bootstrap (using the python implementation), configure,
and make, by using `make -f cfg.mk`.
* gnulib: Update to latest primarily to test the
bootstrap python implementation which is now in beta test.
* README-hacking: Document the `make -f cfg.mk` shortcut.
2024-04-23 12:33:06 +01:00
Paul Eggert
fb543b6b82 tail: avoid infloop with -c on /dev/zero
Problem reported by Ionut Nicula in:
https://bugs.gnu.org/70477
* src/tail.c (tail_bytes): Do not loop forever on commands
like 'tail -c 4096 /dev/zero'.
* tests/tail/tail-c.sh: Test this fix.
2024-04-19 21:45:43 -07:00
Paul Eggert
9ab1f9db94 ls: -f now means -a -U
Problem reported by Toby Kelsey <https://bugs.gnu.org/70418>.
* src/ls.c (decode_switches): -f now simply means -a -U.
(usage): Adjust to match.
2024-04-17 14:42:57 -07:00
Collin Funk
a9b78541fa maint: remove unnecessary stdbool.h include
* src/temp-stream.c: Don't include <stdbool.h> since it is defined in
config.h if the compiler does not support the C23 keyword.
2024-04-17 11:05:10 +01:00
Pádraig Brady
f56ae60585 join: fix error message for -a and -v
* src/join.c (main): s/field/file/ in the error message
for -a and -v, introduced in TEXTUTILS-1_13-24-g6f63d53e1.
Reported at https://bugs.debian.org/1068864
2024-04-12 20:26:46 +01:00
Pádraig Brady
be3a216ab4 doc: NEWS: mention sort being more efficient with /proc files
* NEWS: Mention the improvement in commit v9.5-6-g8ff390328
2024-04-07 13:51:31 +01:00
Paul Eggert
1116367581 split: don’t trust st_size on /proc files
* src/split.c (create): Don’t trust st_size == 0.
2024-04-06 15:18:28 -07:00
Paul Eggert
8ff3903281 sort: don’t trust st_size on /proc files
Problem and fix reported by Takashi Kusumi in:
https://bugs.gnu.org/70231
* src/sort.c (sort_buffer_size): Don’t trust st_size == 0.
2024-04-06 15:18:28 -07:00
Paul Eggert
ac6b8d8224 dd: don’t trust st_size on /proc/files
* src/dd.c (skip): Don’t trust st_size == 0.
2024-04-06 15:18:27 -07:00
Paul Eggert
225cb8d747 cat: don’t trust st_size on /proc files
* src/cat.c (main):
Improve test for when copying will exhaust the output device.
Do not rely on st_size, which is unreliable in /proc.
Use lseek instead; this is good enough here.
* tests/cat/cat-self.sh: Test the relaxation of the heuristic
for self-copying.
2024-04-06 15:18:27 -07:00
Pádraig Brady
8f3989d586 build: update gnulib submodule to latest
* gnulib: Update to latest.
* NEWS: Document 2 bugs fixed.
2024-04-04 11:20:52 +01:00
Pádraig Brady
e8c2b921c6 doc: chown,chgrp: fix missing full stop in --help
* src/chown.c (usage): Add a missing full stop.
Fixes https://bugs.gnu.org/70126
2024-04-01 20:24:55 +01:00
Pádraig Brady
d2df669c9c maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2024-03-28 15:13:45 +00:00
887 changed files with 10424 additions and 8049 deletions

View File

@@ -68,7 +68,7 @@ When sending messages to coreutils@gnu.org or bug-coreutils@gnu.org :
<!--
Copyright (C) 2017-2024 Free Software Foundation, Inc.
Copyright (C) 2017-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -88,7 +88,7 @@ in this matter.
<!--
Copyright (C) 2017-2024 Free Software Foundation, Inc.
Copyright (C) 2017-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

8
.gitignore vendored
View File

@@ -60,13 +60,16 @@
/lib/config.h
/lib/config.hin
/lib/configmake.h
/lib/crc-sliceby8.h
/lib/ctype.h
/lib/dirent.h
/lib/endian.h
/lib/errno.h
/lib/error.h
/lib/fcntl.h
/lib/float.h
/lib/fnmatch.h
/lib/fts_.h
/lib/getopt-cdefs.h
/lib/getopt.h
/lib/glthread
@@ -105,6 +108,7 @@
/lib/stamp-h1
/lib/stdarg.h
/lib/stdbool.h
/lib/stdbit.h
/lib/stdckdint.h
/lib/stddef.h
/lib/stdint.h
@@ -153,7 +157,6 @@
/m4/lib-link.m4
/m4/lib-prefix.m4
/m4/lock.m4
/m4/longlong.m4
/m4/nls.m4
/m4/po.m4
/m4/printf-posix.m4
@@ -192,12 +195,12 @@
/src/coreutils.h
/src/coreutils_shebangs
/src/coreutils_symlinks
/src/crctab.c
/src/cu-progs.mk
/src/fs-def
/src/fs-kernel-magic
/src/fs-latest-magic.h
/src/fs-magic
/src/make-prime-list
/src/primes.h
/src/single-binary.mk
/src/version.c
@@ -207,6 +210,7 @@
/tests/*/*.trs
/tests/.built-programs
/tests/factor/t[0-9][0-9].sh
/tests/init.sh
/tests/t?
/tests/test-suite.log
/tight-scope.mk

View File

@@ -1,4 +1,5 @@
# Map git author names and email addresses to canonical/preferred form.
<jim@meyering.net> <meyering@meta.com>
<jim@meyering.net> <meyering@fb.com>
<jim@meyering.net> <meyering@iou.iou>
<jim@meyering.net> <meyering@redhat.com>

View File

@@ -1 +1 @@
9.4
9.7

View File

@@ -1,6 +1,6 @@
# Suppress valgrind diagnostics we don't care about.
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
# Copyright (C) 2003-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -2,4 +2,5 @@
^bootstrap$
^doc/fdl\.texi$
^man/help2man$
^src/longlong\.h$
^tests/init\.sh$

View File

@@ -44,7 +44,7 @@ join: Mike Haertel
kill: Paul Eggert
link: Michael Stone
ln: Mike Parker, David MacKenzie
logname: FIXME: unknown
logname: David MacKenzie
ls: Richard M. Stallman, David MacKenzie
md5sum: Ulrich Drepper, Scott Miller, David Madore
mkdir: David MacKenzie

View File

@@ -6,7 +6,7 @@ Prerequisites
You will need the "git" version control tools. On Fedora-based
systems, do "yum install git". On Debian-based ones install the
"git-core" package. Then run "git --version". If that says it's
older than version 1.4.4, then you'd do well to get a newer version.
older than version 1.6.4, then you'd do well to get a newer version.
At worst, just download the latest stable release from
https://git-scm.com/ and build from source.
@@ -616,7 +616,7 @@ and root only tests, is to follow these steps (requires lcov to be installed):
xdg-open doc/coverage/index.html
========================================================================
Copyright (C) 2009-2024 Free Software Foundation, Inc.
Copyright (C) 2009-2025 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or

View File

@@ -1,6 +1,6 @@
# Make coreutils. -*-Makefile-*-
# Copyright (C) 1990-2024 Free Software Foundation, Inc.
# Copyright (C) 1990-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -82,14 +82,12 @@ BUILT_SOURCES = .version
# Have no read-only files in the tarball to allow easy removal.
# Have .tarball-version based versions only in tarball builds.
# Have .timestamp based dates only in tarball builds.
# The perl substitution is to change some key uses of "rm" to "/bin/rm".
# See the rm_subst comment for details.
# The touch avoids a subtle, spurious "make distcheck" failure.
dist-hook: gen-ChangeLog
$(AM_V_GEN)chmod -R +rw $(distdir)
$(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
$(AM_V_GEN)date +%s > $(distdir)/.timestamp
$(AM_V_at)perl -pi -e '$(rm_subst)' $(distdir)/Makefile.in
$(AM_V_at)touch $(distdir)/doc/constants.texi \
$(distdir)/doc/coreutils.info
@@ -135,7 +133,8 @@ check-ls-dircolors:
|sed -n 's/^"\(..\)"/\1/p'|sort -u); \
ls=$$(sed -n '/static.*indicator_name\[/,/};'/\p \
$(srcdir)/src/ls.c \
|sed -n '/^ *"/p'|tr , '\n'|sed 's/^ *//' \
|sed -n '/^ *{/ { s/{.\([a-z]\).,.\([a-z]\).}/"\1\2"/g; p; }' \
|tr , '\n'|sed 's/^ *//' \
|sed -n 's/^"\(..\)"/\1/p'|sort -u); \
test "$$dc" = "$$ls"
@@ -144,9 +143,6 @@ check-ls-dircolors:
# current locale considers to be equal.
ASSORT = LC_ALL=C sort
# Extract all lines up to the first one starting with "##".
prologue = perl -ne '/^\#\#/ and exit; print' $(srcdir)/THANKS.in
# FIXME: avoid dependency to build our own 'sort' for 'make dist' ...
# when common platforms have a functional case-folding implementation:
# $ test 'abácad' = "$(printf '%s\n' 'ab' 'ác' 'ad' \
@@ -158,7 +154,7 @@ prologue = perl -ne '/^\#\#/ and exit; print' $(srcdir)/THANKS.in
THANKS: THANKS.in Makefile.am .mailmap thanks-gen .version
$(AM_V_GEN)rm -f $@-t $@; \
{ \
$(prologue); echo; \
perl -ne '/^\#\#/ and exit; print' $(srcdir)/THANKS.in; echo; \
{ perl -ne '/^$$/.../^$$/ and !/^$$/ and s/ +/\0/ and print' \
$(srcdir)/THANKS.in; \
git log --pretty=format:'%aN%x00%aE' \
@@ -209,6 +205,7 @@ MOSTLYCLEANDIRS =
AM_CPPFLAGS = -Ilib -I$(top_srcdir)/lib -Isrc -I$(top_srcdir)/src
include $(top_srcdir)/gl/local.mk
include $(top_srcdir)/lib/local.mk
include $(top_srcdir)/src/local.mk
include $(top_srcdir)/doc/local.mk

319
NEWS
View File

@@ -1,5 +1,318 @@
GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release ?.? (????-??-??) [?]
** Bug fixes
'b2sum' will diagnose --length values that are too big.
Previously it would have silently assumed 512 for any larger values.
[bug introduced in coreutils-9.6]
'base32' and 'base64' when decoding will again diagnose partially
padded data that ends with a newline.
[bug introduced in coreutils-9.5]
'basenc -d -i' will now strip '=' characters from the input
in encodings where padding characters are not valid.
[bug introduced with the basenc program in coreutils-8.31]
'cp -p' had spurious "Operation not supported" failures when
copying to non-NFS files from NFSv4 files with trivial ACLs.
[bug introduced in coreutils-9.6]
'cp --sparse=always' missed some opportunities to create holes.
That is, although the copies had the correct data, sometimes
data zeros used extents rather than holes.
[This bug was present in "the beginning".]
cp missed opportunities to create holes when copying from file
systems like squashfs that support SEEK_HOLE only trivially.
[bug introduced in coreutils-9.0]
cp, install, and mv now avoid possible data corruption on
glibc 2.41 and 2.42 systems when copy_file_range is used with ranges > 2GiB,
avoiding https://sourceware.org/PR33245
[bug triggered since coreutils-9.0]
'date' supports specifying multiple named formats with the last taking
precedence. Previously multiple specifications would induce an error.
[bug introduced in coreutils-5.90]
'install -d' now produces the correct diagnostic upon failure
to create a directory. Previously it would have produced
a confusing error about changing permissions.
[This bug was present in "the beginning".]
"ls --size --block-size=\'k" could misalign output in locales
with multi-byte thousands grouping characters.
[This bug was present in "the beginning".]
'nohup' avoids implementation defined behavior setting umask,
avoiding a FORTIFY runtime failure on Bionic libc.
[This bug was present in "the beginning".]
'od --strings' with '-N' now works correctly. Previously od might
write a NUL byte after a heap buffer, or output invalid addresses.
[These bugs were present in "the beginning".]
'od -w0' will now issue a diagnostic and exit gracefully.
Previously it would have aborted.
[bug introduced in coreutils-9.3]
'od -w' no longer silently mishandles enormous widths like 3037000500.
Instead, it either outputs correctly or diagnoses a too-large width.
[This bug was present in "the beginning".]
'od +N.' (where N is a decimal number) works again as per POSIX.
[bug introduced in textutils-2.0]
'od /dev/null ++0' no longer mistakenly treats the ++0 as an offset.
[This bug was present in "the beginning".]
'sort' with key character offsets of SIZE_MAX, could induce
a read of 1 byte before an allocated heap buffer. For example:
'sort +0.18446744073709551615R input' on 64 bit systems.
[bug introduced in coreutils-7.2]
stdbuf now works on AIX. Previously it would have been ineffective.
[bug introduced with the stdbuf program in coreutils-7.5]
'tail -n NUM' no longer can output more than NUM lines if stdin
is a largish regular file with a nonzero initial offset, and grows
while 'tail' is reading it.
[This bug was present in "the beginning".]
'tail -f -n +NUM' no longer mishandles NUM values >= UINTMAX_MAX
when the input is seekable.
[bug introduced in coreutils-9.6]
'tail --pid' avoids some unlikely races if the kernel reuses PIDs.
[bug introduced in coreutils-9.5]
'tty' now exits with status 4 with a special diagnostic if ttyname
fails even though standard input is a tty. Formerly it quietly
pretended that standard input was not a tty.
[This bug was present in "the beginning".]
** New Features
basenc supports the --base58 option to encode and decode
the visually unambiguous Base58 encoding.
'cksum -a' now supports the 'sha3' argument, to use the SHA3-224,
SHA3-256, SHA3-384, SHA3-512 message digest algorithms depending on
the argument passed to the required --length (-l) option.
'cksum -a' now supports the 'sha2' argument, as a more consistent
interface than the existing 'sha224', 'sha256', 'sha384', 'sha512'
arguments, which are now selected with the --length (-l) option.
'date' now outputs dates in the country's native calendar for the
Iranian locale (fa_IR) and for the Ethiopian locale (am_ET), and also
does so more consistently for the Thailand locale (th_TH.UTF-8).
fold now supports multi-byte characters, honoring their column width.
Also the --characters (-c) option was added to wrap at a certain
number of characters, similarly to --bytes in uni-byte locales.
nproc now honors any cgroup v2 configured CPU quotas,
which may reduce the effective number of processors available.
stty supports setting arbitrary baud rates on supported systems,
like Hurd, Linux with glibc >= 2.42, and some BSDs.
Also on other systems the full set of supported baud rates
is determined at build time if possible.
** Changes to conform better to POSIX.1-2024
readlink now defaults to being verbose if the POSIXLY_CORRECT
environment variable is set.
realpath now supports -E, which specifies the default behavior.
The corresponding long option is --canonicalize.
tsort now accepts and ignores -w.
** Improvements
'factor' is now much faster at identifying large prime numbers,
and significantly faster on composite numbers greater than 2^128.
'seq' is more accurate with large integer start values.
Previously 'seq 18446744073709551617 inf | head -n1' would
output the number before the user specified start value.
** Build-related
cksum was not compilable by Apple LLVM 10.0.0 x86-64, which
lacks support for checking for the VPCLMULQDQ instruction.
[bug introduced in coreutils-9.6]
* Noteworthy changes in release 9.7 (2025-04-09) [stable]
** Bug fixes
'cat' would fail with "input file is output file" if input and
output are the same terminal device and the output is append-only.
[bug introduced in coreutils-9.6]
'cksum -a crc' misbehaved on aarch64 with 32-bit uint_fast32_t.
[bug introduced in coreutils-9.6]
dd with the 'nocache' flag will now detect all failures to drop the
cache for the whole file. Previously it may have erroneously succeeded.
[bug introduced with the "nocache" feature in coreutils-8.11]
'ls -Z dir' would crash on all systems, and 'ls -l' could crash
on systems like Android with SELinux but without xattr support.
[bug introduced in coreutils-9.6]
`ls -l` could output spurious "Not supported" errors in certain cases,
like with dangling symlinks on cygwin.
[bug introduced in coreutils-9.6]
timeout would fail to timeout commands with infinitesimal timeouts.
For example `timeout 1e-5000 sleep inf` would never timeout.
[bug introduced with timeout in coreutils-7.0]
sleep, tail, and timeout would sometimes sleep for slightly less
time than requested.
[bug introduced in coreutils-5.0]
'who -m' now outputs entries for remote logins. Previously login
entries prefixed with the service (like "sshd") were not matched.
[bug introduced in coreutils-9.4]
** Improvements
'logname' correctly returns the user who logged in the session,
on more systems. Previously on musl or uclibc it would have merely
output the LOGNAME environment variable.
* Noteworthy changes in release 9.6 (2025-01-17) [stable]
** Bug fixes
cp fixes support for --update=none-fail, which would have been
rejected as an invalid option.
[bug introduced in coreutils-9.5]
cp,mv --update no longer overrides --interactive or --force.
[bug introduced in coreutils-9.3]
csplit no longer creates empty files given empty input.
[This bug was present in "the beginning".]
ls and printf fix shell quoted output in the edge case of escaped
first and last characters, and single quotes in the string.
[bug introduced in coreutils-8.26]
ls -l no longer outputs "Permission denied" errors on NFS
which may happen with files without read permission, and which resulted
in inaccurate indication of ACLs (missing '+' flag after mode).
[bug introduced in coreutils-9.4]
ls -l no longer outputs "Not supported" errors on virtiofs.
[bug introduced in coreutils-9.4]
mv works again with macFUSE file systems. Previously it would
have exited with a "Function not implemented" error.
[bug introduced in coreutils-8.28]
nproc gives more consistent results on systems with more than 1024 CPUs.
Previously it would have ignored the affinity mask on such systems.
[bug introduced with nproc in coreutils-8.1]
numfmt --from=iec-i now works with numbers without a suffix.
Previously such numbers were rejected with an error.
[bug introduced with numfmt in coreutils-8.21]
printf now diagnoses attempts to treat empty strings as numbers,
as per POSIX. For example, "printf '%d' ''" now issues a diagnostic
and fails instead of silently succeeding.
[This bug was present in "the beginning".]
pwd no longer outputs an erroneous double slash on systems
where the system getcwd() was completely replaced.
[bug introduced in coreutils-9.2]
'shuf' generates more-random output when the output is small.
[bug introduced in coreutils-8.6]
`tail --follow=name` no longer waits indefinitely for watched
file names that are moved elsewhere within the same file system.
[bug introduced in coreutils-8.24]
`tail --follow` without --retry, will consistently exit with failure status
where inotify is not used, when all followed files become inaccessible.
[This bug was present in "the beginning".]
`tail --follow --pid=PID` will now exit when the PID dies,
even in the presence of blocking inputs like unopened fifos.
[This bug was present in "the beginning".]
'tail -c 4096 /dev/zero' no longer loops forever.
[This bug was present in "the beginning".]
** Changes in behavior
'factor' now buffers output more efficiently in some cases.
install -C now dereferences symlink sources when comparing,
rather than always treating as different and performing the copy.
kill -l and -t now list signal 0, as it's a valid signal to send.
ls's -f option now simply acts like -aU, instead of also ignoring
some earlier options. For example 'ls -fl' and 'ls -lf' are now
equivalent because -f no longer ignores an earlier -l. The new
behavior is more orthogonal and is compatible with FreeBSD.
stat -f -c%T now reports the "fuseblk" file system type as "fuse",
given that there is no longer a distinct "ctl" fuse variant file system.
** New Features
cksum -a now supports the "crc32b" option, which calculates the CRC
of the input as defined by ITU V.42, as used by gzip for example.
For performance pclmul instructions are used where supported.
ls now supports the --sort=name option,
to explicitly select the default operation of sorting by file name.
printf now supports indexed arguments, using the POSIX:2024 specified
%<i>$ format, where '<i>' is an integer referencing a particular argument,
thus allowing repetition or reordering of printf arguments.
test supports the POSIX:2024 specified '<' and '>' operators with strings,
to compare the string locale collating order.
timeout now supports the POSIX:2024 specified -f, and -p short options,
corresponding to --foreground, and --preserve-status respectively.
** Improvements
cksum -a crc, makes use of AVX2, AVX512, and ARMv8 SIMD extensions
for time reductions of up to 40%, 60%, and 80% respectively.
'head -c NUM', 'head -n NUM', 'nl -l NUM', 'nproc --ignore NUM',
'tail -c NUM', 'tail -n NUM', and 'tail --max-unchanged-stats NUM'
no longer fail merely because NUM stands for 2**64 or more.
sort operates more efficiently when used on pseudo files with
an apparent size of 0, like those in /proc.
stat and tail now know about the "bcachefs", and "pidfs" file system types.
stat -f -c%T now reports the file system type,
and tail -f uses inotify for these file systems.
wc now reads a minimum of 256KiB at a time.
This was previously 16KiB and increasing to 256KiB was seen to increase
wc -l performance by about 10% when reading cached files on modern systems.
* Noteworthy changes in release 9.5 (2024-03-28) [stable]
** Bug fixes
@@ -944,7 +1257,7 @@ GNU coreutils NEWS -*- outline -*-
env now supports '--list-signal-handling' to indicate non-default
signal handling before executing a program.
** New commands
** New programs
basenc is added to complement existing base64,base32 commands,
and encodes and decodes printable text using various common encodings:
@@ -1464,7 +1777,7 @@ GNU coreutils NEWS -*- outline -*-
tail -F now works with initially non existent files on a remote file system.
[bug introduced in coreutils-7.5]
** New commands
** New programs
base32 is added to complement the existing base64 command,
and encodes and decodes printable text as per RFC 4648.
@@ -5896,7 +6209,7 @@ packages, see ./old/*/NEWS.
========================================================================
Copyright (C) 2001-2024 Free Software Foundation, Inc.
Copyright (C) 2001-2025 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or

2
README
View File

@@ -131,7 +131,7 @@ Please see the file COPYING for copying conditions.
========================================================================
Copyright (C) 1998-2024 Free Software Foundation, Inc.
Copyright (C) 1998-2025 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or

View File

@@ -43,18 +43,19 @@ As an optional step, if you already have a copy of the Gnulib Git
repository, then you can use it as a reference to reduce download
time and file system space requirements:
$ export GNULIB_SRCDIR=/path/to/gnulib
$ export GNULIB_REFDIR=/path/to/gnulib
The next step is to get and check other files needed to build,
which are extracted from other source packages:
The next steps are to get and check other files needed to build,
and complete the build:
$ make -f cfg.mk
For reference the above command runs the following steps,
which can be done individually if required to give more control:
$ ./bootstrap
And there you are! Just
$ ./configure --quiet #[--disable-gcc-warnings] [*]
$ make
$ make check
$ make #[check]
At this point, there should be no difference between your local copy,
and the Git master copy:
@@ -101,7 +102,7 @@ each program. One way to do this is to use vc-dwim
-----
Copyright (C) 2002-2024 Free Software Foundation, Inc.
Copyright (C) 2002-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
#! /bin/bash
# Convert this package for use with valgrind.
# Copyright (C) 2002-2024 Free Software Foundation, Inc.
# Copyright (C) 2002-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -120,6 +120,7 @@ Chris Lesniewski ctl@mit.edu
Chris Sylvain csylvain@umm.edu
Chris Yeo cyeo@biking.org
Christi Alice Scarborough christi@chiark.greenend.org.uk
Christian Brauner christian.brauner@canonical.com
Christian Harkort christian.harkort@web.de
Christian Jullien eligis@orange.fr
Christian Krackowizer ckrackowiz@std.schuler-ag.com
@@ -140,6 +141,7 @@ Dameon G. Rogers dgr03@uark.edu
Dan Hagerty hag@gnu.ai.it.edu
Dan Pascu dan@services.iiruc.ro
Daniel Bergstrom noa@melody.se
Daniel Carpenter dansebpub@gmail.com
Daniel Mach dmach@redhat.com
Daniel P. Berrangé berrange@redhat.com
Daniel Stavrovski d@stavrovski.net

6
TODO
View File

@@ -11,10 +11,6 @@ Modify chmod so that it does not change an inode's st_ctime
https://lists.gnu.org/r/bug-coreutils/2004-09/msg00145.html
Discussed more recently on <https://bugs.debian.org/497514>.
document the following in coreutils.texi:
[
pinky
Suggestion from Paul Eggert:
More generally, there's not that much use for imaxtostr nowadays,
since the inttypes module and newer versions of gettext allow things
@@ -143,7 +139,7 @@ pr's use of nstrftime can make it malloc a very large (up to SIZE_MAX) buffer
-----
Copyright (C) 2002-2024 Free Software Foundation, Inc.
Copyright (C) 2002-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

394
bootstrap
View File

@@ -3,9 +3,9 @@
# Bootstrap this package from checked-out sources.
scriptversion=2023-12-10.18; # UTC
scriptversion=2025-06-10.02; # UTC
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
# Copyright (C) 2003-2025 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -37,9 +37,9 @@ medir=`dirname "$me"`
# A library of shell functions for autopull.sh, autogen.sh, and bootstrap.
scriptlibversion=2023-12-10.18; # UTC
scriptlibversion=2025-06-10.02; # UTC
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
# Copyright (C) 2003-2025 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -152,7 +152,8 @@ po_download_command_format=\
"wget --mirror --level=1 -nd -nv -A.po -P '%s' \
https://translationproject.org/latest/%s/"
# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
# When extracting the package name from an AC_INIT invocation,
# prefer a non-empty tarname (4th argument of AC_INIT if given), else
# fall back to the package name (1st argument with munging).
extract_package_name='
/^AC_INIT(\[*/{
@@ -164,17 +165,20 @@ extract_package_name='
q
}
s/[],)].*//
s/^GNU //
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g
p
}
'
package=$(${AUTOCONF:-autoconf} --trace AC_INIT:\$4 configure.ac 2>/dev/null)
normalize_package_name='
s/^GNU //
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g
'
package=$(${AUTOCONF:-autoconf} --trace 'AC_INIT:$4' configure.ac 2>/dev/null)
if test -z "$package"; then
package=$(sed -n "$extract_package_name" configure.ac) \
|| die 'cannot find package name in configure.ac'
fi
package=$(echo "$package" | sed "$normalize_package_name")
gnulib_name=lib$package
build_aux=build-aux
@@ -478,10 +482,9 @@ find_tool ()
# --------------------- Preparing GNULIB_SRCDIR for use. ---------------------
# This is part of autopull.sh, but bootstrap needs it too, for self-upgrading.
# cleanup_gnulib fails, removing the directory $gnulib_path first.
cleanup_gnulib() {
status=$?
# XXX It's a bad idea to erase the submodule directory if it contains local
# modifications.
rm -fr "$gnulib_path"
exit $status
}
@@ -499,93 +502,155 @@ prepare_GNULIB_SRCDIR ()
test -f "$GNULIB_SRCDIR/gnulib-tool" \
|| die "Error: --gnulib-srcdir or \$GNULIB_SRCDIR is specified," \
"but does not contain gnulib-tool"
elif $use_git; then
if test -n "$GNULIB_REVISION" && $use_git; then
# The 'git checkout "$GNULIB_REVISION"' command succeeds if the
# GNULIB_REVISION is a commit hash that exists locally, or if it is
# branch name that can be fetched from origin. It fails, however,
# if the GNULIB_REVISION is a commit hash that only exists in
# origin. In this case, we need a 'git fetch' and then retry
# 'git checkout "$GNULIB_REVISION"'.
git -C "$GNULIB_SRCDIR" checkout "$GNULIB_REVISION" 2>/dev/null \
|| { git -C "$GNULIB_SRCDIR" fetch origin \
&& git -C "$GNULIB_SRCDIR" checkout "$GNULIB_REVISION"; } \
|| exit $?
fi
else
if ! $use_git; then
die "Error: --no-git is specified," \
"but neither --gnulib-srcdir nor \$GNULIB_SRCDIR is specified"
fi
if git submodule -h | grep -- --reference > /dev/null; then
:
else
die "git version is too old, git >= 1.6.4 is required"
fi
gnulib_path=$(git_modules_config submodule.gnulib.path)
test -z "$gnulib_path" && gnulib_path=gnulib
# Get gnulib files. Populate $gnulib_path, possibly updating a
# submodule, for use in the rest of the script.
if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git \
&& git_modules_config submodule.gnulib.url >/dev/null; then
# Use GNULIB_REFDIR as a reference.
echo "$0: getting gnulib files..."
if git submodule -h|grep -- --reference > /dev/null; then
# Prefer the one-liner available in git 1.6.4 or newer.
git submodule update --init --reference "$GNULIB_REFDIR" \
"$gnulib_path" || exit $?
if test -n "$gnulib_path"; then
# A submodule 'gnulib' is configured.
# Get gnulib files. Populate $gnulib_path, updating the submodule.
if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git; then
# Use GNULIB_REFDIR as a reference.
echo "$0: getting gnulib files..."
git submodule update --init --reference "$GNULIB_REFDIR" "$gnulib_path"\
|| exit $?
else
# This fallback allows at least git 1.5.5.
if test -f "$gnulib_path"/gnulib-tool; then
# Since file already exists, assume submodule init already complete.
# GNULIB_REFDIR is not set or not usable. Ignore it.
if git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
git submodule init -- "$gnulib_path" || exit $?
git submodule update -- "$gnulib_path" || exit $?
else
# Older git can't clone into an empty directory.
rmdir "$gnulib_path" 2>/dev/null
git clone --reference "$GNULIB_REFDIR" \
"$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
&& git submodule init -- "$gnulib_path" \
&& git submodule update -- "$gnulib_path" \
|| exit $?
die "Error: submodule 'gnulib' has no configured url"
fi
fi
else
# GNULIB_REFDIR is not set or not usable. Ignore it.
if git_modules_config submodule.gnulib.url >/dev/null; then
gnulib_path='gnulib'
if test ! -d "$gnulib_path"; then
# The subdirectory 'gnulib' does not yet exist. Clone into it.
echo "$0: getting gnulib files..."
git submodule init -- "$gnulib_path" || exit $?
git submodule update -- "$gnulib_path" || exit $?
elif [ ! -d "$gnulib_path" ]; then
echo "$0: getting gnulib files..."
trap cleanup_gnulib HUP INT PIPE TERM
shallow=
if test -z "$GNULIB_REVISION"; then
if git clone -h 2>&1 | grep -- --depth > /dev/null; then
shallow='--depth 2'
fi
git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \
|| cleanup_gnulib
gnulib_url=${GNULIB_URL:-$default_gnulib_url}
if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git; then
# Use GNULIB_REFDIR as a reference.
git clone "$GNULIB_REFDIR" "$gnulib_path" \
&& git -C "$gnulib_path" remote set-url origin "$gnulib_url" \
&& if test -z "$GNULIB_REVISION"; then
git -C "$gnulib_path" pull origin \
&& {
# We want the default branch of "$gnulib_url" (since that's
# the behaviour if GNULIB_REFDIR is not specified), not the
# current branch of "$GNULIB_REFDIR".
default_branch=`LC_ALL=C git -C "$gnulib_path" \
remote show origin \
| sed -n -e 's/^ *HEAD branch: //p'`
test -n "$default_branch" || default_branch='master'
git -C "$gnulib_path" checkout "$default_branch"
}
else
# The 'git checkout "$GNULIB_REVISION"' command succeeds if the
# GNULIB_REVISION is a commit hash that exists locally, or if it
# is a branch name that can be fetched from origin. It fails,
# however, if the GNULIB_REVISION is a commit hash that only
# exists in origin. In this case, we need a 'git fetch' and then
# retry 'git checkout "$GNULIB_REVISION"'.
git -C "$gnulib_path" checkout "$GNULIB_REVISION" 2>/dev/null \
|| { git -C "$gnulib_path" fetch origin \
&& git -C "$gnulib_path" checkout "$GNULIB_REVISION"; }
fi \
|| cleanup_gnulib
else
if git fetch -h 2>&1 | grep -- --depth > /dev/null; then
shallow='--depth 2'
# GNULIB_REFDIR is not set or not usable. Ignore it.
shallow='--depth 2'
if test -z "$GNULIB_REVISION"; then
git clone $shallow "$gnulib_url" "$gnulib_path" \
|| cleanup_gnulib
else
# Only want a shallow checkout of $GNULIB_REVISION, but git does not
# support cloning by commit hash. So attempt a shallow fetch by
# commit hash to minimize the amount of data downloaded and changes
# needed to be processed, which can drastically reduce download and
# processing time for checkout. If the fetch by commit fails, a
# shallow fetch cannot be performed because we do not know what the
# depth of the commit is without fetching all commits. So fall back
# to fetching all commits.
# $GNULIB_REVISION can be a commit id, a tag name, or a branch name.
mkdir -p "$gnulib_path"
# Use a -c option to silence an annoying message
# "hint: Using 'master' as the name for the initial branch."
# (cf. <https://stackoverflow.com/questions/65524512/>).
git -C "$gnulib_path" -c init.defaultBranch=master init
git -C "$gnulib_path" remote add origin "$gnulib_url"
if git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION"
then
# "git fetch" of the specific commit succeeded.
git -C "$gnulib_path" reset --hard FETCH_HEAD \
|| cleanup_gnulib
# "git fetch" does not fetch tags (at least in git version 2.43).
# If $GNULIB_REVISION is a tag (not a commit id or branch name),
# add the tag explicitly.
revision=`git -C "$gnulib_path" log -1 --pretty=format:%H`
branch=`LC_ALL=C git -C "$gnulib_path" remote show origin \
| sed -n -e 's/^ \([^ ]*\) * tracked$/\1/p'`
test "$revision" = "$GNULIB_REVISION" \
|| test "$branch" = "$GNULIB_REVISION" \
|| git -C "$gnulib_path" tag "$GNULIB_REVISION"
else
# Fetch the entire repository.
git -C "$gnulib_path" fetch origin \
|| cleanup_gnulib
git -C "$gnulib_path" checkout "$GNULIB_REVISION" \
|| cleanup_gnulib
fi
fi
mkdir -p "$gnulib_path"
# Only want a shallow checkout of $GNULIB_REVISION, but git does not
# support cloning by commit hash. So attempt a shallow fetch by commit
# hash to minimize the amount of data downloaded and changes needed to
# be processed, which can drastically reduce download and processing
# time for checkout. If the fetch by commit fails, a shallow fetch can
# not be performed because we do not know what the depth of the commit
# is without fetching all commits. So fall back to fetching all
# commits.
git -C "$gnulib_path" init
git -C "$gnulib_path" remote add origin \
${GNULIB_URL:-$default_gnulib_url}
git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \
|| git -C "$gnulib_path" fetch origin \
|| cleanup_gnulib
git -C "$gnulib_path" reset --hard FETCH_HEAD
fi
trap - HUP INT PIPE TERM
else
# The subdirectory 'gnulib' already exists.
if test -n "$GNULIB_REVISION"; then
if test -d "$gnulib_path/.git"; then
# The 'git checkout "$GNULIB_REVISION"' command succeeds if the
# GNULIB_REVISION is a commit hash that exists locally, or if it
# is a branch name that can be fetched from origin. It fails,
# however, if the GNULIB_REVISION is a commit hash that only
# exists in origin. In this case, we need a 'git fetch' and then
# retry 'git checkout "$GNULIB_REVISION"'.
git -C "$gnulib_path" checkout "$GNULIB_REVISION" 2>/dev/null \
|| { git -C "$gnulib_path" fetch origin \
&& git -C "$gnulib_path" checkout "$GNULIB_REVISION"; } \
|| exit $?
else
die "Error: GNULIB_REVISION is specified in bootstrap.conf," \
"but '$gnulib_path' contains no git history"
fi
fi
fi
fi
GNULIB_SRCDIR=$gnulib_path
# Verify that the submodule contains a gnulib checkout.
# Verify that $gnulib_path contains a gnulib checkout.
test -f "$gnulib_path/gnulib-tool" \
|| die "Error: $gnulib_path is supposed to contain a gnulib checkout," \
|| die "Error: '$gnulib_path' is supposed to contain a gnulib checkout," \
"but does not contain gnulib-tool"
GNULIB_SRCDIR=$gnulib_path
fi
# XXX Should this be done if $use_git is false?
if test -d "$GNULIB_SRCDIR"/.git && test -n "$GNULIB_REVISION" \
&& ! git_modules_config submodule.gnulib.url >/dev/null; then
(cd "$GNULIB_SRCDIR" && git checkout "$GNULIB_REVISION") || cleanup_gnulib
fi
# $GNULIB_SRCDIR now points to the version of gnulib to use, and
# we no longer need to use git or $gnulib_path below here.
}
@@ -647,7 +712,8 @@ fi
autopull_usage() {
cat <<EOF
Usage: $me [OPTION]...
Bootstrap this package from the checked-out sources.
Bootstrap this package from the checked-out sources, phase 1:
Pull files from the network.
Optional environment variables:
GNULIB_SRCDIR Specifies the local directory where gnulib
@@ -664,18 +730,19 @@ Optional environment variables:
which is Gnulib's upstream repository.
Options:
--bootstrap-sync if this bootstrap script is not identical to
--bootstrap-sync If this bootstrap script is not identical to
the version in the local gnulib sources,
update this script, and then restart it with
/bin/sh or the shell \$CONFIG_SHELL
--no-bootstrap-sync do not check whether bootstrap is out of sync
--force attempt to bootstrap even if the sources seem
not to have been checked out
--no-git do not use git to update gnulib. Requires that
\$GNULIB_SRCDIR or the --gnulib-srcdir option
points to a gnulib repository with the correct
revision
--skip-po do not download po files
/bin/sh or the shell \$CONFIG_SHELL.
--no-bootstrap-sync Do not check whether bootstrap is out of sync.
--force Attempt to bootstrap even if the sources seem
not to have been checked out.
--no-git Do not use git to update gnulib. Requires that
\$GNULIB_SRCDIR points to a gnulib repository
with the correct revision.
--skip-po Do not download *.po files.
EOF
bootstrap_print_option_usage_hook
cat <<EOF
@@ -687,21 +754,21 @@ are honored.
Gnulib sources can be fetched in various ways:
* If the environment variable GNULIB_SRCDIR is set (either as an
environment variable or via the --gnulib-srcdir option), then sources
are fetched from that local directory. If it is a git repository and
the configuration variable GNULIB_REVISION is set in bootstrap.conf,
then that revision is checked out.
* If the environment variable GNULIB_SRCDIR is set, then sources are
fetched from that local directory. If it is a git repository and the
configuration variable GNULIB_REVISION is set in bootstrap.conf, then
that revision is checked out.
* Otherwise, if this package is in a git repository with a 'gnulib'
submodule configured, then that submodule is initialized and updated
and sources are fetched from there. If GNULIB_REFDIR is set (either
as an environment variable or via the --gnulib-refdir option) and is
a git repository, then it is used as a reference.
and sources are fetched from there. If the environment variable
GNULIB_REFDIR is set and is a git repository, then it is used as a
reference.
* Otherwise, if the 'gnulib' directory does not exist, Gnulib sources
are cloned into that directory using git from \$GNULIB_URL, defaulting
to $default_gnulib_url.
to $default_gnulib_url; if GNULIB_REFDIR is set and is a git repository
its contents may be used to accelerate the process.
If the configuration variable GNULIB_REVISION is set in bootstrap.conf,
then that revision is checked out.
@@ -869,9 +936,7 @@ update_po_files() {
&& ls "$ref_po_dir"/*.po 2>/dev/null |
sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
langs=$(cd $ref_po_dir && echo *.po | sed 's/\.po//g')
test "$langs" = '*' && langs=x
for po in $langs; do
for po in x $(ls $ref_po_dir | sed -n 's/\.po$//p'); do
case $po in x) continue;; esac
new_po="$ref_po_dir/$po.po"
cksum_file="$ref_po_dir/$po.s1"
@@ -890,7 +955,8 @@ update_po_files() {
autogen_usage() {
cat <<EOF
Usage: $me [OPTION]...
Bootstrap this package from the checked-out sources.
Bootstrap this package from the checked-out sources, phase 2:
Generate files from local files (no network access).
Optional environment variables:
GNULIB_SRCDIR Specifies the local directory where gnulib
@@ -899,9 +965,9 @@ Optional environment variables:
you want to use these sources.
Options:
--copy copy files instead of creating symbolic links
--force attempt to bootstrap even if the sources seem
not to have been checked out
--copy Copy files instead of creating symbolic links.
--force Attempt to bootstrap even if the sources seem
not to have been checked out.
EOF
bootstrap_print_option_usage_hook
cat <<EOF
@@ -1234,6 +1300,20 @@ autogen()
$gnulib_tool $gnulib_tool_options --import $gnulib_modules \
|| die "gnulib-tool failed"
if test $with_gettext = yes && test ! -f $m4_base/gettext.m4; then
# The gnulib-tool invocation has removed $m4_base/gettext.m4, that the
# AUTOPOINT invocation had installed. This can occur when the gnulib
# module 'gettext' was previously present but is now not present any more.
# Repeat the AUTOPOINT invocation and the gnulib-tool invocation.
echo "$0: $AUTOPOINT --force"
$AUTOPOINT --force || return
echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules \
|| die "gnulib-tool failed"
fi
for file in $gnulib_files; do
symlink_to_dir "$GNULIB_SRCDIR" $file \
|| die "failed to symlink $file"
@@ -1257,7 +1337,7 @@ autogen()
# Invoke autoreconf with --force --install to ensure upgrades of tools
# such as ylwrap.
AUTORECONFFLAGS="--verbose --install --force -I $m4_base $ACLOCAL_FLAGS"
AUTORECONFFLAGS="--verbose --install --force $ACLOCAL_FLAGS"
AUTORECONFFLAGS="$AUTORECONFFLAGS --no-recursive"
# Tell autoreconf not to invoke autopoint or libtoolize; they were run above.
@@ -1319,7 +1399,7 @@ autogen()
|| die 'cannot generate runtime-po/Makevars'
# Copy identical files from po to runtime-po.
(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
cp -p po/Makefile.in.in po/*-quot po/*.header po/*.sed po/*.sin runtime-po
fi
fi
@@ -1331,9 +1411,9 @@ autogen()
# ----------------------------------------------------------------------------
# Local Variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# eval: (add-hook 'before-save-hook 'time-stamp nil t)
# time-stamp-start: "scriptlibversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-format: "%Y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
@@ -1347,44 +1427,55 @@ Optional environment variables:
GNULIB_SRCDIR Specifies the local directory where gnulib
sources reside. Use this if you already
have gnulib sources on your machine, and
do not want to waste your bandwidth downloading
them again.
GNULIB_URL URL of the gnulib repository. The default is
$default_gnulib_url,
which is Gnulib's upstream repository.
Options:
--pull Do phase 1: pull files from network
--gen Do phase 2: generate from local files.
(The default is to do both phases.)
--gnulib-srcdir=DIRNAME specify the local directory where gnulib
sources reside. Use this if you already
have gnulib sources on your machine, and
you want to use these sources. Defaults
to \$GNULIB_SRCDIR
--gnulib-refdir=DIRNAME specify the local directory where a gnulib
you want to use these sources.
GNULIB_REFDIR Specifies the local directory where a gnulib
repository (with a .git subdirectory) resides.
Use this if you already have gnulib sources
and history on your machine, and do not want
to waste your bandwidth downloading them again.
Defaults to \$GNULIB_REFDIR
Only used for phase 1 (--pull).
GNULIB_URL URL of the gnulib repository. The default is
$default_gnulib_url,
which is Gnulib's upstream repository.
Only used for phase 1 (--pull).
--bootstrap-sync if this bootstrap script is not identical to
Options:
--pull Do phase 1: Pull files from the network.
--gen Do phase 2: Generate files from local files
(no network access).
(The default is to do both phases.)
--gnulib-srcdir=DIRNAME Specifies the local directory where gnulib
sources reside. Use this if you already
have gnulib sources on your machine, and
you want to use these sources. Defaults
to \$GNULIB_SRCDIR.
--gnulib-refdir=DIRNAME Specifies the local directory where a gnulib
repository (with a .git subdirectory) resides.
Use this if you already have gnulib sources
and history on your machine, and do not want
to waste your bandwidth downloading them again.
Defaults to \$GNULIB_REFDIR.
Only used for phase 1 (--pull).
--bootstrap-sync If this bootstrap script is not identical to
the version in the local gnulib sources,
update this script, and then restart it with
/bin/sh or the shell \$CONFIG_SHELL
--no-bootstrap-sync do not check whether bootstrap is out of sync
/bin/sh or the shell \$CONFIG_SHELL.
--no-bootstrap-sync Do not check whether bootstrap is out of sync.
--copy copy files instead of creating symbolic links
--force attempt to bootstrap even if the sources seem
not to have been checked out
--no-git do not use git to update gnulib. Requires that
--copy Copy files instead of creating symbolic links.
Only used for phase 2 (--gen).
--force Attempt to bootstrap even if the sources seem
not to have been checked out.
--no-git Do not use git to update gnulib. Requires that
\$GNULIB_SRCDIR or the --gnulib-srcdir option
points to a gnulib repository with the correct
revision
--skip-po do not download po files
revision.
Only used for phase 1 (--pull).
--skip-po Do not download *.po files.
Only used for phase 1 (--pull).
EOF
bootstrap_print_option_usage_hook
cat <<EOF
@@ -1396,11 +1487,11 @@ are honored.
Gnulib sources can be fetched in various ways:
* If the environment variable GNULIB_SRCDIR is set (either as an
environment variable or via the --gnulib-srcdir option), then sources
are fetched from that local directory. If it is a git repository and
the configuration variable GNULIB_REVISION is set in bootstrap.conf,
then that revision is checked out.
* If GNULIB_SRCDIR is set (either as an environment variable or via the
--gnulib-srcdir option), then sources are fetched from that local
directory. If it is a git repository and the configuration variable
GNULIB_REVISION is set in bootstrap.conf, then that revision is
checked out.
* Otherwise, if this package is in a git repository with a 'gnulib'
submodule configured, then that submodule is initialized and updated
@@ -1410,7 +1501,8 @@ Gnulib sources can be fetched in various ways:
* Otherwise, if the 'gnulib' directory does not exist, Gnulib sources
are cloned into that directory using git from \$GNULIB_URL, defaulting
to $default_gnulib_url.
to $default_gnulib_url; if GNULIB_REFDIR is set and is a git repository
its contents may be used to accelerate the process.
If the configuration variable GNULIB_REVISION is set in bootstrap.conf,
then that revision is checked out.
@@ -1521,18 +1613,18 @@ if $pull && { $use_git || test -z "$SKIP_PO"; }; then
fi
if $gen; then
autogen \
`if $copy; then echo ' --copy'; fi` \
`if test -z "$checkout_only_file"; then echo ' --force'; fi` \
|| die "could not generate auxiliary files"
autogen \
`if $copy; then echo ' --copy'; fi` \
`if test -z "$checkout_only_file"; then echo ' --force'; fi` \
|| die "could not generate auxiliary files"
fi
# ----------------------------------------------------------------------------
# Local Variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# eval: (add-hook 'before-save-hook 'time-stamp nil t)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-format: "%Y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

View File

@@ -1,6 +1,6 @@
# Bootstrap configuration.
# Bootstrap configuration. -*- sh -*-
# Copyright (C) 2006-2024 Free Software Foundation, Inc.
# Copyright (C) 2006-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@ avoided_gnulib_modules='
gnulib_modules="
$avoided_gnulib_modules
acl
acl-permissions
alignalloc
alignasof
alloca
@@ -45,9 +46,9 @@ gnulib_modules="
backupfile
base32
base64
bool
btoc32
buffer-lcm
byteswap
c-strcase
c32iscntrl
c32isspace
@@ -64,9 +65,10 @@ gnulib_modules="
config-h
configmake
copy-file-range
count-leading-zeros
crc-x86_64
crypto/md5
crypto/sha1
crypto/sha3
crypto/sha256
crypto/sha512
crypto/sm3
@@ -77,8 +79,10 @@ gnulib_modules="
dirfd
dirname
do-release-commit-and-tag
dtimespec-bound
dtoastr
dup2
endian
environ
error
euidaccess
@@ -137,7 +141,7 @@ gnulib_modules="
gnupload
hard-locale
hash
hash-triple
hashcode-file-inode
heap
host-os
human
@@ -145,10 +149,12 @@ gnulib_modules="
idx
ignore-value
inttostr
inttypes
inttypes-h
isapipe
isatty
isblank
issymlink
issymlinkat
largefile
lchmod
ldtoastr
@@ -213,7 +219,7 @@ gnulib_modules="
pthread-mutex
pthread-thread
pthread_sigmask
putenv
putenv-gnu
quote
quotearg
randint
@@ -246,10 +252,12 @@ gnulib_modules="
stat-macros
stat-size
stat-time
stdbool
stdckdint
stdc_leading_zeros
stdc_trailing_zeros
stdckdint-h
stdlib-safer
stpcpy
str_endswith
strdup-posix
strnlen
strnumcmp
@@ -257,13 +265,14 @@ gnulib_modules="
strtoimax
strtoumax
symlinkat
sys_ioctl
sys_resource
sys_stat
sys_wait
sys_ioctl-h
sys_resource-h
sys_stat-h
sys_types-h
sys_wait-h
targetdir
tempname
termios
termios-h
time_rz
timer-time
timespec
@@ -303,12 +312,14 @@ gnulib_modules="
xprintf
xprintf-posix
xreadlink
xsetenv
xstrtod
xstrtoimax
xstrtol
xstrtol-error
xstrtold
xstrtoumax
xvasprintf
year2038-recommended
yesno
"
@@ -333,7 +344,7 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
--from-code=UTF-8\\\
'
# Append these, since we use the propername module.
# Append these, since we use the propername-lite module.
see_manual='"This is a proper name. See the gettext manual, section Names."'
see_manual=\'"$see_manual"\'
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
@@ -352,7 +363,7 @@ automake 1.11.2
autopoint 0.19.2
bison -
gettext 0.19.2
git 1.4.4
git 1.5.5
gperf -
gzip -
m4 -
@@ -378,12 +389,22 @@ bootstrap_post_import_hook ()
&& chmod a-w $tmp-1 $tmp-2 \
&& mv -f $tmp-1 $m4f && mv -f $tmp-2 $mkf)
# If "AM_GNU_GETTEXT(external" or "AM_GNU_GETTEXT([external]" appears
# in configure.ac, remove a file unnecessarily imported by autopoint.
if grep '^[ ]*AM_GNU_GETTEXT(\[*external]*[,)]' \
configure.ac >/dev/null 2>&1; then
rm -f m4/longlong.m4
fi
# Regenerate src/single-binary.mk
(mkf=src/single-binary.mk tmp=single-binary.tmp \
&& rm -f $mkf $tmp \
&& build-aux/gen-single-binary.sh src/local.mk >$tmp \
&& chmod a-w $tmp \
&& mv -f $tmp $mkf)
# Copy tests/init.sh from Gnulib.
$gnulib_tool --copy-file tests/init.sh
}
@@ -402,7 +423,7 @@ bootstrap_epilogue()
# Add dummy 'install-html' target, required for packages using
# non-recursive makefiles with older gettext.
# See https://debbugs.gnu.org/25690
# See https://bugs.gnu.org/25690
if ! grep -w 'install-html' po/Makefile.in.in ; then
printf 'install-%s:;\n' dvi ps pdf html >> po/Makefile.in.in
fi

99
cfg.mk
View File

@@ -1,5 +1,5 @@
# Customize maint.mk -*- makefile -*-
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
# Copyright (C) 2003-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@ manual_title = Core GNU utilities
url_dir_list = https://ftp.gnu.org/gnu/$(PACKAGE)
# Exclude bundled external projects from syntax checks
VC_LIST_ALWAYS_EXCLUDE_REGEX = src/blake2/.*$$
VC_LIST_ALWAYS_EXCLUDE_REGEX = src/(blake2/.*|longlong.h)$$
# Tests not to run as part of "make distcheck".
local-checks-to-skip = \
@@ -48,7 +48,7 @@ export VERBOSE = yes
# 4914152 9e
export XZ_OPT = -8e
old_NEWS_hash = d66ee7a9fdb974017a4a17cf358d047d
old_NEWS_hash = 0e74b03eaf11d9d281aaa0e7cc544bb4
# Add an exemption for sc_makefile_at_at_check.
_makefile_at_at_check_exceptions = \
@@ -57,6 +57,11 @@ _makefile_at_at_check_exceptions = \
# Our help-version script is in a slightly different location.
_hv_file ?= $(srcdir)/tests/misc/help-version
world:
./bootstrap && \
./configure --quiet && \
$(MAKE) $(AM_MAKEFLAGS) -j $$(nproc 2>/dev/null || echo 1)
# Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
dd = $(srcdir)/src/dd.c
sc_dd_O_FLAGS:
@@ -116,7 +121,7 @@ sc_tests_list_consistency:
cd $(top_srcdir); \
$(SHELL) build-aux/vc-list-files tests \
| grep -Ev '^tests/(factor/(run|create-test)|init)\.sh$$' \
| grep -E "$$test_extensions_rx\$$"; \
| grep -E "($$test_extensions_rx)$$"; \
} | sort | uniq -u | grep . && exit 1; :
# Ensure that all version-controlled test scripts are executable.
@@ -139,9 +144,10 @@ sc_ensure_gl_diffs_apply_cleanly:
done
# Avoid :>file which doesn't propagate errors
# Also :>file was seen to trigger EXIT trap on cygwin
sc_prohibit_colon_redirection:
@cd $(srcdir)/tests && GIT_PAGER= git grep -En ': *>.*\|\|' \
&& { echo '$(ME): '"The leading colon in :> will hide errors" >&2; \
@cd $(srcdir)/tests && GIT_PAGER= git grep -En ': *>[^>]' \
&& { echo '$(ME): '":> will hide errors or may trigger EXIT" >&2; \
exit 1; } \
|| :
@@ -298,6 +304,20 @@ sc_prohibit-gl-attributes:
halt='Use _GL... attribute macros' \
$(_sc_search_regexp)
# Ensure that <attributes.h> macros are used in .c files.
sc_prohibit-_gl-attributes:
@prohibit='_GL_ATTRIBUTE' \
in_vc_files='\.c$$' \
halt='Use ATTRIBUTE_... instead of _GL_ATTRIBUTE_...' \
$(_sc_search_regexp)
# Prefer the STRUCT_UTMP typedef over struct gl_utmp.
sc_prohibit-struct-gl_utmp:
@prohibit='struct gl_utmp' \
in_vc_files='\.[ch]$$' \
halt='Use STRUCT_UTMP, not struct gl_utmp' \
$(_sc_search_regexp)
# Prefer the const declaration form, with const following the type
sc_prohibit-const-char:
@prohibit='const char \*' \
@@ -330,6 +350,14 @@ sc_long_lines:
sed -e "s|^|$$file:|" -e '$(FILTER_LONG_LINES)'; \
done | grep . && { msg="$$halt" $(_sc_say_and_exit) } || :
sc_standard_outputs: $(ALL_MANS)
@grep -E 'std(in|out|err)' man/*.1 doc/*.texi \
&& { echo 1>&2 '$@: use "standard ....." in user docs'; exit 1; } || :
@grep -E '[Ss]tandard (in|out|err)([^op]|$$)' man/*.1 doc/*.texi \
&& { echo 1>&2 '$@: use "standard ..put" in user docs'; exit 1; } || :
@grep -E '_\("[^"]*std(in|out|err)' src/*.c \
&& { echo 1>&2 '$@: use "standard ..put" in messages'; exit 1; } || :
# Option descriptions should not start with a capital letter.
# One could grep source directly as follows:
# grep -E " {2,6}-.*[^.] [A-Z][a-z]" $$($(VC_LIST_EXCEPT) | grep '\.c$$')
@@ -493,6 +521,12 @@ sc_prohibit_NULL:
halt='use nullptr instead' \
$(_sc_search_regexp)
sc_prohibit_bare_set:
@prohibit='^ *set [`$$]' \
in_vc_files='\.sh$$' \
halt='use set -- $$args instead of set $$args' \
$(_sc_search_regexp)
# Don't use "indent-tabs-mode: nil" anymore. No longer needed.
sc_prohibit_emacs__indent_tabs_mode__setting:
@prohibit='^( *[*#] *)?indent-tabs-mode:' \
@@ -801,7 +835,8 @@ sc_fs-magic-compare:
sc_gitignore_missing:
@{ sed -n '/^\/lib\/.*\.h$$/{p;p}' $(srcdir)/.gitignore; \
find lib -name '*.in*' ! -name '*~' ! -name 'sys_*' | \
sed 's|^|/|; s|_\(.*in\.h\)|/\1|; s/\.in//'; } | \
sed 's|^|/|; s|_\(.*in\.h\)|/\1|; s/\.in//' | \
sed 's|/fts\.h$$|/fts_.h|'; } | \
sort | uniq -u | grep . && { echo '$(ME): Add above' \
'entries to .gitignore' >&2; exit 1; } || :
@@ -814,12 +849,36 @@ sc_gitignore_missing:
# sort | uniq -d | grep . && { echo '$(ME): Remove above' \
# 'entries from .gitignore' >&2; exit 1; } || :
# Ensure gl/ files are distributed
sc_gldist_missing:
@cd $(srcdir); \
grep '^gl/' gl/local.mk > $@.a; \
find gl '(' -name Makefile.am ')' -prune -o -type f \
'!' '(' -name '*.orig' -or -name '*~' -or \
-name 'ChangeLog.*' ')' -printf '%p\n' | \
LC_ALL=C sort | tr '\012' @ | sed 's/@$$/%/;s/@/ \\@/g' | \
tr @% '\012\012' > $@.e; \
diff -u $@.a $@.e; diff=$$?; \
rm -f $@.a $@.e; \
test "$$diff" = 0 \
|| { echo '$(ME): Inconsistent EXTRA_DIST in gl/local.mk'>&2; \
exit 1; }
sc_prohibit-form-feed:
@prohibit=$$'\f' \
in_vc_files='\.[chly]$$' \
halt='Form Feed (^L) detected' \
$(_sc_search_regexp)
# debbugs.gnu.org/cgi/bugreport.cgi?bug=... -> bugs.gnu.org/...
# bugzilla.redhat.com/show_bug.cgi?id=... -> bugzilla.redhat.com/...
# sourceware.org/bugzilla/show_bug.cgi?id=... -> sourceware.org/PR...
# gcc.gnu.org/bugzilla/show_bug.cgi?id=... -> gcc.gnu.org/PR...
sc_prohibit-long-form-bug-urls:
@prohibit='http.*(bugreport|show_bug)\.cgi' \
halt='use short form bug url' \
$(_sc_search_regexp)
# Override the default Cc: used in generating an announcement.
announcement_Cc_ = $(translation_project_), \
coreutils@gnu.org, coreutils-announce@gnu.org
@@ -838,11 +897,13 @@ exclude_file_name_regexp--sc_bindtextdomain = \
^(gl/.*|lib/euidaccess-stat|src/make-prime-list|src/cksum)\.c$$
exclude_file_name_regexp--sc_trailing_blank = \
^(tests/pr/|gl/.*\.diff$$|man/help2man)
_x_system_h := (system|copy|chown-core|find-mount-point)\.h
_x_system_c := (libstdbuf|make-prime-list)\.c
exclude_file_name_regexp--sc_system_h_headers = \
^src/((system|copy|chown-core|find-mount-point)\.h|make-prime-list\.c)$$
^src/($(_x_system_h)|$(_x_system_c))$$
_src := (false|lbracket|chown-(chgrp|chown)
_src := $(_src)|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
_src := $(_src)|ls-(dir|ls|vdir)|make-prime-list|tac-pipe|uname-(arch|uname))
_gl_src = (xdecto.max|cl-strtold)
exclude_file_name_regexp--sc_require_config_h_first = \
(^lib/buffer-lcm\.c|gl/lib/$(_gl_src)\.c|src/$(_src)\.c)$$
@@ -894,13 +955,15 @@ exclude_file_name_regexp--sc_prohibit_operator_at_end_of_line = \
exclude_file_name_regexp--sc_error_message_uppercase = ^src/factor\.c$$
exclude_file_name_regexp--sc_prohibit_atoi_atof = ^src/make-prime-list\.c$$
# Exception here as we don't want __attribute elided on non GCC
exclude_file_name_regexp--sc_prohibit-gl-attributes = ^src/libstdbuf\.c$$
# Exception here as we don't want __attribute elided on non GCC for stdbuf
# and we don't want to depend on gnulib for make-prime-list
exclude_file_name_regexp--sc_prohibit-gl-attributes = \
^src/(make-prime-list|libstdbuf)\.c$$
exclude_file_name_regexp--sc_prohibit_uppercase_id_est = \.diff$$
exclude_file_name_regexp--sc_ensure_dblspace_after_dot_before_id_est = \.diff$$
exclude_file_name_regexp--sc_ensure_comma_after_id_est = \.diff|$(_ll)$$
exclude_file_name_regexp--sc_long_lines = \.diff$$|$(_ll)|$(_cksum)
exclude_file_name_regexp--sc_long_lines = \.diff$$|$(_ll)|$(_cksum)|bootstrap
# `grep . -q` is not exactly equivalent to `grep . >/dev/null`
# and this difference is significant in the NEWS description
@@ -923,13 +986,15 @@ _gl_TS_unmarked_extern_functions = main usage
_gl_TS_unmarked_extern_functions += single_binary_main_.* _usage_.*
# Headers to search for single line extern _data_ declarations.
_gl_TS_other_headers = $(srcdir)/src/*.h src/*.h
# Tell the tight_scope rule about an exceptional "extern" variable.
# Normally, the rule would detect its declaration, but that uses a
# different name, __clz_tab.
_gl_TS_unmarked_extern_vars = factor_clz_tab
# Avoid tight_scope rule stating these should be static
# as there is no way to achieve that with the way these are defined.
_gl_TS_unmarked_extern_vars += ptr_MD5_.*
_gl_TS_unmarked_extern_vars = ptr_MD5_.*
# Other tight_scope settings
_gl_TS_dir = .
_gl_TS_obj_files = src/*.$(OBJEXT)
# Settings for running codespell.
csiwl_1 = debbugs,clen,te,bu,shs,linke,fo,souch,inout,outin
csiwl_2 = kno,ois,afile,whats,hda,indx,ot,nam
codespell_ignore_words_list = $(csiwl_1),$(csiwl_2)
exclude_file_name_regexp--sc_codespell = \
^(THANKS\.in|tests/pr/.*(F|tn?|l(o|m|i)|bl))$$

View File

@@ -1,7 +1,7 @@
# -*- autoconf -*-
# Process this file with autoconf to produce a configure script.
# Copyright (C) 1991-2024 Free Software Foundation, Inc.
# Copyright (C) 1991-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -190,33 +190,10 @@ if test $gl_gcc_warnings != no; then
# This, $nw, is the list of warnings we disable.
nw=$ew
nw="$nw -Wdeclaration-after-statement" # too useful to forbid
nw="$nw -Waggregate-return" # anachronistic
nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
nw="$nw -Wc++-compat" # We don't care about C++ compilers
nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
nw="$nw -Wtraditional" # Warns on #elif which we use often
nw="$nw -Wcast-qual" # Too many warnings for now
nw="$nw -Wconversion" # Too many warnings for now
nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
nw="$nw -Wsign-conversion" # Too many warnings for now
nw="$nw -Wtraditional-conversion" # Too many warnings for now
nw="$nw -Wunreachable-code" # Too many warnings for now
nw="$nw -Wpadded" # Our structs are not padded
nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
nw="$nw -Wswitch-enum" # Too many warnings for now
nw="$nw -Wswitch-default" # Too many warnings for now
nw="$nw -Wstack-protector" # not worth working around
nw="$nw -Wstack-protector" # not worth working around for pre GCC 15
nw="$nw -Wformat-overflow=2" # False alarms due to GCC bug 110333
nw="$nw -Wformat-truncation=2" # False alarm in ls.c, probably related
# things I might fix soon:
nw="$nw -Wfloat-equal" # sort.c, seq.c
nw="$nw -Wmissing-format-attribute" # copy.c
nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
nw="$nw -Wvector-operation-performance" # warns about randperm.c
# Suppress noreturn warnings with single binaries; otherwise
# GCC complains about the renamed 'main' not being declared noreturn
@@ -227,21 +204,19 @@ if test $gl_gcc_warnings != no; then
# Using -Wstrict-overflow is a pain, but the alternative is worse.
# For an example, see the code that provoked this report:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
# https://gcc.gnu.org/PR33498
# Code like that still infloops with gcc-4.6.0 and -O2. Scary indeed.
gl_MANYWARN_ALL_GCC([ws])
AS_VAR_APPEND([ws], [' -Wswitch-enum'])
AS_VAR_APPEND([ws], [' -Wtrailing-whitespace'])
gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
for w in $ws; do
gl_WARN_ADD([$w])
done
gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
gl_WARN_ADD([-Wno-format-nonliteral])
gl_WARN_ADD([-fdiagnostics-show-option])
gl_WARN_ADD([-funit-at-a-time])
AC_SUBST([WARN_CFLAGS])
AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
@@ -259,30 +234,16 @@ if test $gl_gcc_warnings != no; then
nw=$ew
nw="$nw -Wduplicated-branches" # Too many false alarms
nw="$nw -Wformat-truncation=2"
nw="$nw -Wstrict-overflow"
nw="$nw -Wuninitialized"
nw="$nw -Wunused-macros"
nw="$nw -Wmissing-prototypes"
nw="$nw -Wold-style-definition"
# FIXME: it may be easy to remove this, since it affects only one file:
# the snprintf call at ftoastr.c:132.
nw="$nw -Wdouble-promotion"
# FIXME: remove this line when gcc improves
# FP in careadlinkat.c w/gcc 10.0.1 20200205
gl_WARN_ADD([-Wno-return-local-addr])
# FIXME: remove this line when gcc improves
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
gl_WARN_ADD([-Wno-stringop-overflow])
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
AC_SUBST([GNULIB_WARN_CFLAGS])
# For gnulib-tests, the set is slightly smaller still.
nw=
nw="$nw -Wstrict-prototypes"
# It's not worth being this picky about test programs.
nw="$nw -Wmissing-variable-declarations"
nw="$nw -Wsuggest-attribute=cold"
nw="$nw -Wsuggest-attribute=const"
nw="$nw -Wsuggest-attribute=format"
nw="$nw -Wsuggest-attribute=pure"
@@ -366,8 +327,8 @@ AS_CASE([$LIB_CRYPTO],
[# Check for dlopen and libcrypto dynamic linking in one program,
# as there's little point to checking them separately.
AC_CACHE_CHECK([for dlopen and whether libcrypto is linked dynamically],
[utils_cv_dlopen_libcrypto],
[utils_cv_dlopen_libcrypto=no
[utils_cv_libcrypto_soname],
[utils_cv_libcrypto_soname=no
saved_LIBS=$LIBS
LIBS="$LIBS $LIB_DL $LIB_CRYPTO"
AC_LINK_IFELSE(
@@ -385,14 +346,14 @@ AS_CASE([$LIB_CRYPTO],
sed -n 's/.*\(libcrypto\.so\.[[.0-9]]*\).*/\1/p'`"
AS_CASE([$LIBCRYPTO_SONAME],
[*libcrypto*],
[utils_cv_dlopen_libcrypto=yes])])
[utils_cv_libcrypto_soname=$LIBCRYPTO_SONAME])])
LIBS=$saved_LIBS])
AS_CASE([$utils_cv_dlopen_libcrypto],
[yes],
AS_CASE([$utils_cv_libcrypto_soname],
[*libcrypto*],
[AC_DEFINE([DLOPEN_LIBCRYPTO], [1],
[Define to 1 if dlopen exists and libcrypto is
linked dynamically.])
AC_DEFINE_UNQUOTED([LIBCRYPTO_SONAME], ["$LIBCRYPTO_SONAME"],
AC_DEFINE_UNQUOTED([LIBCRYPTO_SONAME], ["$utils_cv_libcrypto_soname"],
[versioned libcrypto])
])])
@@ -617,6 +578,40 @@ if test $utils_cv_brain_16_bit_supported = yes; then
AC_DEFINE([BF16_SUPPORTED], [1], [Brain 16 bit float supported])
fi
ac_save_CFLAGS=$CFLAGS
CFLAGS="-march=armv8-a+crypto $CFLAGS"
AC_MSG_CHECKING([if vmull intrinsic exists])
AC_CACHE_VAL([utils_cv_vmull_intrinsic_exists],[
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <stdio.h>
#include <sys/auxv.h>
#include <asm/hwcap.h>
#include <arm_neon.h>
int
main (void)
{
uint64x2_t a;
poly64_t shift64 = vget_lane_p64(vcreate_p64(0xB8BC6765), 0);
a = vreinterpretq_u64_p128(vmull_p64(shift64, vreinterpretq_p128_u64(a)));
return (getauxval(AT_HWCAP) & HWCAP_PMULL) > 0;
}
]])
],[
utils_cv_vmull_intrinsic_exists=yes
],[
utils_cv_vmull_intrinsic_exists=no
])])
AC_MSG_RESULT([$utils_cv_vmull_intrinsic_exists])
if test $utils_cv_vmull_intrinsic_exists = yes; then
AC_DEFINE([USE_VMULL_CRC32], [1],
[CRC32 calculation by vmull hardware instruction enabled])
fi
AM_CONDITIONAL([USE_VMULL_CRC32],
[test $utils_cv_vmull_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
ac_save_CFLAGS=$CFLAGS
CFLAGS="-mavx -mpclmul $CFLAGS"
AC_MSG_CHECKING([if pclmul intrinsic exists])
@@ -648,6 +643,75 @@ AM_CONDITIONAL([USE_PCLMUL_CRC32],
[test $utils_cv_pclmul_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
ac_save_CFLAGS=$CFLAGS
CFLAGS=" -mavx2 -mvpclmulqdq $CFLAGS"
AC_MSG_CHECKING([if avx2 pclmul intrinsic exists])
AC_CACHE_VAL([utils_cv_avx2_pclmul_intrinsic_exists],[
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <x86intrin.h>
int
main (void)
{
__m256i a, b;
a = _mm256_clmulepi64_epi128 (a, b, 0x00);
a = _mm256_shuffle_epi8 (a, b);
return __builtin_cpu_supports ("avx2") &&
__builtin_cpu_supports ("vpclmulqdq");
}
]])
],[
utils_cv_avx2_pclmul_intrinsic_exists=yes
],[
utils_cv_avx2_pclmul_intrinsic_exists=no
])])
AC_MSG_RESULT([$utils_cv_avx2_pclmul_intrinsic_exists])
if test $utils_cv_avx2_pclmul_intrinsic_exists = yes; then
AC_DEFINE([USE_AVX2_CRC32], [1],
[CRC32 calculation by avx2 hardware instructions enabled])
fi
AM_CONDITIONAL([USE_AVX2_CRC32],
[test $utils_cv_avx2_pclmul_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
ac_save_CFLAGS=$CFLAGS
CFLAGS=" -mavx512bw -mavx512f -mvpclmulqdq $CFLAGS"
AC_MSG_CHECKING([if avx512 pclmul intrinsic exists])
AC_CACHE_VAL([utils_cv_avx512_pclmul_intrinsic_exists],[
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <x86intrin.h>
int
main (void)
{
__m512i a, b;
a = _mm512_set_epi8 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
a = _mm512_clmulepi64_epi128 (a, b, 0x00);
a = _mm512_shuffle_epi8 (a, b);
return (__builtin_cpu_supports ("avx512bw")
&& __builtin_cpu_supports ("avx512f")
&& __builtin_cpu_supports ("vpclmulqdq"));
}
]])
],[
utils_cv_avx512_pclmul_intrinsic_exists=yes
],[
utils_cv_avx512_pclmul_intrinsic_exists=no
])])
AC_MSG_RESULT([$utils_cv_avx512_pclmul_intrinsic_exists])
if test $utils_cv_avx512_pclmul_intrinsic_exists = yes; then
AC_DEFINE([USE_AVX512_CRC32], [1],
[CRC32 calculation by avx512 hardware instructions enabled])
fi
AM_CONDITIONAL([USE_AVX512_CRC32],
[test $utils_cv_avx512_pclmul_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
CFLAGS="-mavx2 $CFLAGS"
AC_MSG_CHECKING([for avx2 intrinsics])
AC_CACHE_VAL([utils_cv_avx2_intrinsic_exists],[
@@ -658,8 +722,9 @@ AC_LINK_IFELSE(
int
main (void)
{
__m256i a, b;
a = _mm256_sad_epu8 (a, b);
__m256i matches = _mm256_setzero_si256 ();
int mask = _mm256_movemask_epi8 (matches);
int lines = __builtin_popcount (mask);
return __builtin_cpu_supports ("avx2");
}
]])

2
doc/.gitignore vendored
View File

@@ -13,6 +13,8 @@
/coreutils.op
/coreutils.pdf
/coreutils.pg
/coreutils.ps
/coreutils.t2d/
/coreutils.t2p/
/coreutils.toc
/coreutils.tp

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
# Make coreutils documentation. -*-Makefile-*-
# This is included by the top-level Makefile.am.
# Copyright (C) 1995-2024 Free Software Foundation, Inc.
# Copyright (C) 1995-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -42,7 +42,8 @@ AM_MAKEINFOFLAGS = --no-split
doc/constants.texi: $(top_srcdir)/src/tail.c $(top_srcdir)/src/shred.c
$(AM_V_GEN)LC_ALL=C; export LC_ALL; \
$(MKDIR_P) doc && \
{ sed -n -e 's/^#define \(DEFAULT_MAX[_A-Z]*\) \(.*\)/@set \1 \2/p' \
{ sed -n -e \
's/.*\(DEFAULT_MAX[_A-Z]*\)[ =]* \([0-9]*\).*/@set \1 \2/p' \
$(top_srcdir)/src/tail.c && \
sed -n -e \
's/.*\(DEFAULT_PASSES\)[ =]* \([0-9]*\).*/@set SHRED_\1 \2/p'\

View File

@@ -1,6 +1,6 @@
@c File mode bits
@c Copyright (C) 1994--2024 Free Software Foundation, Inc.
@c Copyright (C) 1994--2025 Free Software Foundation, Inc.
@c Permission is granted to copy, distribute and/or modify this document
@c under the terms of the GNU Free Documentation License, Version 1.3 or

View File

@@ -1,6 +1,6 @@
@c GNU Version-sort ordering documentation
@c Copyright (C) 2019--2024 Free Software Foundation, Inc.
@c Copyright (C) 2019--2025 Free Software Foundation, Inc.
@c Permission is granted to copy, distribute and/or modify this document
@c under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -858,7 +858,7 @@ NodeJS's @uref{https://www.npmjs.com/package/natural-sort,natural-sort package}.
@item
In zsh, the
@uref{http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers,
@uref{https://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers,
glob modifier} @samp{*(n)} will expand to files in natural sort order.
@item

View File

@@ -1,6 +1,6 @@
/* buffer-lcm.c - compute a good buffer size for dealing with two files
Copyright (C) 2002-2024 Free Software Foundation, Inc.
Copyright (C) 2002-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Convert string to double in the current locale, falling back on the C locale.
Copyright 2019-2024 Free Software Foundation, Inc.
Copyright 2019-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

3
gl/lib/dtimespec-bound.c Normal file
View File

@@ -0,0 +1,3 @@
#include <config.h>
#define DTIMESPEC_BOUND_INLINE _GL_EXTERN_INLINE
#include "dtimespec-bound.h"

76
gl/lib/dtimespec-bound.h Normal file
View File

@@ -0,0 +1,76 @@
/* Compute a timespec-related bound for floating point.
Copyright 2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Paul Eggert */
#ifndef DTIMESPEC_BOUND_H
# define DTIMESPEC_BOUND_H 1
/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */
# if !_GL_CONFIG_H_INCLUDED
# error "Please include config.h first."
# endif
# include <errno.h>
# include <float.h>
# include <math.h>
_GL_INLINE_HEADER_BEGIN
# ifndef DTIMESPEC_BOUND_INLINE
# define DTIMESPEC_BOUND_INLINE _GL_INLINE
# endif
/* If C is positive and finite, return the least floating point value
greater than C. However, if 0 < C < (2 * DBL_TRUE_MIN) / (DBL_EPSILON**2),
return a positive value less than 1e-9.
If C is +0.0, return a positive value < 1e-9 if ERR == ERANGE, C otherwise.
If C is +Inf, return C.
If C is negative, return -timespec_roundup(-C).
If C is a NaN, return a NaN.
Assume round-to-even.
This function can be useful if some floating point operation
rounded to C but we want a nearby bound on the true value, where
the bound can be converted to struct timespec. If the operation
underflowed to zero, ERR should be ERANGE a la strtod. */
DTIMESPEC_BOUND_INLINE double
dtimespec_bound (double c, int err)
{
/* Do not use copysign or nextafter, as they link to -lm in GNU/Linux. */
/* Use DBL_TRUE_MIN for the special case of underflowing to zero;
any positive value less than 1e-9 will do. */
if (err == ERANGE && c == 0)
return signbit (c) ? -DBL_TRUE_MIN : DBL_TRUE_MIN;
/* This is the first part of Algorithm 2 of:
Rump SM, Zimmermann P, Boldo S, Melquiond G.
Computing predecessor and successor in rounding to nearest.
BIT Numerical Mathematics. 2009;49(419-431).
<https://doi.org/10.1007/s10543-009-0218-z>
The rest of Algorithm 2 is not needed because numbers less than
the predecessor of 1e-9 merely need to stay less than 1e-9. */
double phi = DBL_EPSILON / 2 * (1 + DBL_EPSILON);
return c + phi * c;
}
_GL_INLINE_HEADER_END
#endif

View File

@@ -1,5 +1,5 @@
/* Declare an access pattern hint for files.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
Copyright (C) 2010-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/* Declare an access pattern hint for files.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
Copyright (C) 2010-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Invoke open, but return either a desired file descriptor or -1.
Copyright (C) 2005-2024 Free Software Foundation, Inc.
Copyright (C) 2005-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Invoke open, but return either a desired file descriptor or -1.
Copyright (C) 2005-2024 Free Software Foundation, Inc.
Copyright (C) 2005-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Barebones heap implementation supporting only insert and pop.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
Copyright (C) 2010-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,23 +25,23 @@
#include "xalloc.h"
static int heap_default_compare (void const *, void const *);
static size_t heapify_down (void **, size_t, size_t,
int (*) (void const *, void const *));
static void heapify_up (void **, size_t,
static void heapify_down (void **, idx_t, idx_t,
int (*) (void const *, void const *));
static void heapify_up (void **, idx_t,
int (*) (void const *, void const *));
struct heap
{
void **array; /* array[0] is not used */
size_t capacity; /* Array size */
size_t count; /* Used as index to last element. Also is num of items. */
idx_t capacity; /* Array size */
idx_t count; /* Used as index to last element. Also is num of items. */
int (*compare) (void const *, void const *);
};
/* Allocate memory for the heap. */
struct heap *
heap_alloc (int (*compare) (void const *, void const *), size_t n_reserve)
heap_alloc (int (*compare) (void const *, void const *), idx_t n_reserve)
{
struct heap *heap = xmalloc (sizeof *heap);
@@ -79,8 +79,8 @@ int
heap_insert (struct heap *heap, void *item)
{
if (heap->capacity - 1 <= heap->count)
heap->array = x2nrealloc (heap->array, &heap->capacity,
sizeof *(heap->array));
heap->array = xpalloc (heap->array, &heap->capacity, 1, -1,
sizeof heap->array[0]);
heap->array[++heap->count] = item;
heapify_up (heap->array, heap->count, heap->compare);
@@ -107,16 +107,16 @@ heap_remove_top (struct heap *heap)
/* Move element down into appropriate position in heap. */
static size_t
heapify_down (void **array, size_t count, size_t initial,
static void
heapify_down (void **array, idx_t count, idx_t initial,
int (*compare) (void const *, void const *))
{
void *element = array[initial];
size_t parent = initial;
while (parent <= count / 2)
idx_t parent = initial;
while (parent <= count >> 1)
{
size_t child = 2 * parent;
idx_t child = 2 * parent;
if (child < count && compare (array[child], array[child + 1]) < 0)
child++;
@@ -129,22 +129,21 @@ heapify_down (void **array, size_t count, size_t initial,
}
array[parent] = element;
return parent;
}
/* Move element up into appropriate position in heap. */
static void
heapify_up (void **array, size_t count,
heapify_up (void **array, idx_t count,
int (*compare) (void const *, void const *))
{
size_t k = count;
idx_t k = count;
void *new_element = array[k];
while (k != 1 && compare (array[k / 2], new_element) <= 0)
while (k != 1 && compare (array[k >> 1], new_element) <= 0)
{
array[k] = array[k / 2];
k /= 2;
array[k] = array[k >> 1];
k >>= 1;
}
array[k] = new_element;

View File

@@ -1,6 +1,6 @@
/* Barebones heap implementation supporting only insert and pop.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
Copyright (C) 2010-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,13 +18,15 @@
/* Full implementation: GDSL (http://gna.org/projects/gdsl/) by Nicolas
Darnis <ndarnis@free.fr>. Adapted by Gene Auyeung. */
#include "idx.h"
#include <stddef.h>
struct heap;
void heap_free (struct heap *) _GL_ATTRIBUTE_NONNULL ();
struct heap *heap_alloc (int (*) (void const *, void const *), size_t)
struct heap *heap_alloc (int (*) (void const *, void const *), idx_t)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (heap_free, 1)
_GL_ATTRIBUTE_RETURNS_NONNULL;

View File

@@ -1,6 +1,6 @@
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
Copyright (C) 1999-2024 Free Software Foundation, Inc.
Copyright (C) 1999-2025 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999 Colin Plumb.
This program is free software: you can redistribute it and/or modify

View File

@@ -1,6 +1,6 @@
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
Copyright (C) 1999-2024 Free Software Foundation, Inc.
Copyright (C) 1999-2025 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999 Colin Plumb.
This program is free software: you can redistribute it and/or modify

View File

@@ -1,6 +1,6 @@
/* Generate random integers.
Copyright (C) 2006-2024 Free Software Foundation, Inc.
Copyright (C) 2006-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Generate random integers.
Copyright (C) 2006-2024 Free Software Foundation, Inc.
Copyright (C) 2006-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Generate random permutations.
Copyright (C) 2006-2024 Free Software Foundation, Inc.
Copyright (C) 2006-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -22,28 +22,15 @@
#include "randperm.h"
#include <limits.h>
#include <stdbit.h>
#include <stdckdint.h>
#include <stdint.h>
#include <stdlib.h>
#include "attribute.h"
#include "count-leading-zeros.h"
#include "hash.h"
#include "xalloc.h"
/* Return the floor of the log base 2 of N. If N is zero, return -1. */
ATTRIBUTE_CONST static int
floor_lg (size_t n)
{
static_assert (SIZE_WIDTH <= ULLONG_WIDTH);
return (n == 0 ? -1
: SIZE_WIDTH <= UINT_WIDTH
? UINT_WIDTH - 1 - count_leading_zeros (n)
: SIZE_WIDTH <= ULONG_WIDTH
? ULONG_WIDTH - 1 - count_leading_zeros_l (n)
: ULLONG_WIDTH - 1 - count_leading_zeros_ll (n));
}
/* Return an upper bound on the number of random bytes needed to
generate the first H elements of a random permutation of N
elements. H must not exceed N. */
@@ -53,13 +40,15 @@ randperm_bound (size_t h, size_t n)
{
/* Upper bound on number of bits needed to generate the first number
of the permutation. */
uintmax_t lg_n = floor_lg (n) + 1;
unsigned int lg_n = stdc_bit_width (n) + 1;
/* Upper bound on number of bits needed to generated the first H elements. */
uintmax_t ar = lg_n * h;
/* Upper bound on number of bits needed to generate the first H elements. */
uintmax_t ar;
if (ckd_mul (&ar, lg_n, h))
return SIZE_MAX;
/* Convert the bit count to a byte count. */
size_t bound = (ar + CHAR_BIT - 1) / CHAR_BIT;
size_t bound = ar / CHAR_BIT + (ar % CHAR_BIT != 0);
return bound;
}

View File

@@ -1,6 +1,6 @@
/* Generate buffers of random data.
Copyright (C) 2006-2024 Free Software Foundation, Inc.
Copyright (C) 2006-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -189,9 +189,19 @@ randread_new (char const *name, size_t bytes_bound)
setvbuf (source, s->buf.c, _IOFBF, MIN (sizeof s->buf.c, bytes_bound));
else
{
/* Fill the ISAAC buffer. Although it is tempting to read at
most BYTES_BOUND bytes, this is incorrect for two reasons.
First, BYTES_BOUND is just an estimate.
Second, even if the estimate is correct
ISAAC64 poorly randomizes when BYTES_BOUND is small
and just the first few bytes of s->buf.isaac.state.m
are random while the other bytes are all zero. See:
Aumasson J-P. On the pseudo-random generator ISAAC.
Cryptology ePrint Archive. 2006;438.
<https://eprint.iacr.org/2006/438>. */
s->buf.isaac.buffered = 0;
if (! get_nonce (s->buf.isaac.state.m,
MIN (sizeof s->buf.isaac.state.m, bytes_bound)))
sizeof s->buf.isaac.state.m))
{
int e = errno;
randread_free_body (s);

View File

@@ -1,6 +1,6 @@
/* Generate buffers of random data.
Copyright (C) 2006-2024 Free Software Foundation, Inc.
Copyright (C) 2006-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/* root-dev-ino.c -- get the device and inode numbers for '/'.
Copyright (C) 2003-2024 Free Software Foundation, Inc.
Copyright (C) 2003-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Root device and inode number checking.
Copyright (C) 2003-2024 Free Software Foundation, Inc.
Copyright (C) 2003-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Skipping sequences of characters satisfying a predicate
Copyright 2023-2024 Free Software Foundation, Inc.
Copyright 2023-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/* Include and determine availability of smack routines
Copyright (C) 2013-2024 Free Software Foundation, Inc.
Copyright (C) 2013-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,13 +21,13 @@
# include <sys/smack.h>
#else
static inline ssize_t
smack_new_label_from_self (char **label)
smack_new_label_from_self (MAYBE_UNUSED char **label)
{
return -1;
}
static inline int
smack_set_label_for_self (char const *label)
smack_set_label_for_self (MAYBE_UNUSED char const *label)
{
return -1;
}

View File

@@ -1,6 +1,6 @@
/* Compare integer strings.
Copyright (C) 2005-2024 Free Software Foundation, Inc.
Copyright (C) 2005-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Compare numeric strings. This is an internal include file.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
Copyright (C) 1988-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -22,21 +22,12 @@
# include "strnumcmp.h"
# include "c-ctype.h"
# include <stddef.h>
# define NEGATION_SIGN '-'
# define NUMERIC_ZERO '0'
/* ISDIGIT differs from isdigit, as follows:
- Its arg may be any int or unsigned int; it need not be an unsigned char
or EOF.
- It's typically faster.
POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
isdigit unless it's important to use the locale's definition
of 'digit' even when the host does not conform to POSIX. */
# define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
/* Compare strings A and B containing decimal fractions < 1.
DECIMAL_POINT is the decimal point. Each string
should begin with a decimal point followed immediately by the digits
@@ -76,13 +67,13 @@ fraccompare (char const *a, char const *b, char decimal_point)
if (*a == decimal_point && *b == decimal_point)
{
while (*++a == *++b)
if (! ISDIGIT (*a))
if (! c_isdigit (*a))
return 0;
if (ISDIGIT (*a) && ISDIGIT (*b))
if (c_isdigit (*a) && c_isdigit (*b))
return *a - *b;
if (ISDIGIT (*a))
if (c_isdigit (*a))
goto a_trailing_nonzero;
if (ISDIGIT (*b))
if (c_isdigit (*b))
goto b_trailing_nonzero;
return 0;
}
@@ -91,14 +82,14 @@ fraccompare (char const *a, char const *b, char decimal_point)
a_trailing_nonzero:
while (*a == NUMERIC_ZERO)
a++;
return ISDIGIT (*a);
return c_isdigit (*a);
}
else if (*b++ == decimal_point)
{
b_trailing_nonzero:
while (*b == NUMERIC_ZERO)
b++;
return - ISDIGIT (*b);
return - c_isdigit (*b);
}
return 0;
}
@@ -131,7 +122,7 @@ numcompare (char const *a, char const *b,
do
tmpa = *++a;
while (tmpa == NUMERIC_ZERO);
if (ISDIGIT (tmpa))
if (c_isdigit (tmpa))
return -1;
while (tmpb == NUMERIC_ZERO || tmpb == thousands_sep)
tmpb = *++b;
@@ -139,13 +130,13 @@ numcompare (char const *a, char const *b,
do
tmpb = *++b;
while (tmpb == NUMERIC_ZERO);
return - ISDIGIT (tmpb);
return - c_isdigit (tmpb);
}
do
tmpb = *++b;
while (tmpb == NUMERIC_ZERO || tmpb == thousands_sep);
while (tmpa == tmpb && ISDIGIT (tmpa))
while (tmpa == tmpb && c_isdigit (tmpa))
{
do
tmpa = *++a;
@@ -155,18 +146,18 @@ numcompare (char const *a, char const *b,
while (tmpb == thousands_sep);
}
if ((tmpa == decimal_point && !ISDIGIT (tmpb))
|| (tmpb == decimal_point && !ISDIGIT (tmpa)))
if ((tmpa == decimal_point && !c_isdigit (tmpb))
|| (tmpb == decimal_point && !c_isdigit (tmpa)))
return fraccompare (b, a, decimal_point);
tmp = tmpb - tmpa;
for (log_a = 0; ISDIGIT (tmpa); ++log_a)
for (log_a = 0; c_isdigit (tmpa); ++log_a)
do
tmpa = *++a;
while (tmpa == thousands_sep);
for (log_b = 0; ISDIGIT (tmpb); ++log_b)
for (log_b = 0; c_isdigit (tmpb); ++log_b)
do
tmpb = *++b;
while (tmpb == thousands_sep);
@@ -188,7 +179,7 @@ numcompare (char const *a, char const *b,
do
tmpb = *++b;
while (tmpb == NUMERIC_ZERO);
if (ISDIGIT (tmpb))
if (c_isdigit (tmpb))
return 1;
while (tmpa == NUMERIC_ZERO || tmpa == thousands_sep)
tmpa = *++a;
@@ -196,7 +187,7 @@ numcompare (char const *a, char const *b,
do
tmpa = *++a;
while (tmpa == NUMERIC_ZERO);
return ISDIGIT (tmpa);
return c_isdigit (tmpa);
}
else
{
@@ -205,7 +196,7 @@ numcompare (char const *a, char const *b,
while (tmpb == NUMERIC_ZERO || tmpb == thousands_sep)
tmpb = *++b;
while (tmpa == tmpb && ISDIGIT (tmpa))
while (tmpa == tmpb && c_isdigit (tmpa))
{
do
tmpa = *++a;
@@ -215,18 +206,18 @@ numcompare (char const *a, char const *b,
while (tmpb == thousands_sep);
}
if ((tmpa == decimal_point && !ISDIGIT (tmpb))
|| (tmpb == decimal_point && !ISDIGIT (tmpa)))
if ((tmpa == decimal_point && !c_isdigit (tmpb))
|| (tmpb == decimal_point && !c_isdigit (tmpa)))
return fraccompare (a, b, decimal_point);
tmp = tmpa - tmpb;
for (log_a = 0; ISDIGIT (tmpa); ++log_a)
for (log_a = 0; c_isdigit (tmpa); ++log_a)
do
tmpa = *++a;
while (tmpa == thousands_sep);
for (log_b = 0; ISDIGIT (tmpb); ++log_b)
for (log_b = 0; c_isdigit (tmpb); ++log_b)
do
tmpb = *++b;
while (tmpb == thousands_sep);

View File

@@ -1,6 +1,6 @@
/* Compare numeric strings.
Copyright (C) 2005-2024 Free Software Foundation, Inc.
Copyright (C) 2005-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Target directory operands for coreutils
Copyright 2004-2024 Free Software Foundation, Inc.
Copyright 2004-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -63,56 +63,14 @@ target_directory_operand (char const *file, struct stat *st)
if (must_be_working_directory (file))
return AT_FDCWD;
int fd = -1;
int try_to_open = 1;
int stat_result;
int fd = open (file, O_PATHSEARCH | O_DIRECTORY);
/* On old systems without O_DIRECTORY, like Solaris 10, check with
stat first lest we try to open a fifo for example and hang. */
if (!O_DIRECTORY)
{
stat_result = stat (file, st);
if (stat_result == 0)
{
try_to_open = S_ISDIR (st->st_mode);
errno = ENOTDIR;
}
else
{
/* On EOVERFLOW failure, give up on checking, as there is no
easy way to check. This should be rare. */
try_to_open = errno == EOVERFLOW;
}
}
if (try_to_open)
{
fd = open (file, O_PATHSEARCH | O_DIRECTORY);
/* On platforms lacking O_PATH, using O_SEARCH | O_DIRECTORY to
open an overly-protected non-directory can fail with either
EACCES or ENOTDIR. Prefer ENOTDIR as it makes for better
diagnostics. */
if (O_PATHSEARCH == O_SEARCH && fd < 0 && errno == EACCES)
errno = (((O_DIRECTORY ? stat (file, st) : stat_result) == 0
&& !S_ISDIR (st->st_mode))
? ENOTDIR : EACCES);
}
if (!O_DIRECTORY && 0 <= fd)
{
/* On old systems like Solaris 10 double check type,
to ensure we've opened a directory. */
int err;
if (fstat (fd, st) == 0
? !S_ISDIR (st->st_mode) && (err = ENOTDIR, true)
: (err = errno) != EOVERFLOW)
{
close (fd);
errno = err;
fd = -1;
}
}
/* On platforms lacking O_PATH, using O_SEARCH | O_DIRECTORY to
open an overly-protected non-directory can fail with either
EACCES or ENOTDIR. Prefer ENOTDIR as it makes for better
diagnostics. */
if (O_PATHSEARCH == O_SEARCH && fd < 0 && errno == EACCES)
errno = stat (file, st) < 0 || S_ISDIR (st->st_mode) ? EACCES : ENOTDIR;
return fd - (AT_FDCWD == -1 && fd < 0);
}

View File

@@ -1,6 +1,6 @@
/* Target directory operands for coreutils
Copyright 2022-2024 Free Software Foundation, Inc.
Copyright 2022-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -2,5 +2,4 @@
#define __xnumtoint xnumtoimax
#define __xdectoint_t intmax_t
#define __xstrtol xstrtoimax
#define __xdectoint_signed 1
#include "xdectoint.c"

View File

@@ -1,6 +1,6 @@
/* Convert decimal strings with bounds checking and exit on error.
Copyright (C) 2014-2024 Free Software Foundation, Inc.
Copyright (C) 2014-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,7 +21,6 @@
#include <errno.h>
#include <inttypes.h>
#include <stddef.h>
#include <stdlib.h>
#include <error.h>
@@ -29,50 +28,59 @@
#include <xstrtol.h>
/* Parse numeric string N_STR of base BASE, and return the value.
Exit on parse error or if MIN or MAX are exceeded.
The value is between MIN and MAX.
Strings can have multiplicative SUFFIXES if specified.
ERR is printed along with N_STR on error. */
On a parse error or out-of-range number, diagnose with N_STR and ERR, and
exit with status ERR_EXIT if nonzero, EXIT_FAILURE otherwise.
However, if FLAGS & XTOINT_MIN_QUIET, do not diagnose or exit
for too-low numbers; return MIN and set errno instead.
Similarly for XTOINT_MAX_QUIET and too-high numbers and MAX.
The errno value and diagnostic for out-of-range values depend on
whether FLAGS & XTOINT_MIN_RANGE and FLAGS & XTOINT_MAX_RANGE are set. */
__xdectoint_t
__xnumtoint (char const *n_str, int base, __xdectoint_t min, __xdectoint_t max,
char const *suffixes, char const *err, int err_exit)
char const *suffixes, char const *err, int err_exit,
int flags)
{
strtol_error s_err;
__xdectoint_t tnum, r;
strtol_error s_err = __xstrtol (n_str, nullptr, base, &tnum, suffixes);
__xdectoint_t tnum;
s_err = __xstrtol (n_str, nullptr, base, &tnum, suffixes);
/* Errno value to report if there is an overflow. */
int overflow_errno;
if (s_err == LONGINT_OK)
if (s_err != LONGINT_INVALID)
{
if (tnum < min || max < tnum)
if (tnum < min)
{
s_err = LONGINT_OVERFLOW;
/* Use have the INT range as a heuristic to distinguish
type overflow rather than other min/max limits. */
if (tnum > INT_MAX / 2)
errno = EOVERFLOW;
#if __xdectoint_signed
else if (tnum < INT_MIN / 2)
errno = EOVERFLOW;
#endif
else
errno = ERANGE;
r = min;
overflow_errno = flags & XTOINT_MIN_RANGE ? ERANGE : EOVERFLOW;
if (s_err == LONGINT_OK)
s_err = LONGINT_OVERFLOW;
}
else if (max < tnum)
{
r = max;
overflow_errno = flags & XTOINT_MAX_RANGE ? ERANGE : EOVERFLOW;
if (s_err == LONGINT_OK)
s_err = LONGINT_OVERFLOW;
}
else
{
r = tnum;
overflow_errno = EOVERFLOW;
}
}
else if (s_err == LONGINT_OVERFLOW)
errno = EOVERFLOW;
else if (s_err == LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW)
errno = 0; /* Don't show ERANGE errors for invalid numbers. */
if (s_err != LONGINT_OK)
{
/* EINVAL error message is redundant in this context. */
error (err_exit ? err_exit : EXIT_FAILURE, errno == EINVAL ? 0 : errno,
"%s: %s", err, quote (n_str));
unreachable ();
}
int e = s_err == LONGINT_OVERFLOW ? overflow_errno : 0;
return tnum;
if (! (s_err == LONGINT_OK
|| (s_err == LONGINT_OVERFLOW
&& flags & (tnum < 0 ? XTOINT_MIN_QUIET : XTOINT_MAX_QUIET))))
error (err_exit ? err_exit : EXIT_FAILURE, e, "%s: %s", err, quote (n_str));
errno = e;
return r;
}
/* Parse decimal string N_STR, and return the value.
@@ -84,5 +92,5 @@ __xdectoint_t
__xdectoint (char const *n_str, __xdectoint_t min, __xdectoint_t max,
char const *suffixes, char const *err, int err_exit)
{
return __xnumtoint (n_str, 10, min, max, suffixes, err, err_exit);
return __xnumtoint (n_str, 10, min, max, suffixes, err, err_exit, 0);
}

View File

@@ -1,6 +1,6 @@
/* Convert decimal strings with bounds checking and exit on error.
Copyright (C) 2014-2024 Free Software Foundation, Inc.
Copyright (C) 2014-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,13 +20,32 @@
# include <inttypes.h>
/* Flags for xnumtoimax and xnumtoumax. They can be ORed togethar. */
enum
{
/* If the number is less than MIN, do not diagnose the problem;
instead, return MIN and set errno to EOVERFLOW or ERANGE. */
XTOINT_MIN_QUIET = 1 << 0,
/* Likewise for the MAX argument. */
XTOINT_MAX_QUIET = 1 << 1,
/* The MIN argument is imposed by the caller, not by the type of
the result. This causes the function to use ERANGE rather
than EOVERFLOW behavior when issuing diagnostics or setting errno. */
XTOINT_MIN_RANGE = 1 << 2,
/* Likewise for the MAX argument. */
XTOINT_MAX_RANGE = 1 << 3
};
# define _DECLARE_XDECTOINT(name, type) \
type name (char const *n_str, type min, type max, \
char const *suffixes, char const *err, int err_exit) \
_GL_ATTRIBUTE_NONNULL ((1, 5));
# define _DECLARE_XNUMTOINT(name, type) \
type name (char const *n_str, int base, type min, type max, \
char const *suffixes, char const *err, int err_exit) \
char const *suffixes, char const *err, int err_exit, int flags) \
_GL_ATTRIBUTE_NONNULL ((1, 6));
_DECLARE_XDECTOINT (xdectoimax, intmax_t)

View File

@@ -2,5 +2,4 @@
#define __xnumtoint xnumtoumax
#define __xdectoint_t uintmax_t
#define __xstrtol xstrtoumax
#define __xdectoint_signed 0
#include "xdectoint.c"

View File

@@ -1,6 +1,6 @@
/* xfts.c -- a wrapper for fts_open
Copyright (C) 2003-2024 Free Software Foundation, Inc.
Copyright (C) 2003-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

81
gl/local.mk Normal file
View File

@@ -0,0 +1,81 @@
# Make coreutils programs. -*-Makefile-*-
# This is included by the top-level Makefile.am.
## Copyright (C) 2024-2025 Free Software Foundation, Inc.
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <https://www.gnu.org/licenses/>.
EXTRA_DIST += \
gl/lib/buffer-lcm.c \
gl/lib/buffer-lcm.h \
gl/lib/cl-strtod.c \
gl/lib/cl-strtod.h \
gl/lib/cl-strtold.c \
gl/lib/dtimespec-bound.c \
gl/lib/dtimespec-bound.h \
gl/lib/fadvise.c \
gl/lib/fadvise.h \
gl/lib/fd-reopen.c \
gl/lib/fd-reopen.h \
gl/lib/heap.c \
gl/lib/heap.h \
gl/lib/rand-isaac.c \
gl/lib/rand-isaac.h \
gl/lib/randint.c \
gl/lib/randint.h \
gl/lib/randperm.c \
gl/lib/randperm.h \
gl/lib/randread.c \
gl/lib/randread.h \
gl/lib/root-dev-ino.c \
gl/lib/root-dev-ino.h \
gl/lib/skipchars.c \
gl/lib/skipchars.h \
gl/lib/smack.h \
gl/lib/strintcmp.c \
gl/lib/strnumcmp-in.h \
gl/lib/strnumcmp.c \
gl/lib/strnumcmp.h \
gl/lib/targetdir.c \
gl/lib/targetdir.h \
gl/lib/xdectoimax.c \
gl/lib/xdectoint.c \
gl/lib/xdectoint.h \
gl/lib/xdectoumax.c \
gl/lib/xfts.c \
gl/lib/xfts.h \
gl/local.mk \
gl/modules/buffer-lcm \
gl/modules/cl-strtod \
gl/modules/cl-strtold \
gl/modules/dtimespec-bound \
gl/modules/fadvise \
gl/modules/fadvise-tests \
gl/modules/fd-reopen \
gl/modules/heap \
gl/modules/link-tests.diff \
gl/modules/randint \
gl/modules/randperm \
gl/modules/randread \
gl/modules/randread-tests \
gl/modules/rename-tests.diff \
gl/modules/root-dev-ino \
gl/modules/skipchars \
gl/modules/smack \
gl/modules/strnumcmp \
gl/modules/targetdir \
gl/modules/xdectoint \
gl/modules/xfts \
gl/tests/test-fadvise.c \
gl/tests/test-rand-isaac.c

View File

@@ -6,7 +6,7 @@ lib/buffer-lcm.c
lib/buffer-lcm.h
Depends-on:
stddef
stddef-h
configure.ac:

View File

@@ -0,0 +1,24 @@
Description:
Adjust a double to provide a timespec bound.
Files:
lib/dtimespec-bound.c
lib/dtimespec-bound.h
Depends-on:
float-h
signbit
configure.ac:
Makefile.am:
lib_SOURCES += dtimespec-bound.c
Include:
"dtimespec-bound.h"
License:
GPL
Maintainer:
all

View File

@@ -6,6 +6,7 @@ lib/heap.c
lib/heap.h
Depends-on:
idx
stdlib-safer
xalloc

View File

@@ -7,9 +7,9 @@ lib/randperm.h
Depends-on:
assert-h
count-leading-zeros
randint
stdint
stdc_bit_width
stdint-h
xalloc
hash

View File

@@ -9,6 +9,7 @@ lib/randread.h
Depends-on:
alignasof
bool
error
exitfail
inline
@@ -16,8 +17,7 @@ fopen-safer
getrandom
quote
minmax
stdbool
stdint
stdint-h
unlocked-io
xalloc

View File

@@ -8,8 +8,9 @@ lib/strnumcmp.h
lib/strnumcmp-in.h
Depends-on:
c-ctype
inline
stddef
stddef-h
configure.ac:

View File

@@ -7,8 +7,8 @@ lib/targetdir.h
Depends-on:
attribute
bool
fcntl-h
stdbool
configure.ac:

View File

@@ -8,10 +8,10 @@ lib/xdectoimax.c
lib/xdectoumax.c
Depends-on:
bool
error
errno
errno-h
quote
stdbool
verify
xstrtoimax
xstrtoumax

View File

@@ -6,7 +6,7 @@ lib/xfts.c
lib/xfts.h
Depends-on:
stddef
stddef-h
configure.ac:

View File

@@ -1,5 +1,5 @@
/* Test that fadvise works as advertised.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
Copyright (C) 2010-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Test the ISAAC or ISAAC64 pseudorandom number generator.
Copyright (C) 2010-2024 Free Software Foundation, Inc.
Copyright (C) 2010-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

2
gnulib

Submodule gnulib updated: 259829e78b...68ecc26f30

View File

@@ -1,7 +1,7 @@
include gnulib.mk
AM_CFLAGS = $(GNULIB_TEST_WARN_CFLAGS) $(WERROR_CFLAGS)
include gnulib.mk
# A few tests are inherently warning-evoking.
# In the typical case where we use -Werror, exempt the few offenders.

View File

@@ -1,6 +1,6 @@
# This file is sourced by init.sh, *before* its initialization.
# Copyright (C) 2010-2024 Free Software Foundation, Inc.
# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -178,6 +178,8 @@ ulimit_supported_()
v="$1"
shift
local ulimit_start_=$(date +%s) || skip_ 'ulimit: date error'
(
# Try to disable core dumps which may
# occur with memory constraints
@@ -185,6 +187,16 @@ ulimit_supported_()
ulimit -v $v && "$@"
) >/dev/null 2>&1
ret=$?
local ulimit_end_=$(date +%s) || skip_ 'ulimit: date error'
# This can happen on Solaris 11 at least where fork() can give EAGAIN
# and bash will retry for at least 16 seconds
test $(($ulimit_end_ - $ulimit_start_)) -ge 10 && skip_ 'ulimit too slow'
return $ret
}
# Determine the minimum required VM limit to run the given command.
@@ -200,11 +212,15 @@ get_min_ulimit_v_()
page_size=$(($page_size / 1024))
for v in $( seq 5000 5000 50000 ); do
if ulimit_supported_ $v "$@"; then
ulimit_supported_ $v "$@"; ret=$?
test $ret = 77 && break;
if test $ret = 0; then
local prev_v
prev_v=$v
for v in $( seq $(($prev_v-1000)) -1000 1000 ); do
ulimit_supported_ $v "$@" ||
ulimit_supported_ $v "$@"; ret=$?
test $ret = 77 && break 2;
test $ret = 0 ||
{
ret_v=$((prev_v + $page_size))
echo $ret_v
@@ -488,6 +504,10 @@ require_membership_in_two_groups_()
{
test $# = 0 || framework_failure_
# Skip overflow gids used in user namespaces
overflow_gid=$(cat /proc/sys/kernel/overflowgid 2>/dev/null)
: "${overflow_gid:=1}"
groups=
for group_ in 1 \
${COREUTILS_GROUPS-$( (id -G || /usr/xpg4/bin/id -G) 2>/dev/null)}
@@ -495,7 +515,7 @@ require_membership_in_two_groups_()
# Skip group numbers equal to 2**N - 1 for common N,
# as they are possibly reserved groups like 'nogroup'.
case $group_ in
1 | 32767 | 65535 | 2147483647 | 4294967295) ;;
$overflow_gid | 1 | 32767 | 65535 | 2147483647 | 4294967295) ;;
9223372036854775807 | 18446744073709551615) ;;
*) test -z "$groups" || groups="$groups "
groups="$groups$group_";;
@@ -570,7 +590,7 @@ seek_data_capable_()
# We saw FreeBSD 9.1 take 35s to return from SEEK_DATA for a 1TiB empty file.
# Note lseek() is uninterruptible on FreeBSD 9.1, but it does eventually
# return, and the timeout will ensure a failure return from the process.
timeout --version >/dev/null && TIMEOUT_='timeout 10'
timeout 1 true >/dev/null && TIMEOUT_='timeout 10'
$TIMEOUT_ $PYTHON_ "$abs_srcdir"/tests/seek-data-capable "$@"
}
@@ -660,7 +680,7 @@ mkfifo_or_skip_()
trap_sigpipe_or_skip_()
{
timeout --version >/dev/null ||
timeout 1 true >/dev/null ||
skip_ 'trapping SIGPIPE cannot be safely checked'
(trap '' PIPE && timeout 10 yes |:) 2>&1 | grep 'Broken pipe' >/dev/null ||

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise chdir-long's sample main program.
# Copyright (C) 2005-2024 Free Software Foundation, Inc.
# Copyright (C) 2005-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
#serial 27
# Check declarations for this package.
dnl Copyright (C) 1997-2024 Free Software Foundation, Inc.
dnl Copyright (C) 1997-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,

View File

@@ -1,5 +1,5 @@
#serial 2
dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
dnl Copyright (C) 2007-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

View File

@@ -1,8 +1,8 @@
#serial 115 -*- autoconf -*-
#serial 116 -*- autoconf -*-
dnl Misc type-related macros for coreutils.
# Copyright (C) 1998-2024 Free Software Foundation, Inc.
# Copyright (C) 1998-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -204,7 +204,6 @@ AC_DEFUN([gl_CHECK_ALL_TYPES],
AC_REQUIRE([gl_BIGENDIAN])
AC_REQUIRE([AC_C_VOLATILE])
AC_REQUIRE([AC_C_INLINE])
AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
AC_REQUIRE([gl_CHECK_ALL_HEADERS])
AC_CHECK_MEMBERS(
@@ -215,18 +214,25 @@ AC_DEFUN([gl_CHECK_ALL_TYPES],
AC_REQUIRE([AC_STRUCT_ST_BLOCKS])
AC_REQUIRE([AC_TYPE_GETGROUPS])
dnl FIXME is this section still needed?
dnl These types are universally available now.
AC_REQUIRE([AC_TYPE_MBSTATE_T])
AC_REQUIRE([AC_TYPE_MODE_T])
AC_REQUIRE([AC_TYPE_OFF_T])
AC_REQUIRE([AC_TYPE_PID_T])
AC_REQUIRE([AC_TYPE_SIZE_T])
AC_REQUIRE([AC_TYPE_UID_T])
AC_CHECK_TYPE([ino_t], [unsigned long int])
AC_CHECK_TYPE([ino_t], [],
[AC_DEFINE([ino_t], [unsigned long int],
[Type of file serial numbers, also known as inode numbers.])])
dnl This relies on the fact that Autoconf's implementation of
dnl AC_CHECK_TYPE checks includes unistd.h.
AC_CHECK_TYPE([major_t], [unsigned int])
AC_CHECK_TYPE([minor_t], [unsigned int])
AC_CHECK_TYPE([major_t], [],
[AC_DEFINE([major_t], [unsigned int], [Type of major device numbers.])])
AC_CHECK_TYPE([minor_t], [],
[AC_DEFINE([minor_t], [unsigned int], [Type of minor device numbers.])])
AC_REQUIRE([AC_HEADER_MAJOR])
])

View File

@@ -7,7 +7,7 @@ m4_pattern_forbid([^gl_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
# directory of the coreutils package.
# Copyright (C) 1998-2024 Free Software Foundation, Inc.
# Copyright (C) 1998-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
# stat-prog.m4 serial 7
# Record the prerequisites of src/stat.c from the coreutils package.
# Copyright (C) 2002-2024 Free Software Foundation, Inc.
# Copyright (C) 2002-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 2018-2024 Free Software Foundation, Inc.
'\" Copyright (C) 2018-2025 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2025 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2025 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2025 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2025 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2025 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
@@ -7,11 +7,10 @@
env \- run a program in a modified environment
[DESCRIPTION]
.\" Add any additional description here
[OPTIONS]
.SS "\-S/\-\-split\-string usage in scripts"
[SCRIPT OPTION HANDLING]
The
.B \-S
option allows specifying multiple parameters in a script.
option allows specifying multiple arguments in a script.
Running a script named
.B 1.pl
containing the following first line:
@@ -24,7 +23,7 @@ containing the following first line:
.RE
.PP
Will execute
.B "perl \-w \-T 1.pl".
.B "perl \-w \-T 1.pl"
.PP
Without the
.B '\-S'
@@ -38,20 +37,6 @@ parameter the script will likely fail with:
.PP
See the full documentation for more details.
.PP
.SS "\-\-default-signal[=SIG]" usage
This option allows setting a signal handler to its default
action, which is not possible using the traditional shell
trap command. The following example ensures that seq
will be terminated by SIGPIPE no matter how this signal
is being handled in the process invoking the command.
.PP
.RS
.nf
sh \-c 'env \-\-default-signal=PIPE seq inf | head \-n1'
.fi
.RE
.PP
[NOTES]
POSIX's exec(3p) pages says:

View File

@@ -2,8 +2,8 @@
# Generate a short man page from --help and --version output.
# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009,
# 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2020, 2021 Free Software
# Foundation, Inc.
# 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2020, 2021, 2022, 2025
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@ use Text::Tabs qw(expand);
use POSIX qw(strftime setlocale LC_ALL);
my $this_program = 'help2man';
my $this_version = '1.48.5';
my $this_version = '1.50.1';
sub _ { $_[0] }
sub configure_locale
@@ -49,13 +49,14 @@ sub program_basename;
sub get_option_value;
sub convert_option;
sub fix_italic_spacing;
sub set_indent;
my $version_info = enc_user sprintf _(<<'EOT'), $this_program, $this_version;
GNU %s %s
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009,
2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2020, 2021 Free Software
Foundation, Inc.
2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2020, 2021, 2022, 2025 Free
Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@@ -78,6 +79,7 @@ Usage: %s [OPTION]... EXECUTABLE
-p, --info-page=TEXT name of Texinfo manual
-N, --no-info suppress pointer to Texinfo manual
-l, --libtool exclude the `lt-' from the program name
--loose-indent relax matching of indented continuation lines
-b, --bold-refs apply bold style to references
--help print this help, then exit
--version print version number, then exit
@@ -87,8 +89,8 @@ stdout although alternatives may be specified using:
-h, --help-option=STRING help option string
-v, --version-option=STRING version option string
--version-string=STRING version string
--no-discard-stderr include stderr when parsing option output
--version-string=STRING version string
--no-discard-stderr include stderr when parsing option output
Report bugs to <bug-help2man@gnu.org>.
EOT
@@ -98,6 +100,7 @@ my $manual = '';
my $source = '';
my $help_option = '--help';
my $version_option = '--version';
my $loose_indent = 0;
my $discard_stderr = 1;
my ($opt_name, @opt_include, $opt_output, $opt_info, $opt_no_info, $opt_libtool,
$opt_bold_refs, $version_text);
@@ -114,6 +117,7 @@ my %opt_def = (
'p|info-page=s' => \$opt_info,
'N|no-info' => \$opt_no_info,
'l|libtool' => \$opt_libtool,
'loose-indent!' => \$loose_indent,
'b|bold-refs' => \$opt_bold_refs,
'help' => sub { print $help_info; exit },
'version' => sub { print $version_info; exit },
@@ -180,13 +184,13 @@ while (@opt_include)
$key =~ s/^\s+//;
$key =~ s/\s+$//;
$hash = \%include;
# Handle explicit [<section], [=section] and [>section]
# Handle explicit [<section], [=section] and [>section].
if ($key =~ s/^([<>=])\s*//)
{
if ($1 eq '>') { $hash = \%append; }
elsif ($1 eq '=') { $hash = \%replace; }
}
# NAME/SYNOPSIS replace by default
# NAME/SYNOPSIS replace by default.
elsif ($key eq _('NAME') or $key eq _('SYNOPSIS'))
{
$hash = \%replace;
@@ -222,7 +226,7 @@ while (@opt_include)
# revision info.
unless ($key)
{
# handle options
# Handle options.
if (/^-/)
{
local @ARGV = shellwords $_;
@@ -267,7 +271,7 @@ if (exists $ENV{SOURCE_DATE_EPOCH} and $ENV{SOURCE_DATE_EPOCH} =~ /^(\d+)$/)
# the English version expands to the month as a word and the full year. It
# is used on the footer of the generated manual pages. If in doubt, you may
# just use %x as the value (which should be the full locale-specific date).
my $date = enc strftime _("%B %Y"), localtime $epoch_secs;
my $date = strftime _("%B %Y"), localtime $epoch_secs;
my $program = program_basename $ARGV[0];
my $package = $program;
my $version;
@@ -342,15 +346,15 @@ for ($replace{_('NAME')} || ($include{_('NAME')} ||= ''))
# Man pages traditionally have the page title in caps.
my $PROGRAM = uc $program;
# Set default page head/footers
# Set default page head/footers.
$source ||= "$package $version";
unless ($manual)
{
for ($section)
{
if (/^(1[Mm]|8)/) { $manual = enc _('System Administration Utilities') }
elsif (/^6/) { $manual = enc _('Games') }
else { $manual = enc _('User Commands') }
if (/^(1[Mm]|8)/) { $manual = _('System Administration Utilities') }
elsif (/^6/) { $manual = _('Games') }
else { $manual = _('User Commands') }
}
}
@@ -442,6 +446,7 @@ s/([^\n])\n($PAT_BUGS|$PAT_AUTHOR|$PAT_SEE_ALSO) /$1\n\n$2 /og;
# character.
s/^Copyright +(?:\xa9|\([Cc]\))/Copyright \\(co/mg;
my $require_mono = 0;
while (length)
{
# Convert some standard paragraph names.
@@ -500,15 +505,16 @@ while (length)
}
# Examples, indicated by an indented leading $, % or > are
# rendered in a constant width font.
# rendered in a monospace font when using groff in troff mode.
if (/^( +)([\$\%>] )\S/)
{
my $indent = $1;
my $spaces = $1;
my $prefix = $2;
my $break = '.IP';
while (s/^$indent\Q$prefix\E(\S.*)\n*//)
while (s/^$spaces\Q$prefix\E(\S.*)\n*//)
{
$include{$sect} .= "$break\n\\f(CW$prefix$1\\fR\n";
$include{$sect} .= "$break\n\\*[mono]$prefix$1\\*[/mono]\n";
$require_mono++;
$break = '.br';
}
@@ -531,12 +537,12 @@ while (length)
if (s/^( {1,10}([+-]\S.*?))(?:( +(?!-))|\n( {20,}))(\S.*)\n//)
{
$matched .= $& if %append_match;
$indent = length ($4 || "$1$3");
$indent = set_indent length ($4 || "$1$3");
$content = ".TP\n\x84$2\n\x84$5\n";
unless ($4)
{
# Indent may be different on second line.
$indent = length $& if /^ {20,}/;
$indent = set_indent length $& if /^ {20,}/;
}
}
@@ -545,14 +551,14 @@ while (length)
{
$matched .= $& if %append_match;
$content = ".HP\n\x84$1\n";
$indent = 80; # not continued
$indent = 80; # not continued
}
# Indented paragraph with tag.
elsif (s/^( +(\S.*?) +)(\S.*)\n//)
{
$matched .= $& if %append_match;
$indent = length $1;
$indent = set_indent length $1;
$content = ".TP\n\x84$2\n\x84$3\n";
}
@@ -560,7 +566,7 @@ while (length)
elsif (s/^( +)(\S.*)\n//)
{
$matched .= $& if %append_match;
$indent = length $1;
$indent = set_indent length $1;
$content = ".IP\n\x84$2\n";
}
@@ -681,7 +687,8 @@ EOT
# Append additional text.
while (my ($sect, $text) = each %append)
{
$include{$sect} .= $append{$sect};
$require_mono++ if $text =~ /\\\*\[mono\]/;
$include{$sect} .= $text;
}
# Replace sections.
@@ -691,11 +698,20 @@ while (my ($sect, $text) = each %replace)
}
# Output header.
print <<EOT;
print enc <<EOT;
.\\" DO NOT MODIFY THIS FILE! It was generated by $this_program $this_version.
.TH $PROGRAM "$section" "$date" "$source" "$manual"
EOT
# If monospace was used emit macros for groff.
print enc <<'EOT' if $require_mono;
.\" Define monospaced roman font for groff in troff mode.
.if t .if \n(.g \{\
. ds mono \f(CR
. ds /mono \fP
.\}
EOT
# Section ordering.
my @pre = (_('NAME'), _('SYNOPSIS'), _('DESCRIPTION'), _('OPTIONS'),
_('EXAMPLES'));
@@ -730,8 +746,8 @@ for my $sect (@pre, (grep !$filter{$_}, @sections), @post)
s/\x82/\\e/g;
s/\x83/\\-/g;
# Convert some latin1 chars to troff equivalents
s/\xa0/\\ /g; # non-breaking space
# Convert some latin1 chars to troff equivalents.
s/\xa0/\\ /g; # non-breaking space
print enc $_;
}
@@ -800,3 +816,15 @@ sub fix_italic_spacing
s!\\fI(.*?)\\f([BRP])!\\fI\\,$1\\/\\f$2!g;
return $_;
}
# Return indent to use: either the value passed in, or $v,$v+4 if
# loose index matching is used. The resulting string is used in a
# regex as " {$indent}", so will match either the exact number of
# spaces passed in, or up to four more. See the --loose-indent
# option.
sub set_indent
{
my $i = $_[0];
$i .= ',' . ($_[0] + 4) if $loose_indent;
return $i;
}

View File

@@ -1,7 +1,7 @@
# Make coreutils man pages. -*-Makefile-*-
# This is included by the top-level Makefile.am.
# Copyright (C) 2002-2024 Free Software Foundation, Inc.
# Copyright (C) 2002-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@ if HAVE_PERL
if BOLD_MAN_REFS
help2man_OPTS=--bold-refs
endif
run_help2man = $(PERL) -- $(srcdir)/man/help2man $(help2man_OPTS)
run_help2man = $(PERL) -- $(srcdir)/man/help2man --loose-indent $(help2man_OPTS)
else
run_help2man = $(SHELL) $(srcdir)/man/dummy-man
endif
@@ -54,7 +54,7 @@ mandeps =
# Depend on this to get version number changes.
mandeps += .version
# This is required so that changes to e.g., emit_bug_reporting_address
# This is required so that changes to e.g., emit_ancillary_info
# provoke regeneration of all the manpages.
mandeps += $(top_srcdir)/src/system.h
@@ -194,7 +194,8 @@ endif
&& $(MKDIR_P) $$t \
&& (cd $$t && $(LN_S) '$(abs_top_builddir)/src/'$$prog$(EXEEXT) \
$$argv$(EXEEXT)) \
&& : $${SOURCE_DATE_EPOCH=`cat $(srcdir)/.timestamp 2>/dev/null || :`} \
&& : $${SOURCE_DATE_EPOCH=`date -r $(srcdir)/.tarball-version +%s \
2>/dev/null || :`} \
&& : $${TZ=UTC0} && export TZ \
&& export SOURCE_DATE_EPOCH && $(run_help2man) \
--source='$(PACKAGE_STRING)' \

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2025 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 2009-2024 Free Software Foundation, Inc.
'\" Copyright (C) 2009-2025 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2024 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2025 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.

View File

@@ -1,5 +1,5 @@
# List of files which contain translatable strings.
# Copyright (C) 1996-2024 Free Software Foundation, Inc.
# Copyright (C) 1996-2025 Free Software Foundation, Inc.
# These are nominally temporary...
lib/argmatch.c
@@ -24,12 +24,12 @@ lib/siglist.h
lib/strsignal.c
lib/unicodeio.c
lib/userspec.c
lib/verror.c
lib/version-etc.c
lib/xalloc-die.c
lib/xbinary-io.c
lib/xmemcoll.c
lib/xprintf.c
lib/xsetenv.c
lib/xstrtol-error.c
# Package source files
@@ -110,6 +110,7 @@ src/rmdir.c
src/runcon.c
src/seq.c
src/set-fields.c
src/show-date.c
src/shred.c
src/shuf.c
src/sleep.c

View File

@@ -164,7 +164,7 @@ By adding the directory to your $PATH, older versions can be easily used:
========================================================================
Copyright (C) 2019-2024 Free Software Foundation, Inc.
Copyright (C) 2019-2025 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (C) 2019-2024 Free Software Foundation, Inc.
# Copyright (C) 2019-2025 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright

View File

@@ -136,6 +136,12 @@ sub check_msg($$)
$buf =~ m!https://lists\.gnu\.org/archive/html/!s
and return "use '/r/' in place of '/archive/html/' in lists.gnu.org URLs";
$buf =~ m!https?://(?:.*\.)?sourceware\.org/bugzilla/show_bug\.cgi\?id=(\d+)!s
and return "use shorter https://sourceware.org/PR$1";
$buf =~ m!https?://gcc\.gnu\.org/bugzilla/show_bug\.cgi\?id=(\d+)!s
and return "use shorter https://gcc.gnu.org/PR$1";
return '';
}

1
src/.gitignore vendored
View File

@@ -87,6 +87,7 @@ shred
shuf
sleep
sort
speedlist.h
split
stat
stdbuf

View File

@@ -1,5 +1,5 @@
/* basename -- strip directory and suffix from file names
Copyright (C) 1990-2024 Free Software Foundation, Inc.
Copyright (C) 1990-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/* Base64, base32, and similar encoding/decoding strings or files.
Copyright (C) 2004-2024 Free Software Foundation, Inc.
Copyright (C) 2004-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>
#include <gmp.h>
#include "system.h"
#include "assure.h"
@@ -61,6 +62,7 @@ enum
{
BASE64_OPTION = CHAR_MAX + 1,
BASE64URL_OPTION,
BASE58_OPTION,
BASE32_OPTION,
BASE32HEX_OPTION,
BASE16_OPTION,
@@ -78,6 +80,7 @@ static struct option const long_options[] =
#if BASE_TYPE == 42
{"base64", no_argument, 0, BASE64_OPTION},
{"base64url", no_argument, 0, BASE64URL_OPTION},
{"base58", no_argument, 0, BASE58_OPTION},
{"base32", no_argument, 0, BASE32_OPTION},
{"base32hex", no_argument, 0, BASE32HEX_OPTION},
{"base16", no_argument, 0, BASE16_OPTION},
@@ -119,6 +122,9 @@ Base%d encode or decode FILE, or standard input, to standard output.\n\
"), stdout);
fputs (_("\
--base64url file- and url-safe base64 (RFC4648 section 5)\n\
"), stdout);
fputs (_("\
--base58 visually unambiguous base58 encoding\n\
"), stdout);
fputs (_("\
--base32 same as 'base32' program (RFC4648 section 6)\n\
@@ -193,7 +199,7 @@ base64_required_padding (int len)
#if BASE_TYPE == 42
static int
no_required_padding (int len)
no_required_padding (MAYBE_UNUSED int len)
{
return 0;
}
@@ -263,6 +269,13 @@ struct z85_decode_context
unsigned char octets[5];
};
struct base58_context
{
unsigned char *buf;
idx_t size;
idx_t capacity;
};
struct base2_decode_context
{
unsigned char octet;
@@ -277,6 +290,7 @@ struct base_decode_context
struct base16_decode_context base16;
struct base2_decode_context base2;
struct z85_decode_context z85;
struct base58_context base58;
} ctx;
char *inbuf;
idx_t bufsize;
@@ -285,6 +299,23 @@ static void (*base_decode_ctx_init) (struct base_decode_context *ctx);
static bool (*base_decode_ctx) (struct base_decode_context *ctx,
char const *restrict in, idx_t inlen,
char *restrict out, idx_t *outlen);
static bool (*base_decode_ctx_finalize) (struct base_decode_context *ctx,
char *restrict *out, idx_t *outlen);
struct base_encode_context
{
union {
struct base58_context base58;
} ctx;
};
static void (*base_encode_ctx_init) (struct base_encode_context *ctx);
static bool (*base_encode_ctx) (struct base_encode_context *ctx,
char const *restrict in, idx_t inlen,
char *restrict out, idx_t *outlen);
static bool (*base_encode_ctx_finalize) (struct base_encode_context *ctx,
char *restrict *out, idx_t *outlen);
#endif
@@ -325,10 +356,8 @@ static void
prepare_inbuf (struct base_decode_context *ctx, idx_t inlen)
{
if (ctx->bufsize < inlen)
{
ctx->bufsize = inlen * 2;
ctx->inbuf = xnrealloc (ctx->inbuf, ctx->bufsize, sizeof (char));
}
ctx->inbuf = xpalloc (ctx->inbuf, &ctx->bufsize,
inlen - ctx->bufsize, -1, sizeof *ctx->inbuf);
}
@@ -628,7 +657,7 @@ static void
base16_encode (char const *restrict in, idx_t inlen,
char *restrict out, idx_t outlen)
{
static const char base16[16] = "0123456789ABCDEF";
static const char base16[16] ATTRIBUTE_NONSTRING = "0123456789ABCDEF";
while (inlen && outlen)
{
@@ -713,7 +742,7 @@ isuz85 (unsigned char ch)
return c_isalnum (ch) || strchr (".-:+=^!/*?&<>()[]{}@%$#", ch) != nullptr;
}
static char const z85_encoding[85] =
static char const z85_encoding[85] ATTRIBUTE_NONSTRING =
"0123456789"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -1038,6 +1067,262 @@ base2msbf_decode_ctx (struct base_decode_context *ctx,
return true;
}
/* Map from GMP (up to base 62):
"0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuv";
to base 58:
"123456789A BCDEFGHJKLMNPQRSTUVWXYZabc defghijkmnopqrstuvwxyz"; */
static signed char const gmp_to_base58[256] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
'1','2','3','4','5','6','7','8','9','A',-1, -1, -1, -1, -1, -1,
-1, 'B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R',
'S','T','U','V','W','X','Y','Z','a','b','c',-1, -1, -1, -1, -1,
-1, 'd','e','f','g','h','i','j','k','m','n','o','p','q','r','s',
't','u','v','w','x','y','z',-1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
static signed char const base58_to_gmp[256] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, '0','1','2','3','4','5','6','7','8',-1, -1, -1, -1, -1, -1,
-1, '9','A','B','C','D','E','F','G', -1,'H','I','J','K','L',-1,
'M','N','O','P','Q','R','S','T','U','V','W',-1, -1, -1, -1, -1,
-1, 'X','Y','Z','a','b','c','d','e','f','g','h',-1, 'i','j','k',
'l','m','n','o','p','q','r','s','t','u','v',-1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
static bool
isubase58 (unsigned char ch)
{
return ch < sizeof base58_to_gmp && 0 <= base58_to_gmp[ch];
}
static int
base58_length (int len)
{
/* Base58 output length is approximately log(256)/log(58),
so ensure we've enough place for that + NUL. */
return (len * 138) / 100 + 1;
}
static void
base58_encode_ctx_init (struct base_encode_context *ctx)
{
ctx->ctx.base58.buf = nullptr;
ctx->ctx.base58.size = 0;
ctx->ctx.base58.capacity = 0;
}
static bool
base58_encode_ctx (struct base_encode_context *ctx,
char const *restrict in, idx_t inlen,
MAYBE_UNUSED char *restrict out, idx_t *outlen)
{
*outlen = 0; /* Only accumulate input in this function. */
if (inlen == 0)
return true;
idx_t free_space = ctx->ctx.base58.capacity - ctx->ctx.base58.size;
if (free_space < inlen)
{
ctx->ctx.base58.buf = xpalloc (ctx->ctx.base58.buf,
&ctx->ctx.base58.capacity,
inlen - free_space,
-1, sizeof *ctx->ctx.base58.buf);
}
memcpy (ctx->ctx.base58.buf + ctx->ctx.base58.size, in, inlen);
ctx->ctx.base58.size += inlen;
return true;
}
static void
base58_encode (char const* data, size_t data_len,
char *out, idx_t *outlen)
{
affirm (base_length (data_len) <= *outlen);
size_t zeros = 0;
while (zeros < data_len && data[zeros] == 0)
zeros++;
memset (out, '1', zeros);
char *p = out + zeros;
/* Use GMP to convert from base 256 to base 58. */
mpz_t num;
mpz_init (num);
if (data_len - zeros)
{
mpz_import (num, data_len - zeros, 1, 1, 0, 0, data + zeros);
for (p = mpz_get_str (p, 58, num); *p; p++)
*p = gmp_to_base58[to_uchar (*p)];
}
mpz_clear (num);
*outlen = p - out;
}
static bool
base58_encode_ctx_finalize (struct base_encode_context *ctx,
char *restrict *out, idx_t *outlen)
{
/* Ensure output buffer is large enough. */
idx_t max_outlen = base_length (ctx->ctx.base58.size);
if (max_outlen > *outlen)
{
*out = xrealloc (*out, max_outlen);
*outlen = max_outlen;
}
base58_encode ((char *)ctx->ctx.base58.buf, ctx->ctx.base58.size,
*out, outlen);
free (ctx->ctx.base58.buf);
ctx->ctx.base58.buf = nullptr;
return true;
}
static void
base58_decode_ctx_init (struct base_decode_context *ctx)
{
ctx->ctx.base58.size = 0;
ctx->ctx.base58.capacity = 0;
ctx->ctx.base58.buf = nullptr;
ctx->i = 0;
}
static bool
base58_decode_ctx (struct base_decode_context *ctx,
char const *restrict in, idx_t inlen,
MAYBE_UNUSED char *restrict out, idx_t *outlen)
{
bool ignore_lines = true; /* for now, always ignore them */
*outlen = 0; /* Only accumulate input in this function. */
if (inlen == 0)
return true;
idx_t free_space = ctx->ctx.base58.capacity - ctx->ctx.base58.size;
free_space -= 1; /* Ensure we leave space for NUL (for mpz_set_str). */
if (free_space < inlen)
{
ctx->ctx.base58.buf = xpalloc (ctx->ctx.base58.buf,
&ctx->ctx.base58.capacity,
inlen - free_space,
-1, sizeof *ctx->ctx.base58.buf);
}
/* Accumulate all valid input characters in our buffer.
Note we don't rely on mpz_set_str() for validation
as that allows (skips) all whitespace. */
for (idx_t i = 0; i < inlen; i++)
{
unsigned char c = in[i];
if (ignore_lines && c == '\n')
continue;
if (!isubase58 (c))
return false;
ctx->ctx.base58.buf[ctx->ctx.base58.size++] = base58_to_gmp[to_uchar (c)];
}
return true;
}
static bool
base58_decode (char const *data, size_t data_len,
char *restrict out, idx_t *outlen)
{
affirm (data_len <= *outlen);
size_t ones = 0;
while (ones < data_len && data[ones] == base58_to_gmp['1'])
ones++;
memset (out, 0, ones);
/* Use GMP to convert from base 58 to base 256. */
mpz_t num;
mpz_init (num);
if ((data_len - ones) && mpz_set_str (num, data + ones, 58) != 0)
{
mpz_clear (num);
*outlen = 0;
return false;
}
size_t exported_size = 0;
if (data_len - ones)
{
size_t binary_size = (mpz_sizeinbase (num, 2) + 7) / 8;
affirm (*outlen - ones >= binary_size);
mpz_export (out + ones, &exported_size, 1, 1, 0, 0, num);
}
mpz_clear (num);
*outlen = ones + exported_size;
return true;
}
static bool
base58_decode_ctx_finalize (struct base_decode_context *ctx,
char *restrict *out, idx_t *outlen)
{
/* Ensure output buffer is large enough.
Worst case is input is all '1's. */
idx_t max_outlen = ctx->ctx.base58.size;
if (max_outlen > *outlen)
{
*out = xrealloc (*out, max_outlen);
*outlen = max_outlen;
}
/* Ensure input buffer is NUL terminated (for mpz_get_str). */
if (ctx->ctx.base58.size)
ctx->ctx.base58.buf[ctx->ctx.base58.size] = '\0';
bool ret = base58_decode ((char *)ctx->ctx.base58.buf, ctx->ctx.base58.size,
*out, outlen);
free (ctx->ctx.base58.buf);
ctx->ctx.base58.buf = nullptr;
return ret;
}
#endif /* BASE_TYPE == 42, i.e., "basenc"*/
@@ -1097,6 +1382,14 @@ do_encode (FILE *in, char const *infile, FILE *out, idx_t wrap_column)
inbuf = xmalloc (ENC_BLOCKSIZE);
outbuf = xmalloc (BASE_LENGTH (ENC_BLOCKSIZE));
#if BASE_TYPE == 42
/* Initialize encoding context if needed (for base58) */
struct base_encode_context encode_ctx;
bool use_ctx = (base_encode_ctx_init != nullptr);
if (use_ctx)
base_encode_ctx_init (&encode_ctx);
#endif
do
{
idx_t n;
@@ -1111,16 +1404,38 @@ do_encode (FILE *in, char const *infile, FILE *out, idx_t wrap_column)
if (sum > 0)
{
/* Process input one block at a time. Note that ENC_BLOCKSIZE
is sized so that no pad chars will appear in output. */
base_encode (inbuf, sum, outbuf, BASE_LENGTH (sum));
#if BASE_TYPE == 42
if (use_ctx)
{
idx_t outlen = 0;
base_encode_ctx (&encode_ctx, inbuf, sum, outbuf, &outlen);
wrap_write (outbuf, BASE_LENGTH (sum), wrap_column,
&current_column, out);
wrap_write (outbuf, outlen, wrap_column, &current_column, out);
}
else
#endif
{
/* Process input one block at a time. Note that ENC_BLOCKSIZE
is sized so that no pad chars will appear in output. */
base_encode (inbuf, sum, outbuf, BASE_LENGTH (sum));
wrap_write (outbuf, BASE_LENGTH (sum), wrap_column,
&current_column, out);
}
}
}
while (!feof (in) && !ferror (in) && sum == ENC_BLOCKSIZE);
#if BASE_TYPE == 42
if (use_ctx && base_encode_ctx_finalize)
{
idx_t outlen = BASE_LENGTH (ENC_BLOCKSIZE);
base_encode_ctx_finalize (&encode_ctx, &outbuf, &outlen);
wrap_write (outbuf, outlen, wrap_column, &current_column, out);
}
#endif
/* When wrapping, terminate last line. */
if (wrap_column && current_column > 0 && fputc ('\n', out) == EOF)
write_error ();
@@ -1131,6 +1446,22 @@ do_encode (FILE *in, char const *infile, FILE *out, idx_t wrap_column)
finish_and_exit (in, infile);
}
/* Returns TRUE if BUF of length LEN
ends with a '=' character.
Trailing '\n' characters are ignored. */
ATTRIBUTE_PURE
static bool
has_padding (char const *buf, size_t len)
{
while (len--)
{
if (buf[len] == '\n')
continue;
return buf[len] == '=';
}
return false;
}
static _Noreturn void
do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
{
@@ -1138,7 +1469,7 @@ do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
idx_t sum;
struct base_decode_context ctx;
char padbuf[8] = "========";
char padbuf[8] ATTRIBUTE_NONSTRING = "========";
inbuf = xmalloc (BASE_LENGTH (DEC_BLOCKSIZE));
outbuf = xmalloc (DEC_BLOCKSIZE);
@@ -1161,7 +1492,8 @@ do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
{
for (idx_t i = 0; n > 0 && i < n;)
{
if (isubase (inbuf[sum + i]) || inbuf[sum + i] == '=')
if (isubase (inbuf[sum + i])
|| (REQUIRED_PADDING (1) && inbuf[sum + i] == '='))
i++;
else
memmove (inbuf + sum + i, inbuf + sum + i + 1, --n - i);
@@ -1188,7 +1520,7 @@ do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
/* auto pad input (at eof). */
idx_t auto_padding = REQUIRED_PADDING (ctx.i);
if (auto_padding && (sum == 0 || inbuf[sum - 1] != '='))
if (auto_padding && ! has_padding (inbuf, sum))
{
affirm (auto_padding <= sizeof (padbuf));
IF_LINT (free (inbuf));
@@ -1210,6 +1542,20 @@ do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
}
while (!feof (in));
#if BASE_TYPE == 42
if (base_decode_ctx_finalize)
{
idx_t outlen = DEC_BLOCKSIZE;
bool ok = base_decode_ctx_finalize (&ctx, &outbuf, &outlen);
if (fwrite (outbuf, 1, outlen, out) < outlen)
write_error ();
if (!ok)
error (EXIT_FAILURE, 0, _("invalid input"));
}
#endif
finish_and_exit (in, infile);
}
@@ -1270,6 +1616,7 @@ main (int argc, char **argv)
case BASE2MSBF_OPTION:
case BASE2LSBF_OPTION:
case Z85_OPTION:
case BASE58_OPTION:
base_type = opt;
break;
#endif
@@ -1358,6 +1705,18 @@ main (int argc, char **argv)
base_decode_ctx = z85_decode_ctx;
break;
case BASE58_OPTION:
base_length = base58_length;
required_padding = no_required_padding;
isubase = isubase58;
base_encode_ctx_init = base58_encode_ctx_init;
base_encode_ctx = base58_encode_ctx;
base_encode_ctx_finalize = base58_encode_ctx_finalize;
base_decode_ctx_init = base58_decode_ctx_init;
base_decode_ctx = base58_decode_ctx;
base_decode_ctx_finalize = base58_decode_ctx_finalize;
break;
default:
error (0, 0, _("missing encoding type"));
usage (EXIT_FAILURE);

View File

@@ -15,7 +15,8 @@
#ifndef BLAKE2_IMPL_H
#define BLAKE2_IMPL_H
#ifndef WORDS_BIGENDIAN
#include <endian.h>
#if BYTE_ORDER == LITTLE_ENDIAN
# define NATIVE_LITTLE_ENDIAN 1
#endif

View File

@@ -1,5 +1,5 @@
/* cat -- concatenate files and print on the standard output.
Copyright (C) 1988-2024 Free Software Foundation, Inc.
Copyright (C) 1988-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -37,7 +37,6 @@
#include "ioblksize.h"
#include "fadvise.h"
#include "full-write.h"
#include "safe-read.h"
#include "xbinary-io.h"
/* The official name of this program (e.g., no 'g' prefix). */
@@ -161,8 +160,8 @@ simple_cat (char *buf, idx_t bufsize)
{
/* Read a block of input. */
size_t n_read = safe_read (input_desc, buf, bufsize);
if (n_read == SAFE_READ_ERROR)
ssize_t n_read = read (input_desc, buf, bufsize);
if (n_read < 0)
{
error (0, errno, "%s", quotef (infile));
return false;
@@ -310,8 +309,8 @@ cat (char *inbuf, idx_t insize, char *outbuf, idx_t outsize,
/* Read more input into INBUF. */
size_t n_read = safe_read (input_desc, inbuf, insize);
if (n_read == SAFE_READ_ERROR)
ssize_t n_read = read (input_desc, inbuf, insize);
if (n_read < 0)
{
error (0, errno, "%s", quotef (infile));
write_pending (outbuf, &bpout);
@@ -645,9 +644,19 @@ main (int argc, char **argv)
/* Optimal size of i/o operations of output. */
idx_t outsize = io_blksize (&stat_buf);
/* Device and I-node number of the output. */
dev_t out_dev = stat_buf.st_dev;
ino_t out_ino = stat_buf.st_ino;
/* Device, I-node number and lazily-acquired flags of the output. */
struct
{
dev_t st_dev;
ino_t st_ino;
} out_id;
int out_flags = -2;
bool have_out_dev = ! (S_TYPEISSHM (&stat_buf) || S_TYPEISTMO (&stat_buf));
if (have_out_dev)
{
out_id.st_dev = stat_buf.st_dev;
out_id.st_ino = stat_buf.st_ino;
}
/* True if the output is a regular file. */
bool out_isreg = S_ISREG (stat_buf.st_mode) != 0;
@@ -701,17 +710,30 @@ main (int argc, char **argv)
fdadvise (input_desc, 0, 0, FADVISE_SEQUENTIAL);
/* Don't copy a nonempty regular file to itself, as that would
merely exhaust the output device. It's better to catch this
error earlier rather than later. */
/* Don't copy a file to itself if that would merely exhaust the
output device. It's better to catch this error earlier
rather than later. */
if (out_isreg
&& stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino
&& lseek (input_desc, 0, SEEK_CUR) < stat_buf.st_size)
if (! (S_ISFIFO (stat_buf.st_mode) || S_ISSOCK (stat_buf.st_mode)
|| S_TYPEISSHM (&stat_buf) || S_TYPEISTMO (&stat_buf))
&& have_out_dev
&& SAME_INODE (stat_buf, out_id))
{
error (0, 0, _("%s: input file is output file"), quotef (infile));
ok = false;
goto contin;
off_t in_pos = lseek (input_desc, 0, SEEK_CUR);
if (0 <= in_pos)
{
if (out_flags < -1)
out_flags = fcntl (STDOUT_FILENO, F_GETFL);
int whence = (0 <= out_flags && out_flags & O_APPEND
? SEEK_END : SEEK_CUR);
if (in_pos < lseek (STDOUT_FILENO, 0, whence))
{
error (0, 0, _("%s: input file is output file"),
quotef (infile));
ok = false;
goto contin;
}
}
}
/* Pointer to the input buffer. */

View File

@@ -1,5 +1,5 @@
/* chcon -- change security context of files
Copyright (C) 2005-2024 Free Software Foundation, Inc.
Copyright (C) 2005-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/* chmod -- change permission modes of files
Copyright (C) 1989-2024 Free Software Foundation, Inc.
Copyright (C) 1989-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -170,7 +170,7 @@ describe_change (char const *file, struct change_status const *ch)
printf (_("%s could not be accessed\n"), quoted_file);
return;
default:
case CH_FAILED: case CH_NO_CHANGE_REQUESTED: case CH_SUCCEEDED:
break;
}
@@ -196,7 +196,7 @@ describe_change (char const *file, struct change_status const *ch)
fmt = _("mode of %s retained as %04lo (%s)\n");
printf (fmt, quoted_file, m, &perms[1]);
return;
default:
case CH_NO_STAT: case CH_NOT_APPLIED: default:
affirm (false);
}
printf (fmt, quoted_file, old_m, &old_perms[1], m, &perms[1]);

View File

@@ -1,5 +1,5 @@
/* chown-core.c -- core functions for changing ownership.
Copyright (C) 2000-2024 Free Software Foundation, Inc.
Copyright (C) 2000-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -197,6 +197,7 @@ describe_change (char const *file, enum Change_status changed,
: group ? _("group of %s retained as %s\n")
: _("ownership of %s retained\n"));
break;
case CH_NOT_APPLIED:
default:
affirm (false);
}

Some files were not shown because too many files have changed in this diff Show More