Compare commits

...

326 Commits
v9.5 ... v9.7

Author SHA1 Message Date
Pádraig Brady
8e075ff8ee version 9.7
* NEWS: Record release date.
2025-04-09 11:44:57 +01:00
Pádraig Brady
9ccabd8df3 tests: adjust csplit VM limit for CheriBSD
* tests/misc/csplit-heap.sh: More memory is required to avoid
a false failure on CheriBSD with its heap accounting overhead.
This is confirmed to still trigger with the original memory leak
being tested.
2025-04-08 16:07:06 +01:00
Pádraig Brady
7007c018de ls: support capabilities with device 0,0
* src/ls.c (has_capability_cache): Don't assume
a device major,minor of 0,0 never occurs.
2025-04-08 12:17:19 +01:00
Bruno Haible
0954e91fcf ls: fix crash of "ls -Z ." on OpenBSD's /dev/wd0a disk
* src/ls.c (file_has_aclinfo_cache): Add new static variable
'unsupported_cached'. Don't assume that device 0 never occurs.
2025-04-08 12:02:13 +01:00
Jim Meyering
42f6201aa5 build: use _GL_ATTRIBUTE_NONSTRING attribute to avoid new warnings
Avoid warnings like this from GCC 15:
src/basenc.c:1139:20: error: initializer-string for array of 'char'
truncates NUL terminator but destination lacks 'nonstring' attribute
(9 chars into 8 available) [-Werror=unterminated-string-initialization]
* src/basenc.c (z85_encoding, do_decode): Mark two more variables as
non-terminated.
2025-04-07 18:47:43 +01:00
Pádraig Brady
dcfe04eab5 maint: avoid syntax-check failures from recent commit
* gl/lib/dtimespec-bound.h: Indent, Spellcheck.
* gl/local.mk: Add new gl files.
2025-04-07 18:42:12 +01:00
Paul Eggert
f1df3e703f doc: mention workaround for combining hex floats with suffixes
* doc/coreutils.texi (hexDuration): Mention the p style exponent trick.
2025-04-07 18:40:29 +01:00
Paul Eggert
905afc91a5 build: update gnulib submodule to latest 2025-04-07 01:48:28 -07:00
Paul Eggert
cb7c210d30 timeout: don’t sleep less than requested
Also, change sleep and tail to not sleep less than requested.
* bootstrap.conf (gnulib_modules): Add dtimespec-bound.
* gl/lib/dtimespec-bound.c, gl/lib/dtimespec-bound.h:
* gl/modules/dtimespec-bound: New files.
* src/sleep.c, src/tail.c, src/timeout.c: Include dtimespec-bound.h.
* src/sleep.c, src/tail.c: Don’t include xstrtod.h.
* src/sleep.c (apply_suffix, main):
* src/tail.c (parse_options):
* src/timeout.c (apply_time_suffix):
Don’t sleep less than the true number of seconds.
* src/timeout.c: Don’t include ctype.h.
(is_negative): Remove; no longer needed.
(parse_duration): Use a slightly looser bound on the timeout, one
that doesn’t need -lm on GNU/Linux.  Clear errno before calling
cl_strtod.
2025-04-07 00:59:27 -07:00
Jim Meyering
0311d45d5b maint: silence a -Wunterminated-string-initialization warning
* src/basenc.c (base16_encode): Mark BASE16 as not NUL-terminated.
2025-04-06 08:14:06 +01:00
Pádraig Brady
14af8e34c9 build: update gnulib submodule to latest 2025-04-06 00:07:49 +01:00
Pádraig Brady
dce566553c timeout: remove dependence on libm
This was seen to add about 100,000 ns to the startup time,
on a 2.6 GHz i7-5600U with glibc 2.40.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

So for these reasons revert to checking capabilities as before.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

View File

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

View File

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

4
.gitignore vendored
View File

@@ -60,8 +60,10 @@
/lib/config.h
/lib/config.hin
/lib/configmake.h
/lib/crc-sliceby8.h
/lib/ctype.h
/lib/dirent.h
/lib/endian.h
/lib/errno.h
/lib/error.h
/lib/fcntl.h
@@ -105,6 +107,7 @@
/lib/stamp-h1
/lib/stdarg.h
/lib/stdbool.h
/lib/stdbit.h
/lib/stdckdint.h
/lib/stddef.h
/lib/stdint.h
@@ -207,6 +210,7 @@
/tests/*/*.trs
/tests/.built-programs
/tests/factor/t[0-9][0-9].sh
/tests/init.sh
/tests/t?
/tests/test-suite.log
/tight-scope.mk

View File

@@ -1 +1 @@
9.4
9.6

View File

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

View File

@@ -616,7 +616,7 @@ and root only tests, is to follow these steps (requires lcov to be installed):
xdg-open doc/coverage/index.html
========================================================================
Copyright (C) 2009-2024 Free Software Foundation, Inc.
Copyright (C) 2009-2025 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or

View File

@@ -1,6 +1,6 @@
# Make coreutils. -*-Makefile-*-
# Copyright (C) 1990-2024 Free Software Foundation, Inc.
# Copyright (C) 1990-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -82,14 +82,12 @@ BUILT_SOURCES = .version
# Have no read-only files in the tarball to allow easy removal.
# Have .tarball-version based versions only in tarball builds.
# Have .timestamp based dates only in tarball builds.
# The perl substitution is to change some key uses of "rm" to "/bin/rm".
# See the rm_subst comment for details.
# The touch avoids a subtle, spurious "make distcheck" failure.
dist-hook: gen-ChangeLog
$(AM_V_GEN)chmod -R +rw $(distdir)
$(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
$(AM_V_GEN)date +%s > $(distdir)/.timestamp
$(AM_V_at)perl -pi -e '$(rm_subst)' $(distdir)/Makefile.in
$(AM_V_at)touch $(distdir)/doc/constants.texi \
$(distdir)/doc/coreutils.info
@@ -135,7 +133,8 @@ check-ls-dircolors:
|sed -n 's/^"\(..\)"/\1/p'|sort -u); \
ls=$$(sed -n '/static.*indicator_name\[/,/};'/\p \
$(srcdir)/src/ls.c \
|sed -n '/^ *"/p'|tr , '\n'|sed 's/^ *//' \
|sed -n '/^ *{/ { s/{.\([a-z]\).,.\([a-z]\).}/"\1\2"/g; p; }' \
|tr , '\n'|sed 's/^ *//' \
|sed -n 's/^"\(..\)"/\1/p'|sort -u); \
test "$$dc" = "$$ls"
@@ -209,6 +208,7 @@ MOSTLYCLEANDIRS =
AM_CPPFLAGS = -Ilib -I$(top_srcdir)/lib -Isrc -I$(top_srcdir)/src
include $(top_srcdir)/gl/local.mk
include $(top_srcdir)/lib/local.mk
include $(top_srcdir)/src/local.mk
include $(top_srcdir)/doc/local.mk

170
NEWS
View File

@@ -1,5 +1,169 @@
GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 9.7 (2025-04-09) [stable]
** Bug fixes
'cat' would fail with "input file is output file" if input and
output are the same terminal device and the output is append-only.
[bug introduced in coreutils-9.6]
'cksum -a crc' misbehaved on aarch64 with 32-bit uint_fast32_t.
[bug introduced in coreutils-9.6]
dd with the 'nocache' flag will now detect all failures to drop the
cache for the whole file. Previously it may have erroneously succeeded.
[bug introduced with the "nocache" feature in coreutils-8.11]
'ls -Z dir' would crash on all systems, and 'ls -l' could crash
on systems like Android with SELinux but without xattr support.
[bug introduced in coreutils-9.6]
`ls -l` could output spurious "Not supported" errors in certain cases,
like with dangling symlinks on cygwin.
[bug introduced in coreutils-9.6]
timeout would fail to timeout commands with infinitesimal timeouts.
For example `timeout 1e-5000 sleep inf` would never timeout.
[bug introduced with timeout in coreutils-7.0]
sleep, tail, and timeout would sometimes sleep for slightly less
time than requested.
[bug introduced in coreutils-5.0]
'who -m' now outputs entries for remote logins. Previously login
entries prefixed with the service (like "sshd") were not matched.
[bug introduced in coreutils-9.4]
** Improvements
'logname' correctly returns the user who logged in the session,
on more systems. Previously on musl or uclibc it would have merely
output the LOGNAME environment variable.
* Noteworthy changes in release 9.6 (2025-01-17) [stable]
** Bug fixes
cp fixes support for --update=none-fail, which would have been
rejected as an invalid option.
[bug introduced in coreutils-9.5]
cp,mv --update no longer overrides --interactive or --force.
[bug introduced in coreutils-9.3]
csplit no longer creates empty files given empty input.
[This bug was present in "the beginning".]
ls and printf fix shell quoted output in the edge case of escaped
first and last characters, and single quotes in the string.
[bug introduced in coreutils-8.26]
ls -l no longer outputs "Permission denied" errors on NFS
which may happen with files without read permission, and which resulted
in inaccurate indication of ACLs (missing '+' flag after mode).
[bug introduced in coreutils-9.4]
ls -l no longer outputs "Not supported" errors on virtiofs.
[bug introduced in coreutils-9.4]
mv works again with macFUSE file systems. Previously it would
have exited with a "Function not implemented" error.
[bug introduced in coreutils-8.28]
nproc gives more consistent results on systems with more than 1024 CPUs.
Previously it would have ignored the affinity mask on such systems.
[bug introduced with nproc in coreutils-8.1]
numfmt --from=iec-i now works with numbers without a suffix.
Previously such numbers were rejected with an error.
[bug introduced with numfmt in coreutils-8.21]
printf now diagnoses attempts to treat empty strings as numbers,
as per POSIX. For example, "printf '%d' ''" now issues a diagnostic
and fails instead of silently succeeding.
[This bug was present in "the beginning".]
pwd no longer outputs an erroneous double slash on systems
where the system getcwd() was completely replaced.
[bug introduced in coreutils-9.2]
'shuf' generates more-random output when the output is small.
[bug introduced in coreutils-8.6]
`tail --follow=name` no longer waits indefinitely for watched
file names that are moved elsewhere within the same file system.
[bug introduced in coreutils-8.24]
`tail --follow` without --retry, will consistently exit with failure status
where inotify is not used, when all followed files become inaccessible.
[This bug was present in "the beginning".]
`tail --follow --pid=PID` will now exit when the PID dies,
even in the presence of blocking inputs like unopened fifos.
[This bug was present in "the beginning".]
'tail -c 4096 /dev/zero' no longer loops forever.
[This bug was present in "the beginning".]
** Changes in behavior
'factor' now buffers output more efficiently in some cases.
install -C now dereferences symlink sources when comparing,
rather than always treating as different and performing the copy.
kill -l and -t now list signal 0, as it's a valid signal to send.
ls's -f option now simply acts like -aU, instead of also ignoring
some earlier options. For example 'ls -fl' and 'ls -lf' are now
equivalent because -f no longer ignores an earlier -l. The new
behavior is more orthogonal and is compatible with FreeBSD.
stat -f -c%T now reports the "fuseblk" file system type as "fuse",
given that there is no longer a distinct "ctl" fuse variant file system.
** New Features
cksum -a now supports the "crc32b" option, which calculates the CRC
of the input as defined by ITU V.42, as used by gzip for example.
For performance pclmul instructions are used where supported.
ls now supports the --sort=name option,
to explicitly select the default operation of sorting by file name.
printf now supports indexed arguments, using the POSIX:2024 specified
%<i>$ format, where '<i>' is an integer referencing a particular argument,
thus allowing repetition or reordering of printf arguments.
test supports the POSIX:2024 specified '<' and '>' operators with strings,
to compare the string locale collating order.
timeout now supports the POSIX:2024 specified -f, and -p short options,
corresponding to --foreground, and --preserve-status respectively.
** Improvements
cksum -a crc, makes use of AVX2, AVX512, and ARMv8 SIMD extensions
for time reductions of up to 40%, 60%, and 80% respectively.
'head -c NUM', 'head -n NUM', 'nl -l NUM', 'nproc --ignore NUM',
'tail -c NUM', 'tail -n NUM', and 'tail --max-unchanged-stats NUM
no longer fail merely because NUM stands for 2**64 or more.
sort operates more efficiently when used on pseudo files with
an apparent size of 0, like those in /proc.
stat and tail now know about the "bcachefs", and "pidfs" file system types.
stat -f -c%T now reports the file system type,
and tail -f uses inotify for these file systems.
wc now reads a minimum of 256KiB at a time.
This was previously 16KiB and increasing to 256KiB was seen to increase
wc -l performance by about 10% when reading cached files on modern systems.
* Noteworthy changes in release 9.5 (2024-03-28) [stable]
** Bug fixes
@@ -944,7 +1108,7 @@ GNU coreutils NEWS -*- outline -*-
env now supports '--list-signal-handling' to indicate non-default
signal handling before executing a program.
** New commands
** New programs
basenc is added to complement existing base64,base32 commands,
and encodes and decodes printable text using various common encodings:
@@ -1464,7 +1628,7 @@ GNU coreutils NEWS -*- outline -*-
tail -F now works with initially non existent files on a remote file system.
[bug introduced in coreutils-7.5]
** New commands
** New programs
base32 is added to complement the existing base64 command,
and encodes and decodes printable text as per RFC 4648.
@@ -5896,7 +6060,7 @@ packages, see ./old/*/NEWS.
========================================================================
Copyright (C) 2001-2024 Free Software Foundation, Inc.
Copyright (C) 2001-2025 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or

2
README
View File

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

View File

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

View File

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

View File

@@ -140,6 +140,7 @@ Dameon G. Rogers dgr03@uark.edu
Dan Hagerty hag@gnu.ai.it.edu
Dan Pascu dan@services.iiruc.ro
Daniel Bergstrom noa@melody.se
Daniel Carpenter dansebpub@gmail.com
Daniel Mach dmach@redhat.com
Daniel P. Berrangé berrange@redhat.com
Daniel Stavrovski d@stavrovski.net

2
TODO
View File

@@ -143,7 +143,7 @@ pr's use of nstrftime can make it malloc a very large (up to SIZE_MAX) buffer
-----
Copyright (C) 2002-2024 Free Software Foundation, Inc.
Copyright (C) 2002-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

360
bootstrap
View File

@@ -3,9 +3,9 @@
# Bootstrap this package from checked-out sources.
scriptversion=2023-12-10.18; # UTC
scriptversion=2024-07-04.10; # UTC
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
# Copyright (C) 2003-2025 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -37,9 +37,9 @@ medir=`dirname "$me"`
# A library of shell functions for autopull.sh, autogen.sh, and bootstrap.
scriptlibversion=2023-12-10.18; # UTC
scriptlibversion=2024-11-12.21; # UTC
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
# Copyright (C) 2003-2025 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -478,10 +478,9 @@ find_tool ()
# --------------------- Preparing GNULIB_SRCDIR for use. ---------------------
# This is part of autopull.sh, but bootstrap needs it too, for self-upgrading.
# cleanup_gnulib fails, removing the directory $gnulib_path first.
cleanup_gnulib() {
status=$?
# XXX It's a bad idea to erase the submodule directory if it contains local
# modifications.
rm -fr "$gnulib_path"
exit $status
}
@@ -499,93 +498,141 @@ prepare_GNULIB_SRCDIR ()
test -f "$GNULIB_SRCDIR/gnulib-tool" \
|| die "Error: --gnulib-srcdir or \$GNULIB_SRCDIR is specified," \
"but does not contain gnulib-tool"
elif $use_git; then
if test -n "$GNULIB_REVISION" && $use_git; then
# The 'git checkout "$GNULIB_REVISION"' command succeeds if the
# GNULIB_REVISION is a commit hash that exists locally, or if it is
# branch name that can be fetched from origin. It fails, however,
# if the GNULIB_REVISION is a commit hash that only exists in
# origin. In this case, we need a 'git fetch' and then retry
# 'git checkout "$GNULIB_REVISION"'.
git -C "$GNULIB_SRCDIR" checkout "$GNULIB_REVISION" 2>/dev/null \
|| { git -C "$GNULIB_SRCDIR" fetch origin \
&& git -C "$GNULIB_SRCDIR" checkout "$GNULIB_REVISION"; } \
|| exit $?
fi
else
if ! $use_git; then
die "Error: --no-git is specified," \
"but neither --gnulib-srcdir nor \$GNULIB_SRCDIR is specified"
fi
if git submodule -h | grep -- --reference > /dev/null; then
:
else
die "git version is too old, git >= 1.6.4 is required"
fi
gnulib_path=$(git_modules_config submodule.gnulib.path)
test -z "$gnulib_path" && gnulib_path=gnulib
# Get gnulib files. Populate $gnulib_path, possibly updating a
# submodule, for use in the rest of the script.
if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git \
&& git_modules_config submodule.gnulib.url >/dev/null; then
# Use GNULIB_REFDIR as a reference.
echo "$0: getting gnulib files..."
if git submodule -h|grep -- --reference > /dev/null; then
# Prefer the one-liner available in git 1.6.4 or newer.
git submodule update --init --reference "$GNULIB_REFDIR" \
"$gnulib_path" || exit $?
if test -n "$gnulib_path"; then
# A submodule 'gnulib' is configured.
# Get gnulib files. Populate $gnulib_path, updating the submodule.
if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git; then
# Use GNULIB_REFDIR as a reference.
echo "$0: getting gnulib files..."
git submodule update --init --reference "$GNULIB_REFDIR" "$gnulib_path"\
|| exit $?
else
# This fallback allows at least git 1.5.5.
if test -f "$gnulib_path"/gnulib-tool; then
# Since file already exists, assume submodule init already complete.
# GNULIB_REFDIR is not set or not usable. Ignore it.
if git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
git submodule init -- "$gnulib_path" || exit $?
git submodule update -- "$gnulib_path" || exit $?
else
# Older git can't clone into an empty directory.
rmdir "$gnulib_path" 2>/dev/null
git clone --reference "$GNULIB_REFDIR" \
"$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
&& git submodule init -- "$gnulib_path" \
&& git submodule update -- "$gnulib_path" \
|| exit $?
die "Error: submodule 'gnulib' has no configured url"
fi
fi
else
# GNULIB_REFDIR is not set or not usable. Ignore it.
if git_modules_config submodule.gnulib.url >/dev/null; then
gnulib_path='gnulib'
if test ! -d "$gnulib_path"; then
# The subdirectory 'gnulib' does not yet exist. Clone into it.
echo "$0: getting gnulib files..."
git submodule init -- "$gnulib_path" || exit $?
git submodule update -- "$gnulib_path" || exit $?
elif [ ! -d "$gnulib_path" ]; then
echo "$0: getting gnulib files..."
trap cleanup_gnulib HUP INT PIPE TERM
shallow=
if test -z "$GNULIB_REVISION"; then
if git clone -h 2>&1 | grep -- --depth > /dev/null; then
shallow='--depth 2'
fi
git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \
|| cleanup_gnulib
gnulib_url=${GNULIB_URL:-$default_gnulib_url}
if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git; then
# Use GNULIB_REFDIR as a reference.
git clone "$GNULIB_REFDIR" "$gnulib_path" \
&& git -C "$gnulib_path" remote set-url origin "$gnulib_url" \
&& if test -z "$GNULIB_REVISION"; then
git -C "$gnulib_path" pull origin \
&& {
# We want the default branch of "$gnulib_url" (since that's
# the behaviour if GNULIB_REFDIR is not specified), not the
# current branch of "$GNULIB_REFDIR".
default_branch=`LC_ALL=C git -C "$gnulib_path" \
remote show origin \
| sed -n -e 's/^ *HEAD branch: //p'`
test -n "$default_branch" || default_branch='master'
git -C "$gnulib_path" checkout "$default_branch"
}
else
# The 'git checkout "$GNULIB_REVISION"' command succeeds if the
# GNULIB_REVISION is a commit hash that exists locally, or if it
# is a branch name that can be fetched from origin. It fails,
# however, if the GNULIB_REVISION is a commit hash that only
# exists in origin. In this case, we need a 'git fetch' and then
# retry 'git checkout "$GNULIB_REVISION"'.
git -C "$gnulib_path" checkout "$GNULIB_REVISION" 2>/dev/null \
|| { git -C "$gnulib_path" fetch origin \
&& git -C "$gnulib_path" checkout "$GNULIB_REVISION"; }
fi \
|| cleanup_gnulib
else
if git fetch -h 2>&1 | grep -- --depth > /dev/null; then
shallow='--depth 2'
# GNULIB_REFDIR is not set or not usable. Ignore it.
shallow=
if test -z "$GNULIB_REVISION"; then
if git clone -h 2>&1 | grep -- --depth > /dev/null; then
shallow='--depth 2'
fi
git clone $shallow "$gnulib_url" "$gnulib_path" \
|| cleanup_gnulib
else
if git fetch -h 2>&1 | grep -- --depth > /dev/null; then
shallow='--depth 2'
fi
mkdir -p "$gnulib_path"
# Only want a shallow checkout of $GNULIB_REVISION, but git does not
# support cloning by commit hash. So attempt a shallow fetch by
# commit hash to minimize the amount of data downloaded and changes
# needed to be processed, which can drastically reduce download and
# processing time for checkout. If the fetch by commit fails, a
# shallow fetch cannot be performed because we do not know what the
# depth of the commit is without fetching all commits. So fall back
# to fetching all commits.
git -C "$gnulib_path" init
git -C "$gnulib_path" remote add origin "$gnulib_url"
git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \
|| git -C "$gnulib_path" fetch origin \
|| cleanup_gnulib
git -C "$gnulib_path" reset --hard FETCH_HEAD
git -C "$gnulib_path" checkout "$GNULIB_REVISION" || cleanup_gnulib
fi
mkdir -p "$gnulib_path"
# Only want a shallow checkout of $GNULIB_REVISION, but git does not
# support cloning by commit hash. So attempt a shallow fetch by commit
# hash to minimize the amount of data downloaded and changes needed to
# be processed, which can drastically reduce download and processing
# time for checkout. If the fetch by commit fails, a shallow fetch can
# not be performed because we do not know what the depth of the commit
# is without fetching all commits. So fall back to fetching all
# commits.
git -C "$gnulib_path" init
git -C "$gnulib_path" remote add origin \
${GNULIB_URL:-$default_gnulib_url}
git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \
|| git -C "$gnulib_path" fetch origin \
|| cleanup_gnulib
git -C "$gnulib_path" reset --hard FETCH_HEAD
fi
trap - HUP INT PIPE TERM
else
# The subdirectory 'gnulib' already exists.
if test -n "$GNULIB_REVISION"; then
if test -d "$gnulib_path/.git"; then
# The 'git checkout "$GNULIB_REVISION"' command succeeds if the
# GNULIB_REVISION is a commit hash that exists locally, or if it
# is a branch name that can be fetched from origin. It fails,
# however, if the GNULIB_REVISION is a commit hash that only
# exists in origin. In this case, we need a 'git fetch' and then
# retry 'git checkout "$GNULIB_REVISION"'.
git -C "$gnulib_path" checkout "$GNULIB_REVISION" 2>/dev/null \
|| { git -C "$gnulib_path" fetch origin \
&& git -C "$gnulib_path" checkout "$GNULIB_REVISION"; } \
|| exit $?
else
die "Error: GNULIB_REVISION is specified in bootstrap.conf," \
"but '$gnulib_path' contains no git history"
fi
fi
fi
fi
GNULIB_SRCDIR=$gnulib_path
# Verify that the submodule contains a gnulib checkout.
# Verify that $gnulib_path contains a gnulib checkout.
test -f "$gnulib_path/gnulib-tool" \
|| die "Error: $gnulib_path is supposed to contain a gnulib checkout," \
|| die "Error: '$gnulib_path' is supposed to contain a gnulib checkout," \
"but does not contain gnulib-tool"
GNULIB_SRCDIR=$gnulib_path
fi
# XXX Should this be done if $use_git is false?
if test -d "$GNULIB_SRCDIR"/.git && test -n "$GNULIB_REVISION" \
&& ! git_modules_config submodule.gnulib.url >/dev/null; then
(cd "$GNULIB_SRCDIR" && git checkout "$GNULIB_REVISION") || cleanup_gnulib
fi
# $GNULIB_SRCDIR now points to the version of gnulib to use, and
# we no longer need to use git or $gnulib_path below here.
}
@@ -647,7 +694,8 @@ fi
autopull_usage() {
cat <<EOF
Usage: $me [OPTION]...
Bootstrap this package from the checked-out sources.
Bootstrap this package from the checked-out sources, phase 1:
Pull files from the network.
Optional environment variables:
GNULIB_SRCDIR Specifies the local directory where gnulib
@@ -664,18 +712,19 @@ Optional environment variables:
which is Gnulib's upstream repository.
Options:
--bootstrap-sync if this bootstrap script is not identical to
--bootstrap-sync If this bootstrap script is not identical to
the version in the local gnulib sources,
update this script, and then restart it with
/bin/sh or the shell \$CONFIG_SHELL
--no-bootstrap-sync do not check whether bootstrap is out of sync
--force attempt to bootstrap even if the sources seem
not to have been checked out
--no-git do not use git to update gnulib. Requires that
\$GNULIB_SRCDIR or the --gnulib-srcdir option
points to a gnulib repository with the correct
revision
--skip-po do not download po files
/bin/sh or the shell \$CONFIG_SHELL.
--no-bootstrap-sync Do not check whether bootstrap is out of sync.
--force Attempt to bootstrap even if the sources seem
not to have been checked out.
--no-git Do not use git to update gnulib. Requires that
\$GNULIB_SRCDIR points to a gnulib repository
with the correct revision.
--skip-po Do not download *.po files.
EOF
bootstrap_print_option_usage_hook
cat <<EOF
@@ -687,21 +736,21 @@ are honored.
Gnulib sources can be fetched in various ways:
* If the environment variable GNULIB_SRCDIR is set (either as an
environment variable or via the --gnulib-srcdir option), then sources
are fetched from that local directory. If it is a git repository and
the configuration variable GNULIB_REVISION is set in bootstrap.conf,
then that revision is checked out.
* If the environment variable GNULIB_SRCDIR is set, then sources are
fetched from that local directory. If it is a git repository and the
configuration variable GNULIB_REVISION is set in bootstrap.conf, then
that revision is checked out.
* Otherwise, if this package is in a git repository with a 'gnulib'
submodule configured, then that submodule is initialized and updated
and sources are fetched from there. If GNULIB_REFDIR is set (either
as an environment variable or via the --gnulib-refdir option) and is
a git repository, then it is used as a reference.
and sources are fetched from there. If the environment variable
GNULIB_REFDIR is set and is a git repository, then it is used as a
reference.
* Otherwise, if the 'gnulib' directory does not exist, Gnulib sources
are cloned into that directory using git from \$GNULIB_URL, defaulting
to $default_gnulib_url.
to $default_gnulib_url; if GNULIB_REFDIR is set and is a git repository
its contents may be used to accelerate the process.
If the configuration variable GNULIB_REVISION is set in bootstrap.conf,
then that revision is checked out.
@@ -869,9 +918,7 @@ update_po_files() {
&& ls "$ref_po_dir"/*.po 2>/dev/null |
sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
langs=$(cd $ref_po_dir && echo *.po | sed 's/\.po//g')
test "$langs" = '*' && langs=x
for po in $langs; do
for po in x $(ls $ref_po_dir | sed -n 's/\.po$//p'); do
case $po in x) continue;; esac
new_po="$ref_po_dir/$po.po"
cksum_file="$ref_po_dir/$po.s1"
@@ -890,7 +937,8 @@ update_po_files() {
autogen_usage() {
cat <<EOF
Usage: $me [OPTION]...
Bootstrap this package from the checked-out sources.
Bootstrap this package from the checked-out sources, phase 2:
Generate files from local files (no network access).
Optional environment variables:
GNULIB_SRCDIR Specifies the local directory where gnulib
@@ -899,9 +947,9 @@ Optional environment variables:
you want to use these sources.
Options:
--copy copy files instead of creating symbolic links
--force attempt to bootstrap even if the sources seem
not to have been checked out
--copy Copy files instead of creating symbolic links.
--force Attempt to bootstrap even if the sources seem
not to have been checked out.
EOF
bootstrap_print_option_usage_hook
cat <<EOF
@@ -1234,6 +1282,20 @@ autogen()
$gnulib_tool $gnulib_tool_options --import $gnulib_modules \
|| die "gnulib-tool failed"
if test $with_gettext = yes && test ! -f $m4_base/gettext.m4; then
# The gnulib-tool invocation has removed $m4_base/gettext.m4, that the
# AUTOPOINT invocation had installed. This can occur when the gnulib
# module 'gettext' was previously present but is now not present any more.
# Repeat the AUTOPOINT invocation and the gnulib-tool invocation.
echo "$0: $AUTOPOINT --force"
$AUTOPOINT --force || return
echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules \
|| die "gnulib-tool failed"
fi
for file in $gnulib_files; do
symlink_to_dir "$GNULIB_SRCDIR" $file \
|| die "failed to symlink $file"
@@ -1319,7 +1381,7 @@ autogen()
|| die 'cannot generate runtime-po/Makevars'
# Copy identical files from po to runtime-po.
(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
cp -p po/Makefile.in.in po/*-quot po/*.header po/*.sed po/*.sin runtime-po
fi
fi
@@ -1331,7 +1393,7 @@ autogen()
# ----------------------------------------------------------------------------
# Local Variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# eval: (add-hook 'before-save-hook 'time-stamp nil t)
# time-stamp-start: "scriptlibversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
@@ -1347,44 +1409,55 @@ Optional environment variables:
GNULIB_SRCDIR Specifies the local directory where gnulib
sources reside. Use this if you already
have gnulib sources on your machine, and
do not want to waste your bandwidth downloading
them again.
GNULIB_URL URL of the gnulib repository. The default is
$default_gnulib_url,
which is Gnulib's upstream repository.
Options:
--pull Do phase 1: pull files from network
--gen Do phase 2: generate from local files.
(The default is to do both phases.)
--gnulib-srcdir=DIRNAME specify the local directory where gnulib
sources reside. Use this if you already
have gnulib sources on your machine, and
you want to use these sources. Defaults
to \$GNULIB_SRCDIR
--gnulib-refdir=DIRNAME specify the local directory where a gnulib
you want to use these sources.
GNULIB_REFDIR Specifies the local directory where a gnulib
repository (with a .git subdirectory) resides.
Use this if you already have gnulib sources
and history on your machine, and do not want
to waste your bandwidth downloading them again.
Defaults to \$GNULIB_REFDIR
Only used for phase 1 (--pull).
GNULIB_URL URL of the gnulib repository. The default is
$default_gnulib_url,
which is Gnulib's upstream repository.
Only used for phase 1 (--pull).
--bootstrap-sync if this bootstrap script is not identical to
Options:
--pull Do phase 1: Pull files from the network.
--gen Do phase 2: Generate files from local files
(no network access).
(The default is to do both phases.)
--gnulib-srcdir=DIRNAME Specifies the local directory where gnulib
sources reside. Use this if you already
have gnulib sources on your machine, and
you want to use these sources. Defaults
to \$GNULIB_SRCDIR.
--gnulib-refdir=DIRNAME Specifies the local directory where a gnulib
repository (with a .git subdirectory) resides.
Use this if you already have gnulib sources
and history on your machine, and do not want
to waste your bandwidth downloading them again.
Defaults to \$GNULIB_REFDIR.
Only used for phase 1 (--pull).
--bootstrap-sync If this bootstrap script is not identical to
the version in the local gnulib sources,
update this script, and then restart it with
/bin/sh or the shell \$CONFIG_SHELL
--no-bootstrap-sync do not check whether bootstrap is out of sync
/bin/sh or the shell \$CONFIG_SHELL.
--no-bootstrap-sync Do not check whether bootstrap is out of sync.
--copy copy files instead of creating symbolic links
--force attempt to bootstrap even if the sources seem
not to have been checked out
--no-git do not use git to update gnulib. Requires that
--copy Copy files instead of creating symbolic links.
Only used for phase 2 (--gen).
--force Attempt to bootstrap even if the sources seem
not to have been checked out.
--no-git Do not use git to update gnulib. Requires that
\$GNULIB_SRCDIR or the --gnulib-srcdir option
points to a gnulib repository with the correct
revision
--skip-po do not download po files
revision.
Only used for phase 1 (--pull).
--skip-po Do not download *.po files.
Only used for phase 1 (--pull).
EOF
bootstrap_print_option_usage_hook
cat <<EOF
@@ -1396,11 +1469,11 @@ are honored.
Gnulib sources can be fetched in various ways:
* If the environment variable GNULIB_SRCDIR is set (either as an
environment variable or via the --gnulib-srcdir option), then sources
are fetched from that local directory. If it is a git repository and
the configuration variable GNULIB_REVISION is set in bootstrap.conf,
then that revision is checked out.
* If GNULIB_SRCDIR is set (either as an environment variable or via the
--gnulib-srcdir option), then sources are fetched from that local
directory. If it is a git repository and the configuration variable
GNULIB_REVISION is set in bootstrap.conf, then that revision is
checked out.
* Otherwise, if this package is in a git repository with a 'gnulib'
submodule configured, then that submodule is initialized and updated
@@ -1410,7 +1483,8 @@ Gnulib sources can be fetched in various ways:
* Otherwise, if the 'gnulib' directory does not exist, Gnulib sources
are cloned into that directory using git from \$GNULIB_URL, defaulting
to $default_gnulib_url.
to $default_gnulib_url; if GNULIB_REFDIR is set and is a git repository
its contents may be used to accelerate the process.
If the configuration variable GNULIB_REVISION is set in bootstrap.conf,
then that revision is checked out.
@@ -1521,16 +1595,16 @@ if $pull && { $use_git || test -z "$SKIP_PO"; }; then
fi
if $gen; then
autogen \
`if $copy; then echo ' --copy'; fi` \
`if test -z "$checkout_only_file"; then echo ' --force'; fi` \
|| die "could not generate auxiliary files"
autogen \
`if $copy; then echo ' --copy'; fi` \
`if test -z "$checkout_only_file"; then echo ' --force'; fi` \
|| die "could not generate auxiliary files"
fi
# ----------------------------------------------------------------------------
# Local Variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# eval: (add-hook 'before-save-hook 'time-stamp nil t)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"

View File

@@ -1,6 +1,6 @@
# Bootstrap configuration.
# Copyright (C) 2006-2024 Free Software Foundation, Inc.
# Copyright (C) 2006-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@ avoided_gnulib_modules='
gnulib_modules="
$avoided_gnulib_modules
acl
acl-permissions
alignalloc
alignasof
alloca
@@ -45,9 +46,9 @@ gnulib_modules="
backupfile
base32
base64
bool
btoc32
buffer-lcm
byteswap
c-strcase
c32iscntrl
c32isspace
@@ -64,7 +65,7 @@ gnulib_modules="
config-h
configmake
copy-file-range
count-leading-zeros
crc-x86_64
crypto/md5
crypto/sha1
crypto/sha256
@@ -77,8 +78,10 @@ gnulib_modules="
dirfd
dirname
do-release-commit-and-tag
dtimespec-bound
dtoastr
dup2
endian
environ
error
euidaccess
@@ -145,7 +148,7 @@ gnulib_modules="
idx
ignore-value
inttostr
inttypes
inttypes-h
isapipe
isatty
isblank
@@ -213,7 +216,7 @@ gnulib_modules="
pthread-mutex
pthread-thread
pthread_sigmask
putenv
putenv-gnu
quote
quotearg
randint
@@ -246,10 +249,12 @@ gnulib_modules="
stat-macros
stat-size
stat-time
stdbool
stdckdint
stdc_leading_zeros
stdc_trailing_zeros
stdckdint-h
stdlib-safer
stpcpy
str_endswith
strdup-posix
strnlen
strnumcmp
@@ -257,13 +262,14 @@ gnulib_modules="
strtoimax
strtoumax
symlinkat
sys_ioctl
sys_resource
sys_stat
sys_wait
sys_ioctl-h
sys_resource-h
sys_stat-h
sys_types-h
sys_wait-h
targetdir
tempname
termios
termios-h
time_rz
timer-time
timespec
@@ -309,6 +315,7 @@ gnulib_modules="
xstrtol-error
xstrtold
xstrtoumax
xvasprintf
year2038-recommended
yesno
"
@@ -384,6 +391,9 @@ bootstrap_post_import_hook ()
&& build-aux/gen-single-binary.sh src/local.mk >$tmp \
&& chmod a-w $tmp \
&& mv -f $tmp $mkf)
# Copy tests/init.sh from Gnulib.
$gnulib_tool --copy-file tests/init.sh
}

46
cfg.mk
View File

@@ -1,5 +1,5 @@
# Customize maint.mk -*- makefile -*-
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
# Copyright (C) 2003-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -48,7 +48,7 @@ export VERBOSE = yes
# 4914152 9e
export XZ_OPT = -8e
old_NEWS_hash = d66ee7a9fdb974017a4a17cf358d047d
old_NEWS_hash = be5016485c56f34b60ba4e6d3b407489
# Add an exemption for sc_makefile_at_at_check.
_makefile_at_at_check_exceptions = \
@@ -57,6 +57,11 @@ _makefile_at_at_check_exceptions = \
# Our help-version script is in a slightly different location.
_hv_file ?= $(srcdir)/tests/misc/help-version
world:
./bootstrap && \
./configure --quiet && \
$(MAKE) $(AM_MAKEFLAGS) -j $$(nproc 2>/dev/null || echo 1)
# Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
dd = $(srcdir)/src/dd.c
sc_dd_O_FLAGS:
@@ -116,7 +121,7 @@ sc_tests_list_consistency:
cd $(top_srcdir); \
$(SHELL) build-aux/vc-list-files tests \
| grep -Ev '^tests/(factor/(run|create-test)|init)\.sh$$' \
| grep -E "$$test_extensions_rx\$$"; \
| grep -E "($$test_extensions_rx)$$"; \
} | sort | uniq -u | grep . && exit 1; :
# Ensure that all version-controlled test scripts are executable.
@@ -493,6 +498,12 @@ sc_prohibit_NULL:
halt='use nullptr instead' \
$(_sc_search_regexp)
sc_prohibit_bare_set:
@prohibit='^ *set [`$$]' \
in_vc_files='\.sh$$' \
halt='use set -- $$args instead of set $$args' \
$(_sc_search_regexp)
# Don't use "indent-tabs-mode: nil" anymore. No longer needed.
sc_prohibit_emacs__indent_tabs_mode__setting:
@prohibit='^( *[*#] *)?indent-tabs-mode:' \
@@ -814,6 +825,21 @@ sc_gitignore_missing:
# sort | uniq -d | grep . && { echo '$(ME): Remove above' \
# 'entries from .gitignore' >&2; exit 1; } || :
# Ensure gl/ files are distributed
sc_gldist_missing:
@cd $(srcdir); \
grep '^gl/' gl/local.mk > $@.a; \
find gl '(' -name Makefile.am ')' -prune -o -type f \
'!' '(' -name '*.orig' -or -name '*~' -or \
-name 'ChangeLog.*' ')' -printf '%p\n' | \
LC_ALL=C sort | tr '\012' @ | sed 's/@$$/%/;s/@/ \\@/g' | \
tr @% '\012\012' > $@.e; \
diff -u $@.a $@.e; diff=$$?; \
rm -f $@.a $@.e; \
test "$$diff" = 0 \
|| { echo '$(ME): Inconsistent EXTRA_DIST in gl/local.mk'>&2; \
exit 1; }
sc_prohibit-form-feed:
@prohibit=$$'\f' \
in_vc_files='\.[chly]$$' \
@@ -900,7 +926,7 @@ exclude_file_name_regexp--sc_prohibit-gl-attributes = ^src/libstdbuf\.c$$
exclude_file_name_regexp--sc_prohibit_uppercase_id_est = \.diff$$
exclude_file_name_regexp--sc_ensure_dblspace_after_dot_before_id_est = \.diff$$
exclude_file_name_regexp--sc_ensure_comma_after_id_est = \.diff|$(_ll)$$
exclude_file_name_regexp--sc_long_lines = \.diff$$|$(_ll)|$(_cksum)
exclude_file_name_regexp--sc_long_lines = \.diff$$|$(_ll)|$(_cksum)|bootstrap
# `grep . -q` is not exactly equivalent to `grep . >/dev/null`
# and this difference is significant in the NEWS description
@@ -923,13 +949,15 @@ _gl_TS_unmarked_extern_functions = main usage
_gl_TS_unmarked_extern_functions += single_binary_main_.* _usage_.*
# Headers to search for single line extern _data_ declarations.
_gl_TS_other_headers = $(srcdir)/src/*.h src/*.h
# Tell the tight_scope rule about an exceptional "extern" variable.
# Normally, the rule would detect its declaration, but that uses a
# different name, __clz_tab.
_gl_TS_unmarked_extern_vars = factor_clz_tab
# Avoid tight_scope rule stating these should be static
# as there is no way to achieve that with the way these are defined.
_gl_TS_unmarked_extern_vars += ptr_MD5_.*
_gl_TS_unmarked_extern_vars = ptr_MD5_.*
# Other tight_scope settings
_gl_TS_dir = .
_gl_TS_obj_files = src/*.$(OBJEXT)
# Settings for running codespell.
csiwl_1 = debbugs,clen,te,bu,shs,linke,fo,souch,inout,outin
csiwl_2 = kno,ois,afile,whats,hda,indx,ot,nam
codespell_ignore_words_list = $(csiwl_1),$(csiwl_2)
exclude_file_name_regexp--sc_codespell = \
^(THANKS\.in|tests/pr/.*(F|tn?|l(o|m|i)|bl))$$

View File

@@ -1,7 +1,7 @@
# -*- autoconf -*-
# Process this file with autoconf to produce a configure script.
# Copyright (C) 1991-2024 Free Software Foundation, Inc.
# Copyright (C) 1991-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -198,7 +198,6 @@ if test $gl_gcc_warnings != no; then
nw="$nw -Wtraditional" # Warns on #elif which we use often
nw="$nw -Wcast-qual" # Too many warnings for now
nw="$nw -Wconversion" # Too many warnings for now
nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
nw="$nw -Wsign-conversion" # Too many warnings for now
nw="$nw -Wtraditional-conversion" # Too many warnings for now
nw="$nw -Wunreachable-code" # Too many warnings for now
@@ -206,8 +205,6 @@ if test $gl_gcc_warnings != no; then
nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
nw="$nw -Wswitch-enum" # Too many warnings for now
nw="$nw -Wswitch-default" # Too many warnings for now
nw="$nw -Wstack-protector" # not worth working around
nw="$nw -Wformat-overflow=2" # False alarms due to GCC bug 110333
nw="$nw -Wformat-truncation=2" # False alarm in ls.c, probably related
@@ -231,6 +228,7 @@ if test $gl_gcc_warnings != no; then
# Code like that still infloops with gcc-4.6.0 and -O2. Scary indeed.
gl_MANYWARN_ALL_GCC([ws])
AS_VAR_APPEND([ws], [' -Wswitch-enum'])
gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
for w in $ws; do
gl_WARN_ADD([$w])
@@ -259,6 +257,7 @@ if test $gl_gcc_warnings != no; then
nw=$ew
nw="$nw -Wduplicated-branches" # Too many false alarms
nw="$nw -Wformat-truncation=2"
nw="$nw -Wmissing-variable-declarations"
nw="$nw -Wstrict-overflow"
nw="$nw -Wuninitialized"
nw="$nw -Wunused-macros"
@@ -283,6 +282,7 @@ if test $gl_gcc_warnings != no; then
nw=
nw="$nw -Wstrict-prototypes"
# It's not worth being this picky about test programs.
nw="$nw -Wsuggest-attribute=cold"
nw="$nw -Wsuggest-attribute=const"
nw="$nw -Wsuggest-attribute=format"
nw="$nw -Wsuggest-attribute=pure"
@@ -366,8 +366,8 @@ AS_CASE([$LIB_CRYPTO],
[# Check for dlopen and libcrypto dynamic linking in one program,
# as there's little point to checking them separately.
AC_CACHE_CHECK([for dlopen and whether libcrypto is linked dynamically],
[utils_cv_dlopen_libcrypto],
[utils_cv_dlopen_libcrypto=no
[utils_cv_libcrypto_soname],
[utils_cv_libcrypto_soname=no
saved_LIBS=$LIBS
LIBS="$LIBS $LIB_DL $LIB_CRYPTO"
AC_LINK_IFELSE(
@@ -385,14 +385,14 @@ AS_CASE([$LIB_CRYPTO],
sed -n 's/.*\(libcrypto\.so\.[[.0-9]]*\).*/\1/p'`"
AS_CASE([$LIBCRYPTO_SONAME],
[*libcrypto*],
[utils_cv_dlopen_libcrypto=yes])])
[utils_cv_libcrypto_soname=$LIBCRYPTO_SONAME])])
LIBS=$saved_LIBS])
AS_CASE([$utils_cv_dlopen_libcrypto],
[yes],
AS_CASE([$utils_cv_libcrypto_soname],
[*libcrypto*],
[AC_DEFINE([DLOPEN_LIBCRYPTO], [1],
[Define to 1 if dlopen exists and libcrypto is
linked dynamically.])
AC_DEFINE_UNQUOTED([LIBCRYPTO_SONAME], ["$LIBCRYPTO_SONAME"],
AC_DEFINE_UNQUOTED([LIBCRYPTO_SONAME], ["$utils_cv_libcrypto_soname"],
[versioned libcrypto])
])])
@@ -617,6 +617,40 @@ if test $utils_cv_brain_16_bit_supported = yes; then
AC_DEFINE([BF16_SUPPORTED], [1], [Brain 16 bit float supported])
fi
ac_save_CFLAGS=$CFLAGS
CFLAGS="-march=armv8-a+crypto $CFLAGS"
AC_MSG_CHECKING([if vmull intrinsic exists])
AC_CACHE_VAL([utils_cv_vmull_intrinsic_exists],[
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <stdio.h>
#include <sys/auxv.h>
#include <asm/hwcap.h>
#include <arm_neon.h>
int
main (void)
{
uint64x2_t a;
poly64_t shift64 = vget_lane_p64(vcreate_p64(0xB8BC6765), 0);
a = vreinterpretq_u64_p128(vmull_p64(shift64, vreinterpretq_p128_u64(a)));
return (getauxval(AT_HWCAP) & HWCAP_PMULL) > 0;
}
]])
],[
utils_cv_vmull_intrinsic_exists=yes
],[
utils_cv_vmull_intrinsic_exists=no
])])
AC_MSG_RESULT([$utils_cv_vmull_intrinsic_exists])
if test $utils_cv_vmull_intrinsic_exists = yes; then
AC_DEFINE([USE_VMULL_CRC32], [1],
[CRC32 calculation by vmull hardware instruction enabled])
fi
AM_CONDITIONAL([USE_VMULL_CRC32],
[test $utils_cv_vmull_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
ac_save_CFLAGS=$CFLAGS
CFLAGS="-mavx -mpclmul $CFLAGS"
AC_MSG_CHECKING([if pclmul intrinsic exists])
@@ -648,6 +682,74 @@ AM_CONDITIONAL([USE_PCLMUL_CRC32],
[test $utils_cv_pclmul_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
ac_save_CFLAGS=$CFLAGS
CFLAGS=" -mavx2 -mvpclmulqdq $CFLAGS"
AC_MSG_CHECKING([if avx2 pclmul intrinsic exists])
AC_CACHE_VAL([utils_cv_avx2_pclmul_intrinsic_exists],[
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <x86intrin.h>
int
main (void)
{
__m256i a, b;
a = _mm256_clmulepi64_epi128 (a, b, 0x00);
a = _mm256_shuffle_epi8 (a, b);
return __builtin_cpu_supports ("avx2") &&
__builtin_cpu_supports ("vpclmulqdq");
}
]])
],[
utils_cv_avx2_pclmul_intrinsic_exists=yes
],[
utils_cv_avx2_pclmul_intrinsic_exists=no
])])
AC_MSG_RESULT([$utils_cv_avx2_pclmul_intrinsic_exists])
if test $utils_cv_avx2_pclmul_intrinsic_exists = yes; then
AC_DEFINE([USE_AVX2_CRC32], [1],
[CRC32 calculation by avx2 hardware instructions enabled])
fi
AM_CONDITIONAL([USE_AVX2_CRC32],
[test $utils_cv_avx2_pclmul_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
ac_save_CFLAGS=$CFLAGS
CFLAGS=" -mavx512bw -mavx512f -mvpclmulqdq $CFLAGS"
AC_MSG_CHECKING([if avx512 pclmul intrinsic exists])
AC_CACHE_VAL([utils_cv_avx512_pclmul_intrinsic_exists],[
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <x86intrin.h>
int
main (void)
{
__m512i a, b;
a = _mm512_set_epi8 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
a = _mm512_clmulepi64_epi128 (a, b, 0x00);
a = _mm512_shuffle_epi8 (a, b);
return __builtin_cpu_supports ("avx512bw") &&
__builtin_cpu_supports ("avx512f");
}
]])
],[
utils_cv_avx512_pclmul_intrinsic_exists=yes
],[
utils_cv_avx512_pclmul_intrinsic_exists=no
])])
AC_MSG_RESULT([$utils_cv_avx512_pclmul_intrinsic_exists])
if test $utils_cv_avx512_pclmul_intrinsic_exists = yes; then
AC_DEFINE([USE_AVX512_CRC32], [1],
[CRC32 calculation by avx512 hardware instructions enabled])
fi
AM_CONDITIONAL([USE_AVX512_CRC32],
[test $utils_cv_avx512_pclmul_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
CFLAGS="-mavx2 $CFLAGS"
AC_MSG_CHECKING([for avx2 intrinsics])
AC_CACHE_VAL([utils_cv_avx2_intrinsic_exists],[
@@ -658,8 +760,9 @@ AC_LINK_IFELSE(
int
main (void)
{
__m256i a, b;
a = _mm256_sad_epu8 (a, b);
__m256i matches = _mm256_setzero_si256 ();
int mask = _mm256_movemask_epi8 (matches);
int lines = __builtin_popcount (mask);
return __builtin_cpu_supports ("avx2");
}
]])

View File

@@ -148,7 +148,7 @@
This manual documents version @value{VERSION} of the GNU core
utilities, including the standard programs for text and file manipulation.
Copyright @copyright{} 1994--2024 Free Software Foundation, Inc.
Copyright @copyright{} 1994--2025 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
@@ -1083,8 +1083,16 @@ apparent file sizes, whereas the @option{--block-size} option does.
A @var{signal} may be a signal name like @samp{HUP}, or a signal
number like @samp{1}, or an exit status of a process terminated by the
signal. A signal name can be given in canonical form or prefixed by
@samp{SIG}@. The case of the letters is ignored. The following signal names
and numbers are supported on all POSIX compliant systems:
@samp{SIG}@. The case of the letters is ignored.
@noindent
The signal @samp{0} pseudo signal is synonymous with the name @samp{EXIT}
with the GNU @command{kill} command, and @command{bash} at least,
as @code{trap foo 0} and @code{trap foo EXIT} are equivalent.
@noindent
The following signal names and numbers are supported
on all POSIX compliant systems:
@table @samp
@item HUP
@@ -1552,7 +1560,7 @@ case-insensitive @code{inf}, @code{infinity}, and @code{NaN}, although
whether such values are useful depends on the command in question.
Modern C implementations also accept hexadecimal floating point
numbers such as @code{-0x.ep-3}, which stands for @minus{}14/16 times
@math{2^-3}, which equals @minus{}0.109375. @xref{Parsing of
@math{2^{-3}}, which equals @minus{}0.109375. @xref{Parsing of
Floats,,, libc, The GNU C Library Reference Manual}.
@vindex LC_NUMERIC
@@ -4051,7 +4059,8 @@ and the file name unless no arguments were given.
The 32-bit CRC used is based on the polynomial used
for CRC error checking in the ISO/IEC 8802-3:1996 standard (Ethernet).
Similar output formats are used for the other legacy checksums
selectable with @option{--algorithm=sysv} or @option{--algorithm=bsd},
selectable with @option{--algorithm=crc32b}, and
@option{--algorithm=sysv} or @option{--algorithm=bsd}
detailed at @ref{sum invocation}.
@item Tagged output format
@@ -4100,6 +4109,7 @@ Supported legacy checksums (which are not supported by @option{--check}):
@samp{sysv} equivalent to @command{sum -s}
@samp{bsd} equivalent to @command{sum -r}
@samp{crc} equivalent to @command{cksum} (the default)
@samp{crc32b} only available through @command{cksum}
@end example
Supported more modern digest algorithms are:
@@ -4151,7 +4161,7 @@ as the length is automatically determined when checking.
Print only the unencoded raw binary digest for a single input.
Do not output the file name or anything else.
Use network byte order (big endian) where applicable:
for @samp{bsd}, @samp{crc}, and @samp{sysv}.
for @samp{bsd}, @samp{crc}, @samp{crc32b}, and @samp{sysv}.
This option works only with a single input.
Unlike other output formats, @command{cksum} provides no way to
@option{--check} a @option{--raw} checksum.
@@ -4225,7 +4235,7 @@ a checksum inconsistent with the associated file, or if no valid
line is found, @command{cksum} exits with nonzero status. Otherwise,
it exits successfully.
The @command{cksum} command does not support @option{--check}
with the older @samp{sysv}, @samp{bsd}, or @samp{crc} algorithms.
with the older @samp{sysv}, @samp{bsd}, @samp{crc} or @samp{crc32b} algorithms.
@item --ignore-missing
@opindex --ignore-missing
@@ -5151,12 +5161,22 @@ Use the common DSU, Decorate Sort Undecorate idiom to
sort lines according to their length.
@example
awk '@{print length, $0@}' /etc/passwd | sort -n | cut -f2- -d' '
getent passwd |@/
awk '@{print length, $0@}' | sort -n | cut -f2- -d' '
@end example
In general this technique can be used to sort data that the @command{sort}
command does not support, or is inefficient at, sorting directly.
@item
Use the same DSU idiom as above to sort lines by their last field,
and in this specific example the presented lines are users' full names.
@example
getent passwd | grep -v nologin | cut -d: -f5 | grep ' ' |@/
awk '@{print $NF, $0@}' | sort -k1,1 | cut -f2- -d' '
@end example
@item
Shuffle a list of directories, but preserve the order of files within
each directory. For instance, one could use this to generate a music
@@ -7630,7 +7650,8 @@ non-option argument is specified, @command{ls} operates on the current
directory, acting as if it had been invoked with a single argument of @samp{.}.
@vindex LC_ALL
By default, the output is sorted alphabetically, according to the locale
By default, @command{ls} lists each directory's contents alphabetically,
according to the locale
settings in effect.@footnote{If you use a non-POSIX
locale (e.g., by setting @env{LC_ALL} to @samp{en_US}), then @command{ls} may
produce output that is sorted differently than you're accustomed to.
@@ -7737,16 +7758,6 @@ or any of the following options is in effect:
@option{--dereference} (@option{-L}), or
@option{--dereference-command-line} (@option{-H})).
@item --group-directories-first
@opindex --group-directories-first
Group all the directories before the files and then sort the
directories and the files separately using the selected sort key
(see @option{--sort} option).
That is, this option specifies a primary sort key,
and the @option{--sort} option specifies a secondary key.
However, any use of @option{--sort=none}
(@option{-U}) disables this option altogether.
@item --hide=PATTERN
@opindex --hide=@var{pattern}
In directories, ignore files whose names match the shell pattern
@@ -8073,6 +8084,10 @@ with a security context, but no other alternate access method.
A file with any other combination of alternate access methods
is marked with a @samp{+} character.
@command{ls} uses a @samp{?} character to indicate it is unable to determine
whether alternate access methods apply to the file, which may happen for
example with some NFS setups with files without read permission.
@item -n
@itemx --numeric-uid-gid
@opindex -n
@@ -8127,9 +8142,12 @@ In long format, print the security context to the left of the size column.
@subsection Sorting the output
@cindex sorting @command{ls} output
These options change the order in which @command{ls} sorts the information
it outputs. By default, sorting is done by character code
(e.g., ASCII order).
@vindex LC_COLLATE
These options change the order in which @command{ls} outputs
information for the files in a directory.
(Command-line operands are always processed left to right.)
By default, files are sorted alphabetically by name, using the
character collating sequence specified by the @env{LC_COLLATE} locale.
@table @samp
@@ -8150,11 +8168,19 @@ sort according to the ctime. @xref{File timestamps}.
@opindex -f
@cindex unsorted directory listing
@cindex directory order, listing by
Produce an unsorted directory listing.
This is like @option{--sort=none} (@option{-U}),
but also enable @option{--all} (@option{-a}),
while also disabling any previous use of @option{-l}, @option{--color}
@option{--size}, or @option{--hyperlink}.
Do not sort, and list all files.
This is like @option{--sort=none} (@option{-U}) combined
with @option{--all} (@option{-a}).
@item --group-directories-first
@opindex --group-directories-first
When listing a directory's files,
group all subdirectories before non-directories
and then sort the subdirectories and the non-directories separately.
That is, this option specifies a primary sort key,
and the other sorting options specify a secondary key.
However, any use of @option{--sort=none}
(@option{-U}) disables this option altogether.
@item -r
@itemx --reverse
@@ -8224,10 +8250,12 @@ sort according to the birth time.
@opindex --sort
@opindex none@r{, sorting option for @command{ls}}
Do not sort; list the files in whatever order they are
stored in the directory. (Do not do any of the other unrelated things
that @option{-f} does.) This can be useful when listing large
stored in the directory. This can be useful when listing large
directories, where sorting can take some time.
Unlike @option{-f}, this option does not imply @option{--all}
(@option{-a}).
@item -v
@itemx --sort=version
@opindex -v
@@ -8237,6 +8265,13 @@ Sort by version name and number, lowest first. It behaves like a default
sort, except that each sequence of decimal digits is treated numerically
as an index/version number. @xref{Version sort ordering}.
@item --sort=name
@opindex --sort
@opindex name@r{, sorting option for @command{ls}}
Sort by file name. This is the default operation of @command{ls},
and can be explicitly specified to override any
previously specified sorting option.
@item --sort=width
@opindex --sort
@opindex width@r{, sorting option for @command{ls}}
@@ -8308,6 +8343,7 @@ Specifying @option{--color} and no @var{when} is equivalent to
@option{--color=always}.
If piping a colored listing through a pager like @command{less},
use the pager's @option{-R} option to pass the color codes to the terminal.
@xref{dircolors invocation} to configure the colors used.
@vindex LS_COLORS
@vindex SHELL @r{environment variable, and color}
@@ -8391,7 +8427,7 @@ Specifying @option{--hyperlink} and no @var{when} is equivalent to
@item --indicator-style=@var{word}
@opindex --indicator-style
Append a character indicator with style @var{word} to entry names,
Append a character indicator with style @var{word} to file names,
as follows:
@table @samp
@@ -8419,6 +8455,7 @@ overriding any contrary specification in environment variables
(@pxref{Block size}). If @option{--block-size},
@option{--human-readable} (@option{-h}), or @option{--si} options are used,
they take precedence even if @option{--kibibytes} (@option{-k}) is placed after
the other options.
The @option{--kibibytes} (@option{-k}) option affects the
per-directory block count written in long format,
@@ -8692,7 +8729,7 @@ like @command{csh}.
Quote strings for the shell, even if they would normally not require quoting.
@item shell-escape
Like @samp{shell}, but also quoting non-printable characters using the POSIX
proposed @samp{$''} syntax suitable for most shells.
@samp{$''} syntax suitable for most shells.
@item shell-escape-always
Like @samp{shell-escape}, but quote strings even if they would
normally not require quoting.
@@ -8700,6 +8737,9 @@ normally not require quoting.
Quote strings as for C character string literals, including the
surrounding double-quote characters; this is the same as the
@option{--quote-name} (@option{-Q}) option.
@item c-maybe
Quote strings as for C character string literals, except omit the
surrounding double-quote if no escaping is required.
@item escape
Quote strings as for C character string literals, except omit the
surrounding double-quote
@@ -10246,7 +10286,7 @@ The program accepts the following options. Also see @ref{Common options}.
@opindex -f
@opindex --force
@cindex prompts, omitting
Do not prompt the user before removing a destination file.
Do not prompt the user before replacing a destination file.
@macro mvOptsIfn
If you specify more than one of the @option{-i}, @option{-f}, @option{-n}
options, only the final one takes effect.
@@ -13383,10 +13423,12 @@ printf @var{format} [@var{argument}]@dots{}
@command{printf} prints the @var{format} string, interpreting @samp{%}
directives and @samp{\} escapes to format numeric and string arguments
in a way that is mostly similar to the C @samp{printf} function.
in a way that is mostly similar to the C @samp{printf} function,
and C language escape sequence processing.
@xref{Output Conversion Syntax,, @command{printf} format directives,
libc, The GNU C Library Reference Manual}, for details.
The differences are listed below.
See also @uref{https://en.cppreference.com/w/c/language/escape,
C99 string escapes:}. The differences are listed below.
@mayConflictWithShellBuiltIn{printf}
@@ -13402,6 +13444,15 @@ Missing @var{argument}s are treated as null strings or as zeros,
depending on whether the context expects a string or a number. For
example, the command @samp{printf %sx%d} prints @samp{x0}.
@item
Indexed arguments referenced with @samp{%...$} formats, can be
mixed with standard sequential argument references,
in which case both index types are independent.
For example, the command @samp{printf '%1$s%s' A} prints @samp{AA}.
Also the highest referenced argument, either indexed or sequential,
is considered to be the last one referenced, when determining
unused arguments for reprocessing with the @var{format} argument.
@item
@kindex \c
An additional escape, @samp{\c}, causes @command{printf} to produce no
@@ -13419,9 +13470,9 @@ one.
@kindex %b
An additional directive @samp{%b}, prints its
argument string with @samp{\} escapes interpreted in the same way as in
the @var{format} string, except that octal escapes are of the form
@samp{\0@var{ooo}} where @var{ooo} is 0 to 3 octal digits. If
@samp{\@var{ooo}} is nine-bit value, ignore the ninth bit.
the @var{format} string, except that octal escapes should have a leading
@samp{0} like @samp{\0@var{nnn}}.
If @samp{@var{nnn}} is a nine-bit value, ignore the ninth bit.
If a precision is also given, it limits the number of bytes printed
from the converted string.
@@ -13429,7 +13480,7 @@ from the converted string.
@kindex %q
An additional directive @samp{%q}, prints its argument string
in a format that can be reused as input by most shells.
Non-printable characters are escaped with the POSIX proposed @samp{$''} syntax,
Non-printable characters are escaped with the POSIX @samp{$''} syntax,
and shell metacharacters are quoted appropriately.
This is an equivalent format to @command{ls --quoting=shell-escape} output.
@@ -13696,7 +13747,7 @@ Exit status:
* File type tests:: @code{-[bcdfhLpSt]}
* Access permission tests:: @code{-[gkruwxOG]}
* File characteristic tests:: @code{-e -s -nt -ot -ef}
* String tests:: @code{-z -n = == !=}
* String tests:: @code{-z -n = == != > <}
* Numeric tests:: @code{-eq -ne -lt -le -gt -ge}
* Connectives for test:: @code{! -a -o}
@end menu
@@ -13905,6 +13956,16 @@ shells and systems.
@cindex not-equal string check
True if the strings are not equal.
@item @var{string1} > @var{string2}
@opindex >
@cindex greater-than string check
True if @var{string1} is greater than @var{string2} in the current locale.
@item @var{string1} < @var{string2}
@opindex <
@cindex less-than string check
True if @var{string1} is less than @var{string2} in the current locale.
@end table
@@ -14742,7 +14803,7 @@ and print its name. If given, @var{template} must include at least
three consecutive @samp{X}s in the last component. If omitted, the template
@samp{tmp.XXXXXXXXXX} is used, and option @option{--tmpdir} is
implied. The final run of @samp{X}s in the @var{template} will be replaced
by alpha-numeric characters; thus, on a case-sensitive file system,
by alphanumeric characters; thus, on a case-sensitive file system,
and with a @var{template} including a run of @var{n} instances of @samp{X},
there are @samp{62**@var{n}} potential file names.
@@ -15818,13 +15879,14 @@ Set the output speed to @var{n}.
@item rows @var{n}
@opindex rows
Tell the tty kernel driver that the terminal has @var{n} rows.
Non-POSIX.
@item cols @var{n}
@itemx columns @var{n}
@opindex cols
Tell the kernel that the terminal has @var{n} columns.
@item columns @var{n}
@opindex columns
Tell the kernel that the terminal has @var{n} columns. Non-POSIX.
Same as @samp{cols}. Non-POSIX.
@item drain
@opindex drain
@@ -15849,7 +15911,6 @@ Print the number of rows and columns that the kernel thinks the
terminal has. (Systems that don't support rows and columns in the kernel
typically use the environment variables @env{LINES} and @env{COLUMNS}
instead; however, GNU @command{stty} does not know anything about them.)
Non-POSIX.
@item line @var{n}
@opindex line
@@ -16599,7 +16660,9 @@ It is normally at least two characters, but it may be more.
@item %d
day of month (e.g., @samp{01})
@item %D
date; same as @samp{%m/%d/%y}
date; same as @samp{%m/%d/%y}.
Although commonly used in the US, this format is confusing elsewhere,
and it is ambiguous for dates in different centuries.
@item %e
day of month, space padded; same as @samp{%_d}
@item %F
@@ -16615,6 +16678,7 @@ year corresponding to the ISO week number, but without the century
as @samp{%y}, except that if the ISO week number (see
@samp{%V}) belongs
to the previous or next year, that year is used instead.
This format is ambiguous for dates in different centuries.
@item %G
year corresponding to the ISO week number. This has the
same format and value as @samp{%Y}, except that if the ISO
@@ -16653,9 +16717,11 @@ week number of year, with Monday as first day of week
(@samp{00}@dots{}@samp{53}).
Days in a new year preceding the first Monday are in week zero.
@item %x
locale's date representation (e.g., @samp{12/31/99})
locale's date representation (e.g., @samp{12/31/99}).
This format can be ambiguous for dates in different centuries.
@item %y
last two digits of year (@samp{00}@dots{}@samp{99})
last two digits of year (@samp{00}@dots{}@samp{99}).
This format is ambiguous for dates in different centuries.
@item %Y
year. This is normally at least four characters, but it may be more.
Year @samp{0000} precedes year @samp{0001}, and year @samp{-001}
@@ -18773,13 +18839,9 @@ The program accepts the following options. Also see @ref{Common options}.
Options must precede operands.
@table @samp
@item --preserve-status
@opindex --preserve-status
Return the exit status of the managed @var{command} on timeout, rather than
a specific exit status indicating a timeout. This is useful if the
managed @var{command} supports running for an indeterminate amount of time.
@item --foreground
@item -f
@itemx --foreground
@opindex -f
@opindex --foreground
Don't create a separate background program group, so that
the managed @var{command} can use the foreground TTY normally.
@@ -18819,6 +18881,14 @@ either because the signal was blocked or ignored, or if the @var{command} takes
too long (e.g. for cleanup work) to terminate itself within a certain amount
of time.
@item -p
@itemx --preserve-status
@opindex -p
@opindex --preserve-status
Return the exit status of the managed @var{command} on timeout, rather than
a specific exit status indicating a timeout. This is useful if the
managed @var{command} supports running for an indeterminate amount of time.
@item -s @var{signal}
@itemx --signal=@var{signal}
@opindex -s
@@ -18843,6 +18913,11 @@ C locale (@pxref{Floating point}) followed by an optional unit:
@samp{h} for hours
@samp{d} for days
@end display
@macro hexDuration
A hexadecimal number can precede a @samp{d} suffix only if the number
has a @samp{p} style exponent, e.g., @samp{0x1p0d} means one day.
@end macro
@hexDuration
A duration of 0 disables the associated timeout.
The actual timeout duration is dependent on system conditions,
which should be especially considered when specifying sub-second timeouts.
@@ -19019,6 +19094,8 @@ non-negative integer argument without a suffix, GNU @command{sleep}
also accepts two or more arguments, unit suffixes, and floating-point
numbers in either the current or the C locale. @xref{Floating point}.
@hexDuration
For instance, the following could be used to @command{sleep} for
1 second, 234 milli-, 567 micro- and 890 nanoseconds:

View File

@@ -1,7 +1,7 @@
# Make coreutils documentation. -*-Makefile-*-
# This is included by the top-level Makefile.am.
# Copyright (C) 1995-2024 Free Software Foundation, Inc.
# Copyright (C) 1995-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

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

View File

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

View File

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

View File

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

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

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

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
/* Include and determine availability of smack routines
Copyright (C) 2013-2024 Free Software Foundation, Inc.
Copyright (C) 2013-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

81
gl/local.mk Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

2
gnulib

Submodule gnulib updated: 259829e78b...41e7b7e0d1

View File

@@ -1,6 +1,6 @@
# This file is sourced by init.sh, *before* its initialization.
# Copyright (C) 2010-2024 Free Software Foundation, Inc.
# Copyright (C) 2010-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -178,6 +178,8 @@ ulimit_supported_()
v="$1"
shift
local ulimit_start_=$(date +%s) || skip_ 'ulimit: date error'
(
# Try to disable core dumps which may
# occur with memory constraints
@@ -185,6 +187,16 @@ ulimit_supported_()
ulimit -v $v && "$@"
) >/dev/null 2>&1
ret=$?
local ulimit_end_=$(date +%s) || skip_ 'ulimit: date error'
# This can happen on Solaris 11 at least where fork() can give EAGAIN
# and bash will retry for at least 16 seconds
test $(($ulimit_end_ - $ulimit_start_)) -ge 10 && skip_ 'ulimit too slow'
return $ret
}
# Determine the minimum required VM limit to run the given command.
@@ -200,11 +212,15 @@ get_min_ulimit_v_()
page_size=$(($page_size / 1024))
for v in $( seq 5000 5000 50000 ); do
if ulimit_supported_ $v "$@"; then
ulimit_supported_ $v "$@"; ret=$?
test $ret = 77 && break;
if test $ret = 0; then
local prev_v
prev_v=$v
for v in $( seq $(($prev_v-1000)) -1000 1000 ); do
ulimit_supported_ $v "$@" ||
ulimit_supported_ $v "$@"; ret=$?
test $ret = 77 && break 2;
test $ret = 0 ||
{
ret_v=$((prev_v + $page_size))
echo $ret_v
@@ -570,7 +586,7 @@ seek_data_capable_()
# We saw FreeBSD 9.1 take 35s to return from SEEK_DATA for a 1TiB empty file.
# Note lseek() is uninterruptible on FreeBSD 9.1, but it does eventually
# return, and the timeout will ensure a failure return from the process.
timeout --version >/dev/null && TIMEOUT_='timeout 10'
timeout 1 true >/dev/null && TIMEOUT_='timeout 10'
$TIMEOUT_ $PYTHON_ "$abs_srcdir"/tests/seek-data-capable "$@"
}
@@ -660,7 +676,7 @@ mkfifo_or_skip_()
trap_sigpipe_or_skip_()
{
timeout --version >/dev/null ||
timeout 1 true >/dev/null ||
skip_ 'trapping SIGPIPE cannot be safely checked'
(trap '' PIPE && timeout 10 yes |:) 2>&1 | grep 'Broken pipe' >/dev/null ||

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
/* Base64, base32, and similar encoding/decoding strings or files.
Copyright (C) 2004-2024 Free Software Foundation, Inc.
Copyright (C) 2004-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -325,10 +325,8 @@ static void
prepare_inbuf (struct base_decode_context *ctx, idx_t inlen)
{
if (ctx->bufsize < inlen)
{
ctx->bufsize = inlen * 2;
ctx->inbuf = xnrealloc (ctx->inbuf, ctx->bufsize, sizeof (char));
}
ctx->inbuf = xpalloc (ctx->inbuf, &ctx->bufsize,
inlen - ctx->bufsize, -1, sizeof *ctx->inbuf);
}
@@ -628,7 +626,7 @@ static void
base16_encode (char const *restrict in, idx_t inlen,
char *restrict out, idx_t outlen)
{
static const char base16[16] = "0123456789ABCDEF";
static const char base16[16] _GL_ATTRIBUTE_NONSTRING = "0123456789ABCDEF";
while (inlen && outlen)
{
@@ -713,7 +711,7 @@ isuz85 (unsigned char ch)
return c_isalnum (ch) || strchr (".-:+=^!/*?&<>()[]{}@%$#", ch) != nullptr;
}
static char const z85_encoding[85] =
static char const z85_encoding[85] _GL_ATTRIBUTE_NONSTRING =
"0123456789"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -1138,7 +1136,7 @@ do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
idx_t sum;
struct base_decode_context ctx;
char padbuf[8] = "========";
char padbuf[8] _GL_ATTRIBUTE_NONSTRING = "========";
inbuf = xmalloc (BASE_LENGTH (DEC_BLOCKSIZE));
outbuf = xmalloc (DEC_BLOCKSIZE);

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
/* chown-core.h -- types and prototypes shared by chown and chgrp.
Copyright (C) 2000-2024 Free Software Foundation, Inc.
Copyright (C) 2000-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/* chown, chgrp -- change user and group ownership of files
Copyright (C) 1989-2024 Free Software Foundation, Inc.
Copyright (C) 1989-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -121,7 +121,7 @@ With --reference, change the group of each FILE to that of RFILE.\n\
--preserve-root fail to operate recursively on '/'\n\
"), stdout);
fputs (_("\
--reference=RFILE use RFILE's ownership rather than specifying values\n\
--reference=RFILE use RFILE's ownership rather than specifying values.\n\
RFILE is always dereferenced if a symbolic link.\n\
"), stdout);
fputs (_("\

View File

@@ -1,5 +1,5 @@
/* chroot -- run command or shell with special root directory
Copyright (C) 1995-2024 Free Software Foundation, Inc.
Copyright (C) 1995-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -93,11 +93,11 @@ setgroups (size_t size, MAYBE_UNUSED gid_t const *list)
static int
parse_additional_groups (char const *groups, GETGROUPS_T **pgids,
size_t *pn_gids, bool show_errors)
idx_t *pn_gids, bool show_errors)
{
GETGROUPS_T *gids = nullptr;
size_t n_gids_allocated = 0;
size_t n_gids = 0;
idx_t n_gids_allocated = 0;
idx_t n_gids = 0;
char *buffer = xstrdup (groups);
char const *tmp;
int ret = 0;
@@ -143,7 +143,7 @@ parse_additional_groups (char const *groups, GETGROUPS_T **pgids,
}
if (n_gids == n_gids_allocated)
gids = X2NREALLOC (gids, &n_gids_allocated);
gids = xpalloc (gids, &n_gids_allocated, 1, -1, sizeof *gids);
gids[n_gids++] = value;
}
@@ -230,7 +230,7 @@ main (int argc, char **argv)
uid_t uid = -1;
gid_t gid = -1;
GETGROUPS_T *out_gids = nullptr;
size_t n_gids = 0;
idx_t n_gids = 0;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
@@ -251,7 +251,7 @@ main (int argc, char **argv)
/* Treat 'user:' just like 'user'
as we lookup the primary group by default
(and support doing so for UIDs as well as names. */
size_t userlen = strlen (userspec);
idx_t userlen = strlen (userspec);
if (userlen && userspec[userlen - 1] == ':')
userspec[userlen - 1] = '\0';
break;
@@ -375,7 +375,8 @@ main (int argc, char **argv)
else if (gid_unset (gid))
{
error (EXIT_CANCELED, errno,
_("no group specified for unknown uid: %d"), (int) uid);
_("no group specified for unknown uid: %ju"),
(uintmax_t) uid);
}
}

View File

@@ -1,5 +1,5 @@
/* cksum -- calculate and print POSIX checksums and sizes of files
Copyright (C) 1992-2024 Free Software Foundation, Inc.
Copyright (C) 1992-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
do something like the following:
cc -I../lib -DCRCTAB -o crctab cksum.c
crctab > crctab.c
./crctab > crctab.c
This software is compatible with neither the System V nor the BSD
'sum' program. It is supposed to conform to POSIX, except perhaps
@@ -34,21 +34,11 @@
#include <config.h>
#include <stdio.h>
#include <sys/types.h>
#include <stdint.h>
#include "system.h"
#include <byteswap.h>
#ifdef WORDS_BIGENDIAN
# define SWAP(n) (n)
#else
# define SWAP(n) bswap_32 (n)
#endif
#ifdef CRCTAB
# define BIT(x) ((uint_fast32_t) 1 << (x))
# include <stdio.h>
# define BIT(x) (1u << (x))
# define SBIT BIT (31)
/* The generating polynomial is
@@ -62,7 +52,7 @@
| BIT (11) | BIT (10) | BIT (8) | BIT (7) | BIT (5) \
| BIT (4) | BIT (2) | BIT (1) | BIT (0))
static uint_fast32_t r[8];
static unsigned int r[8];
static void
fill_r (void)
@@ -72,10 +62,10 @@ fill_r (void)
r[i] = (r[i - 1] << 1) ^ ((r[i - 1] & SBIT) ? GEN : 0);
}
static uint_fast32_t
static unsigned int
crc_remainder (int m)
{
uint_fast32_t rem = 0;
unsigned int rem = 0;
for (int i = 0; i < 8; i++)
if (BIT (i) & m)
@@ -87,15 +77,12 @@ crc_remainder (int m)
int
main (void)
{
int i;
static uint_fast32_t crctab[8][256];
static unsigned int crctab[8][256];
fill_r ();
for (i = 0; i < 256; i++)
{
crctab[0][i] = crc_remainder (i);
}
for (int i = 0; i < 256; i++)
crctab[0][i] = crc_remainder (i);
/* CRC(0x11 0x22 0x33 0x44)
is equal to
@@ -104,25 +91,26 @@ main (void)
We precompute the CRC values for the offset values into
separate CRC tables. We can then use them to speed up
CRC calculation by processing multiple bytes at the time. */
for (i = 0; i < 256; i++)
for (int i = 0; i < 256; i++)
{
uint32_t crc = 0;
unsigned int crc = 0;
crc = (crc << 8) ^ crctab[0][((crc >> 24) ^ (i & 0xFF)) & 0xFF];
for (idx_t offset = 1; offset < 8; offset++)
crc = (crc << 8) ^ crctab[0][((crc >> 24) ^ i) & 0xFF];
for (int offset = 1; offset < 8; offset++)
{
crc = (crc << 8) ^ crctab[0][((crc >> 24) ^ 0x00) & 0xFF];
crctab[offset][i] = crc;
crc = (crc << 8) ^ crctab[0][((crc >> 24) ^ 0) & 0xFF];
crctab[offset][i] = crc & 0xFFFFFFFF;
}
}
printf ("#include <config.h>\n");
printf ("#include <stdint.h>\n");
printf ("\nuint_fast32_t const crctab[8][256] = {\n");
printf ("#include \"cksum.h\"\n");
printf ("\n");
printf ("uint_fast32_t const crctab[8][256] = {\n");
for (int y = 0; y < 8; y++)
{
printf ("{\n 0x%08x", crctab[y][0]);
for (i = 0; i < 51; i++)
for (int i = 0; i < 51; i++)
{
printf (",\n 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x",
crctab[y][i * 5 + 1], crctab[y][i * 5 + 2],
@@ -132,32 +120,105 @@ main (void)
printf ("\n},\n");
}
printf ("};\n");
return EXIT_SUCCESS;
}
#else /* !CRCTAB */
# include "cksum.h"
# include <sys/types.h>
# include <endian.h>
# include "system.h"
# ifdef USE_VMULL_CRC32
# include <sys/auxv.h>
# include <asm/hwcap.h>
# endif
# include "crc.h"
/* Number of bytes to read at once. */
# define BUFLEN (1 << 16)
# if USE_PCLMUL_CRC32
static bool
typedef bool (*cksum_fp_t) (FILE *, uint_fast32_t *, uintmax_t *);
static cksum_fp_t
pclmul_supported (void)
{
# if USE_PCLMUL_CRC32 || GL_CRC_X86_64_PCLMUL
bool pclmul_enabled = (0 < __builtin_cpu_supports ("pclmul")
&& 0 < __builtin_cpu_supports ("avx"));
if (cksum_debug)
error (0, 0, "%s",
(pclmul_enabled
? _("using pclmul hardware support")
: _("pclmul support not detected")));
if (pclmul_enabled)
return cksum_pclmul;
# endif
return pclmul_enabled;
return nullptr;
}
static cksum_fp_t
avx2_supported (void)
{
/* AVX512 processors will not set vpclmulqdq unless they support
the avx512 version, but it implies that the avx2 version
is supported */
# if USE_AVX2_CRC32
bool avx2_enabled = (0 < __builtin_cpu_supports ("vpclmulqdq")
&& 0 < __builtin_cpu_supports ("avx2"));
if (cksum_debug)
error (0, 0, "%s",
(avx2_enabled
? _("using avx2 hardware support")
: _("avx2 support not detected")));
if (avx2_enabled)
return cksum_avx2;
# endif
return nullptr;
}
static cksum_fp_t
avx512_supported (void)
{
/* vpclmulqdq for multiplication
mavx512f for most of the avx512 functions we're using
mavx512bw for byte swapping */
# if USE_AVX512_CRC32
bool avx512_enabled = (0 < __builtin_cpu_supports ("vpclmulqdq")
&& 0 < __builtin_cpu_supports ("avx512bw")
&& 0 < __builtin_cpu_supports ("avx512f"));
if (cksum_debug)
error (0, 0, "%s",
(avx512_enabled
? _("using avx512 hardware support")
: _("avx512 support not detected")));
if (avx512_enabled)
return cksum_avx512;
# endif
return nullptr;
}
static cksum_fp_t
vmull_supported (void)
{
/* vmull for multiplication */
# if USE_VMULL_CRC32
bool vmull_enabled = (getauxval (AT_HWCAP) & HWCAP_PMULL) > 0;
if (cksum_debug)
error (0, 0, "%s",
(vmull_enabled
? _("using vmull hardware support")
: _("vmull support not detected")));
if (vmull_enabled)
return cksum_vmull;
# endif
return nullptr;
}
# endif /* USE_PCLMUL_CRC32 */
static bool
cksum_slice8 (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out)
@@ -186,8 +247,8 @@ cksum_slice8 (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out)
while (bytes_read >= 8)
{
uint32_t first = *datap++, second = *datap++;
crc ^= SWAP (first);
second = SWAP (second);
crc ^= htobe32 (first);
second = htobe32 (second);
crc = (crctab[7][(crc >> 24) & 0xFF]
^ crctab[6][(crc >> 16) & 0xFF]
^ crctab[5][(crc >> 8) & 0xFF]
@@ -222,13 +283,17 @@ crc_sum_stream (FILE *stream, void *resstream, uintmax_t *length)
uintmax_t total_bytes = 0;
uint_fast32_t crc = 0;
# if USE_PCLMUL_CRC32
static bool (*cksum_fp) (FILE *, uint_fast32_t *, uintmax_t *);
static cksum_fp_t cksum_fp;
if (! cksum_fp)
cksum_fp = pclmul_supported () ? cksum_pclmul : cksum_slice8;
# else
bool (*cksum_fp) (FILE *, uint_fast32_t *, uintmax_t *) = cksum_slice8;
# endif
cksum_fp = avx512_supported ();
if (! cksum_fp)
cksum_fp = avx2_supported ();
if (! cksum_fp)
cksum_fp = pclmul_supported ();
if (! cksum_fp)
cksum_fp = vmull_supported ();
if (! cksum_fp)
cksum_fp = cksum_slice8;
if (! cksum_fp (stream, &crc, &total_bytes))
return -1;
@@ -245,6 +310,48 @@ crc_sum_stream (FILE *stream, void *resstream, uintmax_t *length)
return 0;
}
/* Calculate the crc32b checksum and length in bytes of stream STREAM.
Return -1 on error, 0 on success. */
int
crc32b_sum_stream (FILE *stream, void *resstream, uintmax_t *reslen)
{
uint32_t buf[BUFLEN / sizeof (uint32_t)];
uint32_t crc = 0;
uintmax_t len = 0;
size_t bytes_read;
if (!stream || !resstream || !reslen)
return -1;
# if GL_CRC_X86_64_PCLMUL
if (cksum_debug)
(void) pclmul_supported ();
# endif
while ((bytes_read = fread (buf, 1, BUFLEN, stream)) > 0)
{
if (len + bytes_read < len)
{
errno = EOVERFLOW;
return -1;
}
len += bytes_read;
crc = crc32_update (crc, (char const *)buf, bytes_read);
if (feof (stream))
break;
}
unsigned int crc_out = crc;
memcpy (resstream, &crc_out, sizeof crc_out);
*reslen = len;
return ferror (stream) ? -1 : 0;
}
/* Print the checksum and size to stdout.
If ARGS is true, also print the FILE name. */
@@ -255,13 +362,12 @@ output_crc (char const *file, int binary_file, void const *digest, bool raw,
if (raw)
{
/* Output in network byte order (big endian). */
uint32_t out_int = SWAP (*(uint32_t *)digest);
uint32_t out_int = htobe32 (*(uint32_t *)digest);
fwrite (&out_int, 1, 32/8, stdout);
return;
}
char length_buf[INT_BUFSIZE_BOUND (uintmax_t)];
printf ("%u %s", *(unsigned int *)digest, umaxtostr (length, length_buf));
printf ("%u %ju", *(unsigned int *)digest, length);
if (args)
printf (" %s", file);
putchar (delim);

View File

@@ -1,19 +1,50 @@
/* Calculate checksums and sizes of files
Copyright 2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef __CKSUM_H__
# define __CKSUM_H__
# include <stdint.h>
# include <stdio.h>
extern bool cksum_debug;
extern int
crc_sum_stream (FILE *stream, void *resstream, uintmax_t *length);
extern int
crc32b_sum_stream (FILE *stream, void *resstream, uintmax_t *length);
extern void
output_crc (char const *file, int binary_file, void const *digest, bool raw,
bool tagged, unsigned char delim, bool args, uintmax_t length)
_GL_ATTRIBUTE_NONNULL ((3));
extern bool
cksum_vmull (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out);
extern bool
cksum_pclmul (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out);
extern bool
cksum_avx2 (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out);
extern bool
cksum_avx512 (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out);
extern uint_fast32_t const crctab[8][256];
#endif

196
src/cksum_avx2.c Normal file
View File

@@ -0,0 +1,196 @@
/* cksum -- calculate and print POSIX checksums and sizes of files
Copyright (C) 2024-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include "cksum.h"
#include <stdio.h>
#include <sys/types.h>
#include <x86intrin.h>
#include "system.h"
/* Number of bytes to read at once. */
#define BUFLEN (1 << 16)
bool
cksum_avx2 (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out)
{
__m256i buf[BUFLEN / sizeof (__m256i)];
uint_fast32_t crc = 0;
uintmax_t length = 0;
size_t bytes_read;
__m256i single_mult_constant;
__m256i four_mult_constant;
__m256i shuffle_constant;
if (!fp || !crc_out || !length_out)
return false;
/* These constants and general algorithms are taken from the Intel whitepaper
"Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction"
*/
single_mult_constant = _mm256_set_epi64x (0x569700E5, 0x75BE46B7,
0x569700E5, 0x75BE46B7);
four_mult_constant = _mm256_set_epi64x (0x10BD4D7C, 0x567FDDEB,
0x10BD4D7C, 0x567FDDEB);
/* Constant to byteswap a full AVX2 register */
shuffle_constant = _mm256_set_epi8 (0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15,
0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15);
while ((bytes_read = fread (buf, 1, BUFLEN, fp)) > 0)
{
__m256i data;
__m256i data2;
__m256i data3;
__m256i data4;
__m256i data5;
__m256i data6;
__m256i data7;
__m256i data8;
__m256i fold_data;
__m256i xor_crc;
__m256i *datap;
if (length + bytes_read < length)
{
errno = EOVERFLOW;
return false;
}
length += bytes_read;
datap = (__m256i *)buf;
/* Fold in parallel 16x 16-byte blocks into 8x 16-byte blocks */
if (bytes_read >= 16 * 8 * 2)
{
data = _mm256_loadu_si256 (datap);
data = _mm256_shuffle_epi8 (data, shuffle_constant);
/* XOR in initial CRC value (for us 0 so no effect), or CRC value
calculated for previous BUFLEN buffer from fread */
xor_crc = _mm256_set_epi32 (0, 0, 0, 0, crc, 0, 0, 0);
crc = 0;
data = _mm256_xor_si256 (data, xor_crc);
data3 = _mm256_loadu_si256 (datap + 1);
data3 = _mm256_shuffle_epi8 (data3, shuffle_constant);
data5 = _mm256_loadu_si256 (datap + 2);
data5 = _mm256_shuffle_epi8 (data5, shuffle_constant);
data7 = _mm256_loadu_si256 (datap + 3);
data7 = _mm256_shuffle_epi8 (data7, shuffle_constant);
while (bytes_read >= 16 * 8 * 2)
{
datap += 4;
/* Do multiplication here for 8x consecutive 16 byte blocks */
data2 = _mm256_clmulepi64_epi128 (data, four_mult_constant,
0x00);
data = _mm256_clmulepi64_epi128 (data, four_mult_constant,
0x11);
data4 = _mm256_clmulepi64_epi128 (data3, four_mult_constant,
0x00);
data3 = _mm256_clmulepi64_epi128 (data3, four_mult_constant,
0x11);
data6 = _mm256_clmulepi64_epi128 (data5, four_mult_constant,
0x00);
data5 = _mm256_clmulepi64_epi128 (data5, four_mult_constant,
0x11);
data8 = _mm256_clmulepi64_epi128 (data7, four_mult_constant,
0x00);
data7 = _mm256_clmulepi64_epi128 (data7, four_mult_constant,
0x11);
/* Now multiplication results for the 8x blocks is xor:ed with
next 8x 16 byte blocks from the buffer. This effectively
"consumes" the first 8x blocks from the buffer.
Keep xor result in variables for multiplication in next
round of loop. */
data = _mm256_xor_si256 (data, data2);
data2 = _mm256_loadu_si256 (datap);
data2 = _mm256_shuffle_epi8 (data2, shuffle_constant);
data = _mm256_xor_si256 (data, data2);
data3 = _mm256_xor_si256 (data3, data4);
data4 = _mm256_loadu_si256 (datap + 1);
data4 = _mm256_shuffle_epi8 (data4, shuffle_constant);
data3 = _mm256_xor_si256 (data3, data4);
data5 = _mm256_xor_si256 (data5, data6);
data6 = _mm256_loadu_si256 (datap + 2);
data6 = _mm256_shuffle_epi8 (data6, shuffle_constant);
data5 = _mm256_xor_si256 (data5, data6);
data7 = _mm256_xor_si256 (data7, data8);
data8 = _mm256_loadu_si256 (datap + 3);
data8 = _mm256_shuffle_epi8 (data8, shuffle_constant);
data7 = _mm256_xor_si256 (data7, data8);
bytes_read -= (16 * 4 * 2);
}
/* At end of loop we write out results from variables back into
the buffer, for use in single fold loop */
data = _mm256_shuffle_epi8 (data, shuffle_constant);
_mm256_storeu_si256 (datap, data);
data3 = _mm256_shuffle_epi8 (data3, shuffle_constant);
_mm256_storeu_si256 (datap + 1, data3);
data5 = _mm256_shuffle_epi8 (data5, shuffle_constant);
_mm256_storeu_si256 (datap + 2, data5);
data7 = _mm256_shuffle_epi8 (data7, shuffle_constant);
_mm256_storeu_si256 (datap + 3, data7);
}
/* Fold two 32-byte blocks into one 32-byte block */
if (bytes_read >= 64)
{
data = _mm256_loadu_si256 (datap);
data = _mm256_shuffle_epi8 (data, shuffle_constant);
xor_crc = _mm256_set_epi32 (0, 0, 0, 0, crc, 0, 0, 0);
crc = 0;
data = _mm256_xor_si256 (data, xor_crc);
while (bytes_read >= 64)
{
datap++;
data2 = _mm256_clmulepi64_epi128 (data, single_mult_constant,
0x00);
data = _mm256_clmulepi64_epi128 (data, single_mult_constant,
0x11);
fold_data = _mm256_loadu_si256 (datap);
fold_data = _mm256_shuffle_epi8 (fold_data, shuffle_constant);
data = _mm256_xor_si256 (data, data2);
data = _mm256_xor_si256 (data, fold_data);
bytes_read -= 32;
}
data = _mm256_shuffle_epi8 (data, shuffle_constant);
_mm256_storeu_si256 (datap, data);
}
/* And finish up last 0-63 bytes in a byte by byte fashion */
unsigned char *cp = (unsigned char *)datap;
while (bytes_read--)
crc = (crc << 8) ^ crctab[0][((crc >> 24) ^ *cp++) & 0xFF];
if (feof (fp))
break;
}
*crc_out = crc;
*length_out = length;
return !ferror (fp);
}

205
src/cksum_avx512.c Normal file
View File

@@ -0,0 +1,205 @@
/* cksum -- calculate and print POSIX checksums and sizes of files
Copyright (C) 2024-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include "cksum.h"
#include <sys/types.h>
#include <x86intrin.h>
#include "system.h"
/* Number of bytes to read at once. */
#define BUFLEN (1 << 16)
bool
cksum_avx512 (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out)
{
__m512i buf[BUFLEN / sizeof (__m512i)];
uint_fast32_t crc = 0;
uintmax_t length = 0;
size_t bytes_read;
__m512i single_mult_constant;
__m512i four_mult_constant;
__m512i shuffle_constant;
if (!fp || !crc_out || !length_out)
return false;
/* These constants and general algorithms are taken from the Intel whitepaper
"Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction"
*/
single_mult_constant = _mm512_set_epi64 (0x8833794C, 0xE6228B11,
0x8833794C, 0xE6228B11,
0x8833794C, 0xE6228B11,
0x8833794C, 0xE6228B11);
four_mult_constant = _mm512_set_epi64 (0xCBCF3BCB, 0x88FE2237,
0xCBCF3BCB, 0x88FE2237,
0xCBCF3BCB, 0x88FE2237,
0xCBCF3BCB, 0x88FE2237);
/* Constant to byteswap a full AVX512 register */
shuffle_constant = _mm512_set_epi8 (0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15,
0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15,
0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15,
0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15);
while ((bytes_read = fread (buf, 1, BUFLEN, fp)) > 0)
{
__m512i data;
__m512i data2;
__m512i data3;
__m512i data4;
__m512i data5;
__m512i data6;
__m512i data7;
__m512i data8;
__m512i fold_data;
__m512i xor_crc;
__m512i *datap;
if (length + bytes_read < length)
{
errno = EOVERFLOW;
return false;
}
length += bytes_read;
datap = (__m512i *)buf;
/* Fold in parallel 32x 16-byte blocks into 16x 16-byte blocks */
if (bytes_read >= 16 * 8 * 4)
{
data = _mm512_loadu_si512 (datap);
data = _mm512_shuffle_epi8 (data, shuffle_constant);
/* XOR in initial CRC value (for us 0 so no effect), or CRC value
calculated for previous BUFLEN buffer from fread */
xor_crc = _mm512_set_epi32 (0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, crc, 0, 0, 0);
crc = 0;
data = _mm512_xor_si512 (data, xor_crc);
data3 = _mm512_loadu_si512 (datap + 1);
data3 = _mm512_shuffle_epi8 (data3, shuffle_constant);
data5 = _mm512_loadu_si512 (datap + 2);
data5 = _mm512_shuffle_epi8 (data5, shuffle_constant);
data7 = _mm512_loadu_si512 (datap + 3);
data7 = _mm512_shuffle_epi8 (data7, shuffle_constant);
while (bytes_read >= 16 * 8 * 4)
{
datap += 4;
/* Do multiplication here for 16x consecutive 16 byte blocks */
data2 = _mm512_clmulepi64_epi128 (data, four_mult_constant,
0x00);
data = _mm512_clmulepi64_epi128 (data, four_mult_constant,
0x11);
data4 = _mm512_clmulepi64_epi128 (data3, four_mult_constant,
0x00);
data3 = _mm512_clmulepi64_epi128 (data3, four_mult_constant,
0x11);
data6 = _mm512_clmulepi64_epi128 (data5, four_mult_constant,
0x00);
data5 = _mm512_clmulepi64_epi128 (data5, four_mult_constant,
0x11);
data8 = _mm512_clmulepi64_epi128 (data7, four_mult_constant,
0x00);
data7 = _mm512_clmulepi64_epi128 (data7, four_mult_constant,
0x11);
/* Now multiplication results for the 16x blocks is xor:ed with
next 16x 16 byte blocks from the buffer. This effectively
"consumes" the first 16x blocks from the buffer.
Keep xor result in variables for multiplication in next
round of loop. */
data = _mm512_xor_si512 (data, data2);
data2 = _mm512_loadu_si512 (datap);
data2 = _mm512_shuffle_epi8 (data2, shuffle_constant);
data = _mm512_xor_si512 (data, data2);
data3 = _mm512_xor_si512 (data3, data4);
data4 = _mm512_loadu_si512 (datap + 1);
data4 = _mm512_shuffle_epi8 (data4, shuffle_constant);
data3 = _mm512_xor_si512 (data3, data4);
data5 = _mm512_xor_si512 (data5, data6);
data6 = _mm512_loadu_si512 (datap + 2);
data6 = _mm512_shuffle_epi8 (data6, shuffle_constant);
data5 = _mm512_xor_si512 (data5, data6);
data7 = _mm512_xor_si512 (data7, data8);
data8 = _mm512_loadu_si512 (datap + 3);
data8 = _mm512_shuffle_epi8 (data8, shuffle_constant);
data7 = _mm512_xor_si512 (data7, data8);
bytes_read -= (16 * 4 * 4);
}
/* At end of loop we write out results from variables back into
the buffer, for use in single fold loop */
data = _mm512_shuffle_epi8 (data, shuffle_constant);
_mm512_storeu_si512 (datap, data);
data3 = _mm512_shuffle_epi8 (data3, shuffle_constant);
_mm512_storeu_si512 (datap + 1, data3);
data5 = _mm512_shuffle_epi8 (data5, shuffle_constant);
_mm512_storeu_si512 (datap + 2, data5);
data7 = _mm512_shuffle_epi8 (data7, shuffle_constant);
_mm512_storeu_si512 (datap + 3, data7);
}
/* Fold two 64-byte blocks into one 64-byte block */
if (bytes_read >= 128)
{
data = _mm512_loadu_si512 (datap);
data = _mm512_shuffle_epi8 (data, shuffle_constant);
xor_crc = _mm512_set_epi32 (0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, crc, 0, 0, 0);
crc = 0;
data = _mm512_xor_si512 (data, xor_crc);
while (bytes_read >= 128)
{
datap++;
data2 = _mm512_clmulepi64_epi128 (data, single_mult_constant,
0x00);
data = _mm512_clmulepi64_epi128 (data, single_mult_constant,
0x11);
fold_data = _mm512_loadu_si512 (datap);
fold_data = _mm512_shuffle_epi8 (fold_data, shuffle_constant);
data = _mm512_xor_si512 (data, data2);
data = _mm512_xor_si512 (data, fold_data);
bytes_read -= 64;
}
data = _mm512_shuffle_epi8 (data, shuffle_constant);
_mm512_storeu_si512 (datap, data);
}
/* And finish up last 0-127 bytes in a byte by byte fashion */
unsigned char *cp = (unsigned char *)datap;
while (bytes_read--)
crc = (crc << 8) ^ crctab[0][((crc >> 24) ^ *cp++) & 0xFF];
if (feof (fp))
break;
}
*crc_out = crc;
*length_out = length;
return !ferror (fp);
}

View File

@@ -1,5 +1,5 @@
/* cksum -- calculate and print POSIX checksums and sizes of files
Copyright (C) 1992-2024 Free Software Foundation, Inc.
Copyright (C) 2021-2025 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -16,20 +16,16 @@
#include <config.h>
#include "cksum.h"
#include <stdio.h>
#include <sys/types.h>
#include <stdint.h>
#include <x86intrin.h>
#include "system.h"
/* Number of bytes to read at once. */
#define BUFLEN (1 << 16)
extern uint_fast32_t const crctab[8][256];
extern bool
cksum_pclmul (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out);
/* Calculate CRC32 using PCLMULQDQ CPU instruction found in x86/x64 CPUs */
bool

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