1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-02-12 10:22:38 +02:00
Commit Graph

30737 Commits

Author SHA1 Message Date
Paul Eggert
af536b5ab7 maint: we use Gnulib’s stddef-h module directly
* bootstrap.conf (gnulib_modules): Add stddef-h, since the code
uses ‘unreachable’ which is supplied by that module.
2025-09-18 14:22:55 -07:00
Pádraig Brady
4ca51b1013 tests: tail/overlay-headers.sh: protect against hang
* tests/tail/overlay-headers.sh: Protect tail invocation with timeout,
and extend the possible running period to 60 seconds like other tests.
Reported by Brudno Haible on T2SDE Linux/alpha
2025-09-18 19:04:57 +01:00
Pádraig Brady
514f723d39 build: fix compile error on macOS
* gnulib: Update to latest to pull fix
for localcharset compile failure on macOS.
2025-09-18 18:04:57 +01:00
Pádraig Brady
0a2a3deb33 tests: tests/tail/wait.sh: protect against hang
* tests/tail/wait.sh: This test was seen to hang occasionally
on an Alpine Linux 3.20 system, so protect the tail(1) call
with `timeout 60` as done in similar tests.
Reported by Bruno Haible.
2025-09-18 17:47:45 +01:00
Pádraig Brady
c2e1816a53 build: fix link failure on macOS
* src/local.mk: Explicitly depend on @INTL_MACOS_LIBS@
which may be not implicitly referenced (in LIBINTL) without gettext.
This is a new transitive dependency through localename-unsafe.
We add this globally to ease future maintenance as currently
6 commands require the localename-unsafe dependency:
date, du through show-date() (fprintftime), and
ls, pr, stat, uptime through strftime().
2025-09-18 17:13:02 +01:00
Pádraig Brady
dc30eab314 build: update gnulib for stringeq adjustment
* gnulib: Pull in stringeq adjustment.
2025-09-17 21:44:46 +01:00
Pádraig Brady
5662192f39 tests: write-errors.sh: avoid portability issue with dash
* tests/misc/write-errors.sh: Use printf rather than echo
since the echo builtin in dash will interpret backslashes.
* tests/misc/read-errors.sh: Likewise for consistency.
2025-09-17 21:37:35 +01:00
Pádraig Brady
2b59958537 cksum,wc: inspect GLIBC_TUNABLES on all architectures
* gnulib: Update gnulib to latest to pull in change
to inspect GLIBC_TUNABLES on non x86_64 or aarch64 platforms.
This was needed on 32 bit x86, which supports calling into
accelerated code, and so requires inspection of GLIBC_TUNABLES
to pass the disablement verification in tests/cksum/cksum.sh
2025-09-17 20:56:38 +01:00
Paul Eggert
5257636761 maint: prefer memeq to memcmp
* gl/modules/randread-tests (Depends-on): Add stringeq.
* gl/tests/test-rand-isaac.c (main):
* src/copy.c (source_is_dst_backup):
* src/digest.c (b64_equal):
* src/install.c (have_same_content):
* src/ls.c (main, parse_ls_color):
* src/nl.c (check_section):
* src/od.c (write_block):
* src/seq.c (seq_fast):
* src/stty.c (eq_mode):
* src/system.h (is_nul):
Prefer memeq to memcmp when either will do.
2025-09-17 12:20:24 -07:00
Paul Eggert
ee367bd38d maint: STREQ → streq
Use new Gnulib streq function instead of rolling our own macro.
* bootstrap.conf (gnulib_modules): Add stringeq.
* src/rm.c (main): Don’t assume streq is a macro that expands to (...),
as it is now a function.
* src/system.h:
* tests/df/no-mtab-status.sh, tests/df/skip-duplicates.sh:
(STREQ): Remove.  All uses replaced by streq.
2025-09-17 12:20:24 -07:00
Paul Eggert
9f823e254a build: update gnulib submodule to latest 2025-09-17 12:20:24 -07:00
Pádraig Brady
78502174a9 tests: fix issues with fold-characters.sh test
This was noticed with:

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

* tests/fold/fold-characters.sh: Move memory limit test to ...
* tests/misc/write-errors.sh: ... which avoids "write error"
messages on stderr due to the ignored SIGPIPE.  It also protects
the fold invocation with a timeout(1) so that fold implementations
that don't exit promptly upon write error don't hang the test suite
(Like we would have done before commit v9.7-311-gc95c7ee76).
2025-09-17 15:32:47 +01:00
Pádraig Brady
42ac231533 doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.32 which is now about 5 years old.
2025-09-17 13:19:32 +01:00
Collin Funk
1efb539630 maint: remove unnecessary uintmaxtostr usage in printf
* src/comm.c (compare_files): Use the "%ju" printf directive instead of
"%s" and printing the result of umaxtostr.
* src/df.c (get_header): Likewise.
* src/ls.c (print_long_format): Likewise.
* src/sort.c (check): Likewise.
2025-09-16 19:43:46 -07:00
Pádraig Brady
168ae824f7 doc: add hardware acceleration configuration docs
* NEWS: Mention the new GLIBC_TUNABLES feature.
* doc/coreutils.texi (Hardware Acceleration): A new node
detailing the build time and run time configuration options.
2025-09-17 00:22:50 +01:00
Pádraig Brady
c95c7ee76f fold: fix write error checks with invalid multi-byte input
* src/fold.c (write_out): A new helper to check all writes.
(fold-file): Use write_out() for all writes.
* tests/fold/fold-zero-width.sh: Adjust to writing more
data in various patterns, rather than two buffers of NULs.
This is a more robust memory bound check, and the '\303' case
tests this particular logic change.
* NEWS: fold now exits immediately, not just promptly.
2025-09-16 18:41:51 +01:00
Pádraig Brady
10459ca7ed fold: exit promptly upon write errors
* NEWS: Mention the improvement.
* src/fold.c (fold_file): Check for write errors
after each buffer read from stdin.
* tests/misc/write-errors.sh: Add test cases.
2025-09-16 14:10:31 +01:00
Pádraig Brady
a6e9807eb9 maint: basenc: refactor overloaded use of ctx->i member
* src/basenc.c (base_decode_context): Remove the shared "i" member,
instead using per encoding data and access functions
for tracking pending data.
2025-09-16 14:09:12 +01:00
Pádraig Brady
dda853a4de tests: fold/fold-zero-width.sh: avoid false failure with ENOSPC
* tests/fold/fold-zero-width.sh: Check relatively large test file
is created appropriately.  Also apply more idomatic wc -l usage.
2025-09-16 14:00:44 +01:00
Pádraig Brady
7de9140e7a doc: NEWS: fold: clarify mem exhaustion trigger
* NEWS: Long lines were not an issue in previously
released coreutils, only the -w limitation was.
2025-09-16 13:56:35 +01:00
Pádraig Brady
b7a7a64ef7 maint: avoid syntax-check failures from recent commits
* cfg.mk: Avoid spellcheck failures.
* src/copy-file-data.c: Avoid sc_tight_scope and long_lines failure.
* src/copy.h: Avoid indentation issues.
2025-09-16 13:44:13 +01:00
Paul Eggert
f6bffa431d cp: create_hole now returns off_t
* src/copy-file-data.c (create_hole): Refactor by returning
resulting offset, not bool.  All callers changed.
2025-09-15 23:17:35 -07:00
Paul Eggert
c80f6eebdf cp: prefer signed types in copy-file-data.c
* src/copy-file-data.c (sparse_copy, lseek_copy)
(copy_file_data): Prefer idx_t to size_t.
(copy_file_data): Defend against st_size < 0, which can happen on
ancient buggy platforms.  Check for overflow; the old code was
wrong on theoretical-but-valid hosts where SIZE_MAX <= INT_MAX.
2025-09-15 23:17:35 -07:00
Paul Eggert
12d03a0444 cp: don’t allocate a separate zero buffer
* src/copy-file-data.c (write_zeros): New args abuf, buf_size.
Use the lazily-allocated buffer, which most likely already exists,
rather than allocating a separate buffer just for zeros.
This makes the code more reentrant as there is no longer
a need for static storage here.  Although there is some CPU
overhead due to the need to zero out the buffer for each file,
the overhead is relatively small as the buffer is smallish
and should be cached.  All callers changed.
2025-09-15 23:17:35 -07:00
Paul Eggert
3f9534a2ab cp: refactor copying to return bytes copied
This doesn’t change behavior; it simplifies future changes.
* src/copy-file-data.c (sparse_copy, lseek_copy, copy_file_data):
Return the number of bytes copied, or -1 on failure,
instead of merely returning a success indication.
All callers changed.
2025-09-15 23:17:35 -07:00
Paul Eggert
560a39f7c0 cp: copy_file_data now supports ibytes
This does not affect current coreutils behavior;
it is merely to help make copy_file_data more useful in the future.
* src/copy-file-data.c (lseek_copy): New arg ibytes.
Caller changed.
(copy_file_data): Implement the ibytes arg; formerly
it was always treated as COUNT_MAX, though all callers
currently pass COUNT_MAX so there was no problem in practice.
2025-09-15 23:17:34 -07:00
Paul Eggert
bcc5cdfb9b cp: prefer signed type for file byte count
* src/copy-file-data.c (sparse_copy): max_n_read arg is now
of type count_t, not uintmax_t.  This is better for debugging
with -fsanitize=undefined.
2025-09-15 23:17:34 -07:00
Paul Eggert
5b5dcb7056 cp: port better to old limited hosts
Port better ancient platforms where OFF_T_MAX is only 2**31 - 1,
but some devices have more than that many bytes.
* src/copy-file-data.c (copy_file_data): Byte count is now
count_t, not off_t.  All callers changed.  Since we need to check
for overflow anyway, also check for too-small calls to fadvise.
2025-09-15 23:17:34 -07:00
Paul Eggert
06a6758d03 cp: refactor out data copying
* po/POTFILES.in, src/local.mk (copy_sources): Add the new file.
* src/copy.c: Move the #includes of alignalloc.h, buffer-lcm.h,
fadvise.h, full-write.h, ioblksize.h to copy-file-data.c.
(enum copy_debug_val, struct copy_debug): Move these decls to copy.h.
(punch_hole, create_hole, is_CLONENOTSUP, sparse_copy)
(write_zeros, lseek_copy, HAVE_STRUCT_STAT_ST_BLOCKS)
(enum scantype, struct scan_inference, infer_scantype):
Move to copy-file-data.c.
(copy_reg): Move the data-copying part of this function
to the new function copy_file_data in copy-file-data.c.
* src/copy-file-data.c: New file, taken from part of copy.c.
2025-09-15 23:17:34 -07:00
Paul Eggert
12bacad85b cp: refactor src/copy.c
This is in preparation for splitting this large module.
* src/copy.c (sparse_copy, lseek_copy): New arg DEBUG, used to
identify copy debug info instead of using a static var.  All
callers changed.
(lseek_copy, infer_scantype): New args SRC_POS and POS.
Callers changed.
(copy_file_data): New function, with contents taken from copy.
(copy_reg): Call it.
2025-09-15 23:17:34 -07:00
Collin Funk
e33bfb5886 doc: NEWS: correct the previous commit
* NEWS: The memory allocated by 'fold' in the past was also bounded by
--width.
2025-09-15 21:40:56 -07:00
Collin Funk
58b5fd0bc8 doc: NEWS: mention fold can operate on very long lines
* NEWS: Before commit fb9016d50 (fold: use fread instead of getline,
2025-08-24), fold required that the maximum line size in a file fit into
memory. Document that this is no longer the case.
2025-09-15 21:09:42 -07:00
Collin Funk
98e5418a38 fold: fix out of bounds write with zero width characters
* src/fold.c (fold_file): Prefer putchar ('\n') to copying characters.
If we do not have room in the output buffer print it since it is not a
full line of text.
* tests/fold/fold-zero-width.sh: New test case.
* tests/local.mk (all_tests): Add it.
2025-09-15 20:55:56 -07:00
Paul Eggert
8339970b15 cp: improve umask caching
* src/copy.c (cached_umask): Avoid syscalls when cached umask is 0.
This can also help the compiler’s static analysis.
2025-09-15 16:15:10 -07:00
Collin Funk
f4dcc2a495 basenc: fix an uninitialized index when decoding an empty file
* src/basenc.c (base64_decode_ctx_init_wrapper)
(base64url_decode_ctx_init_wrapper)
(base32_decode_ctx_init_wrapper)
(base32hex_decode_ctx_init_wrapper): Initialize ctx->i to zero.
Fixes https://bugs.gnu.org/79444
2025-09-14 09:30:16 -07:00
Pádraig Brady
b96cdc66d9 maint: randperm: remove stale dependency
* gl/modules/randperm: Remove assert-h dependency
not required since commit v9.5-34-g26ba82015
2025-09-14 13:44:56 +01:00
Pádraig Brady
7bd3839cda cksum,wc: support disabling hardware acceleration at runtime
This is useful to give better test coverage at least,
and may be useful for users to tune their environment.

* bootstrap.conf: Reference the cpu-supports gnulib module.
* src/cksum.c: Use cpu_supports() rather than __builtin_cpu_supports().
* src/wc.c: Likewise.
* tests/cksum/cksum.sh: Adjust to testing all implementations.
* tests/wc/wc-cpu.sh: A new test to do likewise.
* tests/local.mk: Reference the new wc test.
2025-09-14 13:43:49 +01:00
Pádraig Brady
6848cb93d4 build: update gnulib submodule to latest
Primarily to get the new cpu-supports module.
2025-09-14 13:31:39 +01:00
Paul Eggert
6a1f541ad2 factor: port to strict C
Problem found with Oracle Developer Studio 12.6.
* src/factor.c (factor): Don’t return f() when f returns void.
2025-09-13 12:25:59 -07:00
Collin Funk
f585f3a358 maint: document some functions used by expand and unexpand
* src/expand-common.h (get_next_tab_column, cleanup_file_list_stdin)
(emit_tab_list_info): Document functions.
* src/expand-common.c (cleanup_file_list_stdin, emit_tab_list_info):
Likewise.
2025-09-11 20:31:05 -07:00
Pádraig Brady
4141ae3e49 maint: basenc: refactor all encodings to use finalize
Finalize was required for base58, but it's a more general mechanism
which simplifies the logic for all encodings

* src/basenc.c (do_decode): Always call base_decode_ctx_finalize(),
rather than the awkward double loop at end of buffer.
* tests/basenc/basenc.pl: Add basenc finalization tests.
2025-09-10 23:24:46 +01:00
Collin Funk
1ba065b5be maint: cleanup libraries unnecessarily added to fold
* src/local.mk (src_fold_LDADD): Remove $(MBRTOWC_LIB) since it is
already added to LDADD. Remove $(LIBC32CONV) and $(LIBUNISTRING) which
were for an uncommitted patch which used Gnulib's mbfile module.
2025-09-09 20:39:37 -07:00
Pádraig Brady
2ed207cb1f nohup: avoid FORTIFY runtime failure on Bionic libc
The meaning of non-file permission umask bits is implementation defined.
On Bionic libc, attempting to set them triggers a FORTIFY runtime check.

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

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

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

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