]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
13 days agood: omit some duplicate code
Paul Eggert [Sat, 28 Jun 2025 00:08:28 +0000 (17:08 -0700)] 
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.

13 days agood: replace lookup tables with simple arithmetic
Paul Eggert [Fri, 27 Jun 2025 23:08:06 +0000 (16:08 -0700)] 
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.

13 days agood: support uintmax_t too
Paul Eggert [Fri, 27 Jun 2025 15:45:53 +0000 (08:45 -0700)] 
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.

13 days agood: initialize type-size tables statically
Paul Eggert [Fri, 27 Jun 2025 06:51:37 +0000 (23:51 -0700)] 
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.

13 days agood: prefer intmax_t to uintmax_t
Paul Eggert [Thu, 26 Jun 2025 15:45:47 +0000 (08:45 -0700)] 
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.

13 days agood: fix '+N.' bug
Paul Eggert [Sun, 29 Jun 2025 00:29:22 +0000 (17:29 -0700)] 
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.

13 days agood: fix some unlikely integer overflows
Paul Eggert [Thu, 26 Jun 2025 06:22:37 +0000 (23:22 -0700)] 
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.

13 days agood: prefer idx_t to size_t
Paul Eggert [Wed, 25 Jun 2025 03:34:29 +0000 (20:34 -0700)] 
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.

13 days agood: don’t assume no holes in wide unsigned
Paul Eggert [Wed, 25 Jun 2025 03:01:04 +0000 (20:01 -0700)] 
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.

13 days agomaint: assume long long int
Paul Eggert [Wed, 25 Jun 2025 02:13:20 +0000 (19:13 -0700)] 
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.

13 days agood: fix another off-by-one issue with --strings
Paul Eggert [Sat, 28 Jun 2025 15:07:54 +0000 (08:07 -0700)] 
od: fix another off-by-one issue with --strings

* src/od.c (main): Fix off-by-one error in string_min limit.

13 days agood: fix theoretical size_t malloc overflow
Paul Eggert [Sat, 28 Jun 2025 15:15:42 +0000 (08:15 -0700)] 
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.

2 weeks agodoc: list signals added by POSIX.1-2024
Collin Funk [Sat, 28 Jun 2025 05:15:28 +0000 (22:15 -0700)] 
doc: list signals added by POSIX.1-2024

* doc/coreutils.texi (Signal specifications): Mention that POSIX.1-2024
added SIGWINCH.

2 weeks agodoc: mention that POSIX.1-2024 added dd iflag=fullblock
Collin Funk [Fri, 27 Jun 2025 01:48:51 +0000 (18:48 -0700)] 
doc: mention that POSIX.1-2024 added dd iflag=fullblock

* doc/coreutils.texi (dd invocation): Document that POSIX.1-2024 added
iflag=fullblock.

2 weeks agodoc: cksum: --check: improve supported formats description
Pádraig Brady [Fri, 27 Jun 2025 14:02:50 +0000 (15:02 +0100)] 
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

2 weeks agomaint: prefer UINTMAX_MAX to TYPE_MAXIMUM (uintmax_t)
Collin Funk [Wed, 25 Jun 2025 04:39:20 +0000 (21:39 -0700)] 
maint: prefer UINTMAX_MAX to TYPE_MAXIMUM (uintmax_t)

* src/df.c (get_dev): Use UINTMAX_MAX.
* src/shred.c (dopass): Likewise.

2 weeks agood: output standard diagnostics for invalid -w arguments
Pádraig Brady [Tue, 24 Jun 2025 14:47:48 +0000 (15:47 +0100)] 
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

2 weeks agood: fix various off-by-one issues with --strings with -N
Pádraig Brady [Tue, 24 Jun 2025 00:17:12 +0000 (01:17 +0100)] 
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

2 weeks agobuild: fix compilation error on OpenBSD and Solaris
Bruno Haible [Mon, 23 Jun 2025 20:59:47 +0000 (22:59 +0200)] 
build: fix compilation error on OpenBSD and Solaris

* src/speedgen: Use 'printf', not 'sed', to emit code with newlines.

2 weeks agomaint: make it clear when to add speeds to the speedgen list
H. Peter Anvin [Mon, 23 Jun 2025 18:20:48 +0000 (11:20 -0700)] 
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>
2 weeks agostty: support baud rate macro extraction on more compilers
H. Peter Anvin [Mon, 23 Jun 2025 18:20:47 +0000 (11:20 -0700)] 
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>
2 weeks agostdbuf: support AIX
Collin Funk [Mon, 23 Jun 2025 01:13:36 +0000 (18:13 -0700)] 
stdbuf: support AIX

* src/stdbuf.c (set_LD_PRELOAD): Use the AIX specific environment
variables LDR_PRELOAD or LDR_PRELOAD64.
* NEWS: Mention the bugfix.

2 weeks agostty: stricter floating point parsing
Pádraig Brady [Sun, 22 Jun 2025 15:40:04 +0000 (16:40 +0100)] 
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.

2 weeks agodoc: stty: adjust description of supported speeds
Pádraig Brady [Sun, 22 Jun 2025 14:01:21 +0000 (15:01 +0100)] 
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.

2 weeks agobuild: add src/termios.c to the tarball
Collin Funk [Sun, 22 Jun 2025 05:05:19 +0000 (22:05 -0700)] 
build: add src/termios.c to the tarball

* src/local.mk (EXTRA_DIST): Add src/termios.c.

2 weeks agomaint: use _GL_CMP instead of handwriting three-valued comparisons
Collin Funk [Sun, 22 Jun 2025 04:50:27 +0000 (21:50 -0700)] 
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.

3 weeks agodoc: NEWS: improve recent stty details
H. Peter Anvin [Sat, 21 Jun 2025 01:01:58 +0000 (18:01 -0700)] 
doc: NEWS: improve recent stty details

* src/NEWS: Fix grammar error,
and indicate baud rate probing is opportunistic.

3 weeks agotty: translate new error
Pádraig Brady [Sat, 21 Jun 2025 09:59:46 +0000 (10:59 +0100)] 
tty: translate new error

* src/tty.c (main): Translate and adjust new ttyname() error
diagnostic, to be clearer and avoid a syntax check failure.

3 weeks agotty: better fix for Bug#26371
Paul Eggert [Fri, 20 Jun 2025 18:53:21 +0000 (11:53 -0700)] 
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.

3 weeks agotests: stty: adjust tests for arbitary speeds
Pádraig Brady [Tue, 17 Jun 2025 22:32:05 +0000 (23:32 +0100)] 
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.

3 weeks agostty: arbitrary or non-a priori known speed_t support
H. Peter Anvin [Mon, 16 Jun 2025 21:58:01 +0000 (14:58 -0700)] 
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.

4 weeks agodate: port test to NetBSD 10
Paul Eggert [Tue, 10 Jun 2025 19:51:05 +0000 (12:51 -0700)] 
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.

4 weeks agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 9 Jun 2025 06:52:51 +0000 (23:52 -0700)] 
build: update gnulib submodule to latest

* tests/date/date-debug.sh: Update to match current behavior
of Gnulib's parse-datetime module.

4 weeks agodoc: cp --help: mention --reflink=auto is now the default
Pádraig Brady [Sat, 7 Jun 2025 13:27:59 +0000 (14:27 +0100)] 
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

5 weeks agodoc: make command synopsis more consistent
Pádraig Brady [Tue, 3 Jun 2025 21:58:38 +0000 (22:58 +0100)] 
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

6 weeks agocksum: port to Apple LLVM version 10.0.0
Paul Eggert [Thu, 29 May 2025 15:30:13 +0000 (08:30 -0700)] 
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.

6 weeks agotests: sort: expand multiple output testing
Pádraig Brady [Wed, 28 May 2025 19:48:31 +0000 (20:48 +0100)] 
tests: sort: expand multiple output testing

* tests/sort/sort.pl: Ensure duplicate
output strings are supported.

6 weeks agomaint: assume O_DIRECTORY
Paul Eggert [Wed, 28 May 2025 19:35:14 +0000 (12:35 -0700)] 
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.

6 weeks agobuild: update gnulib submodule to latest
Paul Eggert [Wed, 28 May 2025 19:35:14 +0000 (12:35 -0700)] 
build: update gnulib submodule to latest

6 weeks agomaint: avoid a sc_system_h_headers failure
Pádraig Brady [Sat, 24 May 2025 21:01:44 +0000 (22:01 +0100)] 
maint: avoid a sc_system_h_headers failure

* cfg.mk: Also exclude libstdbuf.c from this check.

6 weeks agostdbuf: don’t allocate more than SIZE_MAX / 2
Paul Eggert [Sat, 24 May 2025 20:01:31 +0000 (13:01 -0700)] 
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.

6 weeks agostdbuf: simplify apply_mode + getenv
Paul Eggert [Sat, 24 May 2025 19:55:13 +0000 (12:55 -0700)] 
stdbuf: simplify apply_mode + getenv

* src/libstdbuf.c (apply_mode): Take getenv arg, not result.
All callers changed.  This is simpler.

6 weeks agostdbuf: port better to Mac OS X 10.4.11
Paul Eggert [Sat, 24 May 2025 19:47:06 +0000 (12:47 -0700)] 
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.

7 weeks agotests: avoid hung tests on older macOS
Pádraig Brady [Wed, 21 May 2025 20:20:11 +0000 (21:20 +0100)] 
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

7 weeks agosort: fix buffer under-read (CWE-127)
Pádraig Brady [Tue, 20 May 2025 15:03:44 +0000 (16:03 +0100)] 
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

7 weeks agomaint: omit -Wmissing-variable-declarations from tests
Paul Eggert [Mon, 19 May 2025 06:34:28 +0000 (23:34 -0700)] 
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).

7 weeks agomaint: avoid sc_preprocessor_indentation failure
Pádraig Brady [Sun, 18 May 2025 09:37:35 +0000 (10:37 +0100)] 
maint: avoid sc_preprocessor_indentation failure

* src/factor.c: Tweak preprocessor indentation.

7 weeks agobuild: generate src/crctab.c when building from git
Collin Funk [Sun, 18 May 2025 04:43:31 +0000 (21:43 -0700)] 
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.

7 weeks agobuild: fix 'make distcheck'
Collin Funk [Sun, 18 May 2025 04:02:20 +0000 (21:02 -0700)] 
build: fix 'make distcheck'

* src/local.mk (EXTRA_DIST): Distribute src/make-prime-list.c
to satisfy the new make dependency.

7 weeks agofactor: fix bug with 128-bit uintmax_t
Paul Eggert [Sun, 18 May 2025 04:42:37 +0000 (21:42 -0700)] 
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.

7 weeks agofactor: refactor to allow non-uintmax_t ints
Paul Eggert [Sun, 18 May 2025 04:42:37 +0000 (21:42 -0700)] 
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".

8 weeks agobuild: support cross-compiling directly from git checkout
Collin Funk [Fri, 16 May 2025 05:02:26 +0000 (22:02 -0700)] 
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

8 weeks agomaint: --help now outputs bug reporting address
Paul Eggert [Wed, 14 May 2025 20:36:40 +0000 (13:36 -0700)] 
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.

8 weeks agomaint: avoid sc_gitignore_missing failure
Pádraig Brady [Mon, 12 May 2025 22:20:43 +0000 (23:20 +0100)] 
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

2 months agodoc: NEWS: fix introduced version of a bug
Pádraig Brady [Mon, 12 May 2025 10:52:17 +0000 (11:52 +0100)] 
doc: NEWS: fix introduced version of a bug

* NEWS: The NFSv4 trivial ACL ENOTSUP issue was introduced in 9.6.

2 months agomaint: avoid sc_GPL_version failure
Pádraig Brady [Mon, 12 May 2025 10:50:25 +0000 (11:50 +0100)] 
maint: avoid sc_GPL_version failure

* cfg.mk (VC_LIST_ALWAYS_EXCLUDE_REGEX): Exclude longlong.h also.

2 months agodoc: suggest GNULIB_REFDIR instead of GNULIB_SRCDIR
Collin Funk [Sun, 11 May 2025 17:07:22 +0000 (10:07 -0700)] 
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'.

2 months agofactor: check overflow with ckd_add etc
Paul Eggert [Mon, 12 May 2025 07:09:16 +0000 (00:09 -0700)] 
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.

2 months agomaint: pacify GCC when selinux is missing
Paul Eggert [Mon, 12 May 2025 02:26:38 +0000 (19:26 -0700)] 
maint: pacify GCC when selinux is missing

* src/selinux.h (restorecon, defaultcon): Use MAYBE_UNUSED.

2 months agofactor: be more cautious about C compiler versions
Paul Eggert [Mon, 12 May 2025 01:22:44 +0000 (18:22 -0700)] 
factor: be more cautious about C compiler versions

* src/factor.c (__GMP_GNUC_PREREQ): Define compatibly with GMP.

2 months agomaint: sync longlong.h from gmp
Paul Eggert [Mon, 12 May 2025 01:00:50 +0000 (18:00 -0700)] 
maint: sync longlong.h from gmp

* .x-update-copyright: Add src/longlong.h.
* src/longlong.h: Sync from gmp.

2 months agofactor: omit incorrect affirms in mulredc2
Paul Eggert [Mon, 12 May 2025 00:25:30 +0000 (17:25 -0700)] 
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.

2 months agobuild: update gnulib submodule to latest
Collin Funk [Sun, 11 May 2025 16:56:37 +0000 (09:56 -0700)] 
build: update gnulib submodule to latest

* bootstrap: Update using './bootstrap --bootstrap-sync'.

2 months agomaint: update NEWS from Gnulib update
Paul Eggert [Sat, 10 May 2025 05:35:34 +0000 (22:35 -0700)] 
maint: update NEWS from Gnulib update

2 months agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 10 May 2025 01:05:48 +0000 (18:05 -0700)] 
build: update gnulib submodule to latest

2 months agomaint: minor followon touchup of GCC warnings
Paul Eggert [Sat, 10 May 2025 04:01:14 +0000 (21:01 -0700)] 
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.

2 months agomaint: modernize GCC warning configuration
Paul Eggert [Fri, 9 May 2025 22:55:47 +0000 (15:55 -0700)] 
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.

2 months agomaint: use MAYBE_UNUSED more consistently
Paul Eggert [Fri, 9 May 2025 22:52:15 +0000 (15:52 -0700)] 
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.

2 months agomaint: fix Automake warning
Paul Eggert [Fri, 9 May 2025 22:49:23 +0000 (15:49 -0700)] 
maint: fix Automake warning

* Makefile.am (prologue): Remove macro, as \# is not portable here
and Automake complains.  Replace its only use with its definiens.

2 months agotests: avoid false failures in user namespaces
Pádraig Brady [Sat, 3 May 2025 08:59:16 +0000 (09:59 +0100)] 
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

2 months agobuild: update to latest gnulib
Pádraig Brady [Thu, 1 May 2025 13:05:59 +0000 (14:05 +0100)] 
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.

2 months agotests: add a test case for negative relative date
Pádraig Brady [Wed, 23 Apr 2025 11:47:54 +0000 (12:47 +0100)] 
tests: add a test case for negative relative date

* tests/date/date.pl: To exercise option processing.

2 months agotests: fix false failure with constrained setfacl
Pádraig Brady [Mon, 21 Apr 2025 10:48:33 +0000 (11:48 +0100)] 
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

2 months agomaint: map Jim's new email address
Pádraig Brady [Sat, 19 Apr 2025 12:46:23 +0000 (13:46 +0100)] 
maint: map Jim's new email address

.mailmap: Add meta.com as an alias.

2 months agols: omit a static var
Paul Eggert [Sat, 12 Apr 2025 19:59:41 +0000 (12:59 -0700)] 
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.

3 months agomaint: post-release administrivia
Pádraig Brady [Wed, 9 Apr 2025 11:14:12 +0000 (12:14 +0100)] 
maint: post-release administrivia

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

3 months agoversion 9.7 v9.7
Pádraig Brady [Wed, 9 Apr 2025 10:44:57 +0000 (11:44 +0100)] 
version 9.7

* NEWS: Record release date.

3 months agotests: adjust csplit VM limit for CheriBSD
Pádraig Brady [Tue, 8 Apr 2025 15:07:06 +0000 (16:07 +0100)] 
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.

3 months agols: support capabilities with device 0,0
Pádraig Brady [Tue, 8 Apr 2025 11:11:06 +0000 (12:11 +0100)] 
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.

3 months agols: fix crash of "ls -Z ." on OpenBSD's /dev/wd0a disk
Bruno Haible [Tue, 8 Apr 2025 10:14:29 +0000 (12:14 +0200)] 
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.

3 months agobuild: use _GL_ATTRIBUTE_NONSTRING attribute to avoid new warnings
Jim Meyering [Sun, 6 Apr 2025 14:55:04 +0000 (07:55 -0700)] 
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.

3 months agomaint: avoid syntax-check failures from recent commit
Pádraig Brady [Mon, 7 Apr 2025 17:42:12 +0000 (18:42 +0100)] 
maint: avoid syntax-check failures from recent commit

* gl/lib/dtimespec-bound.h: Indent, Spellcheck.
* gl/local.mk: Add new gl files.

3 months agodoc: mention workaround for combining hex floats with suffixes
Paul Eggert [Mon, 7 Apr 2025 17:40:29 +0000 (18:40 +0100)] 
doc: mention workaround for combining hex floats with suffixes

* doc/coreutils.texi (hexDuration): Mention the p style exponent trick.

3 months agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 7 Apr 2025 08:46:34 +0000 (01:46 -0700)] 
build: update gnulib submodule to latest

3 months agotimeout: don’t sleep less than requested
Paul Eggert [Mon, 7 Apr 2025 07:30:14 +0000 (00:30 -0700)] 
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.

3 months agomaint: silence a -Wunterminated-string-initialization warning
Jim Meyering [Sun, 6 Apr 2025 07:12:03 +0000 (08:12 +0100)] 
maint: silence a -Wunterminated-string-initialization warning

* src/basenc.c (base16_encode): Mark BASE16 as not NUL-terminated.

3 months agobuild: update gnulib submodule to latest
Pádraig Brady [Sat, 5 Apr 2025 22:24:32 +0000 (23:24 +0100)] 
build: update gnulib submodule to latest

3 months agotimeout: remove dependence on libm
Pádraig Brady [Sat, 5 Apr 2025 20:48:05 +0000 (21:48 +0100)] 
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.

3 months agodoc: mention the edge case of hex durations with 'd' suffix
Pádraig Brady [Sat, 5 Apr 2025 19:26:23 +0000 (20:26 +0100)] 
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".

3 months agomaint: adjustments to recent timeout change
Pádraig Brady [Sat, 5 Apr 2025 10:27:32 +0000 (11:27 +0100)] 
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.

3 months agotimeout: round timeouts up
Paul Eggert [Sat, 5 Apr 2025 07:58:22 +0000 (00:58 -0700)] 
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.

3 months agomaint: ensure that new "make syntax-check"-run sc_codespell passes
Collin Funk [Fri, 4 Apr 2025 19:35:15 +0000 (12:35 -0700)] 
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.

3 months agotimeout: ensure infinitesimal timeouts timeout quickly
Pádraig Brady [Fri, 4 Apr 2025 19:40:26 +0000 (20:40 +0100)] 
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

3 months agotests: fix false failure with multi-byte thousands separators
Pádraig Brady [Fri, 4 Apr 2025 10:53:10 +0000 (11:53 +0100)] 
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

3 months agols: suppress ENOENT errors when reading ACL info
Pádraig Brady [Sun, 30 Mar 2025 14:16:54 +0000 (15:16 +0100)] 
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.

3 months agols: print correct xattr error on all platforms
Pádraig Brady [Fri, 28 Mar 2025 20:24:18 +0000 (20:24 +0000)] 
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.

3 months agomv: port test to OpenBSD 7.5
Paul Eggert [Sun, 23 Mar 2025 19:00:31 +0000 (12:00 -0700)] 
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.

3 months agodoc: id: be direct about valid options with -nr
Pádraig Brady [Sat, 22 Mar 2025 12:28:56 +0000 (12:28 +0000)] 
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

3 months agodoc: id: make option combinations more searchable
Pádraig Brady [Sat, 22 Mar 2025 12:10:36 +0000 (12:10 +0000)] 
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

3 months agols: fix crash on systems with SELinux but without xattr support
Pádraig Brady [Thu, 20 Mar 2025 18:40:01 +0000 (18:40 +0000)] 
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.