]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
8 months agols: use Gnulib’s unsupported errno list
Paul Eggert [Thu, 7 Nov 2024 16:57:42 +0000 (08:57 -0800)] 
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.

8 months agoexpand: use signed colno
Paul Eggert [Thu, 7 Nov 2024 02:04:35 +0000 (18:04 -0800)] 
expand: use signed colno

* src/expand-common.h (colno): Now intmax_t, not uintmax_t.

8 months agoexpand: refactor to introduce ‘colno’
Paul Eggert [Thu, 7 Nov 2024 01:56:15 +0000 (17:56 -0800)] 
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.

8 months agoexpand: prefer xpalloc to x2nrealloc
Paul Eggert [Thu, 7 Nov 2024 00:31:18 +0000 (16:31 -0800)] 
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.

8 months agoenv: prefer xpalloc to x2nrealloc
Paul Eggert [Thu, 7 Nov 2024 00:21:15 +0000 (16:21 -0800)] 
env: prefer xpalloc to x2nrealloc

* src/env.c (usvars_alloc): Use idx_t for size.
(append_unset_var): Use xpalloc instead of x2nrealloc.

8 months agochroot: expand heap a bit less aggressively
Paul Eggert [Thu, 7 Nov 2024 00:18:54 +0000 (16:18 -0800)] 
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.

8 months agomaint: expand heap a bit less aggressively
Paul Eggert [Thu, 7 Nov 2024 00:16:25 +0000 (16:16 -0800)] 
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.

9 months agobuild: Regenerate distributed built files in $(top_srcdir)
Bruno Haible [Sun, 3 Nov 2024 23:11:40 +0000 (00:11 +0100)] 
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).

9 months agocksum: add support for --algorithm=crc32b
Pádraig Brady [Fri, 1 Nov 2024 15:11:55 +0000 (15:11 +0000)] 
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.

9 months agotest: add string operators added by POSIX 2024
Collin Funk [Sat, 2 Nov 2024 03:49:16 +0000 (20:49 -0700)] 
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.

9 months agodoc: mention new timeout short options in NEWS
Pádraig Brady [Fri, 1 Nov 2024 15:58:04 +0000 (15:58 +0000)] 
doc: mention new timeout short options in NEWS

* NEWS: Mention the timeout -f and -p options.

9 months agostty: adjust --help to match POSIX 2024
Collin Funk [Fri, 1 Nov 2024 05:43:18 +0000 (22:43 -0700)] 
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.

9 months agodoc: fix timeout --help for -p
Pádraig Brady [Fri, 1 Nov 2024 12:42:41 +0000 (12:42 +0000)] 
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.

9 months agotimeout: add -f and -p short options as per POSIX 2024
Pádraig Brady [Wed, 30 Oct 2024 12:45:58 +0000 (12:45 +0000)] 
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.

9 months agotests: cksum: verify --check with comments
Sylvestre Ledru [Fri, 18 Oct 2024 20:30:01 +0000 (22:30 +0200)] 
tests: cksum: verify --check with comments

* tests/cksum/cksum-c.sh: Add a test case with a comment.

9 months agotests: improve ls --dired with symlink testing
Sylvestre Ledru [Thu, 17 Oct 2024 20:26:43 +0000 (22:26 +0200)] 
tests: improve ls --dired with symlink testing

* tests/ls/dired.sh: Verify ls --dired with symlink.

9 months agomaint: add syntax-check to ensure all gl/ files are distributed
Pádraig Brady [Mon, 14 Oct 2024 12:06:44 +0000 (13:06 +0100)] 
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.

9 months agobuild: distribute the gl/ directory in the tarballs
Bruno Haible [Mon, 14 Oct 2024 10:26:15 +0000 (11:26 +0100)] 
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.

9 months agocp,mv: align the descriptions of long options
Masatake YAMATO [Sat, 12 Oct 2024 16:28:10 +0000 (01:28 +0900)] 
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

9 months agochroot,whoami: use uintmax_t for printing uids
Collin Funk [Mon, 7 Oct 2024 05:19:51 +0000 (22:19 -0700)] 
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.

10 months agomaint: adjust check-ls-dircolors to recent change in ls.c
Bernhard Voelker [Sun, 6 Oct 2024 14:09:26 +0000 (16:09 +0200)] 
maint: adjust check-ls-dircolors to recent change in ls.c

'make distcheck' would fail since commit 75b34c77e43a, because the
comparison by check-ls-dircolors fails.

* Makefile.am (check-ls-dircolors): Adjust sed(1) expression to the
changed data initialization.

10 months agols: fix spurious output with -Z
Pádraig Brady [Thu, 3 Oct 2024 14:15:48 +0000 (15:15 +0100)] 
ls: fix spurious output with -Z

* src/ls.c (gobble_file): Only output an error if there actually
was an error.

10 months agotests: ls: don't always skip a capability test
Pádraig Brady [Thu, 3 Oct 2024 11:32:45 +0000 (12:32 +0100)] 
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.

10 months agols: tune usage of getxattr/stat syscalls
Paul Eggert [Thu, 3 Oct 2024 04:11:02 +0000 (21:11 -0700)] 
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).

10 months agols: omit cast from gobble_file
Paul Eggert [Wed, 2 Oct 2024 18:22:03 +0000 (11:22 -0700)] 
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 *.

10 months agols: check FILETYPE_INDICATORS cardinality
Paul Eggert [Wed, 2 Oct 2024 00:12:31 +0000 (17:12 -0700)] 
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.

10 months agols: tune indicator_name
Paul Eggert [Tue, 1 Oct 2024 23:54:36 +0000 (16:54 -0700)] 
ls: tune indicator_name

* src/ls.c (indicator_name): Simplify type; it is now merely
a 2-dimensional array of char.  All uses changed.

10 months agols: omit some unnecessary NULs
Paul Eggert [Tue, 1 Oct 2024 20:35:50 +0000 (13:35 -0700)] 
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.

10 months agols: tune is_colored
Paul Eggert [Tue, 1 Oct 2024 20:18:19 +0000 (13:18 -0700)] 
ls: tune is_colored

* src/ls.c (is_colored): Tune.
This shrinks the machine code considerably on x86-64.

10 months agols: omit unnecessary test
Paul Eggert [Tue, 1 Oct 2024 19:10:10 +0000 (12:10 -0700)] 
ls: omit unnecessary test

* src/ls.c (gobble_file): Omit redundant test of variable that
must be false here.

10 months agols: reinstate capability checking in more cases
Pádraig Brady [Wed, 2 Oct 2024 21:57:16 +0000 (22:57 +0100)] 
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.

10 months agodoc: ls: fix regression in -k description
Lukáš Zaoral [Wed, 2 Oct 2024 15:58:49 +0000 (17:58 +0200)] 
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.

10 months agotests: df: avoid false failure due to fuse.portal
Pádraig Brady [Wed, 2 Oct 2024 15:43:34 +0000 (16:43 +0100)] 
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().

10 months agotests: fix skipping of mtab simulation tests
Pádraig Brady [Wed, 2 Oct 2024 15:33:42 +0000 (16:33 +0100)] 
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.

10 months agomaint: avoid sc_preprocessor_indentation failure in factor.c
Bernhard Voelker [Sun, 29 Sep 2024 16:27:00 +0000 (18:27 +0200)] 
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'.

10 months agotests: add fold(1) test for --bytes option
Bernhard Voelker [Sun, 29 Sep 2024 15:39:16 +0000 (17:39 +0200)] 
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'.

10 months agols: use fewer xattr-related syscalls
Paul Eggert [Mon, 30 Sep 2024 05:04:02 +0000 (22:04 -0700)] 
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.

10 months agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 30 Sep 2024 04:17:58 +0000 (21:17 -0700)] 
build: update gnulib submodule to latest

10 months agofactor: eliminate print_uuint recursion
Paul Eggert [Fri, 27 Sep 2024 23:16:43 +0000 (16:16 -0700)] 
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.

10 months agofactor: lessen print_uuint recursion
Paul Eggert [Fri, 27 Sep 2024 21:05:41 +0000 (14:05 -0700)] 
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.

10 months agofactor: print_uuint accepts uuint
Paul Eggert [Fri, 27 Sep 2024 20:15:03 +0000 (13:15 -0700)] 
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.

10 months agofactor: simplify table count
Paul Eggert [Fri, 27 Sep 2024 03:22:06 +0000 (20:22 -0700)] 
factor: simplify table count

* src/factor.c (PRIMES_PTAB_ENTRIES): Simplify.

10 months agofactor: macro refactoring
Paul Eggert [Fri, 27 Sep 2024 03:20:05 +0000 (20:20 -0700)] 
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.

10 months agofactor: improve gmp-related buffering
Paul Eggert [Fri, 27 Sep 2024 03:01:58 +0000 (20:01 -0700)] 
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.

10 months agofactor: buffer stdout like other progs do
Paul Eggert [Thu, 26 Sep 2024 22:41:03 +0000 (15:41 -0700)] 
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.

10 months agofactor: improve fd buffering
Paul Eggert [Thu, 26 Sep 2024 22:36:44 +0000 (15:36 -0700)] 
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.

10 months agofactor: powm2 returns uuint
Paul Eggert [Thu, 26 Sep 2024 18:10:18 +0000 (11:10 -0700)] 
factor: powm2 returns uuint

* src/factor.c (powm2): Return uuint rather than half via
pointer. All callers changed.

10 months agofactor: factor_using_division returns uuint
Paul Eggert [Thu, 26 Sep 2024 17:49:21 +0000 (10:49 -0700)] 
factor: factor_using_division returns uuint

* src/factor.c (factor_using_division): Return uuint rather than
half via pointer. All callers changed.

10 months agofactor: gcd2_odd returns uuint
Paul Eggert [Thu, 26 Sep 2024 17:33:44 +0000 (10:33 -0700)] 
factor: gcd2_odd returns uuint

* src/factor.c (gcd2_odd): Return uuint rather than half via pointer.
All callers changed.

10 months agofactor: mod2 now returns uuint
Paul Eggert [Thu, 26 Sep 2024 17:25:51 +0000 (10:25 -0700)] 
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.

10 months agofactor: new type uuint
Paul Eggert [Thu, 26 Sep 2024 16:31:35 +0000 (09:31 -0700)] 
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.

10 months agofactor: tweak prime_p zero counting
Paul Eggert [Thu, 26 Sep 2024 00:55:00 +0000 (17:55 -0700)] 
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.

10 months agofactor: tweak gcd2_odd performance
Paul Eggert [Thu, 26 Sep 2024 00:50:09 +0000 (17:50 -0700)] 
factor: tweak gcd2_odd performance

* src/factor.c (gcd2_odd): Use stdc_trailing_zeros here too.

10 months agofactor: tweak gcd_odd performance
Paul Eggert [Thu, 26 Sep 2024 00:42:13 +0000 (17:42 -0700)] 
factor: tweak gcd_odd performance

* src/factor.c (gcd_odd): Use stdc_trailing_zeros instead of
counting zeros by hand.

10 months agofactor: switch to stdc_leading_zeros etc
Paul Eggert [Wed, 25 Sep 2024 23:53:52 +0000 (16:53 -0700)] 
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.

10 months agofactor: port to platforms
Paul Eggert [Wed, 25 Sep 2024 22:59:09 +0000 (15:59 -0700)] 
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.

10 months agodoc: remove extraneous periods from option --help
Pádraig Brady [Mon, 23 Sep 2024 20:44:38 +0000 (21:44 +0100)] 
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.

10 months agodoc: sort: be more descriptive than 'manual'
Pádraig Brady [Mon, 23 Sep 2024 20:31:59 +0000 (21:31 +0100)] 
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

10 months agodoc: env: simplify extra info in the man page
Pádraig Brady [Mon, 23 Sep 2024 20:17:28 +0000 (21:17 +0100)] 
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

10 months agodoc: improve printf(1) reference in echo man page
Pádraig Brady [Mon, 23 Sep 2024 19:53:25 +0000 (20:53 +0100)] 
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

10 months agodoc: fix option markup in chgrp, chown, chmod man pages
Pádraig Brady [Mon, 23 Sep 2024 19:49:19 +0000 (20:49 +0100)] 
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

10 months agoprintf: add indexed argument support
Pádraig Brady [Wed, 11 Sep 2024 15:07:48 +0000 (16:07 +0100)] 
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

11 months agomaint: assume C89 escape sequences
Collin Funk [Wed, 4 Sep 2024 02:45:13 +0000 (19:45 -0700)] 
maint: assume C89 escape sequences

* src/ptx.c (unescape_string) [!__STDC__]: Assume compiler supports '\a'
and '\v' escape sequences.

11 months agobuild: update gnulib submodule to latest
Pádraig Brady [Thu, 29 Aug 2024 01:17:16 +0000 (02:17 +0100)] 
build: update gnulib submodule to latest

11 months agoall: fix error checking in gl/lib/xdectoint.c
Pádraig Brady [Wed, 28 Aug 2024 11:33:17 +0000 (12:33 +0100)] 
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

11 months agomaint: avoid a syntax check failure
Pádraig Brady [Sun, 25 Aug 2024 08:15:43 +0000 (09:15 +0100)] 
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.

11 months agomaint: adjust to Gnulib acl changes
Collin Funk [Sat, 24 Aug 2024 18:34:07 +0000 (11:34 -0700)] 
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.

11 months agobuild: update gnulib submodule to latest
Collin Funk [Sat, 24 Aug 2024 18:21:00 +0000 (11:21 -0700)] 
build: update gnulib submodule to latest

* bootstrap: Update from Gnulib.

11 months agoinstall: dereference source symlinks when comparing
Pádraig Brady [Mon, 19 Aug 2024 11:43:09 +0000 (12:43 +0100)] 
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

11 months agomaint: adjust to recent removal of verror.c
Paul Eggert [Thu, 15 Aug 2024 22:12:25 +0000 (15:12 -0700)] 
maint: adjust to recent removal of verror.c

* po/POTFILES.in: Remove lib/verror.c

11 months agobuild: update gnulib submodule to latest
Paul Eggert [Thu, 15 Aug 2024 07:22:05 +0000 (00:22 -0700)] 
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.

11 months agols: add support for explicit file name sorting
Pádraig Brady [Sun, 11 Aug 2024 19:34:08 +0000 (20:34 +0100)] 
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

11 months agomaint: fix syntax-check failure
Pádraig Brady [Sun, 11 Aug 2024 14:08:32 +0000 (15:08 +0100)] 
maint: fix syntax-check failure

* gl/lib/xdectoint.h: Reinstate indentation enforced with cppi.
* src/head.c: Remove now redundant inclusion of "quote.h".

11 months agodoc: printf %b: clarify octal processing
Pádraig Brady [Sun, 11 Aug 2024 13:36:21 +0000 (14:36 +0100)] 
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

11 months agomaint: adjust to Gnulib safe_read etc. changes
Paul Eggert [Sun, 11 Aug 2024 02:30:46 +0000 (19:30 -0700)] 
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.

11 months agomaint: list Gnulib sys_types directly
Paul Eggert [Fri, 9 Aug 2024 15:51:53 +0000 (08:51 -0700)] 
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.

11 months agobuild: update gnulib submodule to latest
Paul Eggert [Fri, 9 Aug 2024 23:50:44 +0000 (16:50 -0700)] 
build: update gnulib submodule to latest

11 months agohead: fix overflows in elide_tail_bytes_pipe
Paul Eggert [Sun, 11 Aug 2024 05:19:17 +0000 (22:19 -0700)] 
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.

11 months agohead: new test for big count
Paul Eggert [Sun, 11 Aug 2024 02:28:37 +0000 (19:28 -0700)] 
head: new test for big count

* tests/head/head-c.sh: Also test head -c with a number
much bigger than UINTMAX_MAX.

11 months agotail: support counts > 2**64
Paul Eggert [Sun, 11 Aug 2024 02:02:44 +0000 (19:02 -0700)] 
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.

11 months agohead: off_t not uintmax_t for file offset
Paul Eggert [Sun, 11 Aug 2024 01:55:09 +0000 (18:55 -0700)] 
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.

11 months agonproc: support --ignore counts > 2**64
Paul Eggert [Sun, 11 Aug 2024 01:53:34 +0000 (18:53 -0700)] 
nproc: support --ignore counts > 2**64

* src/nproc.c (main): Allow --ignore arg to exceed 2**64.

11 months agonl: support -l counts > 2**64
Paul Eggert [Sun, 11 Aug 2024 01:51:50 +0000 (18:51 -0700)] 
nl: support -l counts > 2**64

* src/nl.c (main): Allow -l arg to exceed 2**64.

11 months agohead: support counts > 2**64
Paul Eggert [Sun, 11 Aug 2024 01:49:54 +0000 (18:49 -0700)] 
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.

11 months agodigest: improve -l overflow diagnostic
Paul Eggert [Sun, 11 Aug 2024 01:24:15 +0000 (18:24 -0700)] 
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.

11 months agomaint: distinguish EOVERFLOW vs ERANGE better
Paul Eggert [Sat, 10 Aug 2024 20:00:33 +0000 (13:00 -0700)] 
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.

11 months agotests: df-P.sh: fix intermittent false failure
Richard Purdie [Thu, 8 Aug 2024 17:37:48 +0000 (18:37 +0100)] 
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.

12 months agobuild: modernize AC_CHECK_TYPE usage
Paul Eggert [Sun, 4 Aug 2024 22:32:33 +0000 (15:32 -0700)] 
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.

12 months agomaint: avoid warning on older GCC compilers
Pádraig Brady [Sun, 4 Aug 2024 10:45:34 +0000 (11:45 +0100)] 
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.

12 months agotests: limit mem usage on potentially expensive test
Pádraig Brady [Sat, 3 Aug 2024 13:13:43 +0000 (14:13 +0100)] 
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.

12 months agotests: ensure utils support writing to a closed pipe
Pádraig Brady [Sat, 3 Aug 2024 12:37:33 +0000 (13:37 +0100)] 
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

12 months agodoc: reference 'dircolors invocation' from ls --color info
Pádraig Brady [Sat, 3 Aug 2024 11:48:21 +0000 (12:48 +0100)] 
doc: reference 'dircolors invocation' from ls --color info

* doc/coreutils.texi: Reference how to configure colors,
from the ls --color description.

12 months agodoc: clarify which ls color attributes don't apply to dirs
Pádraig Brady [Sat, 3 Aug 2024 11:35:26 +0000 (12:35 +0100)] 
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.

12 months agoshuf: tiny simplification
Paul Eggert [Sun, 4 Aug 2024 06:00:08 +0000 (23:00 -0700)] 
shuf: tiny simplification

* src/shuf.c (main): Omit redundant assignment.

12 months agoshuf: avoid integer overflow on huge inputs
Paul Eggert [Sun, 4 Aug 2024 05:59:12 +0000 (22:59 -0700)] 
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.

12 months agoshuf: fix randomness bug
Paul Eggert [Sun, 4 Aug 2024 05:31:20 +0000 (22:31 -0700)] 
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.

12 months agomaint: remove unnecessary inttostr usage in printf
Collin Funk [Tue, 30 Jul 2024 04:16:36 +0000 (21:16 -0700)] 
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.

12 months agobuild: support creating reproducible tarball contents
Pádraig Brady [Sun, 21 Jul 2024 17:25:05 +0000 (18:25 +0100)] 
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

12 months agotests: port to noatime file systems
Paul Eggert [Tue, 16 Jul 2024 01:53:46 +0000 (18:53 -0700)] 
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.

12 months agomaint: update bootstrap from Gnulib
Paul Eggert [Mon, 15 Jul 2024 22:28:26 +0000 (15:28 -0700)] 
maint: update bootstrap from Gnulib