]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
10 months agocksum: use AVX2 and AVX512 for speedup
Sam Russell [Mon, 25 Nov 2024 23:25:00 +0000 (00:25 +0100)] 
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.

10 months agotail,tee: fix broken pipe detection on darwin 9
Pádraig Brady [Tue, 26 Nov 2024 14:04:32 +0000 (14:04 +0000)] 
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

10 months agotests: avoid false failure with unicode decomposed file systems
Pádraig Brady [Sun, 24 Nov 2024 12:51:43 +0000 (12:51 +0000)] 
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

10 months agodd: port big-offset test to macOS 12.6
Paul Eggert [Wed, 20 Nov 2024 19:11:54 +0000 (11:11 -0800)] 
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.

10 months agomaint: update .gitignore
Collin Funk [Wed, 20 Nov 2024 02:50:27 +0000 (18:50 -0800)] 
maint: update .gitignore

* .gitignore (/lib/crc-sliceby8.h): Add file generated by Gnulib.

10 months agomaint: prefer mbszero over memset
Collin Funk [Wed, 20 Nov 2024 02:43:19 +0000 (18:43 -0800)] 
maint: prefer mbszero over memset

* src/df.c (replace_invalid_chars): Use mbszero.

10 months agols: port to Oracle Developer Studio 12.6
Paul Eggert [Wed, 20 Nov 2024 06:55:48 +0000 (22:55 -0800)] 
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.

10 months agofactor: fix ‘return’ typo
Paul Eggert [Wed, 20 Nov 2024 06:22:57 +0000 (22:22 -0800)] 
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.

10 months agodoc: mention "printf %d ''" change
Paul Eggert [Tue, 19 Nov 2024 22:01:32 +0000 (14:01 -0800)] 
doc: mention "printf %d ''" change

10 months agotests: fix inconsistent use of getlimits_
Pádraig Brady [Tue, 19 Nov 2024 20:03:01 +0000 (20:03 +0000)] 
tests: fix inconsistent use of getlimits_

* tests/dd/skip-seek-past-file.sh: s/eval $(getlimits)/getlimits_/

10 months agotests: printf: avoid iconv issues on macOS
Pádraig Brady [Tue, 19 Nov 2024 19:57:53 +0000 (19:57 +0000)] 
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

10 months agochown: port test to macOS 12.6 nogroup user
Paul Eggert [Tue, 19 Nov 2024 17:53:17 +0000 (09:53 -0800)] 
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.

10 months agomaint: omit unnecessary to_uchar
Paul Eggert [Tue, 19 Nov 2024 17:18:50 +0000 (09:18 -0800)] 
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’.

10 months agotests: Remove stray ‘i’
Paul Eggert [Tue, 19 Nov 2024 16:55:41 +0000 (08:55 -0800)] 
tests: Remove stray ‘i’

10 months agoprintf: diagnose empty args correctly
Paul Eggert [Tue, 19 Nov 2024 02:19:54 +0000 (18:19 -0800)] 
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.

10 months agoprintf: do n$ overflow checking by hand
Paul Eggert [Mon, 18 Nov 2024 21:46:33 +0000 (13:46 -0800)] 
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.

10 months agoprintf: refactor macros to function
Paul Eggert [Mon, 18 Nov 2024 19:24:10 +0000 (11:24 -0800)] 
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.

10 months agomaint: avoid a syntax-check failure
Pádraig Brady [Mon, 18 Nov 2024 16:17:10 +0000 (16:17 +0000)] 
maint: avoid a syntax-check failure

This was also updated in gnulib.

* bootstrap: s/can not/cannot/

10 months agodoc: describe "New programs" consistently in NEWS
Pádraig Brady [Mon, 18 Nov 2024 16:13:12 +0000 (16:13 +0000)] 
doc: describe "New programs" consistently in NEWS

* NEWS: s/New commands/New programs/

10 months agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 18 Nov 2024 07:00:34 +0000 (23:00 -0800)] 
build: update gnulib submodule to latest

Also, copy bootstrap from gnulib/build-aux/bootstrap.

10 months agofactor: pacify -Wunused-macros
Paul Eggert [Sat, 16 Nov 2024 20:45:34 +0000 (13:45 -0700)] 
factor: pacify -Wunused-macros

* src/factor.c: Also use __GMP_GNUC_PREREQ

10 months agols: refactor gobble_file get_scontext
Paul Eggert [Fri, 15 Nov 2024 01:35:49 +0000 (17:35 -0800)] 
ls: refactor gobble_file get_scontext

* src/ls.c (gobble_file): Simplify by pulling get_scontext
out of ‘if’.

10 months agotests: ls: also test security context output for symlinks
Pádraig Brady [Tue, 12 Nov 2024 11:34:07 +0000 (11:34 +0000)] 
tests: ls: also test security context output for symlinks

* tests/ls/selinux.sh: Test symlinks as well as files.

10 months agotests: avoid false failure with --disable-selinux
Pádraig Brady [Mon, 11 Nov 2024 19:54:18 +0000 (19:54 +0000)] 
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).

10 months agols: fix security context indication in --long mode
Pádraig Brady [Mon, 11 Nov 2024 18:55:19 +0000 (18:55 +0000)] 
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.

10 months agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 11 Nov 2024 16:52:12 +0000 (08:52 -0800)] 
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.

10 months agobuild: update gnulib to latest
Pádraig Brady [Mon, 11 Nov 2024 14:54:03 +0000 (14:54 +0000)] 
build: update gnulib to latest

* NEWS: Mention the fix to nproc honoring the affinity mask
on systems with more than 1024 processors.

10 months agols: add test case for ls -Z bug
Paul Eggert [Sun, 10 Nov 2024 00:51:02 +0000 (16:51 -0800)] 
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.

10 months agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 9 Nov 2024 18:29:14 +0000 (10:29 -0800)] 
build: update gnulib submodule to latest

10 months agotests: avoid false failure on older valgrind
Pádraig Brady [Sat, 9 Nov 2024 16:55:33 +0000 (16:55 +0000)] 
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.

10 months agoseq: seq_fast always exits now
Paul Eggert [Sat, 9 Nov 2024 07:16:45 +0000 (23:16 -0800)] 
seq: seq_fast always exits now

* src/seq.c (seq_fast): Always exit.  Don’t bother freeing
just before exit.

10 months agoseq: simplify cmp calls
Paul Eggert [Sat, 9 Nov 2024 07:10:00 +0000 (23:10 -0800)] 
seq: simplify cmp calls

* src/seq.c (seq_fast): Call cmp in just one place, not two.
Redo loop structure to make it work.

10 months agoseq: use full_write instead of fwrite
Paul Eggert [Sat, 9 Nov 2024 04:17:54 +0000 (20:17 -0800)] 
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.

10 months agoseq: simplify output buffer management
Paul Eggert [Sat, 9 Nov 2024 03:55:54 +0000 (19:55 -0800)] 
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.

10 months agoseq: omit unnecessary malloc for upper bound
Paul Eggert [Fri, 8 Nov 2024 20:28:27 +0000 (12:28 -0800)] 
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.

10 months agoseq: simplify cmp
Paul Eggert [Fri, 8 Nov 2024 20:08:57 +0000 (12:08 -0800)] 
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.

10 months agoseq: explicate incr
Paul Eggert [Fri, 8 Nov 2024 17:35:35 +0000 (09:35 -0800)] 
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.

10 months agoenv: prefer xpalloc to xrealloc
Paul Eggert [Fri, 8 Nov 2024 08:09:19 +0000 (00:09 -0800)] 
env: prefer xpalloc to xrealloc

* src/env.c (extract_varname): Prefer free+xpalloc to
xrealloc, since the old buffer contents don’t matter.

10 months agoshuf: prefer xpalloc to xnrealloc
Paul Eggert [Fri, 8 Nov 2024 08:01:01 +0000 (00:01 -0800)] 
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.

10 months agopwd: prefer xpalloc to xnrealloc
Paul Eggert [Fri, 8 Nov 2024 07:24:14 +0000 (23:24 -0800)] 
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.

10 months agodu: prefer xpalloc to xnrealloc
Paul Eggert [Fri, 8 Nov 2024 06:56:44 +0000 (22:56 -0800)] 
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.

10 months agodf: prefer xpalloc to xnrealloc
Paul Eggert [Fri, 8 Nov 2024 06:45:32 +0000 (22:45 -0800)] 
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.

10 months agobasenc: prefer xpalloc to xnrealloc
Paul Eggert [Fri, 8 Nov 2024 06:32:41 +0000 (22:32 -0800)] 
basenc: prefer xpalloc to xnrealloc

* src/basenc.c (prepare_inbuf): Prefer xpalloc to xnrealloc.

10 months agols: prefer xpalloc to xnrealloc
Paul Eggert [Fri, 8 Nov 2024 06:30:09 +0000 (22:30 -0800)] 
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.

10 months agodf: simplify via xasprintf
Paul Eggert [Fri, 8 Nov 2024 01:16:14 +0000 (17:16 -0800)] 
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.

10 months agocsplit: port to IDX_MAX < INT_MAX
Paul Eggert [Fri, 8 Nov 2024 01:15:12 +0000 (17:15 -0800)] 
csplit: port to IDX_MAX < INT_MAX

* src/csplit.c (max_out): Defend against unlikely IDX_MAX < INT_MAX.

10 months agopr: prefer xpalloc to x2realloc
Paul Eggert [Fri, 8 Nov 2024 00:39:35 +0000 (16:39 -0800)] 
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.

10 months agood: prefer xpalloc to x2realloc
Paul Eggert [Thu, 7 Nov 2024 23:11:37 +0000 (15:11 -0800)] 
od: prefer xpalloc to x2realloc

* src/od.c (string_min, dump_strings): Prefer idx_t to size_t for
sizes.  Use xpalloc, not x2realloc.

10 months agofold: prefer xpalloc to x2realloc
Paul Eggert [Thu, 7 Nov 2024 23:04:50 +0000 (15:04 -0800)] 
fold: prefer xpalloc to x2realloc

* src/fold.c (fold_file): Prefer idx_t to size_t for sizes.
Use xpalloc, not x2realloc.

10 months agosort: prefer xpalloc to x2nrealloc
Paul Eggert [Thu, 7 Nov 2024 22:25:17 +0000 (14:25 -0800)] 
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.

10 months agocut,numfmt: prefer xpalloc to x2nrealloc
Paul Eggert [Thu, 7 Nov 2024 22:17:14 +0000 (14:17 -0800)] 
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.

10 months agoptx: prefer xpalloc to x2nrealloc
Paul Eggert [Thu, 7 Nov 2024 22:09:26 +0000 (14:09 -0800)] 
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.

10 months agood: prefer xpalloc to x2nrealloc
Paul Eggert [Thu, 7 Nov 2024 20:58:49 +0000 (12:58 -0800)] 
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.

10 months agoexpand: check for colno overflow
Paul Eggert [Thu, 7 Nov 2024 20:51:04 +0000 (12:51 -0800)] 
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.

10 months agols: fix aclinfo cache bug
Paul Eggert [Thu, 7 Nov 2024 20:32:21 +0000 (12:32 -0800)] 
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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

11 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).

11 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.

11 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.

11 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.

11 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.

11 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.

11 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.

11 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.

11 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.

11 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.

11 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.

11 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

11 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.

11 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.

12 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.

12 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.

12 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).

12 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 *.

12 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.

12 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.

12 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.

12 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.

12 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.

12 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.

12 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.

12 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().

12 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.

12 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'.

12 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'.

12 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.

12 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

12 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.

12 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.

12 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.

12 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.

12 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.

12 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.

12 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.