Compare commits

...

910 Commits
v9.1 ... 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
Pádraig Brady
cc8689a07c version 9.5
* NEWS: Record release date.
2024-03-28 14:47:20 +00:00
Bruno Haible
bec53850b7 tests: od: avoid outputting undefined floating point values
od was seen to abort() on glibc on ia64 and m68k with the error:
Fatal glibc error: printf_fp.c:501 (__printf_fp_buffer_1):
assertion failed:
  cy == 1 || (p.frac[p.fracsize - 2] == 0 && p.frac[0] == 0)

* tests/od/od-multiple-t.sh: Avoid outputting long double floats
to avoid undefined behavior. 'float' and 'double' are standardized
by IEEE 754 (except on Linux/m68k) and don't have undefined values.
2024-03-27 12:41:33 +00:00
Pádraig Brady
541b026b11 build: update with gnulib fixes
* gnulib: Update to incorporate gnulib fixes
from Bruno Haible
2024-03-26 21:39:11 +00:00
Pádraig Brady
606f54d157 tests: numfmt: fix false failures on some systems
* tests/misc/numfmt.pl: Verify that printf field width specs
count characters and not bytes before enabling locale tests.
This was seen on FreeBSD 14.0 and Solaris 11 OpenIndiana.
Reported by Bruno Haible
2024-03-26 20:09:35 +00:00
Pádraig Brady
6e2b4769cc ls: avoid ENOENT from readdir() on FreeBSD 14
* src/ls.c (print_dir): readdir() on FreeBSD 14 was
seen to pass ENOENT through.  ENOENT in this context
means "Directory unlinked but still open".
Reported by Bruno Haible with tests/ls/removed-directory.sh
2024-03-26 18:57:32 +00:00
Pádraig Brady
3dc8657648 tests: avoid false failure due to mismatched isblank()
There is a mismatch between isblank() used by tr and c32isblank() now
used by uniq on Solaris 11 OpenIndiana. isblank() was seen to return
true for non breaking space, while c32isblank() returned false.
Interestingly on Solaris, non breaking space is considered a blank
character, and isblank() and c32isblank() honor this in all locales.

* tests/uniq/uniq.pl: Adjust the blank check to use join(1) rather than
tr(1), as join uses the same blank determination routines as uniq(1).
2024-03-26 16:53:09 +00:00
Pádraig Brady
30039cb23a cp: with --no-preserve=mode ensure set-group-ID bits maintained on dirs
This issue was introduced in commit v8.19-145-g24ebca6

* src/copy.c (copy_internal): On systems that don't support ACLs,
the fallback default chmod done on directories should maintain
the set-group-ID, as that's generally auto-set by the system.
* NEWS: Mention the fix.
Reported by Bruno Haible on Alpine (with tests/cp/preserve-mode.sh)
2024-03-25 22:27:15 +00:00
Pádraig Brady
c0f02a8f5b tests: avoid false failure with partial locale info
* tests/misc/numfmt.pl: Some systems with the fr_FR.UTF-8
locale installed, do not have a thousands grouping character defined.
In this case we skip the locale tests which depend on a non empty
grouping character.
2024-03-25 18:40:53 +00:00
Pádraig Brady
a51af43294 tests: avoid triggering obsolete tail option processing
* tests/ls/dired.sh: With 2 options, the latter is taken
as a file name on some systems.  This avoids a false
failure on Solaris and FreeBSD at least.
2024-03-25 13:02:52 +00:00
Pádraig Brady
ecb2fecdf9 tests: remove debugging from a test
* tests/ls/dired.sh: Remove temp debugging output.
2024-03-25 12:22:52 +00:00
Pádraig Brady
4cb2742d70 tests: fix false failure on systems that can chmod symlinks
* tests/chmod/symlinks.sh: The count of adjusted modes was
one more on systems where symlink modes can be adjusted.
Therefore only include the non symlinks in the count.
2024-03-25 12:12:19 +00:00
Pádraig Brady
26fd96a96c doc: fix translation issue in chown/chgrp amalgamation
* src/chown-core.h (emit_from_option_description): The conditional
string composition here caused issues for translators.
Instead move to a more general description ...
(src/chown.c (usage): ... here.
Fixes https://bugs.gnu.org/69985
2024-03-24 20:25:37 +00:00
Pádraig Brady
6259593ac7 doc: fix various translation issues
src/chown.c (usage): Translate parameterized strings.
 src/copy.c (copy_internal): Translate each part of ternary.
* src/cp.c (usage): Fix typo; s/exisiting/existing/.
2024-03-24 19:57:29 +00:00
Pádraig Brady
f77a6352fb test: avoid false failure with setgid directories
* tests/chmod/symlinks.sh: Ensure this new test is immune
to setgid directories by resetting modes with =777 rather than 777.
Also output more debugging in all failure cases.
2024-03-24 19:46:57 +00:00
Pádraig Brady
c45fcb2ed2 tests: avoid false failure on new mv --exchange test
* tests/mv/mv-exchange.sh: Canonicalize different
"operation not supported" messages, so we can ignore correctly.
Reported by Bruno Haible on AIX, NetBSD, and OpenBSD.
2024-03-24 18:32:34 +00:00
Pádraig Brady
e0cce6b62a doc: update THANKS related to env --argv0 option
* THANKS.in: Add Matheus who was central to the env --argv0
addition in commit v9.4-167-g193449b17.
2024-03-24 17:56:36 +00:00
Stephane Chazelas
7ebbeeb03d doc: ls: detail output format for device files
* doc/coreutils.texi (ls invocation): State that device numbers
are output, instead of file size.
2024-03-24 17:52:32 +00:00
Pádraig Brady
7b2064216c doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.31 which is now about 5 years old.
2024-03-23 16:02:52 +00:00
Paul Eggert
5a1d00e450 mv: treat --exchange more like non-exchange
Also, improve quality of diagnostics.
Problems/suggestions by Bernhard Voelker in
<https://bugs.gnu.org/69532#82>.
* src/copy.c (emit_verbose): New arg FORMAT.  All uses changed,
to improve quality of diagnostics when --exchange is used.
(copy_internal): Don’t try to optimize --exchange so much; this
simplifies the code and keeps it closer to the non --exchange case.
2024-03-22 18:39:27 -07:00
Paul Eggert
ff42adb55e cp,ln,mv: improve dir vs nondir diagnostics
* src/copy.c (copy_internal): Simplify logic for copying
from directory to non-directory or vice versa, and always
diagnose with both source and destination file names.
2024-03-22 18:39:27 -07:00
Pádraig Brady
193449b173 env: add -a,--argv0 to set the first argument passed to exec
Using the shell's exec -a feature can be awkward
so add support for setting overriding argv[0].
This gives env full control over the arguments it passes.

* src/env.c: Accept -a,--argv0 and set argv[0] appropriately.
* tests/env/env.sh: Add test cases.
* doc/coreutils.texi (env invocation): Describe -a,--argv0.
* NEWS: Mention the new feature.
2024-03-22 13:12:52 +00:00
Pádraig Brady
91e69cd2d0 doc: pr: give solution to expanding TABs in multicolumn output
* doc/coreutils.texi (pr invocation): Explicitly state that
multicolumn output will convert spaces to TABs, and show that
this can be undone with the `pr -t -e` or `expand` commands.
Suggested by Douglas McIlroy in https://bugs.gnu.org/69807
2024-03-21 15:32:13 +00:00
Paul Eggert
1913bfcf57 doc: clarify mv --exchange
In the manual, say it exchanges all data and metadata.
Suggested by Pádraig Brady in:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69532#59
2024-03-20 15:01:07 -07:00
Paul Eggert
5d3fd24f42 mv: new option --exchange
* src/copy.h (struct cp_options): New member 'exchange'.
* src/copy.c (copy_internal): Support the new member.
* src/mv.c (EXCHANGE_OPTION): New constant.
(long_options): Add --exchange.
(usage): Document --exchange.
(main): Support --exchange.
* tests/mv/mv-exchange.sh: New test case.
* tests/local.mk (all_tests): Add it.
2024-03-20 14:40:29 -07:00
Pádraig Brady
425b8a2f53 chmod: fix TOCTOU security issue with symlink replacement
This is an issue with -[H]R mode, where an attacker
may replace a traversed file with a symlink
between where we stat() the file and chmod() the file.

* src/chmod.c (process_file): Remove the first !S_ISLNK guard
as that's now just an optimization, and instead consistently
apply fchmodat() to files/symlinks.  Ensure AT_SYMLINK_NOFOLLOW
is set when traversing in default (-H) mode.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/11108
2024-03-19 23:56:45 +00:00
Pádraig Brady
07a69fc3ba chmod: add support for -h, -H,-L,-P, --dereference options
There have been various requests to add -h to avoid following symlinks
for security reasons.  This wasn't provided previously as chmod(1)
already ignored symlinks unless specified on the command line.
Note chmod defaults to -H mode rather than the chown default of -P,
as usually chown can work directly on symlinks and so defaults
to not traversing those specified on the command line.
Note FreeBSD chmod does default to -P mode, but we retain the -H mode
default also for compatibility with existing chmod behavior.

Adding -HLP will allow chmod to disable traversing CLI symlinks to dirs.
Adding -h will allow to disable following CLI symlinks to files/dirs,
  also operating on all symlinks on systems that support that.
Adding --dereference will be significant with -H (the default).  I.e.
  symlinks to dirs not recursed, but symlinks are dereferenced.
Adding these options will also be consistent with chown(1), chgrp(1),
and chmod(1) on other systems.

Note since chmod(1) currently ignores symlinks by default,
and -h is primarily a mechanism to avoid following symlinks, rather than
for operating on the symlink itself, we make -h try to chmod a symlink,
but ignore ENOTSUP.  In that way we're consistent with chown(1)
where it also ignores ENOTSUP for symlinks, and we don't fail when
trying to be extra secure with command line params.

* doc/coreutils.texi (chmod invocation): Reference the -H,-L,-P
descriptions, and adjust the corresponding macros to say
the default is -H or -P as appropriate.
Add --dereference and -h,--no-dereference descriptions.
* man/chmod.x: Adjust discussion of symlink handling.
* src/chmod.c (main): Accept new options and set
fts flags appropriately.
(process_file): Process / dereference symlinks as necessary.
* src/system.h (emit_symlink_recurse_options): A new function
refactored from chown.c and chmod.c usage().
* tests/chmod/symlinks.sh: New test for the new options.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.
2024-03-19 23:43:53 +00:00
Pádraig Brady
a46f34bb56 maint: basenc: consistently check buffer bounds when encoding
* src/basenc.c (base16_encode, base2msbf_encode, base2lsbf_encode):
Ensure we don't overflow the output buffer, whose length is
passed in the OUTLEN parameter.  This issue was flagged by clang
with -Wunused-but-set-parameter.
2024-03-19 23:43:53 +00:00
Pádraig Brady
bf73a7602a pinky: disable location canonicalization by default
Behave like who(1) in requiring --lookup to enable this
often slow feature.  pinky(1) is supposed to be lightweight after all.

* doc/coreutils.texi (who invocation): Adjust the description to no
longer reference dialup, and be more general about the still significant
delays.
(pinky invocation): Reference the same --lookup description.
* src/pinky.c (main): Accept --lookup to enable DNS lookups.
* NEWS: Mention the change in behavior.
Fixes https://bugs.debian.org/628815
2024-03-19 23:43:53 +00:00
Pádraig Brady
48cd67663d doc: fix stale --dereference info for chown/chgrp
Following v5.2.1-679-g7e29ef8b8 symlinks specified on the command line
no longer induce an error if lchown() is not supported on the system.

* doc/coreutils.texi (chown invocation, chgrp invocation): Adjust
accordingly, and also use a macro to avoid duplication.
* src/chown-core.c: Use our more standard is_ENOTSUP() wrapper
in the code related to this.
2024-03-18 18:40:21 +00:00
Paul Eggert
dda89eb5d3 build: update gnulib submodule to latest 2024-03-16 22:49:45 -07:00
Pádraig Brady
c07a7d999e build: provide a cross-compiling default for 16 bit float checks
* configure.ac: Provide a conservative 16 bit float support default
when cross-compiling, to avoid configure failing in that case.
2024-03-15 11:38:28 +00:00
Grisha Levit
b8d1b00e21 env,kill,timeout: support unnamed signals
Some signals with values less that the max signal number for the system
do not have defined names.  For example, currently on amd64 Linux,
signals 32 and 33 do not have defined names, and Android has a wider
gap of undefined names where it reserves some realtime signals.

Previously the signal listing in env ended up reusing the name
of the last printed valid signal (the repeated HUP below):

    $ env --list-signal-handling true
    HUP        ( 1): IGNORE
    HUP        (32): BLOCK
    HUP        (38): IGNORE

..and the corresponding signal numbers were rejected as operands for the
env, kill, and timeout commands.

This patch removes the requirement that sig2str returns 0 for a signal
number associated with an operand.  This allows unnamed signals to be in
the sets `env' attempts to manipulate when a --*-signal option is used
with no argument, and kill(1) and timeout(1) to send such unnamed
signals.

* src/operand2sig.c (operand2sig): Drop signame argument, accept all
signal numbers <= SIGNUM_BOUND.  All callers updated.
* src/env.c (parse_signal_action_params, reset_signal_handlers)
(parse_block_signal_params, set_signal_proc_mask)
(list_signal_handling): Accept all signal numbers <= SIGNUM_BOUND,
use SIG%d for printing if necessary.
* src/kill.c (list_signals, main): Likewise.
(send_signals): Check errno from kill(3) for bad signo.
* src/timeout.c (main): Update operand2sig call.
* tests/misc/kill.sh: Test listing all signal numbers.
* NEWS: Mention the improvement.
2024-03-13 16:15:35 +00:00
Pádraig Brady
c7f422940a build: add caching for involved configure checks
* configure.ac: Wrap the following with AC_CACHE_VAL,
so that they can be cached / overridden.  We use
the "utils_cv_" prefix as they're coreutils specific overrides.
utils_cv_avx2_intrinsic_exists,
utils_cv_brain_16_bit_supported,
utils_cv_ieee_16_bit_supported,
utils_cv_pclmul_intrinsic_exists,
utils_cv_stdbuf_supported.
2024-03-13 12:31:32 +00:00
Grisha Levit
0cafa1524f build: strengthen 16 bit float support checks
Recent clang provides __bf16 on aarch64 but it is broken.

If built with -O0, the conversion is wrong:

    $ printf '\x3F\x80' | od --end=big -An -tfB | tr -d ' '
    1.875

If built with -O1 or higher, compilation fails:

    fatal error: error in backend:
    Cannot select: 0xb400007a58d29780: f32 = fp_extend 0xb40000...
    0xb40000...: bf16,ch = CopyFromReg 0xb40000..., Register:bf16 %13
    0xb40000...: bf16 = Register %13
    In function: print_bfloat

The latter issue does not cause the existing configure test to fail
because the promotion is optimized out.

* configure.ac: Ensure 16 bit float promotion code does not get
optimized out, and produces an expected result.
2024-03-13 11:49:30 +00:00
Collin Funk
00a34a05f5 maint: prefer minmax.h instead of defining our own
* src/comm.c (min): Remove.
(compare_files): Use MIN which is referenced by system.h.
2024-03-12 20:04:56 +00:00
Ville Skyttä
9a50494875 dircolors: add more archive extensions
* src/dircolors.hin: Add .apk (Alpine Linux/Android package); .drpm
(delta rpm); .egg, .pyz, and .whl (Python related); and .udeb (form of
.deb).
2024-03-12 15:22:01 +00:00
Collin Funk
44c9578a08 doc: add basic documentation for 'pinky'
* doc/coreutils.texi: Add 'pinky' under 'who'.
2024-03-12 14:57:51 +00:00
Pádraig Brady
ab4ffc8503 timeout: fix narrow race in failing to kill processes
* src/timeout.c (main): Block cleanup signals earlier so that cleanup()
is not runnable until monitored_pid is in a deterministic state.
This ensures we always send a termination signal to the child
once it's forked.
* NEWS: Mention the bug fix.
Reported at https://github.com/coreutils/coreutils/issues/82
2024-03-12 14:57:47 +00:00
Pádraig Brady
c1cf5148a1 timeout: fix race where we might kill arbitrary processes
* src/timeout.c (cleanup): Handle the case where monitored_pid
might be -1, which could happen if a signal was received
immediately after a failed fork() call.  In that case it would
send the termination signal to all processes that the timeout
process has permission to send signals too.
* NEWS: Mention the bug fix.
2024-03-11 15:12:36 +00:00
Pádraig Brady
7b92e9fb26 cksum: ensure appropriate "binary" mode with --untagged
* src/digest.c (main): If --binary was enabled with a previous --tag,
then reset the binary mode to auto select if --untagged then specified.
* tests/cksum/cksum-a.sh: Add a test case.
2024-03-06 21:54:02 +00:00
Pádraig Brady
9d8890d872 mv: revert add --swap (-x) option
Since this functionality is recently available
in the exch(1) utility from util-linux,
it was thought best not to complicate mv with it.

This reverts commit 6cd2d5e533
2024-03-05 21:34:00 +00:00
Pádraig Brady
fea833591b cksum: consistently validate --length attributes
* src/digest.c (main): Only validate the last used --length
for being a multiple of 8.
* tests/cksum/b2sum.sh: Add a test case.
Fixes https://bugs.gnu.org/69546
2024-03-04 16:35:27 +00:00
Pádraig Brady
c877c7c1ee doc: fix spellings in NEWS
* NEWS: s/user/uses/; s/exisiting/existing/
2024-03-03 12:27:07 +00:00
Petr Malat
6cd2d5e533 mv: add --swap (-x) option to atomically swap 2 paths
renameat2() syscall allows atomically swapping 2 paths on one
file system. Expose this ability to the user with --swap.

* doc/coreutils.texi: Describe mv --swap option.
* src/mv.c (main): Support --swap.
* tests/mv/mv-swap.sh: Add test for mv -x.
* tests/local.mk: Reference new test.
* NEWS: Mention the new option.
2024-03-03 12:18:45 +00:00
Pádraig Brady
fcfba90d0d cat,cp,mv,dd,install,split: set the default IO size to 256KiB
* src/ioblksize.h: Add updated test results and
increase value from 128KiB to 256KiB, which was last
updated 10 years ago.
* NEWS: Mention the improvement.
2024-02-28 22:26:52 +00:00
lvgenggeng
e397ba1a31 mktemp: fix template diagnostic with --suffix
* src/mktemp.c (main): When --suffix is specified, TEMPLATE
points to the meraged buffer DEST_NAME. As X's in the suffix are
not significant to the generated random characters, the diagnostic
for too few X's should only refer to the template portion.
* tests/misc/mktemp.pl: Adjust accordingly.
* NEWS: Mention the bug fix.
2024-02-27 14:59:33 +00:00
Pádraig Brady
f3bcb59ebd tests: move join tests to their own directory
* tests/misc/join-utf8.sh: Move to tests/join
since there are now multiple join tests.
* tests/misc/join.pl: Likewise.
2024-02-27 14:27:04 +00:00
Pádraig Brady
79c628901d tests: simplify treatment of the $LOCALE_FR_UTF8 variable
* tests/df/problematic-chars.sh: Rely on gnulib setting
this to "none" where not usable.
* tests/misc/sleep.sh: Likewise.
* tests/printf/printf-mb.sh: Likewise.
* tests/printf/printf-quote.sh: Likewise.
* tests/sort/sort-debug-keys.sh: Likewise.
2024-02-27 14:27:04 +00:00
Bruno Haible
f2e70e2d19 join: avoid test failure on systems with no French UTF-8 locale
* tests/misc/join-utf8.sh: Test the value of LOCALE_FR_UTF8 against
'none', not against a missing value.
Fixes https://bugs.gnu.org/69418
2024-02-27 14:26:35 +00:00
Bruno Haible
df5fa309c2 sort: make the startup time optimization effective on glibc < 2.34
* configure.ac: Test where to find the dlopen function. Set LIB_DL.
Use it in the DLOPEN_LIBCRYPTO test.
* src/local.mk (src_sort_LDADD): Add $(LIB_DL).
2024-02-27 13:39:06 +00:00
Pádraig Brady
45411e3fc6 build: improve libcrypto library detection
* configure.ac: Match literal '.' in the file name
to avoid potential mismatches with similarly named libs.
Reported by Andreas Schwab
2024-02-26 19:10:14 +00:00
Aearil
feda512e97 wc: fix -w with breaking space over UCHAR_MAX
* src/wc.c (wc): Fix regression introduced in commit v9.4-48-gf40c6b5cf.
* tests/wc/wc-nbsh.sh: Add test cases for "standard" spaces.
Fixes https://bugs.gnu.org/69369
2024-02-26 17:33:02 +00:00
Pádraig Brady
49912bac28 cp,mv: add --update=none-fail to fail if existing files
* src/cp.c (main): Add support for --update=none-fail to provide the
functionality of diagnosing files in the destination,
and exiting with failure status.
(usage): Mark -n as deprecated.
* src/mv.c: Likewise.
* src/copy.h: Add UPDATE_NONE_FAIL definition.
* src/system.h (emit_update_parameters_note): Add --update=none-fail
description.
* doc/coreutils.texi (cp invocation): Likewise.
Also mention why -n is deprecated.
* tests/mv/update.sh: Add a test case, including precedence
with -n and other --update options.
* tests/cp/cp-i.sh: Verify that --backup and --update=none{,-fail}
are mutually exclusive.
* tests/mv/mv-n.sh: Likewise.
* NEWS: Mention the new feature.
Addresses https://bugs.gnu.org/62572
2024-02-26 17:33:02 +00:00
Pádraig Brady
9907b6f5dc cp,mv: reinstate that -n exits with success if files skipped
* src/cp.c (main): Adjust so that -n will exit success if skipped files.
* src/mv.c (main): Likewise.
* doc/coreutils.texi (cp invocation): Adjust the description of -n.
* src/system.h (emit_update_parameters_note): Adjust --update=none
comparison.
* tests/cp/cp-i.sh: Adjust -n exit status checks.
* tests/mv/mv-n.sh: Likewise.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/62572
2024-02-26 17:33:02 +00:00
Pádraig Brady
3bbdb39388 build: fix libcrypto version linked by sort at runtime
One should link the versioned lib at runtime,
and the unversioned lib at build time,
as the unversioned lib may not be installed,
and better couples the binary with the required version.

* configure.ac: Define LIBCRYPTO_SONAME, determined from
the test binary linked with -lcrypto.  Also document
why we use SHA512() in the check, rather than MD5().
* src/sort.c (link_libcrypto): Use the versioned lib in dlopen().
2024-02-26 17:33:02 +00:00
Pádraig Brady
10be42f033 maint: avoid sc_tight_scope failure in sort.c
* cfg.mk: Exclude the ptr_MD5_* symbols added in
commit v9.4-130-g7f57ac2d2, as there is no way
to declare these static given they way they're defined.
2024-02-26 17:33:02 +00:00
Paul Eggert
d9dc02b09a doc: mention -lcrypto change in NEWS 2024-02-25 21:24:04 -08:00
Paul Eggert
7f57ac2d20 sort: dynamically link -lcrypto if -R
This saves time in the usual case, which does not need -lcrypto.
* configure.ac (DLOPEN_LIBCRYPTO): New macro.
* src/sort.c [DLOPEN_LIBCRYPTO && HAVE_OPENSSL_MD5]: New macros
MD5_Init, MD5_Update, MD5_Final.  Include "md5.h" after defining
them.  Include <dlfcn.h>, and define new functions link_failure
and symbol_address.
(link_libcrypto): New function.
(random_md5_state_init): Call it before using crypto functions.
2024-02-25 18:55:16 -08:00
Paul Eggert
9b6c25510b doc: de-“note” the documentation
* doc/coreutils.texi, man/readlink.x, man/runcon.x:
* src/comm.c (usage):
* src/digest.c (usage):
* src/echo.c (usage):
* src/join.c (usage):
* src/ln.c (usage):
* src/rm.c (usage):
* src/stat.c (usage):
* src/system.h (USAGE_BUILTIN_WARNING):
* src/test.c (usage):
* src/touch.c (usage):
* src/uniq.c (usage):
Rewrite to avoid most uses of “Note that” and similar wording.
These circumlocutions are rarely needed, and avoiding them
improves readability and lessens preaching.
2024-02-25 18:55:16 -08:00
Daan De Meyer
a357cfb021 cp: add --keep-directory-symlink option
When recursively copying files into OS trees, it often happens that
some subdirectory of the source directory is a symlink in the target
directory. Currently, cp will fail in that scenario with the error:

"cannot overwrite non-directory %s with directory %s"

However, we'd like cp in this scenario to follow the destination
directory symlink and copy the files into the symlinked directory
instead. Let's support this by adding a new option
--keep-directory-symlink that makes cp follow destination directory
symlinks.

We name the option --keep-directory-symlink to keep consistent with
tar which has the same option with the same effect.

* doc/coreutils.texi (cp invocation): Describe the new option.
* src/copy.h: Add the new setting.
* src/copy.h: Adjust to follow symlinks if setting enabled.
* src/cp.c (usage): Describe the new option.
(main): Accept the new option.
* tests/cp/keep-directory-symlink.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.
2024-02-22 14:37:47 +00:00
Michel Lind
e82af7c2e6 dircolors: update list of archive file extensions
* src/dircolors.hin: Sort archive section by extension.
Treat .crate (Rust archives) as archive files
(they're essentially tar.gz files).
2024-02-19 14:37:22 +00:00
Collin Funk
430663cb35 maint: prefer #include <...> for gnulib substitute headers
* src/shuf.c: Change #include "getopt.h" to #include <getopt.h>.
* src/stat.c: Change #include "getopt.h" to #include <getopt.h>.
* src/system.h: Change #include "error.h" to #include <error.h>.

Copyright-paperwork-exempt: Yes
2024-02-19 14:19:06 +00:00
Pádraig Brady
8e3b0feb1d doc: add '[' to the info index
* doc/coreutils.texi (test invocation): Add '[' to the index.
2024-02-19 14:14:21 +00:00
Paul Eggert
ad4a9d02f5 build: update gnulib submodule to latest 2024-02-18 00:30:00 -08:00
Paul Eggert
01e52b9adc nohup: document GCC bug number
* src/nohup.c: Add GCC bug number to comment.
2024-02-18 00:29:59 -08:00
Paul Eggert
0a33c5384f ls: remove unnecessary pragmas
* src/ls.c (decode_switches): Remove pragmas.  They are no longer
needed to pacify GCC 13.2.1 with --enable-gcc-checking, and there’s
little point keeping them around for older GCC versions.
2024-02-18 00:29:59 -08:00
Paul Eggert
e298046727 maint: update GCC version comment
* src/copy.c: Update comment.
2024-02-18 00:29:59 -08:00
Paul Eggert
0fee70a9ff maint: document fix for GCC bug 109628
* src/fmt.c [14 <= __GNUC__]: Stop using pragma workaround,
as the GCC folks say the bug is no longer present in GCC 14.
2024-02-18 00:29:59 -08:00
Paul Eggert
aed1aa29db maint: remove unneeded suggest-attributes pragmas
* gl/lib/fadvise.c: Remove pragma that works around GCC bug 83559
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83559>.
This bug was fixed in GCC 9, and we needn’t worry about
--enable-gcc-warnings for compilers that old.
* src/test.c: Likewise.
2024-02-18 00:29:59 -08:00
Greg Wooledge
d39c523728 doc: fix typo in shred example
* doc/coreutils.texi (shred invocation): Fix the example
to correctly close file descriptor 3.
* THANKS.in: Remove old email since now recorded in repo history.
Reported at https://bugs.debian.org/1063837
2024-02-17 13:15:51 +00:00
Collin Funk
afa5d70c0d maint: avoid -Wshadow warning under clang
* src/env.c (parse_signal_action_params, parse_signal_block_params):
Rename OPTARG to ARG so that it does not conflict with OPTARG used by
getopt.

Copyright-paperwork-exempt: Yes
2024-02-07 15:34:13 +00:00
Pádraig Brady
f85472082c build: fix od build on clang < 17
* configure.ac: Ensure the compiler can promote 16 bit floating point
types to float, before enabling that code in od.  This was an issue
with clang 16 at least.
* src/od.c: Adjust for the new defines.
* tests/od/od-float.sh: Likewise.  Also port to the dash shell,
whose inbuilt printf doesn't support hex escapes.
2024-02-07 11:13:38 +00:00
Pádraig Brady
76604db7d2 od: support half precision floating point
Rely on compiler support for _Float16 and __bf16
to support -fH and -fB formats respectively.
I.e. IEEE 16 bit, and brain 16 bit floats respectively.
Modern GCC and LLVM compilers support both types.

clang-sect=half-precision-floating-point
https://gcc.gnu.org/onlinedocs/gcc/Half-Precision.html
https://clang.llvm.org/docs/LanguageExtensions.html#$clang-sect
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0192r4.html
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html

This was tested on:
gcc 13, clang 17 x86 (Both types supported)
gcc 7 aarch64 (Only -fH supported)
gcc 13 ppc(be) (Neither supported. Both will be with GCC 14)

* src/od.c: Support -tf2 or -tfH to print IEEE 16 bit floating point,
or -tfB to print Brain 16 bit floating point.
* configure.ac: Check for _Float16 and __bf16 types.
* doc/coreutils.texi (od invocation): Mention the new -f types.
* tests/od/od-float.sh: Add test cases.
* NEWS: Mention the new feature.
Addresses https://bugs.gnu.org/68871
2024-02-05 13:30:45 +00:00
Paul Eggert
6ec1fb46ab seq: say why not ‘x += step’
* src/seq.c (print_numbers): Add comment.
2024-01-28 23:36:17 -08:00
Pádraig Brady
c01ee18934 doc: split -C: test and document a heap overflow
This was introduced in coreutils 9.2 through commit v9.1-184-g40bf1591b,
and was fixed in coreutils 9.5 through commit v9.4-111-gc4c5ed8f4.
This issue has been assigned CVE-2024-0684.

* NEWS: Mention the bug fix.
* tests/split/line-bytes.sh: Add a test case.
Reported by Valentin Metz.
2024-01-18 16:52:36 +00:00
Pádraig Brady
aa50ea55ea tests: make ulimit -v interact better with ASAN
ulimit -v is generally not supported with ASAN, giving errors like:
  "ReserveShadowMemoryRange failed while trying to map 0x... bytes.
   Perhaps you're using ulimit -v"

* tests/cp/link-heap.sh: Mention ASAN as a possible reason for skipping.
* tests/csplit/csplit-heap.sh: Likewise.
* tests/cut/cut-huge-range.sh: Likewise.
* tests/dd/no-allocate.sh: Likewise.
* tests/printf/printf-surprise.sh: Likewise.
* tests/rm/many-dir-entries-vs-OOM.sh: Likewise.
* tests/head/head-c.sh: Only skip the part of the test needing ulimit.
* tests/split/line-bytes.sh: Likewise.
2024-01-17 23:59:49 +00:00
Paul Eggert
c4c5ed8f4e split: do not shrink hold buffer
* src/split.c (line_bytes_split): Do not shrink hold buffer.
If it’s large for this batch it’s likely to be large for the next
batch, and for ‘split’ it’s not worth the complexity/CPU hassle to
shrink it.  Do not assume hold_size can be bufsize.
2024-01-17 12:19:14 -08:00
Sylvestre Ledru
b09dc6306e tests: ls: add a test to verify that '+' is added
* tests/ls/acl.sh: Add a new test.
* tests/local.mk: Reference the new test.
2024-01-10 22:51:13 +00:00
Samuel Tardieu
f07f5b008f maint: add attributes to two functions without side effects
* src/date.c (res_width): This function computes its result solely
from the value of its parameter and qualifies for the const attribute.
* src/tee.c (get_next_out): This function has no side effect and
qualifies for the pure attribute.
* THANKS.in: Remove duplicate now that author has a commit in the repo.

Those two functions were flagged by GCC 12.3.0,
though not by GCC 13.2.1.
2024-01-06 15:42:44 +00:00
Pádraig Brady
a966dcdb69 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: Manually update copyright year,
until we fully sync with gnulib at a later stage.
* tests/sample-test: Adjust to use the single most recent year.
2024-01-01 13:27:23 +00:00
Paul Eggert
752ccef3eb maint: pacify recent clang better
* configure.ac: Clang now seems to have -Wformat-extra-args,
-Wimplicit-const-int-float-conversion, and
-Wtautological-constant-out-of-range-compare on by default,
so disable them even if --enable-gcc-warnings is not used.
Rely on Gnulib’s check for clang rather than rolling our own.
2023-12-31 19:49:26 -08:00
Paul Eggert
a9e4725773 maint: pacify clang -Winclude-next-absolute-path
* gl/lib/xdectoint.c: Use #include <...> instead of #include "...".
2023-12-31 19:49:26 -08:00
Paul Eggert
b8f0502bb1 build: update gnulib submodule to latest 2023-12-31 19:49:26 -08:00
Paul Eggert
8a757c220b ls: omit bad_cast
* src/ls.c (decode_switches): Declare some local vars to be
char const *, not char *, and omit unnecessary bad_cast calls.
2023-12-31 19:49:26 -08:00
Paul Eggert
1f651f4b3d split: omit bad_cast
* src/split.c (infile): Now char const *, not char *.
(main): Omit unnecessary bad_cast calls.
2023-12-31 19:49:26 -08:00
Pádraig Brady
9e67ccd745 sort: fix thousands grouping handling on single byte locales
* gl/lib/strnumcmp-in.h (numcompare): After commit v9.0-8-g6cafb122f,
we need to treat characters as signed to avoid invalid comparisons
between negative integers and unsigned characters.
* NEWS: Mention the bug fix.
2023-12-29 18:04:36 +00:00
Pádraig Brady
76ec516242 tests: numfmt: fix test related to lower case 'k' SI unit
* tests/misc/numfmt.pl: Following on from v9.4-86-g615167cc4,
adjust this test accordingly.  This test was being skipped
on some systems, and so only noticed now.
Reported by Jim Meyering.
2023-12-29 18:04:36 +00:00
Pádraig Brady
ebb985dc41 tests: run locale tests on more systems
* tests/misc/numfmt.pl: Determine the thousands grouping character
in use, rather than skipping locale tests when it's not a space.
For example fr_FR.UTF-8 uses "NARROW NO-BREAK SPACE" as the grouping
char on modern glibc systems at least.
* tests/sort/sort-h-thousands-sep.sh: Likewise.
2023-12-29 18:04:29 +00:00
Pádraig Brady
4dda343663 maint: distribute new header from previous commit
* src/local.mk: Reference the new header, so it's distributed.
2023-12-29 17:51:19 +00:00
Pádraig Brady
9cc8d6ff59 maint: merge chgrp and chown sources
chown is a close superset of chgrp functionality,
so merge sources to avoid unwanted divergence in future.
This removes about 300 lines in chgrp.c

* build-aux/gen-single-binary.sh: Generate new rules for chgrp.
* cfg.mk: Exclude new wrappers.
* po/POTFILES.in: Remove chgrp.c
* src/chgrp.c: Remove.
* src/chown-chgrp.c: New wrapper.
* src/chown-chown.c: Likewise.
* src/chown.c (main): Prepend ':' for chgrp(1).
* src/chown.h: Define both operating modes.
(usage): Adjust depending on utility being called.
* src/coreutils-chgrp.c: Likewise.
* src/local.mk: Reference new wrappers.
2023-12-27 19:51:00 +00:00
Christian Göttsche
98d463ef5d copy,install: avoid unnecessary security context translations
Do not perform SELinux context translation for operations not involving
user input or output.  Context translation converts MCS/MLS labels into
human readable form, which is useful for user facing applications like
ls(1) or the --context=CTX argument of cp(1).

* src/copy.c (set_process_security_ctx): Use raw selinux variants.
* src/install.c (need_copy): Likewise.
(setdefaultfilecon): Likewise.
* src/selinux.c (computecon): Likewise.
(defaultcon): Likewise.
* tests/cp/no-ctx.sh: Add raw variants to preload lib.
* NEWS: Mention the improvement.
2023-12-19 17:34:33 +00:00
Pádraig Brady
343b8d7ba7 build: update gnulib to latest
* gnulib: Primarily to get raw selinux wrappers
2023-12-19 17:18:46 +00:00
Pádraig Brady
c343bee1b5 maint: avoid false positive warning with newer gcc
* src/pr.c (read_line): GCC 13.2.1 can't discern that CHARS
is not used with '\n', so avoid the -Werror=maybe-uninitialized
issue in dev builds.
2023-12-17 17:19:29 +00:00
Pádraig Brady
63e9f1ae61 doc: cp --no-clobber: improve documentation
* doc/coreutils.texi (cp invocation): Reference the related --update
option, like we had already done in mv invocation.
* src/cp.c (usage): State clearly what --no-clobber does,
indicating it's protection focused, rather than being update focused.
2023-12-17 17:19:11 +00:00
Pádraig Brady
da091b3ab3 chgrp: add --from parameter similar to chown
* doc/coreutils.texi (chown invocation): Convert --from option
description to a macro and call from ...
(chgrp description): ... here.
* src/chown-core.h (emit_from_option_description): A new function
refactored from ...
* src/chown.c (usage): ... here, and called from ...
* src/chgrp.c (usage): ... here.
(main): Accept the --from option as chown(1) does.
* po/POTFILES.in: Add chown-core.h as now translated.
* tests/chown/basic.sh: Decouple the root user from id 0.
* tests/chgrp/from.sh: A new test largely based on chown/basic.sh.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.
Suggested by Ed Neville.
2023-12-15 13:19:27 +00:00
Pádraig Brady
0d9547474d maint: remove obsolete AC_PROG_GCC_TRADITIONAL
* configure.ac: Remove obsolete macro call.
Recent autoconf warns that it is obsolete.
AC_PROG_CPP sets up the -traditional-cpp option if required.
GCC ignores -traditional since commit f458d1d5 (2002).
Fixes https://bugs.gnu.org/67756
2023-12-11 17:03:33 +00:00
Pádraig Brady
4de72b7d9f doc: ls: fix regression in -f description
The description of -f regressed in coreutils 9.0

* doc/coreutils.texi (ls invocation): Detail which options
are enabled/disabled with -f.
* src/ls.c (usage): Likewise.
(decode_switches): Update comments.
Fixes https://bugs.gnu.org/67765
2023-12-11 14:37:02 +00:00
Pádraig Brady
49c8dab5b2 maint: add list/obstack.h to .gitignore
Following recent gnulib update
2023-12-11 14:34:46 +00:00
Pádraig Brady
9becda5d93 build: update gnulib submodule to latest
* bootstrap: Copy from latest Gnulib,
to fix --bootstrap-sync with other options.
2023-12-10 19:05:23 +00:00
Pádraig Brady
0ee8b03422 doc: touch: clarify --time description in man page
* src/touch.c (usage): Reorganise the description to be similar to
the format used for the ls --time description, which formats better
when converted to a man page.  Also separate the description
to allow for more granular translations.
Fixes https://bugs.gnu.org/67656
2023-12-06 13:07:43 +00:00
dann frazier
73d119f4f8 tail: fix tailing sysfs files where PAGE_SIZE > BUFSIZ
* src/tail.c (file_lines): Ensure we use a buffer size >= PAGE_SIZE when
searching backwards to avoid seeking within a file,
which on sysfs files is accepted but also returns no data.
* tests/tail/tail-sysfs.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/67490
2023-12-01 23:01:32 +00:00
Pádraig Brady
615167cc4d numfmt: support lowercase 'k' for Kilo and Kibi
For consistency with the "SI" standard, and with other coreutils
which output a lowercase 'k' in "SI" mode.

* src/numfmt.c (suffix_power): Treat 'k' like 'K' on input.
(double_to_human): Output lowercase 'k' in SI mode.
(usage): Adjust accordingly.
* doc/coreutils.texi: Mention 'k' accepted, and printed in SI mode.
* tests/misc/numfmt.pl: Adjust accordingly.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/47103
2023-11-27 19:41:49 +00:00
Paul Eggert
74b9d6a6e8 uniq: fix bug with -w in multibyte locales
-w counted bytes not characters, which is wrong in multibyte locales.
This bug exists even in Fedora, which is why the recently-added
test cases from Fedora didn’t catch it.
* src/uniq.c (find_field): New arg PLEN.  All callers changed.
Compute length of field correctly in multi-byte locales.
(different): Don’t worry about check_chars; find_field now does that.
* tests/uniq/uniq.pl: Test for this bug.
2023-11-16 11:37:25 -08:00
Paul Eggert
0ed9d1823a tests: omit inapplicable test code
* tests/misc/join.pl, tests/uniq/uniq.pl:
Remove test for "invalid byte, character or field list" message
that is not generated.
2023-11-16 11:37:25 -08:00
Paul Eggert
77201c506f uniq: change macro to function
* src/uniq.c (swap_lines): New static function, replacing
the old SWAP_LINES macro.  These days this is just as fast.
All uses changed.
2023-11-16 11:37:25 -08:00
Paul Eggert
3bee7c9754 uniq: prefer static init
* src/uniq.c (skip_fields, skip_chars, check_chars, count_occurrences)
(output_unique, output_first_repeated, output_later_repeated)
(delimit_groups): Initialize statically, rather than in ‘main’.
This shrinks the executable a bit.
2023-11-16 11:37:25 -08:00
Paul Eggert
a72b7823b4 uniq: simplify and fix unlikely bug by using bool
* src/uniq.c (enum countmode): Remove this type.
(count_occurrences): New static var, replacing the old countmode,
and of type boolean instead of a two-value enum type that was
confusing (and which caused a hard-to-test bug when the count
exceeded INTMAX_MAX - 1).  All uses changed.
2023-11-16 11:37:25 -08:00
Paul Eggert
a257b63ce7 uniq: prefer signed integers
* src/uniq.c (skip_fields, skip_chars, check_chars, size_opt)
(find_field, different, writeline, check_file, main):
Prefer signed to unsigned integer types, since this allows
for better runtime checking with -fsanitize=undefined.
2023-11-14 23:15:18 -08:00
Paul Eggert
23e26ed972 maint: DECIMAL_DIGIT_ACCUMULATE uses stdckdint.h
* src/system.h: Include <stdckdint.h>, since the new
DECIMAL_DIGIT_ACCUMULATE uses it.
Do not include stdckdint.h from files that also include system.h.
(DECIMAL_DIGIT_ACCUMULATE): Omit last arg, which is no longer needed.
Reimplement by using C23-style stdckdint.h’s ckd_mul and ckd_add,
as that’s more standard and is more likely to generate better code.
2023-11-14 20:38:24 -08:00
Paul Eggert
3e0d7787e6 pinky: fix string size calculation
* src/pinky.c (count_ampersands): Simplify and return idx_t.
(create_fullname): Compute proper destination string size,
basically, by adding (ulen - 1) * ampersands rather than ulen *
(ampersands - 1).  Problem found on CHERI-64.
2023-11-11 00:17:49 -08:00
Paul Eggert
4c15a1b6e6 maint: port randread to FreeBSD 14
* gl/lib/randread.c (POINTER_IS_ALIGNED): Rename from
ALIGNED_POINTER to avoid a collision with <machine/param.h>
on FreeBSD 14.
2023-11-11 00:17:49 -08:00
Paul Eggert
394b29aaff build: update gnulib submodule to latest 2023-11-11 00:17:48 -08:00
Pádraig Brady
7f2c97a241 ls: fix recent regression in size alignment
* src/ls.c (print_long_format): Use correct column width,
introduced due to a copy/paste error in commit v9.4-2-gcbb6dfec5
* tests/ls/size-align.sh: Add a test.
* tests/local.mk: Reference the new test.
Fixes https://bugs.gnu.org/66919
2023-11-03 16:34:38 +00:00
Paul Eggert
56e9acb292 join: fix recently introduced NUL bug
* src/join.c (xfields): Simplify and fix bug with fields
that start with a NUL byte when -t is not used.
* tests/misc/join-utf8.sh: Also test when -t is not used,
and when a field starts with NUL.
2023-10-30 10:49:44 -07:00
Paul Eggert
bd45f0963c maint: pacify ‘make syntax-check’
* tests/misc/join-utf8.sh: Omit fail=0.
Fix framework_failure_ typo.
* tests/misc/join.pl: Change ` to '.
2023-10-30 01:33:19 -07:00
Paul Eggert
ba5017b65a maint: copy join, uniq tests from Fedora
* tests/misc/join.pl, tests/uniq/uniq.pl:
Copy from Fedora 39.  This adds more multi-byte tests.
2023-10-30 01:24:43 -07:00
Paul Eggert
11b01fc21f join,uniq: support multi-byte separators
* NEWS: Mention this.
* bootstrap.conf (gnulib_modules): Remove cu-ctype, as this module
is now more trouble than it’s worth.  All uses removed.
Add skipchars.
* gl/lib/cu-ctype.c, gl/lib/cu-ctype.h, gl/modules/cu-ctype:
Remove.
* gl/lib/skipchars.c, gl/lib/skipchars.h, gl/modules/skipchars:
* tests/misc/join-utf8.sh:
New files.
* src/join.c: Include skipchars.h and mcel.h instead of cu-ctype.h.
(tab): Now mcel_t, not int.  All uses changed.
(output_separator, output_seplen): New static vars.
(eq_tab, newline_or_blank, comma_or_blank): New functions.
(xfields, prfields, prjoin, add_field_list, main):
Support multi-byte characters.
* src/numfmt.c: Include ctype.h, skipchars.h.
Do not include cu-ctype.h.
(newline_or_blank): New function.
(next_field): Support multi-byte characters.
* src/sort.c: Include ctype.h instead of cu-ctype.h.
(inittables): Open-code field_sep since it no longer exists.
‘sort’ is not multi-byte safe yet, but when it is this code
will need revamping anyway.
* src/uniq.c: Include mcel.h and skipchars.h instead of cu-ctype.h.
(newline_or_blank): New function.
(find_field): Support multi-byte characters.
* tests/local.mk (all_tests): Add tests/misc/join-utf8.sh
2023-10-30 00:58:04 -07:00
Paul Eggert
2709bea0f4 test: allow non-blank white space in numbers
* src/test.c (find_int): Use isspace, not isblank,
for compatibility with how strtol works, which
is how most other shells do this.
2023-10-30 00:58:04 -07:00
Paul Eggert
a3ce33c106 stdbuf: port to oddball toupper
* src/stdbuf.c: Do not include ctype.h.
(set_libstdbuf_options): Use c_toupper, not toupper,
since the C locale is intended here.
2023-10-30 00:58:04 -07:00
Paul Eggert
8d60cd8ad6 dircolors: assume C-locale spaces
* src/dircolors.c: Include c-ctype.h, not ctype.h.
(parse_line): Use c_isspace, not isspace, as the .dircolors
file format (which does not seem to be documented!) appears
to be ASCII.
2023-10-30 00:58:04 -07:00
Paul Eggert
5602342a16 maint: port to oddball tolower
* src/digest.c (hex_equal): Work even in oddball locales
where tolower does not work as expected on ASCII letters.
2023-10-30 00:58:04 -07:00
Paul Eggert
4edb14d20f maint: include ctype.h selectively
Include ctype.h only in files that need it.  Many of its uses
are incorrect, as they assume single-byte locales.  The idea is
to remove the incorrect uses later, when there is time.
* src/chroot.c, src/csplit.c, src/dd.c, src/digest.c, src/dircolors.c:
* src/expand-common.c, src/expand.c, src/fmt.c, src/fold.c, src/ls.c:
* src/od.c, src/pinky.c, src/pr.c, src/ptx.c, src/seq.c:
* src/set-fields.c, src/split.c, src/stdbuf.c, src/test.c:
* src/tr.c, src/truncate.c, src/unexpand.c, src/wc.c:
Include ctype.h.
* src/system.h: Do not include ctype.h.

include ctype.h.o
2023-10-30 00:58:04 -07:00
Paul Eggert
684e810ae2 maint: move field_sep into separate module
This is so that we don’t need to have every source file
include ctype.h.
* bootstrap.conf (gnulib_modules): Add cu-ctype.
* gl/lib/cu-ctype.c, gl/lib/cu-ctype.h, gl/modules/cu-ctype:
New files.
* src/join.c, src/numfmt.c, src/sort.c, src/uniq.c:
Include cu-ctype.h, for field_sep.
* src/system.h (field_sep): Remove; now supplied by cu-ctype.
2023-10-30 00:58:04 -07:00
Paul Eggert
2f3d9524bb digest: omit unnecessary b2sum includes
* src/blake2/b2sum.c: Do not include string.h, errno.h,
ctype.h, unistd.h, getopt.h.
2023-10-30 00:58:03 -07:00
Paul Eggert
0292a5678a maint: prefer c_isxdigit when that is the intent
* src/digest.c (valid_digits, split_3):
* src/echo.c (main):
* src/printf.c (print_esc):
* src/ptx.c (unescape_string):
* src/stat.c (print_it):
When the code is supposed to support only POSIX-locale hex digits,
use c_isxdigit rather than isxdigit.  Include c-ctype.h as needed.
This defends against oddball locales where isxdigit != c_isxdigit.
2023-10-30 00:58:03 -07:00
Pádraig Brady
f7e25d5bb5 maint: fix syntax check issue
* src/basenc.c: Fix preprocessor indentation.
2023-10-28 13:13:50 +01:00
Pádraig Brady
8c735f6585 base32,base64: disallow non-canonical encodings
This will make decoding more resilient to corruption
whether due to transmission errors or nefarious adjustment.
See https://eprint.iacr.org/2022/361.pdf

* gnulib: Update to commit 3f463202bd enforcing canonical encoding.
* tests/basenc/base64.pl: Add test cases, and adjust existing cases.
* NEWS: Mention the change in behavior.
2023-10-28 13:13:34 +01:00
Paul Eggert
60bd7bad9d basenc: fix unlikely locale issue; tune
This sped up ‘basenc -d --base16’ by 60% on my old platform,
AMD Phenom II X4 910e, Fedora 38.
* src/basenc.c (struct base16_decode_context): Simplify by
omitting have_nibble.  ‘nibble’ is now negative if it’s missing.
All uses changed.
(B16): New macro, inspired by ../lib/base64.c.
(base16_to_int): New static var, likewise.
(isubase16): Reimplement using base16_to_int, since isxdigit is
not guaranteed to succeed on the chars we want when the locale is
oddball.
(base16_decode_ctx): Tune by using base16_to_int and by
2023-10-25 15:09:27 -07:00
Paul Eggert
dcc1514d9a basenc: tweak checks to use unsigned char
This tends to generate better code, at least on x86-64,
because callers are just as fast and callees can avoid a conversion.
* src/basenc.c: The following renamings also change the arg type
from char to unsigned char.  All uses changed.
(isubase): Rename from isbase.
(isubase64url): Rename from isbase64url.
(isubase32hex): Rename from isbase32hex.
(isubase16): Rename from isbase16.
(isuz85): Rename from isz85.
(isubase2): Rename from isbase2.

2023-10-24  Paul Eggert  <eggert@cs.ucla.edu>

* src/basenc.c (struct base16_decode_context):
Simplify by storing -1 for missing nibbles.  All uses changed.
2023-10-25 15:09:27 -07:00
Paul Eggert
f4a59d453e build: update gnulib submodule to latest 2023-10-25 15:09:27 -07:00
Pádraig Brady
5f538c27a1 basenc: --base16: also allow lower case with --ignore-garbage
* src/basenc.c (isbase16): Also return true for lower case.
* tests/basenc/basenc.pl: Add a test case.
Reported by Paul Eggert.
2023-10-25 14:04:00 +01:00
Pádraig Brady
d733f2ec26 basenc: --base16: support lower case hex digits
* src/basenc.c (base16_decode_ctx): Convert to uppercase
before converting from hex.
* tests/basenc/basenc.pl: Add a test case.
* NEWS: Mention the change in behavior.
Addresses https://bugs.gnu.org/66698
2023-10-23 14:04:38 +01:00
Pádraig Brady
2e0dcd87bf doc: fix RFC references
* doc/coreutils.texi: Adjust RFC URLs as the original
now give 404 errors.
2023-10-23 12:29:03 +01:00
Pádraig Brady
caa716803a tests: move all basenc tests to their own directory
* tests/misc/base64.pl: Move to tests/basenc/base64.pl
* tests/misc/basenc.pl: Move to tests/basenc/basenc.pl
* tests/local.mk: Adjust accordingly
2023-10-06 18:22:35 +01:00
Pádraig Brady
378dc38f48 basenc: auto pad base32 and base64 inputs when decoding
Padding of encoded data is useful in cases where
base64 encoded data is concatenated / streamed.
I.e. where there are padding chars _within_ the stream.
In other cases padding is optional and can be inferred.
Note we continue to treat partial padding as invalid,
as that would be indicative of truncation.

* src/basenc.c (do_decode): Auto pad the end of the input.
* NEWS: Mention the change in behavior.
* tests/misc/base64.pl: Adjust to not fail for missing padding.
Addresses https://bugs.gnu.org/66265
2023-10-06 18:21:12 +01:00
Paul Eggert
a2434d3e58 sort: improve --help
Problem reported by Jorge Stolfi (bug#66253).
* src/sort.c (usage): Suggest looking at the manual for -n details.
2023-09-28 18:03:34 -07:00
Pádraig Brady
0c46704832 doc: rm --help: mention that '.' or '..' are rejected
* src/rm.c (usage): State that '.' or '..' are rejected.
2023-09-25 15:26:31 +01:00
Paul Eggert
de4e704273 wc: pacify ‘make syntax-check’
* src/wc_avx2.c (wc_lines_avx2): Explicitly make it ‘extern’.
Not sure why this is needed.
2023-09-23 17:20:26 -07:00
Paul Eggert
2245a95806 wc: distribute src/wc.h
* src/local.mk (noinst_HEADERS): Add src/wc.h.
2023-09-23 17:20:25 -07:00
Paul Eggert
f40c6b5cf2 wc: goto considered harmful
* src/wc.c: Do not include assure.h.  Replace the only
use of ‘assure’ with ‘unreachable’ which is good enough.
(wc, main): Remove labels and gotos.  This doesn’t affect
performance in any way I can measure, and makes the code
a bit easier to follow.
2023-09-23 17:07:52 -07:00
Paul Eggert
6b8b1f9e77 wc: prefer signed integers
Prefer signed to unsigned integers, to make it easier to catch
integer overflow errors.
* src/wc.c: Do not include safe-read.
(total_lines_overflow, total_words_overflow, total_chars_overflow)
(total_bytes_overflow): Now bool, not uintmax_t.  All uses changed.
(max_line_length): Now intmax_t, not uintmax_t.  All uses changed.
The total_... vars are still uintmax_t because overflow into them
is checked.
(page_size): Now idx_t, not size_t.
(wc_lines, wc, get_input_fstatus, compute_number_width, main):
Prefer signed to unsigned ints where either should do.
(wc_lines, wc): Use read rather than safe_read, since we don’t
need safe_read’s checks for huge buffers.
(wc): Redo call to mbrtoc32 to lessen the number of comparisons
against its returned value.  Do this partly by keeping a pointer
to the end of the buffer rather than a count.  Simplify
overflow-checking code.
(compute_number_width): Check for integer overflow.
Don’t assume size_t fits into unsigned long.
* src/wc.h (struct wc_lines): Prefer signed integers.
* src/wc_avx2.c: Do not include safe-read.h.
(wc_lines_avx2): Prefer signed integers.  Use read, not safe_read.
2023-09-23 17:07:52 -07:00
Paul Eggert
8d41285fe4 wc: improve avx2 API
* src/wc.c: Use "#include <...>" for files not in the current dir.
Include "wc.h" instead of declaring wc_lines_avx2 by hand.
(wc_lines): New API, with no file name (no longer needed) and
with a return struct rather than arg pointers.  All uses changed.
Use avx2_supported directly instead of using a function pointer.
Exploit C99-style declarations after statements.
Multiply by 15 rather than dividing; it’s faster and more accurate
and cannot overflow here.
(wc): Simplify based on wc_lines API change.
* src/wc.h: New file.
* src/wc_avx2.c: Include it, to check API better.
(wc_lines_avx2): Use new API.  All uses changed.  Exploit C99.
Make locals more local.
2023-09-23 17:07:52 -07:00
Paul Eggert
769ace51e8 factor,tail: avoid quadratic reallocation
* src/factor.c (struct mp_factors): New member nalloc.
(mp_factor_init): Initialize it.
* src/factor.c (mp_factor_insert):
* src/tail.c (parse_options): Use xpalloc to avoid quadratic
worst-case behavior on reallocation.
* src/tail.c (pids_alloc): New static var.
2023-09-23 01:15:50 -07:00
Paul Eggert
9ecc4f4e44 doc: mention Unicode exceptions for wc 2023-09-23 00:28:28 -07:00
Paul Eggert
a6064bb864 wc: simplify by removing SUPPORT_OLD_MBRTOWC
* src/wc.c (SUPPORT_OLD_MBRTOWC): Remove.  All uses removed.
(wc): Simplify by assuming C99-or-later behavior for mbrtoc32,
which after all is a C11 API.  Fix the !SUPPORT_OLD_MBRTOWC
code, which evidently was never tested seriously.
2023-09-23 00:28:27 -07:00
Paul Eggert
17a9e79023 wc: 3× speedup in C locale
The 3× speedup was measured by invoking 'wc $(find * -type f)'
on the coreutils sources etc. on an Ubuntu 23.04 x86-64.
These changes also speed up wc 20% in UTF-8 locales.
* src/wc.c (wc_isprint, wc_isspace): New static vars.
(wc): Use them for speed.
(main): Initialize them if needed.
(isnbspace): Remove; no longer used.
2023-09-23 00:28:27 -07:00
Paul Eggert
bee39b93f5 wc: treat encoding errors as non white space
* src/wc.c (wc): Treat encoding errors like non white space
characters.
2023-09-23 00:28:27 -07:00
Paul Eggert
31076e8689 wc: fix word count bug
* bootstrap.conf (gnulib_modules): Remove c32isprint.
* src/wc.c (wc): Consider all non-white-space characters
to be word constituents, even if they are not printable.
POSIX requires this, and it is what BSD does.
Partly do this by simplifying the check for a word,
by counting word starts rather than word ends.
* tests/wc/wc.pl: Test for the bug.
2023-09-23 00:28:27 -07:00
Paul Eggert
a6648d4102 maint: omit some unused function tests
* m4/jm-macros.m4: Do not check for ftruncate, iswspace,
mkfifo, mbrlen, sysctl.  Coreutils no longer uses the
corresponding HAVE_* macros, typically because Gnulib
handles them now.
* src/wc.c (iswspace): Remove; unused.
2023-09-23 00:28:27 -07:00
Paul Eggert
fc1822a042 sort: not a special case for mbrtowc
* configure.ac (GNULIB_MBRTOWC_SINGLE_THREAD): Define.
2023-09-23 00:28:27 -07:00
Paul Eggert
14d35d5bad maint: prefer char32_t to wchar_t
This should work better on non-glibc platforms that don’t
use Unicode for wchar_t.  However, POSIX appears to prohibit
this for printf.c so leave that alone.
* bootstrap.conf (gnulib_modules): Add btoc32, c32iscntrl,
c32isprint, c32isspace, c32width, mbrtoc32.  Remove btoc, wcwidth.
* src/df.c, src/ls.c, src/wc.c:
Include uchar.h instead of wchar.h and wctype.h.
* src/df.c (replace_invalid_chars):
* src/ls.c (quote_name_buf):
* src/wc.c (isnbspace, wc):
Use char32_t instead of wchar_t.
2023-09-23 00:28:27 -07:00
Paul Eggert
c5a210a9c8 wc: simplify #if MB_LEN_MAX
* src/wc.c: Don’t have special #ifs for platforms where
MB_LEN_MAX is 1.  On these platforms, MB_CUR_MAX is 1 as well,
so the compiler should optimize away all multi-byte code.
2023-09-23 00:28:26 -07:00
Paul Eggert
fb51f74ff6 wc: avoid undefined conversion state
* src/wc.c (wc): When mbrtowc returns (size_t) -1, zero the
conversion state, since POSIX says it’s undefined.
2023-09-23 00:28:26 -07:00
Paul Eggert
092f8178c0 maint: use mbszero
* bootstrap.conf (gnulib_modules): Add mbszero.
* src/df.c (replace_invalid_chars):
* src/ls.c (quote_name_buf):
* src/pathchk.c (portable_chars_only):
* src/printf.c (STRTOX):
* src/wc.c (wc):
Prefer mbszero to clearing an mbstate_t by hand.
2023-09-23 00:28:26 -07:00
Paul Eggert
c80a538d96 maint: prefer mcel
This causes Gnulib code to also use mcel, which is more consistent.
* bootstrap.conf (avoided_gnulib_modules): Avoid mbuiter
and mbuiterf, since we can now just use mcel.  This avoids
the need to ship and compile mbchar and these modules.
(gnulib_modules): Change mcel to mcel-prefer.
2023-09-23 00:28:26 -07:00
Paul Eggert
6c16044d8d wc: stop worrying about EBCDIC, shift-JIS, etc
* src/wc.c: Do not include mbchar.h.
(wc): Check for ASCII characters instead of using is_basic.
Other parts of Gnulib and coreutils already assume the encoding
is upward compatible with ASCII, and the old code wouldn’t
have worked anyway with shift-JIS.
2023-09-23 00:28:26 -07:00
Paul Eggert
17bddc047b expr: use mcel
The mcel API is simpler and corresponds more closely to how
Emacs etc. behave when the input has encoding errors,
since it treats each encoding-error byte separately.
* bootstrap.conf (gnulib_modules): Add mcel.
* src/expr.c: Include mcel.h instead of mbuiter.h.
(mbs_logical_cspn, mbs_logical_substr, mbs_offset_to_chars):
Use mcel API.
(mbs_logical_substr): Use ximemdup0 so as not to waste memory in
the result, fixing a FIXME.
2023-09-23 00:28:26 -07:00
Paul Eggert
654700ba5d build: update gnulib submodule to latest 2023-09-23 00:28:26 -07:00
Pádraig Brady
2593502290 build: avoid build failures on gcc <= 10, or clang
On gcc 10 the following build failure occurs:
  "error: a label can only be part of a statement
   and a declaration is not a statement"
This is because the current code is non standards conforming,
but GCC >= 11 will compile it (even with the -Wpedantic option).
This issue is tracked for GCC at:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111526

* src/tail.c (parse_options): Avoid a declaration after label,
by using a surrounding block.
2023-09-21 19:04:14 +01:00
Stephen Kitt
d24a117707 tail: allow multiple PIDs
tail can watch multiple files, but currently only a single writer. It
can be useful to watch files from multiple writers, or even processes
not directly related to the files (e.g. watch log files written by a
server process, for the duration of a test driven by a separate
client).

* src/tail.c (writers_are_dead): New function.
(tail_forever): Use it to wait for writers.
(tail_forever_inotify): As above.
(parse_options): Manage --pid options in an array.
* doc/coreutils.texi: Update documentation.
* tests/tail/pid.sh: Add a variant with two PIDs.
* News: Mention the new feature.
2023-09-20 15:53:34 +01:00
Sylvestre Ledru
8367b95a13 ls: --dired now implies long format with hyperlinks disabled
Currently --dired is silently ignored
with conflicting output formats

* src/ls.c (decode_switches): Set default format and hyperlink mode
when the --dired option is specified.
* tests/ls/dired.sh: Check that formats are implied / overridden.
* NEWS: Mention the change in behavior.
* doc/coreutils.texi (ls invocation): Adjust --dired description.
2023-09-17 18:47:50 +01:00
Sylvestre Ledru
3564e3a572 tests: improve ls --dired testing
* tests/ls/dired.sh: Verify ls --dired output against varying offsets.
2023-09-15 13:37:27 +01:00
Pádraig Brady
3b0f5b9971 maint: use C99 int size specifiers rather than PRI.MAX defines
Following on from commit v9.3-128-gf31229ebd
replace all uses of the PRI.MAX portability defines
with C99 size specifiers %z, %j, and %t.
2023-09-13 23:08:02 +01:00
Pádraig Brady
75e24853b7 doc: add subsections for cksum nodes
* doc/coreutils.texi: Specify each of the cksum nodes as a subsection,
so that the docs are organised appropriately in the pdf and html manual.
2023-09-11 20:45:42 +01:00
Paul Eggert
c7ec75a276 cp,mv,install: add copy_internal comment
* src/copy.c (copy_internal): Add comment about
some particularly tricky logic.
2023-09-08 16:25:39 -07:00
Paul Eggert
3cff27ddc1 cp: avoid needless unlinkat after fstatat ELOOP
* src/copy.c (copy_internal): When cp -f's fstatat fails on the
destination with ELOOP, report an error immediately when fstatat
used AT_SYMLINK_NOFOLLOW, as the later unlinkat would fail too.
2023-09-08 16:25:39 -07:00
Paul Eggert
a66a4b77a5 cp,mv,install: minor copy_internal refactoring
* src/copy.c (copy_internal): Redo to avoid need for calculating
fstatat_flags when not needed.  This is for clarity, not speed.
2023-09-08 16:25:39 -07:00
Paul Eggert
67324bf19c cp,mv,install: fix comment punctuation
* src/copy.h: Fix punctuation in comment.
2023-09-08 16:25:39 -07:00
Paul Eggert
69bd8be403 cp,mv,install: simplify copy_internal
* src/copy.c (copy_internal): Simplify.
2023-09-08 16:25:39 -07:00
Paul Eggert
68f4c238ca maint: prefer psame_inode, PSAME_INODE, STP_*
Prefer psame_inode, PSAME_INODE, STP_NBLOCKS, and STP_BLKSIZE,
which take addresses of objects, to their counterparts that
take the whole objects.  In some cases the whole objects might
not be initialized, which would be undefined behavior strictly
speaking.
* gl/lib/root-dev-ino.h (ROOT_DEV_INO_CHECK):
* src/cp-hash.c (src_to_dest_compare):
* src/ls.c (dev_ino_compare):
* src/pwd.c (robust_getcwd):
Prefer PSAME_INODE to SAME_INODE.
* src/chown-core.c (restricted_chown):
* src/copy.c (copy_reg, same_file_ok, source_is_dst_backup)
(copy_internal):
* src/ln.c (do_link):
* src/pwd.c (logical_getcwd):
* src/sort.c (avoid_trashing_input):
* src/split.c (create):
* src/stat.c (find_bind_mount):
Prefer psame_inode to SAME_INODE.
* src/copy.c (infer_scantype):
* src/du.c (process_file):
* src/ls.c (gobble_file, print_long_format)
(print_file_name_and_frills, length_of_file_name_and_frills):
* src/stat.c (print_stat):
Prefer STP_NBLOCKS to ST_NBLOCKS.
* src/copy.c (copy_reg):
* src/head.c (elide_tail_bytes_file, elide_tail_lines_file):
* src/ioblksize.h (io_blksize):
* src/od.c (skip):
* src/shred.c (do_wipefd):
* src/stat.c (print_stat):
* src/tail.c (tail_bytes):
* src/truncate.c (do_ftruncate):
* src/wc.c (wc):
Prefer STP_BLKSIZE to ST_BLKSIZE.
* src/ioblksize.h (io_blksize):
Arg is now struct stat const *, not struct stat.  All callers changed.
2023-09-04 23:12:02 -07:00
Paul Eggert
217d68104a build: update gnulib submodule to latest 2023-09-04 23:12:02 -07:00
Paul Eggert
65a1c5b441 cp,mv,install: a bit more up-to-date source stat
* src/copy.c (copy_reg): Replace caller’s source status
with the more recent version.
2023-09-04 23:12:02 -07:00
Paul Eggert
9cd52bd999 cp,mv,install: fix chmod on Linux CIFS
This bug occurs only when temporarily setting the mode to the
intersection of old and new modes when changing ownership.
* src/copy.c (owner_failure_ok): Treat EACCES like EPERM.
2023-09-02 13:28:23 -07:00
Paul Eggert
5f97136160 cp,mv,install: fix chown on Linux CIFS
* src/copy.c (chown_failure_ok): Also treat EACCES as OK.
2023-09-01 15:10:45 -07:00
Paul Eggert
de4a5220f2 maint: simplify set_owner
* src/copy.c (HAVE_FCHOWN, fchown): Remove.
(fchmod_or_lchmod): Move up.
(fchown_or_lchown): New function.
(set_owner): Use it to simplify.
2023-09-01 15:10:45 -07:00
Paul Eggert
74439d15d7 chown: port to mingw and MSVC 14
* src/chown-core.c (restricted_chown): Don’t assume fchown exists.
The Gnulib doc says that nowadays this is needed only for
ports to mingw and MSVC 14, but it’s an easy port so let’s do it.
2023-09-01 15:10:44 -07:00
Pádraig Brady
850a056441 maint: avoid syntax check failure
* tests/misc/numfmt.pl: Keep lines <= 80 chars.
2023-08-31 21:59:02 +01:00
Paul Eggert
8ed8d003f1 maint: Gnulib module gc
Remove Gnulib modules that coreutils code no longer use directly.
Some of these are used indirectly, but gnulib-tool should do that.
* bootstrap.conf (gnulib_modules): Remove calloc-gnu, cloexec,
getgroups, getpass-gnu, getugroups, getusershell, gnu-mae,
group-member, lchown, mgetgroups, netinet_in, readlink,
realloc-gnu, rename, rpmatch, stpncpy, tzset, wchar-single,
wcswidth.
2023-08-30 20:32:13 -07:00
Paul Eggert
07f8ec6bff maint: assume non-rare encodings
* configure.ac (GNULIB_WCHAR_SINGLE_LOCALE): Define.
This can improve performance, while dropping support for
rare encodings on non-GNU platforms.  Nowadays these encodings
are typically not worth the hassle.
2023-08-30 20:32:13 -07:00
Paul Eggert
af21374071 maint: tune for single thread & locale
* configure.ac (GNULIB_EXCLUDE_SINGLE_THREAD)
(GNULIB_REGEX_SINGLE_THREAD, GNULIB_WCHAR_SINGLE_LOCALE):
Define.
2023-08-30 20:32:13 -07:00
Paul Eggert
e0326b0473 maint: regularize struct initializers
* src/chmod.c (process_file):
* src/df.c (replace_invalid_chars):
* src/iopoll.c (iopoll_internal):
* src/ls.c (quote_name_buf):
* src/pathchk.c (portable_chars_only):
* src/printf.c (STRTOX):
* src/shred.c (main):
* src/stat.c (neg_to_zero, do_stat):
* src/timeout.c (settimeout):
* src/tr.c (card_of_complement):
* src/wc.c (wc):
Prefer ‘{0}’ to initialize everything to zero.
* src/stat.c (do_stat):
* src/timeout.c (settimeout):
Do not assume the usual order for struct members,
as POSIX does not guarantee this.
2023-08-30 20:32:13 -07:00
Paul Eggert
2c902cc288 maint: rely on Gnulib fdatasync
* m4/jm-macros.m4: Remove fdatasync-related code,
as Gnulib now does this.
* src/dd.c (fdatasync) [!HAVE_FDATASYNC]:
* src/shred.c (dosync) [!HAVE_FDATASYNC]: Rely on Gnulib fdatasync.
2023-08-30 20:32:13 -07:00
Paul Eggert
50e99b59bf maint: use modern Gnulib LIB_ macros
* src/local.mk (src_timeout_LDADD, src_dd_LDADD)
(src_shred_LDADD, src_sync_LDADD): Use TIMER_TIME_LIB
and FDATASYNC_LIB instead of LIB_TIMER_TIME and
LIB_FDATASYNC.
2023-08-30 20:32:13 -07:00
Paul Eggert
75bf3c00d3 kill: rely on Gnulib strsignal
Omit checks no longer needed now that we use strsignal.
* configure.ac: Do not check for strsignal-related decls.
* src/kill.c (sys_siglist, strsignal): Remove.
2023-08-30 20:32:13 -07:00
Paul Eggert
8463f41e4d maint: remove rename macro
* src/copy.h (rename) [RENAME_TRAILING_SLASH_BUG]:
Remove: unused, now that Gnulib takes care of this.
2023-08-29 23:57:40 -07:00
Paul Eggert
cbb6dfec55 maint: remove need for mbsalign
This simplifies memory allocation a bit, and removes an arbitrary
limitation from numfmt, which formerly limited cell output to 127
bytes.
* bootstrap.conf (gnulib_modules): Remove mbsalign, strncat.
Add strnlen (the code already used strnlen directly, and we were
saved only because Gnulib used the module indirectly)
* gl/lib/mbsalign.c, gl/lib/mbsalign.h, gl/modules/mbsalign:
* gl/modules/mbsalign-tests, gl/tests/test-mbsalign.c: Remove.
* src/df.c, src/ls.c: Do not include mbsalign.h.
(MBSWIDTH_FLAGS): New constant, now used for all
mbswidth calls.  All callers changed to check for -1 return.
* src/df.c (struct field_data_t): ‘width’ is now int not size_t,
since mbswidth can’t do widths greater than INT_MAX anyway.
Replace ‘align’ with ‘align_right’.  All uses changed.
(print_table): Redo to avoid the need for ambsalign.
(get_header, get_dev): mbswidth returns int, not size_t.
* src/ls.c (MAX_MON_WIDTH): Remove; no longer used.
(abmon_init): Use strnlen to cheaply discard too-long month names.
Align by hand instead of using mbsalign.
* src/numfmt.c: Include stdckdint.h, mbswidth.h.
Do not include mbsalign.h.
(padding_buffer_size): Now idx_t.  All uses changed.
(padding_width): Now intmax_t, since it’s no longer an object
size.  Its sign now records alignment.  All uses changed.
(zero_padding_width): Now int, since it’s given to sprintf.
All uses changed.
(padding_alignment): Remove; it’s now taken from padding_width’s sign.
(double_to_human): Return string length.  BUF_SIZE arg is now idx_t.
Include suffix in output.  All callers changed.  Simplify by not
calling strncat or stpcpy.  Calculate fmt size bound more carefully.
(setup_padding_buffer): Remove.  All uses removed.
(parse_format_string): Use intmax_t, not long, for pad.
On overflow, set widths to large values that cause later code
to do the right thing, rather than separately checking for
overflow here.
(prepare_padded_number): Return bool, not int 0/1.  New arg
PADDING.  All uses changed.  Do not limit padded output to 127
bytes; instead, use xpalloc to expand the output buffer.
(print_padded_number): New arg PADDING.  All uses changed.
(process_suffixed_number): Simplify.
(main): Take extremum if xstrtoimax overflows, as this does
the right thing.
* tests/misc/numfmt.pl: New test suf-20 to test for truncation bug.
Remove tests pad-3.2, fmt-err-7, as they’re no longer invalid but
are quite expensive.
2023-08-29 23:57:40 -07:00
Pádraig Brady
632beba630 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2023-08-29 15:23:14 +01:00
Pádraig Brady
9530a14420 version 9.4
* NEWS: Record release date.
2023-08-29 14:36:22 +01:00
Paul Eggert
2dddc87214 maint: spelling fixes, including author names
Most of this just affects commentary and documentations.  The only
significant behavior change is translating author names via
proper_name_lite rather than proper_name_utf8, or not translating
them at all.  proper_name_lite is good enough for coreutils and
avoids the bloat that had coreutils not using Gnulib proper_name.
* bootstrap.conf (gnulib_modules): Use propername-lite instead
of propername.
(XGETTEXT_OPTIONS): Look for proper_name_lite instead of for
proper_name_utf8.
* cfg.mk (local-checks-to-skip): Remove
sc_proper_name_utf8_requires_ICONV, since we no longer use
proper_name_utf8.
(old_NEWS_hash): Update.
(sc_check-I18N-AUTHORS): Remove; no longer needed.
2023-08-28 14:06:43 -07:00
Paul Eggert
e3f15c9c4a test: omit unreachable code
* src/test.c (unary_operator): Omit unreachable ‘return false;’.
Oracle Solaris Studio 12.6 warns about it.
2023-08-28 14:06:43 -07:00
Bruno Haible
c8340962dd tests: avoid test failure on Android
* gl/tests/test-mbsalign.c (main): Skip the unibyte truncation test
on Android, when the "C" locale in fact is multibyte.
2023-08-28 12:18:26 +01:00
Paul Eggert
9348edb6b6 sort: port sort-merge-fdlimit test to Solaris 10
* tests/sort/sort-merge-fdlimit.sh: Give 'sort' fd 6 too.
Needed for the same reason sort-continue.sh needed a ulimit -n boost.
2023-08-27 20:50:04 -07:00
Paul Eggert
5c9998fbab sort: port sort-continue test back to Solaris 10
* tests/sort/sort-continue.sh: Use ulimit -n 7 not -n 6.  On
Solaris 10 'sort' uses Gnulib mkostemp, which calls Gnulib
getrandom, which opens /dev/urandom to calculate the temp file's
name, which means 'sort' needs one more file descriptor to work.
2023-08-27 19:15:31 -07:00
Pádraig Brady
b3afbcad9c tests: avoid false failure on cygwin
* tests/cksum/md5sum-bsd.sh: Avoid part of test dealing with backslashes
in file names, on systems where backslash is a directory separator.
Issue reported by Bruno Haible on cygwin.
2023-08-27 20:22:32 +01:00
Pádraig Brady
f4e2e2bb57 cksum: adjust tests and docs to binary mode handling
Following commit v9.3-80-g5e1e0993b which makes cksum
match the output of the standalone utilities...

* doc/coreutils.texi (cksum output modes): Remove the mention
that cksum never outputs a binary indicator, as that's no longer the
case.
* tests/cksum/b2sum.sh: Avoid outputting a binary indicator.
* tests/cksum/sm3sum.pl: Likewise.
2023-08-27 19:53:52 +01:00
Pádraig Brady
5e44ad4e6d all: avoid duplicated write errors on FreeBSD
* src/system.h (write_error): Also call fpurge(), which was seen to
be needed on FreeBSD 13.1 to avoid duplicated write errors.
* src/head.c (xwrite_stdout): Likewise.
* bootstrap.conf: Depend on fpurge.
Reported by Bruno Haible.
2023-08-27 17:32:07 +01:00
Pádraig Brady
13e13107e1 tests: avoid false failure where sleep is a shell builtin
* tests/misc/usage_vs_getopt.sh: Handle sleep as a shell builtin,
which was seen on Alpine Linux 3.18.
2023-08-27 17:18:01 +01:00
Bruno Haible
900606431e build: fix link errors of sort, split on CentOS 5 and Solaris 10
* src/local.mk (src_sort_LDADD, src_split_LDADD): Add $(CLOCK_TIME_LIB).
2023-08-27 16:37:54 +01:00
Bruno Haible
016e9a3bb8 build: fix compilation error on AIX 7.1
* src/copy.c (copy_internal): Don't test for ENOTEMPTY if it has the
same value as EEXIST.
2023-08-27 16:37:52 +01:00
Pádraig Brady
32e8ead131 build: update with gnulib fixes
* gnulib: Update to incorporate gnulib fixes
from Bruno Haible from his coreutils 9.4 pre-release testing.
2023-08-27 16:09:07 +01:00
Pádraig Brady
25727ebd6a doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.30 which is now about 5 years old.
2023-08-24 12:10:49 +01:00
Pádraig Brady
13f439ce56 shred: fix operation on Solaris with 64 bit builds
* NEWS: Mention the bug fix.
* gl/lib/randread.c (get_nonce): Limit getrandom() <= 1024 bytes.
2023-08-23 15:23:42 +01:00
Pádraig Brady
d553ab43c6 build: update gnulib submodule to latest
* gnulib: Update to latest
2023-08-22 12:10:09 +01:00
Pádraig Brady
e15f5ab354 doc: reorg texinfo for the checksumming utilities
* doc/coreutils.texi: Reorg so that 'cksum invocation' is the
main node listing all options and output formats, which is then
referenced by the descriptions of the standalone utilities.
Use macros in the description of the standalone utilities
rather than referencing 'md5sum invocation' to be more direct.
2023-08-22 12:09:57 +01:00
Pádraig Brady
b0af86d062 doc: cksum: remove -b description from texinfo
* doc/coreutils.texi (cksum invocation): Following commit 5e1e0993
also remove the desciption of the -b option for the cksum command.
2023-08-21 22:20:39 +01:00
Pádraig Brady
4f92de5822 cp: with --sparse=never, avoid COW and copy offload
* src/cp.c (main): Set default reflink mode appropriately
with --sparse=never.
* src/copy.c (infer_scantype): Add a comment to related code.
* tests/cp/sparse-2.sh: Add a test case.
* NEWS: Mention the bug.
2023-08-21 14:28:14 +01:00
Pádraig Brady
27c76b83b4 maint: comment spelling fix
* tests/split/l-chunk-root.sh: Fix recently introduced typo.
2023-08-19 16:45:17 +01:00
Pádraig Brady
20b9a015e5 maint: remove extraneous line in NEWS
* NEWS: Remove extraneous line.
2023-08-16 11:47:54 +01:00
Bruno Haible
622eea03cd uptime: simplify following gnulib changes
* build-aux/gen-lists-of-programs.sh (build_if_possible_progs):
Remove uptime.
(normal_progs): Add uptime.
* configure.ac: Remove GNULIB_BOOT_TIME invocation.
* m4/boottime.m4: Remove file.
* src/uptime.c: Don't include <sys/sysctl.h>, <OS.h>.
(print_uptime): Don't call sysctl, get_system_info, as Gnulib's
readutmp module now does this.
2023-08-15 15:22:27 -07:00
Paul Eggert
f2c2643fc5 maint: update uptime NEWS
* NEWS: Update as per Bruno Haible <https://bugs.gnu.org/65255#14>.
2023-08-15 15:22:27 -07:00
Pádraig Brady
fc5e68612f tests: fix false failure due to locale on alpine
* tests/sort/sort-debug-keys.sh: Decimal point was seen to be '.'
on fr_FR.UTF-8 on Alpine Linux 3.18, so add an extra guard
to ensure we've a ',' as the decimal point on this locale.
Fixes https://bugs.gnu.org/65310
2023-08-15 22:55:41 +01:00
Paul Eggert
1ea34cbf6a uptime: be more generous about read_utmp failure
* src/uptime.c (print_uptime): Check for overflow
when computing uptime.  Use C99-style decl after statements.
Do not let an idx_t value go negative.
(print_uptime, uptime): Be more generous about read_utmp failures,
or when read_utmp does not report the boot time.  Instead of
failing, warn but keep going, printing the information that we did
get, and then exit with nonzero status.
(print_uptime): Return the desired exit status.  Caller changed.
2023-08-15 14:01:58 -07:00
Bruno Haible
d8cfa5db49 uptime: Include VM sleep time in the "up" duration
* src/uptime.c: Don't include c-strtod.h.
(print_uptime): Don't read /proc/uptime, because the value it provides
does not change when a date adjustment occurs.
* bootstrap.conf (gnulib_modules): Remove 'uptime'.
2023-08-15 14:01:58 -07:00
Paul Eggert
58977651ec build: update gnulib submodule to latest 2023-08-15 14:01:58 -07:00
Bernhard Voelker
0cb8332196 maint: fix typo in NEWS
* NEWS: s|/who/log/wtmp|/var/log/tmp|, introduced in commit 85edb4afbd.
2023-08-15 13:35:13 +02:00
Bernhard Voelker
d428096a6a doc: reference install(1) and cp(1) from each other
* man/cp.x (SEE ALSO): Add install(1).
* man/install.x (SEE ALSO): Add cp(1).

Discussed at
https://lists.gnu.org/r/coreutils/2023-08/msg00026.html
2023-08-15 13:29:41 +02:00
Bruno Haible
db1d95f43b build: fix recent compilation error on GNU/Hurd
* src/copy.c (set_author): Revert change from MACH_PORT_NULL to
MACH_PORT_nullptr from commit 16b5ca6e (2023-06-29).
2023-08-14 22:11:57 +01:00
Pádraig Brady
dc3c843187 maint: avoid syntax-check failure
* po/POTFILES.in: Cater to lib/file-type.c adjustments
as suggested by sc_po_check.
2023-08-14 14:03:35 +01:00
Bruno Haible
049e5b0f87 build: fix link errors with gcc < 4.8
* configure.ac: Attempt to link, not only compile, the test programs
with __builtin_cpu_supports, to avoid link errors with cksum and wc.
2023-08-14 13:45:44 +01:00
Paul Eggert
85edb4afbd doc: improve NEWS discussion of systemd 2023-08-12 23:51:59 -07:00
Paul Eggert
9b673e61af build: update gnulib submodule to latest 2023-08-12 23:51:59 -07:00
Pádraig Brady
f31229ebd1 maint: allow use of printf C99 integer size specifiers
Older systems that had issues with these like HP-UX and Solaris 8
are now obsolete, and can easily apply patches to provide support.
Also we've used %td since coreutils 9.1, with no reported issues.

* cfg.mk (sc_prohibit-c99-printf-format): Remove to allow use of
%[jtz] size specifiers, which allows for cleaner code
by avoiding the need to cast to PRI?MAX etc.
2023-08-12 11:32:25 +01:00
Pádraig Brady
5420604332 doc: separate out description of 2038 time stamp change
* NEWS: Separate out the description of the _existing_ issues
with outputting timestamps on 32 bit systems, from _future_ issues
outputting timestamps on all systems.  Also move this to the
"improvement" section, since it's not really a coreutils
specific issue, and also is a build time configurable option.
2023-08-11 14:34:49 +01:00
Bruno Haible
d70d55c0a4 pinky,users,who: optimize read_utmp invocation
When we are only interested in entries of type USER_PROCESS, tell
read_utmp that it does not need to determine the boot time.

* src/pinky.c (short_pinky): Pass option READ_UTMP_USER_PROCESS.
* src/users.c (users): Likewise.
* src/who.c (who): Likewise, if calling list_entries_who.
2023-08-11 14:07:37 +01:00
Paul Eggert
ad82336026 who: simplify based on readutmp changes
* src/pinky.c (time_string, print_entry, scan_entries, short_pinky):
* src/uptime.c (print_uptime, uptime):
* src/users.c (list_entries_users, users):
* src/who.c (UT_TYPE_RUN_LVL, UT_TYPE_INIT_PROCESS)
(UT_TYPE_LOGIN_PROCESS, UT_TYPE_DEAD_PROCESS, UT_TYPE_NEW_TIME)
(time_string, print_user, print_boottime)
(make_id_equals_comment, print_deadprocs, print_login)
(print_initspawn, print_clockchange, print_runlevel)
(list_entries_who, scan_entries, who):
Simplify, partly by using plain -> rather than macros.
2023-08-08 20:05:33 -07:00
Paul Eggert
422dcd424c pinky,who: omit pragma
* src/pinky.c, src/who.c:
Omit no-longer-needed -Wstringop-overread pragma.
2023-08-08 20:05:33 -07:00
Bruno Haible
911c0bc41d maint: Simplify after gnulib changed
Update gnulib submodule to latest.
All of UT_USER_SIZE, UT_ID_SIZE, UT_LINE_SIZE, UT_HOST_SIZE are now -1.

* src/pinky.c (print_entry): Remove code for bounded-length ut_line,
ut_user, ut_host.
(scan_entries): Remove code for bounded-length ut_user.
* src/who.c (print_line): Remove userlen, linelen arguments.
(print_user): Remove code for bounded-length ut_line, ut_user, ut_host.
(make_id_equals_comment): Remove code for bounded-length ut_id.
(print_boottime, print_deadprocs, print_login, print_initspawn,
print_clockchange, print_runlevel, print_heading): Update print_line
invocations.
(scan_entries): Remove code for bounded-length ut_line.
2023-08-08 20:05:33 -07:00
Paul Eggert
0e58c95000 maint: Update after gnulib module 'readutmp' changed
(This patch is coauthored with Bruno Haible,
with original version at <https://bugs.gnu.org/64937#>.)
This updates the gnulib submodule to latest.
For year-2038 safety on Linux/{x86,arm},
this adds an --enable-systemd option to ‘configure’.
The idea is that this sort of thing will become the default
after it has been tested more.
* configure.ac: Don't test whether struct utmp and struct utmpx
have the ut_host field; this is now done in gnulib's readutmp module.
* src/local.mk: Link the programs 'pinky', 'uptime', 'users',
'who' with $(READUTMP_LIB).
* src/pinky.c, src/who.c:
Test HAVE_STRUCT_XTMP_UT_HOST instead of HAVE_UT_HOST.
* src/pinky.c (print_entry):
* src/who.c (print_user, print_deadprocs, print_login)
(print_initspawn, scan_entries):
Support the situation where ut_line is a 'char *' rather than a
'char[]' of fixed size.  Likewise for ut_user and ut_host.
(make_id_equals_comment): Likewise for ut_id.
* src/pinky.c (print_entry):
* src/who.c (print_user):
Open /dev to simplify looking up its entries.
Don’t use printf if the output might in theory be longer than INT_MAX.
* src/pinky.c (scan_entries, short_pinky):
* src/uptime.c (print_uptime, uptime):
* src/users.c (list_entries_users, users):
* src/who.c (who):
Use idx_t where new read_utmp needs it.
* src/system.h (STREQ_LEN): Add comment that last arg can be -1.
2023-08-03 23:16:00 -07:00
Paul Eggert
cb7bb52551 uptime: fix Y5881633 bug
* src/uptime.c (print_uptime): Prefer signed types.
Fix unlikely bug on platforms with 32-bit long and 64-bit time_t
if the idle time exceeds 2**31 days (about 6 million years...).
2023-08-02 06:52:39 -07:00
Paul Eggert
93e30466ff pinky: fix "d" typo
Problem reported by Bruno Haible (bug#65003).
* src/pinky.c (idle_string): Fix recently-introduced typo:
missing "d" for "days".
2023-08-02 06:52:39 -07:00
Dragan Simic
73ba9f71e1 maint: minor comment cleanups
* src/cut.c: Adjust a few comments slightly, simply to have their
trailing whitespace the same as in the majority of the comments.
2023-08-01 15:35:44 +01:00
Dragan Simic
7783df863a cut: promptly diagnose write errors, continued
* src/cut.c: Complete the error-handling improvements started in
commit e0a4a60af5, by adding a couple of remaining checks for putchar().
While there, sprinkle a few rather useful comments, and perform a few
small code cleanups, to make the code and the comments more uniform
and more conformant to the official coding style.  Also make the help
message slightly more uniform.
2023-08-01 15:34:50 +01:00
Dragan Simic
10dcb0b125 maint: reformat text width in HACKING
* HACKING: Adjust line lengths.
2023-08-01 15:32:21 +01:00
Pádraig Brady
e886b300f7 pinky: fix buffer size on 32 bit builds
* src/pinky.c (idle_string): Use the correct buffer size
following the recent int type adjustment.
2023-08-01 14:59:29 +01:00
Pádraig Brady
89c8c5fff3 od: fix issues with recent format string changes
* src/ioblksize.h: Avoid syntax check with redundant idx.h inclusion.
* src/od.c (FMT_BYTES_ALLOCATED): Increase by two to avoid:
  error: '%s' directive writing between 1 and 2 bytes into a region
  of size between 1 and 4 [-Werror=format-overflow=]
(maint): Use %td to print idx_t rather than invalid %jt format.
2023-08-01 13:30:02 +01:00
Paul Eggert
0b2796750f pinky: prefer signed types
* src/pinky.c (idle_string): Prefer intmax_t to unsigned long int;
this avoids an overflow on platforms where unsigned long is 32
bits and time_t is 64 bits (the bug could occur on such a system
that was idle for more than 6 million years, so it’s a bit
hard to supply a test case...).
2023-07-31 17:51:29 -07:00
Paul Eggert
703d2d6bd4 pathchk: prefer signed types
* src/pathchk.c (validate_file_name): Prefer signed types.
2023-07-31 17:51:29 -07:00
Paul Eggert
244268f719 numfmt: prefer signed types
* src/numfmt.c (suffix_power_char, powerld, expld)
(simple_strtod_int, double_to_human, prepare_padded_number)
(process_suffixed_number): Prefer signed types.
(process_suffixed_number): Fix an unlikely bug if an
arg has exactly 2**32 spaces at the start.
2023-07-31 17:51:29 -07:00
Paul Eggert
df73cf50e9 mktemp,seq: prefer signed types
* src/mktemp.c (main):
* src/seq.c (main): Prefer signed types.
2023-07-31 17:51:28 -07:00
Paul Eggert
a0b8c4ad61 kill: prefer signed types
* src/kill.c (list_signals):
Prefer signed types.  This avoids undefined behavior on
theoretical platforms where unsigned and signed int have
different representations.
2023-07-31 17:51:28 -07:00
Paul Eggert
6387164e5e groups,id: don’t assume gid_t fits in unsigned long
* src/group-list.c (print_group): Convert to intmax_t or
uintmax_t, not to unsigned long.
2023-07-31 17:51:28 -07:00
Paul Eggert
e20d63c442 dircolors,du,expr: prefer signed types
* src/dircolors.c (dc_parse_stream):
* src/du.c (max_depth, main):
* src/expr.c (main):
Prefer signed types.
2023-07-31 17:51:28 -07:00
Paul Eggert
08c325c63b od: prefer signed types
* src/od.c: Include stdckdint.h.
(bytes_to_oct_digits, bytes_to_signed_dec_digits)
(bytes_to_unsigned_dec_digits, bytes_to_hex_digits):
Use ‘char’ for these small constants.
(simple_strtoi): Rename from simple_strtoul.  Convert to int
instead of unsigned long; that’s good enough.  All uses changed.
Simplify by using ckd_mul and ckd_add to check for overflow.
(main): Prefer signed types to unsigned.
2023-07-31 17:51:28 -07:00
Paul Eggert
89f7d44912 cksum,df,digest: prefer signed types
* src/cksum.c (main):
* src/df.c (decode_output_arg):
* src/digest.c (valid_digits):
Prefer idx_t to unsigned types when the value is an index
into an array.
2023-07-31 17:51:28 -07:00
Paul Eggert
73a813e484 join: prefer signed types
* src/join.c (struct outlist, struct field, struct line)
(struct seq, autocount_1, autocount_2, join_field_1, join_field_2)
(extract_field, keycmp, check_order, init_linep, free_spareline)
(getseq, delseq, prfield, prfields, prjoin, join, add_field)
(string_to_join_field, decode_field_spec, add_field_list)
(set_join_field, main):
Prefer signed integers to unsigned.
2023-07-31 17:51:28 -07:00
Paul Eggert
46e5702bf3 factor: prefer signed types
When it’s easy, prefer signed types to unsigned, as
they are less confusing and allow overflow checking.
* src/factor.c (struct mp_factors, udiv_qrnnd)
(count_leading_zeros, count_trailing_zeros)
(factor_insert_multiplicity, mp_factor_clear, mp_factor_insert)
(factor_insert_refind, factor_using_division)
(mp_factor_using_division, powm2, millerrabin, millerrabin2)
(mp_millerrabin, prime_p, prime2_p, mp_prime_p, isqrt, isqrt2)
(invtab, q_freq, factor_using_squfof, strto2uintmax)
(print_factors_single, main):
Prefer signed integers to unsigned.
2023-07-31 17:51:28 -07:00
Paul Eggert
9970fac34b maint: include idx.h everywhere
* src/system.h: Include idx.h here, instead of in every file
that currently uses idx_t.  This should make it easier to use
idx_t in the future.
2023-07-31 17:51:28 -07:00
Paul Eggert
9cbda6e1f8 who: fix only-theoretical overflow
Change stzncpy’s implementation to match its comment, in the case
where SRC + LEN would overflow.  This case never happens in coreutils.
* src/system.h (stzncpy): Work even if SRC + LEN would overflow.
2023-07-31 11:21:43 -07:00
Pádraig Brady
779f34e180 tac: handle short reads on input
This can be reproduced by getting the read() above 2G,
which induces a short read, thus triggering the erroneous failure.

  $ truncate -s 5G 5G

  $ cat 5G | TMPDIR=$PWD tac | wc -c
  tac: /tmp/tacFt7txA: read error: Illegal seek
  0

With the fix in place we now get:

  $ cat 5G | TMPDIR=$PWD src/tac | wc -c
  5368709120

* src/tac.c (tac_seekable): Use full_read() to handle short reads.
* NEWS: Mention the bug fix.
Reported at https://bugs.debian.org/1042546
2023-07-31 18:55:19 +01:00
Bruno Haible
a102826245 uptime: output correct user count on OpenBSD
* src/uptime.c (print_uptime, uptime): Always call read_utmp
and count the result.
* NEWS: Mention the fix (text by Bruno Haible).
2023-07-31 09:28:04 -07:00
Paul Eggert
76c795bf2e build: update gnulib submodule to latest 2023-07-31 09:28:04 -07:00
Paul Eggert
39f5c3f92e build: update gnulib submodule to latest
* NEWS: Mention a bug that this fixes.
2023-07-29 17:23:15 -07:00
Paul Eggert
3cb862ce5f mv: better diagnostic for 'mv dir x' failure
Problem reported by Nir Oren <https://bugs.gnu.org/64785>.
* src/copy.c (copy_internal): Use a more-specific diagnostic when
a rename fails due to a problem that must be due to the
destination, avoiding user confusion in cases like 'mv dir x'
where x is a nonempty directory.
* tests/mv/dir2dir.sh: Adjust to match.
2023-07-22 13:41:07 -07:00
Pádraig Brady
b0e41e3f30 doc: clarify tail -n/-c +NUM operation
tail -n/-c +NUM, is different from tail -n/-c NUM,
and head -n/-c NUM, and head -n/c -NUM, in that it
specifies a 1 based index rather than a count to skip/include.
So clarify this in tail --help and tail info manual.
Note we also mention this gotcha at:
https://www.pixelbeat.org/docs/coreutils-gotchas.html#tail

* doc/coreutils.texi (tail invocation): Give examples for -c/-n +NUM,
to make it clear one has to specify a number 1 larger than
might be expected.
* src/tail.c (usage): State the skip at start edge case more clearly
in the -n description. -c is not often used with tail so we leave
full explanation of that to the info manual.  Also split the string
to simplify translation.
2023-07-20 15:13:01 +01:00
Pádraig Brady
4bf182f92a maint: add a syntax check to prevent use of NULL
* cfg.mk (sc_prohibit_NULL): Direct to use nullptr instead.
2023-07-18 23:13:06 +01:00
Pádraig Brady
8fd50b8672 tests: split: provide more isolated /tmp handling
* tests/split/l-chunk.sh: Move the "expensive" portion to ...
* tests/split/l-chunk-root.sh: .. A new test split from l-chunk.sh
which uses an isolated TMPDIR, rather than exhausting /tmp,
as that gives false positive failures with some other coreutils tests
like tac-2-nonseekable.sh and shuf-reservoir.sh at least.
* tests/local.mk: Reference the new test.
2023-07-18 23:11:24 +01:00
Pádraig Brady
464be62df6 split: honor $TMPDIR for temp files
* bootstrap.conf: Depend on tmpdir rather than tmpfile,
as the standard tmpfile() doesn't honor $TMPDIR.
* src/split.c (copy_to_tmpfile): Adjust to call temp_stream() rather
than tmpfile();
* NEWS: Mention the improvement.
2023-07-18 23:11:24 +01:00
Pádraig Brady
1b86b70dd5 tac: fall back to /tmp if $TMPDIR is unavailable
This also refactors temp_stream() to its own module,
in preparation for use by split.

* src/tac.c: Refactor temp_stream() out to ...
* src/temp-stream.c: ... A new module mostly refactored from tac,
but uses tmpdir to more robustly support $TMPDIR,
while falling back to /tmp if not available.
* src/temp-stream.h: The new module interface.
* src/local.mk: Reference the new module from tac.
* tests/tac/tac.pl: Adjust to non failing missing $TMPDIR.
* po/POTFILES.in: Reference the new module with translatable strings.
* NEWS: Mention the user visible improvements to tac TMPDIR handling.
2023-07-18 23:10:40 +01:00
Pádraig Brady
47e1388d6f maint: add syntax check to ensure safe mkstemp usage
One needs to include stdlib--.h if using mkstemp()
lest one hits esoteric bugs with closed stdin etc.

* cfg.mk (sc_require_stdlib_safer): Add a new syntax check.
(sc_require_stdio_safer): Fix this; broken since commit fa7ed969c3.
2023-07-18 18:59:10 +01:00
Pádraig Brady
02a4ebd6c4 join: promptly diagnose write errors
* src/join.c (prjoin): Check for write errors after each line.
* tests/misc/write-errors.sh: enable the test for join.
* NEWS: Mention the improvement.
2023-07-17 11:28:36 +01:00
Pádraig Brady
b1df1d557e comm: promptly diagnose write errors
* src/comm.c (writeline): Simplify by removing the unneeded STREAM
parameter.  Call write_error() upon ferror().
(compare_files): Adjust to simplified writeline().
* tests/misc/write-errors.sh: Enable comm test.
* NEWS: Mention the improvement.
2023-07-17 11:28:36 +01:00
Pádraig Brady
e0a4a60af5 cut: promptly diagnose write errors
* src/cut.c (cut_bytes): Diagnose errors from fwrite() and putchar().
(cut_fields): Likewise.
* tests/misc/write-errors.sh: Enable the test for cut,
and augment to cover both cut_bytes() and cut_fields().
* NEWS: Mention the improvement.
2023-07-17 11:28:36 +01:00
Pádraig Brady
ca7711456f uniq: promptly diagnose write errors
* src/uniq.c (write_line): Check the output from fwrite() immediately.
(check_file): Likewise.
* tests/misc/write-errors.sh: Enable the test case.
* NEWS: Mention the improvement.
2023-07-17 11:28:36 +01:00
Pádraig Brady
a03c00023a od: promptly diagnose write errors
* src/od.c (dump): Check for write errors after each block written,
to exit early even with large / unbounded inputs.
* tests/misc/write-errors.sh: enable od check.
* NEWS: Mention the improvement.
Fixes https://bugs.gnu.org/64540
2023-07-17 11:28:36 +01:00
Pádraig Brady
0b2ff7637f all: avoid repeated diagnostic upon write error
* cfg.mk (sc_some_programs_must_avoid_exit_failure): Adjust to
avoid false positive.
(sc_prohibit_exit_write_error): A new syntax check to prohibit
open coding error(..., "write error"); instead directing to use...
* src/system.h (write_error): ... a new function to clear stdout errors
before we explicitly diagnose a write error and exit.
* src/basenc.c: Use write_error() to ensure no repeated diagnostics.
* src/cat.c: Likewise.
* src/expand.c: Likewise.
* src/factor.c: Likewise.
* src/paste.c: Likewise.
* src/seq.c: Likewise.
* src/shuf.c: Likewise.
* src/split.c: Likewise.
* src/tail.c: Likewise.
* src/tr.c: Likewise.
* src/unexpand.c: Likewise.
* tests/misc/write-errors.sh: Remove TODOs for the fixed utilities:
expand, factor, paste, shuf, tr, unexpand.
2023-07-17 11:28:36 +01:00
Pádraig Brady
ef47b928d0 tests: ensure utilties exit promptly upon write error
* tests/local.mk: Reference the new test.
* tests/misc/write-errors.sh: A new test to ensure utilities
exit promptly upon writing to /dev/full.
2023-07-17 11:28:30 +01:00
Jim Meyering
c0e7e4a1d4 cksum: improve problematic_chars function
* src/digest.c (problematic_chars): Implement using strcspn,
and traversing S only once, rather than once per escaped byte.
2023-07-13 22:39:04 -07:00
Pádraig Brady
ebd776a422 maint: give a new function the "pure" attribute
* src/digest.c (problematic_chars): This recently introduced
function does not modify state so is pure, even though GCC 13.1 at least
did not warn about that attribute being appropriate.
2023-07-12 20:41:00 +01:00
Pádraig Brady
86614ba1c2 cksum: escape filenames with a leading '\' in --check status
* src/digest.c (digest_check): Also escape in the case that the
file name contains '\'.
* tests/cksum/md5sum-bsd.sh: Add a test case.
* doc/coreutils.texi (md5um invocation): Clarify escaping operation.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/64392
2023-07-11 12:16:41 +01:00
Pádraig Brady
5e1e0993b5 cksum: support transparent emulation of older utils
Support -b, --binary, and -t, --text
to allow full emulation of older utilities with:
  exec cksum -a $algo --untagged "$@"
Note this would diverge from OpenBSD's support of cksum -b.

* src/digest.c: Change -b to mean --binary, not --base64 in all cases.
Accept -b and -t in all cases.  Keep --binary and --text undocumented
for cksum.
* tests/cksum/cksum-base64.pl: s/-b/--base64/.
* tests/cksum/cksum-a.sh: Ensure cksum supports -b and -t appropriately.
* NEWS: Mention the change in behavior.
2023-07-09 14:33:14 +01:00
Pádraig Brady
2f1cffe07a maint: avoid static analysis failure for ignored dup2 return
* src/sort.c: We're ignoring failures from these calls,
so do so explicitly to avoid static analysis issues
as reported by coverity.
2023-07-08 13:42:51 +01:00
Sylvestre Ledru
1ac8630f1e tests: mktemp -t: $TMPDIR has higher priority than -p
* tests/misc/mktemp.pl: Ensure that with -t,
$TMPDIR has precedence over -p.
2023-07-04 12:11:16 +01:00
Paul Eggert
80a6c7faa2 maint: update .gitignore
Add some newly-created Gnulib files,
plus some bootstrap temporaries.
2023-07-01 11:51:17 -07:00
Paul Eggert
57ffc40323 stty: fix untranslated diagnostics
* src/stty.c (set_speed): Translate diagnostics.
2023-07-01 11:51:17 -07:00
Paul Eggert
6380a66a7d maint: sync bootstrap from Gnulib
* bootstrap: Copy from gnulib/build-aux/bootstrap.
2023-07-01 11:51:17 -07:00
Paul Eggert
d727aba601 maint: prefer ckd_add to INT_ADD_WRAPV etc
* bootstrap.conf (gnulib_modules): Add stdckdint.
Also, in C source code, prefer C23 macros like ckd_add
to their Gnulib near-equivalents like INT_ADD_WRAPV.
Include <stdckdint.h> as needed.
2023-07-01 11:51:16 -07:00
Paul Eggert
123d03dca4 who: don’t crash if clock gyrates
* src/who.c (idle_string): Avoid signed integer overflow
if the superuser messes with the clock in bizarre ways.
Remove an ‘assume’ that wasn’t correct under this scenario.
2023-07-01 11:51:16 -07:00
Paul Eggert
c0285a7136 df: omit GCC 5 ‘assume’s
* src/df.c (main):
* src/shred.c (dopass):
Omit ‘assumes’ needed to pacify GCC 5 but not needed with GCC 13.
2023-07-01 11:51:16 -07:00
Paul Eggert
17aaba6a41 maint: pacify GCC bug#109613 better
* src/cut.c (cut_file):
* src/nl.c (nl_file): Pacify GCC Bug#109613 in a better way, by
narrowing the coverage of the ‘assume’ so that bugs in the
no-longer-covered part are not masked.
2023-07-01 11:51:16 -07:00
Paul Eggert
d438486cb5 maint: stop pacifying Parfait
* src/fmt.c (get_paragraph):
* src/stty.c (display_changed, display_all): Omit calls to
‘assume’ that are present only to pacify false positives by Parfait
<https://labs.oracle.com/pls/apex/f?p=94065:12:17236785746387:13>,
which went in-house in 2012 and never came back.
2023-07-01 11:51:16 -07:00
Paul Eggert
a44b866b11 build: update gnulib submodule to latest 2023-07-01 11:51:16 -07:00
Paul Eggert
6d61667d0d maint: go back to using ‘error’
Now that Gnulib’s ‘error’ module does proper static checking
for not returning, we need no longer use the ‘die’ macro.
This makes code easier to read for people that are used to ‘error’.
* cfg.mk (error_fns, exclude_file_name_regexp): Remove ‘die’.
(sc_die_EXIT_FAILURE): Remove.
* src/die.h: Remove.  All includes removed.  All calls to ‘die’
changed back to calls to ‘error’.
* src/install.c (get_ids): Use quoteaf (problem found with
make syntax-check).
* src/system.h: Include error.h, since some of our macros call ‘error’.
Stop including error.h elsewhere.
2023-07-01 11:51:16 -07:00
Paul Eggert
478055dc30 maint: improve static and dynamic checking
This modernizes the source code somewhat, to take advantage
of advances in GCC over the years, and Gnulib’s ‘assure’ module.
Include assure.h in files that now need it.
Do not include assert.h directly; it’s no longer needed.
* bootstrap.conf (gnulib_modules): Add ‘assure’.
* gl/lib/randread.c (randread_error):
* src/chmod.c (describe_change):
* src/chown-core.c (describe_change):
* src/cp.c (decode_preserve_arg):
* src/head.c (diagnose_copy_fd_failure):
* src/ls.c (parse_ls_color):
* src/od.c (decode_one_format):
* src/split.c (main):
* src/test.c (binary_operator, posixtest):
Prefer affirm to abort, since it has better diagnostics in the
normal case and better performance with -DNDEBUG.
* gl/lib/xdectoint.c, src/die.h: Include stddef.h, for unreachable.
* gl/lib/xdectoint.c: Do not include verify.h; no longer needed.
* gl/lib/xdectoint.c (__xnumtoint):
* src/die.h (die):
Prefer C23 unreachable () to assume (false).
* gl/lib/xfts.c (xfts_open):
* src/basenc.c (base32hex_encode):
* src/copy.c (abandon_move, copy_internal, valid_options):
* src/cut.c (cut_fields):
* src/df.c (alloc_field, decode_output_arg, get_dev):
* src/du.c (process_file, main):
* src/echo.c (usage):
* src/factor.c (udiv_qrnnd, mod2, gcd2_odd, factor_insert_large)
(mulredc2, factor_using_pollard_rho, isqrt2, div_smallq)
(factor_using_squfof):
* src/iopoll.c (iopoll_internal, fwrite_wait):
* src/join.c (add_field):
* src/ls.c (dev_ino_pop, main, gobble_file, sort_files):
* src/mv.c (do_move):
* src/od.c (decode_format_string, read_block, dump, main):
* src/remove.c (rm):
* src/rm.c (main):
* src/sort.c (stream_open):
* src/split.c (next_file_name, lines_chunk_split):
* src/stdbuf.c (main):
* src/stty.c (set_speed):
* src/tac-pipe.c (line_ptr_decrement, line_ptr_increment):
* src/touch.c (touch):
* src/tr.c (find_bracketed_repeat, get_next)
(validate_case_classes, get_spec_stats, string2_extend, main):
* src/tsort.c (search_item, tsort):
* src/wc.c (main):
Prefer affirm to assert, as it allows for better static
checking when compiling with -DNDEBUG.
* src/chown-core.c (change_file_owner):
* src/df.c (get_field_list):
* src/expr.c (printv, null, tostring, toarith, eval2):
* src/ls.c (time_type_to_statx, calc_req_mask, get_funky_string)
(print_long_format):
* src/numfmt.c (simple_strtod_fatal):
* src/od.c (decode_one_format):
* src/stty.c (mode_type_flag):
* src/tail.c (xlseek):
* src/tr.c (is_char_class_member, get_next, get_spec_stats)
(string2_extend):
Prefer unreachable () to abort () or assert (false) when merely
pacifying the compiler, e.g., in a switch statement on an enum
where all cases are covered.
* src/copy.c (valid_options): Now returns void; the bool was useless.
Caller no longer needs to assert.
* src/csplit.c (find_line):
* src/expand-common.c (next_file):
* src/shred.c (incname):
* src/sort.c (main):
* src/tr.c (append_normal_char, append_range, append_char_class)
(append_repeated_char, append_equiv_class):
* src/tsort.c (search_item):
Omit assert, since the hardware will check for us.
* src/df.c (header_mode): Now the enum type it should have been.
* src/du.c (process_file):
* src/ls.c (assert_matching_dev_ino):
* src/tail.c (valid_file_spec):
* src/tr.c (validate_case_classes):
Mark defns with MAYBE_UNUSED if they’re not used when -DNDEBUG.
* src/factor.c (prime_p, prime2_p, mp_prime_p): Now ATTRIBUTE_PURE.
Prefer affirm to error+abort.  No need to translate this diagnostic.
* src/fmt.c (get_paragraph):
* src/stty.c (display_changed, display_all, sane_mode):
* src/who.c (idle_string):
Prefer assume to assert, since the goal is merely pacification
and assert doesn’t pacify anyway if -DNDEBUG is used.
* src/join.c (decode_field_spec):
Omit unreachable abort.
* src/ls.c (assert_matching_dev_ino, main):
* src/tr.c (get_next):
Prefer assure to assert, since the check is relatively expensive
and won’t help static analysis.
* src/ls.c (main):
Prefer static_assert to assert of a constant expression.
(format_inode): Redo to make it clear that buflen doesn’t matter,
and that buf must have a certain number of bytes.  All callers changed.
This pacifies -Wformat-overflow.
* src/od.c (decode_one_format):
Omit an assert that tested for obviously undefined behavior,
as the compiler could optimize it away anyway.
* src/od.c (decode_one_format, decode_format_string):
Prefer ATTRIBUTE_NONNULL to runtime checking.
* src/stat.c: Do not include <stddef.h> since system.h does that now.
* src/sync.c (sync_arg):
Prefer unreachable () to assert (true), which was a typo.
* src/system.h: Include stddef.h, for unreachable.
* src/tail.c (xlseek): Simplify by relying on ‘error’ to exit.
2023-07-01 11:51:15 -07:00
Paul Eggert
2522c1db68 maint: fix indenting in previous change
* src/ptx.c: Adjust to fit into 80 columns.
2023-07-01 11:51:14 -07:00
Paul Eggert
16b5ca6e0d maint: prefer C23-style nullptr
* bootstrap.conf (gnulib_modules): Add nullptr.
In code, prefer nullptr to NULL where either will do.
2023-06-29 15:29:29 -07:00
Bruno Haible
e600fbb764 build: ensure that makeinfo ≥ 6.8 checks the @menu structure
See <https://lists.gnu.org/r/bug-texinfo/2023-06/msg00015.html>.

* doc/local.mk (MAKEINFO): New variable.
* cfg.mk (_makefile_at_at_check_exceptions): Update.
2023-06-22 23:22:07 +01:00
Pádraig Brady
e8858f1515 b2sum: fix UAR with --check with malformed checksum lines
* src/digest.c (split_3): Reinstate the check for whitespace after the
digest portion of the line, so that we exit early before inspecting
the file name which would be outside the passed buffer in the case
where the input does not contain a newline.
* tests/cksum/b2sum.sh: Add a test case.
* NEWS: Mention the bug fix.
* THANKS.in: Add Frank Busse who has reported multiple bugs using KLEE.
Fixes https://bugs.gnu.org/64229
2023-06-22 23:22:07 +01:00
Paul Eggert
ed9d8b8730 maint: update GCC bug number in comment 2023-06-21 00:08:21 -07:00
Paul Eggert
3638944ff5 doc: mention fix for bug#64123 2023-06-19 23:24:02 -07:00
Paul Eggert
5ac7f2d281 build: update gnulib submodule to latest 2023-06-19 23:24:02 -07:00
Sylvestre Ledru
15925d0e5b tests: move tests to a directory per utility
* cfg.mk: Adjust syntax check exclusion paths.
* tests/local.mk: Adjust for renamed tests.
2023-06-19 13:12:37 +01:00
Pádraig Brady
d53190ed46 doc: mention cksum error fix with cpu feature checks changes
* NEWS: Mention the error message to aid those searching
for solutions to the issue, and mention cksum also
as that was confirmed to fix the error with the adjusted
cpu feature detection, as discussed at https://bugs.debian.org/1037264
* src/cksum.c: Cleanup syntax-check failure from previous commit.
2023-06-15 01:00:05 +01:00
Paul Eggert
f780a85985 cksum,wc: clean up hw capability checking
* src/cksum.c (cksum_pclmul) [!CRCTAB && !USE_PCLMUL_CRC32]:
Remove macro.
(cksum_fp): No longer file-scope.
(pclmul_supported): Define only if USE_PCLMUL_CRC32.
This omits the debug output "using generic hardware support"
for simplicity and consistency with wc’s output.
(crc_sum_stream) [!USE_PCLMUL_32]: No need for static function pointer.
* src/wc.c (wc_lines_p) [USE_AVX2_WC_LINECOUNT]: No longer file-scope.
(wc) [USE_AVX2_WC_LINECOUNT]: Check for avx2 support at most once,
which was surely the code’s original intent.
(wc) [!USE_AVX2_WC_LINECOUNT]: No need for static function pointer.
2023-06-14 14:54:46 -07:00
Paul Eggert
4ac941565f cksum,wc: don’t include <cpuid.h>
* src/cksum.c [!CRCTAB && USE_PCLMUL_CRC32]:
* src/wc.c [USE_AVX2_WC_LINECOUNT]:
Don’t include <cpuid.h>; no longer needed.
2023-06-14 14:54:46 -07:00
Paul Eggert
7814596fa9 cksum: fix bug in check for cksum_pclmul
This fixes a typo in the previous patch.
Problem reported by Pádraig Brady <https://bugs.gnu.org/64058#11>.
* src/cksum.c (pclmul_supported): Also require AVX support
to use cksum_pclmul.
2023-06-14 14:54:46 -07:00
Paul Eggert
91a74d3614 wc: port to kernels that disable XSAVE YMM
Problem reported by Dave Hansen <https://bugs.gnu.org/64058>.
Apply similar change to cksum and pclmul, too.
* NEWS: Mention wc fix.
* configure.ac (cpuid_exists, get_cpuid_count_exists):
Remove.  All uses removed, since we no longer use __get_cpuid or
__get_cpuid_count.
(pclmul_intrinsic_exists, avx2_intrinsic_exists): Set to no if
__builtin_cpu_supports calls cannot be compiled.
(HAVE_PCLMUL_INTRINSIC, HAVE_AVX2_INTRINSIC): Remove; unused.
Simplify surrounding code because of this.
* src/cksum.c (pclmul_supported):
* src/wc.c (avx2_supported):
Use __builtin_cpu_supports instead of doing it by hand.
Simplify surrounding code because of this.
2023-06-13 21:14:29 -07:00
Ville Skyttä
3789024073 dircolors: update list of backup file extensions
* src/dircolors.hin: Sort backup section by extension.
Treat .dpkg-new and .dpkg-tmp as backup files.
Treat .crdownload (Chromium based browsers' partial download)
as a backup file.
2023-06-12 21:55:51 +01:00
Pádraig Brady
e8e81fc44b dd: fix parsing of numbers with more than two multipliers
* src/dd.c (parse_integer): Use recursion to support more than two
multipliers.  Also protect suffix[-1] access to ensure we don't
inspect before the passed string.
* tests/dd/bytes.sh: Add test cases.
* doc/coreutils.texi (dd invocation): Note the support for specifying
many multipliers in a number.
* NEWS: Mention the bug fix.
Fixes https://bugs.debian.org/1037275
2023-06-11 23:10:34 +01:00
Pádraig Brady
b841f111de build: update gnulib submodule to latest
* gnulib: Update to latest.
* po/POTFILES.in: Remove recent sc_po_check workaround.
* tests/misc/date-debug.sh: Adjust as per spelling fix.
2023-06-09 11:27:35 +01:00
Pádraig Brady
66ea09b0fe doc: od --strings: clarify operation
* doc/coreutils.texi (od invocation): Remove mention of ASCII,
as all printable characters in unibyte locales are output.
* src/od.c (usage): Clarify that only NUL terminated strings
are displayed, and that it's printable chars, not only graphic chars
that are output. I.e., spaces are output also if part of the string.
Reported at https://bugs.ddebian.org/1037217
2023-06-08 11:06:20 +01:00
Pádraig Brady
c2173c0a52 maint: ls.c: update stale comment for previous commit
* src/ls.c (gobble_file): Update comment to correspond with
the changes in the previous commit.
2023-06-07 21:51:47 +01:00
Pádraig Brady
bf574deec8 ls: display command line symlinks that return ELOOP
* src/ls.c (gobble_file): Ensure we lstat() a symlink
specified on the command line, if we receive ELOOP from stat().
* tests/ls/symlink-loop.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/63931
2023-06-07 19:59:40 +01:00
Pádraig Brady
e1e21f6dff ls: use more standard symlink traversal
* src/ls.c (gobble_file): stat() symlinks directly,
rather than their targets.  This will be more consistent
with how symlinks are generally accessed.
(make_link_name): Remove no longer used function.
Addresses https://bugs.gnu.org/63931
2023-06-07 19:59:30 +01:00
Pádraig Brady
6c975de166 doc: reference COPYING from README
* README: Reference COPYING as per the GNU coding standards,
and soon to be enforced with a syntax-check from gnulib.
2023-06-07 16:05:15 +01:00
Pádraig Brady
6a61883757 maint: avoid syntax-check failure
* po/POTFILES.in: Add lib/propername.h due to new comments
that trigger sc_po_check.
2023-06-06 11:34:09 +01:00
Pádraig Brady
3621d51c9d doc: NEWS: mention the more defensive copy_file_range avoidance
* NEWS: Mention the improvement in reinstating runtime avoidance
of copy_file_range(), that came with the last gnulib update,
picking up gnulib commit fb034b35.
2023-06-06 11:16:39 +01:00
Paul Eggert
e8909df3ce build: update gnulib submodule to latest 2023-06-05 22:44:22 -07:00
Pádraig Brady
4d12f4df0c maint: use consistent make variable interpolation syntax
* cfg.mk: Prefer $() interpolation over ${}
lest the reader is confused as to whether shell interpolation,
i.e. $${} was intended.
2023-06-01 13:21:12 +01:00
Pádraig Brady
0147288d20 split: --additional-suffix: disallow trailing '/'
Note mktemp --suffix has the same inconsistency,
but mktemp -d does support creating dirs
so probably best to leave that as is.

* src/split.c (main): Check for trailing /.
* tests/split/additional-suffix.sh: Augment the test.
Reported in https://bugs.debian.org/1036827
2023-05-31 17:26:13 +01:00
Pádraig Brady
d055228e34 maint: adjust code to handle "error" syntax-check changes
* src/dd.c: Don't include no longer used error.h.
Use quoteaf() rather than quote() to quote appropriate for the shell
and to avoid the syntax-check failure,
* src/stty.c: Use quoteaf() rather than quotef()
to have more consistent quoting of the invalid arg.
2023-05-31 17:24:13 +01:00
Pádraig Brady
b7c8eb0046 maint: augment syntax checks to cater for more "error" functions
src/cfg.mk (sc_error_quotes, sc_error_shell_quotes,
sc_error_shell_always_quotes): Include "die" and "diagnose"
in the class of error functions to check arguments for.
2023-05-31 17:20:09 +01:00
Paul Eggert
48f5a39872 dd: fix ‘error’ name issue without macros
* src/dd.c (_GL_NO_INLINE_ERROR): Remove; no longer needed.
(diagnose): Rename from nl_error and omit first arg since it is
always zero.  All uses changed.
(error): Remove macro.
2023-05-30 14:25:03 -07:00
Pádraig Brady
fe18d3982a build: update gnulib submodule to latest
* gnulib: Update to latest.
* src/dd.c: Avoid error macro redefinition.
2023-05-28 15:03:00 +01:00
Pádraig Brady
17479ef60c build: modernize bootstrap prerequsite tools
Following on from commit v9.0-15-gaa31b919c
which updated README-prereq...

* bootstrap.conf: Add an explicit requirement on m4.
Add an explicit requirement on texi2pdf which is often
packaged separately to makeinfo and induces a failure
far down the distribution phase if not present.
Replace the rsync dependency with wget,
which gnulib changed to in 2018.
2023-05-19 22:20:07 +01:00
Pádraig Brady
d5d9b67eec build: update gnulib submodule to latest
* gnulib: Update to latest.
* configure.ac: Remove gnulib reference, as that specific issue
is now explicitly avoided in gnulib itself.
2023-05-19 18:40:53 +01:00
Pádraig Brady
76e1200eeb build: pacify GCC 13 with -flto
* src/cut.c (cut_file): Explicitly mark STREAM as nonnull to avoid
-Werror=null-dereference.
* src/nl.c (nl_file): Likewise.
2023-05-19 11:32:14 +01:00
Pádraig Brady
ba0527d4ca build: revert -Wmaybe-uninitialized warnings avoidance
This reverts commit 800c86d5, as that was deemed too invasive.
We do keep the change to tee.c to allow using -O3 without warnings.
For other optimization options like -O0, -Og, -O1, -Os,
one can use WERROR_CFLAGS= to stop warnings inducing a build failure.
2023-05-19 09:58:50 +01:00
Pádraig Brady
800c86d5fa build: avoid false -Wmaybe-uninitialized warnings
Allow easily building a debug build for example with:
  make CFLAGS='-O0 -ggdb'

False -Wmaybe-uninitialized warnings hit in different
places depending on the compiler passes used.
These changes were tested with gcc 10.2.1, 12.2.1, and 13.1.1 like:
  for o in g s z fast 0 1 2 3; do
    make clean && make -j$(nproc) CFLAGS="-O$o" || break
  done

* src/digest.c: Disable -Wmaybe-uninitialized that gives
false positive here at -O0.
* src/ln.c: Avoid -Wmaybe-uninitialized that gives
false positive here at -O1.
* src/pr.c: Likewise.
* src/sort.c: Likewise.
* src/tee.c: Avoid -Wmaybe-uninitialized that gives
false positive here at -O3 on gcc 13.1.1 at least.
* src/cp.c: Avoid -Wmaybe-uninitialized that gives
false positive here at -Os on gcc 13.1.1 at least.
* src/copy.c: Avoid -Wmaybe-uninitialized that gives
false positive here at -Og on gcc 13.1.1 at least.
* src/head.c: Likewise.
* src/paste.c: Likewise.
2023-05-18 12:13:47 +01:00
Pádraig Brady
aed3b8190a build: gnulib: avoid false -Wstringop-overflow warning
Tested on gcc 13.1.1 with: make CFLAGS='-O0 -ggdb'

* configure.ac: Disable -Wstringop-overflow for gnulib.
This warning is far too problematic in my experience:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
and triggers with gcc -O0 with versions 12,13 at least.
2023-05-18 11:57:26 +01:00
Pádraig Brady
f218412b9a maint: cleanups to NEWS
* NEWS: Use more consistent wording, ordering, and formatting
for recent entries.
2023-05-13 10:33:14 +01:00
Pádraig Brady
059e53e5b4 split: advise the kernel of sequential access pattern
As split is often dealing with large files,
ensure we indicate to the kernel our sequential access pattern.
This was seen to operate 5% faster when reading from SSD,
as tested with:

dd bs=1M count=2K if=/dev/urandom of=big.in

for split in split.orig split; do
  # Ensure big file is not cached
  dd of=big.in oflag=nocache conv=notrunc,fdatasync count=0 status=none
  # Test read efficiency
  CWD=$PWD; (cd /dev/shm && time $CWD/src/$split -n2 $CWD/big.in)
done

real    0m9.039s
user    0m0.055s
sys     0m3.510s

real    0m8.568s
user    0m0.056s
sys     0m3.752s

* src/split.c (main): Use fdadvise to help the kernel
choose a more appropriate readahead buffer.
* NEWS: Mention the improvement.
2023-05-08 21:34:58 +01:00
Pádraig Brady
ba128e628c doc: adjust build instructions for disabling year 2038 support
* README-install: Adjust the instructions as per recent gnulib updates.
2023-05-08 12:57:56 +01:00
Bernhard Voelker
3f942cd03f build: update gnulib submodule to latest
This fixes failures in "very-expensive" tests on FTS with many
directory entries:
  FAIL: tests/rm/ext3-perf
  FAIL: tests/rm/many-dir-entries-vs-OOM

The following shows the problem in the former of the above tests:
  $ mkdir d && seq 400000 | env -C d xargs touch )
  $ rm -rf d
  rm: traversal failed: d: Operation not supported

Gnulib commit 3f0950f65abb (2023-04-26) introduced this regression
which was fixed again with gnulib commit d4d8abb39eb0.

See discussion in
<https://lists.gnu.org/r/bug-gnulib/2023-05/msg00040.html>

* bootstrap.conf (gnulib_modules): Change "year2038-required" to
"year2038-recommended"; the module has been replaced.
* gnulib: Update to latest.
* tests/init.sh: Likewise.
2023-05-07 23:07:12 +02:00
Paul Eggert
42f33ae68c doc: time zone conversion example
* doc/coreutils.texi (Examples of date):
Give time zone conversion example.
2023-05-07 09:17:27 -07:00
Paul Eggert
7edec89fc3 doc: new subsection for date format specs
* doc/coreutils.texi (Date format specifiers): New subsection,
which groups the date format specifiers without otherwise
changing contents.
2023-05-07 09:17:26 -07:00
Pádraig Brady
fae65623a9 pr: fix parsing of empty arguments
Before:
  $ pr --expand-tabs=
  pr: '-e' extra characters or invalid number in the argument:
   ‘SHELL=/bin/bash’: Value too large for defined data type

After:
  $ pr --expand-tabs=
  pr: '-e': Invalid argument: ‘’

* src/pr.c (getoptarg): Ensure we don't parse beyond the
end of an empty argument, thus outputting arbitrary stack
info in subsequent error messages.

Addresses https://bugs.debian.org/1035596
2023-05-06 11:26:04 +01:00
Paul Eggert
300af78691 cp: -p --parents: minor cleanup of previous patch
This doesn’t change behavior; it just clarifies the code a bit.
* src/cp.c (re_protect): New arg DST_SRC_NAME, for clarity, and so
that we need to skip '/'s only once.  Caller changed.
Rename a couple of local variables to try to make things clearer.
2023-05-05 11:05:03 -07:00
Pádraig Brady
c6b1fe4347 cp: -p --parents: fix failure to preserve permissions for absolute paths
* src/cp.c (re_protect): Ensure copy_acl() is passed an absolute path.
* tests/cp/cp-parents.sh: Add a test case.
* NEWS: Mention the bug.
Fixes https://bugs.gnu.org/63245
2023-05-03 18:15:59 +01:00
Pádraig Brady
7223651ad1 tests: provide more info on DEBUG=yes
* README: State that DEBUG=yes is particularly useful with perl tests.
* tests/split/l-chunk.sh: Use the more standard $DEBUG variable
rather than an internal $DEBUGGING variable.
2023-05-02 22:39:03 +01:00
Pádraig Brady
6d683a1d02 doc: provide more info on the default 32-bit cksum digest
* doc/coreutils.texi (cksum invocation): Say that the default
digest format is 32-bit and based on the Ethernet standard CRC.
2023-04-30 22:10:25 +01:00
Pádraig Brady
2cae0419c9 maint: remove redundant exit status handling
* src/numfmt.c: Remove redundant / confusing
use of TIMEOUT_FAILURE.
2023-04-30 13:05:12 +01:00
Paul Eggert
35adc746a0 maint: simplify --enable-gcc-warnings='expensive'
* configure.ac (WERROR_CFLAGS): Omit mention of
-Wno-analyzer-double-free, -Wno-analyzer-null-dereference, and
-Wno-analyzer-use-after-free as manywarnings no longer uses them.
2023-04-26 18:20:20 -07:00
Paul Eggert
21e7573508 maint: suppress GCC 13 false alarms
* src/csplit.c, src/fmt.c, src/make-prime-list.c, src/nohup.c:
Add pragmas to pacify GCC 13 when coreutils is configured
with --enable-gcc-warnings='expensive'.
2023-04-26 18:20:20 -07:00
Paul Eggert
6c199713ed chmod: pacify GCC 13
* src/chmod.c (main): Use xpalloc instead of X2REALLOC,
and make the corresponding variables signed instead of unsigned.
When reallocating the buffer, this grows it by a factor of 1.5, not 2.
This also pacifies gcc -Wanalyzer-null-dereference.
2023-04-26 18:20:19 -07:00
Paul Eggert
d178b49754 csplit: pacify GCC 13
* src/csplit.c (load_buffer): Refactor for clarity.
This also xpacifies gcc -Wanalyzer-use-of-uninitialized-value.
When reallocating the buffer, grow it by a factor of 1.5, not 2.
2023-04-26 18:20:19 -07:00
Paul Eggert
941027eeb7 build: update gnulib submodule to latest 2023-04-26 18:20:19 -07:00
Pádraig Brady
5e1c5f2d71 tests: more cases for read input diagnostics
* tests/misc/read-errors.sh: Exercise more modes of
various utilities for better read error coverage.
* tests/split/fail.sh: Remove part refactored into the above test.
2023-04-26 16:20:50 +01:00
Pádraig Brady
4eb5abbff4 uniq: be more specific when diagnosing read errors
* src/uniq.c (check_file): Use the errno when diagnosing read errors.
2023-04-26 16:19:51 +01:00
Jaroslav Skarvada
b16553cdad build: fix build with -mno-ssse3
Avoid the following error with -mno-ssse3:
 inlining failed in call to 'always_inline' '_mm_shuffle_epi8':
 target specific option mismatch

* configure.ac: Ensure we use ssse3 specific code when
checking whether to enable the pclmul cksum implementation.
2023-04-26 13:51:42 +01:00
Pádraig Brady
3fb0cc80fa pr: fix infinite loop when double spacing
* src/pr.c (init_parameters): Ensure we avoid a 0 lines_per_body
which was possible when adjusting for double spacing.
That caused print_page() to always return true,
causing an infinite loop.
* tests/pr/pr-tests.pl: Add a test case.
* NEWS: Mention the fix.
Fixes https://bugs.debian.org/1034808
2023-04-25 14:18:35 +01:00
Pádraig Brady
cc078f747f copy: reduce verbosity of -i and -u with --verbose
Since skipping of files is central to the operation of -i and -u,
and with -u one may be updating few files out of many,
reinstate the verbosity of this functionality as it was before 9.3.

* src/copy.c (copy_internal): Only output "skipped" message
with --debug.  Also adjust so message never changes with --debug.
* tests/cp/cp-i.sh: Adjust accordingly.
* tests/mv/mv-n.sh: Likewise.
* tests/cp/debug.sh: Add explicit test case for message.
* NEWS: Mention the change in behavior.
2023-04-25 11:17:54 +01:00
Pádraig Brady
7ea7c020e8 tests: ensure all utilities that read input diagnose errors
* tests/misc/read-errors.sh: Add a new test.
* tests/misc/date-f.sh: Remove unneeded test.
* tests/misc/dircolors.sh: Likewise.
* tests/local.mk: Reference new test, and dereference removed ones.
2023-04-24 11:46:28 +01:00
Pádraig Brady
82e1750daa factor: diagnose errors reading the input
* src/factor.c (do_stdin): Exit with failure upon read errors.
* NEWS: Mention the bug fix.
2023-04-24 11:46:28 +01:00
Pádraig Brady
5595673d5c numfmt: diagnose errors reading the input
* src/numfmt.c (main): Exit with failure upon read errors.
* NEWS: Mention the bug fix.
2023-04-24 11:46:28 +01:00
Pádraig Brady
0e62ba282e tsort: diagnose errors reading the input
* src/tsort.c (tsort): Check for errors after readtoken().
* NEWS: Mention the bug fix.
2023-04-24 11:46:28 +01:00
Pádraig Brady
9d333aca43 cksum: fix failure to diagnose read errors with crc32
The default crc32 mode fails to diagnose read errors.

* src/cksum.c (cksum_slice8): Fix the check for read errors.
(cksum_pclmul): Likewise.
* NEWS: Mention the bug fix.
2023-04-24 11:46:28 +01:00
Andreas Schwab
e29f4411c8 tests: avoid failure when cp fails for proc files
When run under QEmu emulation emulated /proc files have
unstable inode numbers.

* tests/cp/proc-short-read.sh: Skip if unstable inode numbers detected.
2023-04-24 11:37:09 +01:00
Pádraig Brady
6bab375973 install: support stripping files with a leading hyphen
* src/install.c (strip): Prepend "./" to file names with a leading "-".
* tests/install/strip-program.sh: Add a test case.
* NEWS: Mention the bug fix.
Reported in https://bugs.debian.org/1034429
2023-04-21 19:13:52 +01:00
Pádraig Brady
f6229adb09 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2023-04-18 15:32:53 +01:00
Pádraig Brady
f386722dc0 version 9.3
* NEWS: Record release date.
2023-04-18 15:08:11 +01:00
Pádraig Brady
d81094dc7b tests: avoid allocation checks on ZFS
* tests/du/basic.sh: Allocation of files was seen to change
asynchronously on ZFS, so avoid allocation comparisons there.
2023-04-16 16:11:20 +01:00
Pádraig Brady
cf91b9d62c tests: tty-eof: fix various issues
* tests/misc/tty-eof.pl: Ensure we don't erroneously
skip commands with parameters.
Comment as to why cut(1) is treated differently.
Adjust expect calls to not wait needlessly for cut output.
2023-04-14 00:02:22 +01:00
Pádraig Brady
daa1e4f557 tests: avoid dependence on file layout for cp sparse check
* tests/cp/sparse-2.sh: Don't depend on the copy taking
<= allocation of the source.  Instead leverage --debug
to check that zero detection is being enabled.
2023-04-13 20:19:18 +01:00
Pádraig Brady
854c90ecc0 copy: --debug: indicate if NUL detection is used with SEEK_HOLE
* src/copy.c (sparse_copy): With --sparse=always we also detect
NULs in extents we're copying, so indicate this with --debug.
2023-04-13 20:19:09 +01:00
Paul Eggert
cc95246ee2 doc: update re 32-bit builds
* README-install: Mention how to build on 32-bit-only hosts.
This builds on a previous patch by Pádraig Brady.
2023-04-10 11:56:43 -07:00
Pádraig Brady
ae4dace2ec build: fix _Noreturn compilation failure
Fix a build failure seen on gcc 3.4 on Solaris 10 at least.

* src/crctab.c: Ensure we include config.h for all compilation units.
This is now required for new _Noreturn usage in gnulib for stdint.h.
* src/cksum.c: Update generation code to ensure config.h included.
* cfg.mk: Remove crctab.c exclusion from the config.h check.
2023-04-10 19:45:14 +01:00
Pádraig Brady
09ded7049b tests: avoid non portable brace expansion
* tests/cp/backup-dir.sh: Avoid non portable brace expansion
which is not supported by FreeBSD or Solaris shells at least.
2023-04-10 18:54:19 +01:00
Paul Eggert
ffd62ab92c maint: require support for post-2038 timestamps
* bootstrap.conf (gnulib_modules): Replace year2038 with
year2038-required.
2023-04-09 19:21:55 -07:00
Paul Eggert
6f91c2eac3 build: update gnulib submodule to latest 2023-04-09 19:21:55 -07:00
Pádraig Brady
ce630dfc7e wc: ensure we update file offset
* src/wc.c (wc): Update the offset when not reading,
and do read if we can't update the offset.
* tests/misc/wc-proc.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/61300
2023-04-08 12:19:40 +01:00
Pádraig Brady
f6c21f6d3a cp,mv: issue "skipped" messages when skipping files
* NEWS: Mention the change in behavior to issue a "not replaced"
error diagnostic with -n, and the "skipped" message with -v.
* src/copy.c (copy_internal): Adjust to output the "skipped" messages
depending on -i, -n, -u.
* tests/cp/cp-i.sh: Adjust accordingly.
* tests/mv/mv-n.sh: Likewise.
2023-04-08 12:11:58 +01:00
Pádraig Brady
db28af406f cp,mv: add --update=none to always skip existing files
Add --update=none which is equivalent to the --no-clobber behavior
from before coreutils 9.2.  I.e. existing files are unconditionally
skipped, and them not being replaced does not affect the exit status.

* src/copy.h [enum Update_type]: A new type to support parameters
to the --update command line option.
[enum Interactive]: Add I_ALWAYS_SKIP.
* src/copy.c: Treat I_ALWAYS_SKIP like I_ALWAYS_NO (-n),
except that we don't fail when skipping.
* src/system.h (emit_update_parameters_note): A new function
to output the description of the new --update parameters.
* src/cp.c (main): Parse --update arguments, ensuring that
-n takes precedence if specified.
(usage): Describe the new option.  Also allude that
-u is related in the -n description.
* src/mv.c: Accept the new --update parameters and
update usage() accordingly.
* doc/coreutils.texi (cp invocation): Describe the new --update
parameters.  Also reference --update from the --no-clobber description.
(mv invocation): Likewise.
* tests/mv/update.sh: Test the new parameters.
* NEWS: Mention the new feature.
Addresses https://bugs.gnu.org/62572
2023-04-08 12:11:50 +01:00
Pádraig Brady
5891d28ede cp: fix --backup with subdirectories
* gnulib: Reference the latest gnulib including the
fix to the backupfile module in commit 94496522.
* tests/cp/backup-dir.sh: Add a test to ensure
we rename appropriately when backing up through subdirs.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/62607
2023-04-04 12:00:11 +01:00
Pádraig Brady
17c31a73f1 tests: tee: avoid false failure due to fifo usage
* tests/misc/tee.sh: Call cleanup_ in all cases to ensure
there are no overlapping interactions on the fifo that
might impact later parts of the test.  This was seen to
cause issue with dash on musl libc.
Addresses https://bugs.gnu.org/62542
2023-03-31 11:58:53 +01:00
Pádraig Brady
5e170ff0b8 tests: adjust csplit VM limit
* tests/misc/csplit-heap.sh: More memory is required to avoid
a false failure on some systems.  Noticed with musl libc
with bash as the shell.  This is confirmed to still easily
trigger with the original memory leak being tested.
Addresses https://bugs.gnu.org/62542
2023-03-31 11:58:53 +01:00
Pádraig Brady
7ad749886c wc: diagnose overflow of total counts
* src/wc.c (wc): Use INT_ADD_WRAPV() to detect overflow.
(main): Upon overflow, saturate the total, print a diagnostic,
and set exit status.
* tests/misc/wc-total.sh: Add a test case, which operates
on BTRFS and 64 bit systems at least.
Reported at https://bugs.debian.org/1027100
2023-03-31 11:58:49 +01:00
Pádraig Brady
a9bd274616 dircolors: diagnose read errors
* NEWS: Mention the fix.
* src/dircolors.c: Fail upon read error from getline().
* tests/misc/dircolors.sh: Add a new test.
* tests/local.mk: Reference the new test.
2023-03-28 14:24:29 +01:00
Pádraig Brady
a4525de1ef tests: add a test case for the previous date fix
* NEWS: Also mention this bug fix.
* tests/misc/date-f.sh: Add a new test.
* tests/local.mk: Reference the new test.
2023-03-28 13:40:43 +01:00
Paul Eggert
9c5e542fd1 date: diagnose -f read errors
* src/date.c (batch_convert): Diagnose read errors, fixing Bug#62497.
2023-03-28 01:53:06 -07:00
Paul Eggert
6272817de0 cp: clarify commentary
* src/copy.c: Make comments a bit clearer.
2023-03-25 13:20:16 -07:00
Pádraig Brady
093a8b4bfa copy: fix --reflink=auto to fallback in more cases
On restricted systems like android or some containers,
FICLONE could return EPERM, EACCES, or ENOTTY,
which would have induced the command to fail to copy
rather than falling back to a more standard copy.

* src/copy.c (is_terminal_failure): A new function refactored
from handle_clone_fail().
(is_CLONENOTSUP): Merge in the handling of EACCES, ENOTTY, EPERM
as they also pertain to determination of whether cloning is supported
if we ever use this function in that context.
(handle_clone_fail): Use is_terminal_failure() in all cases,
so that we assume a terminal failure in less errno cases.
* NEWS: Mention the bug fix.
Addresses https://bugs.gnu.org/62404
2023-03-24 13:12:51 +00:00
Pádraig Brady
55456b95d8 doc: add a NEWS entry for the previous fix
* NEWS: Mention the previous cksum --check fix.
2023-03-24 12:52:13 +00:00
Pádraig Brady
76f2fb6271 cksum: fix reporting of failed checks
This applies to all checksumming utilities,
where we incorrectly report all subsequent files as checking 'OK'
once any file has passed a digest check.
The exit status was not impacted, only the printed status.

* src/digest.c (digest_check): Use the correct state variable
to determine if the _current_ file has passed or not.
* tests/misc/md5sum.pl: Add a test case.
Fixes https://bugs.gnu.org/62403
2023-03-23 12:36:53 +00:00
Nick Alcock
eeabb11eb6 tests: skip some parts of tests/misc/tee.sh if run as root
Similarly to the fix to tests/rmdir/ignore.sh in c0e5f8c59,
tee should not be expected to fail when run with read-only outputs
when run as root.

* tests/misc/tee.sh: Add uid_is_privileged_ guard around test for
read-only outputs.
2023-03-21 16:15:18 +00:00
Pádraig Brady
bdda9adb38 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2023-03-20 14:08:46 +00:00
Pádraig Brady
df4e4fbc7d version 9.2
* NEWS: Record release date.
2023-03-20 13:44:36 +00:00
Pádraig Brady
445f502839 tests: avoid false failure on systems without statx
* tests/ls/stat-free-symlinks.sh: Filter out syscalls that
return ENOSYS, as that was seen with statx() on Debian 10.13
on mips64, and resulted in overcounting of stat calls.
2023-03-19 23:44:51 +00:00
Pádraig Brady
eb745e3b95 stty: ensure arbitrary data is not displayed
* src/stty.c (main): Use static structures to ensure
they're initialized (to zero), so that random data is
not displayed, or compared resulting in a inaccurate
failure reported to users.  This was seen on musl libc
where some parts of the termios c_cc array were
not initialized by tcgetattr().
Reported by Bruno Haible.
2023-03-19 22:25:50 +00:00
Pádraig Brady
82bb131c55 tests: df: avoid false failure on systems with multiple roots
* tests/df/df-symlink.sh: Skip the test on systems
with multiple file system roots.
2023-03-19 12:23:05 +00:00
Pádraig Brady
11f4d59138 doc: uniq: revert previous man page adjustment
* src/uniq.c (usage): -D doesn't take an argument
so should be separated in the description.
2023-03-18 14:58:20 +00:00
Pádraig Brady
8a759fdc88 doc: uniq: use more standard description of -D long option
* src/uniq.c: Describe -D and --all-repeated together,
as with all other long options.
Fixes https://bugs.gnu.org/62249
2023-03-18 11:44:24 +00:00
Pádraig Brady
a109106eb8 tests: aix: avoid unsupported functionality
* tests/misc/tee.sh: AIX doesn't support detecting
closed outputs either with poll() or select() so avoid
testing that functionality.
* tests/tail-2/pipe-f.sh: Likewise.
2023-03-18 11:44:24 +00:00
Bernhard Voelker
f346fc0144 maint: avoid discarded-qualifiers warnings with SELinux 3.5
Since SELinux version 3.5, the return value of context_str(3) is
declared as const; see:
  https://github.com/SELinuxProject/selinux/commit/dd98fa322766
Therefore, GCC complains (here with -Werror):
  src/selinux.c: In function 'defaultcon':
  src/selinux.c:152:16: error: assignment discards 'const' qualifier \
    from pointer target type [-Werror=discarded-qualifiers]
    152 |   if (!(constr = context_str (tcontext)))
        |                ^
  src/selinux.c: In function 'restorecon_private':
  src/selinux.c:252:16: error: assignment discards 'const' qualifier \
    from pointer target type [-Werror=discarded-qualifiers]
    252 |   if (!(constr = context_str (tcontext)))
      |                ^

* src/selinux.c (defaultcon): Define CONSTR as const.
(restorecon_private): Likewise.
2023-03-17 00:12:18 +01:00
Pádraig Brady
1d03781daa test: avoid a test hang on Hurd
* tests/cp/sparse-to-pipe.sh: Protect the cp call seen to
hang on Hurd/i686 with a timeout.
Reported By: Bruno Haible
2023-03-15 18:11:00 +00:00
Pádraig Brady
a8e6e627f1 cksum: fix --raw on 64 bit big endian systems
* src/sum.c (output_bsd): On sparc64 for example,
a crc of 0 was output due to casting an int variable
to uint16_t and thus operating on the wrong end of the variable.
Instead use explicit assignment to the narrower type
to ensure we get the appropriate data.
(output_sysv): Likewise.
Reported by Bruno Haible.
2023-03-15 14:05:38 +00:00
Bruno Haible
f1ff021247 build: avoid -Wsometimes-uninitialized on macOS 12
* src/pr.c (integer_overflow): Mark as _Noreturn.
* src/test.c (beyond): Likewise.
2023-03-15 13:15:11 +00:00
Pádraig Brady
e68b15a3ef doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.29 which is now about 5 years old.
2023-03-13 21:45:50 +00:00
Pádraig Brady
73d372dcc1 tee: avoid undefined behavior after fclose()
* iopoll.c (fclose_wait): Rename from confusing fclose_nonblock name.
Also adjust to do no operations on the stream after fclose()
as this is undefined. Instead use fflush() to determine EAGAIN status.
(fwrite_wait): Renamed from confusing fwrite_nonblock name.
2023-03-13 21:26:21 +00:00
Pádraig Brady
f26af59833 doc: dircolors: better separate the sections in the database
* src/dircolors.hin: Make the separate sections of the self
documenting dircolors database more apparent,
by adding heading comments, and appropriate separation.
2023-03-13 16:20:38 +00:00
Pádraig Brady
47988fad88 ls: --color: honor separate sequences for extension cases
Following on from commit v8.29-45-g24053fbd8 which unconditionally
used case insensitive extension matching, support selective
case sensitive matching when there are separate extension cases
defined with different display sequences.

* src/dircolors.hin: Document how file name suffixes are matched.
Note this is displayed with `dircolors --print-database` which
the texi info recommends to use for details.
* src/ls.c (parse_ls_color): Postprocess the list to
mark entries for case sensitive matching,
and also adjust so that unmatchable entries are more quickly ignored.
(get_color_indicator): Use exact matching rather than
case insensitive matching if so marked.
* tests/ls/color-ext.sh: Add test cases.
* NEWS: Mention the change in behavior.
Addresses https://bugs.gnu.org/33123
2023-03-13 16:20:38 +00:00
Pádraig Brady
1ac1d6def6 tests: adjust du test for recent apparent size change
* tests/du/threshold.sh: Directories are assumed to be
of size 0 with --apparent since commit v9.1-187-g110bcd283
so remove --apparent cases from this test.
2023-03-13 16:20:38 +00:00
Pádraig Brady
16000805eb tee: support non blocking outputs
Non blocking outputs can be seen for example
when piping telnet through tee to a terminal.
In that case telnet sets its input to nonblocking mode,
which results in tee's output being nonblocking,
in which case in may receive an EAGAIN error upon write().
The same issue was seen with mpirun.
The following can be used to reproduce this
locally at a terminal (in most invocations):

  $ { dd iflag=nonblock count=0 status=none;
      dd bs=10K count=10 if=/dev/zero status=none; } |
    tee || echo fail >/dev/tty

* src/iopoll.c (iopoll_internal): A new function refactored from
iopoll(), to also support a mode where we check the output
descriptor is writeable.
(iopoll): Now refactored to just call iopoll_internal().
(fwait_for_nonblocking_write): A new internal function which
uses iopoll_internal() to wait for writeable output
if an EAGAIN or EWOULDBLOCK was received.
(fwrite_nonblock): An fwrite() wrapper which uses
fwait_for_nonblocking_write() to handle EAGAIN.
(fclose_nonblock): Likewise.
src/iopoll.h: Add fclose_nonblock, fwrite_nonblock.
src/tee.c: Call fclose_nonblock() and fwrite_nonblock wrappers,
instead of the standard functions.
* tests/misc/tee.sh: Add a test case.
* NEWS: Mention the improvement.

The idea was suggested by Kamil Dudka in
https://bugzilla.redhat.com/1615467
2023-03-08 18:32:05 +00:00
Pádraig Brady
176b74f0e7 doc: remove redundant NEWS entry
* NEWS: There was no bug on macOS,
and the split -n new feature is documented already.
2023-03-08 18:28:06 +00:00
Paul Eggert
bb9dbcbbfd split: support split -n on larger pipe input
* bootstrap.conf (gnulib_modules): Add free-posix, tmpfile.
* src/split.c (copy_to_tmpfile): New function.
(input_file_size): Use it to split larger files when sizes cannot
easily be determined via fstat or lseek.  See Bug#61386#235.
* tests/split/l-chunk.sh: Mark tests of /dev/zero as
very expensive since they exhaust /tmp.
2023-03-07 13:41:46 -08:00
Pádraig Brady
35ac97e0d6 tee: fix a crash with unwriteable files
This was introduced recently with commit v9.1-166-g6b12e62d9

* src/tee.c (tee_files): Check the return from fopen()
before passing to fileno() etc.
* tests/misc/tee.sh: Add a test case.
2023-03-07 01:14:00 +00:00
Paul Eggert
a4778006c8 maint: pacify ‘make syntax-check’
Problem reported by Pádraig Brady (Bug#61386#226).
* src/split.c (parse_chunk): Use die instead of error.
(main): Quote a string.
* tests/local.mk (all_root_tests): Move du/apparent.sh from here ...
(all_tests): ... to here.
2023-03-06 15:39:07 -08:00
Pádraig Brady
e30af1e584 tail,tee: avoid issues with many files on systems without poll
* src/iopoll.c (iopoll): Protect the call to select against
passing in a descriptor larger than FD_SETSIZE.
2023-03-06 13:04:40 +00:00
Paul Eggert
110bcd2838 du: --apparent counts only symlinks and regular
Problem reported by Christoph Anton Mitterer (Bug#61884).
* src/du.c (process_file): When counting apparent sizes, count
only usable st_size members.
* tests/du/apparent.sh: New file.
* tests/local.mk (all_root_tests): Add it.
2023-03-04 16:57:16 -08:00
Paul Eggert
8022874d12 split: tune for when creating output files
* src/split.c (create): Avoid fstat + ftruncate in the usual case
where the output file does not already exist, by trying
to create it with O_EXCL first.  This costs a failed open
in the unusual case where the output file already exists,
but that’s OK.
2023-03-04 14:49:46 -08:00
Paul Eggert
788654dd82 split: style fix
* src/split.c (ofile_open): Avoid ‘if (! (a = b))’ style.
2023-03-04 14:49:46 -08:00
Paul Eggert
40bf1591bb split: prefer signed integers to size_t
This allows for better runtime checking with gcc
-fsanitize=undefined.
* src/split.c: Include idx.h.
(open_pipes_alloc, n_open_pipes, suffix_length)
(set_suffix_length, input_file_size, sufindex, outbase_length)
(outfile_length, addsuf_length, create, cwrite, bytes_split)
(lines_split, line_bytes_split, lines_chunk_split)
(bytes_chunk_extract, ofile_open, lines_rr, main):
Prefer signed integers (typically idx_t) to size_t.
2023-03-04 14:49:46 -08:00
Paul Eggert
3434cdcec1 split: handle large numbers better
Prefer signed types to uintmax_t, as this allows for better
runtime checking with gcc -fsanitize=undefined.
Also, when an integer overflows just use the maximal value
when the code will do the right thing anyway.
* src/split.c (set_suffix_length, bytes_split, lines_split)
(line_bytes_split, lines_chunk_split, bytes_chunk_extract)
(lines_rr, parse_chunk, main):
Prefer a signed type (typically intmax_t) to uintmax_t.
(strtoint_die): New function.
(OVERFLOW_OK): New macro.  Use it elsewhere, where we now allow
LONGINT_OVERFLOW because the code then does the right thing on all
practical platforms (they have int wide enough so that it cannot
be practically exhausted).  We can do this now that we can safely
assume intmax_t has at least 64 bits.
(parse_n_units): New function.
(parse_chunk, main): Use it.
(main): Do not worry about integer overflow when the code
will do the right thing anyway with the extreme value.
Just use the extreme value.
* tests/split/fail.sh: Adjust to match new behavior.
2023-03-04 14:49:46 -08:00
Paul Eggert
1ebee5b1a3 split: prefer ssize_t for read result
* src/split.c (bytes_split, lines_chunk_split)
(bytes_chunk_extract, main): Prefer ssize_t to size_t when
representing the return value of ‘read’.  Use a negative value
instead of SIZE_MAX to indicate a missing value.
2023-03-04 14:49:46 -08:00
Paul Eggert
e19a59141b split: be more careful about buffer sizes
* src/split.c: Include sys-limits.h, not safe-read.h.
(input_file_size, bytes_split, lines_split, line_bytes_split)
(lines_chunk_split, bytes_chunk_extract, lines_rr): Call read, not
safe_read, since safe_read no longer buys us anything.
(main): Reject outlandish buffer sizes right away,
rather than allocating huge buffers and never using them.
2023-03-04 14:49:46 -08:00
Paul Eggert
0450987853 split: minor -1 / 0 refactor
* src/split.c (create, bytes_split, ofile_open):
Prefer comparing to 0 to comparing to -1.
2023-03-04 14:49:46 -08:00
Paul Eggert
a110ce4ce3 split: don’t worry about ECHILD
* src/split.c (closeout): There should be no need for a special
case for ECHILD, since we never wait for the same child twice.
Simplify with this in mind.
2023-03-04 14:49:46 -08:00
Paul Eggert
41615f0f8f split: don’t assume pid_t fits in int
* src/split.c (filter_pid): Now pid_t, not int.
(of_t): opid member is now pid_t, not int.
2023-03-04 14:49:45 -08:00
Paul Eggert
99fcde22ce split: simplify SIGPIPE handling
Ignore and default SIGPIPE, rather than blocking and unblocking it.
* src/split.c (default_SIGPIPE):
New static var, replacing oldblocked and newblocked.
(create): Use it.
(main): Set it.
2023-03-04 14:49:45 -08:00
Paul Eggert
aa266f1b3d split: port ‘split -n N /dev/null’ better to macOS
* src/split.c (input_file_size): Do not bother with lseek if the
initial read probe reaches EOF, since the file size is known then.
This works better on macOS, which doesn’t allow lseek on /dev/null.
Do not special-case size-zero files, as the issue can occur
with any size file (though /proc files are the most common).
If the current position is past end of file, treat this as
size zero regardless of whether the file has a usable st_size.
Pass through lseek -1 return values rather than using ‘return -1’;
this makes the code a bit easier to analyze (and a bit faster).
Avoid undefined behavior if the size calculation overflows.
(lines_chunk_split): Do not bother with lseek if it would have
no effect if successful.  This works better on macOS, which
doesn’t allow lseek on /dev/null.
* tests/split/l-chunk.sh: Adjust to match fixed behavior.
2023-03-04 14:49:45 -08:00
Paul Eggert
fe64f8be01 maint: fix NEWS quoting
* NEWS: Use English-language quoting in recent news.
2023-03-04 14:49:45 -08:00
Paul Eggert
fb6fc7f3ce split: split more evenly with -n
* src/split.c (bytes_split): New arg REM_BYTES.
Use this to split more evenly.  All callers changed.
(lines_chunk_split, bytes_chunk_extract):
Be consistent with new byte_split.
* tests/split/b-chunk.sh, tests/split/l-chunk.sh: Test new behavior.
2023-03-04 14:49:45 -08:00
Paul Eggert
0d997e18b9 split: small -n lines simplification
* src/split.c (lines_chunk_split):
Rewrite while as if-while for clarity.
2023-03-04 14:49:45 -08:00
Paul Eggert
f749449e5c split: refactor lines_chunk_split
* src/split.c (lines_chunk_split): Simplify by having chunk_end
point to the first byte after the chunk, rather than to the last
byte of the chunk.  This will reduce confusion once we allow
chunks to be empty.
2023-03-04 14:49:45 -08:00
Paul Eggert
0789451237 tee: tune when later -p overrides earlier
* src/tee.c (pipe_check): Make this a local var instead
of a static var.  This suppresses a -Wmaybe-uninitialized
diagnostic with gcc 12.2.1 20221121 (Red Hat 12.2.1-4).
(main): Don’t set pipe_check unnecessarily if a later
-p option overrides an earlier one that wants pipe_check.
Problem discovered when I investigated the GCC warning.
2023-03-04 14:49:45 -08:00
Pádraig Brady
76b5843ff9 maint: refactor tail.c to use iopoll
* src/tail.c (check_output_alive): Reuse iopoll()
rather than directly calling poll() or select().
* src/iopoll.c (iopoll): Refactor to support non blocking operation,
or ignoring descriptors by passing a negative value.
* src/iopoll.h (iopoll): Adjust to support a BLOCK parameter.
* src/tee.c (tee_files): Adjust iopoll() call to explicitly block.
* src/local.mk: Have tail depend on iopoll.c.
2023-03-01 19:27:36 +00:00
Pádraig Brady
5bcc2912e7 tail: avoid undefined behavior when polling outputs
* src/tail.c (check_output_alive): Only check the returned
events from poll() when it indicates there are events to check.
2023-02-28 14:04:16 +00:00
Pádraig Brady
fb757fd7d9 doc: tee -p: clarify operation
* src/tee.c (usage): Change from describing one (non pipe) aspect
to the more general point of being the option to use if working with
pipes, and referencing the more detailed info below.
* doc/coreutils.texi (tee invocation): s/standard/appropriate/ since
the standard operation with pipes is to exit immediately upon write
error.  s/early/immediately/ as it's ambiguous as to what "early"
is in relation to.
2023-02-28 14:02:42 +00:00
Pádraig Brady
b1376bb829 tests: tee -p: add test for early exit with closed pipes
* tests/misc/tee.sh: Add a test for the new iopoll logic
to detect closed outputs and exit early without needing
further input.
2023-02-28 14:02:42 +00:00
Carl Edquist
6b12e62d95 tee: enhance -p mode using iopoll() to detect broken pipe outputs
If input is intermittent (a tty, pipe, or socket), and all remaining
outputs are pipes (eg, >(cmd) process substitutions), exit early when
they have all become broken pipes (and thus future writes will fail),
without waiting for more input to become available, as future write
attempts to these outputs will fail (SIGPIPE/EPIPE).

Only provide this enhancement when pipe errors are ignored (-p mode).

Note that only one output needs to be monitored at a time with iopoll(),
as we only want to exit early if _all_ outputs have been removed.

* src/tee.c (pipe_check): New global for iopoll mode.
(main): enable pipe_check for -p, as long as output_error ignores EPIPE,
and input is suitable for iopoll().
(get_next_out): Helper function for finding next valid output.
(fail_output, tee_files): Break out write failure/output removal logic
to helper function.
(tee_files): Add out_pollable array to track which outputs are suitable
for iopoll() (ie, that are pipes); track first output index that is
still valid; add iopoll() broken pipe detection before calling read(),
removing an output that becomes a broken pipe.
* src/local.mk (src_tee_SOURCES): include src/iopoll.c.
* NEWS: Mention tee -p enhancement in Improvements.
* doc/coreutils.texi: Mention the new early exit behavior in the nopipe
modes for the tee -p option.

Suggested-by: Arsen Arsenović <arsen@aarsen.me>
2023-02-28 14:02:42 +00:00
Carl Edquist
b5c421a784 all: add broken pipe detection while waiting for input
When a program's output becomes a broken pipe, future attempts to write
to that ouput will fail (SIGPIPE/EPIPE).  Once it is known that all
future write attepts will fail (due to broken pipes), in many cases it
becomes pointless to wait for further input for slow devices like ttys.
Ideally, a program could use this information to exit early once it is
known that future writes will fail.

Introduce iopoll() to wait on a pair of fds (input & output) for input
to become ready or output to become a broken pipe.

This is relevant when input is intermittent (a tty, pipe, or socket);
but if input is always ready (a regular file or block device), then
a read() will not block, and write failures for a broken pipe will
happen normally.

Introduce iopoll_input_ok() to check whether an input fd is relevant
for iopoll().

Experimentally, broken pipes are only detectable immediately for pipes,
but not sockets.  Errors for other file types will be detected in the
usual way, on write failure.

Introduce iopoll_output_ok() to check whether an output fd is suitable
for iopoll() -- namely, whether it is a pipe.

iopoll() is best implemented with a native poll(2) where possible, but
fall back to a select(2)-based implementation platforms where there are
portability issues.  See also discussion in tail.c.

In general, adding a call to iopoll() before a read() in filter programs
also allows broken pipes to "propagate" backwards in a shell pipeline.

* src/iopoll.c, src/iopoll.h (iopoll): New function implementing broken
pipe detection on output while waiting for input.
(IOPOLL_BROKEN_OUTPUT, IOPOLL_ERROR): Return codes for iopoll().
(IOPOLL_USES_POLL): Macro for poll() vs select() implementation.
(iopoll_input_ok): New function to check whether an input fd is relevant
for iopoll().
(iopoll_output_ok): New function to check whether an input fd is
suitable for iopoll().
* src/local.mk (noinst_HEADERS): add src/iopoll.h.
2023-02-28 14:02:38 +00:00
Pádraig Brady
0175e337a8 build: update to latest gnulib
* NEWS: Mention the fts fix to avoid the following assert
in rm on mem pressure:
  Program terminated with signal SIGSEGV, Segmentation fault.
    at ../lib/cycle-check.c:60
    assure (state->magic == CC_MAGIC);
* gnulib: Update to the latest to pick up fts commit f17d3977.
2023-02-27 12:17:06 +00:00
Pádraig Brady
995021cb0c tests: avoid hang in new test
* tests/rm/empty-inacc.sh: Ensure we're not reading from stdin
when we're relying on no prompt to proceed.  Also change the
file being tested so that a failure in one test doesn't impact
following tests causing a framework failure.
2023-02-26 18:31:35 +00:00
Pádraig Brady
3ead67dd16 tests: avoid gdb on macOS
gdb was seen to hang intermittently on macOS 12.
Also gdb requires signing on newer macOS systems:
https://sourceware.org/gdb/wiki/PermissionsDarwin
So restrict its use on macOS systems for now.

* tests/rm/r-root.sh: Skip on darwin systems.
* tests/tail-2/inotify-race.sh: Restrict the test to
inotify capable systems to avoid the hang with some gdbs.
* tests/tail-2/inotify-race.sh: Likewise.
2023-02-26 18:31:28 +00:00
Pádraig Brady
65bb276564 cp,install,mv: --debug: output debug info when reflinking
* src/copy.c (copy_reg): Always check whether to output debug info.
(emit_debug): Restrict output with `cp --attributes-only`.
2023-02-24 15:17:36 +00:00
Pádraig Brady
5c8c2a5161 tests: determine if SEEK_HOLE is enabled
Upcomming gnulib changes may disable SEEK_HOLE
even if the system supports it, so dynamically
check if we've SEEK_HOLE enabled.

* init.cfg (seek_data_capable_): SEEK_DATA may be disabled in the build
if the system support is deemed insufficient, so also use `cp --debug`
to determine if it's enabled.
* tests/cp/sparse-2.sh: Adjust to a more general diagnostic.
* tests/cp/sparse-extents-2.sh: Likewise.
* tests/cp/sparse-extents.sh: Likewise.
* tests/cp/sparse-perf.sh: Likewise.
2023-02-24 00:35:18 +00:00
Pádraig Brady
d899f9e332 cp,install,mv: add --debug to explain how a file is copied
How a file is copied is dependent on the sparseness of the file,
what file system it is on, what file system the destination is on,
the attributes of the file, and whether they're being copied or not.
Also the --reflink and --sparse options directly impact the operation.

Given it's hard to reason about the combination of all of the above,
the --debug option is useful for users to directly identify if
copy offloading, reflinking, or sparse detection are being used.

It will also be useful for tests to directly query if
these operations are supported.

The new output looks as follows:

  $ src/cp --debug src/cp file.sparse
  'src/cp' -> 'file.sparse'
  copy offload: yes, reflink: unsupported, sparse detection: no

  $ truncate -s+1M file.sparse

  $ src/cp --debug file.sparse file.sparse.cp
  'file.sparse' -> 'file.sparse.cp'
  copy offload: yes, reflink: unsupported, sparse detection: SEEK_HOLE

  $ src/cp --reflink=never --debug file.sparse file.sparse.cp
  'file.sparse' -> 'file.sparse.cp'
  copy offload: avoided, reflink: no, sparse detection: SEEK_HOLE

* doc/coreutils.texi (cp invocation): Describe the --debug option.
(mv invocation): Likewise.
(install invocation): Likewise.
* src/copy.h: Add a new DEBUG member to cp_options, to control
whether to output debug info or not.
* src/copy.c (copy_debug): A new global structure to
unconditionally store debug into from the last copy_reg operations.
(copy_debug_string, emit_debug): New functions to print debug info.
* src/cp.c: if ("--debug") x->debug=true;
* src/install.c: Likewise.
* src/mv.c: Likewise.
* tests/cp/debug.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.
2023-02-24 00:35:18 +00:00
Paul Eggert
8a7fc0096c build: update gnulib submodule to latest 2023-02-23 13:27:00 -08:00
Pádraig Brady
c97c40c3b4 doc: chgrp,chmod,chown: state --reference always dereferences
* src/chgrp.c (usage): State that --reference always
dereferences symbolic links.
* src/chmod.c (usage): Likewise.
* src/chown.c (usage): Likewise.
Fixes https://bugs.gnu.org/61720
2023-02-23 15:22:14 +00:00
ChuanGang Jiang
3edbf016be doc: fix some spelling mistakes
* doc/coreutils.texi: s/functionalty/functionality/,
   s/sychronize/synchronize/, s/millsecond/millisecond/
   s/paramter/parameters/
* init.cfg: s/parmeters/parameters/
* scripts/build-older-versions/README.older-versions: s/vesion/version/
* tests/misc/env-S-script.sh: s/paramaters/parameters/
Fixes https://bugs.gnu.org/61681
2023-02-21 16:22:20 +00:00
Pádraig Brady
afae7787f2 maint: avoid -Wmaybe-uninitialized warning from GCC13
* src/copy.c (infer_scantype): Always set scan_inference.ext_start,
as per commit 6c03e8fb which was inadvertently reverted by d374d32c.
2023-02-21 16:17:53 +00:00
Jim Meyering
c62488a801 tests: initialize a variable
* tests/rm/interactive-once.sh (write_prot_msg1): Initialize it,
so an envvar setting cannot perturb the test.
2023-02-21 07:18:17 -08:00
Jim Meyering
a0803c4bad rm: --dir (-d): fix bugs in handling of empty, inaccessible directories
* src/remove.c (prompt, rm_fts): In the dir-handling code of both of
these functions, relax a "get_dir_status (...) == DS_EMPTY" condition
to instead test only "get_dir_status (...) != 0", enabling flow control
to reach the prompt function also for unreadable directories. However,
that function itself also needed special handling for this case:
(prompt): Handle empty, inaccessible directories properly,
deleting them with -d (--dir), and prompting about whether to delete
with -i (--interactive).
* tests/rm/empty-inacc.sh: Add tests for the new code.
Reported by наб <nabijaczleweli@nabijaczleweli.xyz> in
bugs.debian.org/1015273
* NEWS (Bug fixes): Mention this.
2023-02-21 07:18:17 -08:00
Paul Eggert
95f4ee0577 tests: port chmod/setgid.sh to macOS 12
* tests/chmod/setgid.sh: Try all the groups you’re a member of,
in case id -g returns 4294967295 (nogroup) which is special
and does not let you chgrp a file to it.
2023-02-18 13:30:10 -08:00
Paul Eggert
f48b80ff26 tests: port better to macOS group numbers
* init.cfg (groups): Port better to macOS 12, where
group 4294967295 (nogroup) is special: you can be a member
without being able to chgrp files to the group.
2023-02-18 13:30:09 -08:00
Paul Eggert
cccfae54dc build: update gnulib submodule to latest 2023-02-18 13:30:09 -08:00
Paul Eggert
4b05739168 cp: fclonefileat security fix + CLONE_ACL + fixups
* src/copy.c: Some changes if HAVE_FCLONEFILEAT && !USE_XATTR.
(fd_has_acl): New function.
(CLONE_ACL): Default to 0.
(copy_reg): Use CLONE_NOFOLLOW to avoid races like CVE-2021-30995
<https://www.trendmicro.com/en_us/research/22/a/
analyzing-an-old-bug-and-discovering-cve-2021-30995-.html>.
Use CLONE_ACL if available and working, falling back to cloning
without it if it fails due to EINVAL.
If the only problem with fclonefileat is that it would create the
file with the wrong timestamp, or with too few permissions,
do that but fix the timestamp and permissions afterwards,
rather than falling back on a traditional copy.
2023-02-16 15:40:06 -08:00
ChuanGang Jiang
cf80f988ee maint: fix some typos in comments
* NEWS: s/commmand/command/
* cfg.mk: Adjust old_NEWS_hash with `make update-NEWS-hash`.
* src/expand-common.c: s/specifed/specified/
* src/pr.c: s/e.g/e.g./
* tests/misc/comm.pl: s/ouput/output/
Fixes https://bugs.gnu.org/61405
2023-02-10 18:06:54 +00:00
Paul Eggert
d374d32ccf cp: simplify infer_scantype
* src/copy.c (infer_scantype): Do not set *SCAN_INFERENCE
when returning a value other than LSEEK_SCANTYPE.
This is just minor refactoring; it simplifies the code a bit.
Callers are uneffected.

doc: document --preserve=mode better
2023-02-09 19:54:20 -08:00
Pádraig Brady
d195e3863c tail: improve --follow=name with single non regular files
* src/tail (tail_forever): Attempt to read() from non blocking
single non regular file, which shouldn't block, but also
read data even when the mtime doesn't change.
* NEWS: Mention the improvement.
* THANKS.in: Thanks for detailed testing.
2023-02-06 16:28:53 +00:00
Pádraig Brady
c0c63e9735 tail: fix support for -F with non seekable files
This was seen to be an issue when following a
symlink that was being updated to point to
different underlying devices.

* src/tail.c (recheck): Guard the lseek() call to only
be performed for regular files.
* NEWS: Mention the bug fix.
2023-02-06 16:18:12 +00:00
Pádraig Brady
ead07bb3d4 cksum: add --raw option to output a binary digest
--raw output is the most composable format, and also is a
robust way to discard the file name without parsing (escaped) output.

Examples:

  $ cksum --raw -a crc "$afile" | basenc --base16
  4ACFC4F0

  $ cksum --raw -a crc "$afile" | basenc --base2msbf
  01001010110011111100010011110000

  $ cksum --raw -a sha256 "$bfile" | basenc --base32
  AAAAAAAADHLGRHAILLQWLAY6SNH7OY5OI2RKNQLSWPY3MCUM4JXQ====

* doc/coreutils.texi (cksum invocation): Describe the new feature.
* src/digest.c (output_file): Inspect the new RAW_DIGEST global,
and output the bytes directly if set.
* src/cksum.c (output_crc): Likewise.
* src/sum.c (output_bsd, output_sysv): Likewise.
* tests/misc/cksum-raw.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.
2023-02-06 13:09:40 +00:00
Pádraig Brady
2984e47c78 build: uptime: avoid issues on systems without utmp.h
* src/uptime.c (print_uptime): Following gnulib commit 9041103
HAVE_UTMP_H will always be defined.  Therefore key on whether
the utmp.ut_type member is present.
* boottime.m4 (GNULIB_BOOT_TIME): Assume utmp.h is present.
2023-02-05 14:15:03 +00:00
Paul Eggert
5699313c76 maint: use alignasof, not stdalign
* .gitignore: Update accordingly.
* bootstrap.conf (gnulib_modules): Replace obsolescent stdalign
with alignasof.
* gl/modules/randread (Depends-on): Depend on alignasof, not stdalign.
2023-02-04 14:42:58 -08:00
Paul Eggert
407d8af116 maint: prefer https: to git:
The idea is to defend against some adversary-in-the-middle attacks.
2023-02-04 14:13:27 -08:00
Paul Eggert
d42e4e9191 build: update gnulib submodule to latest 2023-02-04 10:45:18 -08:00
Pádraig Brady
b5904c985c maint: avoid line length syntax check failure
* src/cp.c: Adjust source line to be <= 80 chars.
2023-02-03 16:42:01 +00:00
Pádraig Brady
ce5225bcef tests: fix exit status check in cp -u test
* tests/cp/preserve-link.sh: This should have been part
of commit v9.1-134-g01503ce73.
2023-02-03 16:38:55 +00:00
Jim Meyering
b319685c6e cksum: accept new option: --base64 (-b)
* src/digest.c [HASH_ALGO_CKSUM]: Include "base64.h"
[HASH_ALGO_CKSUM] (base64_digest): New global.
[HASH_ALGO_CKSUM] (enum BASE64_DIGEST_OPTION): New enum.
[HASH_ALGO_CKSUM] (long_options): Add "base64".
(valid_digits): Rename from hex_digits, now taking an input length argument.
Adjust callers.
(bsd_split_3): Rename arg from hex_digits to digest.
Add new *d_len parameter for length of extracted digest.
Move "i" declaration down to first use.
(split_3): Rename arg from hex_digits to digest.
Add new *d_len parameter for length of extracted digest.
Instead of relying on "known" length of digest to find the following
must-be-whitespace byte, search for the first whitespace byte.
[HASH_ALGO_CKSUM] (output_file): Handle base64_digest.
[HASH_ALGO_CKSUM] (main): Set base64_digest.
[HASH_ALGO_CKSUM] (b64_equal): New function.
(hex_equal): New function, factored out of digest_check.
(digest_check) Factored part into b64_equal and hex_equal.
Rename local hex_digest to digest.
* tests/misc/cksum-base64.pl: Add tests.
* tests/local.mk (all_tests): Add to the list.
* cfg.mk (_cksum): Define.
(exclude_file_name_regexp--sc_prohibit_test_backticks): Exempt new test.
(exclude_file_name_regexp--sc_long_lines): Likewise.
* doc/coreutils.texi (cksum invocation): Document it.
(md5sum invocation) [--check]: Mention digest encoding auto-detect.
* NEWS (New Features): Mention this.
2023-01-31 18:24:28 -08:00
Paul Eggert
7a8db7dbaf doc: document --preserve=mode better
* doc/coreutils.texi: Spruce up cp --preserve=mode doc.
2023-01-31 13:53:58 -08:00
Paul Eggert
6baadf8ba3 cp: improve --preserve usage doc
* src/cp.c (usage): Improve description of --preserve.
2023-01-31 13:53:58 -08:00
Paul Eggert
01503ce731 cp,mv: skipping due to -u is success, not failure
This reverts the previous change, so that when a file
is skipped due to -u, this is not considered a failure.
* doc/coreutils.texi: Document this.
* src/copy.c (copy_internal): If --update says to skip,
treat this as success instead of failure.
* tests/mv/update.sh, tests/cp/slink-2-slink.sh:
Revert previous change, to match reverted behavior.
2023-01-31 09:25:25 -08:00
Paul Eggert
7a69df8899 cp,ln,mv: when skipping exit with nonzero status
* NEWS, doc/coreutils.texi: Document this.
* src/copy.c (copy_internal):
* src/ln.c (do_link): Return false when skipping action due to
--interactive or --no-clobber.
* tests/cp/cp-i.sh, tests/cp/preserve-link.sh:
* tests/cp/slink-2-slink.sh, tests/mv/i-1.pl, tests/mv/i-5.sh:
* tests/mv/mv-n.sh, tests/mv/update.sh:
Adjust expectations of exit status to match revised behavior.
2023-01-31 08:54:37 -08:00
Pádraig Brady
666a7fc1d5 tests: cksum: fix test to include more cases
* tests/misc/cksum-c.sh: Fix typo which caused part
of the test data to be ignored.
2023-01-30 19:29:38 +00:00
Jim Meyering
5c830d40e0 digest.c: remove a duplicate variable
* src/digest.c (digest_check): Locals n_misformatted_lines and
n_improperly_formatted_lines were declared and set/incremented
identically. Remove declaration of the latter. Use the other instead.
2023-01-30 09:26:09 -08:00
Jim Meyering
d73ca62c4f build: avoid spurious failures due to lack of EGREP definition
* configure.ac: Use AC_PROG_EGREP, since many doc and test rules
use $EGREP.
* cfg.mk (sc_tests_list_consistency): Use grep -E, not $(EGREP) here.
2023-01-30 09:18:13 -08:00
Pádraig Brady
95bc69a7e7 tests: ensure we fail if mv --no-copy crashes
* tests/mv/no-copy.sh: Honor `make syntax` check
and use the `returns_ 1 ...` pattern.
2023-01-27 19:46:52 +00:00
Paul Eggert
20005ca733 mv: new option --no-copy
Wishlist item from Mike Frysinger (Bug#61050).
* src/copy.c (copy_internal):
Do not fall back on copying if x->no_copy.
* src/copy.h (struct cp_options): New member no_copy.
* src/mv.c (NO_COPY_OPTION): New constant.
(long_options, usage, main): Support --no-copy.
* tests/mv/no-copy.sh: New test.
* tests/local.mk (all_tests): Add it.
2023-01-27 11:03:38 -08:00
Pádraig Brady
d5868df0d0 maint: add lib/error.h to .gitignore
* .gitignore: Add /lib/error.h as suggested by sc_gitignore_missing
as a result of gnulib change 2886cca8.
2023-01-17 22:38:40 +00:00
Pádraig Brady
7479ef7c11 doc: csplit: more accurate --elide-empty-files help
* src/csplit.c (usage): Use "suppress" rather than "remove"
when describing -z so it's more apparent that the effect
is a particular numbered file is not created, rather than
being removed later.  I.e., don't suggest -z may induce
gaps in file numbering.
Reported at https://bugs.debian.org/1029103
2023-01-17 21:44:48 +00:00
Paul Eggert
28a85116fe build: update gnulib submodule to latest
* m4/xattr.m4: Remove.  This file is now autogenerated by 'bootstrap',
since it's now in Gnulib.  (I did this part by hand.)
2023-01-13 17:51:01 -08:00
Pádraig Brady
7fc84d1c0f copy: copy_file_range: handle ENOENT for CIFS
* src/copy.c (sparse_copy): Fallback to standard copy upon ENOENT,
which was seen intermittently across CIFS file systems.
* NEWS: Mention the bug fix, though qualify it as an "issue"
rather than a bug, as coreutils is likely only highlighting
a CIFS bug in this case.
Fixes https://bugs.gnu.org/60455
2023-01-08 13:34:52 +00:00
Paul Eggert
e64113d601 maint: update .gitignore
* .gitignore: Add confdefs*, conftest* (temporaries built
by ‘configure’).
2023-01-07 15:50:51 -08:00
Paul Eggert
d62ca23f08 maint: adjust to Gnulib macro renaming
* src/local.mk (LDADD, copy_ldadd, remove_ldadd, src_sort_LDADD)
(src_test_LDADD, copy_ldadd, src_date_LDADD, src_ginstall_LDADD)
(src_ln_LDADD, src_ls_LDADD, src_mktemp_LDADD, src_pr_LDADD)
(src_tac_LDADD, src_touch_LDADD, src_dd_LDADD, src_sleep_LDADD)
(src_sort_LDADD, src_tail_LDADD, src_sort_LDADD, LDADD):
Adjust to recent Gnulib changes.
2023-01-07 15:50:51 -08:00
Paul Eggert
ca08a87489 build: update gnulib submodule to latest 2023-01-07 15:50:51 -08:00
Pádraig Brady
f6c93f334e copy: immediately fail with transient reflink errors
* src/copy.c (handle_clone_fail): A new function refactored
from copy_reg() to handle failures from FICLONE or fclonefileat().
Fail with all errors from FICLONE, unless they're from the set
indicating the file system or file do not support the clone operation.
Also fail with errors from fclonefileat() (dest_dest < 0)
if they're from the set indicating a transient failure for the file.
(copy_ref): Call handle_clone_fail() after fclonefileat() and FICLONE.
(sparse_copy): Call the refactored is_CLONENOTSUP()
which is now also used by the new handle_clone_fail() function.
* NEWS: Mention the bug fix.  Also mention explicitly
the older --reflink=auto default change to aid searching.
* cfg.mk: Adjust old_NEWS_hash with `make update-NEWS-hash`.
Fixes https://bugs.gnu.org/60489
2023-01-06 14:32:44 +00:00
Pádraig Brady
f4567ed953 all: further adjustments for new Ronna, Quetta SI prefixes
* src/dd.c (parse_integer): Support Q,R suffixes.
* src/od.c (main): Likewise.
* src/split.c (main): Likewise.
* src/stdbuf.c (parse_size): Likewise.
* src/truncate.c (main): Likewise.
* src/sort.c (specify_size_size): Likewise.
Also line length syntax check fix.
* tests/misc/numfmt.pl: Adust top end large number checks
to the new largest values.
* doc/coreutils.texi (numfmt invocation): Add a numfmt example.
* NEWS: Tweak to aid searchability.
2023-01-06 14:26:40 +00:00
Paul Eggert
e1ff4ee0f6 numfmt: add support for new SI prefixes
* src/dd, src/head.c, src/od.c, src/sort.c, src/stdbuf.c, src/tail.c:
(usage):
* src/system.h (emit_size_note):
Mention new SI prefixes.
* src/du.c (main):
* src/head.c (head_file):
* src/numfmt.c (suffix_power, suffix_power_char, prepare_padded_number):
* src/shred.c (main):
* src/sort.c (unit_order):
* src/tail.c (parse_options):
Support new SI prefixes.
* src/numfmt.c (MAX_ACCEPTABLE_DIGITS): Increase to 33.
(zero_and_valid_suffixes, valid_suffixes): New constants,
with new SI prefixes.
(valid_suffix, unit_to_umax): Use them.
(prepare_padded_number): Diagnose "999Q" instead of "999Y".
* tests/misc/numfmt.pl, tests/misc/sort.pl:
Adjust tests to match new max.
2023-01-05 12:47:41 -08:00
Paul Eggert
26bac32137 ls: adjust to Gnulib renaming
* src/local.mk (src_ls_LDADD): In Gnulib,
LIB_HAS_ACL was renamed to FILE_HAS_ACL_LIB.
2023-01-05 12:47:41 -08:00
Paul Eggert
b7c8754c90 build: update gnulib submodule to latest 2023-01-05 12:47:41 -08:00
Bernhard Voelker
8d4768c94d maint: avoid grep warning in sc_prohibit_test_minus_ao
Newer grep(1) complains:
  $ make sc_prohibit_test_minus_ao
  /usr/bin/grep: warning: * at start of expression
  prohibit_test_minus_ao

* cfg.mk (exclude_file_name_regexp--sc_prohibit_test_minus_ao): Fix
expression inroduced in v8.24-120-g3205bb178, and narrow down the file
pattern to the 'doc/' directory.
2023-01-03 09:16:09 +01:00
Pádraig Brady
31cf78f1d5 doc: copy: mention the reinstated I/O size constraints
* NEWS: Mention the change in behavior re block size multiples
to support unusual devices with this constraint.
* src/copy.c (copy_reg): Likewise.
2023-01-02 23:30:09 +00:00
Paul Eggert
6c343a5574 copy: fix possible over allocation for regular files
* bootstrap.conf (gnulib_modules): Add count-leading-zeros,
which was already an indirect dependency, since ioblksize.h
now uses it directly.
* src/ioblksize.h: Include count-leading-zeros.h.
(io_blksize): Treat impossible blocksizes as IO_BUFSIZE.
When growing a blocksize to IO_BUFSIZE, keep it a multiple of the
stated blocksize.  Work around the ZFS performance bug.
* NEWS: Mention the bug fix.
Problem reported by Korn Andras at https://bugs.gnu.org/59382
2023-01-02 23:30:07 +00:00
Pádraig Brady
01755d36e7 maint: update all copyright year number ranges
Update to latest gnulib with new copyright year.
Run "make update-copyright" and then...

* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Manually update copyright year,
until we fully sync with gnulib at a later stage.
* tests/sample-test: Adjust to use the single most recent year.
2023-01-01 14:50:15 +00:00
Pádraig Brady
0239f2a782 build: update gnulib submodule to latest
mainly to get updated copyright year

* tests/init.sh: Sync with gnulib
2023-01-01 14:47:08 +00:00
Pádraig Brady
c9a21ec317 stty: fix off by one column wrapping on output
* src/stty.c (wrapf): Adjust the comparison by 1,
to account for the space we're adding.
* tests/misc/stty.sh: Add a test case.
* NEWS: Mention the fix.
Reported in https://bugs.debian.org/1027442
2022-12-31 19:01:59 +00:00
Pádraig Brady
879d2180d6 copy: attempt copy offload with sparse files by default
This was seen to vastly improve performance
on NFS 4.2 systems by allowing server side copies,
with partially sparse files (avidemux generated mp4 files).

* src/copy.c (lseek_copy): Also set hole_size to 0,
i.e. enable copy_file_range(), with --sparse=auto (the default),
to enable copy offload in this case, as we've strong signal
from SEEK_DATA that we're operating on actual data and not holes here.
* NEWS: Mention the improvement.
Fixes https://bugs.gnu.org/60416
2022-12-31 00:20:45 +00:00
Pádraig Brady
266b7cbc84 wc: fix regression determining file size
* src/wc.c (wc): Use off_t rather than size_t
when calculating where to seek to, so that
we don't seek to a too low offset on systems
where size_t < off_t, which would result in
many read() calls to determine the file size.
* tests/misc/wc-proc.sh: Add a test case
sufficient for 32 bit systems at least.
* NEWS: Mention the bug fix.
Reported at https://bugs.debian.org/1027101
2022-12-29 14:15:54 +00:00
Pádraig Brady
4bf990bf65 maint: avoid recent syntax check failure
* tests/cp/proc-short-read.sh: Adjust so shorter lines.
2022-12-29 14:15:54 +00:00
Paul Eggert
cfe4af661f doc: improve doc of du with CoW etc
Problem reported by Krzysztof Żelechowski (Bug#60335).
* doc/coreutils.texi (du invocation): Reword.
2022-12-26 10:35:24 -08:00
Paul Eggert
7279459f9f doc: improve du --threshold wording
* doc/coreutils.texi (du invocation): Reword.
2022-12-26 10:35:24 -08:00
Paul Eggert
16fc0f30fe tests: accommodate bogomips capitalizations
* tests/cp/proc-short-read.sh: Kernel on ARMv7 Processor rev 3 (v7l)
spells it "BogoMIPS", so allow any capitalization.  Patch from
Zach van Rijn in <https://bugs.gnu.org/60339>.
2022-12-26 09:01:37 -08:00
Paul Eggert
9581c4b59d build: update gnulib submodule to latest 2022-12-06 11:08:02 -08:00
Paul Eggert
8c4d57ba27 doc: timezone -> time zone 2022-12-06 10:40:53 -08:00
Paul Eggert
5399f2aac4 doc: improve date -I doc
Suggested by Marc Chantreux (bug#59827).
* doc/coreutils.texi (Options for date):
Give formats for -I, like we already do for --rfc-3339.
2022-12-05 18:42:34 -08:00
Dennis Williamson
02441761c9 build: fix missing inclusion of poll.h on macOS
* src/tail.c: Following on from commit v9.1-55-g324c188cf
also include poll.h for __APPLE__, which was seen to be required
on macOS 11.6
2022-12-05 14:32:36 +00:00
Pádraig Brady
aaa306ad76 doc: tee: make -p decription more complete
* doc/coreutils.texi (tee invocation): Give a more
cohesive description of the -p option, and how
it differs from the default operation.
2022-11-29 14:52:52 +00:00
Arsen Arsenović
8613d35be6 scripts: commit-msg: recognize Git cut_lines
This prevents spurious failures from happening when someone sets
commit.verbose or passes -v to commit.
2022-11-20 18:17:47 +00:00
Paul Eggert
7bb940cced doc: more dash fixes
* doc/coreutils.texi, doc/sort-version.texi: Prefer on "x -- y" to
"x---y" in prose, as the result is more readable in Emacs.
Fix some instances of unescaped ‘-’ that should be minus, not
hyphen. Fix some other instances that should be en dash.  No
spaces around en dash when it’s a range.
2022-11-15 10:57:31 -08:00
Paul Eggert
4f43143ab1 maint: fix cfg.mk comment
* cfg.mk (sc_texi_long_option_escaped): Fix comment.
2022-11-15 10:57:31 -08:00
Pádraig Brady
5450c7f8d3 tests: make SIGPIPE trap checking more robust
* init.cfg (trap_sigpipe_or_skip_): A subshell with ignored SIGPIPE
was seen to not terminate, on Solaris 11 at least.
So protect with a timeout(1).
2022-11-15 14:02:16 +00:00
Pádraig Brady
e3bb975448 maint: avoid new grep -q syntax-check failures
* cfg.mk: Exclude NEWS from the check.
* init.cfg: s/grep -q/grep >/dev/null/.
* tests/ls/hyperlink.sh: Likewise.
* tests/ls/symlink-quote.sh: Likewise.
2022-11-15 14:02:10 +00:00
Pádraig Brady
e902f9b88d maint: avoid misquoting of some --long-options in texi
* cfg.mk (sc_texi_long_option_escaped): A new check to
avoid future instances of this.
* doc/coreutils.texi (Common options): Rearrange this menu
to be less repetitive in each description, and avoid long lines.
Addresses https://bugs.gnu.org/59262
2022-11-15 13:30:24 +00:00
Paul Eggert
2fce39eb3a doc: fix markup
Problem reported by Antonio Diaz Diaz (bug#59262).
* doc/coreutils.texi: Use markup in menus to prevent
‘--’ from turning into an em dash, and to be more
consistent.
2022-11-14 19:08:53 -08:00
Paul Eggert
b73888b12c build: update gnulib submodule to latest 2022-11-14 19:08:53 -08:00
Pádraig Brady
994c83e2e3 doc: printf: make "java" encoding example more standard
Note using iconv(1) rather than recode(1) is not appropriate
for this example, as the required functionality is only
available on libiconv's iconv implementation, which is
not installed on most systems.

* doc/coreutils.texi (printf invocation): Use env rather than
/usr/local/bin for the printf command.  Escape '%' so more robust.
Also use a locale that exists on modern systems.
2022-10-28 14:51:56 +01:00
Pádraig Brady
90817ff295 doc: move description of printf options to better location
* doc/coreutils.texi (printf invocation): Move the description
of accepted options from the middle of the unicode discussion.
2022-10-28 13:45:35 +01:00
Pádraig Brady
0925e8a0f4 printf: with \U, support all valid unicode points
Previously this was restricted to the C99 universal character subset,
which restricted most values <= 0x9F, as that simplifies the C lexer.
However printf(1) doesn't need this restriction.
Note also the bash builtin printf already supports all values <= 0x9F.

* src/printf.c (main): Relax the restriction on points <= 0x9F.
* doc/coreutils.texi (printf invocation): Adjust description.
* tests/misc/printf-cov.pl: Adjust accordingly.  Add new cases.
* NEWS: Mention the change in behavior.
Reported at https://bugs.debian.org/1022857
2022-10-28 13:45:27 +01:00
Pádraig Brady
468c4fb10d doc: basenc: reference from base{32,64} docs
* doc/coreutils.texi (base32 invocation): Reference basenc
to improve discoverability.
(base64 invocation): Likewise.
* man/base32.x: Likewise.
* man/base64.x: Likewise.
2022-10-26 12:50:11 +01:00
Pádraig Brady
4fd708810c doc: sort: mention --version useful for IPv4 addresses
* doc/coreutils.texi (sort invocation): Mention in the
multi invocation sort example that the -V GNU extension
could be used to sort IPv4 addresses, and thus simplify
to a single invocation.
2022-09-30 15:44:30 +01:00
Pádraig Brady
339fb6bb84 maint: NEWS: use consistent quoting
* NEWS: Change unmatched curly quote to more consistent single quote.
2022-09-28 19:01:04 +01:00
Pádraig Brady
8aa3b82ea1 doc: be more consistent when documenting exit status
* src/system.h (emit_exec_status): A new function to
output standard "Exit status:" info for commands that exec others.
* doc/coreutils.texi (Exit status): Add "ls" and "runcon"
to the list of commands with non standard exit status.
* src/numfmt.c (main): Call initialize_exit_failure() explicitly
to better indicate this utility may exit with something other than
EXIT_FAILURE.
* src/timeout.c (usage): Use more consistent capitalization.
* src/chroot.c: Call emit_exec_status().
* src/env.c: Likewise.
* src/nice.c: Likewise.
* src/nohup.c: Likewise.
* src/runcon.c: Likewise.
* src/stdbuf.c: Likewise.
2022-09-28 15:06:11 +01:00
Pádraig Brady
4c1d30771d runcon: fix inconsistent exit status upon write error
* src/runcon.c (main): Call initialize_exit_failure(),
so we use an appropriate exit status upon failure to close stdout.
This should have been part of recent commit ea3ee6df.
* tests/misc/help-version.sh: Adjust test case accordingly.
2022-09-28 15:06:11 +01:00
Pádraig Brady
f69743604b maint: getlimits: diagnose invalid options
* src/getlimits.c: Don't call initialize_exit_failure()
as it's not needed for standard EXIT_FAILURE returns.
Also use the function variant that diagnoses invalid options.
2022-09-28 15:06:11 +01:00
Pádraig Brady
322f7abf8a maint: rmdir: also use DS_... constants here
* src/rmdir.c: As with commit 627c9a97,
use DS_NONEMPTY constant to improve readability.
2022-09-28 15:06:11 +01:00
Pádraig Brady
ce2b875cd7 wc: add --total={auto,never,always,only} option
without this option, control of when the total is output
is quite awkward. Consider trying to suppress the total line,
which could be achieved with something like:

   wc-no-total() { wc "$@" /dev/null | head -n-2; }

As well as being non obvious, it's also non general.
It would give a non failure, but zero count if passed a file on stdin.
Also it doesn't work in conjunction with the --files0-from option,
which would need to be handled differently with something like:

   { find files -print0; printf '%s\0' /dev/null; } |
   wc --files0-from=- |
   head -n2

Also getting just the total can be awkward as file names
are only suppressed when processing stdin, and
also a total line is only printed if processing more than one file.
For completness this might be achieved currently with:

  wc-only-total() {
    wc "$@" |
    tail -n1 |
    sed 's/^ *//; s/ [^ 0-9]*$//'
  }

* src/wc.c: Add new --total option.
* tests/misc/wc-total.sh: New test suite for the new option.
* tests/local.mk: Reference the new test.
* doc/coreutils.texi (wc invocation): Document the new option.
* THANKS.in: Add suggestor.
* NEWS: Mention the new feature.
2022-09-26 15:04:56 +01:00
Pádraig Brady
627c9a97c1 maint: use enums to make dir_status code easier to read
* src/system.h: Add DS_EMPTY, and DS_NONEMPTY enums.
* src/remove.c: Use the new enums to make code easier to understand.
2022-09-25 15:26:20 +01:00
Pádraig Brady
800ff60f6f doc: mention the recent rm improvement
* NEWS: Mention the improvement re handling of directory errnos.
2022-09-25 15:25:45 +01:00
Pádraig Brady
c86b6ec711 maint: fix recent syntax-check failures
* .gitignore: Add new headers from gnulib.
* src/basenc.c: Adjust line length due to replacement
of 'verify' with 'static_assert'.
* src/od.c: Likewise.
2022-09-25 15:12:13 +01:00
Paul Eggert
eb7841426c rm: fix diagnostics on I/O error
I ran into this problem when attempting to recursively
remove a directory in a filesystem on flaky hardware.
Although the underlying readdir syscall failed with errno == EIO,
rm issued no diagnostic about the I/O error.

Without this patch I see this behavior:

  $ rm -fr baddir
  rm: cannot remove 'baddir': Directory not empty
  $ rm -ir baddir
  rm: descend into directory 'baddir'? y
  rm: remove directory 'baddir'? y
  rm: cannot remove 'baddir': Directory not empty

With this patch I see the following behavior, which
lets the user know about the I/O error when rm tries
to read baddir's directory entries:

  $ rm -fr baddir
  rm: cannot remove 'baddir': Input/output error
  $ rm -ir baddir
  rm: cannot remove 'baddir': Input/output error

* src/remove.c (Ternary): Remove.  All uses removed.
(get_dir_status): New static function.
(prompt): Last arg is now directory status, not ternary.
Return RM_USER_ACCEPTED if user explicitly accepted.
All uses changed.
Report any significant error in directory status right away.
(prompt, rm_fts): Use get_dir_status to get directory status lazily.
(excise): Treat any FTS_DNR errno as being more descriptive, not
just EPERM and EACCESS.  For example, EIO is more descriptive.
(rm_fts): Distinguish more clearly between explicit and implied
user OK.
* src/remove.h (RM_USER_ACCEPTED): New constant.
(VALID_STATUS): Treat it as valid.
* src/system.h (is_empty_dir): Remove, replacing with ...
(directory_status): ... this more-general function.
All uses changed.  Avoid undefined behavior of looking at
a non-null readdir pointer after corresponding closedir.
* tests/rm/rm-readdir-fail.sh: Adjust test of internals
to match current behavior.
2022-09-24 16:34:31 -07:00
Paul Eggert
5a14ccad48 rm: fix readdir test
* tests/rm/rm-readdir-fail.sh [_DIRENT_HAVE_D_NAMELEN]:
Fix off-by-1 bug in directory entry length.
2022-09-24 16:34:30 -07:00
Paul Eggert
b2f8dfc129 doc: fix typo in previous change 2022-09-20 01:12:37 -07:00
Paul Eggert
4cbe227fa0 doc: warn about tabs command (bug#57946) 2022-09-20 00:10:37 -07:00
Stefan Kangas
875c636ce5 all: prefer HTTPS to HTTP
* README-hacking:
* README-prereq:
* THANKS.in:
* doc/sort-version.texi (Other version/natural sort implementations):
* gl/lib/rand-isaac.c:
* gl/tests/test-rand-isaac.c:
* src/operand2sig.c (operand2sig):
* src/remove.c (nonexistent_file_errno):
* tests/misc/env-signal-handler.sh:
* tests/misc/sort-debug-warn.sh (LC_ALL): Prefer HTTPS to HTTP.
Addresses https://bugs.gnu.org/56512
Copyright-paperwork-exempt: yes
2022-09-18 11:42:02 -07:00
Paul Eggert
9062704bf8 kill: port to picky-conversion hosts
* src/kill.c (send_signals): Don’t rely on conversion overflow
being silent.
2022-09-17 19:41:31 -07:00
Paul Eggert
728f3baa50 maint: fix bootstrap module lists for alignof
* bootstrap.conf (gnulib_modules): Remove alignof, which isn’t
needed since coreutils source modules don’t include alignof.h.
Add stdalign, since they depend on alignof working without
stdalign.h.
2022-09-15 01:16:31 -05:00
Paul Eggert
9a777a44b3 maint: prefer static_assert to verify
* bootstrap.conf: Add assert-h.
* gl/lib/randperm.c: Do not include verify.h.
* gl/lib/randperm.c, src/basenc.c, src/dd.c, src/digest.c:
* src/dircolors.c, src/expr.c, src/factor.c, src/ls.c, src/numfmt.c:
* src/od.c, src/seq.c, src/shred.c, src/sort.c, src/stat.c:
Prefer C23’s static_assert to nonstandard verify.
* gl/modules/randperm (Depends-on): Add assert-h.
2022-09-15 01:16:31 -05:00
Paul Eggert
7363a58286 maint: assume C23 alignof
* gl/lib/randread.c, src/stat.c (print_statfs):
No need to include stdalign.h, now that alignof is a keyword
in C23 and Gnulib arranges for this.
2022-09-15 00:44:01 -05:00
Paul Eggert
b29ef22135 maint: don’t include config.h twice
* gl/lib/fadvise.h, gl/lib/smack.h, src/blake2/blake2-impl.h:
Do not include config.h from a .h file.  config.h is supposed
to be included once, at the start of compilation and before
any other file.
2022-09-15 00:44:01 -05:00
Paul Eggert
3d97ccfa38 build: update gnulib submodule to latest 2022-09-15 00:44:01 -05:00
Álvar Ibeas
76193a5e75 doc: shred: minor fix
* doc/coreutils.texi: Fix wording.

Copyright-paperwork-exempt: yes
2022-09-13 17:25:10 -05:00
Paul Eggert
ede8203763 maint: adjust to Gnulib stdbool C23 change
* gl/lib/mbsalign.c, gl/lib/randread.c, gl/lib/targetdir.h:
* gl/lib/xdectoint.c, gl/lib/xfts.c, gl/lib/xfts.h:
* src/blake2/b2sum.c, src/copy.h, src/die.h, src/system.h:
Don’t include <stdbool.h>, since Gnulib now emulates C23.
2022-09-12 23:07:06 -05:00
Paul Eggert
9a53930aa1 build: update gnulib submodule to latest 2022-09-12 23:07:05 -05:00
Pádraig Brady
39f71795d2 stty: give explicit error for unsupported asymmetric speeds
* src/stty.c (check_speed): If difference input and output speeds
are specified, then validate the system supports that, before
interacting with the device.
2022-09-11 18:44:10 +01:00
Pádraig Brady
760998a789 stty: fix false warnings from [io]speed settings
* src/stty.c (eq_mode): A new function to compare
equivalence of two modes.
(main): Use eq_mode() rather than memcmp() to compare
two modes. Also use stack variables rather than implicitly
initialized static variables.  Also remove all uses of
the SPEED_WAS_SET hack since we now more robustly compare modes.
* NEWS: Update the [io]speed fix entry.
Reported at https://bugs.debian.org/1019468
2022-09-11 15:40:52 +01:00
Pádraig Brady
8fdf9307b6 maint: add lib/gmp.h to .gitignore
* .gitignore: Add generated file.  Tested with:
./configure --without-libgmp && make && git status
2022-09-02 22:06:05 +01:00
Pádraig Brady
d1f4632ff4 stty: add an undocumented ---debug option for more info
* src/stty.c (main): Move internal TESTING code that showed
the new and old mode, upon failure to apply the new mode,
to being runtime controlled with the ---debug option.
Also augment the display to show which items were not
set as expected.
2022-08-31 22:55:31 +01:00
Pádraig Brady
b81205bdc7 doc: stty: clarify that [-]drain is treated as an option
* doc/coreutils.texi (stty invocation): Say that "drain"
is treated as an option, rather than a line setting,
and so option processing rules apply to it.
Reported in https://bugs.debian.org/1018803
2022-08-31 19:09:15 +01:00
Pádraig Brady
f87a78f334 stty: validate ispeed and ospeed arguments
* src/stty.c (apply_settings): Validate [io]speed arguments
against the internal accepted set.
(set_speed): Check the cfset[io]speed() return value so
that we validate against the system supported set.
* tests/misc/stty-invalid.sh: Add a test case.
* NEWS: Mention the bug fix.
Reported in https://bugs.debian.org/1018790
2022-08-31 01:03:33 +01:00
Pádraig Brady
3a1c328cd5 maint: be defensive in avoiding gnulib's poll module
* src/tail.c (check_output_alive): Add a guard that would
trigger on most platforms, to detect if we're using the
gnulib poll module.  That's currently problematic in the
way it emulates poll() using select() and would cause
issues on macOS and AIX at least as poll() is replaced there.
2022-08-29 15:33:12 +01:00
Pádraig Brady
324c188cfd tail: use poll() on macOS
* src/tail.c (check_output_alive): poll() is the most commonly used
interface, so use this on macOS also to minimize divergence.
2022-08-29 15:32:54 +01:00
Pádraig Brady
b3bb2b707c tests: runcon: fix new test to skip on non SELinux systems
* tests/misc/runcon-compute.sh: Use our new internal error
125 status to detect SELinux errors, and skip in this case.
2022-08-27 22:15:44 +01:00
Pádraig Brady
af231b6c4f doc: NEWS: document recent comm fix, and runcon change
* NEWS: Mention comm bug fix, and runcon change in behavior.
2022-08-27 21:37:28 +01:00
Pádraig Brady
d2c5376f05 tests: fix tests after recent runcon change
Following commit v9.1-49-gea3ee6df2

* tests/misc/invalid-opt.pl: Map runcon failure status to 125.
* tests/misc/usage_vs_getopt.sh: Likewise.
2022-08-27 19:18:29 +01:00
Pádraig Brady
708ae170c9 comm: fix NUL --output-delimiter with --total
* src/comm.c (compare_files): Handle the single character
--output-delimeter case separately so that NUL is appropriately
handled.
* doc/coreutils.texi (comm invocation): Fix the description
of --output-delimiter to say an empty delimeter is treated
as a NUL separator, rather than being disallowed.
* tests/misc/comm.pl: Add a test case.
Reported at https://bugs.debian.org/1014008
2022-08-27 18:41:10 +01:00
Pádraig Brady
c88f08f9b6 maint: remove FIXME comment from timeout.c
* src/timeout.c: We shouldn't hardcode `sh -c` as users
can specify that if needed, so remove the comment.
2022-08-27 17:54:42 +01:00
Pádraig Brady
ea3ee6df27 runcon: distinguish runcon specific errors in exit status
* src/runcon.c: Use EXIT_CANCELED (125) instead of EXIT_FAILURE (1),
so that errors specific to runcon can be distinguished,
from those of the invoked program.
* doc/coreutils.texi (runcon invocation): Fix the Exit status
description to say we return 125 (not 127) for internal errors.
* tests/misc/runcon-no-reorder.sh: Add a test case.
2022-08-27 17:50:20 +01:00
Pádraig Brady
e3d6035938 doc: README: split out ancillary information
The README was becoming too long and contained
quite a bit of info only pertaining to rarely used systems, so...

* README: Split out install specific info to README-install.
Also remove a few stale lines, and reorder a few items.
* README-install: A new file split from README.
* Makefile.am [EXTRA_DIST]: Explicitly reference new README-install
file for distribution, since automake only auto adds README.
* TODO: Reference the HPUX info now in README-install.
2022-08-13 21:09:09 +01:00
Pádraig Brady
a88b666bea ls: support explicit --time=modification selection
* src/ls.c [time_args]: Add support for explicit
'mtime' or 'modification' arguments to --time.
* tests/misc/ls-time.sh: Add explicit --time=mtime usage.
* doc/coreutils.texi (ls invocation): Describe --time=mtime.
* NEWS: Mention the new feature.
2022-08-13 13:48:24 +01:00
Pádraig Brady
35fbc51d3f doc: ls: clarify description of timestamps
* src/ls.c (usage): Don't mention "modification" in the
description of ctime (-c), as it's confusing with mtime.
Mention "metadata" when discussing "change" time to
disambiguate from data change time.
* doc/coreutils.texi (ls invocation): State that --time=creation
falls back to using mtime where not available.
2022-08-12 14:21:12 +01:00
Pierre Marsais
c7920f2b1b doc: cp: fix --reflink=when typo in texinfo
This behaviour is correctly documented when doing `cp --help`.
There is no `--reflink=when` option.

* doc/coreutils.texi (cp invocation): Fix document stating
that `--reflink` is equivalent to `--reflink=always`.
2022-08-01 22:00:07 +01:00
Pádraig Brady
993f0d968d doc: uniq: clarify -f operation
* doc/coreutils.texi (uniq invocation): State that leading blanks
are part of the field, and also that -f is one based.
2022-08-01 21:55:12 +01:00
Pádraig Brady
ab976f4090 doc: reference fmt(1) from fold(1)
* man/fold.x: fold and fmt have overlapping functionality,
so reference fmt(1) from the lower level fold(1) utility.
2022-07-30 13:06:56 +01:00
Paul Eggert
afffa445b9 touch: fix aliasing bug
Problem reported by Tim Lange in:
https://lists.gnu.org/r/coreutils/2022-07/msg00008.html
* src/touch.c (date_relative): Rename from get_reldate,
and use a functional style to fix the aliasing bug.
2022-07-27 10:04:49 -07:00
Pádraig Brady
187712b97b doc: env: clarify that empty signal args are ignored
It's useful to treat empty and missing arguments differently.
Missing means all signals, while empty means no signals and
so is a no-op.  It's useful to treat empty arguments like
this, so that dynamically specified arguments like the following
are supported

  env --ignore-signals "$SIGS_TO_IGNORE"

Note `env --ignore-signals=` is treated as an empty argument.

* doc/coreutils.texi (env invocation): Empty args are treated
differently to missing arguments, so call that out explicitly.
* src/env.c (usage): Likewise.
Addresses https://bugs.debian.org/1016049
2022-07-26 14:16:55 +01:00
Pádraig Brady
56783caccf doc: date: clarify which options are mutually exclusive
* src/date.c (usage): Specify that --date, --file, --reference,
and --resolution are mutually exclusive.  This is also useful
documentation to group similar options.
* doc/coreutils.texi (Options for date): Likewise.
Addresses https://bugs.gnu.org/55401
2022-07-24 21:09:24 +01:00
Pádraig Brady
854e035121 date: --debug: diagnose discarded -d or -s options
* src/date.c: (main): Track and diagnose whether any
-d or -s options are dropped, as users may think
multiple options are supported, given they can be relative.
* tests/misc/date-debug.sh: Add a test case.
* NEWS: Mention the improvement.
2022-07-24 20:40:34 +01:00
Pádraig Brady
96c1499413 runcon: ensure --compute runs the file it inspects
* src/runcon.c (main): With -c avoid searching the path
to ensure the file specified to --compute is executed.
* tests/misc/runcon-compute.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Reported in https://bugs.debian.org/1013924
2022-07-24 18:55:41 +01:00
Pádraig Brady
b8aafe5145 doc: tr: clarify that -t is ignored unless translating
* src/tr.c (usage): Don't say that -t is disallowed unless translating.
Reported in https://bugs.debian.org/1012447
2022-07-24 18:22:50 +01:00
Paul Eggert
8ec11f3e72 rm: don’t assume st_size is nonnegative
* src/remove.c: Include stat-time.h.
(cache_fstatat, cache_stat_init): Use negative st->st_atim.tv_sec to
determine whether the stat is cached, not negative st->st_size.
On non-POSIX platforms that lack st_atim.tv_sec, don’t bother to cache.
2022-07-23 12:17:44 -07:00
Paul Eggert
116ac656e7 stat: -c %s now prints unsigned
* src/stat.c (unsigned_file_size): New static function,
copied from src/ls.c.
(print_stat): %s prints an unsigned value now (Bug#56710).
2022-07-22 13:51:13 -07:00
Paul Eggert
e6c7091634 dd: doc improvement (Bug#54586)
* doc/coreutils.texi (dd invocation): Explain
fdatasync and fsync better.
2022-07-06 23:42:55 -05:00
Paul Eggert
8da1edffff cp: don’t remove nonempty cloned dest
This follows up on comments by Pádraig Brady (bug#56391).
* src/copy.c (copy_reg): When --reflink=always removes a file
due to an FICLONE failure, do not remove a nonempty file.
2022-07-06 14:31:32 -05:00
Paul Eggert
1edda5009b cp: don’t create empty file if cannot clone
* src/copy.c (copy_reg): With --reflink=always, if FICLONE fails
on a file we just created, clean up by removing the file (Bug#56391).
2022-07-05 10:02:46 -05:00
Ivan Radić
fa332d998c maint: fix comment typo
* src/uniq.c: s/preceges/precedes/
2022-07-04 15:15:05 +01:00
Paul Eggert
9f71f478ec shuf: better diagnostic for ‘shuf -i -10-10’
* src/shuf.c: Do not include xdectoint.h.
(main): Improve diagnostic for ‘shuf -i -10-10’.  Without this
patch, the diagnostic was “shuf: invalid input range: ‘’” which is
not helpful.  Now it is “shuf: invalid input range: ‘-10-10’”.
2022-06-24 11:03:00 -05:00
Jim Meyering
6c03e8fbb2 cp: avoid -Wmaybe-uninitialized warning from GCC13
* src/copy.c (infer_scantype): Always set scan_inference.ext_start,
to make the code match the comment.
2022-06-23 08:31:21 -07:00
Jim Meyering
7e6c39cc02 maint: remove unnecessary inclusion of hash.h
* src/cut.c: Don't include hash.h. The implementation was
changed not to need that in v8.21-43-g3e466ad05.
2022-06-23 08:31:20 -07:00
Paul Eggert
fa7ed969c3 maint: prefer POSIX-compatible EREs
* cfg.mk (begword, endword): New macros.
(sc_prohibit_stat_macro_address, sc_prohibit_fail_0)
(sc_prohibit_short_facl_mode_spec, sc_require_stdio_safer)
(sc_prohibit_sleep, sc_prohibit_framework_failure)
(sc_marked_devdiagnostics):
* build-aux/gen-single-binary.sh:
Prefer POSIX-compatible EREs to GNU extensions like \w and \<.
2022-06-20 22:23:24 -05:00
Paul Eggert
b54da709a1 cp: fix ‘cp -rx / /mnt’
Problem reported by pkoraou@gmail.com (Bug#55910).
* src/copy.c (copy_internal): Treat a relative destination name ""
as if it were "." for the purpose of directory-relative syscalls
like fstatat that might might refer to the destination directory.
2022-06-11 10:53:59 -07:00
Paul Eggert
93e099e4c3 maint: avoid \] in REs
* cfg.mk (sc_dd_max_sym_length, sc_prohibit_man_see_also_period):
Do not rely on undefined interpretation of \] in regular expressions.
2022-06-03 19:45:47 -07:00
Paul Eggert
0ae619f349 build: update gnulib submodule to latest
* bootstrap: Copy from latest Gnulib.
* tests/misc/ls-misc.pl (v_files): Adjust to new Gnulib behavior.
2022-06-03 19:45:47 -07:00
Bernhard Voelker
b3331d59e8 maint: fix spelling in NEWS entry
* NEWS: s/x86-64/x86_64/
2022-05-26 16:12:41 +02:00
Paul Eggert
8c1a447a37 maint: spelling fix 2022-05-25 11:49:13 -07:00
Paul Eggert
9104dad18b sort: tune diff_reversed
* src/sort.c (diff_reversed): Tune.  On x86-64 with GCC, this
saves a conditional branch and shortens the generated machine code.
2022-05-25 11:24:09 -07:00
Paul Eggert
dc457c5e1b sort: refactor tricky diff reversal
* src/sort.c (diff_reversed): New function, to make the intent clearer.
(keycompare, compare): Use it.
2022-05-25 11:24:09 -07:00
Pádraig Brady
f0fb9cddc0 maint: sort.c: fix syntax-check issue in recent commit
* src/sort.c (keycompare): Avoid useless if before free()
as detected with sc_avoid_if_before_free.
2022-05-25 09:59:29 +01:00
Pádraig Brady
4e0167ea14 sort: fix issue with -rk in previous commit
* src/sort.c (keycompare): Fix typo causing -r to be
effectively ignored with -k.
Fixes https://bugs.gnu.org/55622
2022-05-25 09:47:40 +01:00
Paul Eggert
a351fdd6fc sort: fix unlikely int overflow with -r
* src/sort.c (keycompare, compare): Don’t overflow if -r is
specified and a comparison function returns INT_MIN, as this
causes the comparison to have undefined behavior (typically the
reverse of correct).  glibc memcmp on s390x reportedly returns
INT_MIN in some cases, so this is not a purely academic issue.
2022-05-17 19:30:55 -07:00
Paul Eggert
5864e8f919 maint: simplify comparisons
* src/comm.c (compare_files):
* src/join.c (keycmp):
* src/ls.c (off_cmp):
* src/ptx.c (compare_words, compare_occurs):
* src/set-fields.c (compare_ranges):
Prefer ((a > b) - (a < b)) to variants like (a < b ? -1 : a > b)
as it’s typically faster these days.
2022-05-17 19:30:55 -07:00
Paul Eggert
9f2fa50748 sort: remove some gotos
* src/sort.c (keycompare): Rework to avoid gotos.
This also shrinks the machine code a bit (112 bytes)
with GCC 12 x86-64 -O2.  Nowadays compilers are smart
enough to coalesce jumps so we need not do it by hand.
2022-05-17 19:30:55 -07:00
Paul Eggert
7646618e70 sort: pacify GCC 12 false positive
* src/sort.c (keycompare): Rework to pacify a GCC 12
-Wmaybe-uninitialized false positive, by coalescing some minor
duplicate code and eliminating a branch.  This should execute an
insn or two less in the usual case.
2022-05-17 19:30:55 -07:00
Paul Eggert
16e857509f build: update gnulib submodule to latest 2022-05-17 19:30:55 -07:00
Rasmus Villemoes
f45ab30c0b factor: --exponents: new option for printing in p^e format
When factoring numbers that have a large 2^n factor, it can be hard to
eyeball just how many 2's there are. Add an option to print each prime
power factor in the p^e format (omitting the exponent when it is 1).

* src/factor.c: Add -h, --exponents option for printing in p^e format.
* doc/coreutils.texi (factor invocation): Document the new option.
* tests/misc/factor.pl: Add test case.
* THANKS.in: Add previous suggester
(https://lists.gnu.org/r/coreutils/2017-11/msg00015.html).

Suggested-by: Emanuel Landeholm <emanuel.landeholm@gmail.com>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2022-05-09 14:38:01 +01:00
Pádraig Brady
ddafdae21c tests: sort-NaN-infloop: augment testing for recent fix
* tests/misc/sort-NaN-infloop.sh: Add test case from
https://unix.stackexchange.com/a/700967/37127
* src/sort.c: Avoid syntax-check failure.
2022-05-02 21:26:59 +01:00
Paul Eggert
cfeb6b15a5 build: update gnulib submodule to latest 2022-05-02 10:04:49 -07:00
Paul Eggert
2f56f5a420 sort: fix sort -g infloop again
Problem reported by Giulio Genovese (Bug#55212).
* src/sort.c (nan_compare): To compare NaNs, simply printf+strcmp.
This avoids the problem of padding bits and unspecified behavior.
Args are now long double instead of char *; caller changed.
2022-05-01 22:53:29 -07:00
Paul Eggert
e087525091 mv: test Bug#55029
* tests/mv/backup-dir.sh: New test for Bug#55029,
reported by Steve Ward.
2022-04-20 19:45:59 -07:00
Paul Eggert
6805e4dfc2 build: update gnulib submodule to latest 2022-04-20 19:45:59 -07:00
Paul Eggert
81d58df164 pr: don’t use uninitialized var
Found with -flto and --enable-gcc-warnings.
* src/pr.c (getoptarg): Fix misuse of xstrtol, which does not
necessarily set tmp_long on errror, and does not set errno in any
reliable way.  The previous code might access uninitialized
storage; on typical platforms this merely causes it to possibly
print the wrong diagnostic.
2022-04-19 16:14:50 -07:00
Paul Eggert
913f14bbd0 doc: fix ' and ` in PDF output of code
* doc/coreutils.texi: Set txicodequoteundirected and
txicodequotebacktick so that ' and ` in code examples appear
as-is, rather than being transliterated to ’ and ‘.  E.g., prefer
“... this is equivalent to ‘tr '\303\266' '\305\201'’ and ...” to
“... this is equivalent to ‘tr ’\303\266’ ’\305\201’’ and ...”
in PDF output.
2022-04-19 13:40:38 -07:00
Paul Eggert
f0de24e53f doc: fix footnote formats
* doc/coreutils.texi: Reword footnote, or put it right next
to previous punctuation.
2022-04-19 13:40:38 -07:00
Paul Eggert
6106b56191 doc: prefer ö to $'\u7530'
* doc/coreutils.texi (Character arrays): Avoid using shell
notation like $'\u7530' since this isn’t in POSIX yet. Instead,
use ö and Ł which should work in all texinfo output formats.
2022-04-19 13:40:38 -07:00
Pádraig Brady
dd614d6011 doc: rmdir: clarify --ignore-fail-on-non-empty operation
This option has changed from ignoring only ENOTEMPTY|EEXIST
(i.e. ignore errors _solely_ due to dir not empty),
to ignoring some other errors from more protected dirs
that are not empty.  That adjustment was made to better
support use with --parents, to essentially remove as much of
a hierarchy as possible, without erroring as we hit more
protected non empty parent dirs.
That functionality adjustment was originally discussed at:
https://lists.gnu.org/r/bug-coreutils/2008-01/msg00283.html

* src/rmdir.c (usage): Adjust to be more accurate to current behavior.
Also adjust --parents option to be easier to read.
* doc/coreutils.texi (rmdir invocation): Likewise.
Reported at https://github.com/coreutils/coreutils/issues/40
2022-04-17 13:46:03 +01:00
Pádraig Brady
07d59f5a54 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2022-04-15 22:40:41 +01:00
900 changed files with 18569 additions and 13833 deletions

View File

@@ -13,7 +13,7 @@ Before reporting a new bug, please check the following resources:
* Coreutils FAQ: https://www.gnu.org/software/coreutils/faq/coreutils-faq.html
* Coreutils Gotchas: https://www.pixelbeat.org/docs/coreutils-gotchas.html
contains a list of some quirks and unexpected behaviour (which are often
contains a list of some quirks and unexpected behavior (which are often
mistaken for bugs).
* Online Manual:
@@ -68,7 +68,7 @@ When sending messages to coreutils@gnu.org or bug-coreutils@gnu.org :
<!--
Copyright (C) 2017-2022 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

@@ -22,7 +22,7 @@ contributing to the GNU Project, please read
* Coreutils FAQ: https://www.gnu.org/software/coreutils/faq/coreutils-faq.html
* Coreutils Gotchas: https://www.pixelbeat.org/docs/coreutils-gotchas.html
contains a list of some quirks and unexpected behaviour (which are often
contains a list of some quirks and unexpected behavior (which are often
mistaken for bugs).
* Online Manual:
@@ -88,7 +88,7 @@ in this matter.
<!--
Copyright (C) 2017-2022 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

27
.gitignore vendored
View File

@@ -1,16 +1,19 @@
*.I[12]
*.[EIOX]
*.[EIOXao]
*.bak
*.gcda
*.gcno
*.o
*.a
*~
._bootmp
.deps
.gdb-history
.kludge-stamp
.version
/*.patch
/.Tpo
/.am*
/.re-list
/.sc-start-*
/ABOUT-NLS
/ChangeLog
/GNUmakefile
@@ -32,10 +35,12 @@
/build-aux/test-driver
/build-aux/texinfo.tex
/build-aux/ylwrap
/confdefs*
/config.cache
/config.log
/config.status
/configure
/conftest*
/coreutils-*.tar.gz
/coreutils-*.tar.gz.sig
/coreutils-*.tar.xz
@@ -48,21 +53,26 @@
/lib/alloca.h
/lib/arg-nonnull.h
/lib/arpa/inet.h
/lib/assert.h
/lib/byteswap.h
/lib/c++defs.h
/lib/charset.alias
/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
/lib/float.h
/lib/fnmatch.h
/lib/getopt-cdefs.h
/lib/getopt.h
/lib/glthread
/lib/gmp.h
/lib/iconv.h
/lib/iconv_open-aix.h
/lib/iconv_open-hpux.h
@@ -79,6 +89,7 @@
/lib/math.h
/lib/netdb.h
/lib/netinet/in.h
/lib/obstack.h
/lib/parse-datetime-gen.h
/lib/parse-datetime.c
/lib/poll.h
@@ -94,9 +105,10 @@
/lib/signal.h
/lib/spawn.h
/lib/stamp-h1
/lib/stdalign.h
/lib/stdarg.h
/lib/stdbool.h
/lib/stdbit.h
/lib/stdckdint.h
/lib/stddef.h
/lib/stdint.h
/lib/stdio.h
@@ -106,7 +118,12 @@
/lib/sys/
/lib/termios.h
/lib/time.h
/lib/uchar.h
/lib/unicase.h
/lib/unicase/
/lib/unictype
/lib/unictype.h
/lib/uninorm.h
/lib/unistd.h
/lib/unistr
/lib/unistr.h
@@ -193,8 +210,10 @@
/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
ID
Makefile
Makefile.in

2
.gitmodules vendored
View File

@@ -1,3 +1,3 @@
[submodule "gnulib"]
path = gnulib
url = git://git.sv.gnu.org/gnulib.git
url = https://git.savannah.gnu.org/git/gnulib.git

View File

@@ -1 +1 @@
9.0
9.6

View File

@@ -1,6 +1,6 @@
# Suppress valgrind diagnostics we don't care about.
# Copyright (C) 2003-2022 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

22
AUTHORS
View File

@@ -2,30 +2,30 @@ Here are the names of the programs in this package,
each followed by the name(s) of its author(s).
arch: David MacKenzie, Karel Zak
b2sum: Padraig Brady, Samuel Neves
b2sum: Pádraig Brady, Samuel Neves
base32: Simon Josefsson
base64: Simon Josefsson
basename: David MacKenzie
basenc: Simon Josefsson, Assaf Gordon
cat: Torbjorn Granlund, Richard M. Stallman
cat: Torbjörn Granlund, Richard M. Stallman
chcon: Russell Coker, Jim Meyering
chgrp: David MacKenzie, Jim Meyering
chmod: David MacKenzie, Jim Meyering
chown: David MacKenzie, Jim Meyering
chroot: Roland McGrath
cksum: Padraig Brady, Q. Frank Xia
cksum: Pádraig Brady, Q. Frank Xia
comm: Richard M. Stallman, David MacKenzie
coreutils: Alex Deymo
cp: Torbjorn Granlund, David MacKenzie, Jim Meyering
cp: Torbjörn Granlund, David MacKenzie, Jim Meyering
csplit: Stuart Kemp, David MacKenzie
cut: David M. Ihnat, David MacKenzie, Jim Meyering
date: David MacKenzie
dd: Paul Rubin, David MacKenzie, Stuart Kemp
df: Torbjorn Granlund, David MacKenzie, Paul Eggert
df: Torbjörn Granlund, David MacKenzie, Paul Eggert
dir: Richard M. Stallman, David MacKenzie
dircolors: H. Peter Anvin
dirname: David MacKenzie, Jim Meyering
du: Torbjorn Granlund, David MacKenzie, Paul Eggert, Jim Meyering
du: Torbjörn Granlund, David MacKenzie, Paul Eggert, Jim Meyering
echo: Brian Fox, Chet Ramey
env: Richard Mlynarik, David MacKenzie, Assaf Gordon
expand: David MacKenzie
@@ -67,7 +67,7 @@ printf: David MacKenzie
ptx: François Pinard
pwd: Jim Meyering
readlink: Dmitry V. Levin
realpath: Padraig Brady
realpath: Pádraig Brady
rm: Paul Rubin, David MacKenzie, Richard M. Stallman, Jim Meyering
rmdir: David MacKenzie
runcon: Russell Coker
@@ -81,9 +81,9 @@ shred: Colin Plumb
shuf: Paul Eggert
sleep: Jim Meyering, Paul Eggert
sort: Mike Haertel, Paul Eggert
split: Torbjorn Granlund, Richard M. Stallman
split: Torbjörn Granlund, Richard M. Stallman
stat: Michael Meskes
stdbuf: Padraig Brady
stdbuf: Pádraig Brady
stty: David MacKenzie
sum: Kayvan Aghaiepour, David MacKenzie
sync: Jim Meyering, Giuseppe Scrivano
@@ -91,11 +91,11 @@ tac: Jay Lepreau, David MacKenzie
tail: Paul Rubin, David MacKenzie, Ian Lance Taylor, Jim Meyering
tee: Mike Parker, Richard M. Stallman, David MacKenzie
test: Kevin Braunsdorf, Matthew Bradburn
timeout: Padraig Brady
timeout: Pádraig Brady
touch: Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie, Randy Smith
tr: Jim Meyering
true: Jim Meyering
truncate: Padraig Brady
truncate: Pádraig Brady
tsort: Mark Kettenis
tty: David MacKenzie
uname: David MacKenzie

23
HACKING
View File

@@ -3,24 +3,23 @@ Coreutils Contribution Guidelines
Prerequisites
=============
You will need the "git" version control tools.
On Fedora-based systems, do "yum install git".
On Debian-based ones install the "git-core" package.
Then run "git --version". If that says it's older than
version 1.4.4, then you'd do well to get a newer version.
You will need the "git" version control tools. On Fedora-based
systems, do "yum install git". On Debian-based ones install the
"git-core" package. Then run "git --version". If that says it's
older than version 1.4.4, then you'd do well to get a newer version.
At worst, just download the latest stable release from
https://git-scm.com/ and build from source.
For details on building the programs in this package, see
the file, README-hacking.
For details on building the programs in this package, see the file,
README-hacking.
Use the latest upstream sources
===============================
Base any changes you make on the latest upstream sources.
You can get a copy of the latest with this command:
Base any changes you make on the latest upstream sources. You can get
a copy of the latest with this command:
git clone git://git.sv.gnu.org/coreutils
git clone https://git.savannah.gnu.org/git/coreutils.git
cd coreutils
That downloads the entire repository, including revision control history
@@ -95,7 +94,7 @@ Make your changes on a private "topic" branch
=============================================
So you checked out coreutils like this:
git clone git://git.sv.gnu.org/coreutils
git clone https://git.savannah.gnu.org/git/coreutils.git
Now, cd into the coreutils/ directory and run:
@@ -617,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-2022 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-2022 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
@@ -24,6 +24,7 @@ EXTRA_DIST = \
.prev-version \
.version \
.vg-suppressions \
README-install \
THANKS.in \
THANKS-to-translators \
THANKStt.in \
@@ -81,19 +82,17 @@ 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
gen_start_ver = 8.27
gen_start_ver = 8.31
.PHONY: gen-ChangeLog
gen-ChangeLog:
$(AM_V_GEN)if test -d .git; then \
@@ -134,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"
@@ -208,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

662
NEWS
View File

@@ -1,5 +1,646 @@
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
chmod -R now avoids a race where an attacker may replace a traversed file
with a symlink, causing chmod to operate on an unintended file.
[This bug was present in "the beginning".]
cp, mv, and install no longer issue spurious diagnostics like "failed
to preserve ownership" when copying to GNU/Linux CIFS file systems.
They do this by working around some Linux CIFS bugs.
cp --no-preserve=mode will correctly maintain set-group-ID bits
for created directories. Previously on systems that didn't support ACLs,
cp would have reset the set-group-ID bit on created directories.
[bug introduced in coreutils-8.20]
join and uniq now support multi-byte characters better.
For example, 'join -tX' now works even if X is a multi-byte character,
and both programs now treat multi-byte characters like U+3000
IDEOGRAPHIC SPACE as blanks if the current locale treats them so.
numfmt options like --suffix no longer have an arbitrary 127-byte limit.
[bug introduced with numfmt in coreutils-8.21]
mktemp with --suffix now better diagnoses templates with too few X's.
Previously it conflated the insignificant --suffix in the error.
[bug introduced in coreutils-8.1]
sort again handles thousands grouping characters in single-byte locales
where the grouping character is greater than CHAR_MAX. For e.g. signed
character platforms with a 0xA0 (aka &nbsp) grouping character.
[bug introduced in coreutils-9.1]
split --line-bytes with a mixture of very long and short lines
no longer overwrites the heap (CVE-2024-0684).
[bug introduced in coreutils-9.2]
tail no longer mishandles input from files in /proc and /sys file systems,
on systems with a page size larger than the stdio BUFSIZ.
[This bug was present in "the beginning".]
timeout avoids a narrow race condition, where it might kill arbitrary
processes after a failed process fork.
[bug introduced with timeout in coreutils-7.0]
timeout avoids a narrow race condition, where it might fail to
kill monitored processes immediately after forking them.
[bug introduced with timeout in coreutils-7.0]
wc no longer fails to count unprintable characters as parts of words.
[bug introduced in textutils-2.1]
** Changes in behavior
base32 and base64 no longer require padding when decoding.
Previously an error was given for non padded encoded data.
base32 and base64 have improved detection of corrupted encodings.
Previously encodings with non zero padding bits were accepted.
basenc --base16 -d now supports lower case hexadecimal characters.
Previously an error was given for lower case hex digits.
cp --no-clobber, and mv -n no longer exit with failure status if
existing files are encountered in the destination. Instead they revert
to the behavior from before v9.2, silently skipping existing files.
ls --dired now implies long format output without hyperlinks enabled,
and will take precedence over previously specified formats or hyperlink mode.
numfmt will accept lowercase 'k' to indicate Kilo or Kibi units on input,
and uses lowercase 'k' when outputting such units in '--to=si' mode.
pinky no longer tries to canonicalize the user's login location by default,
rather requiring the new --lookup option to enable this often slow feature.
wc no longer ignores encoding errors when counting words.
Instead, it treats them as non white space.
** New features
chgrp now accepts the --from=OWNER:GROUP option to restrict changes to files
with matching current OWNER and/or GROUP, as already supported by chown(1).
chmod adds support for -h, -H,-L,-P, and --dereference options, providing
more control over symlink handling. This supports more secure handling of
CLI arguments, and is more consistent with chown, and chmod on other systems.
cp now accepts the --keep-directory-symlink option (like tar), to preserve
and follow existing symlinks to directories in the destination.
cp and mv now accept the --update=none-fail option, which is similar
to the --no-clobber option, except that existing files are diagnosed,
and the command exits with failure status if existing files.
The -n,--no-clobber option is best avoided due to platform differences.
env now accepts the -a,--argv0 option to override the zeroth argument
of the command being executed.
mv now accepts an --exchange option, which causes the source and
destination to be exchanged. It should be combined with
--no-target-directory (-T) if the destination is a directory.
The exchange is atomic if source and destination are on a single
file system that supports atomic exchange; --exchange is not yet
supported in other situations.
od now supports printing IEEE half precision floating point with -t fH,
or brain 16 bit floating point with -t fB, where supported by the compiler.
tail now supports following multiple processes, with repeated --pid options.
** Improvements
cp,mv,install,cat,split now read and write a minimum of 256KiB at a time.
This was previously 128KiB and increasing to 256KiB was seen to increase
throughput by 10-20% when reading cached files on modern systems.
env,kill,timeout now support unnamed signals. kill(1) for example now
supports sending such signals, and env(1) will list them appropriately.
SELinux operations in file copy operations are now more efficient,
avoiding unneeded MCS/MLS label translation.
sort no longer dynamically links to libcrypto unless -R is used.
This decreases startup overhead in the typical case.
wc is now much faster in single-byte locales and somewhat faster in
multi-byte locales.
* Noteworthy changes in release 9.4 (2023-08-29) [stable]
** Bug fixes
On GNU/Linux s390x and alpha, programs like 'cp' and 'ls' no longer
fail on files with inode numbers that do not fit into 32 bits.
[This bug was present in "the beginning".]
'b2sum --check' will no longer read unallocated memory when
presented with malformed checksum lines.
[bug introduced in coreutils-9.2]
'cp --parents' again succeeds when preserving mode for absolute directories.
Previously it would have failed with a "No such file or directory" error.
[bug introduced in coreutils-9.1]
'cp --sparse=never' will avoid copy-on-write (reflinking) and copy offloading,
to ensure no holes present in the destination copy.
[bug introduced in coreutils-9.0]
cksum again diagnoses read errors in its default CRC32 mode.
[bug introduced in coreutils-9.0]
'cksum --check' now ensures filenames with a leading backslash character
are escaped appropriately in the status output.
This also applies to the standalone checksumming utilities.
[bug introduced in coreutils-8.25]
dd again supports more than two multipliers for numbers.
Previously numbers of the form '1024x1024x32' gave "invalid number" errors.
[bug introduced in coreutils-9.1]
factor, numfmt, and tsort now diagnose read errors on the input.
[This bug was present in "the beginning".]
'install --strip' now supports installing to files with a leading hyphen.
Previously such file names would have caused the strip process to fail.
[This bug was present in "the beginning".]
ls now shows symlinks specified on the command line that can't be traversed.
Previously a "Too many levels of symbolic links" diagnostic was given.
[This bug was present in "the beginning".]
pinky, uptime, users, and who no longer misbehave on 32-bit GNU/Linux
platforms like x86 and ARM where time_t was historically 32 bits.
Also see the new --enable-systemd option mentioned below.
[bug introduced in coreutils-9.0]
'pr --length=1 --double-space' no longer enters an infinite loop.
[This bug was present in "the beginning".]
shred again operates on Solaris when built for 64 bits.
Previously it would have exited with a "getrandom: Invalid argument" error.
[bug introduced in coreutils-9.0]
tac now handles short reads on its input. Previously it may have exited
erroneously, especially with large input files with no separators.
[This bug was present in "the beginning".]
'uptime' no longer incorrectly prints "0 users" on OpenBSD,
and is being built again on FreeBSD and Haiku.
[bugs introduced in coreutils-9.2]
'wc -l' and 'cksum' no longer crash with an "Illegal instruction" error
on x86 Linux kernels that disable XSAVE YMM. This was seen on Xen VMs.
[bug introduced in coreutils-9.0]
** Changes in behavior
'cp -v' and 'mv -v' will no longer output a message for each file skipped
due to -i, or -u. Instead they only output this information with --debug.
I.e., 'cp -u -v' etc. will have the same verbosity as before coreutils-9.3.
'cksum -b' no longer prints base64-encoded checksums. Rather that
short option is reserved to better support emulation of the standalone
checksum utilities with cksum.
'mv dir x' now complains differently if x/dir is a nonempty directory.
Previously it said "mv: cannot move 'dir' to 'x/dir': Directory not empty",
where it was unclear whether 'dir' or 'x/dir' was the problem.
Now it says "mv: cannot overwrite 'x/dir': Directory not empty".
Similarly for other renames where the destination must be the problem.
[problem introduced in coreutils-6.0]
** Improvements
cp, mv, and install now avoid copy_file_range on linux kernels before 5.3
irrespective of which kernel version coreutils is built against,
reinstating that behavior from coreutils-9.0.
comm, cut, join, od, and uniq will now exit immediately upon receiving a
write error, which is significant when reading large / unbounded inputs.
split now uses more tuned access patterns for its potentially large input.
This was seen to improve throughput by 5% when reading from SSD.
split now supports a configurable $TMPDIR for handling any temporary files.
tac now falls back to '/tmp' if a configured $TMPDIR is unavailable.
'who -a' now displays the boot time on Alpine Linux, OpenBSD,
Cygwin, Haiku, and some Android distributions
'uptime' now succeeds on some Android distributions, and now counts
VM saved/sleep time on GNU (Linux, Hurd, kFreeBSD), NetBSD, OpenBSD,
Minix, and Cygwin.
On GNU/Linux platforms where utmp-format files have 32-bit timestamps,
pinky, uptime, and who can now work for times after the year 2038,
so long as systemd is installed, you configure with a new, experimental
option --enable-systemd, and you use the programs without file arguments.
(For example, with systemd 'who /var/log/wtmp' does not work because
systemd does not support the equivalent of /var/log/wtmp.)
* Noteworthy changes in release 9.3 (2023-04-18) [stable]
** Bug fixes
cp --reflink=auto (the default), mv, and install
will again fall back to a standard copy in more cases.
Previously copies could fail with permission errors on
more restricted systems like android or containers etc.
[bug introduced in coreutils-9.2]
cp --recursive --backup will again operate correctly.
Previously it may have issued "File exists" errors when
it failed to appropriately rename files being replaced.
[bug introduced in coreutils-9.2]
date --file and dircolors will now diagnose a failure to read a file.
Previously they would have silently ignored the failure.
[This bug was present in "the beginning".]
md5sum --check again correctly prints the status of each file checked.
Previously the status for files was printed as 'OK' once any file had passed.
This also applies to cksum, sha*sum, and b2sum.
[bug introduced in coreutils-9.2]
wc will now diagnose if any total counts have overflowed.
[This bug was present in "the beginning".]
`wc -c` will again correctly update the read offset of inputs.
Previously it deduced the size of inputs while leaving the offset unchanged.
[bug introduced in coreutils-8.27]
Coreutils programs no longer fail for timestamps past the year 2038
on obsolete configurations with 32-bit signed time_t, because the
build procedure now rejects these configurations.
[This bug was present in "the beginning".]
** Changes in behavior
'cp -n' and 'mv -n' now issue an error diagnostic if skipping a file,
to correspond with -n inducing a nonzero exit status as of coreutils 9.2.
Similarly 'cp -v' and 'mv -v' will output a message for each file skipped
due to -n, -i, or -u.
** New features
cp and mv now support --update=none to always skip existing files
in the destination, while not affecting the exit status.
This is equivalent to the --no-clobber behavior from before v9.2.
* Noteworthy changes in release 9.2 (2023-03-20) [stable]
** Bug fixes
'comm --output-delimiter="" --total' now delimits columns in the total
line with the NUL character, consistent with NUL column delimiters in
the rest of the output. Previously no delimiters were used for the
total line in this case.
[bug introduced with the --total option in coreutils-8.26]
'cp -p' no longer has a security hole when cloning into a dangling
symbolic link on macOS 10.12 and later.
[bug introduced in coreutils-9.1]
'cp -rx / /mnt' no longer complains "cannot create directory /mnt/".
[bug introduced in coreutils-9.1]
cp, mv, and install avoid allocating too much memory, and possibly
triggering "memory exhausted" failures, on file systems like ZFS,
which can return varied file system I/O block size values for files.
[bug introduced in coreutils-6.0]
cp, mv, and install now immediately acknowledge transient errors
when creating copy-on-write or cloned reflink files, on supporting
file systems like XFS, BTRFS, APFS, etc.
Previously they would have tried again with other copy methods
which may have resulted in data corruption.
[bug introduced in coreutils-7.5 and enabled by default in coreutils-9.0]
cp, mv, and install now handle ENOENT failures across CIFS file systems,
falling back from copy_file_range to a better supported standard copy.
[issue introduced in coreutils-9.0]
'mv --backup=simple f d/' no longer mistakenly backs up d/f to f~.
[bug introduced in coreutils-9.1]
rm now fails gracefully when memory is exhausted.
Previously it may have aborted with a failed assertion in some cases.
[This bug was present in "the beginning".]
rm -d (--dir) now properly handles unreadable empty directories.
E.g., before, this would fail to remove d: mkdir -m0 d; src/rm -d d
[bug introduced in v8.19 with the addition of this option]
runcon --compute no longer looks up the specified command in the $PATH
so that there is no mismatch between the inspected and executed file.
[bug introduced when runcon was introduced in coreutils-6.9.90]
'sort -g' no longer infloops when given multiple NaNs on platforms
like x86_64 where 'long double' has padding bits in memory.
Although the fix alters sort -g's NaN ordering, that ordering has
long been documented to be platform-dependent.
[bug introduced 1999-05-02 and only partly fixed in coreutils-8.14]
stty ispeed and ospeed options no longer accept and silently ignore
invalid speed arguments, or give false warnings for valid speeds.
Now they're validated against both the general accepted set,
and the system supported set of valid speeds.
[This bug was present in "the beginning".]
stty now wraps output appropriately for the terminal width.
Previously it may have output 1 character too wide for certain widths.
[bug introduced in coreutils-5.3]
tail --follow=name works again with non seekable files. Previously it
exited with an "Illegal seek" error when such a file was replaced.
[bug introduced in fileutils-4.1.6]
'wc -c' will again efficiently determine the size of large files
on all systems. It no longer redundantly reads data from certain
sized files larger than SIZE_MAX.
[bug introduced in coreutils-8.24]
** Changes in behavior
Programs now support the new Ronna (R), and Quetta (Q) SI prefixes,
corresponding to 10^27 and 10^30 respectively,
along with their binary counterparts Ri (2^90) and Qi (2^100).
In some cases (e.g., 'sort -h') these new prefixes simply work;
in others, where they exceed integer width limits, they now elicit
the same integer overflow diagnostics as other large prefixes.
'cp --reflink=always A B' no longer leaves behind a newly created
empty file B merely because copy-on-write clones are not supported.
'cp -n' and 'mv -n' now exit with nonzero status if they skip their
action because the destination exists, and likewise for 'cp -i',
'ln -i', and 'mv -i' when the user declines. (POSIX specifies this
for 'cp -i' and 'mv -i'.)
cp, mv, and install again read in multiples of the reported block size,
to support unusual devices that may have this constraint.
[behavior inadvertently changed in coreutils-7.2]
du --apparent now counts apparent sizes only of regular files and
symbolic links. POSIX does not specify the meaning of apparent
sizes (i.e., st_size) for other file types, and counting those sizes
could cause confusing and unwanted size mismatches.
'ls -v' and 'sort -V' go back to sorting ".0" before ".A",
reverting to the behavior in coreutils-9.0 and earlier.
This behavior is now documented.
ls --color now matches a file extension case sensitively
if there are different sequences defined for separate cases.
printf unicode \uNNNN, \UNNNNNNNN syntax, now supports all valid
unicode code points. Previously is was restricted to the C
universal character subset, which restricted most points <= 0x9F.
runcon now exits with status 125 for internal errors. Previously upon
internal errors it would exit with status 1, which was less distinguishable
from errors from the invoked command.
'split -n N' now splits more evenly when the input size is not a
multiple of N, by creating N output files whose sizes differ by at
most 1 byte. Formerly, it did this only when the input size was
less than N.
'stat -c %s' now prints sizes as unsigned, consistent with 'ls'.
** New Features
cksum now accepts the --base64 (-b) option to print base64-encoded
checksums. It also accepts/checks such checksums.
cksum now accepts the --raw option to output a raw binary checksum.
No file name or other information is output in this mode.
cp, mv, and install now accept the --debug option to
print details on how a file is being copied.
factor now accepts the --exponents (-h) option to print factors
in the form p^e, rather than repeating the prime p, e times.
ls now supports the --time=modification option, to explicitly
select the default mtime timestamp for display and sorting.
mv now supports the --no-copy option, which causes it to fail when
asked to move a file to a different file system.
split now accepts options like '-n SIZE' that exceed machine integer
range, when they can be implemented as if they were infinity.
split -n now accepts piped input even when not in round-robin mode,
by first copying input to a temporary file to determine its size.
wc now accepts the --total={auto,never,always,only} option
to give explicit control over when the total is output.
** Improvements
cp --sparse=auto (the default), mv, and install,
will use the copy_file_range syscall now also with sparse files.
This may be more efficient, by avoiding user space copies,
and possibly employing copy offloading or reflinking,
for the non sparse portion of such sparse files.
On macOS, cp creates a copy-on-write clone in more cases.
Previously cp would only do this when preserving mode and timestamps.
date --debug now diagnoses if multiple --date or --set options are
specified, as only the last specified is significant in that case.
rm outputs more accurate diagnostics in the presence of errors
when removing directories. For example EIO will be faithfully
diagnosed, rather than being conflated with ENOTEMPTY.
tail --follow=name now works with single non regular files even
when their modification time doesn't change when new data is available.
Previously tail would not show any new data in this case.
tee -p detects when all remaining outputs have become broken pipes, and
exits, rather than waiting for more input to induce an exit when written.
tee now handles non blocking outputs, which can be seen for example with
telnet or mpirun piping through tee to a terminal.
Previously tee could truncate data written to such an output and fail,
and also potentially output a "Resource temporarily unavailable" error.
* Noteworthy changes in release 9.1 (2022-04-15) [stable]
** Bug fixes
@@ -70,7 +711,7 @@ GNU coreutils NEWS -*- outline -*-
though they still work.
ls no longer colors files with capabilities by default, as file-based
capabilties are very rarely used, and lookup increases processing per file by
capabilities are rarely used, and lookup increases processing per file by
about 30%. It's best to use getcap [-r] to identify files with capabilities.
ls no longer tries to automount files, reverting to the behavior
@@ -161,7 +802,7 @@ GNU coreutils NEWS -*- outline -*-
expr no longer mishandles unmatched \(...\) in regular expressions.
[bug introduced in coreutils-6.0]
ls no longer crashes when printing the SELinux context for unstatable files.
ls no longer crashes when printing the SELinux context for unstattable files.
[bug introduced in coreutils-6.9.91]
mkdir -m no longer mishandles modes more generous than the umask.
@@ -196,6 +837,7 @@ GNU coreutils NEWS -*- outline -*-
** Changes in behavior
cp and install now default to copy-on-write (COW) if available.
I.e., cp now uses --reflink=auto mode by default.
cp, install and mv now use the copy_file_range syscall if available.
Also, they use lseek+SEEK_HOLE rather than ioctl+FS_IOC_FIEMAP on sparse
@@ -466,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:
@@ -739,7 +1381,7 @@ GNU coreutils NEWS -*- outline -*-
** Bug fixes
cp --parents will now set an SELinux context for created directories,
as appropriate for the -a, --preseve=context, or -Z options.
as appropriate for the -a, --preserve=context, or -Z options.
[bug present since SELinux support added in coreutils-6.10]
date again converts from a specified time zone. Previously output was
@@ -986,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.
@@ -1376,7 +2018,7 @@ GNU coreutils NEWS -*- outline -*-
** Bug fixes
df now processes the mount list correctly in the presence of unstatable
df now processes the mount list correctly in the presence of unstattable
mount points. Previously it may have failed to output some mount points.
[bug introduced in coreutils-8.21]
@@ -2546,7 +3188,7 @@ GNU coreutils NEWS -*- outline -*-
rm -r --one-file-system works once again.
The rewrite to make rm use fts introduced a regression whereby
a commmand of the above form would fail for all subdirectories.
a command of the above form would fail for all subdirectories.
[bug introduced in coreutils-8.0]
stat -f recognizes more file system types: k-afs, fuseblk, gfs/gfs2, ocfs2,
@@ -2629,7 +3271,7 @@ GNU coreutils NEWS -*- outline -*-
ls --color now handles files with capabilities correctly. Previously
files with capabilities were often not colored, and also sometimes, files
without capabilites were colored in error. [bug introduced in coreutils-7.0]
without capabilities were colored in error. [bug introduced in coreutils-7.0]
md5sum now prints checksums atomically so that concurrent
processes will not intersperse their output.
@@ -2778,7 +3420,7 @@ GNU coreutils NEWS -*- outline -*-
avoid the disproportionate quadratic performance penalty. Leading to
another improvement:
rm -r is now slightly more standards-conformant when operating on
rm -r is now slightly more standard-conforming when operating on
write-protected files with relative names longer than 8KiB.
@@ -5418,7 +6060,7 @@ packages, see ./old/*/NEWS.
========================================================================
Copyright (C) 2001-2022 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

143
README
View File

@@ -21,7 +21,8 @@ See the file NEWS for a list of major changes in the current release.
If you obtained this file as part of a "git clone", then see the
README-hacking file. If this file came to you as part of a tar archive,
then see the file INSTALL for compilation and installation instructions.
then see the file INSTALL for general compilation and installation
instructions, or README-install for system and coreutils specific instructions.
Like the rest of the GNU system, these programs mostly conform to
POSIX, with BSD and other extensions. For closer conformance, or
@@ -57,97 +58,17 @@ files (man/*.x) are welcome. However, the authoritative documentation
is in texinfo form in the doc directory.
*********************
Pre-C99 build failure
---------------------
***************
Feature requests:
---------------
In 2009 we added this requirement:
To build the coreutils from source, you must have a C99-conforming
compiler, due to the use of declarations after non-declaration statements
in several files in src/. There is code in configure to find and, if
possible, enable an appropriate compiler. However, if configure doesn't
find a C99 compiler, it continues nonetheless, and your build will fail.
There used to be a "c99-to-c89.diff" patch you could apply to convert
to code that even an old pre-c99 compiler can handle, but it was too
tedious to maintain, so has been removed.
***********************
HPUX 11.x build failure
-----------------------
A known problem exists when compiling on HPUX on both hppa and ia64
in 64-bit mode (i.e., +DD64) on HP-UX 11.0, 11.11, and 11.23. This
is not due to a bug in the package but instead due to a bug in the
system header file which breaks things in 64-bit mode. The default
compilation mode is 32-bit and the software compiles fine using the
default mode. To build this software in 64-bit mode you will need
to fix the system /usr/include/inttypes.h header file. After
correcting that file the software also compiles fine in 64-bit mode.
Here is one possible patch to correct the problem:
--- /usr/include/inttypes.h.orig Thu May 30 01:00:00 1996
+++ /usr/include/inttypes.h Sun Mar 23 00:20:36 2003
@@ -489 +489 @@
-#ifndef __STDC_32_MODE__
+#ifndef __LP64__
************************
OSF/1 4.0d and AIX build failures
------------------------
If you use /usr/bin/make on these systems, the build will fail due
to the presence of the "[" target. OSF/1 make(1) appears to
treat "[" as some syntax relating to locks, while AIX make(1)
appears to skip the "[" target. To work around these issues
the best solution is to use GNU make. Otherwise, simply remove
all mention of "[$(EXEEXT)" from src/Makefile.
************************
32 bit time_t build failures
------------------------
On systems where it's determined that 64 bit time_t is supported
(indicated by touch -t <some time after 2038>), but that coreutils
would be built with a narrower time_t, the build will fail.
This can be allowed by passing TIME_T_32_BIT_OK=yes to configure,
or avoided by enabling 64 bit builds. For example GCC on AIX defaults
to 32 bit, and to enable the 64 bit ABI one can use:
./configure CFLAGS=-maix64 LDFLAGs=-maix64 AR='ar -X64'
*************************************************
"make check" failure on IRIX 6.5 and Solaris <= 9
-------------------------------------------------
Using the vendor make program to run "make check" fails on these two systems.
If you want to run all of the tests there, use GNU make.
**********************
Running tests as root:
----------------------
If you run the tests as root, note that a few of them create files
and/or run programs as a non-root user, 'nobody' by default.
If you want to use some other non-root username, specify it via
the NON_ROOT_USERNAME environment variable. Depending on the
permissions with which the working directories have been created,
using 'nobody' may fail, because that user won't have the required
read and write access to the build and test directories.
I find that it is best to unpack and build as a non-privileged
user, and then to run the following command as that user in order
to run the privilege-requiring tests:
sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k check-root
If you can run the tests as root, please do so and report any
problems. We get much less test coverage in that mode, and it's
arguably more important that these tools work well when run by
root than when run by less privileged users.
If you would like to add a new feature, please try to get some sort of
consensus that it is a worthwhile change. One way to do that is to send
mail to coreutils@gnu.org including as much description and justification
as you can. Based on the feedback that generates, you may be able to
convince us that it's worth adding. Please also consult the list of
previously discussed but ultimately rejected feature requests at:
https://www.gnu.org/software/coreutils/rejected_requests.html
***************
@@ -157,6 +78,10 @@ Reporting bugs:
Send bug reports, questions, comments, etc. to bug-coreutils@gnu.org.
To suggest a patch, see the files README-hacking and HACKING for tips.
All of these programs except 'test' recognize the '--version' option.
When reporting bugs, please include in the subject line both the package
name/version and the name of the program for which you found a problem.
If you have a problem with 'sort', try running 'sort --debug', as it
can often help find and fix problems without having to wait for an
answer to a bug report. If the debug output does not suffice to fix
@@ -171,8 +96,8 @@ run this command:
make check TESTS=tests/df/df-P.sh VERBOSE=yes SUBDIRS=. >> log 2>&1
For some tests, you can get even more detail by adding DEBUG=yes.
Then include the contents of the file 'log' in your bug report.
For some tests, particularly perl tests, you can get even more detail by adding
DEBUG=yes. Then include the contents of the file 'log' in your bug report.
***************************************
@@ -181,7 +106,7 @@ There are many tests, but nowhere near as many as we need.
Additions and corrections are very welcome.
If you see a problem that you've already reported, feel free to re-report
it -- it won't bother me to get a reminder. Besides, the more messages I
it -- it won't bother us to get a reminder. Besides, the more messages we
get regarding a particular problem the sooner it'll be fixed -- usually.
If you sent a complete patch and, after a couple weeks you haven't
received any acknowledgement, please ping us. A complete patch includes
@@ -195,30 +120,6 @@ Here are instructions for checking out the latest development sources:
https://savannah.gnu.org/git/?group=coreutils
If your patch adds a new feature, please try to get some sort of consensus
that it is a worthwhile change. One way to do that is to send mail to
coreutils@gnu.org including as much description and justification
as you can. Based on the feedback that generates, you may be able to
convince us that it's worth adding. Please also consult the list of
previously discussed but ultimately rejected feature requests at:
https://www.gnu.org/software/coreutils/rejected_requests.html
WARNING: Now that we use the ./bootstrap script, you should not run
autoreconf manually. Doing that will overwrite essential source files
with older versions, which may make the package unbuildable or introduce
subtle bugs.
WARNING: If you modify files like configure.in, m4/*.m4, aclocal.m4,
or any Makefile.am, then don't be surprised if what gets regenerated no
longer works. To make things work, you'll have to be using appropriate
versions of the tools listed in bootstrap.conf's buildreq string.
All of these programs except 'test' recognize the '--version' option.
When reporting bugs, please include in the subject line both the package
name/version and the name of the program for which you found a problem.
For general documentation on the coding and usage standards
this distribution follows, see the GNU Coding Standards at:
https://www.gnu.org/prep/standards/
@@ -226,13 +127,11 @@ https://www.gnu.org/prep/standards/
For any copyright year range specified as YYYY-ZZZZ in this package
note that the range specifies every single year in that closed interval.
Mail suggestions and bug reports for these programs to
the address on the last line of --help output.
Please see the file COPYING for copying conditions.
========================================================================
Copyright (C) 1998-2022 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

@@ -16,7 +16,7 @@ Specific development tools and versions will be checked for and listed by
the bootstrap script. See README-prereq for specific notes on obtaining
these prerequisite tools.
Valgrind <http://valgrind.org/> is also highly recommended, if
Valgrind <https://valgrind.org/> is also highly recommended, if
Valgrind supports your architecture. See also README-valgrind
(if present).
@@ -27,7 +27,7 @@ few prerequisites, later, a plain 'git pull && make' typically suffices.
You can get a copy of the source repository like this:
$ git clone git://git.sv.gnu.org/<packagename>
$ git clone https://git.savannah.gnu.org/git/<packagename>
$ cd <packagename>
where '<packagename>' stands for 'coreutils' or whatever other package
@@ -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-2022 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

111
README-install Normal file
View File

@@ -0,0 +1,111 @@
Please see the file INSTALL for generic build and installation instructions.
This file details coreutils and system specific build instructions.
*********************
Pre-C99 build failure
---------------------
In 2009 we added this requirement:
To build the coreutils from source, you must have a C99-conforming
compiler, due to the use of declarations after non-declaration statements
in several files in src/. There is code in configure to find and, if
possible, enable an appropriate compiler. However, if configure doesn't
find a C99 compiler, it continues nonetheless, and your build will fail.
There used to be a "c99-to-c89.diff" patch you could apply to convert
to code that even an old pre-c99 compiler can handle, but it was too
tedious to maintain, so has been removed.
***********************
HPUX 11.x build failure
-----------------------
A known problem exists when compiling on HPUX on both hppa and ia64
in 64-bit mode (i.e., +DD64) on HP-UX 11.0, 11.11, and 11.23. This
is not due to a bug in the package but instead due to a bug in the
system header file which breaks things in 64-bit mode. The default
compilation mode is 32-bit and the software compiles fine using the
default mode. To build this software in 64-bit mode you will need
to fix the system /usr/include/inttypes.h header file. After
correcting that file the software also compiles fine in 64-bit mode.
Here is one possible patch to correct the problem:
--- /usr/include/inttypes.h.orig Thu May 30 01:00:00 1996
+++ /usr/include/inttypes.h Sun Mar 23 00:20:36 2003
@@ -489 +489 @@
-#ifndef __STDC_32_MODE__
+#ifndef __LP64__
************************
OSF/1 4.0d and AIX build failures
------------------------
If you use /usr/bin/make on these systems, the build will fail due
to the presence of the "[" target. OSF/1 make(1) appears to
treat "[" as some syntax relating to locks, while AIX make(1)
appears to skip the "[" target. To work around these issues
the best solution is to use GNU make. Otherwise, simply remove
all mention of "[$(EXEEXT)" from src/Makefile.
************************
32 bit time_t build failures
------------------------
Although 32-bit builds fail if that forces time_t to be 32 bits, this
can be fixed by using 64-bit builds. For example, on AIX where GCC
defaults to 32 bits, one can use "./configure CC='gcc -maix64' AR='ar
-X64'"; similarly, on Solaris one can configure with CC='gcc -m64'.
If all else fails one can configure with --disable-year2038;
however, this will mishandle timestamps after 2038, and please file
bug reports for any such situations.
*************************************************
"make check" failure on IRIX 6.5 and Solaris <= 9
-------------------------------------------------
Using the vendor make program to run "make check" fails on these two systems.
If you want to run all of the tests there, use GNU make.
**********************
Running tests as root:
----------------------
If you run the tests as root, note that a few of them create files
and/or run programs as a non-root user, 'nobody' by default.
If you want to use some other non-root username, specify it via
the NON_ROOT_USERNAME environment variable. Depending on the
permissions with which the working directories have been created,
using 'nobody' may fail, because that user won't have the required
read and write access to the build and test directories.
I find that it is best to unpack and build as a non-privileged
user, and then to run the following command as that user in order
to run the privilege-requiring tests:
sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k check-root
If you can run the tests as root, please do so and report any
problems. We get much less test coverage in that mode, and it's
arguably more important that these tools work well when run by
root than when run by less privileged users.
**********************
autotools considerations:
----------------------
WARNING: Now that we use the ./bootstrap script, you should not run
autoreconf manually. Doing that will overwrite essential source files
with older versions, which may make the package unbuildable or introduce
subtle bugs.
WARNING: If you modify files like configure.in, m4/*.m4, aclocal.m4,
or any Makefile.am, then don't be surprised if what gets regenerated no
longer works. To make things work, you'll have to be using appropriate
versions of the tools listed in bootstrap.conf's buildreq string.

View File

@@ -15,7 +15,7 @@ as well as by 'make'. They include:
- Perl <https://www.cpan.org/>
- Tar <https://www.gnu.org/software/tar/>
- Texinfo <https://www.gnu.org/software/texinfo/>
- Wget <http://www.gnu.org/software/wget/>
- Wget <https://www.gnu.org/software/wget/>
- XZ Utils <https://tukaani.org/xz/>
It is generally better to use official packages for your system.

View File

@@ -1,7 +1,7 @@
#! /bin/bash
# Convert this package for use with valgrind.
# Copyright (C) 2002-2022 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
@@ -41,7 +41,7 @@ _path='export PATH='$srcdir':${PATH#*:}'
pre='#!/bin/sh\n'"$_path"'\n'
n=15 # stack trace depth
log_fd=3 # One can redirect this to file like 3>vg.log
test -e /tmp/cu-vg && suppressions='--supressions=/tmp/cu-vg'
test -e /tmp/cu-vg && suppressions='--suppressions=/tmp/cu-vg'
vg="exec /usr/bin/valgrind $suppressions --log-fd=$log_fd \
--leak-check=yes --track-fds=yes --leak-check=full --num-callers=$n"
cat <<EOF > src/vg/gen

View File

@@ -132,7 +132,7 @@ Clark Morgan cmorgan@aracnet.com
Clement Wang clem.wang@overture.com
Colin Plumb colin@nyx.net
Collin Rogowski collin@rogowski.de
Cray-Cyber Project http://www.cray-cyber.org
Cray-Cyber Project https://www.cray-cyber.org
Cristian Cadar cristic@stanford.edu
Cyril Bouthors cyril@bouthors.org
Dale Scheetz dwarf@polaris.net
@@ -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
@@ -160,6 +161,7 @@ David Luyer david_luyer@pacific.net.au
David Madore david.madore@ens.fr
David Malone dwmalone@cnri.dit.ie
David Matei matei@cs.toronto.edu
David Pinto carandraug+dev@gmail.com
Davide Canova kc.canova@gmail.com
Dawson Engler engler@stanford.edu
Dean Gaudet dean-savannah@arctic.org
@@ -188,6 +190,7 @@ Eivind eivindt@multinet.no
Elbert Pol elbert.pol@gmail.com
Eldon Stegall eldon@eldondev.com
Eli Zaretskii eliz@is.elta.co.il
Emanuel Landeholm emanuel.landeholm@gmail.com
Emile LeBlanc leblanc@math.toronto.edu
Emmanuel Lacour elacour@home-dn.net
Eric Backus ericb@lsid.hp.com
@@ -209,6 +212,7 @@ Francesco Montorsi fr_m@hotmail.com
François Pinard pinard@iro.umontreal.ca
François Rigault rigault.francois@gmail.com
Frank Adler fadler@allesklar.de
Frank Busse f.busse@imperial.ac.uk
Frank T Lofaro ftlofaro@snooks.Egr.UNLV.EDU
Fred Fish fnf@ninemoons.com
Frédéric L. W. Meunier 0@pervalidus.net
@@ -228,13 +232,13 @@ Gerald Pfeifer gerald@pfeifer.com
Gerhard Poul gpoul@gnu.org
Germano Leichsenring germano@jedi.cs.kobe-u.ac.jp
Glen Lenker glen.lenker@gmail.com
Glenn Golden gdg@zplane.com
GOTO Masanori gotom@debian.or.jp
Greg Louis glouis@dynamicro.on.ca
Greg McGary gkm@gnu.org
Greg Metcalfe metcalfegreg@qwest.net
Greg Schafer gschafer@zip.com.au
Greg Troxel gdt@bbn.com
Greg Wooledge gawooledge@sherwin.com
Gregory Leblanc gleblanc@cu-portland.edu
Guido Leenders guido.leenders@invantive.com
Guntram Blohm Extern.Guntram.Blohm@AUDI.DE
@@ -408,6 +412,7 @@ Marty Leisner leisner@sdsp.mc.xerox.com
Masami Takikawa takikawm@CS.ORST.EDU
Mate Wierdl mw@moni.msci.memphis.edu
Matej Vela mvela@public.srce.hr
Matheus Afonso Martins Moreira matheus.a.m.moreira@gmail.com
Mathias Brodala info@noctus.net
Matias A. Fonzo selk@dragora.org
Matt Kraai kraai@ftbfs.org
@@ -562,7 +567,6 @@ Rudolf Kastl rkastl@redhat.com
Sahil Amoli sahilamoli@gmail.com
Sami Farin sfarin@ratol.fi
Samuel Neves sneves@dei.uc.pt
Samuel Tardieu sam@rfc1149.net
Samuel Thibault samuel.thibault@ens-lyon.org
Samuli Karkkainen Samuli.Karkkainen@hut.fi
Sander van Malssen svm@kozmix.ow.nl
@@ -631,7 +635,7 @@ Tony Leneis tony@plaza.ds.adp.com
Tony Robinson ajr@eng.cam.ac.uk
Toomas Soome Toomas.Soome@Elion.ee
Toralf Förster toralf.foerster@gmx.de
Torbjorn Lindgren tl@funcom.no
Torbjörn Lindgren tl@funcom.no
Torsten Landschoff torsten@pclab.ifg.uni-kiel.de
Travis Gummels tgummels@redhat.com
Tristan Miller psychonaut@nothingisreal.com

6
TODO
View File

@@ -18,7 +18,7 @@ document the following in coreutils.texi:
Suggestion from Paul Eggert:
More generally, there's not that much use for imaxtostr nowadays,
since the inttypes module and newer versions of gettext allow things
like _("truncating %s at %" PRIdMAX " bytes") to work portably.
like _("truncating %s at %jd bytes") to work portably.
I suspect that (if someone cares to take the time) we can remove
all instances of imaxtostr and umaxtostr in coreutils and gnulib.
@@ -49,7 +49,7 @@ no longer incurs the overhead of saving src. dev/ino and dest. filename
in the hash table.
Write an autoconf test to work around build failure in HPUX's 64-bit mode.
See notes in README -- and remove them once there's a work-around.
See notes in README-install -- and remove them once there's a work-around.
Integrate use of sendfile, suggested here:
https://lists.gnu.org/r/bug-fileutils/2003-03/msg00030.html
@@ -143,7 +143,7 @@ pr's use of nstrftime can make it malloc a very large (up to SIZE_MAX) buffer
-----
Copyright (C) 2002-2022 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

1961
bootstrap

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
# Bootstrap configuration.
# Copyright (C) 2006-2022 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
@@ -20,14 +20,17 @@
avoided_gnulib_modules='
--avoid=canonicalize-lgpl
--avoid=dummy
--avoid=mbuiter
--avoid=mbuiterf
'
# gnulib modules used by this package.
gnulib_modules="
$avoided_gnulib_modules
acl
acl-permissions
alignalloc
alignof
alignasof
alloca
announce-gen
areadlink-with-size
@@ -35,30 +38,34 @@ gnulib_modules="
argmatch
argv-iter
assert
assert-h
assure
attribute
autobuild
backupfile
backup-rename
backupfile
base32
base64
btowc
bool
btoc32
buffer-lcm
byteswap
c-strcase
cl-strtod
cl-strtold
calloc-gnu
c32iscntrl
c32isspace
c32width
canon-host
canonicalize
chmodat
chown
chownat
cloexec
cl-strtod
cl-strtold
closein
closeout
config-h
configmake
copy-file-range
crc-x86_64
crypto/md5
crypto/sha1
crypto/sha256
@@ -71,8 +78,10 @@ gnulib_modules="
dirfd
dirname
do-release-commit-and-tag
dtimespec-bound
dtoastr
dup2
endian
environ
error
euidaccess
@@ -101,6 +110,8 @@ gnulib_modules="
fnmatch-gnu
fopen-safer
fprintftime
fpurge
free-posix
freopen
freopen-safer
fseeko
@@ -112,7 +123,6 @@ gnulib_modules="
fts
full-read
full-write
getgroups
gethrxtime
getline
getloadavg
@@ -120,19 +130,14 @@ gnulib_modules="
getndelim2
getopt-gnu
getpagesize
getpass-gnu
gettext-h
gettime
gettime-res
getugroups
getusershell
git-version-gen
gitlog-to-changelog
gnu-make
gnu-web-doc-update
gnumakefile
gnupload
group-member
hard-locale
hash
hash-triple
@@ -143,13 +148,12 @@ gnulib_modules="
idx
ignore-value
inttostr
inttypes
inttypes-h
isapipe
isatty
isblank
largefile
lchmod
lchown
ldtoastr
lib-ignore
libgmp
@@ -163,18 +167,19 @@ gnulib_modules="
malloc-gnu
manywarnings
mbrlen
mbrtoc32
mbrtowc
mbsalign
mbschr
mbslen
mbswidth
mbszero
mcel-prefer
memcasecmp
memchr
memcmp2
mempcpy
memrchr
minmax
mgetgroups
mkancesdirs
mkdir
mkdir-p
@@ -188,9 +193,9 @@ gnulib_modules="
modechange
mountlist
mpsort
netinet_in
nproc
nstrftime
nullptr
obstack
open
openat-safer
@@ -206,31 +211,27 @@ gnulib_modules="
posixver
priv-set
progname
propername
propername-lite
pthread-cond
pthread-mutex
pthread-thread
pthread_sigmask
putenv
putenv-gnu
quote
quotearg
randint
randperm
rawmemchr
read-file
readlink
readtokens
readtokens0
readutmp
realloc-gnu
regex
remove
rename
renameat
renameatu
rmdir
root-dev-ino
rpmatch
safe-read
same
save-cwd
@@ -242,33 +243,37 @@ gnulib_modules="
settime
sig2str
sigaction
skipchars
smack
ssize_t
stat-macros
stat-size
stat-time
stdbool
stdc_leading_zeros
stdc_trailing_zeros
stdckdint-h
stdlib-safer
stpcpy
stpncpy
str_endswith
strdup-posix
strncat
strnlen
strnumcmp
strsignal
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
tzset
tmpdir
uname
unicodeio
unistd-safer
@@ -278,7 +283,6 @@ gnulib_modules="
unlocked-io
unsetenv
update-copyright
uptime
useless-if-before-free
userspec
utimecmp
@@ -289,9 +293,6 @@ gnulib_modules="
verify
verror
version-etc-fsf
wchar-single
wcswidth
wcwidth
winsz-ioctl
winsz-termios
write-any-file
@@ -314,7 +315,8 @@ gnulib_modules="
xstrtol-error
xstrtold
xstrtoumax
year2038
xvasprintf
year2038-recommended
yesno
"
@@ -343,7 +345,7 @@ see_manual='"This is a proper name. See the gettext manual, section Names."'
see_manual=\'"$see_manual"\'
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
--keyword=proper_name:1,'"$see_manual"'\\\
--keyword=proper_name_utf8:1,'"$see_manual"'\\\
--keyword=proper_name_lite:1,'"$see_manual"'\\\
'
gnulib_tool_option_extras="--tests-base=gnulib-tests --with-tests --symlink\
@@ -360,11 +362,13 @@ gettext 0.19.2
git 1.4.4
gperf -
gzip -
m4 -
makeinfo 6.1
texi2pdf 6.1
patch -
perl 5.5
rsync -
tar -
wget -
xz -
"
@@ -387,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
}

View File

@@ -33,7 +33,6 @@ build_if_possible_progs='
stdbuf
stty
timeout
uptime
users
who
'
@@ -132,6 +131,7 @@ normal_progs='
unexpand
uniq
unlink
uptime
vdir
wc
whoami

View File

@@ -41,7 +41,7 @@ done
# Load actual values from src/local.mk. This will read all the variables from
# the local.mk matching the src_${cmd}_... case.
while read l; do
if echo "$l" | grep -E '^src_\w+ +\+?=' > /dev/null; then
if echo "$l" | grep -E '^src_[_[:alnum:]]+ +\+?=' > /dev/null; then
var=$(echo $l | cut -f 1 -d ' ')
value=$(echo $l | cut -f 2- -d =)
if [ "$value" != " \$(LDADD)" ]; then
@@ -71,6 +71,7 @@ override_single() {
override_single dir ls
override_single vdir ls
override_single arch uname
override_single chgrp chown
for cmd in $ALL_PROGRAMS; do
echo "# Command $cmd"

171
cfg.mk
View File

@@ -1,5 +1,5 @@
# Customize maint.mk -*- makefile -*-
# Copyright (C) 2003-2022 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
@@ -26,7 +26,6 @@ VC_LIST_ALWAYS_EXCLUDE_REGEX = src/blake2/.*$$
# Tests not to run as part of "make distcheck".
local-checks-to-skip = \
sc_proper_name_utf8_requires_ICONV \
sc_indent
# Tools used to bootstrap this package, used for "announcement".
@@ -49,14 +48,20 @@ export VERBOSE = yes
# 4914152 9e
export XZ_OPT = -8e
old_NEWS_hash = 612bad626bf28b1847ad0114cb2cd6fe
old_NEWS_hash = be5016485c56f34b60ba4e6d3b407489
# Add an exemption for sc_makefile_at_at_check.
_makefile_at_at_check_exceptions = ' && !/^cu_install_prog/ && !/dynamic-dep/'
_makefile_at_at_check_exceptions = \
' && !/MAKEINFO/ && !/^cu_install_prog/ && !/dynamic-dep/'
# 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:
@@ -76,8 +81,8 @@ sc_dd_O_FLAGS:
dd_c = $(srcdir)/src/dd.c
sc_dd_max_sym_length:
ifneq ($(wildcard $(dd_c)),)
@len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
@len=$$( (sed -n '/conversions\[] =$$/,/^};/p' $(dd_c);\
sed -n '/flags\[] =$$/,/^};/p' $(dd_c) ) \
|sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p'| wc -L);\
max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
|tr -d '"' | wc -L); \
@@ -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$$' \
| $(EGREP) "$$test_extensions_rx\$$"; \
| grep -E "($$test_extensions_rx)$$"; \
} | sort | uniq -u | grep . && exit 1; :
# Ensure that all version-controlled test scripts are executable.
@@ -189,12 +194,15 @@ sc_prohibit_quotes_notation:
exit 1; } \
|| :
error_fns = (error|diagnose)
# Files in src/ should quote all strings in error() output, so that
# unexpected input chars like \r etc. don't corrupt the error.
# In edge cases this can be avoided by putting the format string
# on a separate line to the arguments, or the arguments in parenthesis.
sc_error_quotes:
@cd $(srcdir)/src && GIT_PAGER= git grep -n 'error *(.*%s.*, [^(]*);$$'\
@cd $(srcdir)/src \
&& GIT_PAGER= git grep -E -n '$(error_fns) *\(.*%s.*, [^(]*\);$$' \
*.c | grep -v ', q' \
&& { echo '$(ME): '"Use quote() for error string arguments" 1>&2; \
exit 1; } \
@@ -206,7 +214,7 @@ sc_error_quotes:
sc_error_shell_quotes:
@cd $(srcdir)/src && \
{ GIT_PAGER= git grep -E \
'error \(.*%s[:"], .*(name|file)[^"]*\);$$' *.c; \
'$(error_fns) \(.*%s[:"], .*(name|file)[^"]*\);$$' *.c; \
GIT_PAGER= git grep -E \
' quote[ _].*file' *.c; } \
| grep -Ev '(quotef|q[^ ]*name)' \
@@ -220,27 +228,17 @@ sc_error_shell_quotes:
# to provide better support for copy and paste.
sc_error_shell_always_quotes:
@cd $(srcdir)/src && GIT_PAGER= git grep -E \
'error \(.*[^:] %s[ "].*, .*(name|file)[^"]*\);$$' \
'$(error_fns) \(.*[^:] %s[ "].*, .*(name|file)[^"]*\);$$' \
*.c | grep -Ev '(quoteaf|q[^ ]*name)' \
&& { echo '$(ME): '"Use quoteaf() for space delimited names" 1>&2; \
exit 1; } \
|| :
@cd $(srcdir)/src && GIT_PAGER= git grep -E -A1 \
'error \([^%]*[^:] %s[ "]' *.c | grep 'quotef' \
'$(error_fns) \([^%]*[^:] %s[ "]' *.c | grep 'quotef' \
&& { echo '$(ME): '"Use quoteaf() for space delimited names" 1>&2; \
exit 1; } \
|| :
# Usage of error() with an exit constant, should instead use die(),
# as that avoids warnings and may generate better code, due to being apparent
# to the compiler that it doesn't return.
sc_die_EXIT_FAILURE:
@cd $(srcdir)/src && GIT_PAGER= git grep -E \
'error \([^?]*EXIT_' \
&& { echo '$(ME): '"Use die() instead of error" 1>&2; \
exit 1; } \
|| :
# Avoid unstyled quoting to internal slots and thus destined for diagnostics
# as that can leak unescaped control characters to the output, when using
# the default "literal" quoting style.
@@ -295,27 +293,6 @@ sc_check-AUTHORS: $(all_programs)
&& diff $(au_actual) $(au_dotdot) \
&& rm -f $(au_actual) $(au_dotdot)
# Each program with a non-ASCII author name must link with LIBICONV.
sc_check-I18N-AUTHORS:
@cd $(srcdir)/src && \
for i in $$(git grep -l -w proper_name_utf8 *.c|sed 's/\.c//'); do \
grep -E "^src_$${i}_LDADD"' .?= .*\$$\(LIBICONV\)' local.mk \
> /dev/null \
|| { echo "$(ME): link rules for $$i do not include" \
'$$(LIBICONV)' 1>&2; exit 1; }; \
done
# Disallow the C99 printf size specifiers %z and %j as they're not portable.
# The gnulib printf replacement does support them, however the printf
# replacement is not currently explicitly depended on by the gnulib error()
# module for example. Also we use fprintf() in a few places to output simple
# formats but don't use the gnulib module as it is seen as overkill at present.
# We'd have to adjust the above gnulib items before disabling this.
sc_prohibit-c99-printf-format:
@cd $(srcdir)/src && GIT_PAGER= git grep -n '%[0*]*[jz][udx]' *.c \
&& { echo '$(ME): Use PRI*MAX instead of %j or %z' 1>&2; exit 1; } \
|| :
# Ensure the alternative __attribute (keyword) form isn't used as
# that form is not elided where required. Also ensure that we don't
# directly use attributes already defined by gnulib.
@@ -343,7 +320,7 @@ FILTER_LONG_LINES = \
\|^[^:]*NEWS:.*https\{,1\}://| d; \
\|^[^:]*doc/fdl.texi:| d; \
\|^[^:]*man/help2man:| d; \
\|^[^:]*tests/misc/sha[0-9]*sum.*\.pl[-:]| d; \
\|^[^:]*tests/cksum/sha[0-9]*sum.*\.pl[-:]| d; \
\|^[^:]*tests/pr/|{ \|^[^:]*tests/pr/pr-tests:| !d; };
sc_long_lines:
@wc -L /dev/null >/dev/null 2>/dev/null \
@@ -366,6 +343,11 @@ sc_option_desc_uppercase: $(ALL_MANS)
@grep '^\\fB\\-' -A1 man/*.1 | LC_ALL=C grep '\.1.[A-Z][a-z]' \
&& { echo 1>&2 '$@: found initial capitals in --help'; exit 1; } || :
# '--' should not be treated as '' (U+2013 EN DASH) in long option names.
sc_texi_long_option_escaped: doc/coreutils.info
@grep ' [^ ]' '$<' \
&& { echo 1>&2 '$@: found unquoted --long-option'; exit 1; } || :
# Ensure all man/*.[1x] files are present.
sc_man_file_correlation: check-x-vs-1 check-programs-vs-x
@@ -441,9 +423,13 @@ sc_prohibit_operator_at_end_of_line:
halt='found operator at end of line' \
$(_sc_search_regexp)
# Partial substitutes for GNU extensions \< and \> in regexps.
begword = (^|[^_[:alnum:]])
endword = ($$|[^_[:alnum:]])
# Don't use address of "stat" or "lstat" functions
sc_prohibit_stat_macro_address:
@prohibit='\<l?stat '':|&l?stat\>' \
@prohibit='$(begword)l?stat '':|&l?stat$(endword)' \
halt='stat() and lstat() may be function-like macros' \
$(_sc_search_regexp)
@@ -496,10 +482,28 @@ sc_ensure_comma_after_id_est:
# a period. Check the first line after each "SEE ALSO" line in man/*.x:
sc_prohibit_man_see_also_period:
@grep -nB1 '\.$$' $$($(VC_LIST_EXCEPT) | grep 'man/.*\.x$$') \
| grep -A1 -e '-\[SEE ALSO\]' | grep '\.$$' && \
| grep -A1 -e '-\[SEE ALSO]' | grep '\.$$' && \
{ echo '$(ME): do not end "SEE ALSO" section with a period' \
1>&2; exit 1; } || :
sc_prohibit_exit_write_error:
@prohibit='error.*EXIT_FAILURE.*write error' \
in_vc_files='\.c$$' \
halt='Use write_error() instead' \
$(_sc_search_regexp)
sc_prohibit_NULL:
@prohibit='$(begword)NULL$(endword)' \
in_vc_files='\.[ch]$$' \
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:' \
@@ -508,7 +512,7 @@ sc_prohibit_emacs__indent_tabs_mode__setting:
# Ensure that tests don't include a redundant fail=0.
sc_prohibit_fail_0:
@prohibit='\<fail=0\>' \
@prohibit='$(begword)fail=0$(endword)' \
halt='fail=0 initialization' \
$(_sc_search_regexp)
@@ -545,14 +549,14 @@ sc_prohibit_env_returns:
# setfacl reject it with: "Unrecognized character found in mode field".
# Use hyphens to give it a length of 3: "...:rw-" or "...:r--".
sc_prohibit_short_facl_mode_spec:
@prohibit='\<setfacl .*-m.*:.*:[rwx-]{1,2} ' \
@prohibit='$(begword)setfacl .*-m.*:.*:[rwx-]{1,2} ' \
halt='setfacl mode string length < 3; extend with hyphen(s)' \
$(_sc_search_regexp)
# Ensure that "stdio--.h" is used where appropriate.
sc_require_stdio_safer:
@if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
files=$$(grep -l '\bfreopen \?(' $$($(VC_LIST_EXCEPT) \
files=$$(grep -El '$(begword)freopen ?\(' $$($(VC_LIST_EXCEPT)\
| grep '\.[ch]$$')); \
test -n "$$files" && grep -LE 'include "stdio--.h"' $$files \
| grep . && \
@@ -561,6 +565,18 @@ sc_require_stdio_safer:
else :; \
fi
# Ensure that "stdlib--.h" is used where appropriate.
sc_require_stdlib_safer:
@if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
files=$$(grep -El '$(begword)mkstemp ?\(' $$($(VC_LIST_EXCEPT)\
| grep '\.[ch]$$')); \
test -n "$$files" && grep -LE 'include "stdlib--.h"' $$files \
| grep . && \
{ echo '$(ME): the above files should use "stdlib--.h"' \
1>&2; exit 1; } || :; \
else :; \
fi
sc_prohibit_perl_hash_quotes:
@prohibit="\{'[A-Z_]+' *[=}]" \
halt="in Perl code, write \$$hash{KEY}, not \$$hash{'K''EY'}" \
@@ -568,7 +584,7 @@ sc_prohibit_perl_hash_quotes:
# Prefer xnanosleep over other less-precise sleep methods
sc_prohibit_sleep:
@prohibit='\<(nano|u)?sleep \(' \
@prohibit='$(begword)(nano|u)?sleep \(' \
halt='prefer xnanosleep over other sleep interfaces' \
$(_sc_search_regexp)
@@ -587,14 +603,14 @@ sc_env_test_dependencies:
grep -vF '[' |paste -d'|' -s))" tests | \
sed "s/\([^:]\):.*env \([^)' ]*\).*/\1 \2/" | uniq | \
while read test prog; do \
printf '%s' $$test | grep -q '\.pl$$' && continue; \
grep -q "print_ver_.* $$prog" $$test \
printf '%s' $$test | grep '\.pl$$' >/dev/null && continue; \
grep "print_ver_.* $$prog" $$test >/dev/null \
|| echo $$test should call: print_ver_ $$prog; \
done | grep . && exit 1 || :
# Use framework_failure_, not the old name without the trailing underscore.
sc_prohibit_framework_failure:
@prohibit='\<framework_''failure\>' \
@prohibit='$(begword)framework_''failure$(endword)' \
halt='use framework_failure_ instead' \
$(_sc_search_regexp)
@@ -617,7 +633,8 @@ sc_prohibit_test_empty:
sc_some_programs_must_avoid_exit_failure:
@cd $(srcdir) \
&& grep -nw EXIT_FAILURE \
$$(git grep -El '[^T]_FAILURE|EXIT_CANCELED' $(srcdir)/src) \
$$(git grep -El '[^T]_FAILURE|EXIT_CANCELED' src/) \
| grep -v '^src/system\.h:' \
| grep -vE '= EXIT_FAILURE|return .* \?' | grep . \
&& { echo '$(ME): do not use EXIT_FAILURE in the above' \
1>&2; exit 1; } || :
@@ -645,7 +662,7 @@ sc_prohibit_test_calls_print_ver_with_irrelevant_argument:
while read file name; do \
for i in $$name; do \
case "$$i" in install) i=ginstall;; esac; \
grep -w "$$i" $$file|grep -vw print_ver_|grep -q . \
grep -w "$$i" $$file|grep -vw print_ver_|grep . >/dev/null \
|| { fail=1; \
echo "*** Test: $$file, offending: $$i." 1>&2; };\
done; \
@@ -778,7 +795,7 @@ sc_THANKS_in_sorted:
# Look for developer diagnostics that are marked for translation.
# This won't find any for which devmsg's format string is on a separate line.
sc_marked_devdiagnostics:
@prohibit='\<devmsg *\(.*_\(' \
@prohibit='$(begword)devmsg *\(.*_\(' \
halt='found marked developer diagnostic(s)' \
$(_sc_search_regexp)
@@ -808,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]$$' \
@@ -833,9 +865,10 @@ exclude_file_name_regexp--sc_bindtextdomain = \
exclude_file_name_regexp--sc_trailing_blank = \
^(tests/pr/|gl/.*\.diff$$|man/help2man)
exclude_file_name_regexp--sc_system_h_headers = \
^src/((die|system|copy|chown-core|find-mount-point)\.h|make-prime-list\.c)$$
^src/((system|copy|chown-core|find-mount-point)\.h|make-prime-list\.c)$$
_src = (crctab|false|lbracket|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
_src := (false|lbracket|chown-(chgrp|chown)
_src := $(_src)|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
_gl_src = (xdecto.max|cl-strtold)
exclude_file_name_regexp--sc_require_config_h_first = \
(^lib/buffer-lcm\.c|gl/lib/$(_gl_src)\.c|src/$(_src)\.c)$$
@@ -854,7 +887,7 @@ exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
^m4/stat-prog\.m4$$
exclude_file_name_regexp--sc_prohibit_fail_0 = \
(^.*/git-hooks/commit-msg|^tests/init\.sh|Makefile\.am|\.mk|.*\.texi)$$
exclude_file_name_regexp--sc_prohibit_test_minus_ao = *\.texi$$
exclude_file_name_regexp--sc_prohibit_test_minus_ao = doc/.*\.texi$$
exclude_file_name_regexp--sc_prohibit_atoi_atof = ^lib/euidaccess-stat\.c$$
# longlong.h is maintained elsewhere.
@@ -876,8 +909,9 @@ exclude_file_name_regexp--sc_prohibit_stat_st_blocks = \
exclude_file_name_regexp--sc_prohibit_continued_string_alpha_in_column_1 = \
^src/(system\.h|od\.c|printf\.c|getlimits\.c)$$
_cksum = ^tests/cksum/cksum-base64\.pl$$
exclude_file_name_regexp--sc_prohibit_test_backticks = \
^tests/(local\.mk|(init|misc/stdbuf|factor/create-test)\.sh)$$
^tests/(local\.mk|(init|misc/stdbuf|factor/create-test)\.sh)$$|$(_cksum)
# Exempt test.c, since it's nominally shared, and relatively static.
exclude_file_name_regexp--sc_prohibit_operator_at_end_of_line = \
@@ -892,7 +926,11 @@ 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)
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
exclude_file_name_regexp--sc_unportable_grep_q = NEWS
# Augment AM_CFLAGS to include our per-directory options:
AM_CFLAGS += $($(@D)_CFLAGS)
@@ -911,10 +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_.*
# 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-2022 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
@@ -55,14 +55,34 @@ gl_ASSERT_NO_GNULIB_POSIXCHECK])
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_GCC_TRADITIONAL
AC_PROG_RANLIB
AC_PROG_EGREP
AC_PROG_LN_S
gl_EARLY
gl_SET_CRYPTO_CHECK_DEFAULT([auto-gpl-compat])
gl_INIT
coreutils_MACROS
# These are safe, since 'sort', coreutils's only multithreaded app,
# does not use the relevant modules.
AC_DEFINE([GNULIB_EXCLUDE_SINGLE_THREAD], [1],
[Define to 1 if apps call 'exclude' functions from a single thread.])
AC_DEFINE([GNULIB_REGEX_SINGLE_THREAD], [1],
[Define to 1 if apps call 'regex' functions from a single thread.])
# Although 'sort' is multithreaded and can use these functions,
# it uses them only from the main thread.
AC_DEFINE([GNULIB_MBRTOWC_SINGLE_THREAD], [1],
[Define to 1 if apps call mbrtowc, mbrtoc32, and 'regex' functions
from a single thread.])
# This is safe, since all apps set locale early.
AC_DEFINE([GNULIB_WCHAR_SINGLE_LOCALE], [1],
[Define to 1 if apps don't set the locale after calling
locale-sensitive functions like mbrtowc and wcwidth.])
AC_DEFINE([GNULIB_MBRTOC32_REGULAR], [1],
[Do not worry about rare encodings like CP864, EBCDIC, Johab, and Shift JIS
that glibc does not support.])
# The test suite needs to know if we have a working perl.
AM_CONDITIONAL([HAVE_PERL], [test "$gl_cv_prog_perl" != no])
@@ -152,6 +172,13 @@ AC_ARG_ENABLE([gcc-warnings],
&& gl_gcc_warnings=yes])]
)
# clang is unduly picky about some things, even by default.
if test "$gl_cv_compiler_clang" = yes; then
gl_WARN_ADD([-Wno-format-extra-args])
gl_WARN_ADD([-Wno-implicit-const-int-float-conversion])
gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
fi
if test $gl_gcc_warnings != no; then
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
AC_SUBST([WERROR_CFLAGS])
@@ -159,8 +186,7 @@ if test $gl_gcc_warnings != no; then
ew=
AS_IF([test $gl_gcc_warnings != expensive],
[# -fanalyzer and related options slow GCC considerably.
ew="$ew -fanalyzer -Wno-analyzer-double-free -Wno-analyzer-malloc-leak"
ew="$ew -Wno-analyzer-null-dereference -Wno-analyzer-use-after-free"])
ew="$ew -fanalyzer -Wno-analyzer-malloc-leak"])
# This, $nw, is the list of warnings we disable.
nw=$ew
@@ -172,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
@@ -180,10 +205,8 @@ 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 80776
nw="$nw -Wformat-overflow=2" # False alarms due to GCC bug 110333
nw="$nw -Wformat-truncation=2" # False alarm in ls.c, probably related
# things I might fix soon:
nw="$nw -Wfloat-equal" # sort.c, seq.c
@@ -205,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])
@@ -213,21 +237,6 @@ if test $gl_gcc_warnings != no; then
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
gl_WARN_ADD([-Wno-format-nonliteral])
# clang is unduly picky about some things.
AC_CACHE_CHECK([whether the compiler is clang], [utils_cv_clang],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[
#ifndef __clang__
#error "not clang"
#endif
]])],
[utils_cv_clang=yes],
[utils_cv_clang=no])])
if test $utils_cv_clang = yes; then
gl_WARN_ADD([-Wno-format-extra-args])
gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
fi
gl_WARN_ADD([-fdiagnostics-show-option])
gl_WARN_ADD([-funit-at-a-time])
@@ -248,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"
@@ -261,6 +271,10 @@ if test $gl_gcc_warnings != no; then
# FP in careadlinkat.c w/gcc 10.0.1 20200205
gl_WARN_ADD([-Wno-return-local-addr])
# FIXME: remove this line when gcc improves
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
gl_WARN_ADD([-Wno-stringop-overflow])
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
AC_SUBST([GNULIB_WARN_CFLAGS])
@@ -268,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"
@@ -336,6 +351,51 @@ if test $utils_cv_localtime_cache = yes; then
AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
fi
# Find the library for dynamic loading of shared libraries.
AC_SEARCH_LIBS([dlopen], [dl])
AS_CASE([$ac_cv_search_dlopen],
[no | 'none required'],
[LIB_DL=],
[*],
[LIB_DL="$ac_cv_search_dlopen"])
AC_SUBST([LIB_DL])
# Should 'sort' link libcrypto dynamically?
AS_CASE([$LIB_CRYPTO],
[-lcrypto],
[# 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_libcrypto_soname],
[utils_cv_libcrypto_soname=no
saved_LIBS=$LIBS
LIBS="$LIBS $LIB_DL $LIB_CRYPTO"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <dlfcn.h>
#include <openssl/sha.h>
/* Use SHA512 rather than MD5 here to avoid deprecation warnings.
So need to check HAVE_OPENSSL_MD5.. with DLOPEN_LIBCRYPTO. */
]],
[[return !(dlopen ("libcrypto.so", RTLD_LAZY | RTLD_GLOBAL)
&& SHA512 (0, 0, 0));]])],
[# readelf works with cross-builds; ldd works on more platforms.
LIBCRYPTO_SONAME="`(readelf -d conftest$EXEEXT || ldd conftest$EXEEXT
) 2>/dev/null |
sed -n 's/.*\(libcrypto\.so\.[[.0-9]]*\).*/\1/p'`"
AS_CASE([$LIBCRYPTO_SONAME],
[*libcrypto*],
[utils_cv_libcrypto_soname=$LIBCRYPTO_SONAME])])
LIBS=$saved_LIBS])
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], ["$utils_cv_libcrypto_soname"],
[versioned libcrypto])
])])
# macOS >= 10.12
AC_CHECK_FUNCS([fclonefileat])
@@ -402,38 +462,6 @@ AC_DEFUN([coreutils_DUMMY_1],
])
coreutils_DUMMY_1
AC_MSG_CHECKING([ut_host in struct utmp])
AC_CACHE_VAL([su_cv_func_ut_host_in_utmp],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <utmp.h>
struct utmp ut;
int s = sizeof ut.ut_host;]])],
[su_cv_func_ut_host_in_utmp=yes],
[su_cv_func_ut_host_in_utmp=no])])
AC_MSG_RESULT([$su_cv_func_ut_host_in_utmp])
if test $su_cv_func_ut_host_in_utmp = yes; then
have_ut_host=1
AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
fi
if test -z "$have_ut_host"; then
AC_MSG_CHECKING([ut_host in struct utmpx])
AC_CACHE_VAL([su_cv_func_ut_host_in_utmpx],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <utmpx.h>
struct utmpx ut;
int s = sizeof ut.ut_host;]])],
[su_cv_func_ut_host_in_utmpx=yes],
[su_cv_func_ut_host_in_utmpx=no])])
AC_MSG_RESULT([$su_cv_func_ut_host_in_utmpx])
if test $su_cv_func_ut_host_in_utmpx = yes; then
AC_DEFINE([HAVE_UTMPX_H], [1], [FIXME])
AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
fi
fi
GNULIB_BOOT_TIME([gl_ADD_PROG([optional_bin_progs], [uptime])])
AC_SYS_POSIX_TERMIOS()
gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
@@ -499,11 +527,6 @@ if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
[Define if your system defines TIOCGWINSZ in sys/pty.h.])
fi
# For src/kill.c.
AC_CHECK_DECLS([strsignal, sys_siglist, _sys_siglist, __sys_siglist], , ,
[AC_INCLUDES_DEFAULT
#include <signal.h>])
# Build df only if there's a point to it.
if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
gl_ADD_PROG([optional_bin_progs], [df])
@@ -521,7 +544,8 @@ gl_WARN_ADD([-errwarn], [CFLAGS])
AC_MSG_CHECKING([whether this system supports stdbuf])
CFLAGS="-fPIC $CFLAGS"
LDFLAGS="-shared $LDFLAGS"
stdbuf_supported=no
AC_CACHE_VAL([utils_cv_stdbuf_supported],[
utils_cv_stdbuf_supported=no
# Note we only LINK here rather than RUN to support cross compilation
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[
@@ -535,40 +559,103 @@ AC_LINK_IFELSE(
if (stdbuf != 1)
return 1;]])
],
[stdbuf_supported=yes])
AC_MSG_RESULT([$stdbuf_supported])
if test "$stdbuf_supported" = "yes" && test -z "$EXEEXT"; then
[utils_cv_stdbuf_supported=yes])])
AC_MSG_RESULT([$utils_cv_stdbuf_supported])
if test "$utils_cv_stdbuf_supported" = "yes" && test -z "$EXEEXT"; then
gl_ADD_PROG([optional_bin_progs], [stdbuf])
fi
CFLAGS=$ac_save_CFLAGS
LDFLAGS=$ac_save_LDFLAGS
ac_c_werror_flag=$cu_save_c_werror_flag
AC_MSG_CHECKING([if __get_cpuid available])
# Test compiler support for half precision floating point types (for od)
AC_MSG_CHECKING([IEEE 16 bit floating point])
AC_CACHE_VAL([utils_cv_ieee_16_bit_supported],[
AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
int
main (void)
{
volatile _Float16 hf = 1;
float f = hf; /* Ensure compiler can promote to float. */
return !(f == 1.0f);
}
]])
],[
utils_cv_ieee_16_bit_supported=yes
],[
utils_cv_ieee_16_bit_supported=no
],[
utils_cv_ieee_16_bit_supported=no
])])
AC_MSG_RESULT([$utils_cv_ieee_16_bit_supported])
if test $utils_cv_ieee_16_bit_supported = yes; then
AC_DEFINE([FLOAT16_SUPPORTED], [1], [IEEE 16 bit float supported])
fi
AC_MSG_CHECKING([Brain 16 bit floating point])
AC_CACHE_VAL([utils_cv_brain_16_bit_supported],[
AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
int
main (void)
{
volatile __bf16 hf = 1;
float f = hf; /* Ensure compiler can promote to float. */
return !(f == 1.0f);
}
]])
],[
utils_cv_brain_16_bit_supported=yes
],[
utils_cv_brain_16_bit_supported=no
],[
utils_cv_brain_16_bit_supported=no
])])
AC_MSG_RESULT([$utils_cv_brain_16_bit_supported])
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 <cpuid.h>
#include <stdio.h>
#include <sys/auxv.h>
#include <asm/hwcap.h>
#include <arm_neon.h>
int
main (void)
{
unsigned int eax, ebx, ecx, edx;
__get_cpuid (1, &eax, &ebx, &ecx, &edx);
return 1;
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;
}
]])
],[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_CPUID], [1], [__get_cpuid available])
cpuid_exists=yes
utils_cv_vmull_intrinsic_exists=yes
],[
AC_MSG_RESULT([no])
])
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])
AC_COMPILE_IFELSE(
AC_CACHE_VAL([utils_cv_pclmul_intrinsic_exists],[
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <x86intrin.h>
@@ -577,49 +664,29 @@ AC_COMPILE_IFELSE(
{
__m128i a, b;
a = _mm_clmulepi64_si128 (a, b, 0x00);
return 1;
a = _mm_shuffle_epi8 (a, b);
return __builtin_cpu_supports ("pclmul");
}
]])
],[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_PCLMUL_INTRINSIC], [1], [pclmul intrinsic exists])
pclmul_intrinsic_exists=yes
utils_cv_pclmul_intrinsic_exists=yes
],[
AC_MSG_RESULT([no])
])
if test "x$cpuid_exists" = "xyes" &&
test "x$pclmul_intrinsic_exists" = "xyes"; then
utils_cv_pclmul_intrinsic_exists=no
])])
AC_MSG_RESULT([$utils_cv_pclmul_intrinsic_exists])
if test $utils_cv_pclmul_intrinsic_exists = yes; then
AC_DEFINE([USE_PCLMUL_CRC32], [1],
[CRC32 calculation by pclmul hardware instruction enabled])
fi
AM_CONDITIONAL([USE_PCLMUL_CRC32],
[test "x$cpuid_exists" = "xyes" &&
test "x$pclmul_intrinsic_exists" = "xyes"])
[test $utils_cv_pclmul_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
AC_MSG_CHECKING([if __get_cpuid_count exists])
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 <cpuid.h>
int
main (void)
{
unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx);
return 1;
}
]])
],[
AC_MSG_RESULT([yes])
get_cpuid_count_exists=yes
],[
AC_MSG_RESULT([no])
])
CFLAGS="-mavx2 $CFLAGS"
AC_MSG_CHECKING([if avx2 intrinstics exists])
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([[
#include <x86intrin.h>
@@ -627,24 +694,89 @@ AC_COMPILE_IFELSE(
main (void)
{
__m256i a, b;
a = _mm256_sad_epu8 (a, b);
return 1;
a = _mm256_clmulepi64_epi128 (a, b, 0x00);
a = _mm256_shuffle_epi8 (a, b);
return __builtin_cpu_supports ("avx2") &&
__builtin_cpu_supports ("vpclmulqdq");
}
]])
],[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_AVX2_INTRINSIC], [1], [avx2 intrinsics exists])
avx2_intrinsic_exists=yes
utils_cv_avx2_pclmul_intrinsic_exists=yes
],[
AC_MSG_RESULT([no])
])
if test "x$get_cpuid_count_exists" = "xyes" &&
test "x$avx2_intrinsic_exists" = "xyes"; then
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],[
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <x86intrin.h>
int
main (void)
{
__m256i matches = _mm256_setzero_si256 ();
int mask = _mm256_movemask_epi8 (matches);
int lines = __builtin_popcount (mask);
return __builtin_cpu_supports ("avx2");
}
]])
],[
utils_cv_avx2_intrinsic_exists=yes
],[
utils_cv_avx2_intrinsic_exists=no
])])
AC_MSG_RESULT([$utils_cv_avx2_intrinsic_exists])
if test $utils_cv_avx2_intrinsic_exists = yes; then
AC_DEFINE([USE_AVX2_WC_LINECOUNT], [1], [Counting lines with AVX2 enabled])
fi
AM_CONDITIONAL([USE_AVX2_WC_LINECOUNT],
[test "x$get_cpuid_count_exists" = "xyes" &&
test "x$avx2_intrinsic_exists" = "xyes"])
[test $utils_cv_avx2_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
# Make coreutils documentation. -*-Makefile-*-
# This is included by the top-level Makefile.am.
# Copyright (C) 1995-2022 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
@@ -25,6 +25,10 @@ doc_coreutils_TEXINFOS = \
doc/fdl.texi \
doc/sort-version.texi
# The customization variable CHECK_NORMAL_MENU_STRUCTURE is necessary with
# makeinfo versions ≥ 6.8.
MAKEINFO = @MAKEINFO@ -c CHECK_NORMAL_MENU_STRUCTURE=1
# The following is necessary if the package name is 8 characters or longer.
# If the info documentation would be split into 10 or more separate files,
# then this is necessary even if the package name is 7 characters long.

View File

@@ -1,6 +1,6 @@
@c File mode bits
@c Copyright (C) 1994--2022 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--2022 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
@@ -296,7 +296,7 @@ example in @ref{Version-sort ordering rules}).
Comparing the string @samp{8.1} to @samp{8.01}, first the
@samp{8}s are compared (and are identical), then the
dots (@samp{.}) are compared and are identical, and lastly the
remaining digits are compared numerically (@samp{1} and @samp{01}) -
remaining digits are compared numerically (@samp{1} and @samp{01}) --
which are numerically equal. Hence, @samp{8.01} and @samp{8.1}
are grouped together.
@@ -587,6 +587,8 @@ ASCII letter or tilde, followed by zero or more ASCII letters, digits,
or tildes; all repeated zero or more times, and ending at string end.
This is equivalent to matching the extended regular expression
@code{(\.[A-Za-z~][A-Za-z0-9~]*)*$} in the C locale.
The longest such match is used, except that a suffix is not
allowed to match an entire nonempty string.
@item
The suffixes are temporarily removed, and the strings are compared
@@ -683,7 +685,7 @@ empty @r{vs} .txt
@end example
The comparison of the third parts (@samp{.} vs
@samp{.txt}) will determine that the shorter string comes first -
@samp{.txt}) will determine that the shorter string comes first --
resulting in @file{hello-8.2.txt} appearing first.
Indeed this is the order in which Debian's @command{dpkg} compares the strings.
@@ -841,7 +843,7 @@ natsort -- how it works}).
Ruby's @uref{https://github.com/github/version_sorter,version_sorter}.
@item
Perl has multiple packages for natual and version sorts
Perl has multiple packages for natural and version sorts
(each likely with its own rules and nuances):
@uref{https://metacpan.org/pod/Sort::Naturally,Sort::Naturally},
@uref{https://metacpan.org/pod/Sort::Versions,Sort::Versions},
@@ -862,9 +864,9 @@ glob modifier} @samp{*(n)} will expand to files in natural sort order.
@item
When writing C programs, the GNU libc library (@samp{glibc})
provides the
@uref{http://man7.org/linux/man-pages/man3/strverscmp.3.html,
strvercmp(3)} function to compare two strings, and
@uref{http://man7.org/linux/man-pages/man3/versionsort.3.html,versionsort(3)}
@uref{https://man7.org/linux/man-pages/man3/strverscmp.3.html,
strverscmp(3)} function to compare two strings, and
@uref{https://man7.org/linux/man-pages/man3/versionsort.3.html,versionsort(3)}
function to compare two directory entries (despite the names, they are
not identical to GNU Coreutils version sort ordering).

View File

@@ -1,6 +1,6 @@
/* buffer-lcm.c - compute a good buffer size for dealing with two files
Copyright (C) 2002-2022 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-2022 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
@@ -46,7 +46,7 @@
Parse the initial prefix of NPTR as a floating-point number in the
current locale or in the C locale (preferring the locale that
yields the longer parse, or the current locale if there is a tie).
If ENDPTR is not NULL, set *ENDPTR to the first unused byte, or to
If ENDPTR is non-null, set *ENDPTR to the first unused byte, or to
NPTR if the prefix cannot be parsed.
If successful, return a number without changing errno.

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-2022 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
@@ -14,12 +14,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Without this pragma, gcc suggests that (given !HAVE_POSIX_FADVISE)
the fdadvise function might be a candidate for attribute 'const'. */
#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
#endif
#include <config.h>
#include "fadvise.h"

View File

@@ -1,5 +1,5 @@
/* Declare an access pattern hint for files.
Copyright (C) 2010-2022 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
@@ -14,7 +14,6 @@
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 <stdio.h>
#include <fcntl.h>
#include <sys/types.h>

View File

@@ -1,6 +1,6 @@
/* Invoke open, but return either a desired file descriptor or -1.
Copyright (C) 2005-2022 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-2022 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-2022 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);
@@ -50,7 +50,7 @@ heap_alloc (int (*compare) (void const *, void const *), size_t n_reserve)
heap->array = xnmalloc (n_reserve, sizeof *(heap->array));
heap->array[0] = NULL;
heap->array[0] = nullptr;
heap->capacity = n_reserve;
heap->count = 0;
heap->compare = compare ? compare : heap_default_compare;
@@ -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);
@@ -96,7 +96,7 @@ heap_remove_top (struct heap *heap)
void *top;
if (heap->count == 0)
return NULL;
return nullptr;
top = heap->array[1];
heap->array[1] = heap->array[heap->count--];
@@ -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-2022 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,276 +0,0 @@
/* Align/Truncate a string in a given screen width
Copyright (C) 2009-2022 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 Pádraig Brady. */
#include <config.h>
#include "mbsalign.h"
#include "minmax.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <wchar.h>
#include <wctype.h>
/* Replace non printable chars.
Note \t and \n etc. are non printable.
Return 1 if replacement made, 0 otherwise. */
static bool
wc_ensure_printable (wchar_t *wchars)
{
bool replaced = false;
wchar_t *wc = wchars;
while (*wc)
{
if (!iswprint ((wint_t) *wc))
{
*wc = 0xFFFD; /* L'\uFFFD' (replacement char) */
replaced = true;
}
wc++;
}
return replaced;
}
/* Truncate wchar string to width cells.
* Returns number of cells used. */
static size_t
wc_truncate (wchar_t *wc, size_t width)
{
size_t cells = 0;
int next_cells = 0;
while (*wc)
{
next_cells = wcwidth (*wc);
if (next_cells == -1) /* non printable */
{
*wc = 0xFFFD; /* L'\uFFFD' (replacement char) */
next_cells = 1;
}
if (cells + next_cells > width)
break;
cells += next_cells;
wc++;
}
*wc = L'\0';
return cells;
}
/* Write N_SPACES space characters to DEST while ensuring
nothing is written beyond DEST_END. A terminating NUL
is always added to DEST.
A pointer to the terminating NUL is returned. */
static char *
mbs_align_pad (char *dest, char const *dest_end, size_t n_spaces)
{
/* FIXME: Should we pad with "figure space" (\u2007)
if non ascii data present? */
while (n_spaces-- && (dest < dest_end))
*dest++ = ' ';
*dest = '\0';
return dest;
}
/* Align a string, SRC, in a field of *WIDTH columns, handling multi-byte
characters; write the result into the DEST_SIZE-byte buffer, DEST.
ALIGNMENT specifies whether to left- or right-justify or to center.
If SRC requires more than *WIDTH columns, truncate it to fit.
When centering, the number of trailing spaces may be one less than the
number of leading spaces.
Return the length in bytes required for the final result, not counting
the trailing NUL. A return value of DEST_SIZE or larger means there
wasn't enough space. DEST will be NUL terminated in any case.
Return SIZE_MAX upon error (invalid multi-byte sequence in SRC,
or malloc failure), unless MBA_UNIBYTE_FALLBACK is specified.
Update *WIDTH to indicate how many columns were used before padding. */
size_t
mbsalign (char const *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags)
{
size_t ret = SIZE_MAX;
size_t src_size = strlen (src) + 1;
char *newstr = NULL;
wchar_t *str_wc = NULL;
char const *str_to_print = src;
size_t n_cols = src_size - 1;
size_t n_used_bytes = n_cols; /* Not including NUL */
size_t n_spaces = 0;
bool conversion = false;
bool wc_enabled = false;
/* In multi-byte locales convert to wide characters
to allow easy truncation. Also determine number
of screen columns used. */
if (!(flags & MBA_UNIBYTE_ONLY) && MB_CUR_MAX > 1)
{
size_t src_chars = mbstowcs (NULL, src, 0);
if (src_chars == SIZE_MAX)
{
if (flags & MBA_UNIBYTE_FALLBACK)
goto mbsalign_unibyte;
else
goto mbsalign_cleanup;
}
src_chars += 1; /* make space for NUL */
str_wc = malloc (src_chars * sizeof (wchar_t));
if (str_wc == NULL)
{
if (flags & MBA_UNIBYTE_FALLBACK)
goto mbsalign_unibyte;
else
goto mbsalign_cleanup;
}
if (mbstowcs (str_wc, src, src_chars) != 0)
{
str_wc[src_chars - 1] = L'\0';
wc_enabled = true;
conversion = wc_ensure_printable (str_wc);
n_cols = wcswidth (str_wc, src_chars);
}
}
/* If we transformed or need to truncate the source string
then create a modified copy of it. */
if (wc_enabled && (conversion || (n_cols > *width)))
{
if (conversion)
{
/* May have increased the size by converting
\t to \uFFFD for example. */
src_size = wcstombs (NULL, str_wc, 0) + 1;
}
newstr = malloc (src_size);
if (newstr == NULL)
{
if (flags & MBA_UNIBYTE_FALLBACK)
goto mbsalign_unibyte;
else
goto mbsalign_cleanup;
}
str_to_print = newstr;
n_cols = wc_truncate (str_wc, *width);
n_used_bytes = wcstombs (newstr, str_wc, src_size);
}
mbsalign_unibyte:
if (n_cols > *width) /* Unibyte truncation required. */
{
n_cols = *width;
n_used_bytes = n_cols;
}
if (*width > n_cols) /* Padding required. */
n_spaces = *width - n_cols;
/* indicate to caller how many cells needed (not including padding). */
*width = n_cols;
{
size_t start_spaces, end_spaces;
switch (align)
{
case MBS_ALIGN_LEFT:
start_spaces = 0;
end_spaces = n_spaces;
break;
case MBS_ALIGN_RIGHT:
start_spaces = n_spaces;
end_spaces = 0;
break;
case MBS_ALIGN_CENTER:
default:
start_spaces = n_spaces / 2 + n_spaces % 2;
end_spaces = n_spaces / 2;
break;
}
if (flags & MBA_NO_LEFT_PAD)
start_spaces = 0;
if (flags & MBA_NO_RIGHT_PAD)
end_spaces = 0;
/* Write as much NUL terminated output to DEST as possible. */
if (dest_size != 0)
{
size_t space_left;
char *dest_end = dest + dest_size - 1;
dest = mbs_align_pad (dest, dest_end, start_spaces);
space_left = dest_end - dest;
dest = mempcpy (dest, str_to_print, MIN (n_used_bytes, space_left));
mbs_align_pad (dest, dest_end, end_spaces);
}
/* indicate to caller how many bytes needed (not including NUL). */
ret = n_used_bytes + ((start_spaces + end_spaces) * 1);
}
mbsalign_cleanup:
free (str_wc);
free (newstr);
return ret;
}
/* A wrapper around mbsalign() to dynamically allocate the
minimum amount of memory to store the result.
Return NULL on failure. */
char *
ambsalign (char const *src, size_t *width, mbs_align_t align, int flags)
{
size_t orig_width = *width;
size_t size = *width; /* Start with enough for unibyte mode. */
size_t req = size;
char *buf = NULL;
while (req >= size)
{
char *nbuf;
size = req + 1; /* Space for NUL. */
nbuf = realloc (buf, size);
if (nbuf == NULL)
{
free (buf);
buf = NULL;
break;
}
buf = nbuf;
*width = orig_width;
req = mbsalign (src, buf, size, width, align, flags);
if (req == SIZE_MAX)
{
free (buf);
buf = NULL;
break;
}
}
return buf;
}

View File

@@ -1,63 +0,0 @@
/* Align/Truncate a string in a given screen width
Copyright (C) 2009-2022 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 <stddef.h>
#include <stdlib.h>
typedef enum { MBS_ALIGN_LEFT, MBS_ALIGN_RIGHT, MBS_ALIGN_CENTER } mbs_align_t;
enum {
/* Use unibyte mode for invalid multibyte strings
or when heap memory is exhausted. */
MBA_UNIBYTE_FALLBACK = 0x0001,
/* As an optimization, don't do multibyte processing
when we know no multibyte characters are present. */
MBA_UNIBYTE_ONLY = 0x0002,
/* Don't add leading padding. */
MBA_NO_LEFT_PAD = 0x0004,
/* Don't add trailing padding. */
MBA_NO_RIGHT_PAD = 0x0008
#if 0 /* Other possible options. */
/* Skip invalid multibyte chars rather than failing. */
MBA_IGNORE_INVALID
/* Align multibyte strings using "figure space" (\u2007). */
MBA_USE_FIGURE_SPACE
/* Don't truncate. */
MBA_NO_TRUNCATE
/* Ensure no leading whitespace. */
MBA_LSTRIP
/* Ensure no trailing whitespace. */
MBA_RSTRIP
#endif
};
size_t
mbsalign (char const *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags)
_GL_ATTRIBUTE_NONNULL ();
char *
ambsalign (char const *src, size_t *width, mbs_align_t align, int flags)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
_GL_ATTRIBUTE_NONNULL ();

View File

@@ -1,6 +1,6 @@
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
Copyright (C) 1999-2022 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
@@ -25,7 +25,7 @@
* so I can be a little bit experimental in the choice of RNGs here.
*
* This generator is based somewhat on RC4, but has analysis
* <http://burtleburtle.net/bob/rand/isaacafa.html>
* <https://burtleburtle.net/bob/rand/isaacafa.html>
* pointing to it actually being better. I like it because it's nice
* and fast, and because the author did good work analyzing it.
* --------------------------------------------------------------------

View File

@@ -1,6 +1,6 @@
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
Copyright (C) 1999-2022 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-2022 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
@@ -35,13 +35,13 @@ int
main (int argc, char **argv)
{
randint i;
randint n = strtoumax (argv[1], NULL, 10);
randint choices = strtoumax (argv[2], NULL, 10);
randint n = strtoumax (argv[1], nullptr, 10);
randint choices = strtoumax (argv[2], nullptr, 10);
char const *name = argv[3];
struct randint_source *ints = randint_all_new (name, SIZE_MAX);
for (i = 0; i < n; i++)
printf ("%"PRIuMAX"\n", randint_choose (ints, choices));
printf ("%ju\n", randint_choose (ints, choices));
return (randint_all_free (ints) == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
@@ -77,14 +77,14 @@ randint_new (struct randread_source *source)
}
/* Create a new randint_source by creating a randread_source from
NAME and ESTIMATED_BYTES. Return NULL (setting errno) if
NAME and ESTIMATED_BYTES. Return nullptr (setting errno) if
unsuccessful. */
struct randint_source *
randint_all_new (char const *name, size_t bytes_bound)
{
struct randread_source *source = randread_new (name, bytes_bound);
return (source ? randint_new (source) : NULL);
return (source ? randint_new (source) : nullptr);
}
/* Return the random data source of *S. */

View File

@@ -1,6 +1,6 @@
/* Generate random integers.
Copyright (C) 2006-2022 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-2022 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,29 +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 "verify.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)
{
verify (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. */
@@ -54,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;
}
@@ -110,7 +98,7 @@ typedef Hash_table sparse_map;
static sparse_map *
sparse_new (size_t size_hint)
{
return hash_initialize (size_hint, NULL, sparse_hash_, sparse_cmp_, free);
return hash_initialize (size_hint, nullptr, sparse_hash_, sparse_cmp_, free);
}
/* Swap the values for I and J. If a value is not already present
@@ -155,7 +143,7 @@ sparse_free (sparse_map *sv)
/* From R, allocate and return a malloc'd array of the first H elements
of a random permutation of N elements. H must not exceed N.
Return NULL if H is zero. */
Return nullptr if H is zero. */
size_t *
randperm_new (struct randint_source *r, size_t h, size_t n)
@@ -165,7 +153,7 @@ randperm_new (struct randint_source *r, size_t h, size_t n)
switch (h)
{
case 0:
v = NULL;
v = nullptr;
break;
case 1:
@@ -210,13 +198,13 @@ randperm_new (struct randint_source *r, size_t h, size_t n)
if (sparse)
{
sv = sparse_new (h * 2);
if (sv == NULL)
if (sv == nullptr)
xalloc_die ();
v = xnmalloc (h, sizeof *v);
}
else
{
sv = NULL; /* To placate GCC's -Wuninitialized. */
sv = nullptr; /* To placate GCC's -Wuninitialized. */
v = xnmalloc (n, sizeof *v);
for (i = 0; i < n; i++)
v[i] = i;

View File

@@ -1,6 +1,6 @@
/* Generate buffers of random data.
Copyright (C) 2006-2022 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
@@ -29,8 +29,6 @@
#include <exitfail.h>
#include <fcntl.h>
#include <quote.h>
#include <stdalign.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -40,6 +38,7 @@
#include "gettext.h"
#define _(msgid) gettext (msgid)
#include "assure.h"
#include "minmax.h"
#include "rand-isaac.h"
#include "stdio-safer.h"
@@ -47,9 +46,9 @@
#include "xalloc.h"
#if _STRING_ARCH_unaligned || _STRING_INLINE_unaligned
# define ALIGNED_POINTER(ptr, type) true
# define POINTER_IS_ALIGNED(ptr, type) true
#else
# define ALIGNED_POINTER(ptr, type) ((size_t) (ptr) % alignof (type) == 0)
# define POINTER_IS_ALIGNED(ptr, type) ((size_t) (ptr) % alignof (type) == 0)
#endif
/* The maximum buffer size used for reads of random data. Using the
@@ -105,11 +104,10 @@ struct randread_source
static void
randread_error (void const *file_name)
{
if (file_name)
error (exit_failure, errno,
errno == 0 ? _("%s: end of file") : _("%s: read error"),
quote (file_name));
abort ();
affirm (exit_failure);
error (exit_failure, errno,
errno == 0 ? _("%s: end of file") : _("%s: read error"),
quote (file_name));
}
/* Simply return a new randread_source object with the default error
@@ -134,7 +132,13 @@ get_nonce (void *buffer, size_t bufsize)
char *buf = buffer, *buflim = buf + bufsize;
while (buf < buflim)
{
ssize_t nbytes = getrandom (buf, buflim - buf, 0);
#if defined __sun
# define MAX_GETRANDOM 1024
#else
# define MAX_GETRANDOM SIZE_MAX
#endif
size_t max_bytes = MIN (buflim - buf, MAX_GETRANDOM);
ssize_t nbytes = getrandom (buf, max_bytes, 0);
if (0 <= nbytes)
buf += nbytes;
else if (errno != EINTR)
@@ -163,21 +167,21 @@ randread_free_body (struct randread_source *s)
default handler. Unless a non-default handler is used, NAME's
lifetime should be at least that of the returned value.
Return NULL (setting errno) on failure. */
Return nullptr (setting errno) on failure. */
struct randread_source *
randread_new (char const *name, size_t bytes_bound)
{
if (bytes_bound == 0)
return simple_new (NULL, NULL);
return simple_new (nullptr, nullptr);
else
{
FILE *source = NULL;
FILE *source = nullptr;
struct randread_source *s;
if (name)
if (! (source = fopen_safer (name, "rb")))
return NULL;
return nullptr;
s = simple_new (source, name);
@@ -185,14 +189,24 @@ 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);
errno = e;
return NULL;
return nullptr;
}
isaac_seed (&s->buf.isaac.state);
}
@@ -267,7 +281,7 @@ readisaac (struct isaac *isaac, void *p, size_t size)
/* If P is aligned, write to *P directly to avoid the overhead
of copying from the buffer. */
if (ALIGNED_POINTER (p, isaac_word))
if (POINTER_IS_ALIGNED (p, isaac_word))
{
isaac_word *wp = p;
while (ISAAC_BYTES <= size)

View File

@@ -1,6 +1,6 @@
/* Generate buffers of random data.
Copyright (C) 2006-2022 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-2022 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
@@ -23,14 +23,14 @@
#include <stdlib.h>
/* Call lstat to get the device and inode numbers for '/'.
Upon failure, return NULL. Otherwise, set the members of
Upon failure, return nullptr. Otherwise, set the members of
*ROOT_D_I accordingly and return ROOT_D_I. */
struct dev_ino *
get_root_dev_ino (struct dev_ino *root_d_i)
{
struct stat statbuf;
if (lstat ("/", &statbuf))
return NULL;
return nullptr;
root_d_i->st_ino = statbuf.st_ino;
root_d_i->st_dev = statbuf.st_dev;
return root_d_i;

View File

@@ -1,6 +1,6 @@
/* Root device and inode number checking.
Copyright (C) 2003-2022 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
@@ -28,7 +28,7 @@ get_root_dev_ino (struct dev_ino *root_d_i) _GL_ATTRIBUTE_NONNULL ();
--preserve-root and --no-preserve-root options. */
# define ROOT_DEV_INO_CHECK(Root_dev_ino, Dir_statbuf) \
(Root_dev_ino && SAME_INODE (*Dir_statbuf, *Root_dev_ino))
(Root_dev_ino && PSAME_INODE (Dir_statbuf, Root_dev_ino))
# define ROOT_DEV_INO_WARN(Dirname) \
do \

3
gl/lib/skipchars.c Normal file
View File

@@ -0,0 +1,3 @@
#include <config.h>
#define SKIPCHARS_INLINE _GL_EXTERN_INLINE
#include <skipchars.h>

56
gl/lib/skipchars.h Normal file
View File

@@ -0,0 +1,56 @@
/* Skipping sequences of characters satisfying a predicate
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
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 "mcel.h"
_GL_INLINE_HEADER_BEGIN
#ifndef SKIPCHARS_INLINE
# define SKIPCHARS_INLINE _GL_INLINE
#endif
/* Return the address just past the leading sequence of possibly
multi-byte characters or encoding errors G in STR that satisfy
PREDICATE (G) if OK is true, or that do not satisfy the predicate
call if OK is false. */
SKIPCHARS_INLINE char *
skip_str_matching (char const *str, bool (*predicate) (mcel_t), bool ok)
{
char const *s = str;
for (mcel_t g; *s && predicate (g = mcel_scanz (s)) == ok;
s += g.len)
continue;
return (char *) s;
}
/* Return the address just past the leading sequence of possibly
multi-byte characters or encoding errors G in BUF (which ends at LIM)
that satisfy PREDICATE (G) if OK is true, or that do not satisfy
the predicate call if OK is false. */
SKIPCHARS_INLINE char *
skip_buf_matching (char const *buf, char const *lim,
bool (*predicate) (mcel_t), bool ok)
{
char const *s = buf;
for (mcel_t g; s < lim && predicate (g = mcel_scan (s, lim)) == ok;
s += g.len)
continue;
return (char *) s;
}
_GL_INLINE_HEADER_END

View File

@@ -1,5 +1,5 @@
/* Include and determine availability of smack routines
Copyright (C) 2013-2022 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
@@ -17,8 +17,6 @@
/* Here we replace or wrap the most common smack functions used by coreutils.
Others will need to be protected by HAVE_SMACK. */
#include <config.h>
#ifdef HAVE_SMACK
# include <sys/smack.h>
#else
@@ -39,7 +37,7 @@ static inline bool
is_smack_enabled (void)
{
#ifdef HAVE_SMACK
return smack_smackfs_path () != NULL;
return smack_smackfs_path () != nullptr;
#else
return false;
#endif

View File

@@ -1,6 +1,6 @@
/* Compare integer strings.
Copyright (C) 2005-2022 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-2022 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;
}
@@ -114,8 +105,8 @@ static inline int _GL_ATTRIBUTE_PURE
numcompare (char const *a, char const *b,
int decimal_point, int thousands_sep)
{
unsigned char tmpa = *a;
unsigned char tmpb = *b;
char tmpa = *a;
char tmpb = *b;
int tmp;
size_t log_a;
size_t log_b;
@@ -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-2022 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-2022 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 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
@@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <fcntl.h>
#include <stdbool.h>
#include <sys/stat.h>
#ifndef _GL_INLINE_HEADER_BEGIN

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-2022 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,59 +21,66 @@
#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include "error.h"
#include "quote.h"
#include "verify.h"
#include "xstrtol.h"
#include <error.h>
#include <quote.h>
#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, NULL, 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));
assume (false);
}
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.
@@ -85,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-2022 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-2022 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
@@ -19,11 +19,10 @@
#include <config.h>
#include <stdbool.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
#include "assure.h"
#include "xalloc.h"
#include "xfts.h"
@@ -34,11 +33,11 @@ xfts_open (char * const *argv, int options,
int (*compar) (const FTSENT **, const FTSENT **))
{
FTS *fts = fts_open (argv, options | FTS_CWDFD, compar);
if (fts == NULL)
if (fts == nullptr)
{
/* This can fail in two ways: out of memory or with errno==EINVAL,
which indicates it was called with invalid bit_flags. */
assert (errno != EINVAL);
affirm (errno != EINVAL);
xalloc_die ();
}

View File

@@ -1,4 +1,3 @@
#include <stdbool.h>
#include "fts_.h"
FTS *

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

@@ -1,28 +0,0 @@
Description:
Align/Truncate a string in a given screen width.
Files:
lib/mbsalign.c
lib/mbsalign.h
Depends-on:
minmax
wchar
wctype
wcwidth
mempcpy
stdint
configure.ac:
Makefile.am:
lib_SOURCES += mbsalign.c mbsalign.h
Include:
"mbsalign.h"
License:
LGPL
Maintainer:
Pádraig Brady

View File

@@ -1,11 +0,0 @@
Files:
tests/test-mbsalign.c
tests/macros.h
Depends-on:
configure.ac:
Makefile.am:
TESTS += test-mbsalign
check_PROGRAMS += test-mbsalign

View File

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

View File

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

24
gl/modules/skipchars Normal file
View File

@@ -0,0 +1,24 @@
Description:
Skip sequences of multi-byte characters or encoding errors
Files:
lib/skipchars.c
lib/skipchars.h
Depends-on:
extern-inline
mcel
configure.ac:
Makefile.am:
lib_SOURCES += skipchars.c
Include:
"skipchars.h"
License:
GPL
Maintainer:
all

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-2022 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
@@ -36,7 +36,7 @@ main (void)
fdadvise (fileno (stdin), 0, 0, FADVISE_RANDOM);
/* Ignored. */
fadvise (NULL, FADVISE_RANDOM);
fadvise (nullptr, FADVISE_RANDOM);
/* Invalid. */
fdadvise (42, 0, 0, FADVISE_RANDOM);

View File

@@ -1,138 +0,0 @@
/* Test that mbsalign works as advertised.
Copyright (C) 2010-2022 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 Pádraig Brady. */
#include <config.h>
#include "mbsalign.h"
#include "macros.h"
#include <stdlib.h>
#include <locale.h>
int
main (void)
{
char dest[4 * 16 + 1];
size_t width, n;
/* Test unibyte truncation. */
width = 4;
n = mbsalign ("t\tés", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
ASSERT (n == 4);
/* Test center alignment. */
width = 4;
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER, 0);
ASSERT (*dest == ' ' && *(dest + n - 1) == ' ');
ASSERT (n == 4);
/* Test center alignment, with no trailing padding. */
width = 4;
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER,
MBA_NO_RIGHT_PAD);
ASSERT (n == 3);
ASSERT (*dest == ' ' && *(dest + n - 1) == 's');
/* Test left alignment, with no trailing padding. (truncate only). */
width = 4;
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_LEFT,
MBA_NO_RIGHT_PAD);
ASSERT (n == 2);
ASSERT (*dest == 'e' && *(dest + n - 1) == 's');
/* Test center alignment, with no padding. (truncate only). */
width = 4;
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER,
MBA_NO_LEFT_PAD | MBA_NO_RIGHT_PAD);
ASSERT (n == 2);
ASSERT (*dest == 'e' && *(dest + n - 1) == 's');
/* Test center alignment, with no left padding. (may be useful for RTL?) */
width = 4;
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER,
MBA_NO_LEFT_PAD);
ASSERT (n == 3);
ASSERT (*dest == 'e' && *(dest + n - 1) == ' ');
if (setlocale (LC_ALL, "en_US.UTF8"))
{
/* Check invalid input is flagged. */
width = 4;
n = mbsalign ("t\xe1\xe2s", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
ASSERT (n == (size_t) -1);
/* Check invalid input is treated as unibyte */
width = 4;
n = mbsalign ("t\xe1\xe2s", dest, sizeof dest, &width,
MBS_ALIGN_LEFT, MBA_UNIBYTE_FALLBACK);
ASSERT (n == 4);
/* Test multibyte center alignment. */
width = 4;
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_CENTER, 0);
ASSERT (n == 5);
ASSERT (*dest == ' ' && *(dest + n - 1) == ' ');
/* Test multibyte left alignment. */
width = 4;
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
ASSERT (n == 5);
ASSERT (*(dest + n - 1) == ' ' && *(dest + n - 2) == ' ');
/* Test multibyte right alignment. */
width = 4;
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_RIGHT, 0);
ASSERT (n == 5);
ASSERT (*(dest) == ' ' && *(dest + 1) == ' ');
/* multibyte multicell truncation. */
width = 4; /* cells */
n = mbsalign ("日月火水", dest, sizeof dest, &width,
MBS_ALIGN_LEFT, 0);
ASSERT (n == 6); /* 2 characters */
/* multibyte unicell truncation. */
width = 3; /* cells */
n = mbsalign ("¹²³⁴", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
ASSERT (n == 6); /* 3 characters */
/* Check independence from dest buffer. */
width = 4; /* cells */
n = mbsalign ("¹²³⁴", dest, 0, &width, MBS_ALIGN_LEFT, 0);
ASSERT (n == 9); /* 4 characters */
/* Check that width is updated with cells required before padding. */
width = 4; /* cells */
n = mbsalign ("¹²³", dest, 0, &width, MBS_ALIGN_LEFT, 0);
ASSERT (width == 3);
/* Test case where output is larger than input
(as tab converted to multi byte replacement char). */
width = 4;
n = mbsalign ("t\tés" /* 6 including NUL */ , dest, sizeof dest,
&width, MBS_ALIGN_LEFT, 0);
ASSERT (n == 7);
/* Test forced unibyte truncation. */
width = 4;
n = mbsalign ("t\tés", dest, sizeof dest, &width, MBS_ALIGN_LEFT,
MBA_UNIBYTE_ONLY);
ASSERT (n == 4);
}
return 0;
}

View File

@@ -1,6 +1,6 @@
/* Test the ISAAC or ISAAC64 pseudorandom number generator.
Copyright (C) 2010-2022 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
@@ -28,7 +28,7 @@
#include "macros.h"
/* This expected output was generated by running the programs in
<http://burtleburtle.net/bob/rand/isaacafa.html>, as last modified
<https://burtleburtle.net/bob/rand/isaacafa.html>, as last modified
on 2010-01-22. The 32-bit numbers were output by rand.c, and the
64-bit by isaac64.c, both on x86, as those programs are not
portable to 64-bit platforms. */
@@ -581,7 +581,7 @@ main (int argc, char **argv)
/* If invoked with a positive argument, run a benchmark;
if with a negative, run a do-nothing benchmark. */
for (iterations = argc <= 1 ? 0 : strtol (argv[1], NULL, 10);
for (iterations = argc <= 1 ? 0 : strtol (argv[1], nullptr, 10);
iterations != 0;
iterations += (iterations < 0 ? 1 : -1))
if (0 <= iterations)

2
gnulib

Submodule gnulib updated: 58c597d13b...41e7b7e0d1

View File

@@ -1,6 +1,6 @@
# This file is sourced by init.sh, *before* its initialization.
# Copyright (C) 2010-2022 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
@@ -275,7 +291,7 @@ require_valgrind_()
# If the given ACL spec would not change the ACLs on the file, then setfacl
# does not invoke the underlying system call - setxattr(). Therefore, to test
# if setting ACLs really works on the current file system, call setfacl twice
# with conflictive ACL specs.
# with conflicting ACL specs.
require_setfacl_()
{
local d='acltestdir_'
@@ -488,7 +504,19 @@ require_membership_in_two_groups_()
{
test $# = 0 || framework_failure_
groups=${COREUTILS_GROUPS-$( (id -G || /usr/xpg4/bin/id -G) 2>/dev/null)}
groups=
for group_ in 1 \
${COREUTILS_GROUPS-$( (id -G || /usr/xpg4/bin/id -G) 2>/dev/null)}
do
# Skip group numbers equal to 2**N - 1 for common N,
# as they are possibly reserved groups like 'nogroup'.
case $group_ in
1 | 32767 | 65535 | 2147483647 | 4294967295) ;;
9223372036854775807 | 18446744073709551615) ;;
*) test -z "$groups" || groups="$groups "
groups="$groups$group_";;
esac
done
case "$groups" in
*' '*) ;;
*) skip_ 'requires membership in two groups
@@ -527,13 +555,25 @@ require_trap_signame_()
# dash 0.5.8 at least does not.
require_kill_group_()
{
kill -0 -- -1 || skip_ 'requires kill with group signalling support'
kill -0 -- -1 || skip_ 'requires kill with group signaling support'
}
# Return nonzero if the specified path is on a file system for
# which SEEK_DATA support exists.
seek_data_capable_()
{
# Check that SEEK_HOLE support is enabled
# Note APFS was seen to not create sparse files < 16MiB
if ! truncate -s16M file.sparse_; then
warn_ "can't create a sparse file: assuming not SEEK_DATA capable"
return 1
fi
if ! cp --debug --reflink=never file.sparse_ file.sparse_.cp \
| grep SEEK_HOLE; then
return 1
fi
# Check that SEEK_HOLE is supported on the passed file
{ python3 < /dev/null && PYTHON_=python3; } ||
{ python < /dev/null && PYTHON_=python; }
@@ -546,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 "$@"
}
@@ -591,7 +631,7 @@ gcc_shared_libs_=
# Compile a shared lib using the GCC options for doing so.
# Pass input and output file as parameters respectively.
# Any other optional parmeters are passed to $CC.
# Any other optional parameters are passed to $CC.
gcc_shared_()
{
local in=$1
@@ -636,7 +676,10 @@ mkfifo_or_skip_()
trap_sigpipe_or_skip_()
{
(trap '' PIPE && yes | :) 2>&1 | grep -qF 'Broken pipe' ||
timeout 1 true >/dev/null ||
skip_ 'trapping SIGPIPE cannot be safely checked'
(trap '' PIPE && timeout 10 yes |:) 2>&1 | grep 'Broken pipe' >/dev/null ||
skip_ 'trapping SIGPIPE is not supported'
}

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise chdir-long's sample main program.
# Copyright (C) 2005-2022 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,66 +0,0 @@
# boottime.m4 serial 4
# Determine whether this system has infrastructure for obtaining the boot time.
# Copyright (C) 1996-2022 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/>.
# GNULIB_BOOT_TIME([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
* ----------------------------------------------------------
AC_DEFUN([GNULIB_BOOT_TIME],
[
AC_CHECK_FUNCS([sysctl])
AC_CHECK_HEADERS_ONCE([sys/param.h])
AC_CHECK_HEADERS([sys/sysctl.h], [], [],
[AC_INCLUDES_DEFAULT
[#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif]])
AC_CHECK_HEADERS_ONCE([utmp.h utmpx.h OS.h])
AC_CACHE_CHECK(
[whether we can get the system boot time],
[gnulib_cv_have_boot_time],
[
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[AC_INCLUDES_DEFAULT
#if HAVE_SYSCTL && HAVE_SYS_SYSCTL_H
# if HAVE_SYS_PARAM_H
# include <sys/param.h> /* needed for OpenBSD 3.0 */
# endif
# include <sys/sysctl.h>
#endif
#if HAVE_UTMPX_H
# include <utmpx.h>
#elif HAVE_UTMP_H
# include <utmp.h>
#endif
#if HAVE_OS_H
# include <OS.h>
#endif
],
[[
#if (defined BOOT_TIME \
|| (defined CTL_KERN && defined KERN_BOOTTIME) \
|| HAVE_OS_H)
/* your system *does* have the infrastructure to determine boot time */
#else
please_tell_us_how_to_determine_boot_time_on_your_system
#endif
]])],
[gnulib_cv_have_boot_time=yes],
[gnulib_cv_have_boot_time=no])
])
AS_IF([test $gnulib_cv_have_boot_time = yes], [$1], [$2])
])

View File

@@ -1,7 +1,7 @@
#serial 27
# Check declarations for this package.
dnl Copyright (C) 1997-2022 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-2022 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 114 -*- autoconf -*-
#serial 116 -*- autoconf -*-
dnl Misc type-related macros for coreutils.
# Copyright (C) 1998-2022 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
@@ -67,16 +67,11 @@ AC_DEFUN([coreutils_MACROS],
fallocate
fchown
fchmod
ftruncate
iswspace
mkfifo
mbrlen
setgroups
sethostname
siginterrupt
sync
syncfs
sysctl
sysinfo
tcgetpgrp
])
@@ -94,22 +89,6 @@ AC_DEFUN([coreutils_MACROS],
dnl This can't use AC_REQUIRE; I'm not quite sure why.
cu_PREREQ_STAT_PROG
# for dd.c and shred.c
#
# Use fdatasync only if declared. On MacOS X 10.7, fdatasync exists but
# is not declared, and is ineffective.
LIB_FDATASYNC=
AC_SUBST([LIB_FDATASYNC])
AC_CHECK_DECLS_ONCE([fdatasync])
if test $ac_cv_have_decl_fdatasync = yes; then
coreutils_saved_libs=$LIBS
AC_SEARCH_LIBS([fdatasync], [rt posix4],
[test "$ac_cv_search_fdatasync" = "none required" ||
LIB_FDATASYNC=$ac_cv_search_fdatasync])
AC_CHECK_FUNCS([fdatasync])
LIBS=$coreutils_saved_libs
fi
# Check whether libcap is usable -- for ls --color support
LIB_CAP=
AC_ARG_ENABLE([libcap],
@@ -236,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-2022 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-2022 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,43 +0,0 @@
# xattr.m4 - check for Extended Attributes (Linux)
# serial 4
# Copyright (C) 2003-2022 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# Originally written by Andreas Gruenbacher.
AC_DEFUN([gl_FUNC_XATTR],
[
AC_ARG_ENABLE([xattr],
AS_HELP_STRING([--disable-xattr],
[do not support extended attributes]),
[use_xattr=$enableval], [use_xattr=yes])
LIB_XATTR=
AC_SUBST([LIB_XATTR])
if test "$use_xattr" = "yes"; then
AC_CHECK_HEADERS([attr/error_context.h attr/libattr.h])
use_xattr=no
if test $ac_cv_header_attr_libattr_h = yes \
&& test $ac_cv_header_attr_error_context_h = yes; then
xattr_saved_LIBS=$LIBS
AC_SEARCH_LIBS([attr_copy_file], [attr],
[test "$ac_cv_search_attr_copy_file" = "none required" ||
LIB_XATTR=$ac_cv_search_attr_copy_file])
AC_CHECK_FUNCS([attr_copy_file])
LIBS=$xattr_saved_LIBS
if test $ac_cv_func_attr_copy_file = yes; then
use_xattr=yes
fi
fi
if test $use_xattr = no; then
AC_MSG_WARN([libattr development library was not found or not usable.])
AC_MSG_WARN([AC_PACKAGE_NAME will be built without xattr support.])
fi
fi
AC_DEFINE_UNQUOTED([USE_XATTR], [`test $use_xattr != yes; echo $?`],
[Define if you want extended attribute support.])
])

View File

@@ -2,3 +2,5 @@
base32 \- base32 encode/decode data and print to standard output
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
basenc(1)

View File

@@ -2,3 +2,5 @@
base64 \- base64 encode/decode data and print to standard output
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
basenc(1)

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 2018-2022 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>.
@@ -7,7 +7,7 @@
basenc \- Encode/decode data and print to standard output
[DESCRIPTION]
.\" Add any additional description here
[ENCODINGS EXAMPLES]
[ENCODING EXAMPLES]
.PP
.nf
.RS

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2022 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>.
@@ -60,17 +60,19 @@ file's group, with the same values; and the fourth for other users not
in the file's group, with the same values.
.PP
.B chmod
never changes the permissions of symbolic links; the
doesn't change the permissions of symbolic links; the
.B chmod
system call cannot change their permissions. This is not a problem
since the permissions of symbolic links are never used.
system call cannot change their permissions on most systems,
and most systems ignore permissions of symbolic links.
However, for each symbolic link listed on the command line,
.B chmod
changes the permissions of the pointed-to file.
In contrast,
.B chmod
ignores symbolic links encountered during recursive directory
traversals.
traversals. Options that modify this behavior are described in the
.B OPTIONS
section.
.SH "SETUID AND SETGID BITS"
.B chmod
clears the set-group-ID bit of a

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2022 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

@@ -2,3 +2,5 @@
cp \- copy files and directories
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
install(1)

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2022 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>.
@@ -24,6 +24,6 @@ shows the space available on that file system rather than on the
file system containing the device node. This version of
.B df
cannot show the space available on unmounted file systems, because on
most kinds of systems doing so requires very nonportable intimate
most kinds of systems doing so requires non-portable intimate
knowledge of file system structures.
.SH OPTIONS

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2022 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-2022 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,3 +2,5 @@
fold \- wrap each input line to fit in specified width
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
fmt(1)

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

@@ -2,3 +2,5 @@
install \- copy files and set attributes
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
cp(1)

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