Compare commits

...

2890 Commits

Author SHA1 Message Date
Collin Funk
1ba065b5be maint: cleanup libraries unnecessarily added to fold
* src/local.mk (src_fold_LDADD): Remove $(MBRTOWC_LIB) since it is
already added to LDADD. Remove $(LIBC32CONV) and $(LIBUNISTRING) which
were for an uncommitted patch which used Gnulib's mbfile module.
2025-09-09 20:39:37 -07:00
Pádraig Brady
2ed207cb1f nohup: avoid FORTIFY runtime failure on Bionic libc
The meaning of non-file permission umask bits is implementation defined.
On Bionic libc, attempting to set them triggers a FORTIFY runtime check.

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

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

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

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

* src/digest.c (main): Continue to support -a "sha###" but
also support -a "sha2" and treat it like "sha3", except in...
(output_file): ... maintain the legacy tags for better compatability.
* doc/coreutils.texi (cksum invocation): Document the -a sha2 option.
* tests/cksum/cksum-base64.pl: Adjust as per modified --help.
* tests/cksum/cksum-c.sh: Add new supported SHA2-### tagged variant.
* NEWS: Mention the new feature.
2025-09-04 14:49:07 +01:00
Collin Funk
403d82a0bf cksum: add support for SHA-3
* src/digest.c: Include sha3.h.
(BLAKE2B_MAX_LEN): Rename to
DIGEST_MAX_LEN since it is also used for SHA-3.
(sha3_sum_stream): New function.
(enum Algorithm, algorithm_args, algorithm_args, algorithm_types)
algorithm_tags, algorithm_bits, cksumfns, cksum_output_fns): Add entries
for SHA-3.
(usage): Mention that SHA-3 is supported. Mention requirements for
--length with SHA-3.
(split_3): Use DIGEST_MAX_LEN instead of BLAKE2B_MAX_LEN. Determine the
length of the digest for SHA-3. Make sure it is 224, 256, 384, or 512.
(digest_file): Set the digest length in bytes. Use DIGEST_MAX_LEN
instead of BLAKE2B_MAX_LEN. Always append the digest length to SHA3 in
the output.
(main): Allow the use of --length with 'cksum -a sha3'.  Use
DIGEST_MAX_LEN instead of BLAKE2B_MAX_LEN. Make sure it is 224, 256,
384, or 512.
* tests/cksum/cksum-base64.pl (@pairs): Add expected sha3 output.
(fmt): Modify the output to use SHA3-512 since that is the default.
(@Tests): Modify arguments for sha3 to use --length=512.
* tests/cksum/cksum-sha3.sh: New test, based on tests/cksum/b2sum.sh.
* tests/local.mk (all_tests): Add the test.
* bootstrap.conf: Add crypto/sha3.
* gnulib: Update to latest commit.
* NEWS: Mention the change.
* doc/coreutils.texi (cksum general options): Mention sha3 as a
supported argument to the -a option. Mention that 'cksum -a sha3'
supports the --length option. Mention that SHA-3 is considered secure.
2025-09-03 22:29:33 -07:00
Collin Funk
022673367b maint: avoid syntax-check failure from previous commit
* src/df.c: Don't include uchar.h.
* src/ls.c: Likewise.
* src/wc.c: Likewise.
2025-09-03 19:15:49 -07:00
Collin Funk
3a81d44d43 fold: check that characters are not non-breaking spaces when -s is used
NetBSD 10 and Solaris 11.4 treat non-breaking spaces as blank
characters unlike glibc.

* src/system.h: Include uchar.h.
(c32isnbspace): New function based on iswnbspace from src/wc.c.
* src/fold.c (fold_file): Use it.
* src/wc.c (iswnbspace): Remove function.
(maybe_c32isnbspace): New function.
(wc, main): Use it.
Fixes https://bugs.gnu.org/79300
2025-09-03 19:12:18 -07:00
Collin Funk
e09f2bc611 maint: prefer issymlink to readlink with a small buffer
* bootstrap.conf (gnulib_modules): Add issymlink and issymlinkat.
* src/copy.c: Include issymlink.h.
(copy_reg): Use issymlink instead of readlinkat.
* src/rmdir.c: Include issymlink.h.
(main): Use issymlink instead of readlink.
* src/tail.c: Include issymlink.h.
(recheck, any_symlinks): Use issymlink instead of readlink.
* src/test.c: Include issymlink.h.
(unary_operator): Use issymlink instead of readlink.
2025-09-03 18:31:08 -07:00
Paul Eggert
1b2f629d96 build: update gnulib submodule to latest 2025-09-03 18:08:53 -07:00
Bruno Haible
db04fc2a09 build: Update after gnulib changed
* gnulib-tests/Makefile.am: Move the AM_CFLAGS assignment before the
'include gnulib.mk'.
2025-09-03 18:08:53 -07:00
Collin Funk
8f6430666f maint: avoid syntax-check failure from previous commit
* tests/seq/seq-long-double.sh: Place comma after "I.e.".
2025-09-02 21:14:34 -07:00
Pádraig Brady
701416709d seq: be more accurate with large integer start values
* src/seq.c (main): Avoid possibly innacurate conversion
to long double, for all digit start values.
* tests/seq/seq-long-double.sh: Add a test case.
* NEWS: Mention the improvement.
Fixes https://bugs.gnu.org/79369
2025-09-02 20:51:55 +01:00
Paul Eggert
c6397d0872 df: pacify static analysis
Problem reported by Yubiao Hu <https://bugs.gnu.org/79336>.
* src/df.c (get_dev): Assume MOUNT_POINT is non-null.
2025-09-01 10:03:14 -07:00
Pádraig Brady
ebd670e7eb ls: fix alignment with locale formatted --size
Fix allocated size alignment in locales with multi-byte grouping chars.
Tested with: LC_ALL=sv_SE.utf8 ls --size --block-size=\'k

* src/ls.c (print_file_name_and_frills): Don't rely on
printf("%*s", width, string) to pad multi-byte strings appropriately.
Instead work out the padding required and use:
printf("%*s%s", padding, "", string) to pad multi-byte appropriately.
* tests/ls/block-size.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/79347
2025-08-31 19:25:38 +01:00
Pádraig Brady
735a4a27f3 b2sum: --length: fix upper bound check
* src/digest.c (main): Don't saturate -l to BLAKE2B_MAX_LEN,
so that the subsequent bounds check is performed.
* tests/cksum/b2sum.sh: Add a test case.
* NEWS: Mention the fix introduced in commit v9.5-71-gf2c84fe63
2025-08-30 12:44:29 +01:00
Collin Funk
89b9115da6 fold: fix handling of invalid multi-byte characters
* src/fold.c (fold_file): Continue the loop when we have buffered bytes
but nothing left to read from the file.
(adjust_column): Don't assume that the character is printable.
* tests/fold/fold-characters.sh: Add a new test case.
(bad_unicode): New function.
2025-08-28 18:57:13 -07:00
Pádraig Brady
4b35a3b920 tests: fold: add tests for multi-byte width
* tests/fold/fold.pl: The i18n patch didn't actually test folding
of multi-byte characters, so add tests for various multi-byte forms.
2025-08-27 16:41:07 +01:00
Pádraig Brady
0001bbc3e2 tests: fold: copy i18n patch tests
* tests/fold/fold.pl: Copy tests from Fedora,
removing copy & pasted logic that was
extraneous to either the i18n patch or upstream.
2025-08-27 14:36:16 +01:00
Pádraig Brady
cbf6a27810 tests: parameterize IO_BUFSIZE
* src/getlimits.c (main): Output IO_BUFSIZE, useful for
sizing data for tests.
* tests/fold/fold-characters.sh: Use it rather than hardcoding.
2025-08-27 12:03:46 +01:00
Pádraig Brady
aec4f85476 build: fold: fix build failure with C99
GCC 10.2 gave the following error:
"error: label at end of compound statement"

* src/fold.c (fold_file): Add a ";" to avoid C2X specific syntax.
2025-08-27 11:50:01 +01:00
Collin Funk
ae89cd646a fold: don't truncate multibyte characters at the end of the buffer
* src/fold.c (fold_file): Replace invalid characters with the original
byte read. Copy multibyte sequences that may not yet be read to the
start of the buffer before reading more bytes.
* tests/fold/fold-characters.sh: Add a test case.
2025-08-26 16:59:32 -07:00
Pádraig Brady
01646ccd64 tests: fold: consolidate all fold tests in tests/fold
* tests/misc/fold.pl: Move from here to ...
* tests/fold/fold.pl: ... here.
* tests/local.mk: Adjust accordingly.
2025-08-26 16:49:56 +01:00
Pádraig Brady
17be45b952 tests: fold: add a memory constraint test
Enforcing this interface behavior is worthwhile
irrespective of our current implementation,
to ensure future or other implementations conform.

* tests/fold/fold-characters.sh: Ensure the fold implementation
uses bounded memory.
2025-08-26 16:48:31 +01:00
Collin Funk
fb9016d505 fold: use fread instead of getline
* src/fold.c: Include ioblksize.h.
(fold_file): Use two IO_BUFSIZE-sized buffers. Use fread instead of
getline. Check for if we reached the end of file.
2025-08-24 13:42:40 -07:00
Pádraig Brady
4bfcf62f74 tests: nproc: fix false failure on some systems
* tests/nproc/nproc-quota.sh: Also simulate sched_getscheduler()
as this will not be called on older or non linux, or
may return ENOSYS on Alpine.
Fixes https://bugs.gnu.org/79299
2025-08-24 11:48:52 +01:00
Collin Funk
11a31296fa maint: prefer STRUCT_UTMP to struct gl_utmp
* cfg.mk (sc_prohibit-struct-gl_utmp): New rule for 'make syntax-check'.
* src/pinky.c (time_string, print_entry, scan_entries, short_pinky):
Use STRUCT_UTMP instead of struct gl_utmp.
* src/uptime.c (print_uptime, print_uptime, uptime): Likewise.
* src/users.c (list_entries_users, users): Likewise.
* src/who.c (time_string, print_user, print_boottime, print_deadprocs)
(print_login, print_initspawn, print_clockchange, print_runlevel)
list_entries_who, scan_entries, who): Likewise.
2025-08-23 18:10:07 -07:00
Pádraig Brady
6c668dc133 tests: cp: ensure copy offload is not disabled for sparse files
Related to commits v9.1-109-g879d2180d and v9.7-248-g306de6c26

* tests/cp/sparse-perf.sh: This edge case was missed a couple of times,
so add a test to ensure we attempt copy offload.
2025-08-23 18:55:46 +01:00
Collin Funk
7d0d9658f9 fold: add the --characters option
* src/fold.c: Include mcel.h.
(count_bytes): Remove variable.
(counting_mode, last_character_width): New variables.
(shortopts, long_options): Add the option.
(adjust_column): If --characters is in used account for number of
characters instead of their width.
(fold_file): Use getline and iterate over the result with mcel functions
to handle multibyte characters.
(main): Check for the option.
* src/local.mk (src_fold_LDADD): Add $(LIBC32CONV), $(LIBUNISTRING), and
$(MBRTOWC_LIB).
* tests/fold/fold-characters.sh: New file.
* tests/fold/fold-spaces.sh: New file.
* tests/fold/fold-nbsp.sh: New file.
* tests/local.mk (all_tests): Add the tests.
* NEWS: Mention the new option.
* doc/coreutils.texi (fold invocation): Likewise.
2025-08-22 22:09:50 -07:00
Paul Eggert
39f22fe687 cp: improve hole handling on squashfs
Better fix for problem reported by Jeremy Allison
<https://bugs.gnu.org/79267>.
* src/copy.c (struct scan_inference): New type, replacing
union scan_inference.  All uses changed.  This is so
infer_scantype can report the first hole's offset when known.
(lseek_copy): 5th arg is now struct scan_inference const *,
not just off_t.  All uses changed.
(infer_scantype): If SEEK_SET+SEEK_HOLE do not find a hole,
fall back on ZERO_SCANTYPE.
2025-08-22 17:40:30 -07:00
Paul Eggert
306de6c261 cp: go back to copy_file_range optimization
This reverts part of the previous change.
* src/copy.c (lseek_copy): When calling sparse_copy, do not
ask it to scan for zeros unless --sparse=always, so that it
can use copy_file_range which can be far more efficient.
2025-08-22 17:40:29 -07:00
Paul Eggert
b7fc76269b cp: always punch holes that we make
Problem reported by Jeremy Allison <https://bugs.gnu.org/79267>.
* src/copy.c (create_hole, sparse_copy): Omit arg PUNCH_HOLES,
as we always punch holes now.  All uses changed.
(lseek_copy): When calling sparse_copy, scan for holes when
sparse_mode == SPARSE_AUTO, as that means we are making holes.
(copy_reg): Always punch any hole made at end.
2025-08-21 15:58:21 -07:00
Pádraig Brady
61a7382c8f tests: nproc: add a test for cgroup quotas
* tests/nproc/nproc-quota.sh: New root only test.
* tests/local.mk: Reference the new test.
2025-08-21 00:04:03 +01:00
Collin Funk
238855dd4e maint: prefer https to http
* doc/sort-version.texi (Other version/natural sort implementations):
Use https in documentation link.
* tests/chmod/symlinks.sh: Use https in license text.
2025-08-19 11:41:17 -07:00
Pádraig Brady
c4df55be7f nproc: honor cgroup v2 CPU quotas
* NEWS: Mention the new feature.
* doc/coreutils.texi (nproc invocation): Mention that
cgroup CPU quotas can limit the reported number.
* gnulib: Update to new nproc gnulib implementation:
https://github.com/coreutils/gnulib/commit/9b07115f4a
2025-08-19 17:24:21 +01:00
Collin Funk
37bca77c4d logname: list David MacKenzie as the author
* src/logname.c (AUTHORS): List David as the author.
* AUTHORS: Likewise.
2025-08-18 20:42:48 -07:00
Paul Eggert
ae6fd2b4a1 realpath: improve doc and NEWS 2025-08-14 21:08:44 -07:00
Collin Funk
c9ae3b553d maint: avoid syntax-check failure from previous commit
* src/tsort.c: Don't include long-options.h since the previous commit
removed the call to parse_gnu_standard_options_only. This avoids a
sc_prohibit_long_options_without_use syntax-check failure.
2025-08-14 19:43:52 -07:00
Paul Eggert
39eec70f7b tsort: add do-nothing -w option
This is for conformance to POSIX.1-2024
* src/tsort.c: Include getopt.h.
(main): Accept and ignore -w.  Do not bother altering
the usage message, as the option is useless.
* tests/misc/tsort.pl (cycle-3): New test.
2025-08-14 17:35:23 -07:00
Pádraig Brady
2543c0052c maint: use short form bug URLs
* cfg.mk (sc_prohibit-long-form-bug-urls): Disallow long form in code.
* scripts/git-hooks/commit-msg: Disallow long form in commit messages.
* NEWS: Shorten long urls.
* bootstrap.conf: Likewise.
* configure.ac: Likewise.
* scripts/git-hooks/commit-msg: Likewise.
* src/csplit.c: Likewise.
* src/fmt.c: Likewise.
* src/make-prime-list.c: Likewise.
* src/nohup.c: Likewise.
* tests/od/od-float.sh: Likewise.
* tests/rm/r-root.sh: Likewise.
* tests/tail/inotify-race.sh: Likewise.
* tests/tail/inotify-race2.sh: Likewise.
2025-08-12 17:50:40 +01:00
Bruno Haible
f4d339c934 basenc: Don't trigger undefined behaviour in mini-gmp
* src/basenc.c (base58_encode): Avoid calling mpz_import on an empty
limb sequence.
2025-08-11 18:07:20 -07:00
Collin Funk
2a092e80e2 realpath: support the -E option required by POSIX
* src/realpath.c (longopts): Add the option.
(main): Likewise.
(usage): Add the option to the --help message.
* tests/misc/realpath.sh: Add a simple test.
* doc/coreutils.texi (realpath invocation): Mention the new option.
* NEWS: Likewise.
2025-08-10 11:41:56 -07:00
Pádraig Brady
192e09042f doc: --base58: add example usage to info
* doc/coreutils.texi (basenc invocation): Add an example
using --base58 to generate a unique ID.  This also demonstrates
compound usage of the basenc command, to convert to/from binary.
2025-08-10 16:21:42 +01:00
Pádraig Brady
d7774907db doc: rearrange NEWS to more standard ordering
* NEWS: Also move items to more appropriate sections.
Also use more consistent quoting.
2025-08-09 22:32:18 +01:00
Pádraig Brady
02c3d43e3a basenc: add base58 support
A 58 character encoding that:
 - avoids visually ambiguous 0OIl characters
 - uses only alphanumeric characters
Described at:
 - https://tools.ietf.org/html/draft-msporny-base58-03

This implementation uses GMP (or gnulib's gmp fallback).
Performance is good in comparison to other implementations.
For example when using libgmp on an i7-5600U system,
encoding is 530 times faster, and decoding 830 times faster
than the implementation using arbitrary precision ints in cpython 3.13.

Memory use is proportional to the size of input.

Encoding benchmarks:

  $ time yes | head -c65535 | src/basenc --base58 -w0 >file.enc
  real    0m0.018s

  ./configure --quiet --without-libgmp && make -j $(nproc)
  $ time yes | head -c65535 | src/basenc --base58 -w0 >file.enc
  real    0m3.431s

  # dnf install python3-base58
  $ time yes | head -c65535 | base58 >file.enc  # cpython 3.13
  real    0m9.700s

Decoding benchmarks:

  $ time src/basenc --base58 -d <file.enc >/dev/null
  real    0m0.010s

  $ ./configure --without-libgmp && make  # gnulib gmp
  $ time src/basenc --base58 -d <file.enc >/dev/null
  real    0m0.145s

  $ time base58 -d <file.enc >/dev/null  # cpython 3.13
  real    0m8.302s

* src/basenc.c (base_decode_ctx_finalize, base_encode_ctx_init,
base_encode_ctx, base_encode_ctx_finalize): New functions to
provide more general processing functionality.
(base58_{de,en}code_ctx{_init,,_finalize}): New functions to
accumulate all input before calling ...
(base58_{de,en}code): ... the GMP based encoding/decoding routines.
(do_encode, do_decode): Call the ctx variants if enabled.
* doc/coreutils.texi (basenc invocation): Describe the new option,
and indicate the main use case being interactive user use.
* src/local.mk: Link basenc with GMP.
* tests/basenc/basenc.pl: Add test cases.
* NEWS: Mention the new feature.
2025-08-09 22:10:27 +01:00
Pádraig Brady
c480428e37 basenc: fix stripping of '=' chars in some encodings
* src/basenc.c (do_decode): With -i ensure we strip '=' chars
if there is no padding for the chosen encoding.
* tests/basenc/basenc.pl: Add a test case.
* NEWS: Mention the bug fix.
2025-08-09 09:59:00 +01:00
Collin Funk
13202995ba maint: prefer attribute.h in .c files
* src/basenc.c (base16_encode, z85_encoding, do_decode): Use
ATTRIBUTE_NONSTRING instead of ATTRIBUTE_NONSTRING.
* src/basenc.c (sc_prohibit-_gl-attributes): New rule for
'make syntax-check'.
2025-08-08 20:49:29 -07:00
Paul Eggert
26bf557e3f cp: omit some needless lseek calls
The sparse code sometimes issued multiple lseeks against the
same file without doing anything in betwee.  Optimize them away
by keeping track of the last hole output, in a way that
crosses the sparse_copy function call boundary.
* src/copy.c (sparse_copy): New arg hole_size, replacing old args
scan_holes and last_write_made_hole.  All callers changed.
(sparse_copy, lseek_copy): Do not create hole at
end; let the caller deal with it.  All callers changed.
(lseek_copy): New args hole_size and total_n_read.  Caller changed.
(copy_reg): Create hole at end for both lseek_copy and sparse_copy.
2025-08-07 20:20:04 -07:00
Paul Eggert
2f2adb294e cp: --sparse=always was missing some holes
The sparse code assumed that st_blksize was the minimum hole size.
However, st_blksize is an optimum I/O buffer size, not the file
system fundamental block size.  Use ST_NBLOCKSIZE instead;
although it may underestimate the true block size that just slows
‘cp’ down a bit, without introducing bugs.
* src/copy.c (sparse_copy): Arg scan_holes replaces
the old hole_size arg.  All callers changed.
(lseek_copy): Remove hole_size arg; no longer needed.
Caller changed.
2025-08-07 20:20:04 -07:00
Collin Funk
c9a30d6781 maint: use consistent references to standard files in messages
* cfg.mk (sc_standard_outputs): Add a grep command for source files.
* src/du.c (main): Use standard input instead of stdin, standard output
instead of stdout, and standard error instead of stderr in messages.
* src/nohup.c (main): Likewise.
* src/sort.c (main): Likewise.
* src/split.c (main): Likewise.
* src/stdbuf.c (main): Likewise.
* src/wc.c (main): Likewise.
* tests/du/files0-from.pl (@Tests): Adjust test case to new messages.
* tests/sort/sort-files0-from.pl: Likewise.
* tests/wc/wc-files0-from.pl: Likewise.
2025-08-05 18:46:04 -07:00
Bernhard Voelker
257efe1ec4 maint: remove now-unused include of 'safe-read.h'
'make syntax-check' complains:
  src/tail.c
  maint.mk: the above files include safe-read.h but don't use it
  make: *** [maint.mk:737: sc_prohibit_safe_read_without_use] Error 1

The removal was missed for tail.c in recent commit d3c7072a09.

* src/tail.c (safe-read.h): Remove include.
2025-08-04 10:53:49 +01:00
Paul Eggert
5c822f4dac maint: prefer same-inode.h
This does not change behavior on POSIX platforms; it’s mostly to
make it clearer when we’re looking for file identity.
* src/cat.c (main):
* src/copy.c (struct dir_list, is_ancestor, copy_internal):
* src/tail.c (struct File_spec, record_open_fd, recheck)
(tail_forever_inotify, tail_file):
* src/test.c (binary_operator):
Use psame_inode, PSAME_INODE, or SAME_INODE instead of comparing
device and inode numbers by hand.
2025-08-03 19:48:06 -07:00
Paul Eggert
01e4d2983a tail: refactor ‘failable’
* src/tail.c (recheck, tail_file): Do not mark a file as tailable
merely because --retry is not in effect.  Simplify internal logic.
This should not change behavior; it’s just for clarity and to
make the code match the comments better.
2025-08-03 19:48:06 -07:00
Paul Eggert
e0100ac746 tail: fix race between read and fstat
* src/tail.c (get_file_status): Remove, since after the changes
described below it would be called in just one place and it’s a
bit clearer to inline by hand.
(tail_file): Don’t call fstat after reading the file, as that
misses changes arriving between read and fstat.  Instead, reuse
the fstat done before reading the file.
2025-08-03 19:48:06 -07:00
Paul Eggert
3655a8cced tail: track errno more accurately
This matters only in some obscure cases hard to test for.
* src/tail.c (file_lines, pipe_lines, pipe_bytes, start_bytes)
(start_lines, tail_bytes, tail_lines, tail): New return
convention, which reports errno.  All callers changed.
(recheck): Don’t lose track of errno if a regular file is
replaced by a symlink.
(get_file_status): Set errno to 0 on success.
(tail_file): Be more careful about f->errnum.
It is now -1 only if the failure was not due to
a system call failing.
2025-08-03 19:48:06 -07:00
Paul Eggert
0b2080f2fa tail: omit redundant assignment
* src/tail.c (recheck): f->remote must be true already,
so don’t set it to true.
2025-08-03 19:48:06 -07:00
Paul Eggert
2d386993e2 tail: prefer readlink to lstat+S_ISLNK
When not already calling lstat for some other reason,
prefer readlink to lstat+S_ISLNK,
as readlink does not suffer from EOVERFLOW issues.
* src/rmdir.c (main):
* src/tail.c (recheck, any_symlinks):
* src/test.c (unary_operator):
2025-08-03 19:48:06 -07:00
Paul Eggert
93805484c5 tail: fix unlikely races with >=2 --pids
Also, fix commentary to talk about “nonexistent” rather than
“dead” processes, since the code looks for the former not the
latter and the difference matters for zombies.
* src/tail.c (some_writers_exist): Rename from writers_are_dead,
negate the sense, don’t have a special and counterintuitive case
for !nbpids, remove PIDs found not to exist, and avoid some
though not all unlikely races when kernels reuse PIDs.
(tail_forever): Optimize via blocking I/O even if --pid was used,
so long as all the writers no longer exist.
(tail_forever, tail_forever_inotify): Simplify the writers_dead
logic; there is no need to have a local var to track this, since
we can use pids and nbpids now.
(parse_options): Also free and clear pids if !forever.
2025-08-03 19:48:06 -07:00
Paul Eggert
15c67b79af tail: prefer < 0 to == -1
* src/tail.c (valid_file_spec, recheck, writers_are_dead)
(tail_forever, check_fspec, tail_forever_inotify, tail_file)
(parse_options, main): Be a bit more systematic about checking
for sign, rather than for exact equality or inequality,
when the sign is enough.  Makes the code a bit clearer
now that -2 sometimes means success.
2025-08-03 19:48:06 -07:00
Paul Eggert
976f8abc19 tail: record file offset more carefully
* src/tail.c (struct File_spec): New member read_pos, replacing
size, since the value was really a read position not a size.
All uses changed.
(xlseek): Move defn up.
(record_open_fd): If the read_pos (formerly) size arg is unknown,
compute it here if it is a regular file.
(file_lines): Return the resulting read pos (or -1 on failure)
instead of storing it via a pointer.  Caller changed.
Simplify by using SEEK_CUR instead of SEEK_SET when that is easy.
Avoid reading the same data twice when there are not enough
lines in the file.
(pipe_lines): Return -2 on success, -1 on failure, rather than
updating a read pos via a pointer (which was weird for pipes anyway).
Caller changed.
(pipe_bytes, tail_bytes, tail_lines, tail):
Return -1 on failure, a file offset if known, and < -1 otherwise,
instead of storing a file offset via a pointer.  Caller changed.
(pipe_bytes): Take initial file offset as an arg, or -1 if unknown.
(start_bytes, start_lines): Return -1 (not 1) on error, -2 (not
-1) on EOF, and do not accept pointer to read pos as an arg since
neither we nor our caller know the read pos.  Callers changed.
(recheck): Do not assume a newly-opened file is at offset zero,
as this is not always true on Solaris.
(tail_forever, check_fspec): Use dump_remainder result only
on regular files, to prevent (very unlikely) overflow.
(tail_file): Remove no-longer-needed TAIL_TEST_SLEEP code.
2025-08-03 19:48:06 -07:00
Paul Eggert
d3c7072a09 maint: prefer 'read' to 'safe_read'
In the old days, safe_read acted more like what full_read does now.
When that went away, some code that invoked safe_read should
have gone back to plain 'read' but I guess we never got around to it.
Simplify this code by going back to plain 'read'.
Use safe_read only in csplit.c, which has a signal handler
and where 'read' can therefore fail with EINTR.
Although safe_read also checks for oversize buffers,
that is better done via io_blksize.
* src/cat.c (simple_cat, cat):
* src/head.c (copy_fd, elide_tail_lines_pipe)
* src/tac.c (tac_seekable, copy_to_temp):
(elide_tail_lines_seekable, head_lines):
* src/tail.c (dump_remainder, file_lines, pipe_lines)
(pipe_bytes, start_bytes, start_lines, tail_forever_inotify):
* src/tr.c (plain_read):
Use plain 'read', not safe_read, since there is no
need to worry about signals or oversize requests.
Also, there is no longer a need to include safe-read.h.
* src/ioblksize.h: Include sys-limits.h, for SYS_BUFSIZE_MAX.
(io_blksize): Max out at SYS_BUFSIZE_MAX.
2025-08-03 19:48:05 -07:00
Paul Eggert
3820447667 tail: prefer signed types to size_t, blksize_t
* src/tail.c (struct File_spec, xwrite_stdout, file_lines)
(pipe_lines, pipe_bytes, start_bytes, any_live_files)
(tail_forever, any_remote_file, any_non_remote_file)
(any_symlinks, any_non_regular_fifo, tailable_stdin)
(tail_forever_inotify, ignore_fifo_and_pipe, main):
Prefer a signed type to size_t, if possible.
Ordinarily this is idx_t, but use int when the value
must fit in int anyway.
(file_lines): Similarly for blksize_t, which had no business
being here anyway.
(main): Check for overflow in the oddball case where ptrdiff_t is
narrower than int.
2025-08-03 19:48:05 -07:00
Paul Eggert
0625370b7a tail: prefer intmax_t to uintmax_t
Signed types let us debug better, by using -fsanitize=undefined.
* doc/local.mk (doc/constants.texi):
Adjust change from macro to enum.
* src/tail.c (COPY_TO_EOF, COPY_A_BUFFER)
(DEFAULT_MAX_N_UNCHANGED_STATS_BETWEEN_OPENS):
Now enum constants, not macros.
(COPY_TO_EOF, COPY_A_BUFFER): Now negative, not positive.
(count_t): New typedef.  Use it instead of uintmax_t.
(COUNT_MAX): New macro; use it instead of UINTMAX_MAX.
(struct File_spec, max_n_unchanged_stats_between_opens)
(dump_remainder, file_lines, pipe_lines, pipe_bytes)
(start_bytes, start_lines, tail_forever, check_fspec)
(tail_forever_inotify, tail_bytes, tail_lines, tail, tail_file)
(parse_obsolete_option, parse_options, main):
Prefer count_t to uintmax_t.
2025-08-03 19:48:05 -07:00
Paul Eggert
fee8859750 tail: don’t output more lines than requested
* src/tail.c (file_lines): Fix an unlikely bug where ‘tail -n N’
could output more than N lines if standard input is a largish
regular file with large initial offset that starts with (say) N-1
lines after the initial offset, but grows to N+1 lines between the
fstat and read calls.  In this case ‘tail -n N’ now outputs N-1
lines, not N+1; that is, it pretends the file grew after ‘tail’
read it.  That is better than outputting more than N lines.
2025-08-03 19:48:05 -07:00
Paul Eggert
eb0086669f tail: xlseek switch → table
* src/tail.c (xlseek): Turn a switch statement into a table.
2025-08-03 19:48:05 -07:00
Paul Eggert
d584545299 tail: prettyname cleanup
* src/tail.c: Use ‘prettyname’ consistently as the identifier
for a prettified file name, as opposed to ‘pretty_filename’,
‘pretty_name’, and ‘name’.  This makes the code easier to follow.
(struct File_spec): New member prettyname.
(pretty_name): Remove.
All uses of pretty_name (f) replaced by f->prettyname.
(close_fd, fremote): Accept struct File_spec, not name.
All callers changed.
(main): Initialize the new prettyname member.
This is simpler/smaller than calling pretty_name everywhere.
2025-08-03 19:48:05 -07:00
Paul Eggert
10aa908ebd tail: optimize tail -n +2**63
* src/tail.c (tail_lines): Also optimize ‘tail -n +N’
on a seekable file, where OFF_T_MAX <= N < UINTMAX_MAX.
Of course this is very unlikely.
2025-08-03 19:48:05 -07:00
Paul Eggert
3918655d4b tail: refactor SEEK_END and lines
* src/tail.c (tail_lines): Refactor to simplify the confusing
code for using SEEK_END when counting lines.  The old code
had a ‘end_pos != 0’ expression that was always true.
2025-08-03 19:48:05 -07:00
Paul Eggert
09fc945b37 tail: refactor to skip stat call on failure
* src/tail.c (tail_bytes): New function.
(tail_bytes, tail_lines, tail): Accept struct stat pointer from
caller instead of calling fstat ourselves.  All callers changed.
(tail_file): Skip a call to fstat if fstat already failed.
* tests/tail/follow-stdin.sh: Adjust to match new behavior
on failure, which omits a redundant diagnostic.
2025-08-03 19:48:05 -07:00
Paul Eggert
d58aa27d06 tail: speed up -c N for huge N
When the user specifies -c N where 2**63 <= N, don’t give
up and use the slow method (which will exhaust memory if
the file is large).  Instead, treat it as N = 2**63 - 1,
since that has equivalent effect.
* src/tail.c (tail_bytes): With -c N and large N, adjust
the code so that lseeks can still be used without
affecting correctness.  Formerly the code gave up and
did a sequential pass through the whole input, which
could easily exhaust memory.
2025-08-03 19:48:05 -07:00
Paul Eggert
6439858056 tail: allow >=2**64 in traditional form
This better matches the treatment of POSIX form,
e.g., ‘tail +Nc’ is now like ‘tail -c +N’ even when N is large.
* src/tail.c: Don’t include xstrtol.h.
(parse_obsolete_option): Treat numbers greater than UINTMAX_MAX as
if they are UINTMAX_MAX.  Parse the number by hand with saturating
arithmetic; nowadays that’s simpler than using xstrtoumax.  There
is no need for a diagnostic now, as the error cannot happen any more.
* tests/tail/tail.pl (obs-plus-c3): New test.
2025-08-03 19:48:04 -07:00
Paul Eggert
ae37265727 tail: check OFF_T_MAX vs COPY_A_BUFFER
* src/tail.c: Document an otherwise-unstated assumption.
2025-08-03 19:48:04 -07:00
Paul Eggert
468f821150 tail: fix SEEK_END typo
* src/tail.c (tail_lines): Fix embarrassing SEEK_END typo.
Luckily this matters only in never-used (though valid) invocations.
2025-08-03 19:48:04 -07:00
Paul Eggert
c667ca229f tail: simplify -c+ on regular files
* src/tail.c (tail_bytes): Simplify the -c+N case by treating
regular files like other files; if the lseek fails for whatever
reason, fall back on the unoptimized version instead of reporting
a fatal error.
2025-08-03 19:48:04 -07:00
Paul Eggert
938035b9b4 maint: don’t lseek memory objects
This affects behavior only on memory objects, which are not in Linux.
Formerly the code would use lseek on these objects,
but POSIX says the result of lseek is unspecified on them,
and in QNX lseek has undefined behavior on typed memory objects.
* src/head.c (elide_tail_bytes_file, elide_tail_lines_file):
Omit unnecessary uses of presume_input_pipe.
Improve some out-of-date comments.
(head): Do not assume a file is seekable merely because its
st_size is usable.  Instead, seek only on regular files.
* src/od.c (skip): Do not seek on memory objects.
2025-08-03 19:48:04 -07:00
Paul Eggert
dfe4df5694 wc: don’t assume opening a file puts you at start
This is not true on Solaris when opening /dev/stdin; it could be
at a nonzero file offset.  Arguably Linux should do likewise.
* src/wc.c (wc): Omit last arg, and act as if it is always -1.
All uses changed.
2025-08-03 19:48:04 -07:00
Paul Eggert
c9e2dd531d head: simplify head_bytes
* src/head.c (diagnose_read_failure): New function.
Use it when possible, to simplify callers.
(head_bytes): Use copy_fd and diagnose_copy_fd_failure instead of
reinventing the wheel.
2025-08-03 19:48:04 -07:00
Paul Eggert
ca30c06e4c head: omit unnecessary lseek
* src/head.c (elseek_diagnostic): New function.
(elseek): Use it.
(head_lines): Use it to avoid an unnecessary lseek.
2025-08-03 19:48:04 -07:00
Collin Funk
2ff3c65e94 readlink: improve documentation for POSIXLY_CORRECT in --help
* NEWS: Improve wording to not imply POSIXLY_CORRECT=1 readlink -q will
be verbose.
* src/readlink.c (usage): Mention the affect of POSIXLY_CORRECT on
-s (--silent), -q (--quiet), and -v (--verbose) in the help message.
(main): Remove spurious newline added by previous commit.
* doc/coreutils.texi (readlink invocation): Mention that -s (--silent)
and -q (--quiet) are not the default when POSIXLY_CORRECT is set.
2025-08-03 12:33:55 -07:00
Collin Funk
ecd803805d readlink: emit errors when POSIXLY_CORRECT is set
* src/readlink.c (main): Set verbose if the POSIXLY_CORRECT environment
variable is set.
* tests/readlink/readlink-posix.sh: New file.
* tests/local.mk (all_tests): Add it.
* NEWS: Mention the change.
* doc/coreutils.texi (readlink invocation): Document the behavior of
POSIXLY_CORRECT.
2025-08-03 10:55:54 -07:00
Pádraig Brady
79206bbfbe doc: mention copy_file_range data corruption avoidance
* NEWS: Mention this important data corruption issue.
2025-08-02 09:52:17 +01:00
Paul Eggert
336cd700c0 build: update gnulib submodule to latest 2025-08-01 17:02:22 -07:00
Bruno Haible
0142856e7b maint: date: refactor to be entirely bottom-up
* src/date.c (show_date_helper): Move function. Remove forward
declaration.
2025-08-01 13:31:28 +01:00
Bruno Haible
4d03487bbb date: fix calendar-related test failures on macOS and OpenBSD
* bootstrap.conf (gnulib_modules): Add xsetenv.
* src/date.c: Include xsetenv.h.
(set_LC_TIME): New function.
(show_date_helper): Call set_LC_TIME instead of setlocale.
* po/POTFILES.in: Add lib/xsetenv.c.
Fixes https://bugs.gnu.org/79118
2025-07-31 21:54:49 -07:00
Collin Funk
5bdd466c68 build: update gnulib submodule to latest 2025-07-31 21:43:55 -07:00
Collin Funk
6c2117ab80 build: fix previous commit
* src/local.mk (src/speedlist.h): Pass correct arguments $(COMPILE). Use
tabs consistently.
2025-07-31 17:57:59 -07:00
Collin Funk
72d483dab7 build: don't use '$<' in non-suffix rules
* src/local.mk (src/speedlist.h): Use the file name instead of '$<'
which is not supported by OpenBSD make.
2025-07-30 16:33:24 -07:00
Pádraig Brady
a7c63296c1 du: improve diagnostics for --time-style
* src/system.h (x_timestyle_args): A new function refactored from ...
* src/ls.c (decode_switches): ... here.
* src/du.c: Use refactored x_timestyle_args() to output a custom error.
Addresses https://bugs.gnu.org/79113
2025-07-29 11:43:09 +01:00
Pádraig Brady
69f21c5d46 doc: use consistent references to standard files
* cfg.mk (sc_standard_outputs): A new syntax check to
enforce standard references.
* doc/coreutils.texi: s/stderr/standard error/ etc.
* src/date.c: Likewise.
* src/dd.c: Likewise.
* src/env.c: Likewise.
* src/sort.c: Likewise.
* src/split.c: Likewise.
* src/stty.c: Likewise.
* src/timeout.c: Likewise.
* src/who.c: Likewise.
2025-07-29 11:43:09 +01:00
Collin Funk
afd899cb47 doc: update git version documented in HACKING
* HACKING: Mention that git version 1.6.4 or later is required since
'./bootstrap' will fail otherwise.
2025-07-27 11:53:42 -07:00
Paul Eggert
4a2402dcfa doc: mention 2025 speedup on large composites 2025-07-27 07:30:49 -07:00
Pádraig Brady
798a35a7b3 maint: avoid :> pattern in tests
This was seen to trigger the EXIT trap on cygwin

* cfg.mk (sc_prohibit_colon_redirection): Disallow all
cases of :> in tests/
* tests/cksum/md5sum-bsd.sh: Adjust to avoid more
stringent syntax check.
2025-07-26 20:06:42 +01:00
Collin Funk
93304acc10 tests: avoid a false failure on Cygwin
* tests/cksum/md5sum-bsd.sh: Use 'echo' instead of ':' to redirect to
the file. Otherwise 'Exit $fail' is not called on Cygwin.
2025-07-26 11:29:02 -07:00
Collin Funk
ba8e55ea95 maint: avoid syntax-check failure from previous commit
* src/test.c (binary_operator): Place string argument on a separate line
to avoid sc_error_quotes syntax-check failure.
2025-07-26 00:17:16 -07:00
Paul Eggert
3c40470c5d test: simplify for clarity
This should help avoid further audit confusion,
such as was just fixed by removing a FIXME.
* src/test.c (enum binop): New type.
(get_mtime): Return a struct timespec instead of returning
a bool and storing a struct timespec.  All callers changed.
(binop): Return an int recording either success (an enum binop)
or failure (-1).  All callers changed.
(binary_operator): Accept an enum binop, so that we need
not recompute the op type.  All callers changed.  Simplify.
2025-07-25 12:27:39 -07:00
Harry Fellowes
ecde78e1df test: removed dead code for unrecognised binary operators
the fallback error in binary_operator() was unreachable, since invalid
binary operators are rejected in three_arguments() via binop() which
returns false and prevents entry into binary_operator().

this dead code was unreachable and safe to remove

ref: line 636 where "binary operator expected" is generated.

Signed-off-by: Harry Fellowes <harryfellowes1@gmail.com>
Copyright-paperwork-exempt: Yes
2025-07-25 12:27:39 -07:00
Collin Funk
56eaa4ffc3 tests: date: add tests for the Ethiopian calendar
* tests/date/date-ethiopia.sh: New file.
* tests/local.mk (all_tests): Add the test.
2025-07-23 07:49:49 -07:00
Collin Funk
a9cd174811 tests: date: add tests for the Solar Hijri calendar
* tests/date/date-iran.sh: New file.
* tests/local.mk (all_tests): Add the test.
2025-07-23 07:49:49 -07:00
Pádraig Brady
5a106af2d6 install: with -d, use more accurate diagnostics
* gnulib: Update to latest to get the fix to
propagate the appropriate error message.
* tests/install/basic-1.sh: Add a test case.
* NEWS: Mention the bug fix.
Addresses https://bugs.gnu.org/79072
2025-07-22 21:15:17 +01:00
Collin Funk
5ab05e5a36 tests: date: add tests for the Thai solar calendar
* tests/date/date-thailand.sh: New file.
* tests/local.mk (all_tests): Add the test.
2025-07-21 21:25:58 -07:00
Collin Funk
027855dcad doc: NEWS: mention that 'date' now supports non-Gregorian calendars
Suggested by Bruno Haible in:
<https://lists.gnu.org/r/bug-gnulib/2025-07/msg00091.html>.

* NEWS: Mention the improvement.
2025-07-21 15:04:53 -07:00
Collin Funk
1b98590037 build: update gnulib submodule to latest
* bootstrap: Update using './bootstrap --bootstrap-sync'.
2025-07-21 14:43:59 -07:00
Bruno Haible
4a3eb45d72 date: update documentation regarding non-Gregorian calendars
* doc/coreutils.texi (Calendars): New section.
2025-07-21 21:18:25 +01:00
Bruno Haible
c3cea90de3 date: force a Gregorian calendar for options --iso-8601 and --rfc-3339
* src/date.c (show_date_helper): Add a use_c_locale parameter.
(batch_convert): Add a format_in_c_locale parameter.
(main): Set format_in_c_locale to true if any of the options --rfc-3339,
--iso-8601, -R is seen.
2025-07-21 21:16:03 +01:00
Pádraig Brady
083f89528e tests: sort: add a test for equivalent floats
* tests/sort/sort-float.sh: Ensure equivalent floats
are treated as such.
2025-07-12 19:58:06 +01:00
Paul Eggert
3a9ec02138 tests: fix fraction comparison in sort-float
Problem reported by Cosima Neidahl <https://bugs.gnu.org/78985#13>.
* tests/sort/sort-float.sh: At top level, use C locale at first.
(dbl_minima_order): Assume C locale.
Use string comparison for the fractional parts.

2025-07-10  Paul Eggert  <eggert@cs.ucla.edu>

tests: fix integer overflow in sort-float
Problem reported by Cosima Neidahl <https://bugs.gnu.org/78985>.
* tests/sort/sort-float.sh (dbl_minima_order):
Use expr instead of test, to avoid problems with integers
too large for the shell.
2025-07-11 14:45:04 -07:00
Paul Eggert
8f9fc8f08c tests: fix integer overflow in sort-float
Problem reported by Cosima Neidahl <https://bugs.gnu.org/78985>.
* tests/sort/sort-float.sh (dbl_minima_order):
Use expr instead of test to compare fractions,
to avoid problems with integers too large for the shell.
2025-07-10 10:18:06 -07:00
Paul Eggert
1dda42fa58 factor: remove SINGLE_WORKS
* src/factor.c (SINGLE_WORKS): Remove, and remove its use,
as the buggy code that it is referring to has been removed.
2025-07-09 22:27:29 -07:00
Paul Eggert
5b2ddab2d3 factor: use 64-bit internal counters
* src/factor.c (factor_using_pollard_rho)
(factor_using_pollard_rho2, mp_factor_using_pollard_rho):
Use int_fast64_t for internal counters rather than int, as int
could overflow on some somewhat-practical examples.  Problem
discovered on a hypothetical platform where W_TYPE_SIZE is neither
32 nor 64, when factoring 0x7ffffffffffffeab7fffffffffff7369 ==
170141183460469225450570946617781744489, causing k to overflow in
mp_factor_using_pollard_rho.  Presumably a similar problem exists
in the previous stable coreutils 9.7, too, on 32-bit platforms
with somewhat-larger test cases, though I haven’t take the
somewhat-extensive CPU time to discover it.
2025-07-09 22:01:42 -07:00
Paul Eggert
4171ca3353 factor: fix mp_factor_using_pollard_rho aliasing
* src/factor.c (mp_factor_using_pollard_rho):
Fix recently-introduced aliasing bug by computing q
before g gets updated in place.  Problem discovered
on a hypothetical platform where W_TYPE_SIZE
is neither 32 nor 64.
2025-07-09 22:01:42 -07:00
Paul Eggert
5fde9ad14b maint: fix apostrophe in old NEWS 2025-07-09 17:12:40 -07:00
Paul Eggert
bbca1c106c factor: speed up converting strings to uuint
* src/factor.c: Do not include c-ctype.h.
(strtouuint): Don’t bother generating a number on
error; just return a strtol_error value other than LONGINT_OK.
Speed up overflow checking.
2025-07-09 17:12:40 -07:00
Paul Eggert
035b837146 factor: simplify primes table
* src/factor.c (primes_ptab): New table of primes, replacing
primes_diff and primes_diff8.  All uses changed.  This is simpler
and should improve performance slightly.  Although this limits the
table’s primes to 2**15 instead of to 668221, the limit can easily
grow to 2**32 by changing the type of ‘prime’, without hurting
performance significantly compared to the primes_diff and
primes_diff8 approach.
* src/make-prime-list.c (output_primes):
For each prime p, output p instead of two differences.
2025-07-09 17:12:40 -07:00
Paul Eggert
b754d14117 factor: prefer false for boolean 0
* src/factor.c: Prefer false to 0 for booleans.
2025-07-09 17:12:40 -07:00
Paul Eggert
d658d121c3 maint: port speedgen to FreeBSD 15
* src/speedgen: Avoid ‘trap 'command' ERR’, as ERR
does not conform to POSIX and does not work in
FreeBSD 15 sh.
2025-07-09 17:12:40 -07:00
Paul Eggert
ef456bef37 factor: speed up Pollard-rho loop counters
* src/factor.c (factor_using_pollard_rho)
(factor_using_pollard_rho2, mp_factor_using_pollard_rho):
Use int, not unsigned long int, for counters that won’t go above
2**31 on practical platforms.  This yields a significant speedup
on GCC 15 x86-64, and using signed values allows for automatic
checks for overflow when using gcc -fsanitize=undefined.
2025-07-09 17:12:40 -07:00
Paul Eggert
033a50af8b factor: avoid an mpz init+clear
* src/factor.c (mp_factor_insert_ui): Rename fom
mp_factor_insert_ui, and change arg type from unsigned long int to
mp_limb_t.  All uses changed.  This avoids creating and freeing a
small mpz_t.
(mp_factor_using_division): Add a static assert requiring that
that mp_limb_t be wide enough, which it should be (and is in
standard GMP).
2025-07-09 17:12:40 -07:00
Paul Eggert
2ba4216441 factor: Pollard-rho a is now mp_limb_t
* src/factor.c (factor_using_pollard_rho)
(factor_using_pollard_rho2): Use mp_limb_t, not unsigned long int,
for a parameter.  This avoids some casts, and avoids a theoretical
bug where converting to mp_limb_t loses info.
2025-07-09 17:12:40 -07:00
Paul Eggert
d4cff38776 factor: redo ge2 in terms of lt2
lt2 a bit more natural, given the current implementation.
* src/factor.c (lt2): New function.
(ge2): Rewrite in terms of lt2.
(gt2): Remove.  All callers changed to use lt2.
2025-07-09 17:12:40 -07:00
Paul Eggert
d70e07668c factor: speed up umul_ppmm when !USE_LONGLONG_H
* src/factor.c (umul_ppmm): When !USE_LONGLONG_H so we need to
define this, speed things up if there is an unsigned type uuroom_t
wide enough to hold two words.  Do not make a similar change for
udiv_qrnnd, as it is not performance critical and anyway on GCC 15
x86-64 that would mean a subroutine call.
2025-07-09 17:12:40 -07:00
Paul Eggert
e16d3f38f3 factor: streamline gcd2_odd
* src/factor.c (gcd2_odd): Omit a gt2 and adjusts other
tests accordingly.  Omit duplicate code that makes A odd.
2025-07-09 17:12:40 -07:00
Paul Eggert
37fbbc5373 factor: faster gcd_odd since 2nd is odd
* src/factor.c (gcd_odd, gcd2_odd): Speed up, given that the
second argument is always odd.
(gcd_odd): Avoid recomputing a temporary.
(gcd2_odd): Test for zero only if a multiple of B.
This saves an ‘assume’.
2025-07-09 17:12:40 -07:00
Paul Eggert
2ce3fc0c1b doc: update ‘factor’ benchmarks 2025-07-09 17:12:40 -07:00
Paul Eggert
3ee25abfd3 factor: prefer exact division
* src/factor.c (mp_factor_using_division, mp_factor_using_pollard_rho):
Use exact division when it suffices, as it’s typically faster.
2025-07-09 17:12:40 -07:00
Paul Eggert
73bb62f7df factor: tune submod2
* src/factor.c (submod2): Use ckd_sub to subtract by hand rather
than using sub_ddmmss plus a compare.  This speeds things up a
bit, on x86-64 with GCC 15 anyway.
2025-07-09 17:12:40 -07:00
Paul Eggert
b0c58a8b29 factor: DELIM and DIVBLOCK no longer macros
* src/factor.c (DELIM): Now a constant, not a macro.
(divblock): Now a static inline function, not a macro DIVBLOCK.
All uses changed.
2025-07-09 17:12:40 -07:00
Paul Eggert
d4bc32a5ff factor: simplify by assuming !PROVE_PRIMALITY
* src/factor.c (PROVE_PRIMALITY, mp_millerrabin): Remove.
All uses removed, and surrounding code simplified.
2025-07-09 17:12:40 -07:00
Paul Eggert
a29d128162 factor: simplify by assuming USE_BAILLIE_PSW
* src/factor.c (make_uuint2, powm, powm2, millerrabin)
(millerrabin2, USE_BAILLIE_PSW): Remove; no longer used.
(prime_p, prime2_p): Simplify by assuming USE_BAILLIE_PSW.
2025-07-09 17:12:40 -07:00
Paul Eggert
5bab674646 factor: prime comments
* src/factor.c: Add comments re prime functions.
2025-07-09 17:12:40 -07:00
Paul Eggert
fb20a7d3e4 factor: no ferror+fclose
* src/make-prime-list.c (main): Avoid parallel calls
to ferror and fclose.
2025-07-09 17:12:40 -07:00
Paul Eggert
86bddb0d53 factor: define SQUARE_OF_FIRST_OMITTED_PRIME
* src/make-prime-list.c (output_primes): Output
SQUARE_OF_FIRST_OMITTED_PRIME, not FIRST_OMITTED_PRIME.  All uses
changed.  This way, the uses don’t need to worry about casts to
avoid overflow.
2025-07-09 17:12:40 -07:00
Paul Eggert
a9a8e0db47 factor: simplify add_ssaaaa default
* src/factor.c (add_ssaaaa): Simplify default implementation.
2025-07-09 17:12:40 -07:00
Paul Eggert
7cbc6c55cc factor: speed up ge2, gt2
* src/factor.c (ge2, gt2): Now branchless static functions.
2025-07-09 17:12:40 -07:00
Paul Eggert
097760c3de factor: improve millerrabin2 API
* src/factor.c (make_uuint2): New function.
(powm2, millerrabin2): Pass two-word args as uuints,
not as mp_limb_t const [2] pointers.  All uses changed.
(prime2_p): Rework to use the new API, fixing a FIXME.
2025-07-09 17:12:40 -07:00
Paul Eggert
d3db83b879 factor: put FACTORS first
* src/factor.c (factor_using_division, mp_finish_up_in_single)
(mp_finish_in_single, factor_using_pollard_rho)
(factor_using_pollard_rho2, factor_up, factor):
Put FACTORS arg first, for consistency.
This is just a refactoring and should not affect speed.
2025-07-09 17:12:40 -07:00
Paul Eggert
4e2aeb31e0 factor: use 1-word code only when tested
* src/factor.c (print_factors): Use single-precision code only
when word size is 32 or 64, as it isn't tested for other sizes and
is known to not work when it the size is 128.  This change does
not affect any known practical platforms.
2025-07-09 17:12:40 -07:00
Paul Eggert
8eb114f080 factor: decrement Miller-Rabin tests from 25 to 24
This avoids some seemingly-unnecessary code in mpz_probab_prime_p.
* src/factor.c (MR_REPS): Shrink from 25 to 24, and add commentary.
2025-07-09 17:12:40 -07:00
Paul Eggert
5037ce930c factor: don’t prove primality
Suggested for consideration by Torbjörn Granlund in:
https://lists.gnu.org/r/coreutils/2025-01/msg00000.html
* src/factor.c (PROVE_PRIMALITY): Now defaults to false.
(mp_prime_p): Help the compiler by telling it mpz_prob_prime_p
returns nonnegative.
* tests/factor/create-test.sh (bigprime): Test 2^400 - 593,
since that’s now practical.
* tests/local.mk (factor_tests): Add new test.
2025-07-09 17:12:40 -07:00
Paul Eggert
f726827e1f factor: add comments to factor.c 2025-07-09 17:12:39 -07:00
Paul Eggert
30b7851cdf factor: always use Baillie-PSW
* src/factor.c (USE_BAILLIE_PSW): New constant.
(prime_p, prime2_p): Use it, i.e., always use Baillie-PSW.
Do so by using mp_prime_p.  Do not tell GCC these functions
are pure; the pure mark was present only to pacify GCC
and is no longer needed now that thes functions call mp_prime_p.
2025-07-09 17:12:39 -07:00
Paul Eggert
3d442fd824 build: update gnulib submodule to latest 2025-07-09 17:12:39 -07:00
Paul Eggert
a76600cda2 factor: use mpz_probab_prime_p
Inspired by a proposal by Torbjörn Granlund in:
https://lists.gnu.org/r/coreutils/2025-01/msg00000.html
* src/factor.c (mp_prime_p): Use mpz_probab_prime_p rather than doing
it by hand, as mpz_probab_prime_p uses Baillie-PSW which is a win.
This removes the need for the ret2 label and goto.
2025-07-09 17:12:39 -07:00
Paul Eggert
5d3fdfd04b factor: don’t give up before last prime in table
* src/factor.c (prime_p, prime2_p, mp_prime_p): Do not skip the
flag_prove_primality test for the last prime in the table, i.e.,
when r == PRIMES_PTAB_ENTRIES - 1.
(mp_prime_p): There is no longer a need for the ret1 label or goto.
2025-07-09 17:12:39 -07:00
Paul Eggert
38c63d58d0 factor: move prime_p local in
* src/factor.c (mp_prime_p): Refactor by moving local further in.
2025-07-09 17:12:39 -07:00
Paul Eggert
bdd13ff8c0 factor: port back to mini-gmp
mini-gmp lacs mpn_tdiv_qr, so supply an emulation of it
when using mini-gmp.
* src/factor.c (copy_mpn_from_mpz, mpn_tdiv_qr) [!mpn_tdiv_qr]:
New functions.
2025-07-09 17:12:39 -07:00
Paul Eggert
442c164ae0 factor: speed up multiprecision Pollard’s rho
These changes are taken from a proposal by Torbjörn Granlund in:
https://lists.gnu.org/r/coreutils/2025-01/msg00000.html
On my x86-64 platform, they improve speed by more than 8× when
factoring 340282366920938463463374607431768211457.
* src/factor.c (mp_modadd, mp_modsub, mp_modadd_1, mp_mulredc):
New functions.
(MP_FACTOR_USING_POLLARD_RHO_N_MAX): New macro.
(mp_factor_using_pollard_rho): Act on mpn not mpz, and on
mp_limb_t not unsigned long int.  Reorder args.  All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
54a2d18b1f factor: use function for binv
* src/factor.c (binv_limb): New function, replacing the old
binv macro.  All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
20beab12df factor: use a more functional style
This is mostly to make the code a bit easier to read.
It shrinks the size of factor.o by 0.7% on my x86-64 platform
though it doesn’t affect CPU performance significantly.
* src/factor.c (mp_no_factors): Rename from mp_factor_init.
(mp_no_factors, mp_factor_using_division, mp_factor):
Return struct mp_factors rather than modifying one passed by reference.
All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
d16059e375 factor: use single vector in struct mp_factors
* src/factor.c (struct mp_factor): New type.
(struct mp_factors): Use it to replace P and E with F.
All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
6e87c9b3a3 factor: omit unnecessary divisions by small primes
* src/factor.c (mp_factor_using_division):
When continuing in single precision, don’t divide by primes that
were already cast out in multiple precision.
On my platform this gave a 2.5% speedup when factoring
2**128 + 172261 = 4999 * 68070087401668026297934508388031283,
as W_TYPE_SIZE == 64 and 4999 is the last prime in the primes table.
2025-07-09 17:12:39 -07:00
Paul Eggert
f7d295d941 factor: use primes_diff more consistently
* src/factor.c (mp_factor_using_division): Use index into
primes_diff consistently with other uses.  This is mostly just a
style change, and likely doesn’t change the generated machine code.
2025-07-09 17:12:39 -07:00
Paul Eggert
748d03ca12 factor: refactor to for later performance speedup
This does not affect performance much, but it should allow future
performance improvements.
* src/factor.c (factor_using_division): Two new args I and P,
which generalize this function.  All uses changed.
(mp_finish_up_in_single, factor_up): New functions, like the
non-*_up* versions but with two new args PRIME_IDX and PRIME.
They mostly just have the old body of the old non-*_up_ versions.
(mp_finish_in_single, factor): Rewrite in terms of the new functions.
2025-07-09 17:12:39 -07:00
Paul Eggert
831623ba66 factor: switch from mp to single when doable
This significantly improves performance when a number exceeds
2**(W_TYPE_SIZE - 1) and is the product of a prime less than
FIRST_OMITTED_PRIME and another prime less than 2**(W_TYPE_SIZE - 1).
On my platform, for example, it doubled the speed of factoring
4999 * (2**128 - 159).
* src/factor.c (mp_size, mp_finish_in_single): New functions.
(mp_factor_using_division, mp_factor_using_pollard_rho):
Finish using single precision when possible.
* tests/factor/factor.pl (lt-5000-times-128-bit): New test.
2025-07-09 17:12:39 -07:00
Paul Eggert
845f3a6158 factor: primes_diff idx type consistency
* src/factor.c (factor_insert_refind):
Use idx_t for indexes into primes_diff,
for consistency with other indexes into primes_diff.
This has no practical effect unless the primes_diff
table becomes unreasonably large.
2025-07-09 17:12:39 -07:00
Paul Eggert
fd458798fe factor: omit q from mp_factor_using_division
* src/factor.c (mp_factor_using_division): Remove unused local.
2025-07-09 17:12:39 -07:00
Paul Eggert
64b860c2f7 factor: mp insert multiplicity too
Support a multiplicity argument in the mp case, too.
This helps keeps the two cases in sync, for maintenance.
* src/factor.c (mp_factor_insert, mp_factor_insert_ui):
New arg M, for multiplicity.  All callers changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
258392808c factor: prefer non-macros
Use something other than a macro when that is easy and won’t hurt
performance.
* src/factor.c (__ll_B, __ll_lowpart, _ll_highpart) [!USE_LONGLONG_H]:
(MAX_NFACTS, highbit_to_mask, factor_insert, PRIMES_PTAB_ENTRIES):
Make these enums, or constants, or static functions instead of macros.
(highbit_to_mask): Rename from HIGHBIT_TO_MASK.  All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
fe136a9800 factor: let builder specify MR_REPS
* src/factor.c (MR_REPS): Let the builder specify it
with -DMR_REPS=whatever.
2025-07-09 17:12:39 -07:00
Paul Eggert
3e438e369c factor: add comments 2025-07-09 17:12:39 -07:00
Paul Eggert
77717f597e factor: factor insertion simplifications
* src/factor.c (factor_insert_multiplicity):
Adjust to keep in sync with mp_factor_insert changes below,
by adding 1 to the index and using memmove to move.
(mp_factor_insert): Omit redundant call to mpz_cmp.
Prefer idx_t (always nonnegative) to ptrdiff_t,
by adding 1 to the indexes.
Prefer mpz_init_set to mpz_init+mpz_set.
Use memmove to move, rather than doing it by hand.
2025-07-09 17:12:39 -07:00
Paul Eggert
374f5fdcc1 factor: check unsigned char counts
* src/factor.c (MAX_NFACTS): Allow word size of 128 bits,
even if this is only theoretical now.
Check that struct factors’s unsigned char counts won’t overflow.
2025-07-09 17:12:39 -07:00
Paul Eggert
5ae141ae14 factor: fix comment 2025-07-09 17:12:39 -07:00
Paul Eggert
a25d188098 factor: paren cleanup
* src/factor.c (umul_ppmm, udiv_qrnnd, addmod, addmod2, submod2)
(binv, divexact_21, redcify2, div_smallq): Omit unnecessary parens.
2025-07-09 17:12:39 -07:00
Paul Eggert
f14ddcb1ef factor: simplify longlong.h setup
* src/factor.c (USE_LONGLONG_H):
Default to false on unusual (but standard-conforming)
platforms that lack int64_t etc.
(UWtype, UHWtype): Now typedefs, not macros.
(UQItype): Remove.
(SItype, USItype, DItype, UDItype): Use standard C types.
2025-07-09 17:12:39 -07:00
Paul Eggert
0a5d071967 factor: prefer uuint to two words in a couple of places
This simplifies things slightly by using uuint for
some two-word integers.
* src/factor.c (strtouuint): Accept uuint *, not two mp_limb_t *.
All callers changed.
(print_factors_single): Accept uuint, not two limbs.
All callers changed.
(print_factors): Use simpler test for high bit,
one that need not worry about promoting to int.
2025-07-09 17:12:39 -07:00
Paul Eggert
59421d373b factor: FALLTHROUGH instead of break
* src/factor.c (print_factors): Use FALLTHROUGH
to make it clear that the "Use GMP" comment also applies here.
2025-07-09 17:12:39 -07:00
Paul Eggert
e7c1abfe79 factor: remove wide_uuint
Simplify by using GMP’s word type instead of pretending to roll our own.
* src/factor.c (wide_uuint): Remove.  All uses replaced by mp_limb_t.
(umul_ppmm) [!umul_ppmm]: Don’t assume unsigned long is at least half
as wide as mp_limb_t.  This simpler anyway.
(strtouuint): Rename from strto2wide_uint.  All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
d6ee61e407 factor: use same word size as GMP
Remove experimental code for 128-bit words as it does not work and
we lack time to figure out why.  Instead, ensure that words are
the same size as with GMP.
* src/factor.c (USE_INT128): Remove.  All uses removed.
(wide_uint, W_TYPE_SIZE): Define to be the same as GMP.
(MP_LIMB_MAX): New macro.  Check that it matches W_TYPE_SIZE.
(USE_LONGLONG_H): Default to true.
(UHWtype) [USE_LONGLONG_H]: Define to unsigned int, same as GMP.
(prime_p): Go back to not worrying about 128-bit words,
since GMP doesn’t worry and doesn’t use them.
(lbuf_putbitcnt): New function, since we cannot assume
that bitcnt_t fits into mp_limb_t.
(print_factors): Use it.
* src/make-prime-list.c (output_primes):
Don’t assume that wide_uint’s maximum is UINTMAX_MAX.
2025-07-09 17:12:39 -07:00
Paul Eggert
c8af57b5b8 factor: unsigned long → mp_bitcnt_t
* src/factor.c (struct mp_factors): e (multiplicity) member
is now of type mp_bitcnt_t, not unsigned long int, since
its value is at most a bit count.  All uses changed.
2025-07-09 17:12:39 -07:00
Paul Eggert
badc24c30c factor: fix test case name
* tests/factor/factor.pl (bug-gmp-plus_2_sup_127_plus_1):
Rename from bug-gmp-plus_2_sup_128_plus_1, so that
it accurately reflects the test case.
2025-07-09 17:12:39 -07:00
Paul Eggert
bdccb27ca6 factor: generalize BIG_POWER_OF_10
* src/factor.c (BIG_POWER_OF_10, LOG_BIG_POWER_OF_10):
Place fewer restrictions on BIG_POWER_OF_10.
This is only for currently-theoretical hosts;
it shouldn’t affect machine code on practical platforms.
2025-07-09 17:12:39 -07:00
Paul Eggert
88cca5d5fc factor: remove wide_int
* src/factor.c (wide_int): Remove, since it gets in the
way of using mp_limb_t for words.  All uses removed.
(submod2, HIGHBIT_TO_MASK, divexact_21):
Rewrite without using wide_int.
This shouldn't change the machine code these days,
as compilers are pretty smart about isolating the
top bit of an unsigned int.
2025-07-09 17:12:39 -07:00
Paul Eggert
397d9b02a3 factor: add platform sanity check
* src/factor.c: Check against theoretical platform.
2025-07-09 17:12:39 -07:00
Paul Eggert
8ff11d626b factor: squfof cleanup
* src/factor.c (USE_SQUFOF, STAT_SQUFOF):
Assume these are always false, and simplify the code accordingly.
We can bring it back later if needed be.
2025-07-09 17:12:39 -07:00
Paul Eggert
d7fd90d22d factor: don’t used uninitialized uu[0]
In practice there’s no bug but we might as well avoid the
undefined behavior.
* src/factor.c (hi_is_set): New static function.
(factor_insert_large, prime2_p, print_factors_single): Use it.
2025-07-09 17:12:39 -07:00
Pádraig Brady
fd59e4a955 build: avoid make distcheck error
* src/local.mk: Similarly to commit v8.22-156-g09937e9d0
track speedlist.h with nodist_src_stty_SOURCES and DISTCLEANFILES
to ensure the make distcheck manifest comparison passes.
Addresses https://bug.gnu.org/78960
2025-07-05 22:14:08 +01:00
Collin Funk
2230933f84 doc: fix a dead link
* doc/coreutils.texi (Block Size): Use an updated link to SI prefixes.
2025-07-05 09:57:29 -07:00
Pádraig Brady
1485eabfdd build: fix non parallel VPATH builds
* src/local.mk: Use the coarser BUILT_SOURCES mechanism
to generate speedlist.h, rather than a specific dependency
(which did seem to work for parallel builds).
Fixes https://bugs.gnu.org/78960
2025-07-05 12:49:02 +01:00
Collin Funk
e34a79a034 maint: prefer endian.h macros to WORDS_BIGENDIAN, part 2
* src/blake2/blake2-impl.h: Include endian.h. Use BYTE_ORDER and
LITTLE_ENDIAN instead of WORDS_BIGENDIAN.
2025-07-04 20:52:37 -07:00
Collin Funk
991934d9c9 maint: prefer endian.h macros to WORDS_BIGENDIAN
* src/od.c: Include endian.h.
(WORDS_BIGENDIAN): Remove definition.
(main): Use BYTE_ORDER, BIG_ENDIAN, LITTLE_ENDIAN instead of
WORDS_BIGENDIAN. Fix formatting.
2025-07-04 10:59:39 -07:00
Collin Funk
4db08f928e maint: add files generated by 'make ps' to .gitignore
* doc/.gitignore (/coreutils.ps, /coreutils.t2d/): Add entries.
2025-07-02 19:01:27 -07:00
Collin Funk
9cb89ff084 doc: remove outdated TODO/FIXME items
* TODO: Remove note about missing documentation for 'pinky' and '['.
* doc/coreutils.texi: Likewise.
2025-07-02 18:51:02 -07:00
Pádraig Brady
8771957703 tests: cat: add test for O_APPEND bug fix
* tests/cat/cat-self.sh: Add a test case
for commit v9.6-19-g7386c291b
2025-07-01 23:32:31 +01:00
Pádraig Brady
ab21f2e95e doc: remove extraneous double quotes within @samp{}
* doc/coreutils.texi (df invocation): @samp{} items
are suitably quoted already.
2025-07-01 12:02:08 +01:00
Collin Funk
1535ac272e doc: use ``...'' instead of "..."
* doc/coreutils.texi (split invocation): Use ``...'' for quoting text.
(cksum common options): Likewise.
(Control): Likewise.
2025-06-30 19:50:58 -07:00
Pádraig Brady
0512608a44 tests: avoid false failure due to varied ERANGE errors
* tests/od/od.pl: Use the system error string for ERANGE,
rather than hardcoding a particular one.
Fixes https://bugs.gnu.org/78934
2025-07-01 00:03:30 +01:00
Paul Eggert
48281e56a3 od: port to Apple clang 14
* src/od.c (print_function_type): New type.  Use it for convenience.
(width_bytes): Omit duplicate entries, such as ‘double’ vs ‘long
double’ on macOS.  Problem reported by Bruno Haible
<https://bugs.gnu.org/78933>.
(decode_one_format): Cast null pointer to print_function_type
to pacify Apple clang-1400.0.29.202.
2025-06-30 15:41:47 -07:00
Pádraig Brady
017fc50bb6 build: fix VPATH builds with --enable-single-binary
* src/local.mk: Adjust the dependency so that speedlist.h
is built irrespective of the object file name.
Note we could use BUILT_SOURCES for this,
but it's better to have this more accurate dependency.
2025-06-30 16:03:44 +01:00
Pádraig Brady
87dcd447b1 od: reinstate half float validation check
Reinstate check removed in commit 56aa549a0 so that we
disallow -f2 when configured with utils_cv_ieee_16_bit_supported=no.
Otherwise the output routines will consume floats,
i.e. 4 bytes at a time.  Without this extra check
the tests/od/od-endian.sh will fail with this configuration.

* src/od.c (decode_one_format): Reinstate the explicit check
for this configuration edge case.
2025-06-30 14:34:55 +01:00
Pádraig Brady
9075b2b8d2 maint: avoid sc_prohibit-quotearg failure
* src/od.c (parse_old_offset): s/quotearg_colon/quotef/.
2025-06-30 13:10:59 +01:00
Paul Eggert
5c5f069a4c od: add test cases for recent fix
* tests/od/od.pl: New tests for the offset issues
2025-06-29 22:32:05 -07:00
Paul Eggert
9002c04ccc od: more minor fixes for offsets
* src/od.c (parse_old_offset): Reject invalid offsets like "++0".
Treat overflowing offsets as errors, not as file names.
2025-06-29 22:26:14 -07:00
Paul Eggert
617220e970 od: refactor parse_old_offset
* src/od.c (parse_old_offset): Refactor for brevity and clarity.
2025-06-29 22:26:14 -07:00
Paul Eggert
3eb731e8ab maint: fix version in NEWS
* NEWS: Update version number as per Jim Meyering
<https://bugs.gnu.org/78880#46>.
2025-06-29 17:14:48 -07:00
Paul Eggert
dcdb2550c4 od: pacify gcc -Wduplicated-cond
Problem reported by Pádraig Brady <https://bugs.gnu.org/78880#43>.
This patch doesn’t fix any bugs; it merely pacifies GCC.
* src/od.c (ispec_to_format): New function, replacing
the old ISPEC_TO_FORMAT macro.  All uses changed.
This part of the change is just refactoring.
(decode_one_format): Pacify à la ispec_to_format.
2025-06-29 17:14:48 -07:00
Paul Eggert
25454fa34d od: be more consistent re sizeof
* src/od.c (width_bytes, decode_one_format): Don’t assume a signed
type has the same size as the corresponding unsigned type.
This has no effect on practical platforms; it’s just for
consistency there.
2025-06-28 21:00:41 -07:00
Paul Eggert
d5ea5e8aed od: fix integer overflow with large pseudos
* src/od.c (format_address_label): Diagnose overflow.
2025-06-28 21:00:41 -07:00
Paul Eggert
667be269ed od: speed up -S
* src/od.c (read_char): Use getc, not fgetc.
2025-06-28 21:00:41 -07:00
Paul Eggert
984dcc37f2 od: check sign bit more often
* src/od.c (read_char, dump_strings, main):
Instead of testing for an exact negative number,
just look at the sign bit.  This is a very minor tweak.
2025-06-28 21:00:41 -07:00
Paul Eggert
9aab4fb287 od: simplify away one loop copy
* src/od.c (dump): Coalesce two loops into one.
2025-06-28 21:00:41 -07:00
Paul Eggert
34b5043c6e od: simpler static initialization
* src/od.c (address_base, address_pad_len, format_address):
Initialize statically rather than dynamically.
(limit_bytes_to_format): Remove.  All uses replaced by
checking sign of end_offset.
(max_bytes_to_format): Remove static var.  Now local to ‘main’.
(end_offset): -1 now means no limit.  All uses changed.
2025-06-28 21:00:41 -07:00
Paul Eggert
0e104647a7 od: minor lcm tuning
* src/od.c (dump, main): Redo lcm calcuations to avoid a multiply.
2025-06-28 21:00:41 -07:00
Paul Eggert
56aa549a06 od: omit some duplicate code
On x86-64 (for example) print_long, print_long_long, and
print_intmax all behave identically, so give GCC enough info so
that it generates code for just one of these functions.
* src/od.c (enum size_spec): Arrange for enum values to
be the same if they represent types that behave the same.
(width_bytes, ISPEC_TO_FORMAT, decode_one_format):
Match the enum size_spec changes.
2025-06-28 21:00:41 -07:00
Paul Eggert
3ad59e19bc od: replace lookup tables with simple arithmetic
* src/od.c (FMT_BYTES_ALLOCATED): Use a simpler formula.
Although slightly too generous, the storage wasted is very small
and it pacifies gcc -Wformat-overflow=2.
(bytes_to_oct_digits, bytes_to_signed_dec_digits)
(bytes_to_unsigned_dec_digits, bytes_to_hex_digoits): Remove.
All uses replaced by algorithmic calculations, which are good
enough: they are valid for integers up to 2620 bits (!) and might
be slightly conservative for wider integers.  Remove related
static_asserts, which are no longer needed.
2025-06-28 21:00:41 -07:00
Paul Eggert
274226dbff od: support uintmax_t too
This has practical effect only on hypothetical platforms where
uintmax_t is wider than unsigned long long int.
* src/od.c (enum size_spec): New constant INTMAX.
(MAX_INTEGRAL_TYPE_WIDTH): Now equals UINTMAX_WIDTH.
(FMT_BYTES_ALLOCATED): Allow for the extra "l" in "%lld".
Also, fix off-by-two error in size calculation.
(width_bytes, integral_type_size): Add entries for uintmax_t.
(print_intmax): New function.
(decode_one_function): Use it.
(ISPEC_TO_FORMAT): New arg Max_fmt. All uses changed.
2025-06-28 21:00:41 -07:00
Paul Eggert
d8aaafc094 od: initialize type-size tables statically
* src/od.c (NO_SIZE): Make it explicitly 0, as the
initializers now rely on this.
(MAX_INTEGRAL_TYPE_SIZE): Remove.  All uses replaced by
ARRAY_CARDINALITY (integral_type_size) - 1.
Move static assertion down to where this can be used.
(integral_type_size, fp_type_size): Make them const,
and initialize them statically.
(main): Omit no-longer-needed initialization code.
2025-06-28 21:00:41 -07:00
Paul Eggert
4d527dda58 od: prefer intmax_t to uintmax_t
* src/od.c (MAX_ADDRESS_LENGTH, pseudo_offset, n_bytes_to_skip)
(max_bytes_to_format, end_offset, skip, format_address_none)
(format_address_std, format_address_paren, format_address_label)
(write_block, parse_old_offset, dump, dump_strings, main):
Prefer intmax_t to uintmax_t.  This makes no practical difference,
and lets -fsanitize=undefined check for signed integer overflow.
(skip, dump): Remove no-longer-needed casts.
(xstr2nonneg): New static function.  All callers of xstrtoumax
now call this function instead.
(main): Use ckd_add to detect signed integer overflow, since
the unsigned trick no longer works reliably.
Let xstrtol_fatal report the overflow, instead of doing
it by hand ourselves.
2025-06-28 21:00:41 -07:00
Paul Eggert
66464e61f5 od: fix '+N.' bug
* src/od.c (parse_old_offset): First arg is now char *,
not char const *.  If a decimal number, temporarily
modify the string so that xstrtoumax does not complain
about the '.'.
* tests/od/od.pl: Test for the bug.
2025-06-28 21:00:41 -07:00
Paul Eggert
88f30ee0a5 od: fix some unlikely integer overflows
* src/od.c (print_n_spaces, pad_at, pad_at_overflow):
New static functions.
(struct tspec, PRINT_FIELDS, print_named_ascii, print_ascii)
(decode_one_format, write_block, main):
Use idx_t, not int, for counts that depend on the number
of bytes in an object.
(decode_one_format): Use print_n_spaces to output spaces.
(PRINT_FIELDS, print_named_ascii, print_ascii):
Use pad_at to avoid integer overflow.
(write_block): Do not use %*s to pad, as the total pad might
exceed INT_MAX.  Instead, pad by hand with putchar (' ').
(main): Use pad_at_overflow to report integer overflow due to
oversize -w.  Use better way to tell whether -w is used,
without needing IF_LINT.
* tests/od/big-w.sh: New test.
* tests/local.mk (all_tests): Add it.
2025-06-28 21:00:41 -07:00
Paul Eggert
35d9bf6915 od: prefer idx_t to size_t
This helps find overflow bugs when compiling with -fsanitize=undefined.
* src/od.c (struct tspec, bytes_per_block, PRINT_FIELDS)
(PRINT_TYPE, print_named_ascii, print_ascii, decode_one_format)
(skip, write_block, read_block, dump, main):
Use idx_t, not size_t.
2025-06-28 21:00:41 -07:00
Paul Eggert
dbe4e2f428 od: don’t assume no holes in wide unsigned
Also, fix minor related typos.
* src/od.c (MAX_INTEGRAL_TYPE_SIZE, MAX_ADDRESS_LENGTH):
Now a constant, not a macro.
(MAX_INTEGRAL_TYPE_WIDTH): New constant.  Use it instead of
CHAR_BIT, so as not to assume that uintmax_t and unsigned long
long int are hole-free.  This doesn’t matter on practical porting
targets, though there is still a mainframe or two that have holes.
(FMT_BYTES_ALLOCATED): Fix typo by changing "jd" to "jo".
Fix off-by-one typo in static assertion.
2025-06-28 21:00:41 -07:00
Paul Eggert
671d79a0b7 maint: assume long long int
It’s long been safe to assume C99+ support for long long int.
* .gitignore: Remove m4/longlong.m4.
* bootstrap.conf (buildreq): Boost git prereq from 1.4.4 to 1.5.5,
syncing with Gnulib.
(bootstrap_post_import_hook): Remove m4/longlong.m4.
* m4/jm-macros.m4 (gl_CHECK_ALL_TYPES):
No need to require AC_TYPE_UNSIGNED_LONG_LONG_INT.
* src/factor.c (DItype, UDItype):
* src/od.c (main):
Assume HAVE_LONG_LONG_INT.
* src/od.c: (unsigned_long_long_int):
Remove.  All uses replaced with unsigned long long int.
2025-06-28 21:00:41 -07:00
Paul Eggert
69b07cc58d od: fix another off-by-one issue with --strings
* src/od.c (main): Fix off-by-one error in string_min limit.
2025-06-28 21:00:41 -07:00
Paul Eggert
0d1c25d1cb od: fix theoretical size_t malloc overflow
* src/od.c (dump, dump_strings): Use idx_t allocators
rather than size_t allocators, to avoid unchecked integer
overflow on theoretical platforms where SIZE_MAX < IDX_MAX.
2025-06-28 21:00:40 -07:00
Collin Funk
2a08ab2bd5 doc: list signals added by POSIX.1-2024
* doc/coreutils.texi (Signal specifications): Mention that POSIX.1-2024
added SIGWINCH.
2025-06-27 22:15:28 -07:00
Collin Funk
cc01e72491 doc: mention that POSIX.1-2024 added dd iflag=fullblock
* doc/coreutils.texi (dd invocation): Document that POSIX.1-2024 added
iflag=fullblock.
2025-06-27 20:10:09 -07:00
Pádraig Brady
7c2729cb58 doc: cksum: --check: improve supported formats description
* doc/coreutils.texi (cksum common options): Reorder and tweak the info
to make it clearer that --check does not support the legacy crc output
from the cksum command.
Reported at https://bugs.debian.org/1108363
2025-06-27 19:50:51 +01:00
Collin Funk
5a5b4a7810 maint: prefer UINTMAX_MAX to TYPE_MAXIMUM (uintmax_t)
* src/df.c (get_dev): Use UINTMAX_MAX.
* src/shred.c (dopass): Likewise.
2025-06-25 09:08:35 +01:00
Pádraig Brady
2b7f3621f8 od: output standard diagnostics for invalid -w arguments
* src/od.c (main): Don't pass LONGINT_OK to xstrtol_fatal(),
as otherwise it will abort().
* tests/od/od.pl: Add test cases.
* NEWS: Mention the bug fix.

Addresses https://bugs.gnu.org/78879
2025-06-24 16:37:01 +01:00
Pádraig Brady
44809c3379 od: fix various off-by-one issues with --strings with -N
* src/od.c (dump_strings): There are three related issues here
due to not accounting for the terminating NUL char appropriately.

1. Ensure BUF always has enough space for the terminating NUL.
This avoids CWE-122: Heap-based Buffer Overflow,
where we wrote a single NUL byte directly after the allocated buffer.
I.e., there should be no buffer overflow with:
  printf '%100s' | od -N100 -S1

2. Ensure we support -S == -N (END_OFFSET - STRING_MIN == ADDRESS):
I.e., there should be output with:
  printf '%100s' | od -N10 -S10

3. Ensure we always output a valid address by ensuring
the ADDRESS and I variables are kept in sync.
I.e., this should output address 0000000 not 1777777777777777777777:
  printf '%100s' | od -N10 -S1

As well as fixing these we simplify by using a single loop
to read the data, rather than two.

* doc/coreutils.texi (od invocation): Clarify that -N
implicitly NUL terminates strings.
* tests/od/od-N.sh: Add test cases.
* NEWS: Mention the bug fixes.

Fixes https://bugs.gnu.org/78880
2025-06-24 16:21:00 +01:00
Bruno Haible
63c040b879 build: fix compilation error on OpenBSD and Solaris
* src/speedgen: Use 'printf', not 'sed', to emit code with newlines.
2025-06-23 22:56:36 +01:00
H. Peter Anvin
7f82aef54e maint: make it clear when to add speeds to the speedgen list
Add a comment making it clear that it is perfectly safe to add
additional speeds to the canned list in the speedgen script, and under
what conditions it is appropriate to do so.

Signed-off-by: "H. Peter Anvin" (Intel) <hpa@zytor.com>
2025-06-23 22:15:27 +01:00
H. Peter Anvin
8c47af9be5 stty: support baud rate macro extraction on more compilers
For generating src/speedtest.h, try a sequence of command-line options
until (or unless) one of them works:

  -dM: gcc, clang and derived compilers, icc classic
  -xdumpmacros: Sun Studio (writes to stderr!)
  -qshowmacros: IBM XL classic
  -PD: MSVC (usable with a wrapper such as cccl from the SWIG project)

Because Sun Studio -xdumpmacros unconditionally writes to stderr,
capture stderr output instead of sending it to /dev/null. This is
perfectly safe, even in the presence of stray stderr output, because:

  1. speedgen ignores input that is not of the form #define B<number>
  2. even if a line of that format would somehow spuriously appear,
     the only outcome is that the generated C code will probe for a few
     more macros.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-06-23 22:13:51 +01:00
Collin Funk
c326f71230 stdbuf: support AIX
* src/stdbuf.c (set_LD_PRELOAD): Use the AIX specific environment
variables LDR_PRELOAD or LDR_PRELOAD64.
* NEWS: Mention the bugfix.
2025-06-23 13:16:32 +01:00
Pádraig Brady
3d35b3c0e5 stty: stricter floating point parsing
* src/stty.c (string_to_baud): Disallow extraneous characters
after floating point numbers.
* tests/stty/stty-invalid.sh: Add test cases.
2025-06-22 17:00:02 +01:00
Pádraig Brady
8b05eca972 doc: stty: adjust description of supported speeds
* doc/coreutils.texi (stty invocation): Remove now imprecise
list of speeds given we may now support higher or arbitrary speeds.
Mention that we may support higher or arbitrary speeds.
2025-06-22 15:01:21 +01:00
Collin Funk
b7db775783 build: add src/termios.c to the tarball
* src/local.mk (EXTRA_DIST): Add src/termios.c.
2025-06-22 11:33:16 +01:00
Collin Funk
1f6186b82c maint: use _GL_CMP instead of handwriting three-valued comparisons
* src/comm.c (compare_files): Use _GL_CMP.
* src/join.c (keycmp): Likewise.
* src/ls.c (off_cmp): Likewise.
* src/ptx.c (compare_words, compare_occurs): Likewise.
* src/set-fields.c (compare_ranges): Likewise.
* src/sort.c (compare_random, diff_reversed, compare): Likewise.
2025-06-22 11:33:11 +01:00
H. Peter Anvin
c00e4e2657 doc: NEWS: improve recent stty details
* src/NEWS: Fix grammar error,
and indicate baud rate probing is opportunistic.
2025-06-21 11:01:01 +01:00
Pádraig Brady
f40438900b tty: translate new error
* src/tty.c (main): Translate and adjust new ttyname() error
diagnostic, to be clearer and avoid a syntax check failure.
2025-06-21 10:59:46 +01:00
Paul Eggert
aec89a3e7d tty: better fix for Bug#26371
* src/tty.c (TTY_USAGE): Rename from TTY_FAILURE, since this
is used only for usage failures.  All uses changed.
(TTY_TTYNAME_FAILURE): New constant.
(main): Remove no-longer-needed assignment of ENOENT to errno.
Make status-setting clearer too.
Report an error if ttyname fails even though stdin is a terminal,
instead of silently pretending that stdin is not a terminal.
* tests/tty/tty.sh: Test for this issue.  This should fix Bug#78244.
2025-06-20 12:15:27 -07:00
Pádraig Brady
efaec80781 tests: stty: adjust tests for arbitary speeds
* tests/stty/stty-invalid.sh: Adjust to what is now invalid.
* tests/stty/stty.sh: Add checks for valid speed variants.
* tests/stty/bad-speed.sh: New test to ensure unsupported speeds
are diagnosed.
2025-06-18 14:21:30 +01:00
H. Peter Anvin
357fda90d1 stty: arbitrary or non-a priori known speed_t support
Support the case where speed_t is simply a number, and in that case
assume that arbitrary values can be passed.  This is assumed to be the
case when all known speed_t macros equal their own value.

Try to probe for a variety of speed_t constants by trying to coax
$(CC) into emitting macro definitions (-E -dM).  If this is not
supported, use a fairly extensive list of constants as a
fallback.  This both improves the test for arbitrary speed support, as
well as allowing proper operation in the case where the constants are
not plain numbers and allows for handing enumerated speed constants
that were not known a priori when the source code was written.

A simple shell script (mostly using sed) is used to turn the list of
constants (probed and predefined) into a pair of conversion functions,
baud_to_value() and value_to_baud(); string_to_baud() is then
reimplemented as a wrapper around the latter.

* src/.gitignore: Add generated speedlist.h.
* src/local.mk: Generate speedlist.h.
* src/speedgen: Portable shell script to generate speedlist.h.
* src/stty.c: Adjust string_to_baud to
convert from arbitrary numeric values.
* src/termios.c: A helper used when generating speedlist.h
* NEWS: Mention the improvement.
2025-06-18 14:20:17 +01:00
Paul Eggert
5c5e8b4a98 date: port test to NetBSD 10
Problem reported by Collin Funk in:
https://lists.gnu.org/r/bug-gnulib/2025-06/msg00094.html
* tests/date/date-debug.sh: Also allow NetBSD 10 mktime behavior.
Although NetBSD contradicts POSIX, POSIX is likely wrong here and
I vaguely recall that there’s a POSIX correction in progress
that will allow the NetBSD behavior.
2025-06-10 13:03:40 -07:00
Paul Eggert
276c04905f build: update gnulib submodule to latest
* tests/date/date-debug.sh: Update to match current behavior
of Gnulib's parse-datetime module.
2025-06-08 23:56:27 -07:00
Pádraig Brady
2f6a74920b doc: cp --help: mention --reflink=auto is now the default
* src/cp.c (usage): Reword the REFLINK description to
indicate that --reflink=auto is the default.
Fixes https://github.com/coreutils/coreutils/issues/103
2025-06-07 18:53:43 +01:00
Pádraig Brady
037b931061 doc: make command synopsis more consistent
* doc/coreutils.texi: Use @dots{} after [OPTION],
to be consistent with man pages.
* src/printenv.c (Usage): Remove unneeded "...".
* src/timeout.c (Usage): Add needed "...",
and also remove redundant [OPTION] only form.
* src/chroot.c (Usage): Likewise.
Fixes https://bugs.gnu.org/78628
2025-06-03 23:11:44 +01:00
Paul Eggert
4eb2ff1c89 cksum: port to Apple LLVM version 10.0.0
This compiler lacks support for the x86-64 VPCLMULQDQ instruction;
compiles fail with "error: invalid cpu feature string for builtin".
Problem reported by Peter Dyballa, and fix suggested by
Pádraig Brady <https://bugs.gnu.org/78562#8>.
* configure.ac (USE_AVX512_CRC32):
Also check that __builtin_cpu_supports ("vpclmulqdq") compiles.
2025-05-29 09:06:34 -07:00
Pádraig Brady
21a662b1ee tests: sort: expand multiple output testing
* tests/sort/sort.pl: Ensure duplicate
output strings are supported.
2025-05-28 21:11:34 +01:00
Paul Eggert
c8d75786b2 maint: assume O_DIRECTORY
Recent changes in Gnulib guarantee O_DIRECTORY != 0.
* gl/lib/targetdir.c (target_directory_operand):
* src/dd.c (usage):
* src/ln.c (main):
Simplify now that O_DIRECTORY must be nonzero.
2025-05-28 12:49:17 -07:00
Paul Eggert
c82b1f01ba build: update gnulib submodule to latest 2025-05-28 12:49:17 -07:00
Pádraig Brady
d3133bd38d maint: avoid a sc_system_h_headers failure
* cfg.mk: Also exclude libstdbuf.c from this check.
2025-05-24 22:01:44 +01:00
Paul Eggert
2b54fe97ff stdbuf: don’t allocate more than SIZE_MAX / 2
* src/libstdbuf.c (apply_mode): Be more conservative about
sizes passed to malloc, since we can’t rely on Gnulib malloc.
2025-05-24 13:02:31 -07:00
Paul Eggert
610725919c stdbuf: simplify apply_mode + getenv
* src/libstdbuf.c (apply_mode): Take getenv arg, not result.
All callers changed.  This is simpler.
2025-05-24 13:02:31 -07:00
Paul Eggert
69b1893585 stdbuf: port better to Mac OS X 10.4.11
Do not link to fchownat, fchmodat, xreallocarray.
While we’re at it, depend as little as possible on problematic
functions like fileno, strtoumax.  Use only functions that
were around in C89.
Problem reported by Peter Dyballa <https://bugs.gnu.org/78509#59>.
* src/libstdbuf.c: Include stddef.h, stdlib.h, gettext.h.
Do not include stdint.h or system.h.
(_): New macro, since we no longer include system.h.
Undef strtoul, not strtoumax.
(fileno_to_name): Remove.  All uses removed.
(apply_mode): New arg STREAM_NAME, so that we no longer need
to depend on fileno which might run into a Gnulib workaround.
Don’t allocate more than ULONG_MAX - 1 bytes, as that’s
not helpful in the real world and this lessens dependency
on newer features like strtoumax.
2025-05-24 13:02:31 -07:00
Pádraig Brady
dc4e6b6703 tests: avoid hung tests on older macOS
These tests were seen to hang on PPC Mac OS X 10.4.11

* tests/cp/existing-perm-race.sh: Protect fifo interactions
with a 1 minute timeout.
* tests/cp/file-perm-race.sh: Likewise.
Reported in https://bugs.gnu.org/78509
2025-05-21 21:22:08 +01:00
Pádraig Brady
8c9602e3a1 sort: fix buffer under-read (CWE-127)
* src/sort.c (begfield): Check pointer adjustment
to avoid Out-of-range pointer offset (CWE-823).
(limfield): Likewise.
* tests/sort/sort-field-limit.sh: Add a new test,
which triggers with ASAN or Valgrind.
* tests/local.mk: Reference the new test.
* NEWS: Mention bug fix introduced in v7.2 (2009).
Fixes https://bugs.gnu.org/78507
2025-05-20 19:36:00 +01:00
Paul Eggert
4469576154 maint: omit -Wmissing-variable-declarations from tests
* configure.ac (GNULIB_WARN_CFLAGS):
Omit -Wmissing-variable-declarations; needed for
gcc (GCC) 15.1.1 20250425 (Red Hat 15.1.1-1).
2025-05-18 23:34:51 -07:00
Pádraig Brady
1be322fd3e maint: avoid sc_preprocessor_indentation failure
* src/factor.c: Tweak preprocessor indentation.
2025-05-18 10:37:35 +01:00
Collin Funk
d8a7220142 build: generate src/crctab.c when building from git
* src/crctab.c: Remove file.
* src/cksum.c [!CRCTAB]: Include config.h.
* src/local.mk: Generate src/crctab.c in a temporary directory.
(EXTRA_DIST): Add src/crctab.c.
* .gitignore (/src/crctab.c): Add entry.
2025-05-18 09:49:29 +01:00
Collin Funk
dc6ce1d0c6 build: fix 'make distcheck'
* src/local.mk (EXTRA_DIST): Distribute src/make-prime-list.c
to satisfy the new make dependency.
2025-05-18 09:41:02 +01:00
Paul Eggert
fe51b33859 factor: fix bug with 128-bit uintmax_t
On so-far-only-theoretical platforms with 128-bit uintmax_t,
'factor' would misbehave by not factoring enough.
Work around the bug (at a performance cost)
and document the issue.  I hope someone with
more time and expertise can fix the performance cost
that this introduces.
To reproduce the correctness bug, build with
'gcc -DUSE_INT128 -DEXHIBIT_INT128_BUG';
'make check' should fail due to the new test case.
* src/factor.c (USE_INT128): New macro.
(wide_uint, wide_int, W_TYPE_SIZE, WIDE_UINT_MAX):
Define to proper values if USE_INT128.
(prime_p) [!EXHIBIT_INT128_BUG]: Work around bug
with 128-bit wide_uint, at some performance cost.
* tests/factor/factor.pl (bug-with-128-bit-uintmax_t):
New test.
2025-05-17 21:49:22 -07:00
Paul Eggert
c4fdbd95bd factor: refactor to allow non-uintmax_t ints
This prepares for using unsigned __int128 instead of uintmax_t.
It doesn’t change behavior.
* src/factor.c (wide_uint, wide_int):
New typedefs, replacing all uses of uintmax_t, intmax_t.
(WIDE_UINT_MAX): New macro, replacing all uses of UINTMAX_MAX.
(USE_LONGLONG_H): Don’t use LONG_MAX and INTMAX_MAX (which
should have been ULONG_MAX and UINTMAX_MAX anyway).
Instead, use W_TYPE_SIZE and ULONG_WIDTH, as that will be
easier to work with if we use unsigned __int128.
(binv): Also unroll for the 128-bit case.
* src/make-prime-list.c (print_wide_uint):
Print "wide_uint" not "uintmax_t".
2025-05-17 21:49:22 -07:00
Collin Funk
3844c15934 build: support cross-compiling directly from git checkout
* src/local.mk: Compile the make-prime-list in a temporary directory
using $(BUILD_CC) so it can be run even when $(CC) is a cross-compiler.
Add some comments.
(noinst_PROGRAMS): Remove src/make-prime-list.
(src_make_prime_list_LDADD): Remove variable.
* src/make-prime-list.c: Don't include config.h and attributes.h.
Remove unnecessary #undefs
(ATTRIBUTE_CONST, ATTRIBUTE_MALLOC): Define for the host compiler.
Fixes https://bugs.gnu.org/78377
2025-05-17 09:17:12 +01:00
Paul Eggert
c8cbb321d9 maint: --help now outputs bug reporting address
This changes the tail of "cat --help" output from:

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Full documentation <https://www.gnu.org/software/coreutils/cat>
or available locally via: info '(coreutils) cat invocation'

to:

Report bugs to: bug-coreutils@gnu.org
GNU coreutils home page: <https://www.gnu.org/software/coreutils/>
General help using GNU software: <https://www.gnu.org/gethelp/>
Full documentation <https://www.gnu.org/software/coreutils/cat>
or available locally via: info '(coreutils) cat invocation'

* src/system.h (emit_bug_reporting_address): Don’t #define.
(emit_ancillary_info): Call emit_bug_reporting_address
instead of doing it by hand, which omitted the bug reporting address.
2025-05-15 09:00:18 -07:00
Pádraig Brady
bd8be6b99e maint: avoid sc_gitignore_missing failure
* .gitignore: Add the soon to be generated lib/fts_.h
* cfg.mk (sc_gitignore_missing): Special case the mapping
of fts.in.h to fts_.h.
Fixes https://bugs.gnu.org/78398
2025-05-12 23:20:43 +01:00
Pádraig Brady
a11c7dcaaf doc: NEWS: fix introduced version of a bug
* NEWS: The NFSv4 trivial ACL ENOTSUP issue was introduced in 9.6.
2025-05-12 11:53:31 +01:00
Pádraig Brady
63e657e877 maint: avoid sc_GPL_version failure
* cfg.mk (VC_LIST_ALWAYS_EXCLUDE_REGEX): Exclude longlong.h also.
2025-05-12 11:51:16 +01:00
Collin Funk
d314730ea4 doc: suggest GNULIB_REFDIR instead of GNULIB_SRCDIR
* README-hacking: Use GNULIB_REFDIR instead of GNULIB_SRCDIR since that
is the correct way to have ./bootstrap do 'git clone --reference'.
2025-05-12 11:37:18 +01:00
Paul Eggert
8dd5b91d2c factor: check overflow with ckd_add etc
* src/factor.c (umul_ppmm, add_ssaaaa, sub_ddmmss, submod)
(mulredc, strto2wide_uint): Prefer ckd_add etc. to doing
overflow checking by hand.
2025-05-12 01:28:48 -07:00
Paul Eggert
229ddeb36a maint: pacify GCC when selinux is missing
* src/selinux.h (restorecon, defaultcon): Use MAYBE_UNUSED.
2025-05-12 01:28:48 -07:00
Paul Eggert
5e35f0e770 factor: be more cautious about C compiler versions
* src/factor.c (__GMP_GNUC_PREREQ): Define compatibly with GMP.
2025-05-12 01:28:48 -07:00
Paul Eggert
c1424ea25e maint: sync longlong.h from gmp
* .x-update-copyright: Add src/longlong.h.
* src/longlong.h: Sync from gmp.
2025-05-12 01:28:48 -07:00
Paul Eggert
4274ff6eee factor: omit incorrect affirms in mulredc2
* src/factor.c (mulredc2): Remove two ‘affirm’ calls that didn’t
match the accompanying comment, and one of which has a false
positive if UINTMAX_WIDTH == 128 and we factor 2**128 + 1.
2025-05-12 01:28:48 -07:00
Collin Funk
4ebc75a36f build: update gnulib submodule to latest
* bootstrap: Update using './bootstrap --bootstrap-sync'.
2025-05-11 10:20:59 -07:00
Paul Eggert
6bd4b1936e maint: update NEWS from Gnulib update 2025-05-09 22:36:19 -07:00
Paul Eggert
75258a69e9 build: update gnulib submodule to latest 2025-05-09 22:12:45 -07:00
Paul Eggert
36e83a6bcd maint: minor followon touchup of GCC warnings
* configure.ac (GNULIB_TEST_WARN_CFLAGS):
Do not use -Wsuggest-attribute=cold, -Wsuggest-attribute=const,
-Wsuggest-attribute=format as they produce false positives with
GCC 15 x86-64.  Use -Wmissing-variable-declarations, as it no
longer seems to hurt.
2025-05-09 21:02:56 -07:00
Paul Eggert
dbdb44de56 maint: modernize GCC warning configuration
* configure.ac: Simplify the setup of GCC’s -W... options,
by removing options no longer needed for GCC 15 (when
configuring with --enable-gcc-warnings) or GCC 12 (without).
I hope this is good enough nowadays.
Add GCC 15’s -Wtrailing-whitespace, since that works for us.
2025-05-09 15:57:13 -07:00
Paul Eggert
1fef50d07b maint: use MAYBE_UNUSED more consistently
* src/basenc.c (no_required_padding):
* gl/lib/smack.h (smack_new_label_from_self)
(smack_set_label_for_self):
* src/cksum.c (output_crc):
* src/digest.c (md5_sum_stream, sha1_sum_stream)
(sha224_sum_stream, sha256_sum_stream, sha384_sum_stream)
(sha512_sum_stream, sm3_sum_stream, output_file):
* src/stat.c (print_statfs, print_stat):
* src/sum.c (output_bsd, output_sysv):
* src/timeout.c (chld):
Mark possibly-unused parameters with MAYBE_UNUSED.
2025-05-09 15:57:13 -07:00
Paul Eggert
16d5cf3e66 maint: fix Automake warning
* Makefile.am (prologue): Remove macro, as \# is not portable here
and Automake complains.  Replace its only use with its definiens.
2025-05-09 15:57:13 -07:00
Pádraig Brady
6218cb18b0 tests: avoid false failures in user namespaces
* init.cfg (require_membership_in_two_groups_): Skip
overflow gids used in user namespaces, as one can't
chgrp() to these.
Fixes https://bugs.gnu.org/78225
2025-05-03 09:59:16 +01:00
Pádraig Brady
e7699b17b5 build: update to latest gnulib
* bootstrap.conf: Adjust for hash-triple module renaming.
* src/copy.c: Likewise.
* src/ln.c: Likewise.
* gnulib: Update to latest.
2025-05-01 14:05:59 +01:00
Pádraig Brady
3a5c9c5537 tests: add a test case for negative relative date
* tests/date/date.pl: To exercise option processing.
2025-04-23 12:47:54 +01:00
Pádraig Brady
948f4713fd tests: fix false failure with constrained setfacl
* tests/ls/acl.sh: In constrained environments, like with
setxattr() disabled for example, require_acl_ does not
check for the required functionality, so use the more
stringent require_setfacl_ instead.
Reported at https://github.com/NixOS/nixpkgs/issues/394953
2025-04-21 11:48:33 +01:00
Pádraig Brady
ca863e3f63 maint: map Jim's new email address
.mailmap: Add meta.com as an alias.
2025-04-19 13:46:23 +01:00
Paul Eggert
0d04b985d6 ls: omit a static var
* src/ls.c (file_has_aclinfo_cache): No need for unsupported_cached;
we can use unsupported_scontext.  Also, improve comments.
2025-04-12 13:00:24 -07:00
Pádraig Brady
356e40ff8e maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2025-04-09 12:14:12 +01:00
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
Pádraig Brady
ca22b9eba0 version 9.1
* NEWS: Record release date.
2022-04-15 22:10:07 +01:00
Pádraig Brady
0f2cf20af6 doc: avoid unicode errors in texi conversion
Avoid "Unicode character U+#1 not supported, sorry" error
when converting from texi to dvi or pdf.

* doc/coreutils.texi (tr invocation): Avoid the @U{XXXX}
texi representation, as even though info and html can represent
these characters directly, there are conversion errors
for pdf and dvi.  Instead use the more abstract shell
$'\uXXXX' representation.
2022-04-15 18:28:38 +01:00
Pádraig Brady
bcfbcef928 build: copy: fix build on macos 10.12
* src/copy.c (copy_reg): Handle the case where CLONE_NOOWNERCOPY
is not defined.
Reported by Jeffrey Walton
2022-04-14 13:37:23 +01:00
Pádraig Brady
87d5f1e17e tail: detect closed stdout on Solaris
* src/tail.c (check_output_alive): Use poll() on Solaris.
Also handle POLLHUP, which Solaris returns in this case.
* tests/tail-2/pipe-f.sh: Use `head -n2` rather than `sed 2q`
as Solaris sed does not exit in this case.
* NEWS: Mention the improvement.
Reported by Bruno Haible.
2022-04-13 20:10:14 +01:00
Pádraig Brady
48e15cef45 maint: syntax-check: fix preprocessor indentation
* gl/lib/targetdir.h: Keep '#' at start of line.
2022-04-13 12:21:01 +01:00
Paul Eggert
b411f21414 cp,mv,install: omit an ‘inline’
* gl/lib/targetdir.c (target_directory_operand):
Omit unnecessary ‘inline’.
2022-04-12 23:57:15 -07:00
Paul Eggert
f0a9f5e7da cp,mv,install: improve EACCES targetdir messages
This improves on the fix for --target-directory diagnostics bugs on
Solaris 11.  Problem reported by Bruno Haible and Pádraig Brady; see:
https://lists.gnu.org/r/coreutils/2022-04/msg00044.html
Also, omit some unnecessary stat calls.
* gl/lib/targetdir.c (target_directory_operand): If !O_DIRECTORY,
do not bother calling open if stat failed with errno != EOVERFLOW.
Rename is_a_dir to try_to_open since that’s closer to what it means.
If the open failed with EACCES and we used O_SEARCH, look at stat
results to see whether errno should be ENOTDIR for better diagnostics.
Treat EOVERFLOW as an “I don’t know whether it’s a directory and
there’s no easy way to find out” rather than as an error.
2022-04-12 23:57:15 -07:00
Paul Eggert
197a570ff0 cp,mv,install: avoid excess stat calls on non-GNU
* gl/lib/targetdir.c (target_directory_operand): New arg ST.
All callers changed.
* src/cp.c (do_copy):
* src/mv.c (main):
Avoid unnecessary stat call if target_directory_operand already
got the status.
2022-04-12 23:57:15 -07:00
Paul Eggert
30c932a309 cp,mv,install: modularize targetdir
Move target directory code out of system.h to a new targetdir module.
This doesn’t change functionality.
* bootstrap.conf (gnulib_modules): Add targetdir.
* src/cp.c, src/install.c, src/mv.c: Include targetdir.h.
* src/system.h (must_be_working_directory, target_directory_operand)
(targetdir_dirfd_valid): Move from here ...
* gl/lib/targetdir.c, gl/lib/targetdir.h, gl/modules/targetdir:
... to these new files.
2022-04-12 23:57:15 -07:00
Pádraig Brady
52139fd690 cp,mv,install: avoid EACCES with non directory destination
* src/system.h (target_directory_operand): Also check with stat()
on systems with O_SEARCH, to avoid open("file", O_SEARCH|O_DIRECTORY)
returning EACCES rather than ENOTDIR, which was seen on Solaris 11.4
when operating on non dirs without execute bit set.
* NEWS: Remove related bug entry, as that issue was only introduced
after coreutils v9.0 was released.
Reported by Bruno Haible.
2022-04-13 00:37:12 +01:00
Pádraig Brady
6e9bf0765f sync: support syncing files on cygwin
* src/sync.c (sync_arg): Similarly to AIX, Cygwin 2.9.0
was seen to need write access to have permission to sync a file.
2022-04-13 00:36:25 +01:00
Pádraig Brady
4f920e93ec tests: cygwin: handle ENOENT from execvp(".")
* tests/misc/env.sh: Verify with another command that
execvp() doesn not return ENOENT, before testing the
exit code from the command in question.
* tests/misc/nice-fail.sh: Likewise.
* tests/misc/stdbuf.sh: Likewise.
* tests/misc/timeout-parameters.sh: Likewise.
2022-04-13 00:36:25 +01:00
Pádraig Brady
f98dcbfc1c tests: env-S.pl: unset cygwin hardwired env vars
* tests/misc/env-S.pl: Unset SYSTEMROOT and WINDIR.
2022-04-13 00:36:25 +01:00
Pádraig Brady
028cad9149 tests: md5sum: fix false failures on cygwin
* tests/misc/md5sum-newline.pl: Avoid binary '*' tags when
comparing checksums.
* tests/misc/md5sum-bsd.sh: Avoid binary '*' tags so that we correctly
trigger the ambiguity test.
Reported by Bruno Haible
2022-04-12 13:30:50 +01:00
Pádraig Brady
2122ceba8e tests: b2sum.sh: fix false failure on cygwin
* tests/misc/b2sum.sh: Avoid binary '*' tags when comparing checksums.
Reported by Bruno Haible
2022-04-11 15:47:16 +01:00
Pádraig Brady
e43099f6e9 tests: dircolors.pl: avoid false failure with TERM=dumb
* tests/Coreutils.pm: Ensure an unset $TERM env var,
which is required on perl 5.22.2 on Solaris 11 OpenIndiana at least,
where TERM was being reset to 'dumb'.
Reported By Bruno Haible.
2022-04-11 15:47:16 +01:00
Pádraig Brady
021fc4fad2 tests: printf-mb.sh: fix false failure with french translations
* tests/misc/printf-mb.sh: As per commit 04148c99c,
adjust non C warnings before comparison, to those of LC_MESSAGES=C.
Reported by Adam Sampson
2022-04-11 15:46:57 +01:00
Pádraig Brady
046ab76166 tests: stty.sh: skip on systems without perl
* init.cfg (stty_reversible_init_): Add require_perl_
to ensure we skip rather than error, without perl.
2022-04-10 15:48:29 +01:00
Pádraig Brady
cc01b8a8f4 cp,mv,install: avoid opening non directory destination
commit v9.0-66-ge2daa8f79 introduced an issue, for example
where cp could hang when overwriting a destination fifo,
when it would try to open() the fifo on systems
like Solaris 10 that didn't support the O_DIRECTORY flag.

This is still racy on such systems, but only in the
case where a directory is replaced by a fifo in
the small window between stat() and open().

* src/system.h (target_directory_operand): On systems without
O_DIRECTORY, ensure the file is a directory before attempting to open().
* tests/cp/special-f.sh: Protect cp with timeout(1),
as cp was seen to hang when trying to overwrite an existing fifo.
* NEWS: Mention the bug fix.
2022-04-09 22:21:24 +01:00
Pádraig Brady
54bec51754 doc: install --compare: clarify mode of operation
* doc/coreutils.texi (install invocation): For the --compare option,
clarify that the ownership or permissions of the source files don't
matter.  Also don't imply --owner or --group need to be specified
for --compare to be effective.
* src/install.c (usage): Add more detail on what's being compared.
Fixes https://bugs.gnu.org/50889
2022-04-09 13:00:52 +01:00
Pádraig Brady
d28e369960 doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.27 which is now about 5 years old.
2022-04-08 17:08:32 +01:00
Bernhard Voelker
8f1f0dc975 maint: remove obsolete statat gnulib module
* bootstrap.conf (gnulib_modules): Remove statat.
2022-04-08 17:05:56 +01:00
Pádraig Brady
73c0c15225 build: update gnulib submodule to latest
* gnulib: Update to latest
* src/copy.c: Replace deprecated {l,}statat(), with fstatat().
* src/cp.c: Likewise.
* src/install.c: Likewise.
* src/remove.c: Likewise.
2022-04-07 17:38:17 +01:00
Pádraig Brady
224c1fee69 factor: improve support on RISCV and loongson
* src/longlong.h: Pull in RISCV fix and loongarch64 support from
https://gmplib.org/repo/gmp/log/tip/longlong.h
2022-04-04 13:41:32 +01:00
Pádraig Brady
8d9321ee0f doc: describe dd iseek as a feature not a change
* NEWS: Move description from "Changes in behavior"
to "New features".
2022-04-03 22:11:25 +01:00
Pádraig Brady
6b5134770d ls: avoid expensive capability lookup by default
Lookup of file-based capabilities adds 30% overhead to the common
case of ls --color usage.  Since the use of file capabilities is
very rare, it doesn't make sense to pay this cost in the common
case.  It's better to use getcap to inspect capabilities, and the
following run shows only 8 files using capabilities on my fedora
35 distro (14 years after the feature was introduced to the linux
kernel).

  $ getcap -r /
  /usr/bin/arping = cap_net_raw+p
  /usr/bin/clockdiff = cap_net_raw+p
  /usr/bin/gnome-keyring-daemon = cap_ipc_lock+ep
  /usr/bin/gnome-shell = cap_sys_nice+ep
  /usr/bin/newgidmap = cap_setgid+ep
  /usr/bin/newuidmap = cap_setuid+ep
  /usr/sbin/mtr-packet = cap_net_raw+ep
  /usr/sbin/suexec = cap_setgid,cap_setuid+ep

* src/dircolors.hin: Set "CAPABILITY" to "00", to indicate unused.
* src/ls.c: Set the default C_CAP color to not colored.
* NEWS: Mention the change in behavior.
2022-04-03 22:10:35 +01:00
Ville Skyttä
52aeae2c3d dircolors: colorize backup files with bright black
* src/dircolors.hin: Add patterns for suffixes for "backup files".
The color used is so they stand out less than non-backup files,
and bright black works well on both light and dark backgrounds.
* THANKS.in: Remove duplicate.
Fixes https://bugs.gnu.org/54521
2022-04-03 20:59:38 +01:00
Pádraig Brady
120ce321d5 doc: join: clarify that -e only effective for -12jo fields
* src/join.c (usage): Clarify that -e is not sufficient
to enable output of missing fields from one of the inputs.
Rather the -12jo options are required to explicitly
enable output of those fields.
Fixes https://bugs.gnu.org/54625
2022-03-29 16:34:10 +01:00
Pádraig Brady
e07c40c3ea maint: sync latest bootstrap from gnulib
* bootstrap: Should have updated this with the last gnulib update.
2022-03-25 19:08:28 +00:00
Pádraig Brady
500c697cc8 tests: improve recent printf test
* tests/misc/printf-mb.sh: Given we shortcut the single char
(invalid multi-byte) case, add a case to ensure we're correctly
checking the return from mbrtowc().
2022-03-20 17:46:13 +00:00
Pádraig Brady
6367cfe5fc printf: support printing the numeric value of multi-byte chars
* src/printf.c (STRTOX): Update to support multi-byte chars.
* tests/misc/printf-mb.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the improvement.
Fixes https://bugs.gnu.org/54388
2022-03-19 16:57:07 +00:00
Pádraig Brady
28adf9cf58 maint: move build-related NEWS item to its own section
* NEWS: Follow other Build-related patterns in NEWS.
2022-03-18 15:02:42 +00:00
Pádraig Brady
aa53e73974 doc: test: clarify that -rwx don't just check perm bits
* src/test.c (usage): State that -rwx is determined by
user access, rather than permission bits.
* doc/coreutils.texi (Access permission tests): Likewise.
* man/test.x [SEE ALSO]: access(2).
Fixes https://bugs.gnu.org/54338
2022-03-12 13:19:06 +00:00
Pádraig Brady
8767d75b9d maint: address syntax-check issues in recent commit
* cfg.mk (sc_die_EXIT_FAILURE): Generalize to match any EXIT_ define,
and also relax to ignore error() usage with ternary operator.
* src/chroot.c (main): Use () to avoid the sc_error_quotes check.
2022-03-07 23:33:25 +00:00
Pádraig Brady
92cb8427c5 stat: only automount with --cached=never
Revert to the default behavior before the introduction of statx().

* src/stat.c (do_stat): Set AT_NO_AUTOMOUNT without --cached=never.
* doc/coreutils.texi (stat invocation): Mention the automount
behavior with --cached=never.
* NEWS: Mention the change in behavior.

Fixes https://bugs.gnu.org/54287
2022-03-07 23:33:21 +00:00
Rohan Sable
85c975df2c ls: avoid triggering automounts
statx() has different defaults wrt automounting
compared to stat() or lstat(), so explicitly
set the AT_NO_AUTOMOUNT flag to suppress that behavior,
and avoid unintended operations or potential errors.

* src/ls.c (do_statx): Pass AT_NO_AUTOMOUNT to avoid this behavior.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/54286

Signed-off-by: Rohan Sable <rsable@redhat.com>
2022-03-07 23:26:42 +00:00
Pádraig Brady
3f61958495 build: ensure AT_NO_AUTOMOUNT is defined
update gnulib submodule to latest,
where this is the only change
2022-03-07 22:00:22 +00:00
Paul Eggert
4306bb6246 date: fix newly-introduced %%-N bug
* src/date.c (adjust_resolution): Don’t mishandle %%-N.
* tests/misc/date.pl (pct-pct): New test.
2022-03-05 11:23:38 -08:00
Paul Eggert
8f31074cb4 chown: warn about USER.GROUP
Suggested by Dan Jacobson (Bug#44770).
* src/chown.c, src/chroot.c (main):
Issue warnings if obsolete USER.GROUP notation is present.
2022-02-24 18:19:40 -08:00
Paul Eggert
3abaa2ad67 build: update gnulib submodule to latest 2022-02-24 18:19:40 -08:00
Pádraig Brady
6dc702928e fmt: fix invalid multi-byte splitting on macOS
On macOS, isspace(0x85) returns true,
which results in splitting within multi-byte characters.

* src/fmt.c (get_line): s/isspace/c_isspace/.
* tests/fmt/non-space.sh: Add a new test.
* tests/local.mk: Reference new test.
* NEWS: Mention the fix.
Addresses https://bugs.gnu.org/54124
2022-02-24 13:58:06 +00:00
Pádraig Brady
677fb3e4ab tests: improve compat with macOS
* tests/misc/wc-nbsp.sh: Only the en_US.iso8859-1 form
is accepted on macOS 10.15.7 at least.  GNU/Linux also
accepts ISO-8859-1 (and canonicalizes the charmap to this).
2022-02-24 13:58:06 +00:00
Paul Eggert
97e9778296 dd: counts ending in "B" now count bytes
This implements my suggestion in Bug#54112.
* src/dd.c (usage): Document the change.
(parse_integer, scanargs): Implement the change.
Omit some now-obsolete checks for invalid flags.
* tests/dd/bytes.sh: Test the new behavior, while retaining
checks for the now-obsolete usage.
* tests/dd/nocache_eof.sh: Avoid now-obsolete usage.
2022-02-22 18:56:53 -08:00
Paul Eggert
ef694d3448 dd: improve doc relative to POSIX
* doc/coreutils.texi (dd invocation): Improve documentation,
clarifying whether features are extensions to POSIX.
2022-02-22 09:04:27 -08:00
Paul Eggert
4439ef3ec4 dd: support iseek= and oseek=
Alias iseek=N to skip=N, oseek=N to seek=N (Bug#45648).
* src/dd.c (scanargs): Parse iseek= and oseek=.
* tests/dd/skip-seek.pl (sk-seek5): New test case.
2022-02-22 09:04:27 -08:00
Paul Eggert
3f7519130a cp: avoid unnecessary buffer allocation
Do not allocate I/O buffer if copy_file_range suffices.
* src/copy.c (sparse_copy, lseek_copy): Buffer arg is now char **
instead of char *, and buffer is now allocated only if needed.
All uses changed.
2022-02-21 00:19:24 -08:00
Paul Eggert
7dbe465fd3 build: update gnulib submodule to latest 2022-02-19 15:54:45 -08:00
Pádraig Brady
cee468f9c5 doc: env: fix man page reference of exec(2) to exec(3p)
* man/env.x: Change exec() reference from section 2 to 3p.
2022-02-15 17:07:22 +00:00
Pádraig Brady
63228501e6 doc: use bold style for man page references
It's more common to use bold style than not,
for references to other man pages.
Ideally each man page renderer would highlight references,
but currently some rely on styles in the page itself.

* man/help2man: Implement a --bold-refs option that
will mark up references like "name(1)" with bold
style around the "name" component.
* man/local.mk: Pass --bold-refs to our help2man unless disabled.
* configure.ac: Add a --disable-bold-man-page-references option.
Addresses https://bugs.gnu.org/53977
2022-02-15 17:07:22 +00:00
Pádraig Brady
041dfff5db dircolors: speed up processing of TERM entries
* src/dircolors.c (main): Avoid glob matching
when we've already matched in a group of {COLOR,}TERM entries.
2022-02-15 17:01:19 +00:00
Pádraig Brady
75c9fc6740 dircolors: consider COLORTERM as well as TERM env vars
COLORTERM is an environment used usually to expose truecolor support in
terminal emulators.  Therefore support matches on that in addition
to TERM.  Also set the default COLORTERM match pattern so that
we apply colors if COLORTERM is any value.

This implicitly supports a terminal like "foot"
without a need for an explicit TERM entry.

* NEWS: Mention the new feature.
* src/dircolors.c (main): Match COLORTERM like we do for TERM.
* src/dircolors.hin: Add default config to match any COLORTERM.
* tests/misc/dircolors.pl: Add test cases.
2022-02-15 17:01:19 +00:00
Paul Eggert
0b0f1965fb tr: mention multibyte problem in man page
* man/tr.x: Document tr problem.
2022-02-14 12:16:40 -08:00
Paul Eggert
8d3dce9861 tr: improve multibyte etc. doc
Problem reported by Dan Jacobson (Bug#48248).
* doc/coreutils.texi (tr invocation): Improve documentation for
tr's failure to support multibyte characters POSIX-style.
* doc/coreutils.texi (tr invocation), src/tr.c (usage):
Use terminology closer to POSIX's.
2022-02-14 12:03:49 -08:00
Pádraig Brady
abc4533fe4 dircolors: add --print-ls-colors to display colored entries
* NEWS: Mention the new feature.
* doc/coreutils.texi (dircolors invocation): Describe the new
--print-ls-colors option.
* src/dircolors.c (print_ls_colors): A new global to select
between shell or terminal output.
(append_entry): A new function refactored from dc_parse_stream()
to append the entry in the appropriate format.
(dc_parse_stream): Adjust to call append_entry().
* tests/misc/dircolors.pl: Add test cases.
2022-02-13 18:25:59 +00:00
Pádraig Brady
26db930c81 chown,chgrp: reinstate numeric id output in -v messages
since gnulib commit ff208d546a,
related to coreutils commit v9.0-143-gabde15969
we no longer maintain numeric IDs through chopt->{user,group}_name.
Therefore we need to adjust to ensure tests/chown/basic.sh passes.

* src/chown-core.c (uid_to_str, gid_to_str): New helper functions
to convert numeric id to string.
(change_file_owner): Use the above new functions to pass
numeric ids to describe_change().
2022-02-13 14:20:16 +00:00
Paul Eggert
d8047ae86d sort: fix several version-sort problems
This also affects ls -v in some corner cases.
Problems reported by Michael Debertol <https://bugs.gnu.org/49239>.
While looking into this, I spotted some more areas where the
code and documentation did not agree, or where the documentation
was unclear.  In some cases I changed the code; in others
the documentation.  I hope things are nailed down better now.
* doc/sort-version.texi: Distinguish more carefully between
characters and bytes.  Say that non-identical strings can
compare equal, since they now can.  Improve readability in
various ways.  Make it clearer that a suffix can be the
entire string.
* src/ls.c (cmp_version): Fall back on strcmp if filevercmp
reports equality, since filevercmp is no longer a total order.
* src/sort.c (keycompare): Use filenvercmp, to treat NULs correctly.
* tests/misc/ls-misc.pl (v_files):
Adjust test to match new behavior.
* tests/misc/sort-version.sh: Add tests for stability,
and for sorting with NUL bytes.
2022-02-12 20:15:03 -08:00
Paul Eggert
e7ccf4775e build: update gnulib submodule to latest 2022-02-12 20:15:02 -08:00
Pádraig Brady
195e943be7 doc: avoid using "[" is URLS in --help output
* src/system.h (emit_ancillary_info): While supported if entered
  manually, the "[" character is not highlighted as part of a
  URL by default in terminals, so avoid using it.
  Addresses https://bugs.gnu.org/53946
2022-02-12 18:43:25 +00:00
Pádraig Brady
d35b305109 doc: adust --help, --version alignment
* src/system.h: Adjust the alignment of the --help
and --version option descriptions, to start at column 21.
This better aligns with the descriptions of most commands,
and also aligns with the minimum column a description must
start at to ensure a blank line is not output when a description
follows an option on a line by itself.
2022-02-12 18:23:48 +00:00
Pádraig Brady
a4d8d58429 doc: rmdir: improve --help formatting
* src/rmdir.c (usage): Move description to column 21,
so that a --long-option on its own line without a
trailing description, doesn't have an erroneous blank
line inserted between the option and description.
Also group descriptions with blank lines rather than indents,
so that man pages don't have erroneous blank lines
added within the description.
Addresses https://bugs.gnu.org/53946
2022-02-12 18:16:34 +00:00
Pádraig Brady
dc689eba57 doc: ls: reference dircolors(1) from --help
* src/ls.c (usage): s/dircolors/dircolors(1)/.
* man/ls.x [SEE ALSO]: Reference dircolors(1).
Addresses https://bugs.gnu.org/53946
2022-02-12 18:03:38 +00:00
Pádraig Brady
353ba4978f doc: ls: improve --help formatting
* src/ls.c (usage): Use blank lines to group multi-line
option descriptions, rather than indenting.
This results in more consistent alignment of descriptions,
and also avoids erroneous new lines in generated in man pages.
Addresses https://bugs.gnu.org/53946
2022-02-12 17:55:03 +00:00
Paul Eggert
cedf627a90 doc: improve version-sort doc
* doc/coreutils.texi, doc/sort-version.texi:
Capitalize “Coreutils”.
* doc/sort-version.texi: Don’t emphasize natural sort so much,
since Coreutils has just version sort.
Use the term “lexicographic” instead of “alphabetic” or “standard”.
Suggest combining ‘V’ with ‘b’, and show why ‘b’ is needed.
Use shorter titles for sections, as GNU Emacs displays info poorly
when titles are too long to fit in a line.
Use @samp instead of @code for samples of data.
Do not use @samp{@code{...}}; @samp{...} should suffice and
double-nesting looks bad with Emacs.
Omit blank lines in examples that would not be present
in actual shell sessions.
Quote with `` and '', not with " or with '.
Mention dpkg --compare-versions more prominently.
Don’t rely on "\n" being equivalent to "\\n" in shell args.
Prefer Unicode name for hyphen-minus.
2022-02-08 10:52:43 -08:00
Christian Hesse
b65ff7e4d0 dircolors: highlight .avif as image
This add highlighting for AV1 Image File Format (AVIF):
https://aomediacodec.github.io/av1-avif/

* src/dircolors.hin: Highlight .avif as image.

Signed-off-by: Christian Hesse <mail@eworm.de>
2022-02-07 13:51:24 +00:00
Paul Eggert
8a3dedfef9 date: test against bug#50115
* tests/misc/date.pl: Add test.
2022-02-05 13:47:07 -08:00
Paul Eggert
cf6c849899 build: update gnulib submodule to latest 2022-02-05 13:47:07 -08:00
Pádraig Brady
b52d66452d doc: fix somewhat ambiguous date format representation
* doc/coreutils.texi (date invocation): Remove @var{...} usage,
as that capitalizes in the representation and thus somewhat
ambiguates the format wrt Month and Minute.  This also avoids
a syntax check failure about redundant capitalization in @var{}.
2022-02-05 12:53:19 +00:00
Paul Eggert
67cd2c3b72 date: improve doc
Problem reported by Dan Jacobson (Bug#51288).
* doc/coreutils.texi (date invocation, Setting the time)
(Options for date):
* src/date.c (usage): Improve doc.
2022-02-04 18:21:46 -08:00
Paul Eggert
413a6cf521 build: update gnulib submodule to latest 2022-02-04 17:43:45 -08:00
Paul Eggert
abde159693 id: print groups of listed name
Problem reported by Vladimir D. Seleznev (Bug#53631).
* src/id.c (main): Do not canonicalize user name before
deciding what groups the user belongs to.
2022-02-04 14:53:35 -08:00
Bernhard Voelker
9a29ee2903 doc: add NEWS entry for recent cksum change
* NEWS (Changes in behavior): Add entry for commit v9.0-92-ga42a03913.
2022-02-01 13:13:05 +00:00
Paul Eggert
59da65b7fe maint: suppress bogus noreturn warnings
* configure.ac: Move the single-binary code before the
gcc-warnings code, so that the latter can depend on the former.
Suppress -Wsuggest-attribute=noreturn with single binaries,
to avoid diagnostics like the following:
  src/expr.c: In function 'single_binary_main_expr':
  error: function might be candidate for attribute 'noreturn'
Problem reported by Pádraig Brady in:
https://lists.gnu.org/r/coreutils/2022-01/msg00061.html
2022-01-31 22:09:37 -08:00
Paul Eggert
1b552e73e8 tr: pacify -fsanitizer=leak
* src/tr.c (main): Use main_exit, not return, in a couple of
places missed last time.
2022-01-31 22:09:37 -08:00
Paul Eggert
222eee9631 chgrp: fix typo in previous change
* src/chgrp.c (main): Use main_exit, not exit.
2022-01-31 22:09:37 -08:00
Paul Eggert
bcc479b0b5 maint: mark some _Noreturn functions
* src/basenc.c (finish_and_exit, do_encode, do_decode):
* src/comm.c (compare_files):
* src/tsort.c (tsort):
* src/uptime.c (uptime):
Mark with _Noreturn.  Otherwise, unoptimized compilations may warn
that the calling renamed-main function doesn't return a value,
when !lint and when single-binary.
2022-01-31 22:09:37 -08:00
Paul Eggert
fb7579768d df: fix memory leak
* src/df.c (devlist_free): Remove.
(filter_mount_list): Free all of devlist, instead of merely
the entries in devlist_table.
2022-01-31 22:09:37 -08:00
Pádraig Brady
253a46d09f maint: cut: avoid exporting recently added variable
* src/cut.c: Make output_delimiter_default static,
as identified by `make syntax-check`.
2022-01-31 22:00:12 +00:00
Paul Eggert
eb3cd9e97b maint: pacify gcc -flto -Wmaybe-uninitialized
* gl/lib/xdectoint.c (__xnumtoint): Tell gcc that ‘error’
does not return here.
* gl/modules/xdectoint (Depends-on): Add stdbool, verify.
2022-01-31 12:07:39 -08:00
Paul Eggert
604f8a6c4d dd: do not access uninitialized
* src/dd.c (parse_integer): Avoid undefined behavior
that accesses an uninitialized ‘n’ when e == LONGINT_INVALID.
Return more-accurate error code when INTMAX_MAX < n.
2022-01-31 12:07:39 -08:00
Paul Eggert
d0e3b0ae1a uptime: simplify -fsanitize=leak pacification
* src/uptime.c (uptime): Exit here ...
(main): ... instead of here.
2022-01-31 12:07:39 -08:00
Paul Eggert
701fcbc78e uniq: remove IF_LINT
* src/uniq.c (check_file): Remove a no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
cb99998abe unexpand: remove IF_LINT
* src/unexpand.c (unexpand): Remove a no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
0ea9aacee9 pr: remove IF_LINT
* src/pr.c (read_line): Remove a no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
10ded12481 truncate: simplify
* src/truncate.c (do_ftruncate): Check != 0 instead of == -1.
Avoid a cast.
(main): Use C99 style decls after statements.
Simplify ‘open’ logic.
2022-01-31 12:07:39 -08:00
Paul Eggert
f8664b6c8e shred: remove IF_LINT
* src/shred.c (dopass): Remove a no-longer-needed IF_LINT.

(read_line): Remove an IF_LINT; no longer needed with
today’s GCC.
2022-01-31 12:07:39 -08:00
Paul Eggert
5288f5ab5e pr: simplify -fsanitize=leak pacification
* src/pr.c (main): Remove an IF_LINT.
Use main_exit rather than return.
2022-01-31 12:07:39 -08:00
Paul Eggert
75a87dc038 pinky: simplify -fsanitize=leak pacification
* src/pinky.c (short_pinky): exit instead of freeing.
2022-01-31 12:07:39 -08:00
Paul Eggert
00973ca777 paste: remove IF_LINT
* src/paste.c (paste_parallel): Remove no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
aafa9bf069 hostname: simplify
* src/hostname.c (sethostname): Provide a substitute on all
platforms, to simplify the mainline code.
(main): Simplify.  Remove an IF_LINT.
Use main_exit rather than return.
2022-01-31 12:07:39 -08:00
Paul Eggert
dba02d1996 factor: remove IF_LINT
* src/factor.c (factor_using_squfof) [USE_SQUFOF]:
Use plain assert (...), not IF_LINT (assert (...)).
This code is currently never compiled or executed,
so this is merely a symbolic cleanup.
2022-01-31 12:07:39 -08:00
Paul Eggert
ec8f3ea958 expand: remove IF_LINT
* src/expand.c (expand): Remove no-longer-needed IF_LINT.
2022-01-31 12:07:39 -08:00
Paul Eggert
ed93b50eea env: simplify -fsanitize=leak pacification
* src/env.c (unset_envvars): Remove IF_LINT code.
(main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
04d735ea96 md5sum: remove IF_LINTs
* src/digest.c (digest_check): Remove IF_LINTs that are no longer
needed, as GCC has gotten smarter since 2008.
2022-01-31 12:07:39 -08:00
Paul Eggert
c55372d0d8 df: simplify -fsanitize=leak pacification
* src/df.c (print_table, main) [lint]: Omit unnecessary cleanup.
(main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
7e7ecf20aa date: simplify -fsanitize=leak pacification
* src/date.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
423fed3dd8 cut: simplify and remove an IF_LINT
* src/cut.c (enum operating_mode, operating_mode)
(output_delimiter_specified, cut_stream):
Remove; no longer needed.
(output_delimiter_default): New static var.  Code can now
use ‘output_delimiter_string != output_delimiter_default’
instead of ‘output_delimiter_specified’.
(cut_file): New arg CUT_STREAM.  Caller changed.
(main): Simplify.  Coalesce duplicate code.  Redo to avoid need
for IF_LINT, or for the static var.  No need to xstrdup optarg.
2022-01-31 12:07:39 -08:00
Paul Eggert
22a0f9c32e cut: simplify -fsanitize=leak pacification
* src/set-fields.c (reset_fields): Remove, as it’s not needed for
-fsanitize=leak even when ‘lint’ is defined.  All uses removed.
2022-01-31 12:07:39 -08:00
Paul Eggert
836617fa12 cp: simplify GCC pacification
* src/cp.c (make_dir_parents_private): Remove IF_LINT code that is
no longer needed, as GCC has apparently gotten smarter since 2008.
2022-01-31 12:07:39 -08:00
Paul Eggert
904f9e3bf4 chown: simplify -fsanitize=leak pacification
* src/chgrp.c, src/chown.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
e55ffab35b basenc: simplify -fsanitize=leak pacification
* src/basenc.c (finish_and_exit): New function.
(do_encode, do_decode): Use it.  Accept new INFILE arg.  Remove
no-longer-needed IF_LINT code.  Exit when done.  Caller changed.
2022-01-31 12:07:39 -08:00
Paul Eggert
e2feea68ac test: simplify gcc pacification
* src/test.c (get_mtime) [lint]: Omit ifdef lint code that is no
longer needed, as GCC has gotten smarter since 2005.
2022-01-31 12:07:39 -08:00
Paul Eggert
a72fc9ba5f tail: simplify -fsanitize=leak pacification
Also, close a no-longer-needed file descriptor when falling
back from inotify.
* src/tail.c (tail_forever_inotify): Return void, not bool.  Exit
on fatal error, or on successful completion.  Accept an extra
argument pointing to a hash table that the caller should free on
non-fatal error; this simplifies cleanup.  Don’t bother setting
errno when returning.  Caller changed.
(main): Omit no-longer-needed IF_LINT code.  Close inotify
descriptor if inotify fails; this fixes a file descriptor leak and
means we needn’t call inotify_rm_watch.  Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
f3984a6dba tac: simplify -fsanitize=leak pacification
* src/tac.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
0106b5a4b8 shuf: simplify -fsanitize=leak pacification
* src/shuf.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
8692f2a6d3 numfmt: simplify -fsanitize=leak pacification
* src/numfmt.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
6ca7266666 mktemp: simplify -fsanitize=leak pacification
* src/mktemp.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
d85374258a dd: simplify -fsanitize=leak pacification
* src/dd.c (cleanup) [lint]: Omit unnecessary cleanup.
(main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
f21ccfb02c cp: simplify cp/install/ln/mv pacification
* src/copy.c (dest_info_free, src_info_free) [lint]:
Remove.  All uses removed.
(copy_internal): Pacify only Clang and Coverity; GCC doesn’t need it.
* src/cp-hash.c (forget_all) [lint]: Remove.  All uses removed.
* src/cp.c, src/install.c, src/ln.c, src/mv.c (main):
Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
b50b63e06c chmod: pacify -fsanitizer=leak
* src/chmod.c (main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
8fe6dd3b77 yes: pacify -fsanitizer=leak
* src/yes.c (main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
a7de740baa tsort: pacify -fsanitizer=leak
* src/tsort.c (detect_loop): Free removed successor.
2022-01-31 12:07:39 -08:00
Paul Eggert
a08853948c sort: pacify -fsanitizer=leak
* src/sort.c (pipe_fork, keycompare, sort, main):
Remove lint code that no longer seems to be needed.
(sort): Unconditionally compile ifdef lint code that is needed
to free storage even when not linting.
(main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
06b45ef985 split: pacify -fsanitizer=leak
* src/split.c (lines_rr): New arg FILESP.  All uses changed.
(main): Use main_exit, not return.  Omit unnecessary alignfree.
2022-01-31 12:07:39 -08:00
Paul Eggert
75b50689f1 ptx: pacify -fsanitizer=leak
* src/ptx.c (unescape_string): Rename from copy_unescaped_string,
and unescape the string in place.  Callers changed.  This way,
we needn’t allocate storage and thus needn’t worry about
-fsanitizer=leak.
2022-01-31 12:07:39 -08:00
Paul Eggert
b29f782a3f seq: pacify -fsanitizer=leak
* src/seq.c (seq_fast): If successful, exit rather than returning true.
Callers changed.
(main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
05e889b7d5 tsort: pacify -fsanitizer=leak
* src/tsort.c (struct item.balance): Now signed char to save space.
(struct item.printed): New member.
(new_item): Initialize k->printed to false.  Simplify via xzalloc.
(scan_zeros): Use k->printed rather than nulling out string.
(tsort): Move exiting code here ...
(main): ... from here.
(tsort) [lint]: Omit no-longer-needed code.  Instead, set head->printed.
2022-01-31 12:07:39 -08:00
Paul Eggert
1a83573596 tr: pacify -fsanitizer=leak
* src/tr.c (main): Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
7a9bda0477 stat: pacify -fsanitizer=leak
* src/stat.c (main):  Use main_exit, not return.
2022-01-31 12:07:39 -08:00
Paul Eggert
9b2a58ba64 comm: pacify -fsanitizer=leak
* src/comm.c (compare_files): Move exiting code here ...
(main): ... from here, to pacify gcc -fsanitize=leak.
2022-01-31 12:07:38 -08:00
Paul Eggert
afa93e8804 expr: lint cleanup, and introducing main_exit
This introduces a new macro main_exit, which is useful
for pacifying gcc -fsanitizer=lint and in some cases
means we can remove some ‘IF_LINT’ and ‘ifdef lint’ code.
* src/expr.c (main): Use main_exit, not return.
(docolon): Omit an IF_LINT that GCC no longer needs.
* src/system.h (main_exit): New macro.
2022-01-31 12:07:38 -08:00
Pádraig Brady
a42a039132 cksum: use more exact selection of digest algorithms
Use more constrained argument matching
to improve forward compatibility and robustness.

For example it's better that `cksum -a sha3` is _not_
equivalent to `cksum -a sha386`, so that a user
specifying `-a sha3` on an older cksum would not be surprised.

Also argmatch() is used when parsing tags from lines like:
SHA3 (filename) = abcedf....
so it's more robust that older cksum instances to fail
earlier in the parsing process, when parsing output from
possible future cksum implementations that might support SHA3.

* src/digest.c (algorithm_from_tag): Use argmatch_exact()
to ensure we don't match abbreviated algorithms.
(main): Likewise.
* tests/misc/cksum-a.sh: Add a test case.
2022-01-30 23:13:52 +00:00
Pádraig Brady
703e0487e4 build: update gnulib submodule to latest
To provide argmatch_exact() that does not
use abbreviated matching, to be used by cksum.
2022-01-30 20:34:29 +00:00
Paul Eggert
57c812cc3e mv: when installing to dir use dir-relative names
When the destination for mv is a directory, use functions like openat
to access the destination files, when such functions are available.
This should be more efficient and should avoid some race conditions.
Likewise for 'install'.
* src/cp.c (must_be_working_directory, target_directory_operand)
(target_dirfd_valid): Move from here ...
* src/system.h: ... to here, so that install and mv can use them.
Make them inline so GCC doesn’t complain.
* src/install.c (lchown) [HAVE_LCHOWN]: Remove; no longer needed.
(need_copy, copy_file, change_attributes, change_timestamps)
(install_file_in_file, install_file_in_dir):
New args for directory-relative names.  All uses changed.
Continue to pass full names as needed, for diagnostics and for
lower-level functions that do not support directory-relative names.
(install_file_in_dir): Update *TARGET_DIRFD as needed.
(main): Handle target-directory in the new, cp-like way.
* src/mv.c (remove_trailing_slashes): Remove static var; now local.
(do_move): New args for directory-relative names.  All uses changed.
Continue to pass full names as needed, for diagnostics and for
lower-level functions that do not support directory-relative names.
(movefile): Remove; no longer needed.
(main): Handle target-directory in the new, cp-like way.
* tests/install/basic-1.sh:
* tests/mv/diag.sh: Adjust to match new diagnostic wording.
2022-01-29 16:29:18 -08:00
Paul Eggert
534cfbb448 cp: fix comment typo 2022-01-29 16:29:18 -08:00
Pádraig Brady
795a16627c doc: NEWS: explain _why_ copy_file_range() is used
* NEWS: Mention why we're making the change in behavior in cat(1).
2022-01-28 15:13:25 +00:00
Pádraig Brady
2fb945ef77 build: update gnulib submodule to latest
To fix a syntax-check false failure
2022-01-28 15:07:14 +00:00
Paul Eggert
50e438972b dd: synchronize output after write errors
Problem reported by Sworddragon (Bug#51345).
* src/dd.c (cleanup): Synchronize output unless dd has been interrupted.
(synchronize_output): New function, split out from dd_copy.
Update conversions_mask so synchronization is done at most once.
(main): Do not die with the output file open, since we want to be
able to synchronize it before exiting.  Synchronize output before
exiting.
2022-01-28 00:01:55 -08:00
Paul Eggert
c4f9554ee9 dd: output final progress before syncing
Problem reported by Sworddragon (Bug#51482).
* src/dd.c (reported_w_bytes): New var.
(print_xfer_stats): Set it.
(dd_copy): Print a final progress report if useful before
synchronizing output data.
2022-01-27 18:35:02 -08:00
Paul Eggert
816d84f138 cat: prefer copy_file_range to read+write
* src/cat.c (copy_cat): New function.
(main): Use it.
2022-01-27 13:04:14 -08:00
Paul Eggert
3b98e21eed csplit: improve integer overflow checking
* src/csplit.c: Prefer signed integers to unsigned for sizes
when either will do.  Check for some unlikely overflows.
(INCR_SIZE): Remove; no longer used.
(free_buffer): Also free the arg, simplifying callers.
(get_new_buffer): Use xpalloc instead of computing new
size by hand.  Add ATTRIBUTE_DEALLOC.
(delete_all_files, close_output_file):
If unlink fails with ENOENT, treat it as success.
(close_output_file): If unlink fails, decrement count anyway.
(parse_repeat_count, parse_patterns): Check for int overflow.
(check_format_conv_type): Use signed format.
2022-01-27 13:04:14 -08:00
Paul Eggert
b973d2d44a maint: simplify memory alignment
Use the new Gnulib modules alignalloc and xalignalloc
to simplify some memory allocation.
Also, fix some unlikely integer overflow problems.
* bootstrap.conf (gnulib_modules): Add alignalloc, xalignalloc.
* src/cat.c, src/copy.c, src/dd.c, src/shred.c, src/split.c:
Include alignalloc.h.
* src/cat.c (main):
* src/copy.c (copy_reg):
* src/dd.c (alloc_ibuf, alloc_obuf):
* src/shred.c (dopass):
* src/split.c (main):
Use alignalloc/xalignalloc/alignfree instead of doing page
alignment by hand.
* src/cat.c (main):
Check for integer overflow in page size calculations.
* src/dd.c (INPUT_BLOCK_SLOP, OUTPUT_BLOCK_SLOP, MAX_BLOCKSIZE):
(real_ibuf, real_obuf) [lint]:
Remove; no longer needed.
(cleanup) [lint]:
(scanargs): Simplify.
* src/ioblksize.h (io_blksize): Do not allow blocksizes largest
than the largest power of two that fits in idx_t and size_t.
* src/shred.c (PAGE_ALIGN_SLOP, PATTERNBUF_SIZE): Remove.
2022-01-27 13:04:14 -08:00
Paul Eggert
1a8a566963 build: update gnulib submodule to latest 2022-01-27 13:04:14 -08:00
Paul Eggert
fbc7958b36 copy: remove unnecessary ‘free’
* src/copy.c (copy_reg): Remove a ‘free’ call that does nothing
because its argument is always a null pointer, starting with
2007-11-1608:31:15Z!jim@meyering.net.
2022-01-27 13:04:14 -08:00
Paul Eggert
f19bc026b3 dd: simplify conv=swab code
Simplify byte-swapping, so that the code no longer needs to
allocate a page before the input buffer.
* src/dd.c (SWAB_ALIGN_OFFSET, char_is_saved, saved_char): Remove.
All uses removed.
(INPUT_BLOCK_SLOP): Simplify to just page_size.
(alloc_ibuf, dd_copy): Adjust to new swab_buffer API.
(swab_buffer): New arg SAVED_BYTE, taking the place of the old
global variables.  Do not access BUF[-1].
2022-01-27 13:04:14 -08:00
Paul Eggert
e94d95075d dd: improve integer overflow checking
* src/dd.c: Prefer signed to unsigned types where either will do,
as this helps improve checking with gcc -fsanitize=undefined.
Limit the signed types to their intended ranges.
(MAX_BLOCKSIZE): Don’t exceed IDX_MAX - slop either.
(input_offset_overflow): Remove; overflow now denoted by negative.
(parse_integer): Return INTMAX_MAX on overflow, instead of unspecified.
Do not falsely report overflow for ‘00x99999999999999999999999999999’.
* tests/dd/misc.sh: New test for 00xBIG.
* tests/dd/skip-seek-past-file.sh: Adjust to new diagnostic wording.
New test for BIGxBIG.
2022-01-27 13:04:14 -08:00
Paul Eggert
e462d928b0 shred: fix declaration typo
* gl/lib/randint.h (randint_all_new):
Do not declare with _GL_ATTRIBUTE_NONNULL (), as
the arg can be a null pointer.  This fixes a typo added in
2021-11-01T05:30:28Z!eggert@cs.ucla.edu.
2022-01-27 13:04:14 -08:00
Paul Eggert
4ec55ec0bd cat: prefer signed to unsigned
* src/cat.c: Prefer signed to unsigned types
where either will do, as they allow for better
overflow checking at runtime.
2022-01-27 13:04:14 -08:00
Paul Eggert
a36bc1910f cat: improve style
* cat.c: Improve style a bit, mostly by assuming C99-style
declarations after statements
2022-01-27 13:04:14 -08:00
Pádraig Brady
4a0a8fdbec doc: csplit: clarify [OFFSET] syntax
* src/csplit.c (usage): Clarify that '+' prefix is optional on OFFSET.
* doc/coreutils.texi (csplit invocation): Likewise.
Fixes https://bugs.gnu.org/53574
2022-01-27 13:07:28 +00:00
Paul Eggert
2ba6fb653c build: allow readlinkat calls
Problem reported by Bernhard Voelker in:
https://lists.gnu.org/r/coreutils/2022-01/msg00026.html
* cfg.mk (sc_prohibit_readlink): Remove.  It’s OK to call
readlinkat to determine whether a file is a symbolic link.
2022-01-15 12:12:49 -08:00
Paul Eggert
b197885b2d cp: rely on Gnulib for copy_file_range workaround
Gnulib now replaces copy_file_range on buggy hosts
so there is no need for Coreutils to worry about the bug.
* src/copy.c: Do not include sys/utsname.h, xstrtol.h.
(functional_copy_file_range): Remove.  All uses now
simply call copy_file_range.
2022-01-14 17:44:49 -08:00
Paul Eggert
db539b7c34 build: update gnulib submodule to latest 2022-01-14 17:44:49 -08:00
Paul Eggert
6df8e86208 doc: fix pluralization typo 2022-01-14 15:47:41 -08:00
Paul Eggert
f39a02a744 cp: fix two typos in previous change
Somehow ‘make check’ didn’t catch these the first few times.
* src/copy.c (copy_dir): Don’t pass null pointer to
copy_internal where it now expects non-null if move mode.
* src/cp.c (make_dir_parents_private): Initialize *attr_list
before recentely-added quick return.
2022-01-14 15:17:54 -08:00
Paul Eggert
95d6754451 cp: omit unnecessary stat of destination
'cp A B' attempts to open B as a directory, to see whether to
write to B/A instead of to B.  In the common case where the
open fails with ENOENT, do not bother to stat B afterwards
since the stat should also fail with ENOENT.
* src/copy.c (copy_internal, copy): Change bool arg about
nonexistent destination to a 3-way int argument.  All callers changed.
(copy_internal): Do not bother to stat a destination already known
to not exist when following symlinks.
2022-01-14 14:09:25 -08:00
Paul Eggert
43fa191b5a build: update gnulib submodule to latest 2022-01-13 12:02:16 -08:00
Paul Eggert
e2daa8f797 cp: when copying to dir use dir-relative names
When copying to a directory, use functions like openat to access
the destination files, when such functions are available.  This
should be more efficient and should avoid some race conditions.
* bootstrap.conf (gnulib_modules): Add areadlinkat-with-size,
fchmodat, fchownat, mkdirat, mkfifoat, utimensat.
* src/copy.c (lchown) [!HAVE_LCHOWN]:
* src/copy.c, src/system.h (rpl_mkfifo, mkfifo) [!HAVE_MKFIFO]:
Remove.  All uses removed.
(utimens_symlink): Remove; we shouldn’t have to worry about
those obsolete systems any more.  All uses replaced by utimensat.
* src/copy.c (copy_dir, set_owner, fchmod_or_lchmod, copy_reg)
(same_file_ok, writable_destination, overwrite_ok, abandon_move)
(create_hard_link, src_is_dst_backup, copy_internal, copy):
* src/cp.c (make_dir_parents_private, re_protect):
New args for directory-relative names.  All uses changed.
Continue to pass full names as needed, for diagnostics and for
lower-level functions like qset_acl that do not support
directory-relative names.
* src/copy.c (copy_reg): Prefer readlinkat to lstatat for merely
checking whether a file is a symlink, to avoid EOVERFLOW issues.
(subst_suffix): New function.
(create_hard_link): Accept a null SRC_NAME as meaning that if it
is needed it needs to be constructed from SRC_RELNAME, DST_NAME,
and DST_RELNAME.
(source_is_dst_backup): Use subst_suffix instead of doing it by hand.
(copy_internal): Remember and use directory-relative names instead
of full names.
* src/cp.c (lchown) [!HAVE_LCHOWN]: Remove.  All uses removed.
(must_be_working_directory): New function.
(target_directory_operand): Simply take file name as arg,
and return a file descriptor or negative number on failure;
open with O_DIRECTORY to obtain any file descriptor.
All uses changed.
(target_dirfd_valid): New function.
(do_copy): Use these new functions to obtain a file descriptor
for any target directory, and use directory-relative names
for that directory.
(main): Omit no-longer-needed stat when --target-directory,
as do_copy now does this.
* src/ln.c (O_PATHSEARCH): Move from here ...
* src/system.h: ... to here.
* tests/cp/fail-perm.sh: Adjust to change in diagnostic wording,
and add a test for --no-target-directory.
2022-01-13 11:36:51 -08:00
Paul Eggert
3f488e1d52 cp: tweak internal name
* src/cp.c (do_copy): Omit confusingly-named local new_dest, since
there’s another var new_dst that means something quite different.
2022-01-13 11:36:51 -08:00
Daniel Knittl-Frank
95ec19ecbd scripts: fix typo in commit-msg git-hook script
Commit 2f438fa9f5 (basenc: A new program
complementary to base64/base32) introduced a typo in the list of allowed
commit message prefixes, accidentally changing "basename" to
"nbasename".  Revert it back to the correct "basename".
2022-01-12 22:59:30 +00:00
Paul Eggert
73bd6306d1 df: tiny simplification
* src/df.c (LOG_EQ): Remove.  All callers replaced by ==.
2022-01-07 14:56:55 -08:00
Pádraig Brady
3067a9293a maint: update all copyright year number ranges
Run "make update-copyright" and then...

* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
2022-01-02 16:15:55 +00:00
Pádraig Brady
76700e775e build: update gnulib submodule to latest
mainly to get updated copyright year

* doc/fdl.texi: Sync from gnulib.
* .gitignore: Add lib/unictype, as bitmap.h therein is depended on
since gnulib commit f698ea71
2022-01-02 16:14:40 +00:00
Paul Eggert
840ae54cf5 date: new option --resolution
* NEWS, doc/coreutils.texi (Options for date): Mention this.
* src/date.c (RESOLUTION_OPTION): New constant.
(DEBUG_DATE_PARSING_OPTION): Rename from DEBUG_DATE_PARSING.
All uses changed.
(long_options, usage, main): Support --resolution.
2021-12-31 10:53:29 -08:00
Paul Eggert
0cd39a246a date: %-N now means suppress extra digits
* NEWS, doc/coreutils.texi: Mention this.
* bootstrap.conf (gnulib_modules): Add gettime-res.
* src/date.c (res_width, adjust_resolution): New functions.
(main): Adjust %-N to be %9N, or whatever, before using it.
2021-12-31 10:53:29 -08:00
Paul Eggert
64b65cf4b8 build: update gnulib submodule to latest 2021-12-31 10:53:29 -08:00
Paul Eggert
1011b88594 doc: Document , vs . in date --rfc-3339=ns 2021-12-31 10:53:29 -08:00
Paul Eggert
6812e6baa7 build: port to AIX 7.1
This fixes a porting bug introduced in
2019-08-12T03:29:00Z!bruno@clisp.org.
Problem discovered on AIX 7.1.
* src/local.mk (LDADD): Add $(LIB_MBRTOWC), since pretty much
every command uses quotearg or mbrtowc or whatever.
(src_sort_LDADD): Add $(LIBPMULTITHREAD) and
$(LIB_PTHREAD_SIGMASK) instead of $(LIBTHREAD).
2021-12-31 10:53:29 -08:00
Paul Eggert
aa670bed50 build: be more careful about Perl
Problem reported by Serge Belyshev (Bug#52844).
* configure.ac (HAVE_PERL): Rely on latest Gnulib gl_PERL, which
sets gl_cv_prog_perl.
2021-12-28 02:03:42 -08:00
Paul Eggert
2f60fa465e build: update gnulib submodule to latest 2021-12-28 02:03:42 -08:00
Max Filippov
5bc9d92868 all: fix adjustment of /proc/$pid/cmdline by single binary
When configured with --enable-single-binary tools issue incorrect prctl:

  prctl(PR_SET_KEEPCAPS, ...)      = -1 EINVAL (Invalid argument)

PR_SET_MM_ARG_START is not a prctl 'option' parameter, it's 'arg2'
parameter for the option PR_SET_MM.  It also has to have 'arg4' and
'arg5' set to 0 explicitly, otherwise the kernel also returns -EINVAL.

* src/coreutils.c (launch_program): Fix prctl arguments.
* NEWS: Mention the improvement.
Fixes https://bugs.gnu.org/52800
2021-12-27 12:09:39 +00:00
Paul Eggert
5475fd6fe0 ls: improve doc for =WHEN
* src/ls.c (usage): Improve clarity of =WHEN args (Bug#52782).
2021-12-24 15:26:16 -08:00
Paul Eggert
d5ae6d8120 doc: colorize -> color
Living so close to Hollywood I know that "colorize"
means adding color to something that was already monochrome,
whereas "color" means to give color to something.
Coreutils apps color text instead of colorizing it.
2021-12-24 09:49:21 -08:00
Bernhard Voelker
1435e8e5c5 maint: update tests/init.sh from gnulib
* tests/init.sh: Sync from gnulib/tests/init.sh.
A recent gnulib update (4f497bf3c) missed this.
2021-12-20 23:13:36 +01:00
Jim Meyering
eb2400fb9f maint: syntax-check requires "char const *", not "const char *"
* gl/lib/mbsalign.c (mbs_align_pad): Adjust.
* src/chroot.c (is_root): Adjust.
* src/digest.c (main): Adjust.
* src/relpath.c (buffer_or_output) Adjust.
* src/ls.c (print_name_with_quoting, get_color_indicator): Adjust.
2021-12-20 12:50:08 -08:00
Jim Meyering
1cfbd4548d maint: split a long line
* src/test.c (three_arguments): Split long line.
2021-12-20 12:50:08 -08:00
Jim Meyering
a2b21e9105 maint: commit-msg: compute UTF-8-aware line-length
* scripts/git-hooks/commit-msg: Count UTF-8 characters rather
than bytes to avoid erroneously rejecting as "longer than 72" a
log message line like the UTF-8 one for id.c just prior.  It has
77 bytes but only 67 characters.
(check_msg): Read in "utf8" mode. Also include actual length
in the diagnostic.
(main): Don't loop when stdout is redirected, as it is when
invoked via vc-dwim.
Paul Eggert reported privately both the error of counting bytes
rather than chars and the re_edit loop when failing via vc-dwim.
2021-12-20 10:46:11 -08:00
Paul Eggert
915a5e3360 id: improve doc for when USER is omitted
* src/id.c (usage): “current user” → “current process” (Bug#52656).
2021-12-19 09:17:08 -08:00
Paul Eggert
8621e44cda maint: use GNU style for spacing 2021-12-18 09:35:04 -08:00
Bruno Haible
3bf118dad0 build: non-recursive Automake in a less hacky way
* bootstrap.conf (gnulib_modules): Remove
non-recursive-gnulib-prefix-hack.
(gnulib_tool_option_extras): Add --automake-subdir.
(bootstrap_post_import_hook): No need to massage lib/gnulib.mk.
2021-12-16 09:33:12 -08:00
Paul Eggert
064b31eb48 build: update bootstrap to latest 2021-12-16 09:33:12 -08:00
Paul Eggert
1827ae8243 build: update gnulib submodule to latest 2021-12-16 09:33:12 -08:00
Jim Meyering
bbc5e84513 maint: factor.c: avoid new GCC 12 warning
* src/factor.c (millerrabin2): Mark as ATTRIBUTE_PURE,
per advice from GCC 12.
2021-12-14 19:52:50 -08:00
Paul Eggert
bfc7a9b5e0 build: update gnulib submodule to latest
* NEWS: Mention the bugfix.
2021-12-14 12:47:36 -08:00
Paul Eggert
8931d571d0 mv: Bug#52410 fix
The recent Gnulib update fixed this bug reported by Vincent Vermilya.
* tests/mv/backup-dir.sh: Test for Bug#52410.
2021-12-10 14:10:51 -08:00
Paul Eggert
4f497bf3c7 build: update gnulib submodule to latest 2021-12-10 14:10:50 -08:00
Paul Eggert
e3d1ff0437 uname: port to recent macOS
Problem reported by Jakub Sokołowski (bug #52330).
* src/uname.c [__APPLE__]: Don’t include sys/syctl.h,
mach/machine.h, mach-o/arch.h.
(print_element_env): New function.  With __APPLE__, it defers to the
env var UNAME_MACHINE (if given) for uname -m, and similarly for -nrsv.
(main): Use it.  For -p with __APPLE__, rely on predefined macros
and omit any 64-bit indication, for compatibility with macOS uname.
2021-12-07 14:00:42 -08:00
Paul Eggert
5e36c0ce07 cp: clone on macOS
* configure.ac: Check for fclonefileat.
* src/copy.c [HAVE_FCLONEFILEAT && !USE_XATTR]:
Include <sys/clonefile.h>.
(copy_reg): If possible, use fclonefileat to clone.
2021-11-21 19:13:03 -08:00
Paul Eggert
41bec08d7a cp: streamline cloning by skipping fstat
* src/copy.c (copy_reg): Attempt clone_file before fstat of dest,
so that if clone_file succeeds we can skip the fstat.
2021-11-21 12:32:46 -08:00
Paul Eggert
5012223d78 cp: fix --preserve=ownership permissions bug
This fixes a bug that I introduced in
2006-12-06T19:44:08Z!eggert@cs.ucla.edu.
* src/copy.c (USE_XATTR): New macro.
(copy_reg): Use it to help the compiler.  Prefer open u+w to a
later chmod u=rw; u+r isn’t needed for xattr.  For the later u-r,
do only one (or zero) chmod calls instead of two (or one).
In the last chmod, respect the umask instead of ignoring it.
* tests/cp/preserve-mode.sh: Test for the bug.
2021-11-20 13:50:35 -08:00
Paul Eggert
3e2d644483 maint: prefer MAYBE_UNUSED
Prefer MAYBE_UNUSED to _GL_UNUSED, since the C2x syntax
will be [[maybe_unused]] at the start of the declaration,
and we want to look forward to that.  All uses of _GL_UNUSED
either changed to MAYBE_UNUSED, or (when not needed) removed.
2021-11-18 21:37:38 -08:00
Paul Eggert
d0f035fc64 cp: fix security context race
This fixes an issue introduced in the fix for Bug#11100.
* NEWS: Mention this.
* src/copy.c (copy_reg): Fix obscure bug where open-without-CREAT
failed with ENOENT and we forget to call set_process_security_ctx
before calling open-with-CREAT. Also, don’t bother to unlink
DST_NAME if open failed with ENOENT; and if unlink fails with
ENOENT, don’t consider that to be an error (someone else could
have removed the file for us, and that’s OK).  Also, don’t worry
about move mode, since we use O_EXCL|O_CREAT and so won’t open
an existing file.
2021-11-18 08:31:59 -08:00
Paul Eggert
0f84467a34 maint: update NEWS for macOS fix 2021-11-16 17:06:36 -08:00
Paul Eggert
0060ef82ee cp: minor clarity tweak
* src/copy.c (copy_reg): Use cached data_copy_required.
2021-11-16 16:51:44 -08:00
Paul Eggert
08930f21cb cp: fix ptrdiff_t/ssize_t theoretical glitches
* src/copy.c (sparse_copy): Use system.h’s SSIZE_MAX.
Don’t assume SSIZE_MAX <= PTRDIFF_MAX.
2021-11-16 16:11:27 -08:00
Paul Eggert
eae8df0d94 build: update gnulib submodule to latest 2021-11-15 22:36:57 -08:00
Paul Eggert
1b988ffa95 maint: fix nonnull decl
* gl/lib/randread.h (randread_new): Do not mark with
_GL_ATTRIBUTE_RETURNS_NONNULL, since it can return NULL.
2021-11-15 22:22:24 -08:00
Paul Eggert
0f4d9e849b build: update gnulib submodule to latest 2021-11-15 15:26:19 -08:00
Pádraig Brady
2378a53143 tests: avoid false failure in env-signal-handler.sh
* tests/misc/env-signal-handler.sh: Use retry_delay_ to
avoid a false failure under load, where env hasn't setup
the SIGINT handling before timeout(1) sends the SIGINT.
Fixes https://bugs.gnu.org/51793
2021-11-13 14:38:08 +00:00
Pádraig Brady
a0468760ff maint: fix recent syntax-check failures
* cfg.mk (exclude_file_name_regexp--sc_system_h_headers):
Add chown-core.h to the regexp, to better decouple from system.h.
* src/env.c: Remove minmax.h include already included in system.h.
* src/libstdbuf.c: Likewise.
* src/prog-fprintf.h: Remove doubled semicolon.
2021-11-01 13:45:15 +00:00
Paul Eggert
ea02406748 maint: use minmax.h instead of rolling our own
* gl/lib/mbsalign.c, gl/lib/randread.c, src/system.h (MAX, MIN):
Remove; include minmax.h instead.
* gl/modules/mbsalign, gl/modules/randread (Depends-on): Add minmax.
* src/factor.c (MIN): Remove.
2021-10-31 22:36:46 -07:00
Paul Eggert
9f8a38414b maint: add function attributes to .h files
Add _GL_ATTRIBUTE_NONNULL, _GL_ATTRIBUTE_MALLOC,
_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DALLOC_FREE,
_GL_ATTRIBUTE_RETURNS_NONNULL to .h files when appropriate.
* gl/lib/mbsalign.h, gl/lib/randperm.h, src/chown-core.h:
Include stdlib.h, for the benefit of _GL_ATTRIBUTE_DALLOC_FREE.
* gl/lib/randread.c (randread_free_body): New static function.
(randread_new, randread_free): Use it.
* src/copy.c (valid_options): Remove assert that is no longer
needed because it is now checked statically.
2021-10-31 22:36:46 -07:00
Paul Eggert
25e68323b9 maint: enable -Wsuggest-attribute=format
* configure.ac (WERROR_CFLAGS): Enable -Wsuggest-attribute=format
for lib/ and src/.
* src/copy.c (copy_attr_error, copy_attr_allerror):
Add ATTRIBUTE_FORMAT.
(copy_attr): Ignore -Wsuggest-attribute=format in the
small section of code that needs it ignored.
* src/test.c (test_syntax_error): Mark with ATTRIBUTE_FORMAT.
(binary_operator): Omit unnecessary NULL args, pacifying
-Wsuggest-attribute=format.
2021-10-31 22:36:46 -07:00
Paul Eggert
d16821975e maint: modernize attribute usage
* src/system.h (__attribute__): Remove.  Replace all uses that
rely on this by _GL_ATTRIBUTE_xxx or ATTRIBUTE_xxx.
(ATTRIBUTE_WARN_UNUSED_RESULT): Remove.  Replace all uses by
NODISCARD.
2021-10-31 22:36:46 -07:00
Paul Eggert
9287ce5bbc maint: remove unused __attribute__ defn
* gl/lib/randread.c (__attribute__): Remove; no longer
used after the recent _Noreturn change.
2021-10-31 22:36:46 -07:00
Paul Eggert
2a9bacee50 b2sum: simplify attribute usage
* src/blake2/blake2.h (BLAKE2_PACKED): Simplify, and port better
to older GCC, by using _GL_ATTRIBUTE_PACKED.
2021-10-31 22:36:46 -07:00
Paul Eggert
389e766367 maint: prefer attribute.h in .c files
This will help us make the transition to C2x, where some
attributes must come at the start of function decls.
Leave the attributes alone in .h files for now,
as the Gnulib tradition is to not expose attribute.h to users.
* bootstrap.conf (gnulib_modules): Add ‘attribute’.
* gl/lib/randperm.c, src/make-prime-list.c, src/system.h:
Include attribute.h.
* gl/lib/strnumcmp.c (strnumcmp): Remove _GL_ATTRIBUTE_PURE here,
as this belongs in the .h file.
* gl/lib/strnumcmp.h (strnumcmp): Add _GL_ATTRIBUTE_PURE here.
* src/sort.c (human_numcompare, numcompare): Now ATTRIBUTE_PURE;
discovered due to strnumcmp.h change.
* gl/lib/randperm.c, src/copy.c, src/dd.c, src/df.c, src/digest.c:
* src/env.c, src/expr.c, src/factor.c, src/ls.c:
* src/make-prime-list.c, src/numfmt.c, src/od.c, src/pathchk.c:
* src/pinky.c, src/pr.c, src/ptx.c, src/realpath.c, src/relpath.c:
* src/seq.c, src/sort.c, src/stat.c, src/stty.c, src/system.h:
* src/tr.c, src/uniq.c, src/wc.c:
In .c files, crefer ATTRIBUTE_CONST to _GL_ATTRIBUTE_CONST, and
similarly for ATTRIBUTE_FORMAT and ATTRIBUTE_PURE.
* src/system.h (FALLTHROUGH): Remove; attribute.h defines it.
2021-10-31 22:36:46 -07:00
Pádraig Brady
bafff0019c sort: --debug: add warnings about sign, radix, and grouping chars
New warnings are added related to the handling
of thousands grouping characters, decimal points, and sign characters.
Examples now diagnosed are:

$ printf '0,9\n1,a\n' | sort -nk1 --debug -t, -s
sort: key 1 is numeric and spans multiple fields
sort: field separator ‘,’ is treated as a group separator in numbers
1,a
_
0,9
___

$ printf '1,a\n0,9\n' | LC_ALL=fr_FR.utf8 sort -gk1 --debug -t, -s
sort: key 1 is numeric and spans multiple fields
sort: field separator ‘,’ is treated as a decimal point in numbers
0,9
___
1,a
__

$ printf '1.0\n0.9\n' | LC_ALL=fr_FR.utf8 sort -s -k1,1g --debug
sort: note numbers use ‘,’ as a decimal point in this locale
0.9
_
1.0
_

$ LC_ALL=fr_FR.utf8 sort -n --debug /dev/null
sort: text ordering performed using ‘fr_FR.utf8’ sorting rules
sort: note numbers use ‘,’ as a decimal point in this locale
sort: the multi-byte number group separator in this locale \
      is not supported

$ sort --debug -t- -k1n /dev/null
sort: key 1 is numeric and spans multiple fields
sort: field separator ‘-’ is treated as a minus sign in numbers
sort: note numbers use ‘.’ as a decimal point in this locale

$ sort --debug -t+ -k1g /dev/null
sort: key 1 is numeric and spans multiple fields
sort: field separator ‘+’ is treated as a plus sign in numbers
sort: note numbers use ‘.’ as a decimal point in this locale

* src/sort.c (key_warnings): Add the warnings above.
* tests/misc/sort-debug-warn.sh: Add test cases.
Also check that all sort invocations succeed.
* NEWS: Mention the improvement.
Addresses https://bugs.gnu.org/51011
2021-10-31 23:19:05 +00:00
Paul Eggert
aa31b919ca maint: modernize README-{hacking,prereq} 2021-10-30 16:28:25 -07:00
Paul Eggert
1753012b8d cp: revert unnecessary FreeBSD workaround
That was a false alarm due to a bug in FreeBSD 9.1 truss;
see Pádraig Brady’s report (Bug#51433#29).
* src/copy.c (lseek_copy, infer_scantype): Don’t bother checking
whether lseek returned -1.  This doesn’t entirely revert the
previous change, as it keeps the code simplification of the
previous change while reverting the check for -1.
2021-10-30 10:04:54 -07:00
Paul Eggert
a9e31457bf cp: defend better against FreeBSD 9.1 zfs bug
Problem reported by Pádraig Brady (Bug#51433#14).
* src/copy.c (lseek_copy, infer_scantype): Report an error if
lseek with SEEK_DATA or SEEK_HOLE returns less than -1,
as this is an lseek bug.
2021-10-29 18:23:54 -07:00
Pádraig Brady
f60a3981c3 doc: say that printf(1) is preferred over echo(1)
* src/echo.c (usage): Say printf(1) is preferred
due to being more standard and robust.
* man/echo.x [SEE ALSO]: Reference printf(1).
* doc/coreutils.texi (echo invocation): Mention in the
summary that echo is not robust when outputting
any string, and that printf is preferred.
Also expand on the examples showing how to
output a single '-n' string.
Addresses https://bugs.gnu.org/51311
2021-10-22 15:12:33 +01:00
Pádraig Brady
13af84d09a doc: timeout --kill-after: clarify disabled timeouts
* doc/coreutils.texi (timeout invocation): Clarify
that -k is ignored if either its duration or the
main timeout duration is 0.
Addresses https://bugs.gnu.org/51128
2021-10-12 14:47:44 +01:00
Pádraig Brady
0750fcdf34 timeout: ensure --foreground -k exits with status 137
* src/timeout.c (main): Propagate the killed status from the child.
* doc/coreutils.texi (timeout invocation): Remove the
description of the --foreground specific handling of SIGKILL,
now that it's consistent with the default mode of operation.
* tests/misc/timeout.sh: Add a test case.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/51135
2021-10-12 14:32:57 +01:00
Pádraig Brady
d085678bd6 doc: timeout --foreground: add clarification on exit status
* doc/coreutils.texi (timeout invocation): Add detail on
how --foreground allows timeout(1) to use more standard
exit status as the uncatchable SIGKILL is not sent to itself.
Fixes https://bugs.gnu.org/51135
2021-10-11 22:15:52 +01:00
Paul Eggert
6cafb122fa sort: fix unlikely bug when '\377' < 0
* gl/lib/strintcmp.c (strintcmp): Don’t assume that the input
cannot contain ((char) -1), as this equals '\377' when char is
signed (assuming 8-bit char).
* src/sort.c (decimal_point): Now char, to make it clear
that it’s always in char range now.
(NON_CHAR): New constant.
(traverse_raw_number): Return char not unsigned char;
this is simpler and could be faster.  All callers changed.
(main): Do not convert decimal_point and thousands_sep to
unsigned char, as this can mishandle comparisons on
machines where char is signed and the input data contains
((char) -1).  Use NON_CHAR, not -1, as an out-of-range value for
thousands_sep.
2021-10-10 16:06:28 -07:00
Paul Eggert
5b43b8e9ce build: update gnulib submodule to latest 2021-10-02 18:55:01 -07:00
Paul Eggert
b31a6a09ad maint: switch to C11-style _Noreturn
Use C11-style _Noreturn instead of the old ATTRIBUTE_NORETURN
macro.  This pacifies clang on OpenBSD 6.9, which otherwise
complains "'noreturn' function does return" in some places.
* gl/lib/randread.c, src/system.h (ATTRIBUTE_NORETURN):
Remove.  All uses either removed as GCC no longer needs them, or
changed to C11-style _Noreturn since Gnulib arranges for _Noreturn
globally nowadays.
2021-10-02 18:44:21 -07:00
Paul Eggert
4cfd48481d ls: port to OpenBSD
Problem reported by Brian Callahan (Bug#50972).
* src/ls.c (decode_switches): Don’t assume __GNUC_PREREQ.
2021-10-02 18:08:33 -07:00
Pádraig Brady
0475ce9f84 doc: adjust ls --zero option order in texinfo
* doc/coreutils.texi (ls invocation - general output formatting):
The option ordering was not changed when the option was renamed
from --null to --zero.
2021-09-26 13:48:03 +01:00
Pádraig Brady
61c81ffaac tests: cp/sparse-perf: make more robust and add zfs comments
* init.cfg (seek_data_capable_): Add a timeout to ensure failure for
slow lseek(...SEEK_DATA) calls (even if that syscall isn't interrupted).
* tests/cp/sparse-perf.sh: Run the SEEK_DATA check on the
1TiB empty file to exclude both FreeBSD 9.1 which takes 35s,
and ZFS which requires a delay of about 5s between file creation
and use of SEEK_DATA to correctly determine it's empty (return ENXIO).
Also remove the stat size checks as they invalidate the test
due to cp never writing data due to it being always zeros,
and thus converted to holes in the output.
2021-09-25 22:40:01 +01:00
Pádraig Brady
e8b56ebd53 chmod: fix exit status when ignoring symlinks
* src/chmod.c: Reorder enum so CH_NOT_APPLIED
can be treated as a non error.
* tests/chmod/ignore-symlink.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/50784
2021-09-24 23:42:20 +01:00
Pádraig Brady
6f38c4b279 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2021-09-24 13:58:11 +01:00
Pádraig Brady
725bb111bd version 9.0
* NEWS: Record release date.
2021-09-24 13:35:26 +01:00
Pádraig Brady
bfedefd872 tests: sparse-perf: avoid false failure
* tests/cp/sparse-perf.sh: Avoid the case where
we saw SEEK_DATA take 35s to return a result
against a 1TB sparse file.  This happened on
a FreeBSD 9.1 VM at least.
Reported by Nelson H. F. Beebe.
2021-09-24 12:17:58 +01:00
Pádraig Brady
56bff500c5 cksum: fix -a crc on 64 bit big endian systems
* src/cksum.c (crc_sum_stream): On sparc64 for example,
a crc of 0 was printed due to mismatch in size of
variable copied between generator and output functions.
uint_fast32_t is generally 64 bits on 64 bit systems,
so we copy through an int to ensure we don't use the wrong
end of a 64 bit variable.
Reported by Nelson H. F. Beebe
2021-09-24 00:39:05 +01:00
Pádraig Brady
a656db664d tail: fix detection of closed stdout on macOS
* bootstrap.conf: We only need poll on Linux and AIX
where poll is not replaced.  Also resinstate dependence
on select so we can use it unconditionally.
* src/tail.c (check_output_alive): Reinstate use of select()
by default as poll was seen to be ineffective for this
application on macOS.
Fixes https://bugs.gnu.org/50714
2021-09-21 17:50:54 +01:00
Pádraig Brady
f8819b657f maint: clean up c++ style comments
* src/expand-common.h: Remove commented variables.
* src/remove.h: Change to C style comment.
* src/tail.c: Likewise.
2021-09-21 16:22:18 +01:00
Pádraig Brady
23953cecf9 tests: date-debug: avoid a false failure on solaris
* tests/misc/date-debug.sh: Use a dynamic time format,
as the C locale on solaris uses %T rather than %H:%M:%S
for the time component.
2021-09-20 23:42:03 +01:00
Jim Meyering
f6fc52a828 doc: drop extraneous single quotes in help
* src/digest.c (usage) [cksum --help]: Drop single quotes
around each checksum name.
* src/tee.c (usage) [tee --help]: Likewise.
2021-09-20 21:42:28 +01:00
Jim Meyering
971aebfacc cksum: list Pádraig as coauthor
* src/digest.c (AUTHORS) [HASH_ALGO_CKSUM]: Add Pádraig as
cksum coauthor.
* AUTHORS: Likewise.
2021-09-20 21:42:26 +01:00
Jim Meyering
7b0db3c69c tests: env-s.pl: avoid spurious failure on OS X
* tests/misc/env-S.pl: The __CF_USER_TEXT_ENCODING envvar
would cause many of these sub-tests to fail. Ignore it.
2021-09-20 10:01:53 -07:00
Pádraig Brady
4382207c1d build: update gnulib submodule to latest
* gnulib: Update to latest.
Fixes "extern inline" and "rpl_free" issues.
2021-09-20 16:31:48 +01:00
Pádraig Brady
22d3751e0f doc: fix --help formatting for checksum utils
* src/digest.c (usage): Indicate that --length and --algorithm
require arguments.  Emit corresponding emit_mandatory_arg_note().
Use consistent alignment.
2021-09-20 16:27:39 +01:00
Pádraig Brady
88b7ff98fe cksum: support more transparent emulation of older utils
* src/digest.c: Allow using the --untagged option with --check,
so that `cksum -a md5 --untagged` used to emulate md5sum for example,
may be augmented with the --check option.  Also support the --tag
option with cksum, to allow overriding a previous --untagged setting.
* doc/coreutils.texi: Adjust accordingly.
* tests/misc/cksum-a.sh: Likewise.
2021-09-20 16:21:15 +01:00
Pádraig Brady
f80c6c267d tests: avoid rare race in tail-2/F-vs-rename.sh
* tests/tail-2/F-vs-rename.sh: Keep stdout and stderr separate,
so that interspersion doesn't impact regex checks.  Also wait
for each file's data to be printed to avoid multiple writes
to a file to be printed in a single iteration, which would
impact the regex checks.  Also we refactor the check function,
rather than repeatedly redefining variations.
2021-09-20 11:19:53 +01:00
Pádraig Brady
6946f9e47d maint: remove duplicate from THANKS.in
* THANKS.in: Now that Tianjia Zhang has a commit in the repo.
2021-09-17 13:38:45 +01:00
Tianjia Zhang
a2b5e9f85b tests: fix typo in cksum-a.sh
* tests/misc/cksum-a.sh: fix typo md5um to md5sum.
2021-09-17 12:08:19 +01:00
Pádraig Brady
8922ee206c tests: fix rare false failure in tail-2/F-vs-rename
This is wrong fix really, as only introducing delay I think.

* tests/tail-2/F-vs-rename.sh: Avoid a rare false failure
due to a race in the test.  Now wait until tail has noticed
that b is replaced before writing to a, so that the subsequent
write of "y" to b will be displayed independently from
current contents of b ("x").
2021-09-17 01:28:14 +01:00
Pádraig Brady
5134612fa7 tests: port removed-directory test to FreeBSD
* tests/ls/removed-directory.sh: On FreeBSD 9.1 at least,
one gets ENOENT when trying to traverse the current removed dir
with ../, so instead reference the parent dir directly.
2021-09-17 00:18:03 +01:00
Pádraig Brady
14ed8b8810 rmdir: fix uninitialized memory causing incorrect error
* src/rmdir.c (main): Only inspect the returned stat structure,
when stat(2) returns success.
2021-09-16 23:45:16 +01:00
Jim Meyering
3283cc7725 build: avoid new chmod.c warnings from upcoming GCC12
Here are the warnings:
src/chmod.c:175:3: error: 'ch.new_mode' may be used uninitialized in\
    this function [-Werror=maybe-uninitialized]
  175 |   strmode (ch->new_mode, perms);
src/chmod.c:178:3: error: 'ch.old_mode' may be used uninitialized in\
    this function [-Werror=maybe-uninitialized]
  178 |   strmode (ch->old_mode, old_perms);

* src/chmod.c (process_file): Initialize ch.  Its new_mode and
old_mode fields could indeed be used uninitialized to form mode
strings, but those are used only when built from initialized members.
2021-09-16 15:22:15 -07:00
Pádraig Brady
e6c57cf19b digest: ignore empty lines when checking
* src/digest.c (digest_check): Treat empty lines like comments,
as commented checksum files very often have empty lines.
* tests/misc/md5sum.pl: Adjust accordingly.
2021-09-16 20:39:28 +01:00
Pádraig Brady
7ebcd88fb2 factor: sync longlong.h adjustments from upstream
* src/longlong.h: Sync changes from:
https://gmplib.org/repo/gmp/log/tip/longlong.h
2021-09-16 15:42:33 +01:00
Pádraig Brady
92ffc842dc stat,tail: add support for the secretmem file system
* src/stat.c (human_fstype): Add case for the 'secretmem'
file system type.
* NEWS: Mention the Improvement.
2021-09-16 15:21:05 +01:00
Pádraig Brady
cca434a4a5 maint: sync help2man to latest version
* man/help2man: sync to changes from version 1.48.5.
Note this doesn't materially change the generated man pages.
2021-09-16 15:03:23 +01:00
Pádraig Brady
3215736685 doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.25 which is now about 5 years old.
2021-09-16 14:49:19 +01:00
Pádraig Brady
814cbd5698 tests: ensure returns_ check failures are propagated
* tests/misc/cksum-a.sh: Set fail=1 if returns_ check fails.
* tests/misc/sync.sh: Likewise.
* tests/misc/yes.sh: Likewise.
2021-09-16 12:21:16 +01:00
Pádraig Brady
73f8fd760d cksum: fix --check with non tagged format checksums
* src/digest.c: Always set the digest_length, so that
we check the correct number of hex digits when parsing
non tagged format checksums.
* tests/misc/cksum-a.sh: Add a test case.  Also fix
up this test which was ineffective due to fail=1
being set in a subshell and ignored.
2021-09-16 12:20:24 +01:00
Paul Eggert
121f74dfc2 cksum: fix off-by-1 bug with \r stripping
Problem reported by Jim Meyering (Bug#50611).
* src/digest.c (digest_check): When stripping trailing \r,
avoid subscript error before start of line.
2021-09-16 00:25:26 -07:00
Paul Eggert
2715aba08a maint: prefer rawmemchr to memchr when easy
* bootstrap.conf (gnulib_modules): Add rawmemchr.
* src/csplit.c: Include idx.h.
* src/csplit.c (record_line_starts):
* src/head.c (elide_tail_lines_pipe):
* src/shuf.c (next_line):
* src/split.c (lines_split):
* src/tail.c (pipe_lines):
* src/wc.c (wc_lines):
Prefer rawmemchr to memchr when rawmemchr is easy.
* src/csplit.c (load_buffer):
* src/head.c (struct linebuffer):
Make room for a 1-byte sentinel.
2021-09-15 15:08:28 -07:00
Paul Eggert
f8dc5a6215 split: avoid NULL + 1
* src/split.c (lines_chunk_split): Don’t add to a null pointer.
It’s undefined behavior, and it’s unnecessarily confusing
regardless.
2021-09-15 15:08:28 -07:00
Pádraig Brady
ed1c58427d digest: support windows format checksum files
Support checksum files with CRLF line endings,
which is a common gotcha for using --check on windows,
or with checksum files generated on windows.
Note we escape \r here to support the original coreutils format
(with file name at EOL), and file names with literal
\r characters as the last character of their name.

* src/digest.c (filename_unescape): Convert \\r -> \r.
(print_filename): Escape \r -> \\r.
(output_file): Detect \r chars in file names.
(digest_check): Ignore literal \r char at EOL.
* tests/misc/md5sum.pl: Add a test case.
* tests/misc/sha1sum.pl: Likewise.
* NEWS: Mention the improvement.
2021-09-15 20:44:18 +01:00
Pádraig Brady
7b8f38aa87 doc: improve --help indenting in checksum utils
* src/digest.c (usage): Indent multi-line descriptions for clarity.
2021-09-15 20:44:18 +01:00
Pádraig Brady
8d5038af05 cksum: operate in binary mode only
This only practically matters on windows.
But given there are separate text handling options in cygwin,
keep the interface simple, and avoid exposing the
confusing binary/text difference here.

* doc/coreutils.texi (md5sum invocation): Mention that
--binary and --text are not supported by the cksum command.
* src/digest.c: Set flag to use binary mode by default.
(output_file): Don't distinguish text and binary modes with
' ' and '*', and just use ' ' always.
2021-09-15 20:44:18 +01:00
Pádraig Brady
f9a787656b cksum: use --tag format by default
This format is a better default, since it results in simpler usage,
as you don't need to specify --tag on generation or -a on
checking invocations.  Also it's a more general format supporting
mixed and length adjusted digests.

* doc/coreutils.texi (cksum invocation): Document a new --untagged
option, to use the older coreutils format.
(md5sum invocation): Mention that cksum doesn't support --tag.
* src/digest.c: Adjust cksum(1) to default to --tag,
and accept the new --untagged option.
* tests/misc/b2sum.sh: Adjust accordingly.
* tests/misc/cksum-a.sh: Likewise.
* tests/misc/cksum-c.sh: Likewise.
2021-09-15 20:44:18 +01:00
Pádraig Brady
d9b78a2329 cksum: support --zero in default mode
* src/cksum.h: Thread DELIM through the output functions.
* src/digest.c: Likewise.
* src/sum.c: Likewise.
* src/sum.h: Likewise.
* src/cksum.c: Likewise. Also adjust check to allow -z
with traditional output modes.  Also ajust the global variable
name to avoid shadowing warnings.
* tests/misc/cksum-a.sh: Adjust accordingly.
2021-09-15 20:44:18 +01:00
Pádraig Brady
8e411226f9 digest: support -length specifiers on all digest tags
This will be generally useful going forward, for sha3-256 etc.

* src/digest.c: Rename b2_length to digest_length, and
adjust/simplify the code to operate on this for both
b2sum and cksum -a blake2b.
2021-09-15 20:44:18 +01:00
Pádraig Brady
772173a832 cksum: support digest detection for tagged format
Support `cksum --check FILE` without having to specify a digest
algorithm, allowing for more generic file check instructions.
This also supports mixed digest checksum files, supporting
more robust multi digest checks.

* src/digest.c (algorithm_from_tag): A new function to
identify the digest algorithm from a tagged format line.
(split3): Set the algorithm depending on tag, and update
the expected digest length accordingly.
* tests/misc/cksum-c.sh: Add a new test.
* tests/local.mk: Reference the new test.
* tests/misc/md5sum.pl: Adjust to more generic error.
* tests/misc/sha1sum.pl: Likewise.
* doc/coreutils.texi (md5sum invocation): Mention the new -c feature.
* NEWS: Mention the new feature.
2021-09-15 20:44:18 +01:00
Pádraig Brady
217cd278ec maint: simplify b2sum to only handle BLAKE2b
Any further variants will use the cksum -a table driven mechanism.

* src/digest.c: Remove BLAKE2 specific table driven code.
2021-09-15 20:44:18 +01:00
Pádraig Brady
8362f2552a digest: add support for sm3
Add message digest sm3, which uses the OSCCA SM3 secure
hash (OSCCA GM/T 0004-2012 SM3) generic hash transformation.

* bootstrap.conf: Add the sm3 module.
* doc/coreutils.texi: Mention the cksum -a option.
* src/digest.c: Provide support for --algorithm='sm3'.
* tests/misc/sm3sum.pl: Add a new test (from Tianjia Zhang)
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.

Tested-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
2021-09-15 20:44:18 +01:00
Pádraig Brady
ad6c8e1181 cksum: add --algorithm option to select digest mode
* src/digest.c: Organize HASH_ALGO_CKSUM to be table driven,
and amalgamate all digest algorithms.
(main): Parse all options if HASH_ALGO_CKSUM, and disallow
--tag, --zero, and --check with the traditional bsd, sysv, and crc
checksums for now.
* src/local.mk: Reorganize to include all digest modules in cksum.
* tests/misc/cksum-a.sh: Add a new test.
* tests/misc/b2sum.sh: Update to default to checking with cksum,
as b2sum's implementation diverges a bit from the others.
* tests/local.mk: Reference the new test.
* doc/coreutils.texi (cksum invocation): Adjust the summary to
identify the new mode, and document the new --algorithm option.
* man/cksum.x: Adjust description to be more general.
* man/*sum.x: Add [See Also] section referencing cksum(1).
* NEWS: Mention the new feature.
2021-09-15 20:44:16 +01:00
Pádraig Brady
6a5c561b4f digest: refactor cksum(1) into digest.c
* cfg.mk: Adjust cksum.c to not require config.h
and support a main (for crctab) without calling bindtextdomain().
* po/POTFILES.in: Remove cksum_pclmul.c since it no longer
concerns itself with diagnostics.
* src/cksum.c: Refactor to just providing stream digest,
and digest printing functionality.
* src/cksum.h: Adjust to the new interface.
* src/cksum_pclmul.c: Remove diagnostics, and determine errors
internally.
* src/crctab.c: Separate from cksum.h since that's now included
multiple times.
* src/digest.c: Provide cksum(1) functionality if -DHASH_ALGO_CKSUM
* src/local.mk: Adjust to new crctab.c and HASH_ALGO_CKSUM define.
2021-09-15 15:35:53 +01:00
Pádraig Brady
2aab794c84 cksum: document the --debug option
This should have been part of commit v8.32-113-gb73b9fcb1

* doc/coreutils.texi (cksum invocation): Add the --debug description.
* src/cksum.c (usage): Likewise.
(main): Also give explicit indication when using generic hardware.
2021-09-15 15:35:53 +01:00
Pádraig Brady
97f98b63a4 sum: handle EOVERFLOW for too large inputs
* src/sum.c (bsd_sum_stream): Detect overflow when updating length.
(sysv_sum_stream): Likewise.
2021-09-15 15:35:53 +01:00
Pádraig Brady
eb17c610d4 digest: refactor sum(1) into digest.c
Since digest will be providing all digest functionality,
refactor sum.c into it.

* po/POTFILES.in: sum.c no longer has translatable strings so remove.
* src/digest.c: Call out to new stream interfaces in sum.c
* src/local.mk: Adjust sources for the sum binary.
* src/sum.c: Provide a stream interface for BSD and SYSV digests.
* src/sum.h: A new file to declare the exported functions in sum.c
2021-09-15 15:35:53 +01:00
Pádraig Brady
51268b5dbb digest: add LENGTH parameter to digest to support cksum
* src/digest.c (digest_file): Add a LENGTH param,
to support cksum(1), and sum(1) which output the
length as part of their output.
2021-09-15 15:35:53 +01:00
Pádraig Brady
f0b32e79cc maint: rename md5sum.c to more general digest.c
md5sum.c will be the base for all digest functions,
so rename accordingly.

* src/md5sum.c: Rename to ...
* src/digest.c: ... renamed from md5sum.c
* scripts/git-hooks/commit-msg: Allow digest: commit prefix.
* po.POTFILES.in: Adjust to new name.
* src/local.mk: Likewise.
2021-09-15 15:35:53 +01:00
Pádraig Brady
f76a568313 doc: fix ambiguities in logname(1) and whoami(1)
* doc/coreutils.texi (whoami invocation): Clarify it prints names,
not numeric IDs.
* man/whoami.x: Likewise.
* man/logname.x: Reference getlogin(3).
* src/logname.c: Clarify that it prints the login name,
rather than the name of the effective user ID.

Fixes https://bugs.gnu.org/48894
2021-09-15 15:26:22 +01:00
nl6720
7f303de877 dircolors: add *direct* to TERM matching
Search for "direct color" at:
https://invisible-island.net/xterm/terminfo.html

* src/dircolors.hin: Add *direct* to match terminals that
support direct colors (24-bit color / TrueColor).
The trailing * will match entries like xterm-direct2.

Addresses https://bugs.gnu.org/39827
2021-09-15 14:51:11 +01:00
Pádraig Brady
0cfb60e90d tests: stat-vs-dirent.sh: avoid a false failure
* tests/ls/stat-vs-dirent.sh: Skip the test if we can't stat(1),
as the file may have been removed, or have a malformed name
due to '\n' etc. in the file name.
2021-09-12 23:16:18 +01:00
Pádraig Brady
ac4841298e tests: add new stdin reading programs to tty-eof test
* tests/misc/tty-eof.pl: Add b2sum and basenc.
2021-09-09 21:35:52 +01:00
Pádraig Brady
4af4d61d53 build: update gnulib submodule to latest
* gnulib: Update to latest. This fixes a gnulib test failure in base64,
among other fixes.
* cfg.mk: Disable sc_indent as auto indent is too invasive for now.
2021-09-09 21:35:03 +01:00
Pádraig Brady
91feded51c doc: fix repeated word
A proposed change to gnulib's sc_prohibit_doubled_word
was made to detect this in future.

* README: s/can can/can/.
Fixes https://bugs.gnu.org/50484
2021-09-09 16:25:36 +01:00
Paul Eggert
588790a38c doc: can “can can”
Problem reported by Akbarkhon Variskhanov (Bug#50484).
2021-09-09 08:05:14 -07:00
Paul Eggert
3c855eb572 doc: add missing "as" (thanks to Nelson H.F. Beebe) 2021-09-07 16:15:40 -07:00
Justin Tracey
1d5dbb8203 tests: narrow scope of faulty join args
* tests/misc/join.pl: Only test invalid-j with an invalid -j field,
not with missing operands as well.
2021-09-05 12:10:41 +01:00
Pádraig Brady
669d45de0f doc: indicate the default algorithm in the sum(1) man page
* src/sum.c (usage): Indicate that -r (BSD algorithm) is the default.
2021-08-31 11:33:29 +01:00
Pádraig Brady
e1c21f39cc sum: always output a file name if one passed
Adjust to output the file name if any name parameter is passed.
This is consistent with sum -s, cksum, and sum implementations
on other platforms.  This should not cause significant compat
issues, as multiple fields are already output, and so already
need to be parsed.

* src/sum.c (bsd_sum_file): Output the file name
if any name parameter is passed.
* tests/misc/sum.pl: Adjust accordingly.
* doc/coreutils.texi (sum invocation): Likewise.
* NEWS: Mention the change in behavior.
2021-08-31 11:33:26 +01:00
Paul Eggert
cff4ce7a5e tests: port better to NetBSD
* tests/misc/help-version.sh: Test that /dev/full causes
shell printf to fail.  This ports better to NetBSD 9.88.46,
where it doesn’t.  Problem reported by Nelson H. F. Beebe.
2021-08-30 17:02:06 -07:00
Paul Eggert
549cb8d901 tests: merge help-version changes back from gzip
* tests/misc/help-version.sh: Merge gzip-related changes
back from gzip/tests/help-version.  This fixes problems
when TERM is not 'dumb', and should simplify maintenance.
2021-08-30 17:02:06 -07:00
Assaf Gordon
709d1f8253 basenc: fix bug49741: using wrong decoding buffer length
Emil Lundberg <lundberg.emil@gmail.com> reports in
https://bugs.gnu.org/49741 about a 'basenc --base64 -d' decoding bug.
The input buffer length was not divisible by 3, resulting in
decoding errors.

* NEWS: Mention fix.
* src/basenc.c (DEC_BLOCKSIZE): Change from 1024*5 to 4200 (35*3*5*8)
which is divisible by 3,4,5,8 - satisfying both base32 and base64;
Use compile-time verify() macro to enforce the above.
* tests/misc/basenc.pl: Add test.
2021-08-29 22:06:32 -06:00
Paul Eggert
97d8dcc5ca basenc: prefer signed to unsigned integers
This patch modifies basenc to prefer signed integers to
unsigned, as signed are less error-prone.
This patch also updates Gnulib to to latest, which updates Gnulib’s
base32 and base64 modules to prefer signed to unsigned integers.
* src/basenc.c: Include idx.h.
(struct base2_decode_context): Use unsigned char, not unsigned
for an octet that must fit in an unsigned char.
(base_encode, struct base_decode_context)
(base64_decode_ctx_wrapper, prepare_inbuf, base64url_encode)
(base64url_decode_ctx_wrapper, base32_decode_ctx_wrapper)
(base32hex_encode, base32hex_decode_ctx_wrapper, base16_encode)
(base16_decode_ctx, z85_encode, Z85_HI_CTX_TO_32BIT_VAL)
(z85_decoding, z85_decode_ctx, base2msbf_encode)
(base2lsbf_encode, base2lsbf_decode_ctx, base2msbf_decode_ctx)
(wrap_write, do_encode, do_decode, main):
Prefer signed integers to unsigned.
(main): Treat extremely large wrap columns as if they were
infinite; that’s good enough.  Since we’re now using xstrtoimax,
this allows ‘-w -0’ (same as ‘-w 0’).
* tests/misc/base64.pl (gen_tests): -w-0 is no longer an error.
2021-08-27 17:12:27 -07:00
Jim Meyering
88562dc9c7 maint: avoid new syntax-check failure
find-mount-point.h rightly includes <stdlib.h> for its use
of _GL_ATTRIBUTE_DEALLOC_FREE, which uses free, yet that new
inclusion provoked a syntax-check failure. Exempt this header
file as we've done for others.
* cfg.mk (exclude_file_name_regexp--sc_system_h_headers):
Add find-mount-point.h to the regexp.
(sc_system_h_headers): Use grep -E, for a more readable regexp.
2021-08-25 08:45:39 -07:00
Pádraig Brady
c431893b96 tests: avoid reflinks when testing SEEK_DATA logic
This better tests the SEEK_HOLE logic which
replaced the original fiemap hole identification logic.
Also it avoids a false failure in sparse-2.sh
on reflink supporting file systems, where we
try to correlate the file sizes produced by cp and dd.

* tests/cp/sparse-2.sh: s/cp/cp --reflink=never/
* tests/cp/sparse-extents-2.sh: Likewise.
* tests/cp/sparse-extents.sh: Likewise.
* tests/cp/sparse-perf.sh: Likewise.
* tests/cp/sparse.sh: Likewise.

Fixes https://github.com/coreutils/coreutils/issues/54
2021-08-25 12:37:57 +01:00
Paul Eggert
b020d456d1 df: pacify -Wsuggest-attribute=malloc
Problem found with latest Gnulib and GCC 11.2.1.
* src/find-mount-point.h (find_mount_point):
Add _GL_ATTRIBUTE_MALLOC and _GL_ATTRIBUTE_DEALLOC_FREE.
2021-08-22 13:10:26 -07:00
Paul Eggert
3c18082822 build: update gnulib submodule to latest 2021-08-22 13:10:26 -07:00
Paul Eggert
88846befff maint: use clearerr on stdin when appropriate
This is so that commands like ‘fmt - -’ read from stdin
both times, even when it is a tty.  Fix some other minor
issues that are related.
* src/blake2/b2sum.c (main):
* src/cksum.c (cksum):
* src/cut.c (cut_file):
* src/expand-common.c (next_file):
* src/fmt.c (fmt):
* src/fold.c (fold_file):
* src/md5sum.c (digest_file, digest_check):
* src/nl.c (nl_file):
* src/od.c (check_and_close):
* src/paste.c (paste_parallel, paste_serial):
* src/pr.c (close_file):
* src/sum.c (bsd_sum_file):
Use clearerr on stdin so that stdin can be read multiple times
even if it is a tty.  Do not assume that ferror preserves errno as
POSIX does not guarantee this.  Coalesce duplicate diagnostic
calls.
* src/blake2/b2sum.c (main):
* src/fmt.c (main, fmt):
Report read error, even if it's merely fclose failure.
* src/fmt.c: Include die.h.
(fmt): New arg FILE.  Close input (reporting error) if not stdin.
All callers changed.
* src/ptx.c (swallow_file_in_memory): Clear stdin's EOF flag.
* src/sort.c (xfclose): Remove unnecessary feof call.
2021-08-22 13:10:26 -07:00
Paul Eggert
4d355e5270 doc: spell out stdin, stdout, stderr
* doc/coreutils.texi: Spell out words like “stdin” in
English prose.
2021-08-22 13:10:24 -07:00
Paul Eggert
bbb19b1868 chmod: fix use of uninitialized var if -v
Problem reported by Michael Debertol (Bug#50070).
* NEWS: Mention the fix.
* src/chmod.c (struct change_status): New struct, replacing the
old enum Change_status.  All uses changed.
(describe_change): Distinguish between cases depending on
whether 'stat' or its equivalent succeeded.  Report a line
of output even if 'stat' failed, as that matches the documentation.
Rework to avoid casts.
(process_file): Do not output nonsense modes computed from
uninitialized storage, removing a couple of IF_LINTs.  Simplify by
defaulting to CH_NO_STAT.
2021-08-15 21:32:09 -07:00
Pádraig Brady
29079b9aa2 maint: update .gitignore
* .gitignore: ignore new lib/malloc gnulib directory.
2021-08-14 22:23:11 +01:00
Pádraig Brady
a0f205ba92 maint: allow hook script accept "Signed-off-by:"
* scripts/git-hooks/commit-msg: Relax this constraint.
2021-08-14 21:40:54 +01:00
Paul Eggert
a3c04f8da1 df: fix bug with automounted
If the command-line argument is automounted, df would use
stat info that became wrong after the following open.
* NEWS: Mention the fix (bug#50012).
* src/df.c (automount_stat_err): New function.
This fixes the hang on fifos in a better way, by using O_NONBLOCK.
(main): Use it.
2021-08-11 11:22:40 -07:00
Pádraig Brady
a574283c7a cat: with -E fix handling of \r\n spanning buffers
We must delay handling when \r is the last character
of the buffer being processed, as the next character
may or may not be \n.

* src/cat.c (pending_cr): A new global to record whether
the last character processed (in -E mode) is '\r'.
(cat): Honor pending_cr when processing the start of the buffer.
(main): Honor pending_cr if no more files to process.
* tests/misc/cat-E.sh: Add test cases.
Fixes https://bugs.gnu.org/49925
2021-08-08 00:09:38 +01:00
Paul Eggert
02fc0e3f68 maint: update .gitignore 2021-07-31 13:36:31 -07:00
Paul Eggert
ba5a3b21b5 build: update gnulib submodule to latest 2021-07-31 13:36:31 -07:00
Paul Eggert
ffbd64ec86 uniq: pacify GCC -fanalyzer
Pacify GCC 11.1 -fanalyzer.
* src/uniq.c (check_file): Use simpler test to check whether this
is the first time through the loop.  Although the old test was
correct, the new one is easier to understand and perhaps a tiny
bit more efficient.
2021-07-31 11:17:18 -07:00
Paul Eggert
84da62974d numfmt: omit unnecessary pointer test
Caught by GCC 11.1 -fanalyzer.
* src/numfmt.c (simple_strtod_int): Remove unnecessary test of
*endptr vs NULL.  Presumably this was a typo and **endptr was
intended instead of *endptr, but an **endptr test is also
unnecessary since c_isdigit (0) returns false.
2021-07-31 11:17:18 -07:00
Pádraig Brady
d1316583b2 doc: add options summary list to tr texinfo
* doc/coreutils.texi (tr invocation): Provide a summary
list of the available options, which is useful to
provide a quick reminder for those already familiar
with the functionality of tr.
Fixes https://bugs.gnu.org/49764
2021-07-29 13:19:33 +01:00
Pádraig Brady
dcd6e4172c tests: augment new ls --zero test cases
* tests/ls/zero-option.sh: Check for the disabled, disallowed,
and allowed option combinations.
2021-07-28 23:17:34 +01:00
Pádraig Brady
eca33373ce maint: avoid syntax-check failures in recent ls changes
* src/ls.c: Fix ifdef indenting and long line.
2021-07-28 23:16:50 +01:00
Paul Eggert
d60b2922ff doc: modernize usage of “disk” and “core”
In documentation and comments, don’t assume that secondary storage
devices are disk devices.  Similarly, don’t assume that main memory
uses magnetic cores, which became obsolete in the 1970s.
* src/du.c (usage):
* src/ls.c (usage):
* src/shred.c (usage): Reword to avoid “disk” in usage messages.
2021-07-28 12:30:12 -07:00
Paul Eggert
1625916a1b doc: improve ls documentation
* doc/coreutils.texi (ls invocation): Document implementation more
closely.  Be more consistent about style.  Omit some needless words.
* src/ls.c (usage): Don’t overdocument -f, as the details were wrong.
Omit -1 advice as it’s a bit obsolete now that we have --zero and
is a bit much for --usage output anyway.
2021-07-28 12:30:12 -07:00
Paul Eggert
c75779cac3 ls: rename --null to --zero (Bug#49716)
* NEWS, doc/coreutils.texi (General output formatting):
* src/ls.c (usage):
Document this.
* src/ls.c (ZERO_OPTION): Rename from NULL_OPTION.
All uses changed.
(long_options): Rename --null to --zero.
(dired_dump_obstack, main, print_dir): Use '\n' instead of
eolbyte where eolbyte must equal '\n'.
(decode_switches): Decode --zero instead of --null.
--zero also implies -1, -N, --color=none, --show-control-chars.
Use easier-to-decipher code to set ‘format’ and ‘dired’.
Reject attempts to combine --dired and --zero.
* tests/local.mk: Adjust to test script renaming.
* tests/ls/zero-option.sh: Rename from tests/ls/null-option.sh,
and test --zero instead of --null.
2021-07-27 18:08:39 -07:00
Paul Eggert
9e4a6101f2 ls: compute defaults more lazily
* src/ls.c (enum time_type, enum sort_type, enum indicator_style)
(enum Dereference_symlink, ignore_mode):
Put ‘= 0’ after default values, since the code relies
on static storage defaulting to zero.
(enum sort_type): Reorder so that -1 can be used to represent unset.
(main): Test print_with_color after parse_ls_color may have reset it.
(decode_line_length): Return the line length instead of setting
static storage.  All uses changed.  Treat line lengths exceeding
PTRDIFF_MAX as infinite, to avoid pointer-subtraction glitches.
(stdout_isatty): New function, to avoid calling isatty twice.
(decode_switches): Calculate defaults more lazily, to avoid using
syscalls or getenv during startup unless the results are more
likely to be needed.  Use -1 to indicate options that haven’t been
set on the command line yet.  Move print_with_color test from
here to ‘main’.  Suppress bogus GCC warning.
(getenv_quoting_style): Return the quoting style instead of
setting static storage.
(init_column_info): New arg MAX_COLS, to avoid recalculating it.
Caller changed.
2021-07-27 18:08:38 -07:00
Pádraig Brady
e094d2e3e1 maint: avoid recent syntax-check issues
* .gitignore: Cater for recently added poll module.
* src/stdbuf.c: Avoid false positive from sc_prohibit_readlink.
2021-07-26 15:42:29 +01:00
Paul Eggert
7d44ac224c ls: add --null option (Bug#49716)
* NEWS, doc/coreutils.texi (General output formatting):
* src/ls.c (usage): Document this.
* src/ls.c (NULL_OPTION): New constant.
(long_options): Add --null.
(eolbyte): New static var.
(dired_dump_obstack, main, print_dir, print_current_files)
(print_many_per_line, print_horizontal, print_with_separator):
Output eolbyte instead of '\n'.
(decode_switches): Decode --null.
* tests/ls/null-option.sh: New file.
* tests/local.mk (all_tests): Add it.
2021-07-26 00:59:37 -07:00
Paul Eggert
39673b6d4c ls: port to wider off_t, uid_t, gid_t
* src/ls.c (dired_pos): Now off_t, not size_t, since it counts
output file offsets.
(dired_dump_obstack): This obstack's file offsets are now
off_t, not size_t.
(format_user_or_group, format_user_or_group_width):
ID arg is now uintmax_t, not unsigned long, since uid_t and
gid_t values might exceed ULONG_MAX.
(format_user_or_group_width): Use snprintf with NULL instead of
sprintf with a discarded buffer.  This avoids a stack buffer,
and so should be safer.
2021-07-26 00:59:37 -07:00
Paul Eggert
0a41ad2cfb ls: demacroize
Prefer functions or constants to macros where either will do.
That’s cleaner, and nowadays there’s no performance reason to
prefer macros.  All uses changed.
* src/ls.c (INITIAL_TABLE_SIZE, MIN_COLUMN_WIDTH):
Now constants instead of macros.
(file_or_link_mode): New function, replacing the old macro
FILE_OR_LINK_MODE.
(dired_outbyte): New function, replacing the old macro DIRED_PUTCHAR.
(dired_outbuf): New function, replacing the old macro DIRED_FPUTS.
(dired_outstring): New function, replacing the old macro
DIRED_FPUTS_LITERAL.
(dired_indent): New function, replacing the old macro DIRED_INDENT.
(push_current_dired_pos): New function, replacing the old macro
PUSH_CURRENT_DIRED_POS.
(assert_matching_dev_ino): New function, replacing the old macro
ASSERT_MATCHING_DEV_INO.
(do_stat, do_lstat, stat_for_mode, stat_for_ino, fstat_for_ino)
(signal_init, signal_restore, cmp_ctime, cmp_mtime, cmp_atime)
(cmp_btime, cmp_size, cmp_name, cmp_extension)
(fileinfo_name_width, cmp_width, cmp_version):
No longer inline; compilers can deduce this well enough nowadays.
(main): Protect unused assert with ‘if (false)’ rather than
commenting it out, so that the compiler checks the code.
(print_dir): Output the space and newline in the same buffer
as the human-readable number they surround.
(dirfirst_check): New function, replacing the old macro
DIRFIRST_CHECK.  Simplify by using subtraction.
(off_cmp): New function, replacing the old macro longdiff.
(print_long_format): No need to null-terminate the string now.
(format_user_or_group): Let printf count the bytes.
2021-07-26 00:59:37 -07:00
Paul Eggert
c09b25dd3f ls: simplify sprintf usage
* src/ls.c (format_user_or_group_width, print_long_format):
Use return value from sprintf instead of calling strlen on
the resulting buffer, or inferring the length some other way.
2021-07-26 00:59:36 -07:00
Paul Eggert
558959daa9 build: update gnulib submodule to latest 2021-07-26 00:59:36 -07:00
Paul Eggert
5622ab450e maint: fix white space 2021-07-26 00:59:36 -07:00
Paul Eggert
3753c706b7 env: fix usage typo
* src/env.c (usage): Fix pluralization typo.
2021-07-26 00:59:36 -07:00
Kamil Dudka
d6125af095 df: fix duplicated remote entries due to bind mounts
As originally reported in <https://bugzilla.redhat.com/1962515>,
df invoked without -a printed duplicated entries for NFS mounts
of bind mounts.  This is a regression from commit v8.25-54-g1c17f61ef99,
which introduced the use of a hash table.

The proposed patch makes sure that the devlist entry seen the last time
is used for comparison when eliminating duplicated mount entries.  This
way it worked before introducing the hash table.

Patch co-authored by Roberto Bergantinos.

* src/ls.c (struct devlist): Introduce the seen_last pointer.
(devlist_for_dev): Return the devlist entry seen the last time if found.
(filter_mount_list): Remember the devlist entry seen the last time for
each hashed item.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/49298
2021-07-02 17:32:46 +01:00
Paul Eggert
da0d448bca tail: use poll, not select
This fixes an unlikely stack out-of-bounds write reported by
Stepan Broz via Kamil Dudka (Bug#49209).
* bootstrap.conf (gnulib_modules): Replace select with poll.
* src/tail.c: Do not include <sys/select.h>.
[!_AIX]: Include poll.h.
(check_output_alive) [!_AIX]: Use poll instead of select.
(tail_forever_inotify): Likewise.  Simplify logic, as there is no
need for a ‘while (len <= evbuf_off)’ loop.
2021-06-26 18:40:26 -07:00
Paul Eggert
177bfdd7ca tail: fix abuse2 test race
* tests/tail-2/inotify-hash-abuse2.sh (fastpoll):
Fix race where tailed file ‘f’ temporarily did not exist.
2021-06-26 18:40:26 -07:00
Paul Eggert
53bb0235d5 maint: while (1) → while (true) 2021-06-26 18:40:26 -07:00
Nikolay Nechaev
18dbcae25a maint: remove redundant checks on buffer sizes in tail
* src/tail.c: remove redundant size checks before calls to
`xwrite_stdout`
2021-06-21 13:17:06 +01:00
Pádraig Brady
5f8e6fc202 stat: use decomposed decimal device numbers by default
* src/stat.c (default_format): Use decomposed decimal
representation (major,minor) in the default format.
This is least ambiguous for human interpretation,
and more consistent with ls for example.
Fixes https://bugs.gnu.org/48960
2021-06-21 12:03:42 +01:00
Pádraig Brady
4a8278229e stat: support more device number representations
In preparation for changing the default device number
representation (to decomposed decimal), provide more
formatting options for device numbers.

These new (FreeBSD compat) formatting options are added:

   %Hd  major device number in decimal (st_dev)
   %Ld  minor device number in decimal (st_dev)
   %Hr  major device type in decimal (st_rdev)
   %Lr  minor device type in decimal (st_rdev)
   %r   (composed) device type in decimal (st_rdev)
   %R   (composed) device type in hex (st_rdev)

* doc/coreutils.texi (stat invocation): Document new formats.
* src/stat.c (print_it): Handle the new %H and %L modifiers.
(print_statfs): Adjust to passing the format as two chars
rather than an int.  Using an int was introduced in commit db42ae78,
but using separate chars is cleaner and more extensible.
(print_stat): Likewise.  Handle any modifiers and the new 'r' format.
(usage): Document the new formats.
* tests/misc/stat-fmt.sh: Add a test case for new modifiers.
Addresses https://bugs.gnu.org/48960
2021-06-21 12:01:04 +01:00
Paul Eggert
4edad9e121 build: update gnulib submodule to latest
Coreutils mistakenly did not list xstrndup as a module
that it depends on directly.  When the latest Gnulib removed
the dirname module's dependency on xstrndup, this mistake
caused coreutils to not build.  Since all of Coreutils's
uses of xstrndup know the string length, xmemdup0 is a better
match for what's needed.  Since the size args are typically
signed or derived from subtracting pointers, the new Gnulib
ximemdup0 function is a better match yet.
So, use ximemdup0 instead of xstrndup.
* src/cut.c, src/dircolors.c, src/expand-common.c, src/expand.c:
* src/numfmt.c, src/set-fields.c, src/unexpand.c:
Do not include xstrndup.h; no longer needed.
* src/dircolors.c (parse_line):
* src/expand-common.c (parse_tab_stops):
* src/numfmt.c (parse_format_string):
* src/set-fields.c (set_fields):
Use ximemdup0 instead of xstrndup.
2021-06-11 18:05:57 -07:00
Jim Meyering
370c294018 maint: bootstrap: remove reference to unused hash-pjw module
* bootstrap.conf (gnulib_modules): Remove hash-pjw. No longer used.
2021-05-28 13:10:46 -07:00
Pádraig Brady
d1b0257077 build: update gnulib submodule to latest
Fixes a false test failure with MALLOC_CHECK_ set.

* gnulib: Update to latest.
2021-05-15 20:33:26 +01:00
Pádraig Brady
26eccf6c98 copy: remove fiemap logic
This is now only used on 10 year old linux kernels,
and performs a sync before each copy.

* src/copy.c (extent_copy): Remove function and all callers.
* src/extent-scan.c: Remove.
* src/extent-scan.h: Remove.
* src/fiemap.h: Remove.
* src/local.mk: Adjust for removed files.
* NEWS: Adjust to say fiemap is removed.
2021-05-15 16:14:11 +01:00
Pádraig Brady
ba5e6885d2 copy: disallow copy_file_range() on Linux kernels before 5.3
copy_file_range() before Linux kernel release 5.3 had many issues,
as described at https://lwn.net/Articles/789527/, which was
referenced from https://lwn.net/Articles/846403/; a more general
article discussing the generality of copy_file_range().
Linux kernel 5.3 was released in September 2019, which is new enough
that we need to actively avoid older kernels.

* src/copy.c (functional_copy_file_range): A new function
that returns false for Linux kernels before version 5.3.
(sparse_copy): Call this new function to gate use of
copy_file_range().
2021-05-13 00:14:22 +01:00
Pádraig Brady
6b499720fe tests: fix tests/cp/sparse-2.sh false failure on some systems
* tests/cp/sparse-2.sh: Double check cp --sparse=always,
with dd conv=sparse, in the case where the former didn't
create a sparse file.  Now that this test is being newly run
on macos, we're seeing a failure due to seek() not creating
holes on apfs unless the size is >= 16MiB.
2021-05-12 22:14:11 +01:00
Pádraig Brady
4eb2e9c11a tests: ensure we test SEEK_DATA where used
fiemap is no longer the default copy implementation,
so check for SEEK_DATA support instead as that's preferred.
This will ensure better test coverage on systems without fiemap.

* init.cfg: Replace fiemap_capable_ with seek_data_capable_.
This is best supported with python 3 so prefer that.
* tests/seek-data-capable: A new test script checking for
SEEK_DATA support on the passed file name,
called from seek_data_capable_.
* tests/fiemap-capable: Remove no longer used probing script.
* tests/cp/fiemap-perf.sh: Renamed to tests/cp/sparse-perf.sh
* tests/cp/fiemap-2.sh: Renamed to tests/cp/sparse-2.sh
* tests/cp/fiemap-extents.sh: Renamed to tests/cp/sparse-extents.sh
* tests/cp/sparse-fiemap.sh: Renamed to tests/cp/sparse-extents-2.sh
* tests/cp/fiemap-FMR.sh: Renamed to tests/cp/copy-FMR.sh
* tests/local.mk: Reference the renamed tests.
2021-05-12 22:14:11 +01:00
Pádraig Brady
2e66e1732f copy: handle system security config issues with copy_file_range()
* src/copy.c (sparse_copy): Upon EPERM from copy_file_range(),
fall back to a standard copy, which will give a more accurate
error as to whether the issue is with the source or destination.
Also this will avoid the issue where seccomp or apparmor are
not configured to handle copy_file_range(), in which case
the fall back standard copy would succeed without issue.
This specific issue with seccomp was noticed for example in:
https://github.com/golang/go/issues/40900
2021-05-12 22:14:11 +01:00
Pádraig Brady
017877bd08 copy: handle EOPNOTSUPP from SEEK_DATA
* src/copy.c (infer_scantype): Ensure we don't error out
if SEEK_DATA returns EOPNOTSUPP, on systems where this value
is distinct from ENOTSUP.  Generally both of these should be checked.
2021-05-12 22:14:11 +01:00
Pádraig Brady
8ec0d1799e copy: handle ENOTSUP from copy_file_range()
* src/copy.c (sparse_copy): Ensure we fall back to
a standard copy if copy_file_range() returns ENOTSUP.
This generally is best checked when checking ENOSYS,
but it also seems to be a practical concern on Centos 7,
as a quick search gave https://bugzilla.redhat.com/1840284
2021-05-12 22:14:11 +01:00
Pádraig Brady
e35e4d1757 build: update gnulib submodule to latest
Fixes a bits/long-double.h include build issue on some systems.

* bootstrap: Sync new --version option from gnulib.
* gnulib: Update to lastest.
Reported by Carl Edquist
2021-05-10 17:44:57 +01:00
Carl Edquist
bf483155e5 build: fix __get_cpuid_count check to catch link failure
The test program will compile successfully even if __get_cpuid_count
is not declared.  The error for the missing symbol will only show up
at link time.  Thus, use AC_LINK_IFELSE instead of AC_COMPILE_IFELSE.

* configure.ac (__get_cpuid_count check): Use C_LINK_IFELSE instead
of AC_COMPILE_IFELSE.
(__get_cpuid check): Likewise.
2021-05-10 13:35:20 +01:00
Pádraig Brady
09bbb2b703 maint: consistently free hash structures in dev mode
Ensure we call hash_free() to avoid valgrind and leak_sanitizer
"definitely lost" warnings.  These were not real leaks as
we terminate immediately after, but we should avoid these
"definitely lost" warnings where possible.

* src/copy.c: Add dest_info_free() and src_info_free().
* src/copy.h: Declare the above.
* src/cp-hash.c: Don't define unless "lint" is defined.
* src/install.c: Call dest_info_free() in dev mode.
* src/mv.c: Likewise.
* src/cp.c: Likewise. Also call src_info_free().
* src/ln.c: Call hash_free() in dev mode.
* src/tail.c: Call hash_free() even if about to exit, in dev mode.

Fixes https://bugs.gnu.org/48189
2021-05-08 14:57:33 +01:00
Bernhard Voelker
65e4d0f71e maint: fix sc_space_before_open_paren failure
* src/copy.c (dest_info_init): Add space before parens.
(src_info_init): Likewise.
Syntax-check failure introduced in the previous commit.
2021-05-06 23:42:57 +02:00
Pádraig Brady
f1d2e8e289 copy: exit immediately upon failure to allocate hash memory
* src/copy.c (dest_info_init, src_info_init): Terminate immediately
upon memory exhaustion.
2021-05-03 18:53:35 +01:00
Pádraig Brady
ea9af99234 copy: ensure we enforce --reflink=never
* src/copy.c (sparse_copy): Don't use copy_file_range()
with --reflink=never as copy_file_range() may implicitly
use acceleration techniques like reflinking.
(extent_copy): Pass through whether we allow reflinking.
(lseek_copy): Likewise.
Fixes https://bugs.gnu.org/48164
2021-05-02 21:27:17 +01:00
Pádraig Brady
e7fff54c92 wc: add --debug to diagnose which implementation used
* src/wc.c: (main): Handle the new --debug option.
Only call avx2_supported if needed.
(avx2_supported): Diagnose various failures and attempts.
* NEWS: Mention the new wc improvement and --debug option.
2021-05-02 20:51:37 +01:00
Kristoffer Brånemyr
4064c57380 wc: use avx2 optimization when counting only lines
Use cpuid to detect CPU support for avx2 instructions.
Performance was seen to improve by 5x for a file with only newlines,
while the performance for a file with no such characters is unchanged.

* configure.ac [USE_AVX2_WC_LINECOUNT]: A new conditional,
set when __get_cpuid_count() and avx2 compiler intrinsics are supported.
* src/wc.c (avx2_supported): A new function using __get_cpuid_count()
to determine if avx2 instructions are supported.
(wc_lines): A new function refactored from wc(),
which implements the standard line counting logic,
and provides the fallback implementation for when avx2 is not supported.
* src/wc_avx2.c: A new module to implement using avx2 intrinsics.
* src/local.mk: Reference the new module.  Note we build as a separate
lib so that it can be portably built with separate -mavx2 etc. flags.
2021-05-02 20:51:37 +01:00
Paul Eggert
d435cfc0bc touch: fix wrong diagnostic (Bug#48106)
Problem reported by Roland (Bug#48106).
* src/touch.c (touch): Take more care when deciding whether
to use open_errno or utime_errno in the diagnostic.
Stop worrying about SunOS 4 (which as part of the problem),
as it’s long obsolete.  For Solaris 10, verify that EINVAL
really means the file was a directory.
2021-05-01 15:47:13 -07:00
Paul Eggert
62a7ce5f50 maint: port to Autoconf 2.71
* configure.ac: Use AC_PROG_CC, not AC_PROG_CC_STDC.
* gl/modules/smack (configure.ac):
* m4/jm-macros.m4 (coreutils_MACROS):
* m4/xattr.m4 (gl_FUNC_XATTR):
Use AS_HELP_STRING, not AC_HELP_STRING.
* m4/check-decl.m4 (gl_CHECK_DECLS):
Do not require AC_HEADER_TIME; we no longer care about it directly.
* m4/jm-macros.m4 (coreutils_MACROS):
Do not require AC_ISC_POSIX, which became obsolete in 2006.
Use AC_LINK_IFELSE instead of AC_TRY_LINK.
2021-04-26 23:32:45 -07:00
Paul Eggert
8527942835 csplit: size_t overflow check
* src/csplit.c (get_new_buffer): Fix unlikely size_t overflow.
2021-04-26 23:32:45 -07:00
Paul Eggert
5fcf8c6487 build: update gnulib submodule to latest
* src/csplit.c (load_buffer):
* src/pinky.c (create_fullname):
Use intprops-based checks rather than xalloc_oversized,
since Gnulib xalloc.h no longer includes xalloc-oversized.h.
2021-04-26 23:32:45 -07:00
Zorro Lang
785478013b copy: do not refuse to copy a swap file
* src/copy.c (sparse_copy): Fallback to read() if copy_file_range()
fails with ETXTBSY.  Otherwise it would be impossible to copy files
that are being used as swap.  This used to work before introducing
the support for copy_file_range() in coreutils.  (Bug#48036)
2021-04-26 18:00:58 -07:00
Bernhard Voelker
b7091093bb tests: fix FP in ls/stat-free-color.sh
On newer systems like Fedora 34 and openSUSE Tumbleweed, ls(1) calls
newfstatat(STDOUT_FILENO, ...), but only when there is something to
output.

* tests/ls/stat-free-color.sh: Add -a option to the reference invocation
of ls, thus enforcing something gets output.
2021-04-22 20:14:32 +02:00
Pádraig Brady
34a48bf0f0 doc: clarify that ln --relative requires --symbolic to be specified
* doc/coreutils.texi (ln invocation): State --symbolic is required.
* src/ln.c (usage): Explicitly state -s is not implied.
Fixes https://bugs.gnu.org/47703
2021-04-11 19:23:37 +01:00
Pádraig Brady
512fe04902 doc: clarify what's counted by wc
* src/wc.c (usage): State that only printable characters are considered
when counting words.  This also disambiguates wether we're talking
about bytes or characters in this context.
* doc/coreutils.texi (wc invocation): Likewise.  Also clarify
that --characters counts valid locale aware characters,
and that --lines does not count a trailing "line" unless
it ends with a newline character.
Fixes https://bugs.gnu.org/47702
2021-04-11 19:23:13 +01:00
Pádraig Brady
ef772bf97f maint: use "char const *" rather than "const char *"
* cfg.mk (sc_prohibit-const-char): Add a new syntax-check to
enforce this style.
* *.[ch]: sed -i 's/const char \*/char const */g'
2021-04-11 18:33:45 +01:00
Pádraig Brady
34ed19eed8 ls: cache name width determination
This is especially important now for --sort=width,
as that can greatly increase how often this
expensive quote_name_width() function is called per file.

This also helps the default invocation of ls,
or specifically the --format={across,vertical} cases
(when --width is not set to 0),
to avoid two calls to this function per file.

Note the only case where we later compute the width,
is for --format=commas.  That's only done once though,
so we leave the computation close to use to
maximize hardware caching.

* src/ls.c (struct fileinfo): Add a WIDTH member to cache
the screen width of the file name.
(update_current_files_info): Set the WIDTH members for cases
they're needed multiple times.  Note we do this explicitly here,
rather than caching at use, so that the fileinfo
structures can remain const in the sorting and presentation functions.
(sort_files): Call the new update_current_files_info() in this
initialization function.
(fileinfo_name_width): Renamed from fileinfo_width,
and adjusted to return the cached value if available.
2021-04-11 14:58:45 +01:00
Carl Edquist
751ad58e00 ls: add --sort=width option to sort by file name width
This helps identify the outliers for long filenames, and also produces
a more compact display of columns when listing a directory with many
entries of various widths.

* src/ls.c (sort_type, sort_types, sort_width): New sort_width sort
type.
(sort_args): Add "width" sort arg.
(cmp_width, fileinfo_width): New sort function and helper for file name
width.
(quote_name_width): Add function prototype declaration.
(usage): Document --sort=width option.
* doc/coreutils.texi: Document --sort=width option.
* tests/ls/sort-width-option.sh: New test for --sort=width option.
* tests/local.mk: Reference new test.
* NEWS: Mention the new feature.
2021-04-11 14:58:38 +01:00
Paul Eggert
e3766c5db1 env: simplify --split-string memory management
* bootstrap.conf (gnulib_modules): Add idx.
* src/env.c: Include idx.h, minmax.h.
Prefer idx_t to ptrdiff_t when values are nonnegative.
(valid_escape_sequence, escape_char, validate_split_str)
(CHECK_START_NEW_ARG):
Remove; no longer needed now that we validate as we go.
(struct splitbuf): New type.
(splitbuf_grow, splitbuf_append_byte, check_start_new_arg)
(splitbuf_finishup): New functions.
(build_argv): New arg ARGC.  Validate and process in one go, using
the new functions; this is simpler and more reliable than the old
approach (as witness the recent bug).  Avoid integer overflow in
the unlikely case where the string contains more than INT_MAX
arguments.
(parse_split_string): Simplify by exploiting the new build_argv.
2021-03-29 21:44:58 -07:00
Paul Eggert
5b5622f605 build: update gnulib submodule to latest 2021-03-29 21:44:58 -07:00
Pádraig Brady
9f1bda18f2 tests: add a test case for recent env fix
* tests/misc/env-S.pl: Add a test case for recent commit ec6904f0.
2021-03-29 15:48:39 +01:00
Pádraig Brady
f20797f1d7 maint: ignore all .a files in .gitignore
* .gitignore: Rather than add the new src/libcksum_pclmul.a,
just ignore any such libs.
* src/.gitignore: Likewise.
Reported by Kristoffer Brånemyr.
2021-03-29 14:10:09 +01:00
Paul Eggert
12abdb757a env: prefer ptrdiff_t
* src/env.c (usvars_used, vnlen, unset_envvars, expansion)
(build_argv): Prefer ptrdiff_t to size_t when either will do.
2021-03-26 15:17:28 -07:00
Paul Eggert
5f99c7533d env: improve whitespace warning
* src/env.c (main): Issue -S warning for any whitespace,
not just space.
2021-03-26 15:17:28 -07:00
Paul Eggert
7fc887299e env: use GNU coding style
* src/env.c: Use GNU coding style for recentish changes.
2021-03-26 15:17:28 -07:00
Paul Eggert
52f11d8b7c env: remove asserts
The assertions didn’t help catch the most recent bug which
was in their area, and kind of get in the way.
* src/env.c: Do not include <assert.h>, and remove all assertions.
These seem to have been put in to pacify gcov, but surely there’s
a better way.
(escape_char): Pacify GCC with 'assume' instead.
2021-03-26 15:17:28 -07:00
Paul Eggert
6c4efdc0f5 doc: document env fix
* NEWS, doc/coreutils.texi (env invocation): Document recent change.
2021-03-26 15:17:28 -07:00
Paul Eggert
ec6904f0ed env: fix address violation with '\v' in -S
Problem reported by Frank Busse (Bug#47412).
* src/env.c (C_ISSPACE_CHARS): New macro.
(shortopts, build_argv, main): Treate all C-locale space
characters like space and tab, for compatibility with FreeBSD.
(validate_split_str, build_argv, parse_split_string):
Use the C locale, not the current locale, to determine whether a
byte is a space character.
2021-03-26 13:50:16 -07:00
Paul Eggert
4698e284f3 hostname: pacify valgrind
* src/hostname.c (main) [IF_LINT]: Free hostname (Bug#47384).
2021-03-25 11:21:15 -07:00
Paul Eggert
c7a588ac36 hostname: use puts
* src/hostname.c (main): Prefer puts to printf "%s\n".
2021-03-25 09:19:02 -07:00
Paul Eggert
8980b7c898 maint: indenting
* src/ln.c: Fix indenting.
2021-03-25 09:19:02 -07:00
Kamil Dudka
6e98f67758 ln: fix memory leaks in do_link
* src/ln.c (do_link): Free memory allocated by convert_abs_rel
on all code paths (Bug#47373).
2021-03-25 09:19:02 -07:00
Paul Eggert
238dd8eb76 stdbuf: port lib to macOS
* src/libstdbuf.c (fprintf, free, strtoumax): Undef these too,
since Gnulib might replace them.
2021-03-24 17:00:46 -07:00
Paul Eggert
1677294076 cksum: port recent changes to macOS
* src/cksum.c (cksum_slice8): Fix bug on little-endian
platforms lacking __bswap_32: the SWAP macro evaluates
its argument multiple times, but the macro has a side effect.
2021-03-24 16:47:50 -07:00
Bernhard Voelker
b5a6a56ffc maint: update bootstrap from gnulib
* bootstrap: Sync from gnulib/build-aux/bootstrap; the previous gnulib
update (commit 1a3eb6c30) missed to update that file.
2021-03-22 16:52:11 -07:00
Paul Eggert
a71539e628 ptx: remove use of diacrit module
The diacrit module is obsolete, and ptx’s use of it is obsolete
too; it assumes an 8-bit locale (not that common these days) and
that TeX cannot process the 8-bit characters (nowadays, it can).
* NEWS, doc/coreutils.texi (Charset selection in ptx): Document this.
* bootstrap.conf (gnulib_modules): Remove diacrit.
* src/ptx.c: Do not include diacrit.h.
(print_field, fix_output_parameters): Remove obsolete support
for 8-bit diacritics.
2021-03-21 14:01:15 -07:00
Paul Eggert
1a3eb6c305 build: update gnulib submodule to latest 2021-03-21 14:01:15 -07:00
Pádraig Brady
86c8dc2e85 cksum: don't exit immediately if a single file overflows
This behavior was introduced in commit FILEUTILS-4_0_44-4-g519b707b4.

* src/cksum.c (cksum_slice8): Only report the overflow, and continue.
* src/cksum_pclmul.c (cksum_pclmul): Likewise.
2021-03-15 13:12:29 +00:00
Pádraig Brady
b73b9fcb1d cksum: add --debug to diagnose which implementation used
* src/cksum.c: (main): Use getopt_long to parse options,
and handle the new --debug option.
(pclmul_supported): Diagnose various failures and attempts.
* NEWS: Mention the new option.
2021-03-15 12:44:27 +00:00
Kristoffer Brånemyr
4b9118cdb3 cksum: use pclmul hardware instruction for CRC32 calculation
Use cpuid to detect CPU support for hardware instruction.
Fall back to slice by 8 algorithm if not supported.
A 500MiB file improves from 1.40s to 0.67s on an i3-2310M

* configure.ac [USE_PCLMUL_CRC32]: A new conditional,
set when __get_cpuid() and clmul compiler intrinsics are supported.
* src/cksum.c (pclmul_supported): A new function using __get_cpuid()
to determine if pclmul instructions are supported.
(cksum): A new function refactored from cksum_slice8(),
which calls pclmul_supported() and then cksum_slice8()
or cksum_pclmul() as appropriate.
* src/cksum.h: Export the crctab array for use in the new module.
* src/cksum_pclmul.c: A new module to implement using pclmul intrinsics.
* po/POTFILES.in: Reference the new cksum_pclmul module.
* src/local.mk: Likewise.  Note we build it as a separate library
so that it can be portably built with separate -mavx etc. flags.
* tests/misc/cksum.sh: Add new test modes for pertinent buffer sizes.
2021-03-15 12:44:22 +00:00
Pádraig Brady
90c4ef1f7d maint: propagate DEPENDENCIES to libs in single binary mode
build-aux/gen-single-binary.sh (override_single): A new function
to refactor the existing mappings for dir, vdir, and arch.
This function now also sets the DEPENDENCIES variable so that these
dependencies can be maintained later in the script, where
we now propagate the automake generated $(src_$cmd_DEPENDENCIES)
to our equivalent src_libsinglebin_$cmd_a_DEPENDENCIES.
This will ensure that any required libs are built,
which we require in a following change to cksum that
builds part of it as a separate library.
2021-03-14 23:45:46 +00:00
Pádraig Brady
9de1d153f8 rmdir: diagnose non following of symlinks with trailing slash
GNU/Linux is unusual here in that rmdir("symlink/") returns ENOTDIR,
whereas Solaris and FreeBSD at least, will follow the symlink
and remove the target directory.  We don't make the behavior
on Linux kernels consistent, but at least clarify
the confusing error message.

* src/rmdir (main): Output a specific error message for the above case.
(remove_parents): In the error message, don't assume intermediate paths
are directories, as they could be symlinks.
* tests/rmdir/symlink-errors.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the improvement.
2021-02-19 11:35:30 +00:00
Kamil Dudka
a5e0d8f387 stat,tail: add support for the exfat file system
Bug: https://bugzilla.redhat.com/1921427

* src/stat.c (human_fstype): Add case for the 'exfat' file system type.
* NEWS: Mention the Improvement.
Fixes https://bugs.gnu.org/46613
2021-02-18 13:50:29 +00:00
Erik Auerswald
bd6c97deed pr: fix alignment of input tabs to multiple columns
This regression was introduced in commit COREUTILS-6_8-58-g553d347d3

* src/pr.c (init_parameters): Process tabs for multiple columns.
* tests/pr/pr-tests.pl: Add test cases.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/46422
2021-02-15 21:31:07 +00:00
Pádraig Brady
2de30c7350 cat: extend --show-ends to show \r\n as ^M$
- \r\n is common a line end combination
  - catting such a file without options causes it to display normally
  - overwriting the first char with $, loses info

* src/cat.c (cat): Convert \r preceeding a \n to ^M.
* tests/misc/cat-E.sh: New test.
* tests/local.mk: Reference new test.
* tests/misc/cat-proc.sh: Fix typo.
* doc/coreutils.texi (cat invocation): Mention the new behavior.
* NEWS: Mention the improvement.
2021-02-10 14:17:26 +00:00
Paul Eggert
735083ba24 expr: fix bug with unmatched \(...\)
Problem reported by Qiuhao Li.
* NEWS: Mention this.
* doc/coreutils.texi (String expressions):
Document the correct behavior, which POSIX requires.
* src/expr.c (docolon): Treat unmatched \(...\) as empty.
* tests/misc/expr.pl: New test.
2021-01-26 09:24:41 -08:00
Pádraig Brady
bb21daa125 split: fix --number=K/N to output correct part of file
This functionality regressed with the adjustments
in commit v8.25-4-g62e7af032

* src/split.c (bytes_chunk_extract): Account for already read data
when seeking into the file.
* tests/split/b-chunk.sh: Use the hidden ---io-blksize option,
to test this functionality.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/46048
2021-01-25 21:39:09 +00:00
Paul Eggert
eebed78799 doc: rmdir --recursive substitutes
* doc/coreutils.texi (rmdir invocation): Add note on how to remove
empty subdirectories recursively.
2021-01-18 21:09:27 -08:00
Paul Eggert
e9789a1cf2 mkdir: fix bug when -m's more generous than umask
Problem reported by David McCall (Bug#45886).
I introduced this problem when fixing Bug#14371.
* NEWS: Mention the fix.
* src/mkdir.c (struct mkdir_options): New members umask_ancestor,
umask_self, replacing umask_value.
(make_ancestor): Use them when temporarily adjusting umask.
(main): Set them, and set the umask to umask_self instead
of leaving it alone.
* tests/mkdir/perm.sh (tests): Add test case for bug.
2021-01-15 02:59:24 -08:00
Paul Eggert
06f70d9ee6 doc: modernize and fix regexp xref
* doc/coreutils.texi: Fix regexp cross-reference that had become
out-of-date (Bug#45749).  Also, fix some obsolete references to
SunOS and to /usr/dict/words, and change “Linux” to “GNU/Linux”
where appropriate.  Unfortunately the pipeline example gets more
complicated since /usr/share/dict/words is not sorted the way that
‘comm’ wants.
2021-01-09 13:05:50 -08:00
Bernhard Voelker
ebf2c4dcc6 doc: make formatting of SEE ALSO in cat.1 and tac.1 consistent
None of the coreutils man pages - but the two above - are using bold
setting for the references to other man pages in the SEE ALSO section.

* man/cat.x (SEE ALSO): Remove '\fB...\fP' setting.
* man/tac.x: Likewise, and add a reference to cat(1).
2021-01-03 13:57:36 +00:00
Bernhard Voelker
f01d9e23db maint: exempt 'doc/fdl.texi' from 'make update-copyright'
This file is a copy from gnulib and therefore should not get changed
by the yearly update.

* .x-update-copyright: Add pattern for the above file.
* doc/fdl.texi: Revert the previous change.
2021-01-02 01:39:15 +01:00
Pádraig Brady
32ff1d1313 maint: update all copyright year number ranges
Run "make update-copyright" and then...

* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
2021-01-01 16:36:09 +00:00
Pádraig Brady
ffb7ebfa25 tests: add a test for cksum
* tests/misc/cksum.sh: Test basic operation.
* tests/local.mk: Reference the new test.
2020-12-28 16:21:38 +00:00
Kristoffer Brånemyr
a7533917e0 cksum: use more efficient slice by 8 algorithm
A 100MB file improves from 2.50s to 1.80s on a Sparc T5220
A 100MB file improves from 0.54s to 0.13s on an i3-2310M

* bootstrap.conf: Explicitly depend on byteswap,
since now used directly by coreutils.
* src/cksum.c (cksum): Process in multiples of 8 bytes.
(main): Adjust for generation of expanded crctab.
* src/cksum.h: Split now larger crctab to separate header.
* src/local.mk: Reference the new header.
* NEWS: Mention the improvement.
2020-12-28 16:21:38 +00:00
Paul Eggert
fb64712c4d build: update gnulib submodule to latest
* src/make-prime-list.c (free): Undef, since Gnulib's free-posix
module now defines this to rpl_free on some platforms.
2020-12-24 22:03:13 -08:00
Pádraig Brady
08b59f31a5 doc: remove extraneous ./src/ prefix from examples
* doc/coreutils.texi (numfmt invocation): s|./src/numfmt|numfmt|
2020-12-18 14:58:59 +00:00
Pádraig Brady
e5cb4aaa0b doc: add seq inf and sleep inf examples to texinfo
* doc/coreutils.texi (seq invocation): Mention "inf" is supported,
and describe that it's handled specially to generate infinite
whole integer sequences.  Also mention that such infinite generation
is supported for integer steps up to 200.
(sleep invocation): Give `sleep inf` as an example to sleep forever.
* src/seq.c: Add a comment on SEQ_FAST_STEP_LIMIT, to say it's
reflected in the texinfo description.
2020-12-18 14:54:57 +00:00
Paul Eggert
3e61d5dd31 doc: document mkdir -m -p better
Chris Colohan wrote that the man page did not do enough to dispel
a common misunderstanding that “contributed to one of the scariest
outages Google has ever seen” (Bug#45258).
* doc/coreutils.texi (mkdir invocation):
* src/mkdir.c (usage): Document -m vs -p better.
2020-12-15 11:58:48 -08:00
KOBAYASHI Takashi
567fc2c2ad nl: fix --section-delimiter handling of single characters
* src/nl.c (main): Enforce the POSIX specified
behavior of assuming ':' is specified after a single
character argument to -d.
* tests/misc/nl.sh: Add a test case.
* NEWS: Mention the bug fix.
2020-12-15 14:11:55 +00:00
Pádraig Brady
1935528ce9 doc: mention the GNU extensions to nl --section-delimiter
* doc/coreutils.texi (nl invocation): Mention the GNU extensions
of allowing arbitrary length and empty delimiter strings.
* src/nl.c (usage): Likewise.
* tests/misc/nl.sh: Add test cases for the GNU extensions.
2020-12-15 14:11:51 +00:00
Pádraig Brady
b0d527fb40 maint: refactor nl section delimiter handling
* src/nl.c (main): Update the default delimiter characters
when passed two characters with --section-delimiter.
Avoid redundant copies for the body and footer delimiter strings,
and instead, just offset into the header string.
(check_section): Avoid redundant comparing of 2 bytes of memory
for an empty delimiter.
2020-12-15 13:17:39 +00:00
Paul Eggert
d312696559 build: update gnulib submodule to latest 2020-12-11 19:04:04 -08:00
Arman Absalan
14562f8b20 chroot,comm,join: fix usage options style
* src/chroot.c (usage): Fix indentation of options.
* src/comm.c: Likewise.
* src/join.c: Likewise.
2020-12-08 18:08:17 +01:00
Pádraig Brady
e361bff8a5 date: with --debug, show the output format
The format can be determined from --options or the locale,
so it's useful to output the format string being used.

* src/date.c (show_date): Show the output format
along with the date being shown.
* tests/misc/date-debug.sh: Adjust accordingly.
Addresses https://bugs.gnu.org/44960
2020-12-01 13:51:06 +00:00
Tim Gates
5ed804a9b8 maint: fix typo, characteres -> characters
* src/expr.c: Fix typo in comment.
2020-11-27 19:56:02 +00:00
Nishant Nayan
6bf108358a rm: do not skip files upon failure to remove an empty dir
When removing a directory fails for some reason, and that directory
is empty, the rm_fts code gets the return value of the excise call
confused with the return value of its earlier call to prompt,
causing fts_skip_tree to be called again and the next file
that rm would otherwise have deleted to survive.

* src/remove.c (rm_fts): Ensure we only skip a single fts entry,
when processing empty dirs.  I.e. only skip the entry
having successfully removed it.
* tests/rm/empty-immutable-skip.sh: New root-only test.
* tests/local.mk: Add it.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/44883
2020-11-26 16:51:38 +00:00
Pádraig Brady
b886390947 maint: mention in NEWS about new df remote fs types
* NEWS: Mention new remote file system types
recognized since gnulib commit dd1fc46b.
2020-11-26 14:29:57 +00:00
Pádraig Brady
e53bb7ad05 maint: remove no longer needed se_const helper
This was needed before libselinux-2.3 (May 2014),
but modern releases have the correct const declarations.

* src/chcon.c: Remove se_const() wrapper.
* src/cp.c: Likewise.
* src/install.c: Likewise.
* src/mkdir.c: Likewise.
* src/mkfifo.c: Likewise.
* src/mknod.c: Likewise.
* src/system.h: Likewise.
* gnulib: update to pick up const correctness fixes in selinux stubs.
2020-11-23 22:25:55 +00:00
Pádraig Brady
382044196e maint: fix syntax-check failure
* po/POTFILES.in (src/selinux.c): Remove entry as this source doesn't
contain any translatable strings anymore; avoids a sc_po_check failure.
2020-11-23 14:09:51 +00:00
Paul Eggert
d12f5da6d4 install: suppress "Operation not supported" false alarms
At least, I *think* they are false alarms.  An SELinux expert eye
would be welcome.
* src/install.c (setdefaultfilecon): If selabel_lookup fails
due to either ENOTSUP or ENODATA, don’t diagnose the issue.
Problem reported by Kamil Dudka in:
https://lists.gnu.org/r/coreutils/2020-11/msg00050.html
2020-11-23 01:48:45 -08:00
Paul Eggert
b8a543fe02 maint: propagate errno better in selinux.c
* src/selinux.c: Don’t include die.h; no longer needed.
(computecon, defaultcon, restorecon): Propagate errno.
(defaultcon, restorecon): Don’t diagnose errors or exit, as that’s
the caller’s responsibility.
2020-11-23 01:00:23 -08:00
Pádraig Brady
7b341f084b maint: use absolute paths with selabel_lookup
* src/selinux.c: selabel_lookup requires absolute paths
(while only older matchpathcon before libselinux < 2.1.5 2011-0826 did).
* po/POTFILES.in: Readd src/selinux.c since we now have
a translatable error message.
2020-11-23 01:00:22 -08:00
Bernhard Voelker
344cf0ee5f maint: minor cleanup
The previous commit introduced a couple of syntax-check failures.

* .gitignore (/lib/se-label.h): Add entry to silence the
sc_gitignore_missing check.  Sort entries in C locale.
* po/POTFILES.in (src/selinux.c): Remove entry as this source doesn't
contain any translatable strings anymore; avoids a sc_po_check failure.
* src/mv.c: Replace tabs by spaces to avoid complaints by
sc_prohibit_tab_based_indentation.
2020-11-22 15:17:17 +01:00
Paul Eggert
fc372b4ba7 build: update gnulib submodule to latest 2020-11-21 19:13:11 -08:00
Paul Eggert
3aaa42deaa maint: port from matchpathcon to selabel_lookup
Ubuntu 20.10 is using a newer version of libselinux that
complains that matchpathcon is obsolete.  Rewrite the code
that it uses the recommended selabel_lookup instead.
* m4/jm-macros.m4 (coreutils_MACROS): Do not check for
matchpathcon_init_prefix, as it is no longer used.
* src/copy.c (set_file_security_ctx): Omit process_local arg,
as it is equivalent to !x->set_security_context.  All callers changed.
* src/copy.h (struct cp_options): set_security_context is now of
type struct selabel_handle *, not bool.  All uses changed.
* src/cp.c, src/install.c, src/mkdir.c, src/mkfifo.c, src/mknod.c:
* src/mv.c: Include selinux/label.h.
(main): Use selabel_open for set_security context.
* src/install.c (matchpathcon_init_prefix): Remove; now unused.
(get_labeling_handle): New static function.
(setdefaultfilecon, main): Use it.
(setdefaultfilecon): Do something regardless of
ENABLE_MATCHPATHCON, which seems to be a revenant macro.
(setdefaultfilecon): Use selabel_lookup instead of the obsolescent
matchpathcon.  Report an error unless it fails due to ENOENT.
* src/local.mk (src_ginstall_CPPFLAGS): Remove.
* src/selinux.c: Include selinux/label.h
Do not include die.h, error.h, canonicalize.h.
(defaultcon, restorecon_private, restorecon):
New arg HANDLE.  All callers changed.
Use selabel_lookup rather than matchpathcon.
(restorecon_private, restorecon): Don’t lose track of errno.
* src/selinux.c, src/selinux.h:
(restorecon): Don’t call ‘error’; that’s the caller’s job.
Use HAVE_SELINUX_LABEL_H, not HAVE_SELINUX_SELINUX_H,
in case there is some weird system with the former but not the latter.
* src/selinux.h (struct selinux_handle): Add forward decl.
2020-11-21 18:41:25 -08:00
Paul Eggert
5c8e2716b3 build: port to Solaris 10
* src/local.mk (src_ln_LDADD, src_mktemp_LDADD, src_tac_LDADD):
Add $(LIB_CLOCK_GETTIME), since these use tempname which uses
clock_gettime if getrandom fails.  On platforms like Solaris 10,
clock_gettime is not in the standard C library.
2020-11-21 18:41:25 -08:00
Paul Eggert
4c667a86d3 build: update gnulib submodule to latest 2020-11-21 18:41:24 -08:00
Pádraig Brady
c3a5280731 doc: mention that sort -g supports hex numbers
* doc/coreutils.texi (sort invocation): Mention explicitly
that --general-numeric-sort supports arbitrary format hex numbers,
but also mention that consistent case/width hex numbers can
be sorted faster with a standard sort.
2020-11-18 14:00:43 +00:00
Pádraig Brady
2bc66c5ea7 tr: fix crash validating -c with some case char classes
This crash was identified by Cyber Independent Testing Lab:
https://cyber-itl.org/2020/10/28/citl-7000-defects.html
and was introduced with commit v8.5-163-g3f48829c2

* src/tr.c (validate_case_classes): Don't apply these
extra case alignment checks in the --complement case,
which is even more restrictive as to the contents of SET2.
* tests/misc/tr-case-class.sh: Add a test case,
for a large SET1, which caused the length adjustment
in validate_case_classes to underflow and trigger the assert.
* NEWS: Mention the bug fix.
2020-11-14 16:51:49 +00:00
Ben Pfaff
1833f51aaa doc: clarify in texinfo that test == ... is non portable
* doc/coreutils.texi (test invocation): Mention non portability
of the double equals form.
2020-11-12 18:59:31 +00:00
Pádraig Brady
6fc695cb4a ls: fix crash printing SELinux context for unstatable files
This crash was identified by Cyber Independent Testing Lab:
https://cyber-itl.org/2020/10/28/citl-7000-defects.html
and was introduced with commit v6.9.90-11-g4245876e2

* src/ls.c (gobble_file): Ensure scontext is initialized
in the case where files are not statable.
* tests/ls/selinux-segfault.sh: Renamed from proc-selinux-segfault.sh,
and added test case for broken symlinks.
* tests/local.mk: Adjust for the renamed test.
* NEWS: Mention the bug fix.
2020-11-11 17:28:54 +00:00
Pádraig Brady
beafa5c0a3 timeout: support sub-second timeouts on macOS
* m4/jm-macros.m4: Check for setitimer.
* src/timeout.c: Use setitimer if timer_settime is not available.
* NEWS: Mention the improvement.
2020-11-07 21:35:01 +00:00
Pádraig Brady
165a80f6e6 maint: avoid strncat warning on GCC
GCC 10.1.1 without optimization gives:

  error: ‘strncat’ argument 2 declared attribute ‘nonstring’
    [-Werror=stringop-overflow=]
    strncat (comment, UT_ID (utmp_ent), utmpsize);

Note the strncat man page says that:
  "src does not need to be null-terminated
   if it contains n or more bytes."
And the POSIX spec says that the second (source) parameter
is an array not a string.
So I think it's incorrect for strncat to require src be a string type.
This constraint seems to be being added to the gcc builtin strncat,
as specifiying -fno-builtin also avoids the warning.
Note specifying any optimization level also avoids the warning.

* src/who.c (make_id_equals_comment): Avoid the issue by using
stpcpy + stzncpy, instead of strcpy + strncat.
This pattern is used elsewhere in who.c
2020-11-07 21:34:34 +00:00
Pádraig Brady
ff80b6b0a0 stat,tail: sync file system constants from the linux kernel
* src/stat.c: Add magic constants for "devmem", and
"zonefs" file systems.
* NEWS: Mention the improvement.
2020-10-28 14:16:29 +00:00
Pádraig Brady
53324dd611 maint: cleanup operation of fs-magic-compare
* src/local.mk: Ensure we map 2 hex digits to 4,
so that we don't output already handled Z3FOLD file system (0x33).
Also hide the generation command for src/fs.h.
2020-10-28 14:16:12 +00:00
Pádraig Brady
51cfaef655 doc: make blank lines before --help consistent
* src/basenc.c (usage): Remove extraneous blank line,
to be consistent with other utilities that have options.
* src/realpath.c: Likewise.
* src/runcon.c: Likewise.
Addresses https://bugs.gnu.org/44248
2020-10-27 19:23:46 +00:00
Jim Meyering
cc816fb978 maint: avoid new sort.c warning from upcoming GCC11
gcc version 11.0.0 20201025 (experimental) warns that
src/sort.c:1655:1: warning: function might be candidate for attribute \
  'pure' if it is known to return normally [-Wsuggest-attribute=pure]
* src/sort.c (limfield): Mark as pure.
2020-10-26 07:47:36 -07:00
Kamil Dudka
4278e6615f dd: drop old workaround for lseek() bug in Linux kernel
The workaround triggers warnings from newer kernel versions in case
a user does not have sufficient privileges for the MTIOCGET ioctl.

* src/dd.c (skip_via_lseek): Drop wrapper function no longer needed.
(skip): Use lseek() directly.
(advance_input_after_read_error): Likewise.

Reported-by: Nir Soffer at https://bugzilla.redhat.com/1876840
Fixes https://bugs.gnu.org/44235
2020-10-26 13:31:36 +00:00
KOBAYASHI Takashi
2c898597ea nl: support a negative --line-increment
* src/nl.c (main): Allow -i to accept down to INTMAX_MIN.
* tests/misc/nl.sh: Add test cases.
* NEWS: Mention the new feature.
2020-10-26 13:15:46 +00:00
Pádraig Brady
fe41d6c651 nl: only fail if need to output overflowed numbers
Previously we would have failed immediately upon internal overflow,
which didn't output the full line being processed, and assumed
there would be another numbered line.

* src/nl.c (line_no_overflow): A new global to track overflow.
(print_lineno): Only fail if about to output an overflowed number.
(reset_lineno): A new function to refactor resetting of the number,
and which also clears line_no_overflow.
* tests/misc/nl.sh: Add a test case.
2020-10-25 16:57:19 +00:00
Pádraig Brady
175c7c6a60 maint: add lib/parse-datetime-gen.h to .gitignore
* .gitignore: update to ignore new file
generated by the latest gnulib update.
2020-10-25 13:35:40 +00:00
Pádraig Brady
f803c0e92d maint: sync help2man to latest version
* man/help2man: sync to changes from version 1.47.16.
Note this doesn't materially change the generated man pages.
Addresses https://bugs.gnu.org/44105
2020-10-25 13:31:37 +00:00
Paul Eggert
00ea4bacf6 build: update gnulib submodule to latest
* gl/lib/randperm.c, src/cp-hash.c, src/ls.c, src/sort.c, src/tail.c:
Change all instaces of hash_delete to hash_remove to accommodate
change to Gnulib API.
2020-10-19 10:58:53 -07:00
Grigorii Sokolik
d9b33b1535 maint: remove already handled FIXME in tail.c
* src/tail.c: Remove FIXME to follow a file name in a recreated
directory. The comment was added in commit v8.5-191-g61b77891c
while the fix (albeit not using inotify) was added in
commit v8.27-21-gba5fe2d4b
2020-10-17 16:54:17 +01:00
Grigorii Sokolik
db3131adb8 maint: update docs for build prerequisites
* README-prereq: Explicitly pull tags,
and update the xz git repo url.
2020-10-17 16:53:35 +01:00
Benno Schulenberg
ebaffa5094 doc: fix punctuation in stat --help
* src/stat.c (usage): Replace a mistaken semicolon with a colon,
and replace mistaken backticks with single quotes.  Also reorder
some words, for clarity.
Fixes https://bugs.gnu.org/43707
2020-09-29 21:57:30 +01:00
Pádraig Brady
5b8161ee4d doc: clarify timeout --foreground description
* doc/coreutils.texi (timeout invocation): Avoid any implication
that `timeout --foreground` could be used to retroactively
timeout commands not already invoked by timeout(1).
Fixes bug https://bugs.gnu.org/42831
2020-08-12 18:40:17 +01:00
Emanuele Giacomelli
7cf45f4f6a csplit: fix regex suppression with specific match count
* src/csplit.c (process_regexp): Process the line suppression
in all invocations so that the last match is suppressed.
Previously with a non infinite match count,
the last regex pattern was not suppressed.
* NEWS: Mention the bug fix.
* tests/misc/csplit-suppress-matched.pl: Add a test case.
Fixes https://bugs.gnu.org/42764
2020-08-08 21:50:13 +01:00
Bernhard Voelker
c0e5f8c59b tests: skip some parts of 'tests/rmdir/ignore.sh' if run as root
Parts of this test expect that the rmdir syscall returns with EPERM,
but the root user does not see that.

* tests/rmdir/ignore.sh: Add uid_is_privileged_ guards around parts
of the test which expect rmdir() to fail with EPERM.

Reported by Nick Alcock <nix@esperi.org.uk> in
https://bugs.gnu.org/42633
2020-07-31 19:49:35 +02:00
Bernhard Voelker
881c3f20ec doc: show version in title of HTML manual
* doc/coreutils.texi (@include version.texi): Move before ...
(@settitle): ... this.  Add the version after the package name.

Suggested by Jonny Grant <jg@jguk.org> in
https://lists.gnu.org/r/bug-coreutils/2020-07/msg00021.html
2020-07-28 23:30:11 +02:00
Paul Eggert
fd0fdeff94 build: update gnulib submodule to latest
* src/local.mk (src_expr_LDADD, src_factor_LDADD):
Adjust to Gnulib renaming of LIB_GMP to LIBGMP.
2020-07-28 13:45:47 -07:00
Pádraig Brady
97757b5eba doc: fix typo in env --split-string documentation
* doc/coreutils.texi: Fix grammar.
2020-07-27 13:16:42 +01:00
Paul Eggert
fa7a5074d7 date: clarify the Epoch
* src/date.c (usage): Mention the Epoch under %s for clarity,
and capitalize.
2020-07-24 13:33:40 -07:00
Paul Eggert
3f06bde222 doc: modernize date examples
* doc/coreutils.texi: Use more-modern date examples.
Capitalize “Epoch” to be consistent with POSIX.
2020-07-24 13:33:40 -07:00
Paul Eggert
7b3a62e016 build: update gnulib submodule to latest
* bootstrap.conf (gnulib_modules): Add hash-triple.
2020-07-24 13:33:40 -07:00
Bernhard Voelker
49bd08aea5 doc: clarify 'timeout -k' behavior
* doc/coreutils.texi (timeout invocation): Document that the the
duration of --kill-after=DURATION begins when sending the initial
signal.  Also mention that -k does not have any effect if timeout's
duration is 0.

Suggested by Jonny Grant <jg@jguk.org>.
2020-07-20 22:02:02 +02:00
Paul Eggert
9462c1202d factor: port to --without-libgmp
* src/factor.c (mp_factor_using_division): Use mpz_fdiv_q_2exp
instead of its no-longer-documented mpz_div_2exp alias.
(print_factors): Use mpz_out_str instead of gmp_printf.
2020-07-18 18:46:35 -07:00
Paul Eggert
6b6f0f54c0 build: be less aggressive about -fanalyzer
* configure.ac: Don’t enable -fanalyzer unless configured with the
new --enable-gcc-warnings=expensive option.  See thread at:
https://lists.gnu.org/r/coreutils/2020-07/msg00011.html
2020-07-10 17:38:31 -07:00
Paul Eggert
55d985064c factor: explain why non-GMP code (Bug#42269)
* doc/coreutils.texi (factor invocation):
* src/factor.c: Explain why the two-word algorithm is useful.
2020-07-08 18:59:41 -07:00
Paul Eggert
67fc55d636 doc: mention expr and factor bignums
* NEWS:
* doc/coreutils.texi (expr invocation, factor invocation):
Mention bignum support on all platforms.  Modernize timings.
2020-07-08 08:11:57 -07:00
Paul Eggert
95955e6746 factor: treat ' +bignum' like non-bignum
* src/factor.c (strto2uintmax): Instead of here ...
(print_factors): ... skip spaces and '+' here, so that
bignums are treated like non-bignums.
* tests/misc/factor.pl (bug-gmp-plus_2_sup_128_plus_1): New test.
2020-07-08 08:11:57 -07:00
Paul Eggert
af941bc523 tests: simplify since expr now works on bignums
* cfg.mk (sc_prohibit_expr_unsigned): Remove.
* tests/dd/skip-seek-past-dev.sh (DEV_OFLOW):
* tests/id/setgid.sh (gp1):
* tests/misc/cut-huge-range.sh (CUT_MAX):
* tests/misc/expr.pl:
* tests/misc/sort-discrim.sh:
Assume expr works on bignums.
* tests/misc/cut-huge-range.sh (subtract_one):
Remove; no longer needed.
2020-07-08 08:11:57 -07:00
Paul Eggert
712855a77d factor: simplify tests by assuming libgmp
* tests/misc/factor.pl: Test bignums even if !HAVE_GMP.
2020-07-08 08:11:57 -07:00
Paul Eggert
1304644488 maint: use Gnulib libgmp module
This lets use assume multiple-precision arithmetic on all
platforms, simplifying the code.
* bootstrap.conf (gnulib_modules): Add libgmp.
* configure.ac: Don’t call cu_GMP, as this is now done by Gnulib.
* m4/gmp.m4: Remove.
* src/expr.c, src/factor.c: Use gmp.h unconditionally.
* src/factor.c: Use the simpler ‘#ifndef mpz_inits’ to
determine whether there is an mpz_inits macro.
2020-07-07 14:48:21 -07:00
Paul Eggert
4c8495cf11 build: update gnulib submodule to latest 2020-07-07 14:48:21 -07:00
Bernhard Voelker
b1c6ef230c doc: add timeout examples
* doc/coreutils.texi (timeout invocation): Add examples.

Suggested by Jonny Grant <jg@jguk.org> in
https://lists.gnu.org/r/bug-coreutils/2020-06/msg00018.html
2020-07-04 00:19:31 +02:00
Andreas Schwab
6a3d2883fe tests: avoid spurious testsuite failure
* tests/dd/stats.sh: Increase timeout.
Fixes https://bugs.gnu.org/42135
2020-06-30 13:44:34 +01:00
Pádraig Brady
947c553ff9 tests: fix false failure with valgrind and reflink
* tests/cp/fiemap-FMR.sh: Avoid FICLONE ioctl,
which would avoid the point of the test (fiemap testing).
Also it avoids a valgrind bug with this ioctl:
https://bugs.kde.org/show_bug.cgi?id=397605
2020-06-26 19:57:09 +01:00
Paul Eggert
4b04a0c3b7 cp: use copy_file_range if available
* NEWS: Mention this.
* bootstrap.conf (gnulib_modules): Add copy-file-range.
* src/copy.c (sparse_copy): Try copy_file_range if not
looking for holes.
2020-06-25 18:53:43 -07:00
Paul Eggert
a6eaee501f cp: use SEEK_DATA/SEEK_HOLE if available
If it works, prefer lseek with SEEK_DATA and SEEK_HOLE to FIEMAP,
as lseek is simpler and more portable (will be in next POSIX).
Problem reported in 2011 by Jeff Liu (Bug#8061).
* NEWS: Mention this.
* src/copy.c (lseek_copy) [SEEK_HOLE]: New function.
(enum scantype): New constants ERROR_SCANTYPE, LSEEK_SCANTYPE.
(union scan_inference): New type.
(infer_scantype): Last arg is now union scan_inference *,
not struct extent_scan *.  All callers changed.
Prefer SEEK_HOLE to FIEMAP if both work, since
SEEK_HOLE is simpler and more portable.
(copy_reg): Do the fdadvise after initial scan, in case the scan
fails.  Report an error if the initial scan fails.
(copy_reg) [SEEK_HOLE]: Use lseek_copy if scantype says so.
2020-06-25 18:53:43 -07:00
Paul Eggert
2fcd0f3328 cp: avoid copy_reg goto
* src/copy.c (copy_reg): Redo to avoid label and goto.
2020-06-25 18:53:43 -07:00
Paul Eggert
761ba28400 cp: refactor extent_copy
* src/copy.c (extent_copy): New arg SCAN, replacing
REQUIRE_NORMAL_COPY.  All callers changed.
(enum scantype): New type.
(infer_scantype): Rename from is_probably_sparse and return
the new type.  Add args FD and SCAN.  All callers changed.
2020-06-25 18:53:43 -07:00
Paul Eggert
d80820b3b5 maint: typo fix
* NEWS: Fix typo.
2020-06-25 18:53:42 -07:00
Paul Eggert
eac715a412 chmod: man page fixes
* man/chmod.x: Mention -6000 too.  Use .BR to fix trailing period.
2020-06-23 08:41:40 -07:00
Pádraig Brady
6de819a2e3 doc: fix punctuation in man pages
* man/chmod.x: Add missing punctuation.
* src/expand-common.c: Likewise.
* src/numfmt.c: Likewise.
* src/rm.c: Likewise.

Fixes https://bugs.gnu.org/41962
2020-06-21 22:43:20 +01:00
Bernhard Voelker
f5644c986c stat,tail: add support for the VBOXSF file system
* src/stat.c (human_fstype): Add case for the 'vboxsf' file system type
which is used for VirtualBox Shared Folders mounted in VirtualBox guest
VMs.
* NEWS: Mention the Improvement.
Fixes https://bugs.gnu.org/41935
2020-06-20 16:07:19 +02:00
Paul Eggert
25725f9d41 cp: default to COW
Likewise for ‘install’.  Proposed in Bug#24400, and long past due.
* NEWS:
* doc/coreutils.texi (cp invocation):
* src/copy.h (enum Reflink_type): Document this.
* src/cp.c (cp_option_init):
* src/install.c (cp_option_init): Implement this.
2020-06-18 22:38:06 -07:00
Tobias Stoeckmann
0fe9fdece7 maint: avoid signed integer overflows
Since -LONG_MIN results in LONG_MIN again, the operation itself is
a signed integer overflow.

This can be observed with the following calls (best if compiled
with -ftrapv or -fsanitize=undefined):

  $ numfmt --padding=-9223372036854775808
  $ seq 1e-9223372036854775808

Technically, the change in seq "reduces" the precision, but a double
or long double that small would be represented as 0 anyway.

* src/numfmt.c: Explicitly disallow --padding=LONG_MIN.
* src/seq.c: Treat 1e$LONG_MIN as 1e-$LONG_MAX.
* tests/misc/numfmt.pl: Add a test case.
* tests/misc/seq-precision.sh: Likewise.

Fixes https://bugs.gnu.org/41850
2020-06-15 23:07:03 +01:00
Bernhard Voelker
189776ff3b doc: timeout: improve documentation of the exit status
* doc/coreutils.texi (timeout invocation): Document that the exit
status is 137 when the KILL signal is used, regardless of whether that
signal is sent to COMMAND or timeout.
* src/timeout.c (usage): Likewise. Also split out and expand
on the possible exit status values to a separate table.

Discussed at https://bugs.gnu.org/41634
2020-06-07 15:41:48 +02:00
Paul Eggert
b4ab357e42 maint: use getrandom, not getentropy
This makes for one Gnulib module less, and at runtime there’s
typically just one getrandom syscall instead of several for large
nonces.
* gl/lib/randread.c: Include sys/random.h instead of sys/time.h
and unistd.h.
(get_nonce): Use getrandom, not getentropy.
* gl/modules/randread (Depends-on):
Depend on getrandom, not getentropy.
* src/shred.c (main):
* src/shuf.c (main):
* src/sort.c (random_md5_state_init):
Say "getrandom" rather than "getentropy" in (unlikely) diagnostic.
2020-06-01 15:54:50 -07:00
Paul Eggert
b3ff4113fd maint: use getentropy and new tempname modules
Update gnulib submodule to latest and use its new features.
Gnulib’s new getentropy module means coreutils can now assume
getentropy instead of approximating it, badly in some cases.
Gnulib’s improvements to the tempname module mean coreutils no
longer needs to maintain private patches.
* bootstrap.conf (gnulib_modules): Remove gettimeofday.
* gl/lib/randread.c (NAME_OF_NONCE_DEVICE): Remove.
(get_nonce): Return success indicator.  Remove bytes_bound arg.
All callers changed.  Rewrite by using getentropy instead of
reading the nonce device and falling back on gettimeofday.
Fail if getentropy fails.
(randread_new): Return NULL (setting errno) if get_nonce fails.
All callers changed.
* gl/lib/tempname.c.diff, gl/lib/tempname.h.diff:
* gl/modules/tempname.diff: Remove.
* gl/modules/randread (Depends-on):
Depend on getentropy, not gettimeofday.
* src/ptx.c (swallow_file_in_memory):
* src/shuf.c (read_input):
Adjust to read_file changes in Gnulib.
* src/shred.c (main):
* src/shuf.c (main):
* src/sort.c (random_md5_state_init):
Diagnose the new form of randread_new failures: randread_new can
fail now when !random_source, meaning getentropy failed.
2020-05-31 22:39:48 -07:00
Paul Eggert
c229285ceb echo: pacify Oracle Studio 12.6
* src/echo.c (main): Don’t assign pointer to bool.
This is well-defined in C99, but is arguably bad style
and Oracle Studio 12.6 complains.
2020-05-31 22:39:48 -07:00
Bernhard Voelker
aefd434e56 maint: copy FDL from gnulib instead of using it as module
Since the previous gnulib update, bootstrap outputs this warning:

  Notice from module fdl:
    Don't use this module! Instead, copy the referenced license file \
    into your version control repository.

See gnulib commit:
  https://git.sv.gnu.org/cgit/gnulib.git/commit/?id=88fc5afbccc9

* bootstrap.conf (gnulib_modules): Remove 'fdl'.
* doc/fdl.texi: Add file as a copy of 'gnulib/doc/fdl.texi'.
* doc/.gitignore (/fdl.texi): Remove entry.
* cfg.mk (FILTER_LONG_LINES): Add pattern for the 'fdl.texi' file.
2020-05-25 16:31:08 +02:00
Bernhard Voelker
46e0ce5e5d maint: fix syntax-check failure from recent adjustment
* cfg.mk (old_NEWS_hash): Regenerate after commit v8.32-15-g6d0107a37
2020-05-23 03:53:59 +02:00
Bernhard Voelker
9dbaf54eed tests: fix removed-directory test
The previous attempt to skip that test on NFS (commit 4181fc5183)
made the test fail; it introduced two problems:
a) In the good case, i.e., when the subshell returns with exit status 0,
the test ran into framework_failure_.
b) As the subshell also runs with 'set -x', the later comparison of
/dev/null with 'err' would fail.

* tests/ls/removed-directory.sh: Revert to the style without subshell,
and add 'test -d .' to verify that 'ls' can read the removed dir.
2020-05-23 03:42:24 +02:00
Paul Eggert
6d0107a37f date: document +%-N change
Suggested by Kamil Dudka in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00205.html
* NEWS: Mention the change for coreutils 8.23.
* doc/coreutils.texi (Padding and other flags):
Document it.
2020-05-20 17:32:53 -07:00
Paul Eggert
4181fc5183 ls: port removed-directory test to NFS
* tests/ls/removed-directory.sh:
Port test to NFS, where one gets a stale file handle
when looking at a removed directory.
2020-05-20 17:32:53 -07:00
Paul Eggert
dc7aac9c7e dd: omit unnecessary vars when !lint
* src/dd.c (real_ibuf, real_obuf) [!lint]:
Remove, as they're needed only when lint checking.
All uses removed when 'lint' is not defined.
2020-05-20 17:32:53 -07:00
Paul Eggert
e18efcfd04 maint: omit unnecessary pragmas and fix tsort.c
* src/chown-core.c, src/comm.c:
* src/tsort.c (record_relation):
Remove GCC 10 pragmas that are not needed in GCC 10.1.0 (the first
public GCC 10 release) and that in some cases cause diagnostics
with GCC 10.1.0.  The tsort.c change fixes a bug that was
inadvertantly introduced when these pragmas were added.
2020-05-20 17:32:52 -07:00
Paul Eggert
1bbb0827db build: update gnulib submodule to latest 2020-05-20 17:32:52 -07:00
Pádraig Brady
c7194b43fc maint: avoid warnings from GCC's -fanalyzer
* src/env.c (build_argv): Add an assert() to avoid:
  warning: use of NULL 'n' where non-null expected
  [CWE-690] [-Wanalyzer-null-argument]
  note: argument 1 of 'getenv' must be non-null
* src/dd.c (alloc_ibuf): Don't discard the allocated pointer, to avoid:
  [CWE-401] [-Wanalyzer-malloc-leak]
(alloc_obuf): Likewise.
(cleanup): Deallocate the now tracked buffers which
also avoids "possibly lost" warnings from valgrind.
* src/tsort.c (search_item): Add asserts to avoid:
  [CWE-690] [-Wanalyzer-null-dereference]
(record_relation): An assert doesn't suffice here,
so disable the warning for this function.
* src/comm.c: Suppress the following false positive for the whole file:
  [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
* src/chown-core.c: Suppress the following false positive for the file:
  [CWE-415] [-Wanalyzer-double-free]
2020-05-11 21:18:47 +01:00
Jason Kim
9c8a385aa4 ls: allow --classify to be ignored for non tty output
Have the `ls` `--classify` option take an optional argument for when to
classify ("always", "auto", "never"), just like the optional argument
for `--color`.  When the optional argument is not specified, default to
"always" for backwards compatibility.

* src/ls.c (usage): Update help text.
(decode_switches): Support an optional argument for --classify.
* tests/ls/classify.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.
2020-04-27 13:48:32 +01:00
Bernhard Voelker
f38bd362d9 build: update gnulib to latest - to avoid du(1) crash on XFS
Pull in a fix for FTS to avoid a crash when traversing a heavily
changed XFS file system:

> fts: remove NOSTAT_LEAF_OPTIMIZATION

* NEWS (Bug fixes): Mention the fix.
* gnulib: Update to latest.
* bootstrap: Sync from gnulib/build-aux/bootstrap.

Discussed at:
<https://lists.gnu.org/r/bug-gnulib/2020-04/msg00068.html>
2020-04-22 19:45:36 +02:00
Pádraig Brady
730876d067 maint: clean up recently added test
* tests/misc/uniq-collate.sh: Remove logic that
was already refactored into gen_input().
2020-04-02 16:10:05 +01:00
Pádraig Brady
7b5f0fa47c cp: ensure --attributes-only doesn't remove files
* src/copy.c (copy_internal): Ensure we don't unlink the destination
unless explicitly requested.
* tests/cp/attr-existing.sh: Add test cases.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/40352
2020-04-02 15:44:55 +01:00
Paul Eggert
271b217045 build: update gnulib submodule to latest
* src/selinux.c: Do not include dosname.h; not needed, since
system.h does that for us via dirname.h.
2020-03-28 13:05:32 -07:00
Bernhard Voelker
9b4bb9d28a maint: add texi2dvi build directory to doc/.gitignore
* doc/.gitignore (/coreutils.t2p/): Add entry for the build directory
left behind after 'make pdf'.
While at it, sort the file.
2020-03-15 11:20:41 +01:00
Paul Eggert
672819c73f ls: improve removed-directory test
* tests/ls/removed-directory.sh: Remove host_triplet test.
Skip this test if one cannot remove the working directory.
From a suggestion by Bernhard Voelker (Bug#39929).
2020-03-07 10:30:56 -08:00
Paul Eggert
10fcb97bd7 ls: restore 8.31 behavior on removed directories
* NEWS: Mention this.
* src/ls.c: Do not include <sys/sycall.h>
(print_dir): Don't worry about whether the directory is removed.
* tests/ls/removed-directory.sh: Adjust to match new (i.e., old)
behavior.
2020-03-07 10:19:57 -08:00
Pádraig Brady
da589f1d63 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-03-05 14:04:42 +00:00
Pádraig Brady
8d13292a73 version 8.32
* NEWS: Record release date.
2020-03-05 13:23:50 +00:00
Pádraig Brady
c8539d36c7 tests: don't rely on system env(1) being present
* tests/misc/env-S.pl: `env -i env` will call the system env
due to the path being cleared, so pass the absolute path
of our env binary under test to avoid that.  This was seen
to be an issue on Guix where /usr/bin/env was not available.
2020-03-04 18:00:38 +00:00
Pádraig Brady
0ea65e29dc basenc: avoid undefined behaviour in z85 processing
* src/basenc.c (z85_decode_ctx_init): Ensure we're working
with unsigned, as otherwise ubsan triggers with:
  src/basenc.c:767:18: runtime error: signed integer overflow:
  43 * 52200625 cannot be represented in type 'int'
(z85_encode): Likewise to avoid the usban error:
  src/basenc.c:630:26: runtime error:
  left shift of 134 by 24 places cannot be represented in type 'int'
2020-03-04 12:38:27 +00:00
Pádraig Brady
f2034aa9bb tests: avoid a false failure on OpenIndiana 11
* tests/misc/timeout-parameters.sh: Split the large timeout
handling to ...
* tests/misc/timeout-large-parameters.sh: ... here, so that
the 3 second delay is contained in its own test, and if
the test is skipped due invalid handling within timeout(1),
it will be more apparent.
Also adjust the check so we skip whenever the kernel timer
fires immediately, to handle the buggy OpenIndiana 11 kernel also.
Reported by Bruno Haible.
2020-03-01 23:36:05 +00:00
Pádraig Brady
ab305f746e tests: avoid a hang on GNU/Hurd from 2019
* tests/du/8gb.sh: Add a timeout around:
`dd bs=1 seek=8G of=big < /dev/null`
2020-03-01 22:04:20 +00:00
Pádraig Brady
04e2b9b1a6 tests: use bash in some scripts to avoid false failures
* init.cfg (require_bash_as_SHELL_): A new function to replace
SHELL for the current test, with bash if available.
This is useful on OpenIndiana 11 where /bin/sh was seen
to have races in handling of SIGPIPE.
* tests/misc/seq-epipe.sh: Use the new function to enforce bash.
* tests/misc/env-signal-handler.sh: Likewise.
Reported by Bruno Haible
2020-03-01 22:02:39 +00:00
Pádraig Brady
5cdab9f26b tests: improve test coverage for ls stat checks
* tests/ls/stat-free-color.sh: Check for the availability
of various stat calls individually, and add statx() and fstatat64()
to the list to check.  Fix the stat counting logic to
ignore lines like "+++ exited with 0 +++".
* tests/ls/stat-free-symlinks.sh: Check syscalls other than stat().
2020-03-01 13:06:01 +00:00
Bruno Haible
e840c78685 tests: enable 4 more tests to be executed on FreeBSD
* init.cfg (gcc_shared_libs_): New variable.
(gcc_shared_): Use it, instead of hardcoding -ldl.
(require_gcc_shared_): Determine the suitable value
for gcc_shared_libs_.
2020-03-01 10:56:12 +00:00
Pádraig Brady
ea1c1b7515 tests: fix incorrect || fail pattern in tests
* tests/ls/stat-free-symlinks.sh: s/|| fail/|| fail=1/.
* tests/misc/tee.sh: Likewise.
* tests/touch/relative.sh: Likewise.
* cfg.mk (sc_prohibit_or_fail): A new syntax-check to avoid this.
2020-02-29 22:45:00 +00:00
Pádraig Brady
de73a867ca tests: avoid false failures on darwin 19.2.0
With these adjustments, all tests pass on macOS Catalina.

* tests/dd/sparse.sh: Adjust so that systems like apfs that
don't create holes < 16 MiB do not fail erroneously.
* tests/touch/trailing-slash.sh: Darwin was seen to dereference
symlinks to files when given a trailing slash, so avoid
that particular case.
2020-02-29 22:45:00 +00:00
Bruno Haible
54bf2c2f1a tests: fix test failure on FreeBSD 12
* tests/misc/csplit-io-err.sh: Limit the effect of the fwrite
override to streams != stderr, as fwrite is in the error() path there.
2020-02-29 22:39:47 +00:00
Jan Nieuwenhuizen
516cdf38af build: once again distribute .tar.gz files
* configure.ac: Reenable distribution of gzip-compressed
tarballs, for Guix bootstrapping reasons as discussed at:
https://lists.gnu.org/r/coreutils/2020-02/msg00042.html
* THANKS.in: Remove me, as now a committer.
* NEWS (Build-related): Mention this.
2020-02-27 21:55:57 +00:00
Pádraig Brady
cc4c55e4bc maint: ensure .deps/ in the project root is ignored by git
* .gitignore: s|*/.deps/|.deps|
2020-02-27 16:44:03 +00:00
Pádraig Brady
8de80feb51 doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.23 which is now about 5 years old.
2020-02-27 16:11:42 +00:00
Colin Watson
05a99f7d7f ls: issue error message on removed directory
If the current directory has been removed, then "ls" confusingly
produced no output and no error message, indistinguishable from
running on an empty directory.

* src/ls.c (print_dir): Report ENOENT on GNU/Linux if readdir
finds no directory entries at all, not even "." or "..",
and a recheck with the getdents syscall returns ENOENT.
We recheck with getdents() as POSIX states that
"The directory entries for dot and dot-dot are optional".
* tests/ls/removed-directory.sh: New file.
* tests/local.mk (all_tests): Add new test.
* NEWS: Mention the change in behavior.
Reported by Owen Thomas.
2020-02-27 14:11:37 +00:00
Pádraig Brady
93db70867d build: update to latest gnulib
* bootstrap.conf: Adjust for changes to fchmodat and fchownat,
which are now separated from chmodat and chownat respectively.
2020-02-25 14:26:39 +00:00
Pádraig Brady
ead8464e3a b2sum: sync better with upstream
* src/blake2/blake2-impl.h: Sync load16() implementation,
which doesn't change code generation.
Also leverage (builtin) memcpy to more efficiently
move data on little endian systems,
giving a 2% win with GCC 9.2.1 on an i3-2310M.
2020-02-25 13:51:21 +00:00
Pádraig Brady
9134993562 factor: sync longlong.h adjustments from upstream
* src/longlong.h: Sync changes from:
https://gmplib.org/repo/gmp/log/tip/longlong.h
mips64: Provide r6 asm code as default expression yields.
arm32: Define sub_ddmmss separately for non-thumb (no rsc instruction).
powerpc: Add "CLOBBER" descriptions for some registers.
x86: Fix criterion for when to use mulx in umul_ppmm.
2020-02-25 11:55:38 +00:00
Pádraig Brady
75f79010cd stat,tail: sync file system constants from the linux kernel
* src/stat.c: Add magic constants for "binderfs", "dma-buf-fs",
"erofs", "ppc-cmm-fs", and "z3fold".
* NEWS: Mention the improvement.
2020-02-25 00:03:40 +00:00
Pádraig Brady
8e81d44b52 uniq: avoid strcoll() to improve performance and consistency
strcoll() is only significant to uniq(1) if it returns 0,
and it generally only does so with buggy locales or mismatched
locales and data.  Some systems may have strcoll()
return 0 for equivalent normalized unicode forms,
but for consistency across platforms strcoll() is avoided.
The various cases are defined in the new test.
This is consistent with newer POSIX standards as discussed at:
https://www.austingroupbugs.net/view.php?id=963

* src/uniq.c: s/xstrcoll/memcmp/.
* tests/local.mk: Reference the new test.
* tests/misc/uniq-collate.sh: Add a new test.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/38627
2020-02-24 10:12:42 +00:00
Pádraig Brady
61c49d3693 doc: clarify that '%a' stat format outputs mode bits
* src/stat.c (usage): Mention permission bits rather than
"access" so there is no confusion with ACLs etc.
Also indicate we output the file type with '%A'.
* doc/coreutils.texi (stat invocation): Likewise.
Also indicate '%A' is similar to `ls -ld` output.
Addresses https://bugs.gnu.org/39613
2020-02-15 11:24:15 +00:00
Pádraig Brady
3150f4a82e tests: fix test for symlink
* tests/cp/preserve-gid.sh: s/-l/-L/.
Reported by Kamil Dudka
2020-02-10 15:06:21 +00:00
Kamil Dudka
b96b1a4728 tests: ensure tests/cp/preserve-gid.sh works with single binary
* tests/cp/preserve-gid.sh: If configured with --enable-single-binary
copy the coreutils single binary, instead of the cp one-line launcher.

Discussed at https://bugzilla.redhat.com/1800597
Fixes https://bugs.gnu.org/39485
2020-02-09 14:19:35 +00:00
Pádraig Brady
304bc557af maint: avoid syntax-check failure in previous commit
* configure.ac: Restrict lines to 80 chars.
2020-02-09 14:19:35 +00:00
Jim Meyering
d7da53c47e build: suppress new FP warning from gcc-10.0.1
* configure.ac (GNULIB_WARN_CFLAGS): Add -Wno-return-local-addr
to avoid FP warning about careadlinkat.c. Discussed starting in
https://lists.gnu.org/r/coreutils/2020-02/msg00006.html
2020-02-08 17:52:48 -08:00
Pádraig Brady
fa6d154b7b build: update to latest gnulib
Pick up recent build fixes to avoid sysctl.h inclusion on glibc systems,
restrict the max file size supported by read-file to PTRDIFF_MAX,
and to avoid a -Werror=unused failure in test-canonicalize.
2020-02-04 19:12:33 +00:00
Pádraig Brady
ab108667ba tests: avoid false failure due to varying /proc/kallsyms
* tests/cp/proc-short-read.sh: Switch to using /proc/cpuinfo,
rather than /proc/kallsyms which was seen to vary in some cases.
Fixes https://bugs.gnu.org/39357
2020-02-04 19:11:37 +00:00
Pádraig Brady
1f443fe572 rmdir: fix --ignore-fail-on-non-empty with permissions errors
Since v6.10-21-ged5c4e7 `rmdir --ignore-fail-on-non-empty`
had reversed the failure status for directories that failed
to be removed for permissions reasons.  I.E. it would have
returned a failure status for such non empty dirs, and vice versa.

* src/rmdir.c (errno_may_be_non_empty): Rename from the
more confusing errno_may_be_empty(), and remove the EEXIST
case (specific to Solaris), which is moot here since
handled in errno_rmdir_non_empty().
(ignorable_failure): Fix the logic error so that
_non_ empty dirs are deemed to have ignorable failures.
(main): Fix clobbering of errno by is_empty_dir().
(remove_parents): Likewise.
* tests/rmdir/ignore.sh: Add a test case.
* THANKS.in: Add reporter who fixed the errno handling.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/39364
2020-02-04 19:11:37 +00:00
Pádraig Brady
709b4d9d8d build: avoid vector performance warnings in randperm
* configure.ac: Add -Wno-vector-operation-performance to suppress the
following gcc-9.2 error in gl/lib/randperm.c:
  error: vector operation will be expanded piecewise
2020-02-03 19:38:02 +00:00
Pádraig Brady
18c9382801 build: avoid including sysctl.h on glibc
* src/uname.c: Avoid unneeded header with GLIBC,
which has been deprecated since glibc-2.30.
* src/uptime.c: Likewise.
2020-02-03 19:38:02 +00:00
Pádraig Brady
2cecc3cc99 ls: support --time=creation to show/sort birth time
* src/ls.c (usage): Reorganize help for --time,
and add description for --time=birth.
(do_statx): Store btime in mtime if available.
(get_stat_btime): A new function to read the creation time
from the appropriate stat structure member.
(cmp_btime): A new function to compare birth time.
(print_long_format): Output '?' when birth time unavailable.
* doc/coreutils.texi: Document --time={birth,creation}.
* tests/local.mk: Reference the new test.
* tests/ls/birthtime.sh: Add a new test.
* NEWS: Mention the new feature.
2020-02-03 19:37:56 +00:00
Chris Meyering
dda53d75a8 build: rearrange yes(1) code to prevent GCC 10 warning
* src/yes.c (main): Convert for loop to do-while in order to indicate
that the loop will be run at least once.
This avoids the following warning after the second loop:
src/yes.c:110:20: error: writing 1 byte into a region of size 0
2020-01-30 18:38:18 +00:00
Emil Engler
fbbf81ec00 maint: add lib/iconv_open-zos.h to .gitignore
* .gitignore: Add file newly generated by gnulib commit 49e78fc
2020-01-01 23:59:40 +00:00
Pádraig Brady
0d77e1b7ea build: auto enable use of openssl with >= version 3
* configure.ac: Set --with-openssl=auto-gpl-compat as the default,
so that openssl is used for md5sum etc., with openssl >= 3,
which is newly licensed under ASL v2.
* gnulib: Update to include "auto-gpl-compat" support.
2020-01-01 22:14:45 +00:00
Pádraig Brady
ff2f85273a maint: adjust to split out xstrtol-error gnulib module
* bootstrap.conf: Depend on the new module split from xstrtol.
* src/df.c: Include "xstrtol-error.h" for xstrtol_fatal.
* src/du.c: Likewise.
* src/ls.c: Likewise.
* src/od.c: Likewise.
* src/pr.c: Likewise.
* src/sort.c: Likewise.
2020-01-01 14:36:12 +00:00
Pádraig Brady
aaba82431c maint: update all copyright year number ranges
Run "make update-copyright" and then...

* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
2020-01-01 14:16:56 +00:00
Bernhard Voelker
7490e94aa7 doc: add example to demonstrate sub-second sleep times
* doc/coreutils.texi (sleep invocation): Add an example to demonstrate
how to use the floating-point and the scientific notation to sleep
for sub-second times, e.g. milli-, micro- and nanoseconds.

Inspired by Stephane Chazelas in:
  https://lists.gnu.org/r/coreutils/2019-12/msg00005.html
2019-12-08 17:44:37 +01:00
Pádraig Brady
ec5ab42604 maint: fix syntax-check failure from recent adjustment
* cfg.mk (old_NEWS_hash): Regenerate after commit v8.31-56-gc1e1965.
2019-12-02 16:21:08 +00:00
Kamil Dudka
5118a2e392 chcon: do not validate security context if SELinux is disabled
* src/chcon.c (main): Skip call of security_check_context()
in case SELinux is disabled to avoid unnecessary failure.

Bug: https://bugzilla.redhat.com/1777831
2019-12-02 16:21:05 +00:00
Paul Eggert
ad591a52b4 doc: remove colon from node name
* doc/sort-version.texi (Minus/Hyphen and Colon characters):
Rename from “Minus/Hyphen @samp{-} and Colon @samp{:} characters”,
as texi2any 6.6 complains about colons in node names.
2019-11-11 16:54:19 -08:00
Paul Eggert
0103fb0244 shred: modernize documentation
* doc/coreutils.texi (shred invocation):
Modernize discussion to today’s technology (Bug#38168).
* src/shred.c (usage): Omit lengthy duplication of the manual’s
discussion of file systems and storage devices, as that became out
of sync with the manual.  Instead, just cite the manual.
2019-11-11 16:54:19 -08:00
Paul Eggert
04b136e298 all: improve parsing of numeric arguments
This addresses a longstanding "update all callers" FIXME in
lib/xstrtol.c, by having programs check that numbers do not
have unknown suffixes.  The problem was also reported for
'shuf' by my student Maggie Huang while reimplementing a shuf
subset in Python as an exercise in UCLA Computer Science 35L:
https://web.cs.ucla.edu/classes/fall19/cs35L/assign/assign3.html
This patch also improves the portability of the code to unusual
platforms where ULONG_MAX < SIZE_MAX.
* NEWS: Mention user-visible changes.
* src/chgrp.c (parse_group):
* src/chroot.c (parse_additional_groups):
* src/du.c (main):
* src/install.c (get_ids):
* src/join.c (string_to_join_field):
* src/ls.c (decode_switches):
* src/md5sum.c (split_3):
* src/shuf.c (main):
* src/sort.c (specify_nthreads):
* src/uniq.c (size_opt, main):
Use uintmax_t instead of unsigned long, for portability
to oddball platforms where unsigned long is not wide enough.
* src/du.c (main):
* src/expr.c (mpz_init_set_str) [!HAVE_GMP]:
* src/install.c (get_ids):
* src/ls.c (decode_switches):
* src/mknod.c (main):
* src/ptx.c (main):
* src/shuf.c (main):
* src/sort.c (specify_nmerge, specify_nthreads):
Reject numbers with suffixes.
* src/md5sum.c (split_3): Simplify.
2019-10-22 15:04:43 -07:00
Paul Eggert
ed2db6886b stdbuf: improve size checking
* bootstrap.conf (gnulib_modules): Add minmax.
* src/libstdbuf.c: Include stdint.h, minmax.h.
(apply_mode): Don’t assume SIZE_MAX <= ULONG_MAX.
Improve checking for invalid sizes.
2019-10-22 15:04:43 -07:00
Paul Eggert
74163ea677 shuf: improve randperm overflow checking
* gl/lib/randperm.c: Include randperm.h first, since it’s the API.
Include stdint.h, count-leading-zeros.h, verify.h.
(floor_lg): Rename from ceil_log (which was not actually
implementing the ceiling!) and implement the floor using
count_leading_zeros.
(randperm_bound): Use floor_lg, not ceil_log.  Use uintmax_t
instead of size_t in case the size gets large on a 32-bit host.
* gl/modules/randperm (Depends-on): Add count-leading-zeros, stdint.
2019-10-22 15:04:43 -07:00
Paul Eggert
565dd395c3 build: don’t worry about logical-op checking
* configure.ac: Remove code tailoring --enable-gcc-warnings
to GCC 4.7 and earlier, as developers no longer need to worry
about GCCs that old.
2019-10-22 15:04:43 -07:00
Paul Eggert
6716a79773 build: re-enable type-limits checking
* configure.ac: When --enable-gcc-warnings is used, omit
-Wno-type-limits.  The need for -Wno-type-limits has passed, now
that intprops.h uses builtin primitives for GCC 5 and later, given
that recent GCCs issue type-limits warnings only for non-constant
expressions.  --enable-gcc-warnings is not intended for use with
old compilers, so we can drop -Wno-type-limits now.
2019-10-22 15:04:42 -07:00
Paul Eggert
c1e19656c8 shuf: fix bug with ‘-r -n 0’
‘shuf -r -n 0 file’ would mistakenly read from standard input.
Problem reported by my student Jingnong Qu while reimplementing a
shuf subset in Python as an exercise in UCLA Computer Science 35L:
https://web.cs.ucla.edu/classes/fall19/cs35L/assign/assign3.html
* NEWS: Mention the fix.  Also, ASCIIfy a previous item.
* src/shuf.c (main): Fix bug.
* tests/misc/shuf.sh: Add a test case for the bug.
2019-10-21 13:20:35 -07:00
Jeff Layton
a99ab26611 ls: use statx instead of stat when available
statx allows ls to indicate interest in only certain inode metadata.
This is potentially a win on networked/clustered/distributed
file systems. In cases where we'd have to do a full, heavyweight stat()
call we can now do a much lighter statx() call.

As a real-world example, consider a file system like CephFS where one
client is actively writing to a file and another client does an
ls --color in the same directory. --color means that we need to fetch
the mode of the file.

Doing that with a stat() call means that we have to fetch the size and
mtime in addition to the mode. The MDS in that situation will have to
revoke caps in order to ensure that it has up-to-date values to report,
which disrupts the writer.

This has a measurable affect on performance. I ran a fio sequential
write test on one cephfs client and had a second client do "ls --color"
in a tight loop on the directory that held the file:

Baseline -- no activity on the second client:

WRITE: bw=76.7MiB/s (80.4MB/s), 76.7MiB/s-76.7MiB/s (80.4MB/s-80.4MB/s),
       io=4600MiB (4824MB), run=60016-60016msec

Without this patch series, we see a noticable performance hit:

WRITE: bw=70.4MiB/s (73.9MB/s), 70.4MiB/s-70.4MiB/s (73.9MB/s-73.9MB/s),
       io=4228MiB (4433MB), run=60012-60012msec

With this patch series, we gain most of that ground back:

WRITE: bw=75.9MiB/s (79.6MB/s), 75.9MiB/s-75.9MiB/s (79.6MB/s-79.6MB/s),
       io=4555MiB (4776MB), run=60019-60019msec

* src/stat.c: move statx to stat struct conversion to new header...
* src/statx.h: ...here.
* src/ls.c: Add wrapper functions for stat/lstat/fstat calls,
and add variants for when we are only interested in specific info.
Add statx-enabled functions and set the request mask based on the
output format and what values are needed.
* NEWS: Mention the Improvement.
2019-10-09 22:07:42 +01:00
Paul Eggert
86ee5548c1 truncate: avoid integer-overflow assumptions
* src/truncate.c (do_ftruncate): Simplify overflow checking,
and don’t rely on theoretically-nonportable assumptions
like assuming that OFF_MAX < UINTMAX_MAX.
2019-10-03 12:41:51 -07:00
Paul Eggert
ba1ea8caee numfmt: avoid unlikely integer overflow
* src/numfmt.c (parse_format_string): Report overflow if
pad < -LONG_MAX, since that can’t be negated.
2019-10-03 12:41:51 -07:00
Paul Eggert
ac2b4a43e6 nl: fix integer-overflow bug
Problem reported by Roland Illig (Bug#37585)
* src/nl.c (print_lineno): Don’t rely on undefined behavior when
checking for integer overflow.
2019-10-03 12:41:51 -07:00
Paul Eggert
bb23a7563f cp: simplify integer overflow checking
* src/copy.c (sparse_copy): Use INT_ADD_WRAPV instead
of doing overflow checking by hand.
2019-10-03 12:41:51 -07:00
Pádraig Brady
1c8050cc4d seq: use faster processing for integer steps from 2 to 200
* src/seq.c: (seq_fast): Accept STEP as a parameter and use that
to skip the output of generated numbers.
(main): Relax to using seq_fast for integer steps between 1 and 200.
For larger steps the throughput was faster using the standard
incrementing procedure.
(cmp): Use the equivalent but faster memcmp for equal len strings.
* tests/misc/seq.pl: Update fast path cases.
Addresses https://bugs.gnu.org/37241
2019-09-08 18:59:24 +01:00
Pádraig Brady
49b1010cc0 maint: use consistent header ordering and spacing in NEWS
* NEWS: Move "Changes in behavior" before "New features",
and ensure there is only a single blank line between sections.
2019-09-08 18:59:21 +01:00
Paul Eggert
f2dfea7e99 build: update gnulib submodule to latest 2019-08-15 02:50:33 -07:00
Assaf Gordon
b8609c7cf2 scripts: document how to build older versions on newer systems
Based on https://lists.gnu.org/r/coreutils/2019-08/msg00011.html .

* scripts/build-older-versions/README.older-versions: Documentation
* scripts/build-older-versions/build-older-versions.sh: Helper script.
* scripts/build-older-versions/.gitignore: Ignore build directory.
* scripts/build-older-versions/coreutils-5.0-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-5.97-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-6.10-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-6.11-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-6.12-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-7.2-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.13-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.17-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.18-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.24-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.4-on-glibc-2.28.diff: Patches.
2019-08-15 01:15:20 -06:00
Bruno Haible
a3d070fa32 build: adjust for recent gnulib pthread changes
Discussed in https://lists.gnu.org/r/coreutils/2019-08/msg00030.html .

* bootstrap.conf (gnulib_modules): Replace 'pthread' with
pthread-* modules.
* src/sort.c: Remove GNULIB_defined_pthread_functions conditional.
2019-08-12 15:10:46 -06:00
Assaf Gordon
725c8d6bed date: mention military timezone changes from gnulib
Gnulib commits f1f10d47be8762e4ca17c8957a0520b08d28abfb and
0673d8ab42c9bb0cf618a21b537cdd8fb976fb73 negated the meaning of
military timezones parsed in gnu date.
See https://lists.gnu.org/r/bug-gnulib/2019-08/msg00005.html and
https://lists.gnu.org/r/coreutils/2019-08/msg00021.html

* NEWS: Mention this user-visible change.
* tests/misc/date.pl: Add tests for the new behavior.
2019-08-10 21:14:20 -06:00
Bernhard Voelker
3cbddd58fd maint: add lib/argmatch.h to po/POTFILES.in
* po/POTFILES.in (lib/argmatch.h): Add to avoid sc_po_check error:
    "maint.mk: you have changed the set of files with translatable \
     diagnostics;"
2019-08-10 21:07:59 -06:00
Assaf Gordon
961d668eea gnulib: update to latest 2019-08-10 21:07:59 -06:00
Pádraig Brady
becf0db0da doc: clarify that truncate creates sparse files
* src/truncate.c (usage): Explicitly mention "sparse".
* doc/coreutils.texi (truncate invocation): Likewise.
Addresses https://bugs.gnu.org/36963
2019-08-08 13:34:54 +01:00
Mike Swanson
eb5a9ebaf1 dircolors: recognize the WebP image format
* src/dircolors.hin: Add .webp for the WebP image format.
Fixes https://bugs.gnu.org/36899
2019-08-07 07:17:27 +02:00
Bernhard Voelker
a574029110 maint: fix error in syntax-check checking
The previous commit introduced a bug into the following syntax-check,
and thus effectively turned it off:

  $ make sc_prohibit_test_calls_print_ver_with_irrelevant_argument; \
      echo $?
  prohibit_test_calls_print_ver_with_irrelevant_argument
  fatal: cannot change to 'grep': No such file or directory
  0

* cfg.mk (sc_prohibit_test_calls_print_ver_with_irrelevant_argument):
Remove changing directory, and pass $(srcdir) as argument to 'git -C'.
2019-08-06 16:11:01 -07:00
Akim Demaille
0e2d4e1425 maint: fix issues in syntax-check
* cfg.mk (sc_prohibit_colon_redirection): Don't expect `|` to denote
the pipe character in git grep.
(sc_tests_executable)
(sc_case_insensitive_file_names)
(sc_some_programs_must_avoid_exit_failure)
(sc_prohibit_test_background_without_cleanup_)
(sc_prohibit_test_calls_print_ver_with_irrelevant_argument)
(sc_prohibit_test_ulimit_without_require_)
(sc_prohibit_test_background_without_cleanup_)
(sc_THANKS_in_duplicates)
*sc_prohibit_test_calls_print_ver_with_irrelevant_argument):
Don't expect builddir to be a descendant of srcdir.
(sc_strftime_check): Don't check file size against 0 when "N\nq\n" was
already put in the file.
* THANKS.in: Remove me.
2019-08-04 11:11:16 -07:00
Assaf Gordon
07f811a3c0 seq: fix superfluous output line
Under certain circumstances seq prints an extra line when the output
format has custom format with characters following the printed numbers:

    $ seq -f "%g " 1000000 1000000
     1e+06
     1e+06

This is due to the "print_extra_number" logic using strings to determine
whether a 'extra number' is needed, but only one string was trimmed
when using a custom printf format.

Prompted by https://lists.gnu.org/r/coreutils/2019-08/msg00001.html

* NEWS: Mention fix.
* src/seq.c (print_numbers): Trim the 'x0_str' string before comparing
it to the previous 'x_str' string.
* tests/misc/seq-extra-number.sh: Add this scenario.
* tests/local.mk (all_tests): Add new test.
2019-08-02 18:29:25 -06:00
Bernhard Voelker
c0f2219d3a doc: improve new version sort chapter
* doc/sort-version.texi: Fix some typos, avoid overly long lines in
the generated PDF, enclose some sample strings in @samp{...} for better
readability, etc.  This also avoids an sc-avoid-builtin error:
s/builtin/built-in/
2019-07-22 08:52:52 +02:00
Assaf Gordon
3264d4ca0d doc: add "version sort ordering" chapter
* doc/sort-version.texi: New file.
* doc/local.mk (doc_coreutils_TEXINFOS): Add new file.
* doc/coreutils.texi: @include new file, replace previous "Details about
version sort" section.
2019-07-15 13:28:20 -06:00
Andreas Dilger
a1a5e9a32e stat: don't explicitly request file size for filenames
When calling 'stat -c %N' to print the filename, don't explicitly
request the size of the file via statx(), as it may add overhead on
some filesystems.  The size is only needed to optimize an allocation
for the relatively rare case of reading a symlink name, and the worst
effect is a somewhat-too-large temporary buffer may be allocated for
areadlink_with_size(), or internal retries if buffer is too small.

The file size will be returned by statx() on most filesystems, even
if not requested, unless the filesystem considers this to be too
expensive for that file, in which case the tradeoff is worthwhile.

* src/stat.c: Don't explicitly request STATX_SIZE for filenames.
2019-07-12 19:51:09 +01:00
Paul Eggert
3ae38a5995 od: use fseek on non-regular files
Problem reported by Szőts Ákos (Bug#36291).
* NEWS: Mention this.
* src/od.c (skip): Try fseek even on files that do not have usable
sizes, falling back on fread if fseek fails.
2019-06-19 18:48:54 -07:00
Paul Eggert
a3a454b9d9 doc: mention ls -l user/group justification
* doc/coreutils.texi (What information is listed):
Document justification of user and group columns in ls -l output
(Bug#36220).
2019-06-18 00:32:25 -07:00
Jeff Layton
0b9bac90d8 stat: fix enabling of statx logic
* src/stat.c: STATX_INO isn't defined until stat.h is included.
Move the test down so it works properly.
2019-06-14 22:43:46 +01:00
Assaf Gordon
0251229bfd tests: avoid false-positive in date-debug test
When debugging an invalid date due to DST switching, the intermediate
'normalized time' should not be checked - its value can differ between
systems (e.g. glibc vs musl).

Reported by Niklas Hambüchen in
https://lists.gnu.org/r/coreutils/2019-05/msg00031.html
Analyzed by Rich Felker in
https://lists.gnu.org/r/coreutils/2019-05/msg00039.html

* tests/misc/date-debug.sh: Replace the exact normalized time
with 'XX:XX:XX' so different values would not trigger test failure.
2019-06-12 21:14:34 -06:00
Jeff Layton
6cc35de16f stat: Use statx where available and support --cached
* src/stat.c: Drop statbuf argument from out_epoch_sec().
Use statx() rather than [lf]stat() where available,
so a separate call is not required to get birth time.
Set STATX_* mask bits only for things we want to print,
which can be more efficient on some file systems.
Add a new --cache= command-line option that sets the appropriate hint
flags in the statx call.  These are primarily used with network
file systems to indicate what level of cache coherency is desired.
The new option is available unconditionally for better portability,
and ignored where not implemented.
* doc/coreutils.texi: Add documention for --cached.
* man/stat.x (SEE ALSO): Mention statx().
* NEWS: Mention the new feature.
2019-06-10 22:59:28 +01:00
Pádraig Brady
bb481a0c1d doc: fix description of tail -f on truncated files
* doc/coreutils.texi (tail invocation): Update to match
the new behavior following commit v8.23-189-gb28ff6a
2019-06-09 12:42:15 +01:00
Pádraig Brady
738a746d82 split: fix failure for certain number of specified files
* src/split.c (set_suffix_length): Use a more standard
zero based logN calculation for the number of units.
* tests/split/suffix-auto-length.sh: Add a test case.
* THANKS.in: Mention the reporter.
* NEWS: Mention the fix.
Fixes https://bugs.gnu.org/35291
2019-06-08 22:58:01 +01:00
Paul Eggert
00d72e6122 dd: be more careful about signal handling
Problem reported by Hans Henrik Bergan (Bug#36007).
* NEWS: Mention this.
* src/dd.c (iclose, ifdatasync, ifstat, ifsync):
New functions, which are more careful about SIGINT.
(cleanup): Use iclose instead of close.
(finish_up): Process signals first.
(skip, dd_copy, main): Use ifstat instead of fstat.
(dd_copy): Use ifdatasync and ifsync instead of fdatasync and fsync.
2019-05-30 13:54:18 -07:00
Paul Eggert
4c223ab4b6 maint: fix version number in NEWS 2019-05-29 16:45:16 -07:00
Paul Eggert
3b1046f80f cp: fix /dev/stdin problem on Solaris
Problem reported by Jakub Kulik (Bug#35713).
* NEWS: Mention this.
* configure.ac (DEV_FD_MIGHT_BE_CHR): New macro.
* src/copy.c (DEV_FD_MIGHT_BE_CHR): Default to false.
(follow_fstatat): New function.
(copy_internal): Use it.
* src/copy.h (XSTAT): Remove; no longer used.
2019-05-28 13:44:40 -07:00
Kevin Locke
3a87ad5124 doc: clarify dd sparse detection is by *output* block
The wording of the dd --help text suggests that output will be skipped
for sparse *input* blocks (i.e. that NUL-checking is done on input
blocks) while the code actually checks/skips all-NUL *output* blocks.[1]

* src/dd.c (usage): Update the --help text to clarify the above.
* tests/dd/sparse.sh: Ensure sparseness is controlled with obs.

[1]: https://superuser.com/a/1136358
2019-05-26 12:53:26 +01:00
Martin Castillo
4f38974aaf doc: fix typo in sort set operations example
* doc/coreutils.texi (sort invocation): Add a missing -u
option to uniq.
Addresses https://bugs.gnu.org/35849
2019-05-22 14:44:56 +01:00
Paul Eggert
a60af87f24 b2sum: port blake2b-ref.c to HP-UX aCC
Continue the fix for Bug#35650.
* src/blake2/blake2b-ref.c [HAVE_CONFIG_H]: Include <config.h>.
2019-05-17 07:58:32 -07:00
Paul Eggert
de54e1a809 b2sum: sync better with upstream
* src/blake2/b2sum.c: Reorder source code to minimize diffs from:
https://github.com/BLAKE2/BLAKE2/blob/master/b2sum/b2sum.c
2019-05-15 12:58:13 -07:00
Paul Eggert
5f261e239f b2sum: port to HP-UX aCC
Its support for the -include option is flaky.  Problem reported by
Michael Osipov (Bug#35650).  Plus, we could run into other
compilers that don’t support any option like -include.  Change the
code so that -include is not needed.  Although this causes us to
depart from the upstream version, we’re already doing that for
other reasons.
* configure.ac (USE_XLC_INCLUDE): Remove, as there’s no
guarantee a compiler will support something like -include.
* src/blake2/b2sum.c [HAVE_CONFIG_H]: Include <config.h>.
* src/local.mk (src_b2sum_CPPFLAGS): Add -DHAVE_CONFIG_H.
Do not use -include or a substitute.
2019-05-15 12:42:58 -07:00
Paul Eggert
5b96efab90 stdbuf: port configure-time checking to HP-UX aCC
Problem reported by Michael Osipov (Bug#35650).
* configure.ac: Use AC_LANG_WERROR to pay attention to compiler
and linker warnings when testing whether stdbuf will work.
2019-05-14 09:21:33 -07:00
Paul Eggert
6e97d361b4 b2sum: port to HP-UX C
* src/blake2/blake2.h (BLAKE2_PACKED):
Don’t assume __attribute__ ((packed)) works on non-Microsoft
compilers.  Instead, assume it works only if we have good
reason to assume so, and fall back on Microsoft (or not packing)
otherwise.  In practice, not packing is good enough and the
BLAKE2_PACKED macro is mostly just for documentation.
2019-05-11 13:55:54 -07:00
Paul Eggert
6f4c2e06ae cp: port fiemap.h to C99
* src/extent-scan.c (extent_scan_read): Adjust to change in
struct fiemap.
* src/fiemap.h (struct fiemap): Use FLEXIBLE_ARRAY_MEMBER
to port to C99.
2019-05-11 13:55:54 -07:00
Paul Eggert
2fd0be3621 basenc: port to C99
* src/basenc.c: Various minor style cleanups.
(struct base_decode_context): Do not use anonymous unions, as
they’re not in C99.  Use a named union instead.  All uses changed.
2019-05-11 13:55:54 -07:00
Paul Eggert
a970a97737 maint: adjust to recent verify_true removal
* src/system.h (X2NREALLOC, X2REALLOC, DECIMAL_DIGIT_ACCUMULATE):
Use verify_expr instead of verify_true, which has been removed.
(DECIMAL_DIGIT_ACCUMULATE): Remove unnecessary size check.
2019-05-11 13:55:54 -07:00
Paul Eggert
39073add8f build: update gnulib submodule to latest 2019-05-11 13:55:54 -07:00
Bernhard Voelker
7d8adb20f6 gnulib: update to the latest
* gnulib: Update to latest, mainly for:
  > mountlist: make parsing /proc/self/mountinfo more robust
* NEWS: Mention the fix.

Fixes https://bugs.gnu.org/33468
2019-04-19 10:21:43 +02:00
Shugo Maeda
6d78a28078 factor: output immediately if stdout is a tty but stdin is not
* src/factor.c (lbuf_putc): Use line buffered mode if the standard
output is a terminal in the same way as the stdio library.
User programs might use pty only for the standard out
like the example of Ruby's PTY module:
https://docs.ruby-lang.org/en/2.6.0/PTY.html#module-PTY-label-Example
* NEWS: Mention the fix.
Fixes https://bugs.gnu.orv/35046
2019-03-31 15:49:48 -07:00
Pádraig Brady
ebf70f297c maint: fix syntax check failure
* src/ln.c: Remove leading TAB.
2019-03-30 15:07:14 -07:00
Martin Castillo
ba36d5118f maint: tee: use STDIN_FILENO rather than 0
* src/tee.c (tee_files): Use the name rather than the value.
Addresses https://bugs.gnu.org/35041
2019-03-30 15:04:42 -07:00
Paul Eggert
59e01d13e6 dd: improve doc of stderr output
* doc/coreutils.texi (dd invocation):
Document stderr output more carefully.
Say that conv=block can lose input data.
2019-03-19 20:09:02 -07:00
Kamil Dudka
ae61b10663 md5sum,b2sum,sha*sum: --help: add note about binary/text mode
* src/md5sum.c (usage): Make it clear that there is no difference
between binary mode and text mode on GNU systems.

Bug: https://bugzilla.redhat.com/406981
Bug: https://bugzilla.redhat.com/1688740
2019-03-18 08:48:57 +01:00
Paul Eggert
1a69508711 doc: add NEWS item for Solaris symlink fix 2019-03-17 13:25:10 -07:00
Paul Eggert
3e0dff3925 ln: port to symlink ("x", ".") failing with EINVAL
Problem reported by John Marino (Bug#34894).
* src/ln.c (main): Port ln -s to Solaris symlink function,
where symlink ("x", ".") fails with errno == EINVAL.
2019-03-17 13:22:32 -07:00
Pádraig Brady
4a21102470 doc: add a NEWS entry for the ln O_DIRECTORY fix
* NEWS: Mention the bugfix.
2019-03-16 14:21:40 -07:00
Paul Eggert
6a707feee8 ln: port to platforms lacking O_DIRECTORY
* src/ln.c (main): Port to older platforms lacking
support for POSIX.1-2008’s O_DIRECTORY flag (Bug#34876).
2019-03-16 11:24:58 -07:00
Kamil Dudka
6bd78f27fd doc: improve wording of the --kibibytes option description
Bug: https://bugzilla.redhat.com/1527391 , https://bugs.gnu.org/33646

* doc/coreutils.texi (General output formatting): Improve wording of
'--kibibytes' option.
2019-03-15 12:26:02 -06:00
Bernhard Voelker
5b9d747261 maint: sync extra files from gnulib
Some files are physically copied from gnulib, and should get sync'ed
after each update to latest gnulib.  This was forgotten during recent
updates.

* COPYING: Merge from gnulib/doc/COPYINGv3.
* tests/init.sh: Merge from gnulib/tests/init.sh.
2019-03-11 11:39:29 +01:00
Pádraig Brady
ab8c604765 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-03-10 17:08:36 -07:00
Pádraig Brady
cf28242fd5 version 8.31
* NEWS: Record release date.
2019-03-10 16:34:41 -07:00
Pádraig Brady
5f47cda3ab tests: test-N: include subsecond values in gating check
* tests/misc/test-N.sh: The subsecond values for atime and mtime
were potentially seen to differ on newlyl created files.
So we include the subsecond portion when comparing stat values.
2019-03-10 15:05:26 -07:00
Pádraig Brady
a971cd4ff7 tests: wc-nbsp: fix false failures on various systems
* tests/misc/wc-nbsp.sh: Add gating checks for all characters,
as there are disparate classifications on various systems:
SunOS 5.10 treats \u202F, \u2060 as !iswprint()
SunOS 5.10 treats \u00A0, \u2007 as iswspace()
AIX 7.2, Darwin 17.4.0, NetBSD 7.1 treat \u2060 as !iswprint()
2019-03-09 20:59:21 -08:00
Pádraig Brady
66e2daa689 tests: tail-2/pipe-f: avoid false failure closing stdout
* tests/tail-2/pipe-f.sh: Check closing stdout with >&-
is effective, which avoids a false failure on NetBSD 7.1
Reported by Assaf Gordon
2019-03-06 22:26:30 -08:00
Pádraig Brady
a376de95c3 tests: tac-2-nonseekable: ensure we don't block indefinitely
* tests/misc/tac-2-nonseekable.sh: Add a timeout to both
protect and check whether we can close stdin correctly.
2019-03-06 22:00:53 -08:00
Pádraig Brady
daa46dbe7d tests: id/zero: avoid false failure due to sed differences
* tests/id/zero.sh: sed on OSX will output a \n even
if the input doesn't have a \n on the last "line".
So ensure we always have a trailing '\n' to avoid the disparity.
2019-03-06 22:00:53 -08:00
Pádraig Brady
b918a20234 tests: test-N: fix false positives on some systems
Testing by Assaf Gordon on OSX showed the atime wasn't
being updated when explicitly set back in time.
Also Debian 8.11 / mips64 was seen to not update the
mtime when truncating an empty file.

* tests/misc/test-N.sh: Isolate from different timestamping
behaviors of various (file) systems, by correlating
the timestamps with stat(1) before using `test -N`.
2019-03-06 22:00:53 -08:00
Assaf Gordon
bf2f64c7d5 doc: replace @hashchar{} with actual hash character
Very old makeinfo-4.13 fails with:
  ./doc/coreutils.texi:2286: Unknown command `hashchar'.
  ./doc/coreutils.texi:2286: Misplaced {.
  ./doc/coreutils.texi:2286: Misplaced }.

Reported Bernhard Voelker in
https://lists.gnu.org/r/coreutils/2019-03/msg00016.html .

* doc/coreutils.texi (basenc invocation): Replace @hashchar{} with
actual hash character.  The special syntax is only required
when referring to #line directives.
2019-03-06 21:59:27 -08:00
Pádraig Brady
4bb49f04a1 build: avoid statx related build failure on AIX
* src/stat.c (get_birthtime): Check also for STATX_BTIME define,
as a different statx is available on AIX 7.2.
2019-03-06 10:53:00 -08:00
Pádraig Brady
16358bc19c tests: wc-nbsp.sh: avoid failure on FreeBSD
* tests/misc/wc-nbsp.sh: FreeBSD and OS X don't
treat non breaking space as printable characters.
So use wc -L to determine printability before
testing non breaking space functionality.
2019-03-06 10:52:17 -08:00
Pádraig Brady
4bbbe49074 build: fix env build where SIGNUM_BOUND is not constant
* src/env.c (initialize_signals): A new function to initialize
the signals array on the heap, to avoid a build failure on
opensolaris, where SIGNUM_BOUND is not a constant.
2019-03-06 09:00:44 -08:00
Pádraig Brady
efa3e5dda6 doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.22 which is now about 5 years old.
2019-03-04 01:28:42 -08:00
Pádraig Brady
7c35a36bf4 build: revert recent change with distributed man page handling
* man/local.mk: commit f114495e added an extra check to ensure
a binary was working before using it to generate the man page.
However this was not working for the false(1) command,
and also one can generally specify that one should not
be using generated commands on the current system by passing
'cross_compiling=yes' to the configure invocation.
2019-03-04 01:15:51 -08:00
Pádraig Brady
6bf6d7f461 env: add --list-signal-handling to output non default handling
* src/env.c (main): Output blocked or ignored signals
before a command is executed.
* doc/coreutils.texi (env invocation): Add the option.
* tests/misc/env-signal-handler.sh: Add a test case.
* NEWS: Mention the new feature.
2019-03-04 00:37:42 -08:00
Assaf Gordon
95adadd9a4 env: new options --{default,ignore,block}-signal[=SIG]
New options to set signal handlers for the command being executed.
--block-signal suggested by Paul Eggert in http://bugs.gnu.org/34488#71
--default-signal is useful to overcome the POSIX limitation that shell
must not override inherited signal state, e.g. the second 'trap' here is
a no-op:

   trap '' PIPE && sh -c 'trap - PIPE ; seq inf | head -n1'

Instead use:

   trap '' PIPE && sh -c 'env --default-signal=PIPE seq inf | head -n1'

Similarly, the following will prevent CTRL-C from terminating the
program:

   env --ignore-signal=INT seq inf > /dev/null

See https://bugs.gnu.org/34488#8

* NEWS: Mention new options.
* doc/coreutils.texi (env invocation): Document new options.
* man/env.x: Add example of --default-signal=SIG usage.
(SEE ALSO): Mention sigprocmask.
* src/env.c (signals): New global variable.
(longopts): Add new options.
(usage): Print new options.
(parse_signal_params): Parse comma-separated list of signals, store in
signals variable.
(reset_signal_handlers): Set each signal to SIG_DFL/SIG_IGN.
(parse_block_signal_params): Parse command-line options.
(set_signal_proc_mask): Call sigprocmask to block/unblock signals.
(main): Process new options.
* src/local.mk (src_env_SOURCES): Add operand2sig.c.
* tests/misc/env-signal-handler.sh: New test.
* tests/local.mk (all_tests): Add new test.
2019-03-04 00:37:07 -08:00
Martin Bukatovic
186896d65f stat: print birth time on systems supporting statx
* configure.ac: Check for statx(), available on glibc >= 2.28.
* src/stat.c (get_birthtime): Call statx() when available.
* NEWS: Mention the improvement.
2019-03-03 23:33:51 -08:00
Pádraig Brady
811493e2a9 df: support different file system encodings when not using tty
* src/df.c (replace_problematic_chars): A new wrapper to be
more conservative in our replacement when not connected to a tty.
* tests/df/problematic-chars.sh: Add a test case.
2019-03-03 22:31:08 -08:00
Pádraig Brady
0d6be4b01f maint: tidy up recent additions to NEWS
* NEWS: Move date change to improvements and fix nohup grammar.
2019-03-03 19:21:37 -08:00
Bernhard Voelker
4ae1369516 doc: further clarify 'yes' alternative in seq invocation
* doc/coreutils.texi (node seq invocation): Clarify to use the tool
'yes'; otherwise the reader may interpret the sentence as if one
could pass 'yes' as the INCREMENT value.
2019-02-27 18:51:30 +01:00
Pádraig Brady
a5202bd585 wc: treat non breaking space as a word separator
* src/wc.c (iswnbspace): A new function to match
characters in this class.
(isnbspace): Likewise for single byte charsets.
(main): Initialize posixly_correct from the environment,
to allow disabling honoring NBSP in non C locales.
(wc): Call is[w]nbspace() along with is[w]space.
* bootstrap.conf: Ensure btowc is available.
* tests/misc/wc-nbsp.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the change in behavior.
2019-02-25 22:49:44 -08:00
Paul Eggert
2ab2f7a422 doc: more date +%F clarifications
* doc/coreutils.texi (Date conversion specifiers):
Plain %F is actually like %+4Y-%m-%d.
(Padding and other flags): Mention POSIX restrictions.
* src/date.c (usage): Document recent changes.
2019-02-25 10:21:07 -08:00
Paul Eggert
d5c820109e doc: give date +%+F example
* doc/coreutils.texi (Padding and other flags):
Give example for + conversion specification.
2019-02-25 08:03:38 -08:00
Paul Eggert
3e7fd6650e doc: fix typo in previous patch 2019-02-25 00:25:25 -08:00
Paul Eggert
b1e7af28eb date: ‘+’ conversion specification flag
The recent Gnulib update fixed Bug#34608; document and test this.
* NEWS: Mention the change.
* doc/coreutils.texi (Padding and other flags):
Update doc to cover new flag and other POSIX.1-2017 changes.
* tests/misc/date.pl (date-century-plus): New test.
2019-02-24 23:59:55 -08:00
Paul Eggert
c50c4ab9e1 build: update gnulib submodule to latest 2019-02-24 23:59:55 -08:00
Bernhard Voelker
44af84263e all: detect --help and --version more consistently
For select programs which accept only --help and --version options
(in addition to non-option arguments), process these options before
any other options.

Before:

  $ dd bs=1 --help
  dd: unrecognized option '--help'
  Try 'dd --help' for more information.

  $ yes me --help
  me --help
  me --help
  ...

After:
Any occurrence of '--help' in the arguments (prior to '--') will
show the help screen.

Discussed in https://bugs.gnu.org/33468 .

* NEWS: Mention change.
* src/cksum.c, src/dd.c, src/hostid.c, src/hostname.c, src/link.c,
src/logname.c, src/nohup.c, src/sleep.c, src/tsort.c, src/unlink.c,
src/uptime.c, src/users.c, src/whoami.c, src/yes.c (main): Replace
parse_long_options() + getopt_long() calls with
parse_gnu_standard_options_only(); Remove <getopt.h> inclusion;
Remove empty 'struct long_options' variable;
* tests/misc/help-version-getopt.sh: Add test.
* tests/local.mk (all_tests): Reference it.
2019-02-24 19:32:29 +01:00
Pádraig Brady
36b99b6113 gnulib: update to the latest
update to a version with parse_gnu_standard_options_only()
2019-02-23 18:55:53 -08:00
Martin Castillo
f473489f48 doc: fix join examples in texinfo
* doc/coreutils.texi (join invocation): Fix various errors.
Fixes https://bugs.gnu.org/34583
Fixes https://bugs.gnu.org/34584
2019-02-19 23:29:04 -08:00
Daming Yang
b1ac478653 ls: better align month abbreviations containing digits
* src/ls.c (abmon_init): Align numeric abbreviations right.
* NEWS: Mention the improvement.
2019-02-18 20:06:05 -08:00
Pádraig Brady
5e1a554712 sort: clarify in --debug; only text comparisons affected
* src/sort.c (main): Adjust the debug info regarding locales,
to clarify that only textual comparisons are affected.
* tests/misc/sort-debug-warn.sh: Adjust accordingly.
Fixes https://bugs.gnu.org/34490
2019-02-17 19:17:17 -08:00
Pádraig Brady
636cbdb77b comm,join: ensure warnings are apparent upon exit
* src/comm.c (main): Output a warning right before exit,
in case previous errors have scrolled from view.
* src/join.c (main): Likewise.
* tests/misc/comm.pl: Addjust accordingly.
* tests/misc/join.pl: Likewise.
Fixes https://bugs.gnu.org/34347
2019-02-11 22:56:21 -08:00
Filipp Gunbin
620112526b doc: fix typo referencing RFC 2822
* doc/coreutils.texi (date invocation): s/822/2822/.
Fixes https://bugs.gnu.org/34438
2019-02-11 22:56:08 -08:00
Pádraig Brady
2193e0b9fb gnulib: update to use new strtold module
* gnulib: Update to make the new strtold module available.
* bootstrap.conf: strtod is now a dependency of c-strtod,
which in turn is a dependency of cl-strtod.  This treats
strtold and strtod similarly.
* gl/lib/cl-strtod.c: Adjust to assume strtold is available.
* tests/misc/sort-float.sh: Likewise.
* src/sort.c: Likewise.
(nan_compare): Adjust comment to indicate
we still have to init padding bits as per
https://sourceware.org/bugzilla/show_bug.cgi?id=13246
2019-02-10 20:32:59 -08:00
Pádraig Brady
03fbb5ecec seq: output decimal points consistently with invalid locales
* src/seq.c (print_numbers): Only reset the locale if it
was successfully set originally.
* tests/misc/seq-locale.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the fix.
2019-02-03 17:18:08 -08:00
Pádraig Brady
027eeec7b0 build: ensure sys/select.h is included
bootstrap.conf: Explicitly depend on select, rather than transitively.
* src/tail.c: Unconditionally include select.h as we use select()
outside inotify contexts now.
2019-02-03 17:18:08 -08:00
Pádraig Brady
2e8f885a2a stat,tail: fix android build and support inotify
* src/extract-magic: Treat android like linux,
which fixes the build by ensuring the constants are defined.
* src/stat.c: Support all constants on android, including
the android specific "sdcardfs".
* src/tail.c: Fix inclusion of statfs headers to be independent
of inotify availability, as fremote() is used on linux even
if inotify has been disabled.  Also enable fremote() on android.
* NEWS: Mention the improvment.
Fixes https://bugs.gnu.org/34239
2019-02-03 17:18:08 -08:00
Pádraig Brady
90933c8eb0 tests: add test for locale decimal processing
* tests/misc/sleep.sh: Check locale processing of printf, sleep,
and timeout, when the french locale data is available.
2019-01-30 17:49:05 -08:00
Pádraig Brady
001897e7e2 build: fix recent build failure on systems without strtold
Recently introduced in commit v8.30-50-geb73e23

* gl/lib/cl-strtod.c: Fall back to strtod() on systems
without strtold() (like we already do in sort).
2019-01-30 17:49:05 -08:00
Pádraig Brady
ca80339454 maint: fix new syntax-check failure from recent change
* cfg.mk: Exclude cl-strtold.c wrapper from requiring config.h
2019-01-27 20:42:09 -08:00
Paul Eggert
8adc7ccf7c printf,seq: remove c-strtod dependency
* gl/modules/cl-strtold (Files): Add lib/cl-strtod.c, lib/cl-strtod.h.
(Depends-on): Remove cl-strtod.
(configure.ac): Redquire AC_C_RESTRICT.
2019-01-26 23:19:47 -08:00
Paul Eggert
eb73e23f31 printf,seq: improve long double accuracy
This fixes a thinko in the previous patch.
* gl/lib/cl-strtod.c (STRTOD): New macro.
(CL_STRTOD): Use it.
2019-01-26 23:19:47 -08:00
Paul Eggert
3fe8bc09be printf,seq,sleep,tail,timeout: accept current-locale floats
These commands now accept floating-point numbers in the
current locale, as well as in the C locale.
Compatibility problem reported by Robert Elz.
* NEWS: Document this.
* bootstrap.conf (gnulib_modules): Add cl-strtod, cl-strtold.
Remove c-strtold.
* doc/coreutils.texi (Floating point, tail invocation)
(printf invocation, timeout invocation, sleep invocation)
(seq invocation): Document this.
* gl/lib/cl-strtod.c, gl/lib/cl-strtod.h, gl/lib/cl-strtold.c:
* gl/modules/cl-strtod, gl/modules/cl-strtold: New files.
* src/printf.c, src/seq.c, src/sleep.c, src/tail.c, src/timeout.c:
Include cl-strtod.h instead of c-strtod.
* src/printf.c (vstrtold):
* src/seq.c (scan_arg, print_numbers):
* src/sleep.c (main):
* src/tail.c (parse_options):
* src/timeout.c (parse_duration):
Use cl_strtold instead of c_strtold.
2019-01-26 22:41:09 -08:00
Paul Eggert
3cd48057c7 doc: update Goldberg URL
* doc/coreutils.texi (Floating point): Update URL.
2019-01-25 11:32:46 -08:00
Paul Eggert
643a7325ec sleep: improve doc
Problem reported by Robert Elz.
* doc/coreutils.texi (sleep invocation):
Say that arguments must be non-negative, which means they cannot
be arbitrary floating-point numbers.  Mention POSIX, not
“historical implementations” that are no longer of practical
interest.  List the extensions to POSIX.
* src/sleep.c (usage): Omit needless words, removing dubious
commentary about “most implementations” and incorrect commentary
about “arbitrary”.  Details about exactly which numbers are
allowed can be found in the documentation.
2019-01-25 11:17:18 -08:00
Pádraig Brady
fa50623394 tail: fix handling of broken pipes with SIGPIPE ignored
* init.cfg (trap_sigpipe_or_skip_): A new function refactored from...
* tests/misc/printf-surprise.sh: ...here.
* tests/misc/seq-epipe.sh. Likewise.
* src/tail.c (die_pipe): Ensure we exit upon sending SIGPIPE.
* tests/tail-2/pipe-f.sh: Ensure we exit even if SIGPIPE is ignored.
* NEWS: Mention the bug fix.
2019-01-20 12:53:24 -08:00
Ayappan
17983b2cb3 tail: fix recent ineffective AIX change
* src/tail.c: Fix commit v8.30-40-gd5ab4cb which was ineffective.
Fixes http://bugs.gnu.org/33946
2019-01-20 00:45:32 -08:00
Pádraig Brady
d26dece5d8 build: ensure VLAs are not used
Fail developer builds if VLAs are used,
as there are portability concerns to consider with them.

* configure.ac: Enable -Wvla which is implicit in the full list added.
* m4/jm-macros.m4: Define GNULIB_NO_VLA which disables use of
VLAs within gnulib code.
2019-01-19 21:15:01 -08:00
Pádraig Brady
94fa0aa0d0 gnulib: update to the latest
* gnulib: Update to a version supporting GNULIB_NO_VLA
* bootstrap: Sync with latest
2019-01-19 21:07:04 -08:00
Bernhard Voelker
f114495e3e build: use distributed man pages when running with --help fails
When building against an incompatible GLIBC version compared to that
on the build host, then running the just-built binary might fail
although it is the same platform - thus CROSS_COMPILING is false.
As a result, generating the man pages fails.

* man/local.mk (.x.1): Add a check to verify that running the utility
with --help succeeds, otherwise falling back to using 'dummy-man'.
2019-01-16 08:26:01 +01:00
Pádraig Brady
39ca7731e2 ls: with --group-directories-first, also group symlinked dirs
* src/ls.c (is_linked_directory): A new function to
also consider symlinked directories.
(main): Rename check_symlink_color to check_symlink_mode,
and enable that with --group-directories-first.
(DIRFIRST_CHECK): Adjust to use is_linked_directory,
rather than just is_directory.
(gobble_file): Simplify to always update f->linkmode
if the stat() succeeds.
* tests/ls/group-dirs.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the change in behavior.
Suggested by Amin Bandali in
https://lists.gnu.org/r/coreutils/2018-12/msg00017.html
2019-01-12 19:23:45 -08:00
Pádraig Brady
d5ab4cbe42 tail: don't exit immediately with filters on AIX
* src/tail.c: Fix the check_output_available check on AIX.
Note we don't use poll for all systems as the overhead
of adding the gnulib poll module wouldn't be worth it
just for this single use.
* tests/tail-2/pipe-f.sh: Fix the test which always passed
due to only the exit code of sleep being checked.
* NEWS: Mention the bug fix and rearrange alphabetically.
Fixes http://bugs.gnu.org/33946
2019-01-12 19:23:41 -08:00
Assaf Gordon
d045ce5166 basenc: allocate buffers on heap
Allocate the encoding/decoding buffers dynamically on the heap instead
of using variable-length-array (VLA) on the stack.
Discussed in https://lists.gnu.org/r/coreutils/2019-01/msg00004.html .

* src/basenc.c (do_encode,do_decode): Allocate inbuf/outbuf using
xmalloc, and free if using LINT.
2019-01-05 17:14:07 -07:00
Pádraig Brady
daaae12e3b doc: adjust URLs in help to avoid wrapping
* src/system.h: Adjust lines containing URLs so that
they don't wrap on 80 column terminals.  One could also
use .UR macros, but these aren't universally available.
Note the adjustments here need to be compatible with
the pattern matching done in help2man.
Addresses https://bugs.gnu.org/33914
2019-01-04 08:15:56 -08:00
Assaf Gordon
8dfcf38af1 maint: update all copyright year number ranges
Run "make update-copyright" and then...

* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
2019-01-01 16:51:48 -07:00
Bernhard Voelker
1f9152a50f maint: mention base32 in the title line of common basenc.c
* src/basenc.c: Do the above, and remove a redundant comment.
2019-01-01 16:32:27 -07:00
Assaf Gordon
67c537b91c base64,base32: fix 'extra operand' error message
In the following invocation, 'a' is the input file, and 'b' is the extra
operand:

  $ base64 a b

Report 'b' in the error message instead of 'a':

  $ base64 a b
  base64: extra operand 'b'

Discussed in https://lists.gnu.org/r/coreutils/2018-12/msg00008.html .

* src/basenc.c (main): If there is more than one non-option operand,
report the second one (assuming the first is a the input file name).
* tests/misc/base64.pl: Add tests.
* tests/misc/basenc.pl: Adjust expectedc error message in tests.
* NEWS: Mention bugfix.
2019-01-01 16:32:27 -07:00
Pádraig Brady
d1de5857c7 doc: mention that more than 8 colors are supported by ls
* src/dircolors.hin: Mention any codes supported by the terminal
are allowed.
Addresses https://bugs.gnu.org/33915
2018-12-31 05:17:23 -08:00
Assaf Gordon
2f438fa9f5 basenc: A new program complementary to base64/base32
Encodes/decodes data in various common formats:
base64,base64url,base32,base32,base16,base2,z85.

Discussed here:
https://lists.gnu.org/r/coreutils/2018-11/msg00014.html
https://lists.gnu.org/r/coreutils/2018-12/msg00019.html

* AUTHORS: Add basenc.
* README: Reference the new program.
* NEWS: Mention the new program.
* build-aux/gen-lists-of-programs.sh: Add basenc.
* doc/coreutils.texi: (basenc invocation): Document the new command.
* man/.gitignore: Ignore the generated man page.
* man/basenc.x: A new template, with few examples.
* man/local.mk: Reference the new man page.
* scripts/git-hooks/commit-msg: Allow basenc as program prefix.
* src/.gitignore: Ignore the new binary.
* src/basenc.c:
(usage): Mention new options.
(main): Handle new options.
(isbase*, base*_length, base*_encode, base*_decode_ctx): Implement new
encoding/decoding formats.
* src/local.mk: Add new program.
* tests/local.mk: Add new test.
* tests/misc/basenc.pl: New tests.
* tests/misc/help-version.sh (basenc_setup): use '--version' for default
invocation (basenc errors with no parameters).
2018-12-27 23:46:02 -07:00
Assaf Gordon
21c59d6845 maint: rename base64.c to basenc.c
In preparation for adding 'basenc' program.
Suggested in https://lists.gnu.org/r/coreutils/2018-11/msg00019.html .

* src/base64.c: Rename to src/basenc.c.
* src/local.mk: Update base*_SOURCES definitions.
* po/POTFILEs.in: Rename base64 to basenc.
2018-12-21 15:26:11 -07:00
Paul Eggert
69df9e20e2 shred,sort,split: add NEWS item 2018-12-15 12:42:50 -08:00
Paul Eggert
a6756257ef shred,sort,split: fix ftruncate error reporting
Problem reported for split by Scott Worley (Bug#33761):
* src/shred.c (do_wipefd):
Also report an error if ftruncate fails	on a shared memory object.
* src/sort.c (get_outstatus): New function.
(stream_open, avoid_trashing_input): Use it.
* src/sort.c (stream_open):
* src/split.c (create):
If ftruncate fails, do not report an error
unless it is a regular file or a shared memory object.
2018-12-15 12:14:49 -08:00
Bernhard Voelker
4711c49312 sync: add NEWS and test for the fix in the previous commit
* NEWS (Bug fixes): Mention the fix in commit 94d364f157.
While at it, remove duplicate "Changes in behavior" heading.
* tests/misc/sync.sh: Add a test with a write-only file for the fix.
2018-11-06 17:02:26 -08:00
Paul Eggert
94d364f157 sync: fix open fallback bug
Problem caught by Coverity Analysis
and reported by Kamil Dudka (Bug#33287).
* src/sync.c (sync_arg): Fix typo in fallback code.
2018-11-06 10:35:31 -08:00
Paul Eggert
806b0d1580 ln: use linkat and symlinkat
Open a target directory and use its file descriptor in linkat,
symlinkat, etc. syscalls, instead of constructing long file names
by concatenating the target directory name to a basename.
This avoids O(N²) behavior with ‘ln F1 F2 ... Fn DIR’ when DIR is
a long file name with many slashes.  It also avoids some races if
DIR is renamed while ln is running.
* bootstrap.conf (gnulib_modules): Add openat-safer.
* src/ln.c: Include fcntl-safer.h.
(O_PATHSEARCH): New constant.
(errno_nonexisting, target_directory_operand): Remove; no longer used.
(atomic_link, do_link): New arg DESTDIR_FD.  All uses changed.
(do_link): New arg DEST_BASE.  All uses changed.
(main): Open target directory and use its file descriptor
as DESTDIR_FD.
2018-10-28 01:46:11 -07:00
Paul Eggert
d9a4d98371 build: update gnulib submodule to latest
* src/copy.c (copy_internal):
* src/cp.c (do_copy):
* src/ln.c (do_link):
Adjust to Gnulib API change.
2018-10-28 01:46:11 -07:00
Bernhard Voelker
bdd54b4ee0 tests: provide 100% coverage for echo
*  src/echo.c (usage): Assert that STATUS is always EXIT_SUCCESS.
* tests/misc/echo.sh: Add further tests for all hex and escape and
escape characters.

To get coverage statistics, run:
  make coverage -j 4 TESTS=tests/misc/echo.sh SUBDIRS=.
  xdg-open doc/coverage/src/echo.c.gcov.frameset.html
2018-10-27 05:02:54 -07:00
Pádraig Brady
8d328706c6 echo: always process escapes when POSIXLY_CORRECT is set
* src/echo.c (main): Always enable backslash processing if
POSIXLY_CORRECT is set.
* tests/misc/echo.sh: Add (the first) test for the echo command.
* tests/local.mk: Reference the new test.
* tests/misc/printf.sh: Update a stale comment.
* doc/coreutils.texi (echo invocation). Mention that POSIXLY_CORRECT
now always enables backslash processing.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/32703
Issue identified by Eric Blake.
2018-10-27 03:05:24 -07:00
Bernhard Voelker
1a674a036b test: add -N unary operator
Bash knows 'test -N FILE'.  Add it to GNU 'test' as well.

* src/test.c (unary_operator): Add a case for 'N'.
(usage): Document it.
* doc/coreutils.texi (node File characteristic tests): Likewise.
* NEWS (New features): Likewise.
* tests/misc/test-N.sh: Add a test.
* tests/local.mk (all_tests): Reference it.
2018-10-26 11:05:25 +02:00
Bernhard Voelker
7fd7709a7a test: simplify redundant code
Remove the function 'test_unop', as the cases therein are redundant to
those handled by 'unary_operator'; exception: the cases 'o' and 'N':
they had been present in test_unop and handling the commands
  test -N STR
  test -o STR
and
  test x = x -a -N STR
  test x = x -a -o STR
which ran into an error later on anyway.
With this commit, the error diagnostic will change from ...
  $ /usr/bin/test -N STR
  /usr/bin/test: extra argument '-N'
  $ /usr/bin/test -o STR
  /usr/bin/test: extra argument '-o'
... to ...
  $ src/test -N STR
  src/test: '-N': unary operator expected
  $ src/test -o STR
  src/test: '-o': unary operator expected

* src/test.c (test_unop): Remove.
(unary_operator): Fail with test_syntax_error in the default case.
(term): Directly call unary_operator.
(two_arguments): Likewise.
* tests/misc/test-diag.pl: Adjust error diagnostic.
2018-10-26 10:54:11 +02:00
Bernhard Voelker
88c32fa68e test: remove support for the ambigous -a unary operator
* src/test.c (unary_operator): Remove case 'a'.
(test_unop): Likewise.
* NEWS (Changes in behavior): Document the change.

Discussed at https://bugs.gnu.org/33097
2018-10-26 10:53:57 +02:00
Bernhard Voelker
6bc89f5f85 test: avoid FP in chroot-credentials.sh for different group list order
On my openSUSE:Tumbleweed system, I get a false positive test failure
in the above 'check-root' test because the group lists inside and
outside the chroot have a different order:

  ++ chroot --userspec=berny / id -G
  ++ id -G berny
  + test '100 454 457 480 492' = '100 480 492 457 454'
  + fail=1

* tests/misc/chroot-credentials.sh (num_sort): Add function to sort
group lists, and use it in the test cases which test multiple groups.
2018-10-21 14:55:51 +02:00
Paul Eggert
8ea92f2a1d doc: tidy up setuid commentary
* doc/perm.texi (Mode Structure): Improve wording.
(Numeric Modes): Don’t say “on execution” (Bug#9594).
2018-10-20 10:59:17 -07:00
Paul Eggert
571f63f501 ln: avoid directory hard-link races
Previously, 'ln A B' did 'stat("B"), lstat("A"), link("A","B")'
where the stat and lstat were necessary to avoid hard-linking
directories on systems that can hard-link directories.
Now, in situations that prohibit hard links to directories,
'ln A B' merely does 'link("A","B")'.  The new behavior
avoids some races and should be more efficient.
This patch was inspired by Bug#10020, which was about 'ln'.
* bootstrap.conf (gnulib_modules): Add unlinkdir.
* src/force-link.c (force_linkat, force_symlinkat): New arg for
error number of previous try.  Return error number, 0, or -1 if
error, success, or success after removal.  All callers changed.
* src/ln.c: Include priv-set.h, unlinkdir.h.
(beware_hard_dir_link): New static var.
(errnoize, atomic_link): New functions.
(target_directory_operand): Use errnoize for simplicity.
(do_link): New arg for error number of previous try.  All callers
changed.  Do each link atomically if possible.
(main): Do -r check earlier.  Remove linkdir privileges so we can
use a single linkat/symlinkat instead of a racy substitute for the
common case of 'ln A B' and 'ln -s A B'.  Set beware_hard_dir_link
to disable this optimization.
2018-10-19 12:38:34 -07:00
Paul Eggert
cbc427485e cp: 'cp -il A B' no longer fails if user OKs it
* NEWS: Mention the change.
* src/copy.c (copy_internal): Replace the link if the
user has okayed it.
2018-10-19 12:38:34 -07:00
Paul Eggert
9c3730e601 build: update gnulib submodule to latest
* gl/modules/tempname.diff: Update to match Gnulib.
2018-10-19 12:38:33 -07:00
Paul Eggert
4d5db7193c doc: add chmod examples
Discussed in https://bugs.gnu.org/11043 .

* doc/coreutils.texi (chmod invocation): Add examples.
2018-10-17 14:31:04 -06:00
Bjarni Ingi Gislason
dedb3973e3 doc: fix minor mistakes in "env.x"
* man/env.x (OPTIONS): Fix a spelling mistake.  Protect a period at the
beginning of a line.
2018-10-02 01:09:44 +02:00
Achilles Gaikwad
a32a756a58 id: support multiple specified users
$ id root nobody
  uid=0(root) gid=0(root) groups=0(root)
  uid=99(nobody) gid=99(nobody) groups=99(nobody)

* src/id.c (main): Make variables opt_zero, just_group_list,
just_group, use_real, just_user global to be used in a new
function.
(print_stuff): New function that will print user and group
information for the specified USER.
When using -G option delimit each record with two NULs.
Restructure the code in the file to have global variables
followed by functions.
* tests/id/zero.sh: Add test cases to check the usage
of -z option with multiple users.
* tests/id/uid.sh: Add a test case to ensure all users
are queried in the presence of errors.
* doc/coreutils.texi: Document the interface changes.
* NEWS: Mention the new feature.
2018-09-29 22:39:26 -07:00
Stéphane Campinas
7262994810 doc: csplit: clarify handling of regexps with negative offsets
* doc/coreutils.texi (csplit invocation): Detail the behavior
with regexp patterns and negative offsets, which differs from
line number patterns, to avoid looping on the input.  For example:
  $ seq 50 | csplit -s - /15/-5 /12/
  csplit: ‘/12/’: match not found
2018-09-24 23:48:56 -07:00
Pádraig Brady
f7b2502100 doc: csplit: clarify input may not be reproducible from output
* doc/coreutils.texi (csplit invocation): Clarify that
portions of the input may be skipped and thus the input
may not be reproducible by just concatenating the output files.
Fixes https://bugs.gnu.org/32317
2018-09-23 21:17:04 -07:00
Paul Eggert
e5dae2c6b0 df: omit redundant comparison
Trivial inefficiency reported by Bruno Haible in:
http://lists.gnu.org/r/bug-gnulib/2018-07/msg00109.html
* src/df.c (hide_problematic_chars): Omit redundant test.
2018-07-27 12:03:52 -07:00
Paul Eggert
25c74a37ca df: tune slightly
* src/df.c (get_header, get_dev):
Avoid calling mbswidth twice when once will do.
2018-07-26 18:19:45 -07:00
Paul Eggert
1ecf7abe4a df: avoid multibyte character corruption on macOS
This improves on the earlier fix for the problem reported by
Chih-Hsuan Yen (Bug#32236), by also looking for other control
characters and for encoding errors.
* src/df.c: Include wchar.h and wctype.h instead of c-ctype.h.
(hide_problematic_chars): Process the string as multibyte.
Use iswcntrl, not c_iscntrl.
2018-07-26 18:19:45 -07:00
Chih-Hsuan Yen
437555061c df: avoid multibyte character corruption on macOS
* src/df.c (hide_problematic_chars): Use c_iscntrl() as
passing 8 bit characters to iscntrl() is not supported on macOS.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/32236
2018-07-26 10:24:41 -07:00
Wodry
46d6bd0c0a doc: improve documentation of binary prefixes
* doc/coreutils.texi (Common options):
* src/dd.c, src/head.c, src/od.c, src/stdbuf.c, src/tail.c (usage):
* src/system.h (emit_size_note):
Mention binary prefixes (Bug#32242).
Copyright-paperwork-exempt: Yes
2018-07-22 08:37:15 -07:00
Pádraig Brady
49b682bdd8 tests: avoid false failure on sparc 32 bit
* tests/rm/rm-readdir-fail.sh: Skip the test entirely on 32 bit,
so we avoid conflating the 32bit and 64 bit types, as that
triggers alignment issues (SIGBUS) on Gentoo sparc.
Fixes https://bugs.gnu.org/29886
2018-07-21 12:36:46 -07:00
Paul Eggert
4397410532 build: update gnulib submodule to latest
* bootstrap.conf, src/copy.c, src/mv.c, src/shred.c:
Adjust to renaming of renameat2 to renameatu.
2018-07-05 09:52:14 -07:00
Pádraig Brady
351ac1256b tests: fix skipping in some tests
* tests/cp/cp-a-selinux.sh: Use 'skip_' rather than the probably
undefined 'skip'.
* tests/du/2g.sh: Likewise.
* tests/install/install-Z-selinux.sh: Likewise.
* tests/misc/chcon.sh: Likewise.
* tests/misc/selinux.sh: Likewise.
* tests/mkdir/restorecon.sh: Likewise.
* cfg.mk (sc_prohibit-skip): A new syntax check to catch the issue.
2018-07-04 17:48:41 -07:00
Jim Meyering
19ceb7b89e maint: init.cfg: fix a minor test-related quoting bug
* init.cfg (require_membership_in_two_groups_): This fixes a bug
introduced by me in v8.15-8-gdd0e4c562.  Luckily, the consequence
of low-probability triggering the bug was the mere added backslash
in the diagnostic: "...but running id -G\ either...".  It would be
triggered in a test failure for one who is a member of only one or
fewer groups.
2018-07-01 20:09:17 -07:00
Pádraig Brady
83322567de maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2018-07-01 18:28:37 -07:00
Pádraig Brady
53793cd35f version 8.30
* NEWS: Record release date.
2018-07-01 17:56:07 -07:00
Pádraig Brady
89f7fcd055 tests: standardize perl usage in tests
* tests/cp/fiemap-FMR.sh: Ensure perl is parameterized to $PERL,
and ensure require_perl_ is used, so tests are skipped appropriately.
* tests/cp/preserve-gid.sh: Likewise.
* tests/du/long-from-unreadable.sh: Likewise.
* tests/misc/env-S-script.sh: Likewise.
* tests/misc/sort-benchmark-random.sh: Likewise.
* tests/rm/deep-2.sh: Likewise.
2018-06-30 18:57:43 -07:00
Pádraig Brady
3246bc08a6 maint: copy: avoid new static analyzer warnings
* src/copy.c (copy_internal): Use the lint protected src_mode,
rather than accessing the src_sb again.  Also unconditionally
populate src_sb when !x->move_mode and in lint mode.
Reported by Kamil Dudka with coverity and clang analyzer.
2018-06-30 18:57:43 -07:00
Pádraig Brady
68cf7ad5ad maint: fix recent stale comments and spelling mistakes
* doc/coreutils.texi: s/seperator/separator/.
* tests/misc/env-S.pl: Likewise.
* src/env.c: Fix stale comment.
2018-06-30 18:56:39 -07:00
Pádraig Brady
1755ffb7b6 maint: disable overly agressive sc_gitignore_redundant
* cfg.mk (sc_gitignore_redundant): Disabled for now as too
aggressive flagging entries like /lib/arg-nonnull.h in
a newly checked out repo.
2018-06-27 02:38:59 -07:00
Pádraig Brady
a68efd1283 env: adjust diagnostics provided for shebang usage
* src/env.c (main): Don't process '-' specially since
that causes an issue on the openbsd getopt implementation
where a lone '-' is now processed as an option, and anyway
it doesn't particuarly help diagnosing common shebang
usage issues.  Also don't restrict the extra diagnostics
for shebang usage to the case with 3 arguments, as
further arguments can be passed to a script.
* tests/misc/env-S.pl: Adjust accordingly.
2018-06-27 02:38:59 -07:00
Assaf Gordon
4b7595d751 tests: accept getopt errors without single-quotes
On OpenBSD 6.2, invalid single options produce error messages
without single quotes:

    $ ./src/chroot -/
    chroot: unknown option -- /

As opposed to other systems:

    ./src/chroot: invalid option -- '/'

Modify the grep search to accept this.

* tests/misc/usage_vs_getopt.sh (checkprg): Change the grep pattern
to accomodate no-single-quotes cases.
2018-06-27 02:38:59 -07:00
Pádraig Brady
d542945c3a tests: fix false failures when perl not available
* tests/local.mk: Reference the stub that skips perl tests,
with the correct path.
2018-06-27 02:38:59 -07:00
Pádraig Brady
6d6095f33a tests: fix false failure with limited shebang lines
* tests/misc/env-S-script.sh: Provide a wrapper to
emulate shebang processing, but without length limits,
which are 127 on Linux for example.
2018-06-27 02:38:58 -07:00
Pádraig Brady
91d78a570f maint: update gnulib to latest
* gnulib: Update to latest, which incorporates
a thread linking fix from Bruno Haible,
which was seen on newer Ubuntu systems.
2018-06-27 00:48:03 -07:00
Assaf Gordon
3e5dcddba7 tests: remove unused Data::Dumper perl module
The module is not needed anymore (was used during development).
Despite being a Perl core module, platforms like CentOS don't install
it by default.  Reported by Bruno Haible at
https://lists.gnu.org/r/coreutils/2018-06/msg00093.html.

* tests/misc/csplit-suppress-matched.pl: Remove Data::Dumper.
2018-06-27 00:41:08 -07:00
Carlos Santos
2ed7c28679 maint: fix -Werror=suggest-attribute=malloc in expr.c
Add attribute 'malloc' to mpz_get_str to prevent
the following on GCC 8.1.1

  src/expr.c:117:1: error: function might be candidate for attribute
    'malloc' if it is known to return normally
      [-Werror=suggest-attribute=malloc]
   mpz_get_str (char const *str, int base, mpz_t z)
   ^~~~~~~~~~~
  cc1: all warnings being treated as errors

* src/expr.c (mpz_get_str): Add _GL_ATTRIBUTE_MALLOC.
2018-06-24 21:23:05 -07:00
Pádraig Brady
932ec637a6 maint: update gnulib to latest
* gnulib: Update to latest.
* .gitignore: Add new entries.
* bootstrap.conf: Enable wchar-single, which will enable more
efficient replacements of wcwidth and mbrtowc, as we indicate
that the charset will no change between invocations of these functions.
2018-06-24 21:22:44 -07:00
Pádraig Brady
da07736952 maint: sync longlong.h from gmp repo
* src/longlong.h: Sync changes.  No functional change.
2018-06-24 17:43:17 -07:00
Pádraig Brady
07df260421 maint: avoid false positive in src/fs-magic-compare
* src/local.mk (fs_normalize_perl_subst): `make src/fs-magic-compare`
was reporting incorrectly that AFS was not being handled.
Add a mapping to our KAFS identifier.
* .gitignore: Add intermediate files from `make src/fs-magic-compare`
2018-06-24 17:43:17 -07:00
Bernhard Voelker
5fb8eb091f tests: initialize fail=0 to avoid "unary operator expected" errors
With an uninitialized variable 'fail', the unquoted use like
  test $fail = 1
lead to the shell error
  "unary operator expected".

The uninitialized 'fail' variable was a side effect of
  https://git.sv.gnu.org/cgit/gnulib.git/commit/?id=e91c0d4f9
which was pulled into coreutils-v8.26 with
  https://git.sv.gnu.org/cgit/coreutils.git/commit/?id=ef9650170
Coreutils test code relied and relies on 'fail' to be initialized,
so initialize that variable here.

* tests/local.mk (TESTS_ENVIRONMENT): Initialize fail=0.
2018-06-23 22:37:42 +02:00
Jim Meyering
cb1f253e63 maint: do not depend directly on gnulib's now-unused ftello module
* bootstrap.conf (gnulib_modules): Remove ftello, since it is
no longer used directly, since v8.9-11-geab97b307.
2018-06-21 15:51:19 -07:00
Pádraig Brady
ac7bd90cee tests: provide an option to relax the need for gdb
* tests/rm/r-root.sh: gdb provides extra protection,
but is not strictly necessary.  So provide an option
for maintainers to relax the requirements.
2018-06-20 21:18:32 -07:00
Pádraig Brady
c932e5c9ec rm: add --preserve-root=all to protect mounts
* src/remove.c (rm_fts): With the --preserve-root=all extension,
reject command line arguments that are mount points.
* src/remove.h (rm_options): Add preserve_all_root to store config.
* src/mv.c (rm_option_init): Init preserve_all_root to false.
* src/rm.c (main): Init preserve_all_root as per option.
(usage): Describe the new option.
* src/remove.c (rm_fts): Lookup the parent device id,
and reject the cli argument if a separate file system.
* tests/rm/one-file-system.sh: Add a test case.
* NEWS: Mention the new feature.
2018-06-20 21:18:32 -07:00
Adam Borowski
163df41d45 cp: add --reflink=never to force standard copy mode
This mode is currently the default, but most if not all users of
reflink-capable filesystems want --reflink=auto, which is often
encapsulated into an alias.  Adding --reflink=never allows overriding
such an alias.

* doc/coreutils.texi (cp invocation): Describe the new option.
* src/cp.c: Support --reflink=never.
* tests/cp/reflink-auto.sh: Add a test case.
* NEWS: Mention the new feature.
2018-06-20 21:17:19 -07:00
Assaf Gordon
668306ed86 env: add -S/--split-string option
Adopted from FreeBSD's env(1), useful for specifing multiple
parameters on a shebang (#!) script line, e.g:

   #!/usr/bin/env -S perl -w -T

Discussed in https://lists.gnu.org/r/coreutils/2018-04/msg00011.html

* src/env.c (valid_escape_sequence,escape_char,scan_varname,
  extract_varname,validate_split_str,build_argv,
  parse_split_string): New functions.
  (main): Process new option and call parse_split_string.
  (usage): Mention new option.
* tests/misc/env-S.pl: Test new option from the command line.
* tests/misc/env-S-script.sh: Test new option from shebang scripts.
* tests/local.mk (all_tests): Add new tests.
* man/env.x (OPTIONS): Show a brief example of -S usage and point to
the full documentation for more information.
* doc/coreutils.texi (env invocation): Detail usage of -S/--split-string
option.
* NEWS: Mention new option.
2018-06-20 21:15:31 -07:00
Assaf Gordon
a0118a71bb env: add -v/--debug option
Prints verbose information about each step:

  $ env -v -uFOO  -C /tmp BAR=BAZ date -u
  env: unset:    FOO
  env: setenv:   BAR=BAZ
  env: chdir:    '/tmp'
  env: executing: date
  env:    arg[0]= ‘date’
  env:    arg[1]= ‘-u’
  Sun Apr 22 08:52:30 UTC 2018

Inspired by FreeBSD's env(1).

* src/env.c (usage): Mention new option.
  (main): Print debug information if requested.
* NEWS: Mention new option.
* doc/coreutils.texi (env invocation): Mention -v/--debug.
2018-06-20 21:14:47 -07:00
Assaf Gordon
068b46e73b maint: refactor unsetenv call in env
Keep unset envvars (-uFOO) in an array for later deletion,
instead of reiterating over argv.  Done in preparation for
'-S string' feature. Related to '-u' discussion in
https://lists.gnu.org/r/coreutils/2018-04/msg00013.html

* src/env.c (append_unset_var,unset_envvars): New functions.
 (main): Use new functions.
2018-06-20 21:14:10 -07:00
Kaxandra Labat
24053fbd8f ls: ignore case when coloring file extensions
* src/ls.c (get_color_indicator): s/STREQ_LEN/c_strncasecmp/
* src/dircolors.hin: Remove a now redundant entry.
* tests/ls/color-ext.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the change in behavior.
2018-06-20 21:02:30 -07:00
Pádraig Brady
c744c65f50 md5sum,b2sum,sha*sum: support -z,--zero option
* doc/coreutils.texi (md5sum invocation): Describe the new option,
and how it's not supported by --check, and how it disables escaping.
* src/md5sum.c (delim): A new global to parmeterize the out delimiter.
(main): Don't enable file name escaping with -z, and output '\0'.
* tests/misc/md5sum-newline.pl: Add a test case.
* NEWS: Mention the new feature.
2018-06-20 21:01:14 -07:00
Pádraig Brady
77517a9917 wc: optimize processing of ASCII in multi byte locales
===== Benchmark setup (on GNU/Linux) ====
$ yes áááááááááááááááááááá | head -n100000 > mbc.txt
$ yes 12345678901234567890 | head -n100000 > num.txt

===== Before ====
$ time src/wc -Lm < mbc.txt
real    0m0.186s
$ time src/wc -m < mbc.txt
real    0m0.186s
$ time src/wc -Lm < num.txt
real    0m0.055s
$ time src/wc -m < num.txt
real    0m0.056s

==== After ====
$ time src/wc -Lm < mbc.txt
real    0m0.196s
$ time src/wc -m < mbc.txt
real    0m0.173s
$ time src/wc -Lm < num.txt
real    0m0.031s
$ time src/wc -m < num.txt
real    0m0.028s

* src/wc.c (wc): Only call wide variant functions like
iswprint() and wcwidth() for non is_basic() characters.
I.E. non ISO C "basic character set" characters.
This is especially significant on OSX where wcwidth()
is very expensive (about 10x in tests).
* NEWS: Mention the improvement.
Suggested by Eric Fischer.
2018-06-20 21:00:39 -07:00
Paul Eggert
21682faa5e doc: port test.1 to doclifter
* man/test.x: Use \& instead of quoting (Bug#31803).
2018-06-14 12:07:38 -07:00
Paul Eggert
de73c801f3 doc: port man pages to doclifter
Problem reported by Eric S. Raymond (Bug#31803).
* man/test.x: Add SYNOPSIS section, since help2man
understandably gets confused by the square brackets.
* src/ln.c (usage): Omit parenthetical "(Nth form)" in usage,
as it confuses doclifter.
2018-06-13 16:01:14 -07:00
Pádraig Brady
5e7b8928b7 cp: preserve existing permissions with --no-preserve=mode
This issue was introduced in commit v8.19-145-g24ebca6

* src/copy.c (copy_internal): With --no-preserve=mode,
only reset permissions for newly created files.
(copy_reg): Likewise.
* NEWS: Mention the fix.
* tests/cp/preserve-mode.sh: Add a test case.
Fixes https://bugs.gnu.org/31675
2018-06-03 16:27:37 -07:00
Pádraig Brady
c8eb21c9c0 tests: fix periodic false failure in month alignment
* tests/ls/abmon-align.sh: Base relative month adjustment
from the middle of the month, to avoid failures due
to months being repeated.
Fixes https://bugs.gnu.org/31644
2018-05-29 10:14:07 -07:00
Bjarni Ingi Gislason
fb1ca34140 doc: formatting fixes in "du.x" and "rm.x"
Avoid warnings from: groff -b -e -mandoc -T utf8 -rF0 -t -w w -z

* man/du.x: Change ".BR" to ".B" if there is only one argument.
Protect an end-of-sentence indicator (.?!) with '\&'
if it does not mean an end of a sentence.
Change '--' to '\-\-' if it indicates an option.
* man/rm.x: Change '\=' to '='.
2018-05-25 21:19:46 -07:00
Pádraig Brady
c732388fa1 cp: with --force; replace self referential symlinks
* src/copy.c (copy_internal): Don't fail immediately upon
getting ELOOP when running stat() on the destination,
rather proceeding if -f specified, allowing the link
to be removed.  If the loop is not in the final component
of the destination path, we still fail but at the
subsequent unlink() stage.
* doc/coreutils.texi (cp invocation): Adjust wording to say
that --force doesn't work with dangling links, rather than
all links that can't be traversed.
* tests/cp/thru-dangling.sh: Add a test case.
* NEWS: Mention the change in behavior.
Discussed in https://bugs.gnu.org/31335
2018-05-17 20:52:09 -07:00
Pádraig Brady
d3daa95096 cp: fix symlink checks when overwriting files
Ensure this _does_ recreate the symlink
  Given "path1" and "path2" are on different devices.
  $ touch "path1/file"
  $ cd path2/; ln -s path1/file
  $ cp -dsf path1/file .

Ensure this does _not_ overwrite file
  $ touch file
  $ ln -s file l1
  $ cp -sf l1 file

* src/copy.c (same_file_ok): Remove device ids from consideration,
instead deferring to future EXDEV with --link or allowing
the first case above to work.
Also ensure that we do not exist this function too early,
when the destination file is not a symlink, which protects
against the second case.
* tests/cp/cross-dev-symlink.sh: Add a test for the first case.
* tests/cp/same-file.sh: Add a test for the second case above.
* NEWS: Mention the bug fixes.
* THANKS.in: Mention the reporters who also analyzed the code.
Fixes https://bugs.gnu.org/31364
2018-05-15 09:55:19 -07:00
Pádraig Brady
a391007511 cp: ensure --remove-destination doesn't traverse symlinks
* src/cp.c (target_directory_operand): Allow through inaccessible
arguments with -f or --remove.
* doc/coreutils.texi (cp invocation): Clarify that -f doesn't directly
impact the removal of non-traversable symlinks.
* tests/cp/dir-rm-dest.sh: Test the new behavior.
* tests/cp/thru-dangling.sh: Enforce -f behavior wrt symlinks.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/31335
2018-05-15 09:52:44 -07:00
Pádraig Brady
694d10b71e maint: make chmod/chgrp/chown leak free under valgrind
* src/chmod.c: Deallocate the mode change array in dev mode.
* src/chown.c: Make chopt_free() actually deallocate, but
only call in dev mode.
* src/chgrp.c: Likewise.
2018-05-14 23:51:13 -07:00
Pádraig Brady
a5d158ab8f doc: improve formatting of nl --help
* src/nl.c (usage): Better delineate the information.
2018-05-14 21:33:37 -07:00
Paul Eggert
f6cb50cc99 who: simplify port to GCC 8
* src/who.c (make_id_equals_comment): Use simpler workaround
for GCC bug 85602.  Suggested by Martin Sebor in:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85602#c3
2018-05-14 13:49:58 -07:00
Pádraig Brady
ea7ae28b10 build: make GCC 8 adjustments more portable
* src/chown-core.h (chopt_free): Just define away this noop.
* src/chown-core.c (chopt_free): Remove the empty implementation.
2018-05-03 18:59:53 -07:00
Paul Eggert
3299901cde build: update gnulib submodule to latest 2018-05-03 17:50:11 -07:00
Paul Eggert
9781fcd532 maint: port to GCC 8
* src/chown-core.h (chopt_free, gid_to_name, uid_to_name):
No longer const.
* src/make-prime-list.c (xalloc): Add malloc attribute.
* src/who.c (make_id_equals_comment): Work around GCC bug 85602
by using mempcpy rather than strncat.  Although the old code
was correct, strncat raises so many hackles that it’s not
worth maintaining its use here.
2018-05-03 13:04:15 -07:00
Paul Eggert
e0566c5fea maint: remove strpbrk module
* bootstrap.conf (gnulib_modules): Remove obsolete module strpbrk.
2018-05-03 13:04:15 -07:00
Paul Eggert
ad9b283247 build: update gnulib submodule to latest 2018-05-03 13:04:14 -07:00
Pádraig Brady
22424dde74 doc: retroactively adjust info about tail and closed output
* NEWS: Expand on the 8.28 description of how tail more
responsively reacts to closed output, and move from "Improvements"
to "Changed behavior".
* cfg.mk (old_NEWS_hash): Regenerate.
Fixes https://bugs.gnu.org/31225
2018-04-20 17:54:14 -07:00
Pádraig Brady
3968f28dfd doc: timeout --help: mention 0 DURATION disables timeout
* src/timeout.c (usage): Mention that a duration of 0 disables
the associated timeout, which is both concise info and useful
functionality as timeouts are frequently configured.
2018-04-18 20:11:23 -07:00
Eric Blake
e6017741e9 doc: retroactively document -e/-u addition in NEWS
Prompted by https://bugs.gnu.org/31045

* NEWS: Update 8.8 blurb to mention other split additions.
* cfg.mk (old_NEWS_hash): Regenerate.
2018-04-05 21:38:51 -07:00
Paul Eggert
a8a52e2f05 doc: Clarify octal bits in permissions
* doc/perm.texi (Numeric Modes): Briefly explain octal.
Reorder description to make it more intuitive (Bug#29069).
2018-04-03 08:41:14 -07:00
Tobias Stoeckmann
d1a754c827 cut: improve large file support on 32 bit
Increase max range from SIZE_MAX to UINTMAX_MAX, which will
allow cut to support line lengths up to the max file size
on all systems. The inherent SIZE_MAX limitation in cut was
removed with the enhancements in https://bugs.gnu.org/13127.
Also numfmt gets similarly increased --field ranges due to
shared code.

* src/cut.c: s/size_t/uintmax_t/.
* src/numfmt.c: Likewise.
* src/set-fields.c: Likewise.
* src/set-fields.h: Likewise.
* tests/misc/cut-huge-range.sh: Adjust accordingly.
* tests/misc/numfmt.pl: Likewise.
* NEWS: Mention the improvement.
2018-03-28 00:00:09 -07:00
Pádraig Brady
30e91a10ea tests: avoid a recent syntax-check failure
* tests/ls/a-option.sh: s/framework_failure/&_/.
2018-03-27 23:54:14 -07:00
Paul Eggert
8d6acfd853 ls: -A now overrides -a
Problem reported by Karl Berry (Bug#30963).
* NEWS: Mention this.
* src/ls.c (decode_switches): Implement this.
* tests/ls/a-option.sh: New file.
* tests/local.mk (all_tests): Add it.
2018-03-27 15:05:22 -07:00
Roland Hieber
49b126bfc5 doc: fix two typos in github templates
* .github/ISSUE_TEMPLATE.txt: Fix typo "coreitils" in the URL to the bug
tracker.
* .github/PULL_REQUEST_TEMPLATE.txt: Likewise.
2018-03-24 08:37:19 +01:00
Pádraig Brady
5ed2018360 ls: increase the allowed abmon width from 5 to 12
This will impact relatively few languages,
and will make Arabic or Catalan etc.
output unambiguous abbreviated month names.

* src/ls.c (MAX_MON_WIDTH): Increase from 5 to 12.
* NEWS: Mention the bug fix.
* tests/ls/abmon-align.sh: Augment to check for ambiguous output.
Fixes https://bugs.gnu.org/30814
2018-03-16 03:16:43 -07:00
Brent Petit
0753c3f6dc stat,tail: add support for the EXFS file system
Enhanced XFS (EXFS) is a version of XFS maintained by HPE.
EXFS uses a unique magic number to allow the use of community
XFS, and EXFS filesystems at the same time.

* src/stat.c (human_fstype): Add file system ID definition,
and use "exfs" as the name.
* NEWS: Mention the Improvement.
2018-03-14 09:15:59 -07:00
Paul Eggert
b1fa4aa63c build: update gnulib submodule to latest 2018-03-06 15:22:26 -08:00
Paul Eggert
2eaf3a14a5 stat: work around IBM xlC bug
Problem reported by John Wiersba (Bug#30718)
* src/stat.c (human_time): Avoid giving an integer constant
expression a name, as it runs afoul of a bug in IBM XL C/C++ for
AIX 12.01.0000.0002.
2018-03-05 15:51:06 -08:00
Bernhard Voelker
1f52607fc3 maint: adjust email address of Keith Thompson in THANKS.in
* THANKS.in (Keith Thompson): Update email address as requested by
himself at https://lists.gnu.org/r/coreutils/2018-03/msg00004.html
2018-03-04 20:36:32 +01:00
Pádraig Brady
0a85449dde cp: set appropriate default permissions for special files
This issue was introduced in commit v8.19-145-g24ebca6

* src/copy.c (copy_internal): When setting default permissions
to use with --no-preserve=mode, only set executable bits for
directories or sockets.
* NEWS: Mention the fix.
* tests/cp/preserve-mode.sh: Add a test case.
Fixes https://bugs.gnu.org/30534
2018-02-24 18:15:26 -08:00
Pádraig Brady
33f17ab9db doc: use consistent example format in manual
* doc/coreutils.texi: Use @example consistently
as we don't need the smaller or fixed width representation.
This is especially true for the synopsis of commands.
@smallexample is rendered left aligned for HTML
which is awkward to read with the center aligned main content.
2018-01-21 11:40:57 -08:00
Paul Eggert
4bc50727f0 mv: clarify ‘mv -n A A’ change 2018-01-10 00:51:54 -08:00
Paul Eggert
bedd9bb652 mv: fewer syscalls for ‘mv a b’
This builds on a previous patch for mv atomicity (Bug#29961).
It merely improves performance; it does not fix bugs.
* src/copy.h (struct cp_options): New members last_file, rename_errno.
* src/copy.c (copy_internal): Support new rename_errno member
for the copy options.  Avoid calling stat when new members
suggest it’s not needed.
(cp_options_default): Initialize new members.
* src/mv.c: Include renameat2.h.
(main): With two arguments, first call ‘renamat2 (AT_FDCWD, "a",
AT_FDCWD, "b", RENAME_NOREPLACE)’.  Use its results to skip
remaining processing if possible; for example, if it succeeds
there is no need to stat either "a" or "b".  Also, set
x.last_file when it is the last file to rename.
2018-01-10 00:51:54 -08:00
Paul Eggert
29baf25aa0 mv: improve -n atomicity
Problem reported by Kamil Dudka (Bug#29961).
* NEWS: Mention this.
* src/copy.c: Include renameat2.h.
(copy_internal): If mv, try renameat2 first thing, with
RENAME_NOREPLACE.  If this works, skip most of the remaining code.
Also, fail quickly if it fails with EEXIST, and we are using -n.
2018-01-10 00:51:54 -08:00
Michael Orlitzky
bc2fd97964 doc: warn about following symlinks recursively in chown/chgrp
In both chown and chgrp (which shares its code with chown), operating
on symlinks recursively has a window of vulnerability where the
destination user or group can change the target of the operation.
Warn about combining the --dereference, --recursive, and -L flags.

* doc/coreutils.texi (warnOptDerefWithRec): Add macro.
(node chown invocation): Add it to --dereference and -L.
(node chgrp invocation): Likewise.

See also: CVE-2017-18018
2018-01-10 08:45:24 +01:00
Paul Eggert
b88f8d1101 cp: remove ASSIGN_BASENAME_STRDUPA
* src/cp.c (do_copy): Just use ASSIGN_STRDUPA, as this simplifies
the code and uses less memory.
2018-01-05 22:57:21 -08:00
Paul Eggert
7e244891b0 mv: -n overrides -u
* NEWS: Mention these fixes.
* doc/coreutils.texi (cp invocation, mv invocation):
Mention that -n is silent, and that it overrides -u.
* src/cp.c, src/mv.c (main): -n overrides -u.
2018-01-04 13:57:58 -08:00
Paul Eggert
3f9b1b86b1 tr: add -A, for compatibility with AIX tr
Problem reported by Michael (Bug#29946).
* src/tr.c (main): Add undocumented -A option.
2018-01-03 11:04:03 -08:00
Michael Orlitzky
7597cfa482 doc: clarify chown/chgrp --dereference defaults
* doc/coreutils.texi: the documentation for the --dereference
  flag of chown/chgrp states that it is the default mode of
  operation. Document that this is only the case when operating
  non-recursively.
2018-01-03 19:11:07 +01:00
Pádraig Brady
bd4dd61a17 tests: avoid false failure with xargs on AIX
* tests/misc/shred-remove.sh: AIX xargs defaults to using
'_' to indicate end of input, thus ignoring it.
Rather than specifying -E to avoid this behavior, simplify
by removing sed and xargs usage.
2018-01-02 14:07:00 +00:00
Pádraig Brady
ece7157933 maint: update all copyright year number ranges
Run "make update-copyright" and then...

* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
2018-01-01 15:57:22 +00:00
Pádraig Brady
1d7db19cba maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2017-12-27 18:26:39 +00:00
Pádraig Brady
27b2b19aa8 version 8.29
* NEWS: Record release date.
2017-12-27 17:54:32 +00:00
Pádraig Brady
8992dfa54c tests: avoid false failure on AIX 7.2
* tests/tail-2/pipe-f.sh: Close stdout in a subshell
to ensure the current shell isn't impacted.  Subsequent
piped commands like `echo foo | blah` were seen to fail
due to the previous closing of stdout.
Reported by Assaf Gordon.
2017-12-23 10:25:57 +00:00
Pádraig Brady
f4fec33607 doc: describe recent build checks for 32 bit time_t
* README: Document the new handling of 32 bit time_t,
with examples of how to build in 64 bit mode on AIX.
Also mention that GNU make is desired on AIX
due to its mishandling of the "[" target.
Suggested by Assaf Gordon.
2017-12-23 10:25:56 +00:00
Pádraig Brady
ba4b0bde2e tests: fix recent portability issues on solaris 10
* tests/misc/ptx.pl: Escape the '^' character which is
otherwise considered as a line continuation character.
* tests/misc/shred-remove.sh: sed doesn't support \n.
2017-12-21 13:52:24 +00:00
Pádraig Brady
70c84e046e maint: remove reference to excluded changelog item
* build-aux/git-log-fix: Remove old entry.
2017-12-21 12:15:29 +00:00
Pádraig Brady
6821f2fb4e maint: add doc/coverage to .gitignore
* .gitignore: Ignore the generated coverage report.
2017-12-20 14:53:29 +00:00
Pádraig Brady
9f8b16e992 doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.20 which is now about 5 years old.
2017-12-20 14:36:37 +00:00
Bernhard Voelker
47fb363432 doc: mention which privileges are needed to chmod
POSIX specification for chmod(1):
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/chmod.html

* doc/coreutils.texi (chmod invocation): Add a sentence about who can
change the file mode bits of a file - (almost) a copy from what POSIX
requires.

Fixes https://bugs.gnu.org/29207.
2017-12-18 08:07:12 +01:00
Pádraig Brady
177f131385 tests: fix recent regressions with dash
* tests/misc/timeout.sh: dash outputs the "Killed"
message to stderr rather than the terminal.
* tests/misc/usage_vs_getopt.sh: dash doesn't yet
support the POSIX proposed $'...' shell quoting syntax.
2017-12-16 13:34:19 -08:00
Pádraig Brady
a1300c60ef build: avoid a signed overflow warning in ptx
* src/ptx.c (fix_output_parameters): GCC 6.3.1 with
./configure --enable-single-binary would give:
  error: assuming signed overflow does not occur
  when simplifying conditional to constant [-Werror=strict-overflow]
    if (file_index > 0)
So change the type of file_index to signed (size_t).
2017-12-16 13:08:43 -08:00
Bernhard Voelker
36325c7f03 maint: adjust for the renamed nstrfime gnulib module
* bootstrap.conf: s/strftime/nstrfrime/.
2017-12-10 18:46:17 -08:00
Pádraig Brady
108f34a71b build: update gnulib submodule to latest
* gnulib: Update with various build/test fixes.
2017-12-10 18:03:35 -08:00
Pádraig Brady
a58ce6f023 tests: fix false failure in new dd/nocache_eof test
* test/dd/nocache_eof.sh: Also handle fadvise64_64 which is
used on 32 bit x86.  Note strace internally maps fadvise64_64
to {arm,xtensa}_fadvise64_64.
2017-12-10 17:13:18 -08:00
Pádraig Brady
e44df9d3f5 tail: fix tailing non seekable files on certain systems
* src/tail.c (tail_bytes): On systems were blksize_t is unsigned
and the same size or wider than off_t (android for example),
our initialized (off_t) -1 would be promoted to unsigned before
comparison, and thus fail to follow the appropriate path.
* tests/tail-2/tail-c.sh: Add a test case.
* NEWS: Mention the fix.
This issue was introduced in commit v8.23-47-g2662702
Reported at https://github.com/termux/termux-app/issues/233
2017-12-10 17:13:18 -08:00
Pádraig Brady
8fb32039bc build: avoid build failure without sys/mtio.h
* m4/jm-macros.m4: Check for the header.
* src/dd.c: Avoid the workaround where the header
is not available (on non glibc systems).
* src/shred.c: Likewise.
2017-12-10 17:13:18 -08:00
Pádraig Brady
b697bac049 doc: reorganize ls -k and --time-style help
* src/ls.c (usage): Clarify -k only applies to -s usage
and directory 'total' lines.  Move the description
of TIME_STYLE out of the option section as it was awkward
to read and write there within 80 columns.
2017-12-10 17:12:49 -08:00
Pádraig Brady
532b4285de doc: clarify numeric setuid handling in chmod man page
* man/chmod.x: Update the information to state one can
clear the setuid and setgid bits for directories numerically
using an additional leading '0' or a leading '='.
That has been supported since v8.15-64-g8931cdb.
Fixes https://bugs.gnu.org/29390
2017-12-09 18:26:56 -08:00
Pádraig Brady
6150b10698 doc: shred: change 'truncate' to the more descriptive 'deallocate'
* doc/coreutils.texi (shred invocation): s/truncate/deallocate/.
* src/shred.c (usage): Likewise.
Fixes https://bugs.gnu.org/29317
2017-12-09 16:54:03 -08:00
Pádraig Brady
f17c1df391 doc: clarify that cp --force may recreate files
* doc/coreutils.texi (cp invocation): The language used
to describe recreating the file was a little confusing
as it mentioned opening a removed file.
Fixes https://bugs.gnu.org/29315
2017-12-09 16:18:00 -08:00
Kamil Dudka
e184a46e39 doc: fix default QUOTING_STYLE for %N format of stat(1)
* doc/coreutils.texi (stat invocation): The default value
of QUOTING_STYLE for the %N format of 'stat --printf' is
'shell-escape-always'.
Fixes https://bugs.gnu.org/29563
Reported by Christian Groessler at
https://bugzilla.redhat.com/1520399#c3
2017-12-04 10:29:42 -08:00
Jean Delvare
166fe58561 tests: make ls/block-size more readable
* tests/ls/block-size.sh: The output of the test was hard to read. Add
comments saying what we are testing to make it easier to understand.
2017-12-02 16:54:32 +01:00
Bernhard Voelker
052cce9e3e tests: verify usage vs. getopt
Verify that all options mentioned in usage are actually recognized
by the program.

* tests/misc/usage_vs_getopt.sh: Add test.
* tests/local.mk (all_tests): Reference it.

Co-authored-by: Pádraig Brady <P@draigBrady.com>
2017-11-29 13:29:00 +01:00
Pádraig Brady
ba9c7449b9 readlink: remove superfluous comma from usage output
* src/readlink.c (usage): Remove ',' after --quiet option.
2017-11-29 13:27:51 +01:00
Bernhard Voelker
5782a362e1 all: use consistent diagnostics for unknown long options
Previously, e.g. cksum failed to output the offending unknown long
option:
  $ cksum --unknown-opt
  cksum: invalid option -- '-'
  Try 'cksum --help' for more information.
i.e., it tried to diagnose '-' as short option.
Instead, it should diagnose the unknown long option:
  $ cksum --unknown-opt
  cksum: unrecognized option '--unknown-opt'
  Try 'cksum --help' for more information.

* src/cksum.c (long_options): Add struct with null entry only.
(main): Use it in the getopt_long call.
* src/dd.c: Likewise.
* src/hostid.c: Likewise.
* src/hostname.c: Likewise.
* src/link.c: Likewise.
* src/logname.c: Likewise.
* src/nohup.c: Likewise.
* src/sleep.c: Likewise.
* src/tsort.c: Likewise.
* src/unlink.c: Likewise.
* src/uptime.c: Likewise.
* src/users.c: Likewise.
* src/whoami.c: Likewise.
* src/yes.c: Likewise.
* NEWS (Improvements): Mention the fix.
2017-11-29 13:27:02 +01:00
Pádraig Brady
b505dc5734 test: fix issues with tests/cp/preserve-mode.sh
* tests/cp/preserve-mode.sh: This was the only use of awk,
which may not be available on the system resulting
in an ineffective test.  Also the permissions bits for
directories were not being checked at all.
2017-11-28 22:12:22 -08:00
Pádraig Brady
b5d6f66b60 build: update gnulib submodule to latest
* gnulib: Update with various build/test fixes.
2017-11-28 22:04:39 -08:00
Pádraig Brady
346de3c1e1 build: update gnulib submodule to latest
* gnulib: Update including various build fixes.
2017-11-28 00:45:07 -08:00
Bernhard Voelker
a72abc9304 timeout: also support short -v option
* src/timeout.c (main): Add short option character 'v' to getopt_long
call.
* tests/misc/timeout.sh: Run the test both for the long and the short
option.
2017-11-27 22:05:56 +01:00
Pádraig Brady
5f02cddc18 dd: support iflag=direct with arbitrary sized files
* src/dd.c (iread): Handle read error with a non-aligned
file offset in the O_DIRECT case.  This is not an issue
on XFS at least, but on EXT4 the final read will return
EINVAL rather than the expected 0 to indicate EOF.
* tests/dd/direct.sh: Test the iflag=direct case also.
* NEWS: Mention the improvement.
2017-11-24 16:28:57 -08:00
Pádraig Brady
559c7a57c7 timeout: add --verbose to diagnose timeouts
This is useful as handling in shell is complicated
with the varying exit status in the --kill-after case.

* src/timeout.c (main): Handle '-v' and store
COMMAND for the diagnostic.
(cleanup): Diagnose the signal name before sending.
(usage): Document -v, --verbose.
* doc/coreutils.texi (timeout invocation): Likewise.
* tests/misc/timeout.sh: Add a test case.
* NEWS: Mention the new feature
Fixes https://bugs.gnu.org/21760
2017-11-23 17:46:55 -08:00
Pádraig Brady
31dd7a0de2 tail: seek to the end of block devices
* src/tail.c (tail_bytes): Try lseek(..., SEEK_END) when
we can't determine the file size.
* tests/tail-2/end-of-device.sh: Add a new root only test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the improvement.
Paul Eggert suggested using lseek() (rather than ioctl(BLKGETSIZE64)).
Fixes https://bugs.gnu.org/29259
2017-11-18 22:26:02 -08:00
Bernhard Voelker
25030d942d maint: include the module year2038 from gnulib
* bootstrap.conf (gnulib_modules): Add 'year2038' to ensure that time_t
is 64-bit (and thus works after 2038).

Suggested by Bruno Haible in
https://lists.gnu.org/r/bug-gnulib/2017-11/msg00022.html
2017-11-14 10:12:01 +01:00
Bernhard Voelker
60e77fa49a maint: update gnulib to latest
* gnulib: Update - mainly for the recent year2038 changes.
* tests/init.sh: Update from gnulib/tests/init.sh.
2017-11-14 10:12:01 +01:00
Assaf Gordon
a4eedb251e doc: add github issue/pull-request templates
These templates instruct contributors not to use github, and instead
use the upstream GNU development resources. Discussed in
http://lists.gnu.org/archive/html/coreutils/2017-11/msg00007.html .

* .github/ISSUE_TEMPLATE.txt,
  .github/PULL_REQUEST_TEMPLATE.txt: New files.
2017-11-09 15:15:15 -07:00
Jim Meyering
95bfb36292 maint: make hook script reject "/archive/html" in lists.gnu.org URLS
* scripts/git-hooks/commit-msg: Require the abbreviated "/r/"
form in any log message URL.
2017-11-07 20:16:55 -08:00
Jim Meyering
9d88182ce1 maint: shorten https://lists.gnu.org/archive/html/... links
Each /archive/html/ part can be replace with /r/.
Run this to induce the change:
git grep -l archive/html|xargs perl -pi -e 's,/archive/html/,/r/,g'
* TODO: Perform that substitution.
* bootstrap: Likewise.
* src/sort.c (sequential_sort): Likewise.
* src/tail.c (tail_file): Likewise.
* tests/misc/sort-merge-fdlimit.sh: Likewise.
* tests/misc/stty-row-col.sh: Likewise.
* tests/misc/unexpand.pl: Likewise.
* tests/rm/readdir-bug.sh: Likewise.
* tests/tail-2/inotify-rotate.sh: Likewise.
2017-11-07 20:16:13 -08:00
Thomas Deutschmann
aebefc25f9 tests: avoid false failure with inaccessible mount points
* tests/ls/readdir-mountpoint-inode.sh: Skip the test
if any mount points are inaccessible by the current user.
Fixes https://bugs.gnu.org/29167
Reported at: https://bugs.gentoo.org/353164
2017-11-06 21:34:40 -08:00
Bernhard Voelker
e83f10c483 doc: fix "Up" field of realpath usage examples
Older versions of 'makeinfo' choke on a missing reference:

  ./doc/coreutils.texi:14177: `Realpath usage examples' has no Up field\
  (perhaps incorrect sectioning?).
  makeinfo: Removing output file `doc/coreutils.info' due to errors; \
  use --force to preserve.

* doc/coreutils.texi (realpath invocation): Add a menu referencing
the usage examples - introduced in v8.27-91-g7449f0d.
2017-11-05 16:56:39 -08:00
Pádraig Brady
ada1caedd5 maint: ensure https:// URLs are used in --help and man pages
* configure.ac(AC_INIT): Specify the URL explicitly, so we're
not dependent on unreleased autoconf.
2017-11-05 16:36:58 -08:00
Assaf Gordon
5ab71e4d3f stat: output default formats for --terse in usage
Suggested by L A Walsh in https://bugs.gnu.org/28763 .

* src/stat.c (fmt_terse_fs): Define format for --terse -f here.
(fmt_terse_regular): Define format for --terse here.
(fmt_terse_selinux): Likewise for when SELinux is enabled.
(default_format): Use the above constants.
(usage): Output the formats for the terse modes.
2017-10-31 16:31:16 -06:00
Pádraig Brady
b04ce61958 df: fix hang with fifo argument
* src/df.c (main): stat() before open(), and avoid
the optional open when given a fifo argument.
* tests/df/unreadable.sh: Add a test case.
* NEWS: Mention the fix.
Fixes https://bugs.gnu.org/29038
2017-10-30 09:47:43 -07:00
Jim Meyering
f89c20bdf7 build: ls.c: apply _GL_ATTRIBUTE_PURE to more functions
* src/ls.c (DEFINE_SORT_FUNCTIONS): Apply _GL_ATTRIBUTE_PURE
to each strcmp-derived function definition, since GCC8 with
-Wsuggest-attribute=pure now warns it is needed.
2017-10-27 21:18:46 -07:00
Vincent Lefevre
61a8b5cb56 doc: reference statfs(2) in the stat(1) man page
* man/stat.x (SEE ALSO): Mention statfs(2) in addition to stat(2).
Note statfs() is generally used rather than statvfs(),
so we'll defer that reference to the SEE ALSO section of statfs(2).
Fixes https://bugs.gnu.org/28989
2017-10-25 21:36:19 -07:00
Pádraig Brady
e818f19cf8 tests: avoid false failure when O_DIRECT isn't supported
* tests/dd/nocache_eof.sh: Only run the O_DIRECT tests
when 512 byte alignment is supported.  Otherwise with older
XFS on systems with > 1MiB pages, or on file systems not
supporting O_DIRECT, there would have been false failures.
* tests/dd/direct.sh: Clarify the skip message.
2017-10-24 20:08:05 -07:00
Pádraig Brady
de15a497d1 dd: fix nocache regions passed to posix_fadvise()
Previously with oflag=direct the call to invalidate_cache()
was not passed to the kernel, as it was less than a page size,
and a subsequent call was not made to invalidate the pending space.
Similarly with oflag=nocache the pending space at EOF was
not invalidated.  Even though these amount to only a single page
in the page cache it can be significant.  For example on
XFS before kernel patch v4.9-rc1-4-g0ee7a3f, O_DIRECT files
would have been read inefficiently if any pages were cached,
even if they were already synced to storage.

* src/dd.c (i_nocache_eof, o_nocache_eof): New bools used
to control when we want invalidate_cache(,0) to clear to EOF.
(cache_round): Use IO_BUFSIZE (currently 132KiB) to minimize
calls to the relatively expensive advise function, rather
than page_size.  This also makes it clear that while the
kernel function operates on pages, this size is chosen for
performance reasons.
(invalidate_cache): Refactor to share more code between
input and output paths. Use i_nocache_eof and o_nocache_eof
rather than proxying off max_records.  Ensure we
invalidate full pages when clearing to EOF as the kernel
will ignore any non complete pages.  Fix the offset used
for the output path.
(dd_copy): Invalidate the cache of the input after the
offset is updated, for consistency and so we don't try to
invalidate before the start of the file.  When we read
EOF on input, set flags so that we invalidate to EOF.
(main): Invalidate to EOF in more cases, by depending
on the i_nocache_eof and o_nocache_eof flags.
* doc/coreutils.texi (dd invocation): Clarify the alignment
and persisted caveats on the example applying "nocache"
to part of a file.
* tests/dd/nocache_eof.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Issue reported by Eric Bergen.
2017-10-24 19:38:12 -07:00
Michael Stone
9fa178fccd doc: mention QUOTING_STYLE env var in ls man page
* src/ls.c (usage): Mention QUOTING_STYLE with the --quoting-style
option, and indicate it has lower precedence than that option.
2017-10-24 10:29:35 -07:00
Pádraig Brady
84f7231dfa maint: apply suggested cleanup to recent stty.c change
This should have been part of commit v8.28-17-gf926f7c
* src/stty.c (check_argument): Align line continuation chars,
and ensure the function macro is immune to usage with if/else.
Suggested by Jim Meyering and Paul Eggert.
2017-10-23 23:31:40 -07:00
Pádraig Brady
cc19f63be3 b2sum: fix crash with --check and truncated input
* src/md5sum.c (split_3): Ensure we don't walk off
the end of the string.
* tests/misc/b2sum.sh: Add test cases.
Fixes https://bugs.gnu.org/28860
2017-10-23 23:17:17 -07:00
Pádraig Brady
f926f7ce0e stty: fix processing of options when -F is specified
This was a latent issue that became significant with
the addition of the -F option in FILEUTILS-3_16n-56-ge46a424

* src/stty.c (apply_settings): Refactor argument checking
to a function macro.  Augment the argument check to ignore
NULLed out arguments (already processed -F).
* NEWS: Mention the fix.
* tests/misc/stty-invalid.sh: Add a test case.
Fixes https://bugs.gnu.org/28859
2017-10-23 23:15:25 -07:00
Pádraig Brady
cbf35912da timeout: fix a small race that would ignore command exit
This fixes a regression from commit v8.26-39-g2f69dba

* src/timeout.c (block_cleanup_and_chld): Rename from block_cleanup
to indicate we also block SIGCHLD to avoid the race where SIGCHLD
fires between waitpid() polling and sigsuspend() waiting for a signal.
* NEWS: Mention the fix.
2017-10-23 23:10:42 -07:00
Thomas Jarosch
cccd01b4da timeout: fix regression when invoked with blocked SIGCHLD
We inherit the signal mask from our parent process,
therefore ensure SIGCHLD is not blocked.

If SIGCHLD is blocked, sigsuspend() won't be interrupted
when the child process exits and we hang until the timeout (SIGALRM).

This fixes a regression from commit v8.26-39-g2f69dba

* src/timeout.c (install_sigchld): Ensure SIGCHLD is unblocked.
* NEWS: Mention the issue.
2017-10-23 23:09:02 -07:00
Pádraig Brady
856b828320 build: reinstate distribution of man pages
man pages change little between systems,
so falling back to distributed pages make sense
when cross compiling or lacking perl.

* man/local.mk: Add all man pages to EXTRA_DIST
so that they're distributed in the generated tarball.
Use the dummy-man page generator if cross compiling.
Set TZ to avoid a distcheck failure where man pages
used a diffent month than those rebuilt (with a .timestamp).
* man/dummy-man: Only fall back to generating a stub
if copying an existing man page fails.
* man/help2man: Sync portable TZ=UTC0 specification
from upstream help2man.
* NEWS: Mention the build-related change.
Fixes https://bugs.gnu.org/28574
2017-10-01 17:32:48 -07:00
Pádraig Brady
6774b991db maint: remove a duplicate entry from THANKS
* .mailmap: Prefer Colin Watson's last used email address.
2017-10-01 17:32:30 -07:00
Paul Eggert
4b8c92b940 copy: revert recent patch for vulnerable dirs
I plan to propose a better patch to catch vulnerable parent
directories.
* NEWS, doc/coreutils.texi (Target directory): Document this.
* src/cp.c, src/install.c, src/ln.c, src/mv.c:
Do not include targetdir.h.
(target_directory_operand): Remove test for vulnerable parents.
* src/cp.c (stat_target_operand): Remove.  All uses removed.
* src/local.mk (noinst_HEADERS): Remove src/targetdir.h.
(src_ginstall_SOURCES, src_cp_SOURCES, src_ln_SOURCES)
(src_mv_SOURCES): Remove src/targetdir.c.
* src/targetdir.c, src/targetdir.h: Remove.
* tests/mv/vulnerable-target.sh: Remove.
* tests/local.mk (all_root_tests): Remove it.
2017-09-24 23:10:56 -07:00
Pádraig Brady
63d2f05f52 tests: fix test hang on case insenitive file systems
* tests/split/filter.sh: Due to an invalid 'FILE = zero.in'
construct trying to initialize a FILE variable, it would
instead try to run the FILE command which is present on
macOS 10.13 with APFS.
We also remove a redundant duplicate test clause introduced
during a rebase, and simplify the piped timeout command,
to avoid requiring a subshell and associated quoting.
* THANKS.in: Add the reporter Jack Howarth.
Fixes https://bugs.gnu.org/28506
2017-09-24 12:37:39 -07:00
Pádraig Brady
3a3f5f359e tests: avoid a false failure in expr test with UTF8
* tests/misc/expr.pl: Skip the quote varying tests in
the multi-byte locales as these tests aren't that interesting
in those locales.  Also ERR_SUBST is already defined for
some tests so awkward to redefine to munge UTF8 quotes to ASCII.
2017-09-20 22:21:31 -07:00
Assaf Gordon
454d7f31c5 expr: add detailed syntax error messages
Show offending argument instead of a generic 'syntax error' message.
Suggested by Bernhard Voelker in https://bugs.gnu.org/28461#13 .

* src/expr.c (syntax_error): Remove.
(required_more_args): New function.
(eval7, main): Replace syntax_error call with detailed die message.
* tests/misc/expr.pl: Add tests for new messages.
2017-09-19 23:51:54 -06:00
Pádraig Brady
a608f1e781 maint: fix new syntax-check failures from HTTPS adjustments
* cfg.mk [old_NEWS_hash]: update with `make update-NEWS-hash`.
[sc_long_lines]: Avoid flagging (long) URLs in NEWS.
* src/sort.c: Tweak to a shorter line.
* src/tail.c: Likewise.
Introduced in v8.28-4-gbe87d61
2017-09-19 22:32:00 -07:00
Pádraig Brady
0be99382d9 maint: fix new syntax check failures from copy restrictions
* doc/coreutils.texi: Remove doubled word.
* src/targetdir.c: Explicitly mark exported function.
* tests/local.mk: This is not a root only test.
* tests/mv/vulnerable-target.sh: Use returns_.
Introduced in v8.28-3-g44ccd1c
2017-09-19 22:21:28 -07:00
Pádraig Brady
c34f8d5c78 shred: reinstate --remove file name length obfuscation
This was unintentionally removed in v8.27-60-g2ae1460
* src/shred.c (wipename): Interate through all name lengths.
* tests/misc/shred-remove.sh: Add test cases.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/28507
2017-09-19 21:24:38 -07:00
Paul Eggert
4cb3f4faa4 maint: copy bootstrap from Gnulib 2017-09-19 01:25:13 -07:00
Paul Eggert
be87d61299 all: prefer HTTPS in URLs 2017-09-19 01:22:54 -07:00
Paul Eggert
44ccd1c465 copy: check for vulnerable target dirs
* NEWS, doc/coreutils.texi (Target directory): Document this.
* src/cp.c, src/install.c, src/ln.c, src/mv.c: Include targetdir.h.
(target_directory_operand): Use the new targetdir_operand_type
function to check for vulnerable target directories.
* src/cp.c (stat_target_operand): New function.
(target_directory_operand, do_copy): Use it.
* src/local.mk (noinst_HEADERS): Add src/targetdir.h.
(src_ginstall_SOURCES, src_cp_SOURCES, src_ln_SOURCES)
(src_mv_SOURCES): Add src/targetdir.c.
* src/targetdir.c, src/targetdir.h: New files.
* tests/mv/vulnerable-target.sh: New test.
* tests/local.mk (all_root_tests): Add it.
2017-09-19 00:14:30 -07:00
Bernhard Voelker
97c5045435 ptx: avoid infloop due to zero-length matches with -S regex
* src/ptx.c (find_occurs_in_text): Die with an appropriate error
diagnostic when the given regular expression returns a match of
length 0.
* tests/misc/ptx.pl (S-infloop): Add a test.
* NEWS (Bug fixes): Mention the fix.

Fixes https://bugs.gnu.org/28417 which was detected using
Symbolic Execution techniques developed in the course of the
SYMBIOSYS research project at COMSYS, RWTH Aachen University.
2017-09-14 07:50:27 +02:00
Pádraig Brady
5d9d07bbb1 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2017-09-01 19:25:50 -07:00
Pádraig Brady
e9d231112a version 8.28
* NEWS: Record release date.
2017-09-01 18:53:58 -07:00
Pádraig Brady
38c2b405dd tests: fix false failure in recent ls --hyperlink test
* tests/ls/hyperlink.sh: If the hostname or any part of
the absolute path would be changed due to URL encoding,
the test would fail.  Therefore simplify to remove
these components of the URL from consideration.
2017-09-01 00:03:08 -07:00
Pádraig Brady
c6f9c75c16 maint: avoid a syntax-check failure
* .gitignore: Remove lines indicated by sc_gitignore_redundant
in a freshly checked out repo.
2017-08-31 21:29:39 -07:00
Pádraig Brady
2ba96977c9 tests: exclude the expensive gnulib fts-tests
* gnulib: The only change in this gnulib update
is the tagging of the fts-tests module as longrunning,
which gnulib-tool currently implicitly excludes.
This test was seen to take about 20s and 285MB.
Reported by Assaf Gordon on space restricted VMs.
2017-08-30 22:49:24 -07:00
Pádraig Brady
173bee1bdf tty: don't distinguish input errors
* src/tty.c (main): Don't distinguish ENOTTY from other errors,
because isatty() doesn't portably distinguish errors.
Solaris returns ENOENT for all input errors for example.
Musl also returns ENOENT, and ENODEV may be returned as disscussed at:
http://openwall.com/lists/musl/2017/04/06/6
* tests/misc/tty.sh: Adjust accordingly.
2017-08-30 20:46:49 -07:00
Pádraig Brady
5ee9c8f7a6 tests: avoid printf '0*d' construct unsupported by ash
* tests/ln/sf-1.sh: Generate specific length with space padding
which is supported.
Reported by Assaf Gordon on Alpine Linux.
2017-08-30 20:39:54 -07:00
Pádraig Brady
1e8c458210 tests: skip tests upon failure to set SELinux context
On some setups the root:object_r:tmp_t context is invalid.
This does indicate a limitation in the test framework,
but for now we'll relax this to skipping the tests.
The tests still run on a Fedora 25 system for example.

* tests/cp/cp-a-selinux.sh: Upon chcon error, skip rather than ERROR.
* tests/install/install-Z-selinux.sh: Likewise.
* tests/misc/chcon.sh: Likewise.
* tests/misc/runcon-no-reorder.sh: Likewise.
* tests/misc/selinux.sh: Likewise.
* tests/mkdir/restorecon.sh: Likewise.
2017-08-30 17:18:17 -07:00
Kamil Dudka
87a95504bb expr: fix a recently introduced memory leak
* src/expr.c (eval6): Free memory allocated by mbs_logical_substr().

Introduced in v8.27-47-ga9f2be5.  Detected by Coverity Analysis:

Error: RESOURCE_LEAK:
src/expr.c:851: leaked_storage: Variable "s" going out of scope
leaks the storage it points to.
849|             char *s = mbs_logical_substr (l->u.s, pos, len);
850|             v = str_value (s);
851|->         }
852|         freev (l);
853|         freev (i1);
2017-08-30 12:04:29 -07:00
Pádraig Brady
db8d1bb92c build: fix build of renameat2 on Alpine Linux
* gnulib: The only change included in this update
it the added check for the presence of <linux/fs.h>
which is not present on Alpine Linux by default.
2017-08-30 01:33:06 -07:00
Pádraig Brady
d952949829 tty: fix exit code with EINVAL
* src/tty.c (main): All systems mention that isatty()
man return EINVAL as well as (the POSIX compliant) ENOTTY.
Also Centos 6 was seen to return EINVAL from ttyname().
* tests/misc/tty.sh: Fix a test issue where we assume
standard input is always a valid tty.
Reported by Assaf Gordon on OpenSolaris 5.10 and 5.11,
and Centos 6.5
2017-08-30 01:29:53 -07:00
Pádraig Brady
f5d7c0842e runcon: revert "disable use of the TIOCSTI ioctl"
This reverts commit v8.27-97-g8cb06d4 because
the setsid() fallback was not implemented correctly
and disabling the ioctl was not a complete solution
to the security issue of the child being passed
the tty of the parent.

Given runcon is not really a sandbox command,
the advice is to use `runcon ... setsid ...`
to avoid this particular issue.
2017-08-30 00:28:20 -07:00
Pádraig Brady
f169345506 stat: fix determination of max name length on BSD systems
We only use one of statfs or statvfs for `stat -f`
and on the BSDs we use statfs which doesn't have the
f_namelen member.  However on OpenBSD and later FreeBSD
systems statfs does provide f_namemax, so use that.

* NEWS: Mention the improvement for OpenBSD and FreeBSD.
* m4/stat-prog.m4: Check for f_namemax in the statfs struct.
* src/stat.c: Return '?' rather than '*' when we can't
determine the max length of the file system.
* tests/ln/sf-1.sh: This test was failing on all BSDs
due to '*' being returned for the max length which
caused the test to attempt to create 1Mi+1 names.
The test now uses a short name when we can't determine
the max name length to use.

Reported by Assaf Gordon on various BSD based systems.
2017-08-29 23:42:54 -07:00
Pádraig Brady
3ebdc3e1af stat,tail: support "AAFS" AppArmor file system
* src/stat.c (human_fstype): This file system is used
to manage AppArmor policy in the Linux kernel.
2017-08-29 01:04:32 -07:00
Pádraig Brady
ba76db563f all: update gnulib submodule to latest
* bootstrap: Sync timestamp update.
2017-08-29 00:38:20 -07:00
Pádraig Brady
8cb06d4b44 runcon: disable use of the TIOCSTI ioctl
Similar to the issue with SELinux sandbox (CVE-2016-7545),
children of runcon can inject arbitrary input to the terminal
that would be run at the originating terminal privileges.

The new libseccomp dependency is widely available and used
on modern SELinux systems, but is not available by default
on older systems like RHEL6 etc.

* m4/jm-macros.m4: Check for libseccomp and
warn if unavailable on selinux supporting systems.
* src/local.mk: Link runcon with -lseccomp.
* src/runcon.c (disable_tty_inject): A new function to
disable use of the TIOCSTI using libseccomp, or with setsid()
where libseccomp is unavailable.
* tests/misc/runcon-no-inject.sh: A new test that uses
python to make the TIOCSTI call, and ensure that doesn't succeed.
* tests/local.mk: Reference the new test
* NEWS: Mention the fix.
Addresses http://bugs.gnu.org/24541
2017-08-29 00:38:19 -07:00
Pádraig Brady
799bac0d06 ls: support --hyperlink to output file:// URIs
Terminals such as iTerm2 and VTE based terminals
(as of version 0.49.1), support hyperlinks when
passed terminals codes as described at:
https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda

* src/ls.c (gobble_file): Allocate an absolute file name to output.
(quote_name): Output the absolute name with the appropriate codes.
(file_escape): A new function to encode file names as per rfc8089.
(main): Handle the new option and call the file_escape_init() helper.
Disable --dired when --hyperlink is specified.
(print_dir): Get the absolute file name here too, so that the
directory name can be linkified.
* NEWS: Mention the new feature.
* tests/ls/hyperlink.sh: Add a new test.
* tests/local.mk: Reference the new test.
* doc/coreutils.texi (ls invocation): Describe --hyperlink.
2017-08-29 00:38:19 -07:00
Pádraig Brady
4e112e90b1 doc: remove older ChangeLog items
This saves about 0.5MB uncompressed from the tarball.

* Makefile.am: Following on from v8.26-34-g2c64bc8
update the oldest documented version to 8.18 which
is now about 5 years old.  Also remove older ChangeLogs
that were previously thought to be for changes not
in the git history, but are adequately recorded upon review.
* build-aux/ChangeLog-2007: Remove file.
* lib/ChangeLog-2007: Likewise.
* m4/ChangeLog-2007: Likewise.
2017-08-29 00:38:19 -07:00
Colin Watson
57dea5ed07 env: add --chdir option
This is useful when chaining with other commands that run commands in a
different context, while avoiding using the shell to cd, and thus
having to consider shell quoting the chained command.

* NEWS (New features): Document the new option.
* doc/coreutils.texi (env invocation): Likewise.
* src/env.c (usage): Likewise.
(main): Implement the new option.
* tests/misc/env.sh: Test the new option.
2017-08-29 00:38:19 -07:00
Pádraig Brady
2686052667 tests: don't fail tests when failing to write files
* tests/sample-test: Use framework_error_ rather than fail=1
* tests/chown/deref.sh: Likewise.
* tests/chown/preserve-root.sh: Likewise.
* tests/cp/src-base-dot.sh: Likewise.
* tests/dd/unblock-sync.sh: Likewise.
* tests/du/2g.sh: Likewise.
* tests/du/inacc-dest.sh: Likewise.
* tests/du/one-file-system.sh: Likewise.
* tests/fmt/goal-option.sh: Likewise.
* tests/ln/hard-backup.sh: Likewise.
* tests/ls/color-dtype-dir.sh: Likewise.
* tests/ls/m-option.sh: Likewise.
* tests/ls/stat-dtype.sh: Likewise.
* tests/ls/time-style-diag.sh: Likewise.
* tests/ls/x-option.sh: Likewise.
* tests/misc/chcon.sh: Likewise.
* tests/misc/nohup.sh: Likewise.
* tests/misc/od-N.sh: Likewise.
* tests/misc/sort-compress.sh: Likewise.
* tests/misc/tac-continue.sh: Likewise.
* tests/misc/time-style.sh: Likewise.
* tests/mv/backup-dir.sh: Likewise.
* tests/mv/dir2dir.sh: Likewise.
* tests/rm/dir-no-w.sh: Likewise.
* tests/rm/dir-nonrecur.sh: Likewise.
* tests/rm/inaccessible.sh: Likewise.
* tests/rm/interactive-always.sh: Likewise.
* tests/rm/interactive-once.sh: Likewise.
* tests/rm/rm3.sh: Likewise.
* tests/rm/v-slash.sh: Likewise.
* tests/touch/relative.sh: Likewise.
2017-08-29 00:37:59 -07:00
Josef Cejka
a19ff5d817 df: avoid stat() for dummy file systems with -l
When systemd is configured to automount a remote file system - see
'man systemd.automount(5)', then the mount point is initially
mounted by systemd with the file system type "autofs".
When the resource is used later on, then the wanted file system is
mounted over that mount point on demand.
'df -l' triggered systemd to mount the file system because it called
stat() on the mount point.
Instead of single-casing "autofs" targets, we can avoid stat()ing
all dummy file systems (which includes "autofs"), because those are
skipped later on in get_dev() anyway.

*src/df.c (filter_mount_list): Also skip dummy file systems unless
the -a option or a specific target are given.
* NEWS: Mention the fix.

Co-authored-by: Bernhard Voelker <mail@bernhard-voelker.de>

Fixes http://bugzilla.suse.com/show_bug.cgi?id=1043059
2017-08-28 23:22:28 -07:00
Assaf Gordon
7449f0d0ab doc: add 'realpath usage examples' section
* doc/coreutils.texi (Realpath usage examples): New section.
2017-08-28 23:22:28 -07:00
Assaf Gordon
ac48f7135e doc: fix realpath index entry
The 'readlink' node has '@findex realpath' in it. This results in
    info doc/coreutils.info realpath
incorrectly jumping to the 'readlink' node (instead of the 'realpath'
node). Change it to @cindex instead.

* doc/coreutils.texi (readlink): Change '@findex realpath' to @cindex.
2017-08-28 23:22:28 -07:00
Assaf Gordon
65b7bf790c realpath: improve usage description for --relative-{to,base}
* src/realpath.c (usage): Explicitly say 'DIR' instead of 'FILE' for
--relative-{to,base} parameters, to avoid giving the impression
that regular files can be used as relative base.
* doc/coreutils.texi (realpath): Same.
2017-08-28 23:22:28 -07:00
Pádraig Brady
ac2eebc224 ls: consistently quote symlink targets
* src/ls.c (gobble_file): Disable the optimization to avoid quoting
if the symlink target itself needs quoting.  This was introduced
with the quoting alignment adjustments in v8.25-106-g01971c0
* tests/ls/symlink-quote.sh: Add a test.
* tests/local.mk: Reference the test.
* NEWS: Mention the fix.
2017-08-24 19:26:32 -07:00
Pádraig Brady
5ee49fea85 tail: reinstate inotify use with FIFOs
commit v8.27-44-g18f6b22 was too aggressive in
only allowing inotify use with regular files. This will
support responsive processing of `tail -f fifo | ...`

* src/tail.c (any_non_regular): Adjust to allow FIFOs
since inotify supports these well.
* tests/tail-2/inotify-only-regular.sh: Adjust comment.
2017-08-24 19:20:47 -07:00
Pádraig Brady
d306546d84 maint: avoid a syntax check failure
* src/sort.c: Don't include stdio--.h as fopen() is no longer used.
2017-08-19 15:45:13 -07:00
Pádraig Brady
4b5bc5454e tests: fix issues on alpine linux
* tests/misc/seq-epipe.sh: Remove stale comment.
* tests/misc/sort-debug-warn.sh: musl doesn't indicate a set_locale()
failure with missing locales, so avoid a test portion in that case.
* tests/misc/wc-files0.sh: Avoid a bug on older ash implementations.
Addresses http://bugs.gnu.org/28054
2017-08-19 15:36:54 -07:00
Paul Eggert
1d9765a764 ptx: fix some integer overflow bugs
Problem reported by Lukas Zachar at:
http://bugzilla.redhat.com/1482445
* src/ptx.c (line_width, gap_size, maximum_word_length)
(reference_max_width, half_line_width, before_max_width)
(keyafter_max_width, truncation_string_length, compare_words)
(compare_occurs, search_table, find_occurs_in_text, print_spaces)
(fix_output_parameters, define_all_fields):
Use ptrdiff_t, not int, for object offsets and sizes.
(WORD, OCCURS): Use ptrdiff_t, not short int.
(WORD_TABLE, number_of_occurs, generate_all_output):
Prefer ptrdiff_t to size_t where either will do.
(total_line_count, file_line_count, OCCURS, fix_output_parameters)
(define_all_fields):
Use intmax_t, not int, for line counts.
(DELTA): Remove.  All uses changed.
(OCCURS, find_occurs_in_text, fix_output_parameters):
Use int, not size_t, for file indexes.
(tail_truncation, before_truncation, keyafter_truncation)
(head_truncation, search_table, define_all_fields)
(generate_all_output):
Use bool for booleans.
(digest_word_file, find_occurs_in_text):
Use x2nrealloc instead of checking for overflow by hand.
(find_occurs_in_text, fix_output_parameters, define_all_fields):
Omit unnecessary cast.
(fix_output_parameters): Don’t assume integers fit in 11 digits.
(fix_output_parameters, define_all_fields):
Use sprintf return value rather than calling strlen.
(define_all_fields): Do not rely on sprintf to generate a string
that may contain more than INT_MAX bytes.
(main): Use xstrtoimax, not xstrtoul.
Use xnmalloc to catch integer overflow.
2017-08-17 12:03:03 -07:00
Paul Eggert
74fcbe5225 nohup: simplify by using fcntl
* src/nohup.c: Do not include cloexec.h.
(main): Use fcntl rather than dup + set_cloexec_flag.
2017-08-17 12:03:03 -07:00
Paul Eggert
1a210762d5 sort: use pthread_sigmask, not sigprocmask
POSIX says sigprocmask has unspecified behavior in a multithreaded
program like ‘sort’.
* src/sort.c (pthread_sigmask) [GNULIB_defined_pthread_functions]:
New macro, for use when ‘sort’ is not multithreaded.
(cs_enter, cs_leave): Use it.  Pass address, not value, as
this is typically a tad faster.  All callers changed.
2017-08-17 12:03:03 -07:00
Paul Eggert
dae474bf9b sort: minor cleanups
* src/sort.c (move_fd): Rename from move_fd_or_die,
since it no longer can die.
2017-08-17 12:03:03 -07:00
Paul Eggert
717f1d02e1 sort: file descriptor discipline
Use O_CLOEXEC when creating file descriptors, so that subsidiary
processes do not inherit file descriptors that they do not need.
This is helpful for ‘sort’, as it is a multithreaded program that
forks and execs.
* bootstrap.conf (gnulib_modules): Add mkostemp, open, pipe2.
* src/sort.c (create_temp_file): Open temporary file with O_CLOEXEC.
(stream_open): Open the stream with O_CLOEXEC.
(pipe_fork): Create the pipe with O_CLOEXEC.
(check_output): Open the output file with O_CLOEXEC.
(main): Use xfopen/xfclose to handle --files0-from, so that
O_CLOEXEC is used properly.  This is simpler anyway.
* tests/misc/sort-files0-from.pl: Adjust to change in diagnostic
wording.
2017-08-17 12:03:03 -07:00
Paul Eggert
72f1751f60 build: update gnulib submodule to latest 2017-08-17 12:03:02 -07:00
Pádraig Brady
900b5621e6 kill: fix signal number to name lookup on AIX
* src/operand2sig.c (operand2sig): AIX uses a different bit pattern
in the returned status from the wait() functions and from shells.
Therefore hardcode the selection of the lower bits of the number.
* NEWS: Mention the fix.
2017-08-13 21:33:01 -07:00
Pádraig Brady
45d1957ce8 build: use the appropriate single file include option with xlc
* configure.ac: Set USE_XLC_INCLUDE when __xlc__ is defined.
* src/local.mk: Use it to select the appropriate include option.
Reported by Michael Felt.
2017-08-13 21:33:01 -07:00
Pádraig Brady
cc721e9b7b tests: avoid false failures on AIX
* tests/ln/sf-1.sh: Limit the symlink size to 1MiB
to avoid memory exhaustion seen on NFS on AIX, giving:
  + printf '%0*d' 4294967296 0
  + ./tests/ln/sf-1.sh: line 38: printf: warning: 0: Result too large
* tests/id/setgid.sh: Skip the test when the adjusted gid
would equal 4294967295, as that's reserved on AIX.
Reported by Michael Felt.
2017-08-13 21:33:01 -07:00
Pádraig Brady
787a8876fa sort: handle musl locale differences in --debug reporting
* src/sort.c (main): Don't assume hard_LC_COLLATE implies
a successful setting of the locale as musl defaults to
UTF8 when failing to set the specified locale.
* tests/misc/sort-debug-warn.sh: Adjust for the now
separated locale debug info and map the musl specific
message back to the common case.
Addresses https://bugs.gnu.org/28054
2017-08-13 21:32:11 -07:00
Pádraig Brady
ae15011284 seq: produce consistent error messages upon write error
* src/seq.c (io_error): Use the same error message as would
be generated at exit time when closing the stdout stream.
The inconsistency was added with commit v8.25-26-gc92585b.
This was noticed due to an inconsistency in the expected
error message generated by seq on musl libc.
Addresses https://bugs.gnu.org/28054
2017-08-13 21:31:57 -07:00
Pádraig Brady
c81dda1b39 tests: fix false failure with large printf formats
* tests/misc/printf-surprise.sh: With musl libc the
large printf format does succeed, outputting data.
To avoid SIGPIPE being generated we ignore that signal
and then handle the subsequent EPIPE error.
Addresses https://bugs.gnu.org/28054
2017-08-13 21:31:28 -07:00
Jim Meyering
96101eef33 build: adjust warning options to work with latest GCC
* configure.ac: Disable some new warnings to avoid false positives.
Building with warnings enabled and latest gcc would evoke build
failure without these changes.  Disable the following in coreutils
proper: -Wformat-overflow=2 -Wformat-truncation=2, and
disable these for gnulib: -Wformat-truncation=2 -Wduplicated-branches
2017-08-12 13:51:19 -07:00
Jim Meyering
0b7fababf8 gnulib: update to latest and adjust gl/modules/tempname.diff
* gnulib: Update to latest.
* gl/modules/tempname.diff: This patch failed to apply.
Adjust it to reflect removal of the secure_getenv dependency.
2017-08-12 13:24:29 -07:00
Jim Meyering
e9ba42e9bf chroot: fix typo in preceding change: didn't compile
* src/chroot.c (usage): Add backslashes.
2017-08-11 17:48:47 -07:00
Jim Meyering
9bf4361f4d doc: correct technicality in chroot's --help output
* src/chroot.c (usage): Use correct quoting in descriptive diagnostic.
We would run `"$SHELL" -i`, not `${SHELL} -i`.
2017-08-10 09:18:58 -07:00
Assaf Gordon
8e2929a29b doc: fix join example
* doc/coreutils.texi (join invocation): Fix incorrect output in example.
Reported by Phlosioneer in https://bugs.gnu.org/28014 .
2017-08-08 22:04:57 -06:00
Paul Eggert
fd7ac4402b build: update gnulib submodule to latest 2017-08-03 16:34:17 -07:00
Paul Eggert
b6ab084421 copy: more-accurate warning about destruction
* src/copy.c (copy_internal):
* tests/cp/backup-is-src.sh, tests/mv/backup-is-src.sh:
Say "might destroy", not "would destroy".
2017-08-03 13:46:36 -07:00
Pádraig Brady
81a05b32f7 maint: avoid a syntax-check failure
* src/shred.c (wipename): As per the comment, the arguments
to error() are sufficiently quoted, so split the call over
multiple lines to avoid the syntax-check.
2017-08-02 20:21:20 -07:00
Paul Eggert
1af3fb93f8 build: update gnulib submodule to latest 2017-08-02 11:14:21 -07:00
Paul Eggert
a04039284c copy: go back to failing 'cp --backup a~ a'
Suggested by Kamil Dudka in:
http://lists.gnu.org/archive/html/coreutils/2017-07/msg00072.html
* NEWS: Document the changed nature of the fix.
* doc/coreutils.texi, tests/cp/backup-is-src.sh:
* tests/mv/backup-is-src.sh: Revert previous change.
* src/copy.c (source_is_dst_backup): New function.
(copy_internal): Use it.  Fail instead of falling back on numbered
backups when it looks like the backup will overwrite the source.
Although this reintroduces a race, it's more compatible with
previous behavior.
2017-08-01 13:18:45 -07:00
Paul Eggert
e01bb64aeb copy: sanity-check --suffix
* src/cp.c, src/install.c, src/ln.c, src/mv.c (main):
Use set_simple_backup_suffix, to sanity-check the user-supplied
backup suffix.
2017-07-30 17:18:31 -07:00
Paul Eggert
0d74ac470f copy: make backup files more reliably
* NEWS, doc/coreutils.texi (Backup options): Document the change.
* bootstrap.conf (gnulib_modules): Add backup-rename.
* src/copy.c (copy_internal): Silently switch to numbered backups
if a simple backup might lose data.  Use backup_file_rename
to avoid races with numbered backups.
* tests/cp/backup-is-src.sh, tests/mv/backup-is-src.sh:
Adjust to match new behavior.
2017-07-30 17:18:31 -07:00
Paul Eggert
2ae1460dad shred: avoid rename race
Use renameat2 to avoid a rename race condition, on recent-enough
GNU/Linux.
* bootstrap.conf (gnulib_modules): Add renameat2.
* src/shred.c: Include renameat2.h.
(wipename): Use renameat2 instead of rename.
2017-07-30 17:18:31 -07:00
Paul Eggert
ac6956bbce build: update gnulib submodule to latest 2017-07-30 17:18:31 -07:00
Jim Meyering
c8ee5f19e8 maint: fix grammar in a shred.c comment
* src/shred.c: Remove spurious "to" in an old comment.
2017-07-24 17:55:26 -07:00
Pádraig Brady
5744964496 maint: fix recent syntax-check failures
* .gitignore: Add /lib/utime.h from the recent gnulib update.
* src/nproc.c (usage): Adjust spacing to placate help2man.
2017-07-23 12:32:29 -07:00
Pádraig Brady
79c8041a84 shred: remove redundant zeroing of freed memory
* src/shred.c (dopass): shred used to read the input file,
and so needed to ensure internal memory was cleared.
This is no longer the case since SH-UTILS-1_16f-260-gf381610
so avoid this redundant clearing.
(do_wipefd): Likewise.
* NEWS: Remove the recent mention of this issue.
2017-07-23 12:26:22 -07:00
Pádraig Brady
8b1c6eebac maint: resync with blake2 upstream
* src/blake2/blake2-impl.h: Don't use the equivalent explicit_bzero().
2017-07-23 12:25:40 -07:00
Pádraig Brady
388e150792 tests: avoid a false failure on AIX
* tests/misc/sync.sh: Normalize the error messages
when syncing a non read/write directory, as AIX
gives the "Is a directory" error.
Also ensure that sync(1) returns an error for this
case on all systems.
2017-07-23 12:23:31 -07:00
Paul Eggert
73d55732df shred: use explicit_bzero
* NEWS: Document this.
* bootstrap.conf (gnulib_modules): Add explicit_bzero.
* gl/lib/randint.c (randint_free):
* gl/lib/randread.c (randread_free):
* src/blake2/blake2-impl.h (secure_zero_memory):
* src/shred.c (dopass, do_wipefd):
Prefer explicit_bzero to memset when erasing secrets.
2017-07-20 14:02:47 -07:00
Paul Eggert
b05d02318c build: update gnulib submodule to latest 2017-07-20 14:02:46 -07:00
Andreas Schwab
545f181f4e nproc: fix indentation of usage output
* src/nproc.c (usage): Align output.
2017-07-10 09:40:03 -07:00
Jim Meyering
83ed661947 groups: do not exit early
Most programs take care to operate on all command-line-specified
operands before exiting.  That is an important feature that allows
to identify all problems with the first run.  However, groups would
exit upon the first problematic user name.
Bug introduced via commit v6.10-56-g167b8025ac.
* src/groups.c (main): Do not exit immediately upon error.
* tests/misc/groups-process-all.sh: New file. Test for this.
* tests/local.mk (all_tests): Add it.
* NEWS (Bug fixes): Mention this.
2017-07-10 10:17:57 +02:00
Jim Meyering
ed57568ea5 tests: groups-dash.sh: avoid false failure
* tests/misc/groups-dash.sh: Avoid false failure on a system for which
"none" is a valid user name.  The first invocation would succeed, and
the second would fail with "groups: ‘--’: no such user".
Use a user name that cannot exist.
2017-07-08 18:41:16 +02:00
Jim Meyering
df2c30dca6 doc: tweak wording
* NEWS (Bug fixes): Tweak wording of the mv/cp-vs-symlink-ownership
entry and the one about df.
2017-07-08 18:41:16 +02:00
Assaf Gordon
a9f2be5bfe expr: add multibyte support
Discussed in https://bugs.gnu.org/26779 .

* NEWS: Mention the improvement.
* bootstrap.conf: Add gnulib modules mbslen,mbschr.
* src/expr.c (mbs_logical_substr): New function to return a substring
based on logical character positions (instead of bytes).
(mbs_logical_cspn): Similar to strcspn/mbscspn, but returns number of
logical characters instead of byte offset.
(mbs_offset_to_chars): New function to return number of logical
characters fitting in a given byte offset.
(docolon): Report matched logical characters instead of bytes.
(eval6): For length/substr/index operations, use logical characters
instead of bytes by calling the above new functions.
* tests/misc/expr.pl: Repeat all tests with non-C locale to detect any
regressions.
* tests/misc/expr-multibyte.pl: New tests with multibyte input.
* tests/local.mk: Add new test file.
2017-06-28 01:23:52 +00:00
Jim Meyering
e13fe20049 maint: avoid spurious "make distcheck" failure
When the generated file, doc/constants.texi, happens to be older than
doc/coreutils.info, it will not be updated until/unless its generated
contents change.  This is due to way that rule is careful to update
the file, to avoid provoking a pointless rerunning of makeinfo.

Note that this does not happen when one first runs "make distclean",
as recommended in README-release.  However, I sometimes run it as
a more-rigorous "make check", and shouldn't have to manually run
"make distclean" first, in that case.

Before this change, one could reproduce the failure by running
`touch -dyesterday doc/constants.texi && make distcheck`.  It would
fail with "makeinfo: could not open ../../doc/coreutils.info-t
for writing: Permission denied"
* Makefile.am (dist-hook): Touch the two generated files, so that
they cannot be out of date wrt doc/coreutils.texi.
2017-06-20 16:01:39 -07:00
Pádraig Brady
1379bdc65b maint: use C99 for loop initial declarations where possible
This results in a net reduction of about 120 lines.
2017-06-17 15:51:59 -07:00
Pádraig Brady
18f6b22fe1 tail: only use inotify with regular files
* src/tail.c (any_non_regular): A new function to check passed files.
(main): Use the above to skip inotify if any non regular files passed
like /dev/tty or /dev/ttyUSB0 etc.
* tests/tail-2/inotify-only-regular.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/21265 and http://bugs.gnu.org/27368
2017-06-17 14:50:04 -07:00
Pádraig Brady
aab875a40b tail: with -f don't warn if doing a blocking read of a tty
* src/tail.c: (main): Only issue the warning about -f being
ineffective when we're not going into simple blocking mode.
* tests/tail-2/follow-stdin.sh: Ensure the warning is output correctly.
Fixes http://bugs.gnu.org/27368
2017-06-17 14:50:00 -07:00
Pádraig Brady
ce0415fda1 tail: exit promptly when output no longer writable
This will support use cases like:

  tail -f file.log | grep -q trigger &&
  process_immediately

* src/tail.c (check_output_alive): A new function that
uses select on fifos or pipes to detect if they're broken.
(tail_forever): Call check_output_alive() periodically.
(tail_forever_inotify): Merge the select() call from
check_output_alive() into the select() originally present
for the --pid case, and adjust accordingly.
* tests/tail-2/pipe-f.sh: Add test cases.
* NEWS: Mention the improvement.
2017-06-11 15:05:14 -07:00
Jim Meyering
28042c4ff5 maint: update to work with GCC7's -Werror=implicit-fallthrough=5
* src/system.h (FALLTHROUGH): Define.
* src/cp.c (main): Use new FALLTHROUGH macro in place of comments.
* src/basename.c (main): Likewise.
* src/dircolors.c (append_quoted): Likewise.
* src/echo.c (main): Likewise.
* src/fold.c (main): Likewise.
* src/join.c (main): Likewise.
* src/kill.c (main): Likewise.
* src/ls.c (get_funky_string, gobble_file): Likewise.
* src/sort.c (parse_field_count, main): Likewise.
* src/stat.c (print_it): Likewise.
* src/tail.c (parse_obsolete_option): Likewise.
* src/test.c (posixtest): Likewise.
* src/wc.c (wc): Likewise.
* src/who.c (main): Likewise.
2017-06-10 19:40:49 -07:00
Pádraig Brady
ba16bdd890 tail: with --pid, ensure all inotify events are processed
* NEWS: Mention the bug fix.
* src/tail.c (tail_forever_inotify): With --pid, avoid waiting
for new events if there are still events to process.
* tests/tail-2/inotify-dir-recreate.sh: Adjust to trigger.
2017-06-07 10:09:46 -07:00
Pádraig Brady
fd41e49973 tests: fix issues with recently added tail test
* tests/tail-2/inotify-dir-recreate.sh: Skip when
inotify is not usable.  Also remove a bash specific &> construct.
2017-06-07 00:03:37 -07:00
Pádraig Brady
f1de9740e6 copy: don't fail when unable to chown symlinks
* src/copy.c (copy_internal): Honor the x->require_preserve flag
for symlinks as we do for ordinary files, so we don't exit with
failure upon failure to chown a symbolic link.
* NEWS: Mention the bug fix.
2017-06-02 21:54:03 -07:00
Sebastian Kisela
6ebaf81950 doc: mention setpriv --no-new-privs feature in runcon info
* doc/coreutils.texi (runcon invocation): Mention setpriv usage.
Discussed at https://bugzilla.redhat.com/1360903
2017-05-29 12:42:00 -07:00
Pádraig Brady
62c6f1fc78 mv: distinguish copy and rename operations with --verbose
* src/copy.c (copy_internal): In x->move_mode distinguish
whether we're copying, creating directory, or renaming.
* tests/mv/backup-dir.sh: Adjust to new output.
* tests/mv/mv-n.sh: Likewise.
* tests/mv/mv-special-1.sh: Likewise.
* NEWS: Mention the improvement.
Fixes http://bugs.gnu.org/26971
2017-05-18 02:08:42 +01:00
Prateek saxena
82911c51ae uptime: remove inconsistent AM/PM from current time
* src/uptime.c (main): 00-23 was always used for the hour component
of the current time, so remove the AM/PM output (which was only
present in some locales anyway).  Also add seconds to the time
to be more consistent with the usual procps-ng uptime implementation
on GNU/Linux.
* NEWS: Mention the fix.
Fixes http://bugs.gnu.org/26783
2017-05-11 12:54:29 +01:00
Pádraig Brady
42192c5177 maint: fix various typos in recent commits
* NEWS: Grammar fixes.
* HACKING: Likewise.
2017-05-03 18:23:17 -07:00
Jaak Ristioja
b359661725 doc: Fixed typo in timeout man page
* man/timeout.x: Correct spelling of "currently".
Fixes http://bugs.gnu.org/26762
2017-05-03 18:17:48 -07:00
Pádraig Brady
d91e912343 doc: update the instructions for generating a coverage report
* HACKING: Change from explicit instructions to using gnulib
provided coverage testing targets.  Also include instructions
for adding root only tests to the report.
Fixes http://bugs.gnu.org/26709
2017-04-29 20:56:10 -07:00
Paul Eggert
7ea15a57c7 dd: simplify translator’s jobs
* src/dd.c (print_xfer_stats): Format the SI units directly,
without translating them, to simplify the translators’ jobs.
See Bug#26621.
2017-04-27 14:49:43 -07:00
Pádraig Brady
9287ef2b17 date,touch: test and document large TZ security issue
Add a test for CVE-2017-7476 which was fixed in gnulib at:
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=94e01571

* tests/misc/date-tz.sh: Add a new test which overwrites enough
of the heap to trigger a segfault, even without ASAN enabled.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
2017-04-26 21:49:12 -07:00
Pádraig Brady
5d4be52a98 build: update gnulib submodule to latest
* .gitignore: Add new entry as indicated by `make syntax-check`.
2017-04-26 21:49:06 -07:00
Paul Eggert
d1f5616b2d dd: status=progress outputs "6 s", not "6.00001 s"
Problem reported by Benno Schulenberg (Bug#26621).
* NEWS: Document this.
* src/dd.c (print_xfer_stats): With status=progress,
format times with %.0f rather than %g.  Improve
translator comments.
2017-04-24 00:32:15 -07:00
Paul Eggert
ed0b8f195a build: update gnulib submodule to latest 2017-04-22 15:18:51 -07:00
Paul Eggert
28b677c014 maint: remove unused functions and constants
These were found by clang.
* gl/lib/rand-isaac.c (min):
* gl/lib/randint.c (shift_right):
* src/md5sum.c (algorithm):
Remove; unused.
2017-04-22 02:47:21 -07:00
Paul Eggert
e97ee26c88 date: adjust to gnulib parse-datetime changes
* doc/coreutils.texi (Options for date): Capitalize a sentence.
* tests/misc/date-debug.sh: Adjust --debug output to match
recent changes to Gnulib’s parse-datetime module.
2017-04-22 02:47:21 -07:00
Paul Eggert
a750b6cfc3 build: update gnulib submodule to latest
* gl/modules/tempname.diff: Update to match current Gnulib.
2017-04-22 02:47:20 -07:00
Bogdan Drozdowski
f4570a9ed6 shred: fix invalid pattern generation for certain sizes
* src/shred.c (fillpattern): Fix the "off by one" issue when
testing whether we have enough space to copy the already
written portion of the buffer to the remainder of the buffer.
Specifically for buffer sizes that are (3*(2^x))+1, i.e. 7,13,...
we both use an uninitialized byte and invoke undefined
behavior in memcpy() operation on overlapping memory regions.
* tests/misc/shred-passes.sh: Add an invocation that will
trigger either valgrind UMR, or ASAN like:
  ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges
  #1 0x403065 in fillpattern src/shred.c:293
A direct test is awkward due to the random writes surrounding
the problematic pattern writes.
Fixes http://bugs.gnu.org/26545
2017-04-17 19:44:30 -07:00
Bo Rydberg
8d34b455f8 doc: fix awk example for getting penultimate field
* doc/coreutils.texi (cut invocation): Add required brackets.
Fixes http://bugs.gnu.org/26519
2017-04-16 19:10:17 -07:00
Sebastian Kisela
ba5fe2d4b8 tail: revert to polling if a followed directory is replaced
* src/tail.c (tail_forever_inotify): Add the IN_DELETE_SELF flag when
creating watch for the parent directory.  After the parent directory
is removed, an event is caught and then we switch from inotify to
polling mode.  Till now, inotify has always frozen because it waited for
an event from a watched dir, which has been already deleted and was not
added again.
* tests/tail-2/inotify-dir-recreate.sh: Add a test case.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/26363
Reported at https://bugzilla.redhat.com/1283760
2017-04-05 17:45:17 -07:00
Pádraig Brady
2c622e11f4 maint: fix syntax-check issues in previous tty commit
* src/tty.c: Avoid EXIT_FAILURE to be more descriptive
and to placate sc_some_programs_must_avoid_exit_failure.
2017-04-05 16:19:04 -07:00
Paul Eggert
937388c305 tty: handle misconfigured namespaces
On some platforms, isatty succeeds but ttyname fails.
POSIX does not seem to allow this, but there it is.
Problem reported by Christian Brauner (Bug#26371).
While we’re at it, check for errors more carefully and return a
new exit status 4 if stdin is closed or a similar error occurs.
* doc/coreutils.texi (tty invocation): Document new behavior.
* init.cfg (stderr_fileno_):
Don't assume have_input_tty is not in the environment.
* src/tty.c (TTY_STDIN_ERROR): New constant.
(main): Exit with nonzero status if there is a usage error,
like other coreutils programs.
Check for error in getting stdin type.
* tests/misc/tty.sh: New file.
* tests/local.mk (all_tests): Add it.
2017-04-05 11:35:35 -07:00
Pádraig Brady
4c85c757e5 doc: refactor and update expand and unexpand --help
* src/expand-common.c (emit_tab_list_info): A new function to
output the extended info on --tab=LIST, including the new
'+' and '/' prefixes.
* src/expand-common.h: Declare the above.
* src/expand.c (usage:): Call emit_tab_list_info and
match alignment with that used in unexpand --help.
* src/unexpand.c (usage): Likewise.
2017-04-02 16:52:34 -07:00
Jacob Keller
9daef34543 expand,unexpand: add support for incremental tab stops
Support --tabs="1,+8" which is equivalent to --tabs="1,9,17,..."
useful for viewing unified diff output with its 1 character
gutter for example.

* doc/coreutils.texi ({expand,unexpand} invocation): Document,
using diff processing as the example.
* src/expand-common.c (set_increment_size): Update the new
increment_size global.
(parse_tab_stops): Handle the new '+' prefix.
(finalize_tab_stops): Verify both '+' and '/' prefixes
are not used together.
* tests/misc/expand.pl: Add test cases.
* NEWS: Mention the new feature.
2017-04-02 16:35:08 -07:00
Paul Eggert
c7bcea1b78 sort: update comment
* src/sort.c: Update identifiers in comment.
2017-03-30 08:29:28 -07:00
Chris Davies
c1c558e050 doc: clarify in dd man page that bs= overrides [io]bs=
* src/dd.c (usage): Add the extra info.
Reported in https://bugs.debian.org/859021
2017-03-29 19:03:23 -07:00
Ludovic Courtès
f542200938 tests: avoid false ulimit failure on some systems
* tests/misc/cut-huge-range.sh: On some systems returns_ may
use more memory, so incorporate that in the determination
of the ulimit value to use.  Noticed on ARMv7 with bash-4.4.12,
and x86_64 with bash-4.2.37.
Fixes http://bugs.gnu.org/26253
2017-03-27 21:23:07 -07:00
Pádraig Brady
a5239412c1 maint: avoid syntax check failure with wrapped returns_
* cfg.mk (sc_prohibit_env_returns): Allow wrapped calls to
return_ of the form: `wrapper_ returns_ ...` which is needed
with the following commit.
2017-03-27 21:23:07 -07:00
Michael Heimpold
73c8452e83 split: add new --hex-suffixes option
* doc/coreutils.texi (split invocation): Document the new option.
* src/split.c (usage): Likewise.
(main): Process the new option much like --numeric-suffixes,
but with an adjusted alphabet.
* tests/split/numeric.sh: Refactor to support --hex mode.
* NEWS: Mention the new feature.
2017-03-27 20:32:58 -07:00
Pádraig Brady
264f5446cd md5sum,b2sum,sha*sum: don't erroneously trigger BSD reversed mode
* src/md5sum.c (split_3): Verify hex digits internally before
triggering the global bsd_reversed mode flag.
(bsd_split_3): Likewise.
* tests/misc/md5sum-bsd.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/26263
2017-03-27 20:32:58 -07:00
Philipp Thomas
7c228bc55e df: avoid querying excluded file systems
* src/df.c (filter_mount_list): Avoid stat() on
explicitly excluded file systems, which is especially
significant in cases like `-x nfs` which may hang.
* NEWS: Mention the bug fix.
2017-03-26 22:48:33 -07:00
Pádraig Brady
8e7bcdd806 maint: avoid a static analysis warning in expand-common
* src/expand-common.c (next_file): We're dependent on calling
this function with NULL to initialize things appropriately.
So enforce this with assert(), which avoids a warning from
clang-anaylzer.
2017-03-26 15:20:26 -07:00
Pádraig Brady
0839e6d8d9 split: process more efficiently when filters exit early
* src/split.c (bytes_split): Don't write to an existing filter
if it has exited.  When filters exit early, skip input data if
possible.  Refactor out 2 redundant variables.
* tests/split/filter.sh: Improve test coverage given the
new more efficient processing.  Also use a 10TB file to
expand the file systems tested on.
2017-03-26 15:20:26 -07:00
Pádraig Brady
a79dbb97bf split: ensure input is processed when filters exit early
commit v8.25-4-g62e7af0 introduced the issue as it
broke out of the processing loop irrespective of
the value of new_file_flag which was used to indicate
a finite number of filters or not.

For example, this ran forever (as it should):
  $ yes | split --filter="head -c1 >/dev/null" -b 1000
However this exited immediately due to EPIPE being propagated
back through cwrite and the loop not considering new filters:
  $ yes | split --filter="head -c1 >/dev/null" -b 100000

Similarly processing would exit early for a bounded number of
output files, resulting in empty data sent to all but the first:
  $ truncate -s10T big.in
  $ split --filter='head -c1 >$FILE' -n 2 big.in
  $ echo $(stat -c%s x??)
  1 0

I was alerted to this code by clang-analyzer,
which indicated dead assigments, which is often
an indication of code that hasn't considered all cases.

* src/split.c (bytes_split): Change the last condition in
the processing loop to also consider the number of files
before breaking out of the processing loop.
* tests/split/filter.sh: Add a test case.
* NEWS: Mention the bug fix.
2017-03-26 15:20:23 -07:00
Pádraig Brady
04148c99c5 tests: avoid a false failure on OS X 10.5.8
* tests/misc/sort-debug-keys.sh: Disparate LC_CTYPE and LC_MESSAGES
are not supported, with the result LC_MESSAGES=C is used throughout.
Therefore just set LC_ALL in the test, and normalize the message
variants with sed.
Reported and tested by J Rogowsky.
2017-03-11 10:48:10 -08:00
Pádraig Brady
e3c51a3357 build: fix missing renameat() on OS X 10.5.8
* bootstrap.conf: Depend on renameat.
Reported and tested by J Rogowsky.
Fixes http://bugs.gnu.org/26044
2017-03-10 21:23:12 -08:00
Paul Eggert
612086660b tests: port to tzdb-2017a
Problem reported by Bernhard Voelker in:
http://lists.gnu.org/archive/html/coreutils/2017-03/msg00026.html
* tests/misc/date-debug.sh: Port test to tzdb 2017a,
and future-proof the America/Belize test.
2017-03-09 23:59:39 -08:00
Pádraig Brady
51d7a16c12 build: for factor use C in more cases for arm64 and ppc64
* src/longlong.h: Sync from gmp repo incorporating:
Use asm-free umul_ppmm() on arm64 and ppc64.
2017-03-08 23:02:06 -08:00
Pádraig Brady
6b5d38d850 doc: rearrange a recent bug entry to an improvement in NEWS
* NEWS: The stat,tail change was an improvement, not a bug fix.
* cfg.mk [old_NEWS_hash]: update with `make update-NEWS-hash`.
2017-03-08 22:59:42 -08:00
Pádraig Brady
93509ff8b5 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2017-03-08 21:25:35 -08:00
Pádraig Brady
3df84f0492 version 8.27
* NEWS: Record release date.
2017-03-08 21:00:00 -08:00
Pádraig Brady
3308cdaf9f build: update gnulib submodule to latest
Removes extraneous parse-datetime.c generated during build
2017-03-08 20:18:58 -08:00
Pádraig Brady
79a5cb161d stat,tail: support "RDT" Linux kernel control file system
* src/stat.c (human_fstype): This file system is the user interface
for resource allocation in Intel's Resource Director Technology.
2017-03-08 17:55:09 -08:00
Pádraig Brady
280d421375 doc: spelling fix for recent doc addition
* doc/coreutils.texi (join invocation): s/preceeding/preceding/.
2017-03-08 17:25:58 -08:00
Bernhard Voelker
6dc540ed7a build: avoid redundant build of tr with --enable-single-binary
* src/local.mk [check-duplicate-no-install]: Depend on the
single-binary tr, or the system tr, as the edge case
where these are not available only result in the sanity
check being effectively ignored.
2017-03-07 21:34:06 -08:00
Assaf Gordon
6fc3ef9e6f build: fix 'install-html' target
Switching to non-recursive makefiles broke the 'install-html' target:
The gettext plumbing requires an 'install-html' target in po/Makefile.
This was fixed in gettext v0.19.8.1-41-ge5a008a, but packages using
older gettext need to manually patch po/Makefile.in.in.
Reported (for 'sed') and suggested fix by Eric Blake in
https://bugs.gnu.org/25690 .

* bootstrap.conf (bootstrap_epilogue): Add 'install-{html,pdf,dvi,ps}'
  targets to po/Makefile.in.in (if needed).
2017-03-08 00:56:04 +00:00
Pádraig Brady
ddbe4b7a37 maint: bump makeinfo --version requirement to 6.1
* bootstrap.conf: s/4.13/6.1/ as versions previous to that
generated invalid html with interspersed <span> tags that
were visible to the user.  Version 6.1 is available for a
year now, and is available in most distros.
2017-03-04 14:11:43 -08:00
Bernhard Voelker
fe8cc1ddaa doc: avoid makeinfo warning
makeinfo issues the following:

  doc/coreutils.texi:6568: warning: @sc argument all uppercase,\
    thus no effect.

* doc/coreutils.texi (join invocation): Remove the @sc macro around
the all uppercase "GNU".
2017-03-04 14:00:24 -08:00
Pádraig Brady
10d1d203a4 build: update gnulib submodule to latest
Fixes a test-lock failure on MacOS
2017-03-03 09:02:52 -08:00
Pádraig Brady
6555f41883 timeout: handle multiple children on solaris
* src/timeout.c (install_sigchld): A new function to
install the SIGCHLD handler using sigaction() rather
than signal(), because with the latter on solaris
the signal handler is reset to default and thus
sigsuspend() only returns for the first finished child.
Reported by Assaf Gordon.
2017-03-03 00:30:20 -08:00
Pádraig Brady
28803c8a31 tests: avoid a spurious failure on older debian
* tests/misc/cut-huge-range.sh: Bump up the ulimit,
to avoid a false failure due hitting the previously
detected ulimit.
Reported by Assaf Gordon.
2017-03-03 00:25:54 -08:00
Pádraig Brady
b88e4dd3c6 build: fix libstdbuf build on AIX 7
* src/libstdbuf.c: undef malloc so as libstdbuf is
not linked with gnulib, and anyway the replacement is
never needed since we never malloc(0).
Reported by Assaf Gordon.
2017-03-03 00:23:56 -08:00
Assaf Gordon
00381d22d4 doc: expand 'join' info section
* doc/coreutils.texi (join invocation): Expand section to
add examples and more details.
Suggested by Dan Jacobson in https://bugs.gnu.org/25870
2017-03-01 18:47:24 -08:00
Pádraig Brady
8b22614b9a doc: give a stronger security warning in md5/sha1 man pages
* man/md5sum.x: Give a more direct warning againt the use
of this hash algorithm for security purposes.
* man/sha1sum.x: Likewise.
Suggested by Jim Meyering.
2017-03-01 09:33:29 -08:00
Pádraig Brady
3be3da3bec expand: avoid an extraneous warning on 32 bit
* src/expand-common (parse-tab-stops): Exit earlier upon overflow
so another warning isn't issued (on 32 bit) in add_tab_stop().
Flagged in https://hydra.nixos.org/build/49499970
2017-03-01 09:25:28 -08:00
Pádraig Brady
109ba4441b doc: indicate sha1 has the same limitations as md5
* doc/coreutils.texi (sha1sum invocation): Given that a SHA-1
preimage attack has occurred as documented at http://shattered.io/,
document sha1sum as having the same limitations as md5sum.
(md5sum): Parameterize the warning for use in both cases.
* man/md5sum.x: Mention b2sum(1) as a more secure alternative.
* man/sha1sum.x: Give the same warning as done for md5sum(1).
2017-02-28 20:24:47 -08:00
Pádraig Brady
06c3123f6e maint: avoid a -Werror=null-dereference with GCC-6.3.1
* src/stty.c (sane_mode): Assert to inform the compiler
we know the pointer will be valid.
2017-02-28 19:26:04 -08:00
Pádraig Brady
b1413b6011 expand,unexpand: support specifying a trailing tab size
* doc/coreutils.texi (expand invocation): Document the feature.
(unexpand invocation): Likewise.
* src/expand-common.c (extend_size): A new global to use
when the last tab stop is prefixed by '/'.
(set_extend_size): A new function to validate and set
the new extend_size global.
(parse_tab_stops): Call set_extend_size() for '/' prefixes.
(finalize_tab_stops): Ensure a single specified '/' is
treated like a standard tabsize, but also ensure that
when '/' is specified with a single other entry that
we process as a list rather than a tab size.
(get_next_tab_stop): Use the tab size if set,
for items after the user specified tab position list.
* tests/misc/expand.pl: Add test cases
* NEWS: Mention the new feature.
Fixes http://bugs.gnu.org/25540
2017-02-28 19:26:01 -08:00
Pádraig Brady
9404382f6b nproc: support OMP_THREAD_LIMIT to set a max value
This comes from the latest gnulib.
Also handling of OMP_NUM_THREADS has been adjusted
to support comma separated values indicating a nesting level,
in which case the first value is taken.  Also OMP_NUM_THREADS=0
is now ignored instead of being treated as 1, to match
the behavior of libgomp.

* NEWS: Mention the OMP_THREAD_LIMIT improvement,
and OMP_NUM_THREADS now handling nested values.
* doc/coreutils.texi (nproc invocation): Describe OMP_THREAD_LIMIT
as a way to set the max value, with OMP_THREAD_LIMIT setting the min.
* tests/misc/nproc-override.sh: A new test to exercise the
updated gnulib code with all combinations of these OMP variables.
* tests/local.mk: Reference the new test.
2017-02-26 09:31:50 -08:00
Pádraig Brady
e1d1b4f497 build: update gnulib submodule to latest 2017-02-26 07:07:20 -08:00
Pádraig Brady
509152bdd4 doc: add NEWS for an improvement to dd in the last release
* NEWS: Mention the avoidance of the gotcha with specifying
a hex constant like count=0x1000 etc. as that previously
was silently interpreted as 0.
2017-02-22 20:54:17 -08:00
Pádraig Brady
db277d6077 cp: set SELinux context for --parents directories
* src/copy.c (set_process_security_ctx, set_file_security_ctx):
Export for use in cp.c.
* src/copy.h: Likewise.
* src/cp.c (make_dir_parents_private): Call the exported functions
to set the security context for new and updated directories.
* tests/cp/cp-a-selinux.sh: Add a test case.

Fixes http://bugs.gnu.org/25378
2017-02-22 20:23:31 -08:00
Pádraig Brady
e4a4427502 maint: tweaks so syntax tests pass for previous commit
* .gitignore: placate sc_gitignore_redundant.
* po/POTFILES.in: placate sc_po_check.
2017-02-17 19:36:58 -08:00
Bernhard Voelker
cc3085bae4 doc: avoid makeinfo warning
Commit v8.26-38-g99deaff introduced this warning:

    MAKEINFO doc/coreutils.info
  ./doc/coreutils.texi:10268: \
    warning: `.' or `,' must follow @xref, not `@'.

* doc/coreutils.texi (readlink invocation): Add '.' after @xref macro.
2017-02-16 18:47:27 +01:00
Paul Eggert
1c27b56095 maint: xsetmode renamed to xbinary-io
* bootstrap.conf, src/base64.c, src/cat.c, src/cksum.c:
* src/head.c, src/md5sum.c, src/od.c, src/split.c, src/sum.c:
* src/tac.c, src/tail.c, src/tee.c, src/tr.c, src/wc.c:
Adjust to renaming of the xsetmode module to xbinary-io,
and of the xsetmode function to xset_binary_mode.
2017-02-16 00:40:50 -08:00
Paul Eggert
a24e9cc55c build: update gnulib submodule to latest 2017-02-16 00:40:50 -08:00
Paul Eggert
75aababed4 maint: use xsetmode, not xfreopen
This fixes a bug noted by Eric Blake.  Code was using xfreopen to
change files to binary mode, but this fails for stdout when in
append mode.  Such code should use xsetmode instead.  This affects
only the port on platforms like MS-Windows which distiguish text
from binary I/O.
* bootstrap.conf (gnulib_modules):
Remove xfreopen and add xsetmode.  Sort.
* src/base64.c (main):
* src/cat.c (main):
* src/cksum.c (cksum):
* src/head.c (head_file, main):
* src/md5sum.c (digest_file):
* src/od.c (open_next_file):
* src/split.c (main):
* src/sum.c (bsd_sum_file, sysv_sum_file):
* src/tac.c (tac_file, main):
* src/tail.c (tail_file):
* src/tee.c (tee_files):
* src/tr.c (main):
* src/wc.c (wc_file): Use xsetmode, not xfreopen.
2017-02-15 15:59:16 -08:00
Paul Eggert
e5cfadd6c7 build: update gnulib submodule to latest 2017-02-15 15:59:16 -08:00
Pádraig Brady
bd4bb42d65 maint: tweaks so syntax tests pass for previous commit
* src/force-link.h: Don't include headers already included by system.h
* src/force-link.c: Likewise.  Also include system.h and
explicitly mark extern functions as such.
2017-02-12 18:05:37 -08:00
Paul Eggert
376967889e ln: replace destination links more atomically
If the file B already exists, commands like 'ln -f A B' and
'cp -fl A B' no longer remove B before creating the new link.
Instead, they arrange for the new link to replace B atomically.
This should fix a race condition reported by Mike Crowe (Bug#25680).
* NEWS, doc/coreutils.texi (cp invocation, ln invocation):
Document this.
* bootstrap.conf (gnulib_modules): Add symlinkat.
* src/copy.c, src/ln.c: Include force-link.h.
* src/copy.c (same_file_ok): It's also OK to remove a destination
symlink when creating symbolic links, or when the source and
destination are on the same file system and when creating hard links.
* src/copy.c (create_hard_link, copy_internal):
* src/ln.c (do_link):
Rewrite using force_linkat and force_symlinkat, to close a window
where the destination temporarily does not exist.
* src/cp.c (main): Do not set x.unlink_dest_before_opening
merely because we are in link-creation mode.
* src/force-link.c, src/force-link.h: New files.
* src/local.mk (copy_sources, src_ln_SOURCES): Add them.
* tests/cp/same-file.sh: Adjust test case to match fixed behavior.
2017-02-11 23:14:02 -08:00
Tobias Stoeckmann
2f69dba5df timeout: fix race possibly terminating wrong process
The race is unlikely, as timeout(1) needs to receive a signal
in the few operations between waitpid() returning and exit().
Also the system needs to have reallocated the just released pid
in this time window.

Previously we never disabled the signal handler that sent
the termination signal to the "child" pid.  However once waitpid()
has reaped the child, the system is free to allocate that pid,
so we must ensure we don't process any further signals.

* build-aux/gen-lists-of-programs.sh: Build timeout(1) optionally...
* configure.ac: ...predicated on sigsuspend() being available.
* src/timeout.c (block_cleanup): A new function to ensure the
cleanup() handler is disabled after waitpid has returned.
(main): Use sigsuspend() to wait with cleanup() enabled but
disabled once it returns, and thus disabled for the waitpid() call.
(monitored_pid): Change to the more accurate pid_t.
* NEWS: Mention the fix.

Fixes http://bugs.gnu.org/25624
2017-02-09 22:15:43 -08:00
Pádraig Brady
99deaff7e8 doc: note the relationship between realpath and readlink
* doc/coreutils.texi (realpath invocation): Mention that realpath
is the preferred command for canonicalization.
(readlink invocation): Likewise.
* man/readlink.x: Likewise.
2017-02-09 21:52:23 -08:00
Janne Snabb
1ddcd24d52 tail: fix output of redundant headers when resuming
* src/tail.c (check_fspec): Only enable printing of the file header
if we've actually read some data and this is a new file.  Also
move printing of the file header to...
(dump_remainder): ...here, to allow printing only when data read.
* tests/tail-2/overlay-headers.sh: A new test for suspension
and resumption of tail.
* tests/local.mk: Reference the new test.
* NEWS: Mention the fix.
Fixes http://bugs.gnu.org/23539
2017-02-08 14:42:18 -08:00
Pádraig Brady
c95c0a0fd4 tests: fix tail test race causing false failure
* tests/tail-2/retry.sh: The replacement of the "missing" directory
is not atomic, and therefore tail(1) can take a different path,
especially if there is a delay between the rmdir(2) and creat(2).
This is noticeable for example with `make coverage` because in
that case the coverage files written by rmdir(1) on exit,
induce a significant delay thus triggering the issue.
2017-02-08 14:40:22 -08:00
Pádraig Brady
a520942efa tail: fix erroneous status about 'giving up' on file
* src/tail.c (recheck): Set f->ignore before we
use it to show the appropriate error.
* tests/tail-2/retry.sh: Ensure the "giving up" message
is not presented.
2017-02-08 14:40:22 -08:00
Pádraig Brady
2c64bc8729 doc: only distribute 5 years of ChangeLogs
Remove old log files that have corresponding entries
in the source code repository.
This saves about 2.5MB uncompressed, 0.5M compressed.

* Makefile.am (gen-ChangeLog): Adjust to taking all
logs since a particular version (8.15 in this case).
Also mention in the truncated log where to get older entries.
(changelog_etc): Remove the no longer distributed files.
* build-aux/git-log-fix: Remove now unused entries.
* ChangeLog-200[5-8]: Delete.
* doc/ChangeLog-2007: Likewise.
* po/ChangeLog-2007: Likewise.
* old/*: Likewise.
2017-02-08 14:39:48 -08:00
Maxime de Roucy
c0a79542fb maint: fix HACKING instructions to run a single test
* HACKING: s/make TEST=/make check TEST=/
The 'check' target was missing there since v8.20-57-geac397e.
2017-02-07 02:15:20 +01:00
Pádraig Brady
7a9c524f15 build: fix issue with HAVE_FALLOCATE on centos5
* src/copy.c (punch_hole): Work around an empty definition
of HAVE_FALLOCATE which leads to a build error of:
"error: #if with no expression"
That was triggered by the inclusion of <linux/fs.h> in
commit v8.25-68-g89e1fef with kernel-headers-2.6.18.
Reported by Nelson H. F. Beebe
2017-01-25 18:24:29 +00:00
Manolis Ragkousis
c974f835a5 build: Properly expand cu_install_program when cross-compiling
* src/local.mk (cu_install_program): Replace @INSTALL_PROGRAM@
with @INSTALL@ when cross-compiling; missed in commit 477a1e8e.
Message-Id: <20170125163329.5690-1-manolis837@gmail.com>
Copyright-paperwork-exempt: Yes
2017-01-25 10:55:48 -06:00
Mike Swanson
9f888b75c0 dircolors: highlight windows archive format
* src/dircolors.hin: Match *.{wim,swm,dwn,esd}
2017-01-21 16:05:58 +00:00
Pádraig Brady
662470cd82 maint: mention the recent date time zone bug fix
* NEWS: Add the bug fix from commit v8.26-27-gb14be50
2017-01-21 15:17:47 +00:00
Assaf Gordon
bd9beb5102 maint: appease syntax-check failures due to recent updates
* bootstrap: s/time stamp/timestamp/.
* old/fileutils/NEWS: Likewise.
* src/tail.c: Avoided a long line.
2017-01-21 15:04:43 +00:00
Paul Eggert
b14be5085c date: fix TZ= regression
Problem reported by Paul Wise for Debian, in:
https://bugs.debian.org/851934
This is fallout from the fix for GNU Bug#23035.
* src/date.c (batch_convert): New args TZ and TZSTRING.
All uses changed.
(batch_convert, main): Adjust to parse_datetime2 API change.
(main): Allocate time zone object.
* tests/misc/date-debug.sh: Fix incorrect test case,
caught by the fix.
* tests/misc/date.pl: Test the fix.
2017-01-20 18:24:54 -08:00
Paul Eggert
7cecdd6d69 build: update gnulib submodule to latest 2017-01-20 18:24:54 -08:00
Jim Meyering
25c7c0db9b maint: update README-hacking, now that vc-dwim accepts --init
* README-hacking: I've just released vc-dwim-1.8, so we can improve
the documentation to reference its --initialize option here.
2017-01-15 08:52:39 -08:00
Paul Eggert
0e9b51d179 date: output "-00" for indeterminate time zone
* NEWS: Document this behavior, which comes with recent Gnulib.
* doc/coreutils.texi (Formatting file timestamps, du invocation)
(Time conversion specifiers, Setting the time, Options for date):
Mention when -00 is output for numeric time zones.
Be more careful about Internet RFC numbers, ISO 8601, etc.
2017-01-14 23:59:01 -08:00
Paul Eggert
0b61395910 date: new option spelling --rfc-email
* NEWS:
* doc/coreutils.texi (Time conversion specifiers)
(Options for date, Examples of date): Document this.
* src/date.c (rfc_email_format): Rename from rfc_2822_format.
All uses changed.
(usage, long_options): Support --rfc-email.
2017-01-14 23:59:01 -08:00
Paul Eggert
103d2b92da maint: modernize URLs
A lot of this is converting http: to https:.
Also, gmane went away, so remove URLs that no longer work and
are not easy to figure out what they were.
Some of this stuff is so old that it no longer matters anyway.
2017-01-14 23:59:01 -08:00
Paul Eggert
24622902ca build: update gnulib submodule to latest 2017-01-14 23:59:01 -08:00
Bernhard Voelker
cade92336d doc: move "File timestamps" to a separate chapter
The above new section looked a bit odd as the only general documentation
in between the utility chapters.

* doc/coreutils.texi (File timestamps): Move to a separate chapter.
2017-01-10 22:15:07 +01:00
Eric Blake
83bfb98991 maint: fix recent syntax check failures
Commit 4f650aad was incomplete; it changed NEWS but not the hash,
and introduced a grammar error.

* cfg.mk (old_NEWS_hash): Update via 'make update-NEWS-hash'.
* doc/coreutils.texi (File timestamps): Fix doubled word.
2017-01-10 14:13:44 -06:00
Paul Eggert
5e871b355f doc: cover file timestamps better
Prompted by a bug report from Scott Deerwester (Bug#25407).
* doc/coreutils.texi (File timestamps): New section.
Revamp other sections to use this new section, and
use more-consistent terminology.
2017-01-09 15:15:04 -08:00
Paul Eggert
f4650aadbe maint: standardize on "timestamp" as per POSIX 2017-01-09 15:15:04 -08:00
Pádraig Brady
9c0a3a27f7 stty: ensure no side effects from invalid options
* src/stty.c (apply_settings): A new function refactored
from main() that is used to both check and apply options.
(main): Call apply_settings before we open the device,
so all validation is done before interacting with a device.
* NEWS: Mention the improvement.
* tests/misc/stty.sh: Add a test case.
2017-01-09 00:27:07 +00:00
Assaf Gordon
229431d63c tests: improve 'date --debug' tests
Update tests following improvements to gnulib's parse-datetime.y module.
See https://lists.gnu.org/archive/html/bug-gnulib/2017-01/msg00002.html

* tests/misc/date-debug.sh: Add tests for each of the gnulib changes.
2017-01-05 22:12:58 -05:00
Assaf Gordon
3568c6a582 build: update gnulib submodule to latest 2017-01-05 22:02:35 -05:00
Pádraig Brady
e7a2580b96 maint: update all copyright year number ranges
Run "make update-copyright" and then...

* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
2017-01-01 22:38:02 +00:00
Zooko
b02631b14b doc: recommend b2sum as well as SHA2
b2sum is faster, easier to use safely, and more future-proof
2016-12-28 16:34:34 +00:00
Pádraig Brady
d1a1276979 tests: avoid false fails on NFS due to EPERM
* tests/chgrp/basic.sh: On some NFS setups a user is
not allowed to set a group on a file even if a member
of that group.  Therefore skip this test on remote file systems.
* tests/chgrp/default-no-deref.sh: Likewise.
* tests/chgrp/no-x.sh: Likewise.
* tests/chgrp/posix-H.sh: Likewise.
* tests/chgrp/recurse.sh: Likewise.
* tests/tail-2/inotify-rotate-resources.sh: Change to skipping
on remote file systems in the standard way.
2016-12-28 16:33:43 +00:00
Paul Eggert
ed77fb40ca doc: Update POSIX part of README (Bug#25259) 2016-12-27 15:03:05 -08:00
Pádraig Brady
e17e5f40b8 wc: with only --bytes, determine size more efficiently
* src/wc.c (wc): Avoid reading the end of the file
when the size is not a multiple of PAGE_SIZE,
as the special case handling for files in /proc and /sys
is only required when st_size is 0 or a multiple of PAGE_SIZE.
* tests/misc/wc-proc.sh: Add a test case.
2016-12-26 12:57:16 +00:00
Pádraig Brady
94d2c6848b maint: correct the version for the previous bug fix
While st_size would have been incorrect for subsequent
files since v7.1, it was only used since v8.24.

* tests/misc/wc-files0.sh: s/7.1/8.24/
* NEWS: Likewise.

Reported by Bernhard Voelker
2016-12-20 13:07:07 +00:00
William R. Fraser
9944e4763b wc: fix wrong byte counts when using --files-from0
* src/wc.c (main): Reset fstatus[0].failed between files when reusing
the fstatus[0] entry in --files-from0 mode.  This ensures a stat() is
done for each file, avoiding incorrect counts and redundant reading.
* NEWS: Mention the bug fix.
* tests/misc/wc-files0.sh: Add a test case.
Fixes http://bugs.gnu.org/23073
2016-12-19 20:13:51 +00:00
Pádraig Brady
f071b04afa tests: fix typos in previous commit
* init.cfg (skip_if_mcstransd_is_running_): Fix typos
_introduced my me_ in the previous commit.
2016-12-18 20:39:41 +00:00
Nicolas Iooss
be2f82f670 tests: support non-MLS enabled SELinux systems
When running "make check" on a Linux system running SELinux with a
non-MLS policy, tests/mkdir/restorecon.sh test fails with:

  chcon: invalid context: root:object_r:tmp_t:s0: Invalid argument

Indeed in such a configuration, contexts cannot have ":s0" suffix.

* init.cfg (get_selinux_type): Refactor this function to here
from various tests.  Update to work with a non-MLS policy.
(mls_enabled_): A new function to detect if MLS is enabled.
(skip_if_mcstransd_is_running_): Update to not skip when
MLS is not enabled.
* tests/mkdir/restorecon.sh: Use a valid non-MLS context when needed.
* tests/install/install-Z-selinux.sh: Likewise.
* tests/cp/cp-a-selinux.sh: Likewise.
* tests/misc/selinux.sh: Likewise.
* tests/misc/chcon.sh: Skip if non-MLS as --range used throughout.
Fixes http://bugs.gnu.org/22631
2016-12-18 20:03:59 +00:00
Torbjörn Granlund
ca52f3bf3f factor: retry properly if Pollard rho gives a trivial factorization
* src/factor.c (factor_using_pollard_rho): Handle trivial factor g = n.
(factor_using_pollard_rho2): Handle trivial factor g1 = n1, g0 = n0.
* tests/misc/factor.pl: Add a test case.
Fixes http://bugs.gnu.org/25135
2016-12-08 10:10:38 +00:00
Niels Möller
c44da11506 factor: fix infinite loop in gcd2_odd
* src/factor.c (gcd2_odd): Fix the case a1 == 0, a0 == 0.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/25135
2016-12-08 10:10:34 +00:00
Pádraig Brady
11c1b73c1b doc: fix --help for: od -t f[SIZE]
* src/od.c (usage): SIZE is that of float, not integer.
2016-12-02 13:10:18 +00:00
Pádraig Brady
fbb337e1c3 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2016-11-30 18:35:39 +00:00
Pádraig Brady
ae40e18baf version 8.26
* NEWS: Record release date.
2016-11-30 18:11:57 +00:00
Pádraig Brady
1ee01c4066 tests: fix false failure with spaces in $PWD
* tests/misc/ptx-overrun.sh: Quote appropriately to avoid this
recently added issue, noticed by `make taint-distcheck`.
2016-11-30 15:50:59 +00:00
Pádraig Brady
40434e566e maint: avoid "make distcheck" failure without excess .deps directories
* Makefile.am (my-distcheck): Add the -r option to xargs so that
rmdir doesn't return an error when there are no extraneous .deps dirs.
2016-11-30 14:48:01 +00:00
Pádraig Brady
a2bb79844f tests: fix ERRORs and false FAILs on some platforms
* tests/misc/ls-time.sh: Skip the test rather than ERROR
when `touch -m -d ...` fails (Hurd).
* tests/tail-2/follow-stdin.sh: Avoid false FAILs by ignoring
the variances in sterror output.
* tests/rm/rm-readdir-fail.sh: Likewise.  Also avoid ERRORs
on systems that don't define _D_EXACT_NAMELEN.
2016-11-29 21:21:12 +00:00
Pádraig Brady
0655b86a6e head: fix processing of non-seekable input as seekable
* src/head.c (elide_tail_bytes_file): Ensure we don't use
st_size unless we've previously used seek() to determine
the CURRENT_POS in the seekable file.
This was seen to cause issue on FreeBSD 11 when the pipe
buffer was filled with `yes | head --lines=-0`, in which
case st_size was 64KiB while ST_BLKSIZE() was 4KiB.
Reported by Assaf Gordon.
2016-11-28 18:36:32 +00:00
Kamil Dudka
d8104265f2 install,mkdir: fix handling of -DZ and -pZ, respectively
... in the case where two or more directories nested in each other are
created and each of them defaults to a different SELinux context.

* src/install.c (make_ancestor): When calling defaultcon(), give it the
same path that is given to mkdir().  The other path is not always valid
wrt. current working directory.
* src/mkdir.c (make_ancestor): Likewise.
* NEWS: Mention the bug fix.

Reported at https://bugzilla.redhat.com/1398913
2016-11-28 16:17:31 +00:00
Pádraig Brady
a39641cbb8 tac: fix mem corruption when failing to read non seekable inputs
This was detected with ASAN, but can also be seen without ASAN with:
  $ tac - - <&-
  tac: standard input: read error: Bad file descriptor
  *** Error in `tac': malloc(): memory corruption: 0x...

* src/tac.c (copy_to_temp): Don't close our output stream on
(possibly transient) output error, or on input error.
(temp_stream): clearerr() on the stream about to be reused,
to ensure future stream use is not impacted by transient errors.
* tests/misc/tac-2-nonseekable.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/25041
2016-11-28 13:19:24 +00:00
Pádraig Brady
6f30a99fa5 tail: fix uninitialized memory read when failing to read file
Reproduced under UBSAN with `tail -f <&-` giving:
  tail.c:2220:18: runtime error: load of value 190,
  which is not a valid value for type ‘_Bool'

* src/tail.c (tail_file): Ensure f->ignore is initialized
in all cases where we can't tail the specified file.
* tests/tail-2/follow-stdin.sh: Add a test case which
checks stderr has no UBSAN warnings.
Fixes http://bugs.gnu.org/25041
2016-11-27 21:10:15 +00:00
Pádraig Brady
5c09e82b4f doc: add NEWS entries for recent changes
* NEWS: Mention in improvements about the workaround for
the glibc issue with closed stdin, and the new supported file systems.
* tests/misc/b2sum.sh: Spelling fix.
2016-11-27 01:20:09 +00:00
Pádraig Brady
286a401bc5 stat,tail: sync with latest Linux file systems
Update with the results from:

  kgit='https://git.kernel.org/cgit/linux/kernel/git'
  wget -q $kgit/torvalds/linux.git/plain/include/uapi/linux/magic.h \
    -O src/fs-latest-magic.h
  make src/fs-magic-compare

* src/stat.c (human_fstype): Add entries for:
BALLOON_KVM, CGROUP2, DAXFS, ZSMALLOC.
2016-11-27 00:28:16 +00:00
Pádraig Brady
4535563318 build: fix potential factor build failure on arm and risc
* src/longlong.h: Sync from gmp repo incorporating:
Protect umul_ppmm with do ... while (0)
Replace obsolete ARC asm 'J' constraints with 'Cal'
Provide umul_ppmm for riscv64
2016-11-27 00:28:16 +00:00
Pádraig Brady
12f6214d07 shred,sort: ensure faster unaligned access to rand module
glibc has changed the public define
from _STRING_ARCH_unaligned to _STRING_INLINE_unaligned as per
https://sourceware.org/bugzilla/show_bug.cgi?id=19462

* gl/lib/rand-isaac.c: Cater for both defines.
* gl/lib/randread.c: Likewise.
* src/system.h: Update commented out code.
2016-11-27 00:27:45 +00:00
Paul Eggert
c7c0c8b659 shuf: test input-closed bug
Problem reported by Alex Ryan (Bug#25029).
* tests/misc/shuf.sh: Test for shuffling with stdin closed.
2016-11-26 15:38:08 -08:00
Paul Eggert
7e76f092a0 build: update gnulib submodule to latest 2016-11-26 15:38:08 -08:00
Paul Eggert
e490178c39 numfmt: pacify Sun C 5.14
* src/numfmt.c (main): Don't implicitly coerce pointer in bool
initializer.  Although it's portable C99 code, it's confusing.
2016-11-25 18:54:32 -08:00
Pádraig Brady
55f14d7a09 tests: fix false failure on new ls test
* tests/ls/quote-align.sh: Remove "total" line
which can vary per file system depending on allocation.
Reported by Assaf Gordon on OpenSolaris (5.11/5.10).
2016-11-25 14:35:13 +00:00
Pádraig Brady
d91aeef052 pr: fix read from invalid memory with tabs in separator
This was detected with:
  echo a > a; pr "-S$(printf "\t\t\t")" a -m a > /dev/null
Resulting in ASAN triggering:
  ====================================================
  ERROR: AddressSanitizer: global-buffer-overflow
  READ of size 1 at 0x00000041b622 thread T0
    #0 0x40506a in print_sep_string ../src/pr.c:2241
    #1 0x407ec4 in read_line ../src/pr.c:2493
    #2 0x40985c in print_page ../src/pr.c:1802
    #3 0x40985c in print_files ../src/pr.c:1618
    #4 0x4036e0 in main ../src/pr.c:1136

* src/pr.c (init_parameters): Ensure we only override the
specified separator when it's a single tab, thus matching
the calculated separator length.
* tests/pr/pr-tests.pl: Add a test case.
* NEWS: Mention the fix.
2016-11-25 14:08:42 +00:00
Pádraig Brady
ca99c524e8 ptx: fix an invalid heap reference with short --width
* src/ptx.c (fix_output_parameters): Ensure line_width doesn't
go negative, which can happen when the --width is less
than the --gap-size.
* tests/misc/ptx-overrun.sh: Add a test case that triggers
with ASAN.  (Note the longer filename is needed to trigger).
Fixes http://bugs.gnu.org/25011
2016-11-24 16:21:59 +00:00
Bernhard Voelker
19157e87fd doc: clarify that readlink's --quiet option is on by default
* src/readlink.c (usage): Mark the --quiet/--silent option as active
by default.
* doc/coreutils.texi (readlink invocation): Likewise.
2016-11-24 10:51:27 +01:00
Pádraig Brady
4258e97b2d tests: fix false failure with ASAN in rm-readdir-fail
* tests/rm/rm-readdir-fail.sh: ASAN correctly indicated
that fts was writing to freed memory.  This was because
we reused a single dirent in our readdir() test wrapper.
Since fts was deallocating those dirents, we now get
a new dirent for each call to our readdir wrapper.
2016-11-24 01:31:45 +00:00
Pádraig Brady
4954f79ad2 split: fix memory corruption during chunk extraction
ASAN reported this error for: split -n2/3 /dev/null
  ERROR: AddressSanitizer: negative-size-param: (size=-1)
  #0 0x7f0d4c36951d in __asan_memmove (/lib64/libasan.so.2+0x8d51d)
  #1 0x404e06 in memmove /usr/include/bits/string3.h:59
  #2 0x404e06 in bytes_chunk_extract src/split.c:988
  #3 0x404e06 in main src/split.c:1626

Specifically there would be invalid memory access
and subsequent processing if the chunk to be extracted
was beyond the initial amount read from file (which is
currently capped at 128KiB).  This issue is not in a
released version, only being introduced in commit v8.25-4-g62e7af0

* src/split.c (bytes_chunk_extract): The initial_read != SIZE_MAX
should have been combined with && rather than ||, but also this
condition is always true in this function so remove entirely.
* tests/split/b-chunk.sh: Add a test case.

Fixes http://bugs.gnu.org/25003
2016-11-24 00:24:58 +00:00
Pádraig Brady
68c5eeccd0 tail: fix checking of remoteness when not using inotify
In recent commit v8.25-93-g7fc7206 we used the f->remote flag
which wasn't set in all cases.  This was detected with
ASAN giving this error when reading f->remote;
  runtime error: load of value 190,
  which is not a valid value for type '_Bool'

* src/tail.c (fremote): Query the system even without inotify.
(recheck): Always set f->fremote for valid files.
2016-11-24 00:24:21 +00:00
Jim Meyering
477a1e8ed4 build: avoid racy failure of "make -jN install"
Installing with -j2 or greater could result in a failure like
  /bin/sh: line 29: /P/bin/install: Permission denied
when /P/bin/install specifies your PATH-selected install program.
This would arise because we're using "install" to install all
man/*.1 files, and that command would run concurrently with the one
that installs "/P/bin/install" itself.  We would run this command:
"src/ginstall src/ginstall /P/bin/install", and it would result
in intervals during which the destination file does not exist,
is empty or incomplete and not executable.  We addressed this
problem long ago for installation of actual binaries by telling the
installation rules to use our just-built bin/ginstall (only when not
cross-compiling) rather than the PATH-resolved "install" program.
This change is to do the same for those .1 files.
* src/local.mk (INSTALL): Override automake's default of something
like "INSTALL = /P/bin/install -c".
(INSTALL_PROGRAM): Now that we set INSTALL, there is no longer any
need to set this derived variable.  Its default definition,
"INSTALL_PROGRAM = ${INSTALL}" does what we require.
Improved by Eric Blake.
2016-11-23 07:35:56 -08:00
Bernhard Voelker
fb82445ea0 maint: fix 'syntax-check' targets for VPATH builds
* cfg.mk (sc_gitignore_missing): Add $(srcdir) to .gitignore filename.
(sc_gitignore_redundant): Likewise.
2016-11-23 12:17:03 +01:00
Bernhard Voelker
d738921c7f maint: add build-aux/ar-lib to .gitignore
* .gitignore: Add entry for the above file which is created
by  './bootstrap'.
2016-11-23 12:16:32 +01:00
Paul Eggert
38286df537 pr: fix integer overflow in buffer size calcs
Problem reported by Marcel Böhme (Bug#24996).
* configure.ac (WERROR_CFLAGS): Avoid -Wtype-limits.
* src/pr.c (col_sep_string): Now a const pointer.  All uses changed.
(integer_overflow): New function.
(separator_string, main, init_parameters, init_store_cols):
Check for integer overflow.
(align_column, read_line, print_stored): Avoid integer overflow.
2016-11-23 00:07:27 -08:00
Bernhard Voelker
b50a151346 comm: add --total option
* src/comm.c (total_option): Add bool variable for the new option.
(TOTAL_OPTION): Add enum value.
(long_options): Add array element for the new option.
(usage): Document the new option here.
(compare_files): Count the lines in total[3], and output the summary at
the end.
(main): Accept the new option.
* doc/coreutils.texi (comm invocation): Document it.
* tests/misc/comm.pl: Test it.  While at it, improve the test data
to have 1 unique line in the first file, 2 unique lines in the second
file, and 3 common lines.
* NEWS (New Features): Mention the new option.

Fixes http://bugs.gnu.org/24929
2016-11-22 22:03:47 +01:00
Pádraig Brady
812877bfcb all: update gnulib submodule to latest
Also sync these copies with gnulib:
* bootstrap: Sync missed part of AIX support.
* tests/init.sh: Support compare_ on AIX.
2016-11-22 20:10:24 +00:00
Pádraig Brady
1d46419fde tests: fix false failure with FreeBSD 11 multibyte quoting
* tests/misc/printf-quote.sh: FreeBSD 11 was seen to treat
\u0378 as a printable character.  Therefore change to
using the \u0081 C1 control character.  We use the UTF-8
representation because our printf implementation explicitly
disallows \u0081 as input.
Reported by Assaf Gordon
2016-11-22 20:04:25 +00:00
Pádraig Brady
055b08ff78 tests: fix false fails due to passing env vars to returns_
On BSD /bin/sh it was seen that unexported env vars passed to
returns_() would not be propagated to the wrapped command.

* cfg.mk (sc_prohibit_env_returns): Add a syntax check to disallow.
* tests/misc/csplit-io-err.sh: Rearrange to export vars in a subshell.
* tests/rm/rm-readdir-fail.sh: Likewise.
* tests/misc/nohup.sh: Export and unset vars around returns_.
* tests/misc/printenv.sh: Likewise.
Reported by Assaf Gordon
2016-11-22 20:04:25 +00:00
Pádraig Brady
b572a286d5 tests: fix recent tail-2 test regressions
* tests/tail-2/pipe-f.sh: Avoid issue with readable
directories on BSD systems.
* tests/tail-2/retry.sh: Likewise.
Reported by Assaf Gordon
2016-11-22 20:04:25 +00:00
Pádraig Brady
01971c0e3f ls: improve alignment of quoted names
This provides better alignment when some names are quoted,
which also provides better indication that quotes are not
part of the name.

* src/ls.c (align_variable_outer_quotes): A new variable
set when ls is aligning columns (not using -m, non-zero -w),
and has a variable quoting style (shell, shell-escape, c-maybe).
(quote_name_buf): Writes to buffer rather than FILE,
taking care to avoid data copying if possible.  Refactored from...
(quote_name): ...here.  This now manages the buffer passed
to quote_name_buf() and outputs the padding, colors and name
in the appropriate order, while managing the --dired offsets.
(get_color_indicator): A new function to return the color sequence,
refactored from...
(print_color_indicator): ...here.  This now simply outputs.
(print_dir): Refactor common parts to quote_name().
(clear_files): Reset the flag indicating at least one
file is quoted in the current directory.
(needs_quoting): A new function to indicate at the scan stage
whether a name needs quoting.  Called from...
(gobble_file): ...here, until we find the first quoted file.
(print_name_with_quoting): Mostly refactored to quote_name().
* tests/ls/quote-align.sh: A new test for various output formats.
* tests/local.mk: Reference the new test.
* NEWS: Mention the improvement.
2016-11-22 20:04:25 +00:00
Pádraig Brady
ea94589e9e b2sum: a new checksum utility with md5sum like interface
Note we don't support the --algorithm option of the
b2sum command in the external BLAKE2 project, as that
was deemed too confusing for users.
"BLAKE2b" was chosen as the default algorithm to use,
which is single threaded but performs well on 64 bit.

* src/blake2: CC0 source copied from external project.
* cfg.mk[VC_LIST_ALWAYS_EXCLUDE_REGEX]: Exclude blake2/
from syntax checks, make update-copyright, etc.
* src/local.mk: Reference the sources for b2sum,
and set the compilation flags.
* doc/coreutils.texi (b2sum invocation): Reference the
md5sum invocation node, and add descriptions of -l.
* tests/misc/b2sum.sh: Add new test.
* tests/local.mk: Reference new test.
* AUTHORS: Add new binary.
* README: Likewise.
* build-aux/gen-lists-of-programs.sh: Likewise.
* man/.gitignore: Likewise.
* scripts/git-hooks/commit-msg: Likewise.
* man/b2sum.x: New man page template.
* man/local.mk: Reference new template.
* src/.gitignore: Ignore new binaries.
* src/blake2/.gitignore: Ignore new build atrifacts.
* src/md5sum.c (usage): Describe the new -l option.
* NEWS: Mention the new program.
2016-11-22 20:04:24 +00:00
Jim Meyering
373ba16f33 maint: avoid "make distcheck" failure due to excess .deps directories
* Makefile.am (my-distcheck): Remove all .deps directories before the
recursive diff that searches for left-behind files.  Otherwise, with
automake master (some time after v1.15), "make distcheck" would fail
due to those directories being left behind after "make distclean".
2016-11-22 10:21:25 -08:00
Pádraig Brady
f179919848 cp: improve status message when omitting directories
* src/copy.h (cp_options): Add a new flag for install(1).
* src/copy.c (copy_internal): For cp, also output remediation
advice which also indicates why directories aren't copied by default.
The message is unchanged for install(1).
* src/cp.c (cp_option_init): Init install_mode to false.
* src/mv.c (cp_option_init): Likewise.
* src/install.c (cp_option_init): Init install_mode to true.
* tests/install/basic-1.sh: Add a test case.
* tests/cp/link-deref.sh: Adjust test case.
Fixes http://bugs.gnu.org/24958
2016-11-19 17:05:33 +00:00
Pádraig Brady
0c5cc8384a tests: fix non portable date in recent test
* tests/misc/date.pl: Years < 1900 fail on solaris at least.
Reported by Assaf Gordon
2016-11-16 01:58:36 +00:00
Pádraig Brady
23a166d0e7 tests: fix false failure on OS X
* tests/misc/sort-h-thousands-sep.sh: The sv_SE locale
may be available while sv_SE.utf8 is not.  Therefore
test and use the same locale, now definfed in a variable.
Reported by Jim Meyering.
2016-11-15 21:29:10 +00:00
Antonio Ospite
1ba4cdb3e1 dircolors: highlight Motion JPEG multimedia files
* src/dircolors.hin: Add .mjpg and .mjpeg multimedia files.
This resolves http://bugs.gnu.org/24436.
2016-11-15 12:35:37 -08:00
Jim Meyering
4d4d8bccc3 tests: use "returns_" rather than explicit comparison with "$?"
The previous "returns_"-using change failed to convert many
uses of "$?".  Convert all but two of the remaining ones.
* tests/ls/stat-vs-dirent.sh: Likewise.
* tests/misc/head-write-error.sh: Likewise.
* tests/misc/nice.sh: Likewise.
* tests/misc/nohup.sh: Likewise.
* tests/misc/stdbuf.sh: Likewise.
* tests/misc/sync.sh: Likewise.
* tests/tail-2/pid.sh: Likewise.
* tests/tail-2/wait.sh: Likewise.
Thanks to Bernhard Volker for spotting this.
2016-11-13 17:09:57 -08:00
Pádraig Brady
eba871cd32 all: reduce usage of proper_name_utf8()
This reduces a standard coreutils install size by about 160K.

* src/cat.c: Change to proper_name() which removes about 18K text.
* src/cp.c: Likewise.
* src/df.c: Likewise.
* src/du.c: Likewise.
* src/getlimits.c: Likewise.
* src/realpath.c: Likewise.
* src/split.c: Likewise.
* src/stdbuf.c: Likewise.
* src/timeout.c: Likewise.
* src/truncate.c: Likewise.
* src/local.mk: Remove -llibiconv from the above programs.
* cfg.mk (sc_check-AUTHORS): Adjust to use factor(1).
* AUTHORS: Adjust to use ASCII to satisfy sc_check-AUTHORS.
2016-11-14 00:34:39 +00:00
Bernhard Voelker
40122a96df maint: add 'returns_' to exclude list in sc_prohibit_and_fail_1
The previous commit v8.25-96-g22063c8 lets 'make syntax-check' fail,
because the above check falsely detects a case where 'returns_' is
already in use.

* cfg.mk (sc_prohibit_and_fail_1): Add 'returns_' to exclude list.
2016-11-13 18:16:32 +01:00
Jim Meyering
22063c8c08 tests: use "returns_" rather than explicit comparison with "$?"
* tests/chmod/no-x.sh: Likewise.
* tests/cp/no-deref-link1.sh: Likewise.
* tests/cp/no-deref-link2.sh: Likewise.
* tests/cp/no-deref-link3.sh: Likewise.
* tests/du/move-dir-while-traversing.sh: Likewise.
* tests/ls/infloop.sh: Likewise.
* tests/ls/stat-failed.sh: Likewise.
* tests/ls/time-style-diag.sh: Likewise.
* tests/misc/chroot-fail.sh: Likewise.
* tests/misc/env-null.sh: Likewise.
* tests/misc/env.sh: Likewise.
* tests/misc/nice-fail.sh: Likewise.
* tests/misc/printenv.sh: Likewise.
* tests/misc/timeout.sh: Likewise.
* tests/tail-2/follow-name.sh: Likewise.
2016-11-13 08:26:19 -08:00
Pádraig Brady
4d45722d11 tail: only retry file open if --retry specifed
* src/tail.c (tail_file): On failure to open a file,
set ignore=true when --retry is not specified.
* tests/tail-2/assert-2.sh: Adjust to the new behavior.
* tests/tail-2/retry.sh: Add a test case.  Also change
from `tail ... && fail=1` to the more robust `returns_ 1 ...`
construct which detects segfaults etc.
* NEWS: Document the fix.
2016-11-10 12:43:42 +00:00
Pádraig Brady
659060233f tail: ensure -f --retry 'missing' handles truncation
* src/tail.c (tail_forever): The BLOCKING optimization is only
enabled for non regular files (which can't be truncated), so ensure
we don't enable that unless we've a valid file descriptor.
* tests/tail-2/retry.sh: Add a test case.
* NEWS: Mention the bug fix.
2016-11-09 21:38:33 +00:00
Pádraig Brady
7fc7206b03 tail: avoid outputting repeated data with remote files
* src/tail.c (tail_forever): Only read up to st_size on network
file systems to avoid the issue with a stale attribute cache
returning a smaller st_size than we have already read().
The was seen with glusterfs at least and caused the complete
file to be repeatedly output due to assuming the file was
truncated in this case.
* NEWS: Mention the fix.
2016-11-09 19:36:42 +00:00
Pádraig Brady
2a80912529 tail: terminate when following pipes and untailable non pipes
* src/tail.c (ignore_pipe_or_fifo): Mark the descriptor as -1
for pipes so that any_live_files() detects correctly that
the entry is no longer live.
* tests/tail-2/pipe-f.sh: Add a test case.
* NEWS: Mention the fix.
Fixes http://bugs.gnu.org/24903 which was detected
using Symbolic Execution techniques developed in
the course of the SYMBIOSYS research project at
COMSYS, RWTH Aachen University.
2016-11-08 23:19:08 +00:00
Pádraig Brady
23066be1b6 maint: misc tweaks to recent changes
* doc/coreutils.texi(cut invocation): Give a more accurate description
of cut field handling limitations.
* tests/misc/stat-fmt.sh: Fix the test header to be more general.
* tests/tail-2/retry.sh: Spellings.
2016-11-07 17:12:39 +00:00
Pádraig Brady
7ce2589b77 maint: refactor printing of backup suffix --help
* src/system.h (emit_backup_suffix_note): A new function to
output the backup suffix info.  The strings are unchanged,
so translations are not impacted.
* src/cp.c (usage): Use the new function.
* src/ln.c (usage): Likewise.
* src/mv.c (usage): Likewise.
* src/install.c (usage): Likewise.
2016-11-07 17:09:35 +00:00
Rishabh Dave
ec946718ae maint: simplify handling of backup --suffix in various tools
* src/cp.c (main): Avoid the getenv("SIMPLE_BACKUP_SUFFIX") call,
which is now done if needed in the gnulib backupfile module.
Also avoid the redundant strdup, as we don't modify this suffix.
* src/install.c (main): Likewise.
* src/ln.c (main): Likewise.
* src/mv.c (main): Likewise.
Fixes http://bugs.gnu.org/23153
2016-11-07 17:09:35 +00:00
Pádraig Brady
30012b290f date: add %q to output the quarter of the year
* doc/coreutils.texi (date invocation): Document %q.
* src/date.c (usage): Likewise.
* tests/misc/date.pl: Add a test case.
* cfg.mk (sc_strftime_check): Adjust to allow %q.
* NEWS: Mention the new feature.
2016-11-07 17:09:15 +00:00
Pádraig Brady
7ba9355d0a all: update gnulib submodule to latest
Incorporating these coreutils specific changes:
  backupfile: initialize default suffix within the implementation
  strftime,strptime: support %q to represent the quarter

Also sync these copies with gnulib:
* bootstrap: Now supports AIX.
* gnulib: Update to the latest.
* tests/init.sh: dash(1) is now disabled.
2016-11-07 13:17:19 +00:00
Pádraig Brady
5161effd83 doc: clarify in texinfo that cut doesn't reorder fields
* doc/coreutils.texi (cut invocation): Clarify the more
sophisticated field processing supported by awk(1).
Fixes http://bugs.gnu.org/24881
2016-11-05 12:16:34 +00:00
Pádraig Brady
9ad400f1ad stat: make --format=%N honor the QUOTING_STYLE env var
* doc/coreutils.texi (stat invocation): Describe the
QUOTING_STYLE values now supported.
* src/stat.c (getenv_quoting_style): A new function called
from main, that sets the default quoting style for quotearg.
(main): Call getenv_quoting_style() when %N specified.
* tests/misc/stat-fmt.sh: Add a test case.
* NEWS: Mention the improvement.
Fixes http://bugs.gnu.org/23422
2016-11-05 00:44:06 +00:00
Pádraig Brady
6f64cb64f7 doc: improve the --help description of ls -N
* src/ls.c (usage): The existing description was inaccurate
as -N does not directly impact whether control characters
are displayed or not.
2016-11-05 00:42:23 +00:00
Pádraig Brady
c6656eed6a dd: warn about counts specified with confusing 0x prefix
* src/dd.c (parse_integer): Suggest to use "00x" instead of "0x",
which is significant for the "count", "seek", and "skip" operands.
* tests/dd/misc.sh: Add a test case.
Fixes http://bugs.gnu.org/24874
2016-11-04 20:38:32 +00:00
Pádraig Brady
d0ddfadfb2 md5sum,sha*sum: fix --ignore-missing with checksums starting with 00
* NEWS: Mention the fix.
* src/md5sum.c (digest_file): Add a new MISSING parameter to
return whether the file was missing, separately from the digest.
* tests/misc/md5sum.pl: Add a test case.
Fixes http://bugs.gnu.org/24795
2016-10-26 20:42:30 +01:00
Bishop Bettini
34d1aeaf31 doc: fix typo in stdbuf man page
* man/stdbuf.x: Correct spelling of immediately.
Fixes http://bugs.gnu.org/24763
2016-10-21 17:31:22 -07:00
Jim Meyering
f8b8bbc1b9 maint: we use die; remove now-unnecessary uses of abort
* src/expr.c (integer_overflow): Remove an abort-after-die.
* src/paste.c (write_error): Likewise.
* src/sort.c (badfieldspec): Likewise.
* src/tr.c (string2_extend): Likewise. Also remove a few
break statements, each after an abort.
2016-10-16 11:28:39 -07:00
Pádraig Brady
492dcb2eb1 all: use die() rather than error(EXIT_FAILURE)
die() has the advantage of being apparent to the compiler
that it doesn't return, which will avoid warnings in some cases,
and possibly generate better code.
* cfg.mk (sc_die_EXIT_FAILURE): A new syntax check rule to
catch any new uses of error (CONSTANT, ...);
2016-10-16 12:23:55 +01:00
Jim Meyering
d035eacfde build: also distribute new file, src/die.h
* src/local.mk (noinst_HEADERS): Add die.h.
2016-10-15 16:52:14 -07:00
Jim Meyering
dad7ab0b7b build: add die.h; avoid new warnings from GCC 7
* src/die.h (die): New file/function from grep.
Note: we expect this file to migrate to gnulib.
* src/csplit.c: Include die.h.
(check_format_conv_type): Use die in place of error-nonzero;break;
* src/install.c (strip): Likewise.
* src/nl.c (proc_text): Likewise.  This also suppresses a new warning
from GCC 7's -Werror=strict-overflow.
* src/tail.c (parse_options): Likewise.
* src/basename.c (main): Adjust "fall through" comment
so that GCC 7's -Wimplicit-fallthrough honors it.
* src/cp.c (main): Add a "fall through" comment.
* src/ls.c (gobble_file): Likewise.
(get_funky_string): Adjust a "fall through" comment so it is
recognized.
* cfg.mk (exclude_file_name_regexp--sc_system_h_headers): Add die.h
to this list of exempt src/*.h files.
2016-10-15 08:41:42 -07:00
Jim Meyering
0d9323ec55 maint: pr: avoid new GCC 7 warning
* src/pr.c (main): Avoid this warning from GCC 7:
src/pr.c:1119:6: error: assuming signed overflow does not occur when \
  simplifying conditional to constant [-Werror=strict-overflow]
   if (n_files == 0)
2016-10-15 08:41:42 -07:00
Jim Meyering
1d5fe84b4e gnulib: update to latest and adapt printf-quote.sh test
* .gitignore: Add /lib/limits.h.
* tests/misc/printf-quote.sh: Reflect that a single quote is now
rendered as "'", rather than as ''\'''.
2016-10-15 08:41:42 -07:00
Pádraig Brady
0e060d9fef rm: disallow --n alias for --no-preserve-root
* src/rm.c (main): Ensure the full --no-preserve-root
option is specified, rather than allowing --n etc.
* tests/rm/r-root.sh: Add a test case.
* NEWS: Mention the change in behavior.

Improved by Jim Meyering.
Fixes http://bugs.gnu.org/24604
2016-10-04 23:35:59 +01:00
Pádraig Brady
f04daf570b tail: -F now always processes initially untailable files
which was not the case when inotify was not available.

* src/tail.c (any_live_files): Simplify, since the IGNORE
flag is now only set when a file should be ignored indefinitely.
(recheck): Only output the "giving up on name" message
when that's actually the case.  Only set the IGNORE flag
when ignoring a file indefinitely.
(tail_file): Likewise.
* tests/tail-2/retry.sh: Add a test case.  Also run
all existing test cases with and without inotify.
NEWS: Mention the fix.
THANKS.in: Add the reporter.
Fixes http://bugs.gnu.org/24495 which was detected
using Symbolic Execution techniques developed in
the course of the SYMBIOSYS research project at
COMSYS, RWTH Aachen University.
2016-09-28 23:40:47 +01:00
Jim Meyering
eb406b2caf who: avoid new warning from upcoming gcc-7
* src/who.c (idle_string): This function would fail to compile
with -Werror and today's built-from-git gcc due to this warning:
src/who.c: In function 'print_user':
src/who.c:201:36: error: may write format character ':' at offset 4 \
  past the end of the destination [-Werror=format-length=]
           sprintf (idle_hhmm, "%02d:%02d",
                                    ^~~~~
The fix is to use an assertion to inform gcc of the existing
invariant that guarantees the number of hours is less than 24.
2016-09-22 10:17:07 -07:00
Paul Eggert
1db94ee969 ls: fix %%b format and precompute more
The old code mishandled --time-spec='+%%b', as it misinterpreted
the '%b' as being the month abbreviation.  Also, it mishandled
the extremely unlikely case of a month abbreviation containing '%'.
The performance part of this patch sped up 'ls' by about 1% on my
little benchmark of 'ls -lR' on the source directory in the
en_US.UTF-8 locale (Fedora 24 x86-64).
* NEWS: Document the bug fix.
* src/ls.c (first_percent_b, abformat_init): New static functions.
(ABFORMAT_SIZE): New constant.
(use_abformat): New static var.
(abmon, required_mon_width): Remove these static vars.
(abmon_init): Now accepts a pointer to abmon, and returns a boolean.
All callers changed.  Reject month abbrs containing '%', as these
would mess up strftime.  Simplify mbsalign result checking,
since (size_t) -1 exceeds ABFORMAT_SIZE.
(abformat_init, align_nstrftime): Precompute all 24 formats at
startup, rather than computing a format for each time stamp.
(decode_switches): Call abformat_init instead of abmon_init.
(align_nstrftime): Accept recentness bool instead of format.
All callers changed.
* tests/misc/time-style.sh: Test for format with '%%b'.
2016-09-19 12:48:32 -07:00
George Burgess IV
e095378302 pinky,who: remove redeclarations of ttyname
Given that `ttyname` is already conditionally declared in src/system.h,
other declarations are redundant and problematic for example in ChromeOS
which has a new FORTIFY implementation that, as an artifact of how it's
implemented, causes the compiler to complain if certain standard library
functions are redeclared without special compiler-specific attributes.

* src/pinky.c: Remove declaration (which was unused anyway).
* src/who.c: Remove declaration.
* src/system.h (getlogin, getuid, geteuid, getgrgid, getpwuid, ttyname):
Add the parameter type to the declarations to avoid warnings when these
backup declarations are used.
2016-09-11 12:46:02 +01:00
Jim Meyering
677ae07083 gnulib: update to latest, for getprogname fixes
Compiling in gnulib-tests/ would fail on some platforms
due to a missing lib/assert.h.  Reported by Assaf Gordon in
https://lists.gnu.org/archive/html/coreutils/2016-09/msg00016.html
2016-09-09 19:28:22 -07:00
Paul Eggert
89e1fef97c cp: use FICLONE instead of BTRFS_IOC_CLONE
This doesn't affect the generated code on my system; it's merely
a cleaner way to use the recently-introduced Linux-specific API.
* m4/jm-macros.m4 (gl_CHECK_ALL_HEADERS): Check for linux/fs.h.
* src/copy.c: Include <linux.fs.h> if available.
(FICLONE) [__linux__]: Define if not already defined.
(clone_file): Use FICLONE instead of the older BTRFS_IOC_CLONE,
as this ioctl is no longer btrfs-specific.
2016-09-09 15:29:07 -07:00
Assaf Gordon
c6389a1340 date: add '--debug' option
Usage example:
    date --debug -d 'now + 3 days'

Print parsing and debugging information to stderr when using date's
-d/--date option.
See: http://lists.gnu.org/archive/html/coreutils/2016-01/msg00076.html

* src/date.c (main): Add '--debug' option, enable debugging
in gnulib's parse-datetime.y module.
* tests/misc/date.pl: Repeat tests with '--debug' enable, ensure
no regression.
* tests/misc/date-debug.sh: Test output of '--debug' option.
* tests/local.mk: Add above test.
* NEWS: Mention new option.
* doc/coreutils.texi: Likewise.
2016-09-08 01:00:23 -04:00
Paul Eggert
d47090d964 sort: port to strict C + valgrind
* bootstrap.conf (gnulib_modules): Add flexmember.
* src/sort.c: Include flexmember.h.
(struct tempnode): Make the last member flexible.
(create_temp_file): Port to strict C11/C99 rules for
allocation alignment with flexible array members.
2016-09-07 19:51:12 -07:00
Paul Eggert
e9e7289210 build: update gnulib submodule to latest 2016-09-07 19:51:12 -07:00
Pádraig Brady
6643842bad factor: reinstate immediate output with interactive use
* src/factor.c (lbuf_putc): Only buffer more than a line
when not using the tool interactively.
* NEWS: Mention the bug fix.
Fixes http://pad.lv/1620139
2016-09-07 10:20:39 +01:00
Kamil Dudka
5445f7811f ls: allow interruption when reading slow directories
Postpone installation of signal handlers until they're needed.
That is right before the first escape sequence is printed.

* src/ls.c (signal_setup): A new function refactored from main()
to set and restore signal handlers.
(main): Move signal handler setup to put_indicator()
so that the default signal handling is untouched as long as possible.
Adjusted condition for restoring signal handlers to reflect the change.
(put_indicator): Install signal handlers if called for the very first
time.  It uses the same code that was in main() prior to this commit.
* NEWS: Mention the improvement.

See https://bugzilla.redhat.com/1365933
Fixes http://bugs.gnu.org/24232
2016-09-07 10:16:59 +01:00
Pádraig Brady
22d188e299 doc: fix typo in date example
* doc/coreutils.texi (date invocation): Add a missing quotation mark.
Fixes http://bugs.gnu.org/24349
2016-09-01 16:39:04 +01:00
Jim Meyering
48ea99e1fa dircolors: recognize .zst and .tzst suffixes
* src/dircolors.hin: Add .zst and .tzst suffixes for the
Zstandard/zstd compression tools.  See http://zStd.net and
https://code.facebook.com/posts/1658392934479273/
2016-08-31 10:39:30 -07:00
Jim Meyering
d7ee241c23 maint: tr: tweak/make-consistent a pair of loop indices
* src/tr.c (unquote): Use indices of type "unsigned int", rather
than a mix or "size_t" and "int", presuming that no command-line-
specified string will have length longer than UINT_MAX.
2016-08-30 07:57:21 -07:00
Jim Meyering
def5cd571b tr: move decls "down" 2016-08-30 07:57:21 -07:00
Jim Meyering
d591776d81 ptx: avoid new warning/error from upcoming gcc-7.x
* src/ptx.c (fix_output_parameters): Switch to an unsigned type that
matches the OCCURS.file_index type. This avoids the following error
from gcc-7.0.0 20160829 (experimental):
  src/ptx.c:1220:14: error: assuming signed overflow does not occur \
    when simplifying conditional to constant [-Werror=strict-overflow]
          if (file_index > 0)
2016-08-29 08:37:08 -07:00
Pádraig Brady
bd75118c16 cp: with --parents --no-preserve=mode don't copy dir perms
* src/cp.c (make_dir_parents_private): Use default permissions for
created directories when --no-preserve=mode is specified.
* tests/cp/cp-parents.sh: Add a test case.
* NEWS: Mention the fix.
Fixes http://bugs.gnu.org/24251
2016-08-18 13:54:48 +01:00
Pádraig Brady
3e71b06577 doc: fix ambiguous multiplier info in dd man page
* src/dd.c (usage): Add a comma which is significant for
the rewrapping done in man pages.
2016-08-18 11:58:39 +01:00
Assaf Gordon
ff2178bf30 maint: refactor common expand(1) and unexpand(1) code
* src/expand.c, src/unexpand.c: Move global variables from here...
* src/expand-common.h, src/expand-common.c: ... to here.
* src/expand.c, src/unexpand.c: (parse_tab_stops, validate_tab_stops,
next_file): Move identical functions to new module.
(add_tab_stop): Move to new module, including additional code from
'unexpand' (keeping max_column_width) which will have no effect in when
used in 'expand'. Refactor common next-column calculation code
into a new function 'get_next_tab_column'.
* src/local.mk: (src_expand_SOURCES, src_unexpand_SOURCES): Add
'expand-common.c'; (noinst_HEADERS): Add 'expand-common.h'.
* po/POTFILES.in: Add 'expand-common.c'.
* tests/misc/expand.pl: Add more tests.
* tests/misc/unexpand.pl: Likewise.
* TODO: Move conclusions to above test after investigation.
2016-08-09 11:31:00 +01:00
Philipp Thomas
1c17f61ef9 df: improve performance with many mount points
Use hash table for seaching in filter_mount_list() and get_dev()

This improves performance for 20K mount entries from:
  real    0m1.731s
  user    0m0.532s
  sys     0m1.188s
to:
  real    0m1.066s
  user    0m0.028s
  sys     0m1.032s

* src/df.c (devlist_table): Define hash table.
(devlist_hash): Add hash function.
(devlist_compare): Add hash comparison function.
(devlist_for_dev): Add lookup function.
(devlist_free): Add cleanup function.
(filter_mount_list): Use the above hash table.
While at it, rename the variable 'devlist' to 'seen_dev' for
better readability.
(me_for_dev): Use the above lookup function.
NEWS: Mention the improvement.
THANKS.in: Remove the committer; add original submitter Josef Cejka.
2016-08-03 12:35:47 +01:00
Pádraig Brady
5bbce2d2d7 doc: revert recent date(1) synopsis change
* src/date.c (usage): This was thought to introduce other ambiguities,
and was inconsistent with the format presented in the touch(1) docs.
* doc/coreutils.texi (date invocation): Likewise.
See http://bugs.gnu.org/24077
2016-07-28 12:38:20 +01:00
Bernhard Voelker
558ce3044d maint: pacify GCC 6 with -Wnull-dereference
src/id.c:249:29: error: potential null pointer dereference \
[-Werror=null-dereference]
       pw_name = xstrdup (pwd->pw_name);
                          ~~~^~~~~~~~~
src/whoami.c:89:11: error: potential null pointer dereference \
[-Werror=null-dereference]
   puts (pw->pw_name);
         ~~^~~~~~~~~

* src/id.c (main): Explicitly exit with EXIT_FAILURE after an eror to
help gcc-6 to detect that the dereferenced pointer is valid.
* src/whoami.c (main): Likewise.
2016-07-27 21:28:49 +02:00
Bernhard Voelker
f0e0f3ac92 build: update gnulib submodule to latest
Mainly for
* 77d36b5 obstack: pacify GCC 6 with -Wnull-dereference
2016-07-27 21:28:33 +02:00
Jim Meyering
5e6911ccd6 maint: skip a check when en_US.UTF-8 collation rules are broken
* cfg.mk (sc_THANKS_in_sorted): This check would fail on systems
for which "." is not ignored.  Add a quick sort-based check for
that error, and skip the check on any broken system.
2016-07-27 09:31:03 -07:00
Pádraig Brady
8d1b163080 doc: make date(1) synopsis consistent with output +FORMAT
* src/date.c (usage): Make the characters used to summarize
the input format, match the output +FORMAT characters.
* doc/coreutils.texi (date invocation): Likewise.
Fixes http://bugs.gnu.org/24077
2016-07-27 17:08:24 +01:00
Bernhard Voelker
a69e54cfdf maint: fix dependency of man/arch.1
The following is a reproducer for the wrong dependency:

  $ ./configure --enable-install-program=arch
  $ make
  $ rm -f src/arch man/arch.1
  $ make man/arch.1
    GEN      man/arch.1
  help2man: can't get `--help' info from man/arch.td/arch
  Try `--no-discard-stderr' if option outputs to stderr
  Makefile:14378: recipe for target 'man/arch.1' failed
  make: *** [man/arch.1] Error 127

* man/local.mk (man/arch.1): Change to depend on src/arch rather than
src/uname: while the arch binary depends on uname.c and uname-arch.c,
its man page depends on the arch binary.

Reported downstream by Rodrigues Goldwyn <rgoldwyn@suse.com> in
https://build.opensuse.org/request/show/415172
2016-07-27 07:11:20 +02:00
Kamil Dudka
0f9fc7b3b9 sort: with -h, disallow thousands separator between number and unit
* src/sort.c (traverse_raw_number): Accept thousands separator only
if it is immediately followed by a digit.
* tests/misc/sort-h-thousands-sep.sh: Cover the fix for this bug.

Suggested by Pádraig Brady in http://bugs.gnu.org/24015
2016-07-18 22:24:26 +01:00
Kamil Dudka
dfbc945a56 sort: make -h work with -k and blank used as thousands separator
* src/sort.c (traverse_raw_number): Allow to skip only one occurrence
of thousands_sep to avoid finding the unit in the next column in case
thousands_sep matches as blank and is used as column delimiter.
* tests/misc/sort-h-thousands-sep.sh: Add regression test for this bug.
* tests/local.mk: Reference the test.
* NEWS: Mention the bug fix.
Reported at https://bugzilla.redhat.com/1355780
Fixes http://bugs.gnu.org/24015
2016-07-18 22:12:32 +01:00
Kamil Dudka
5cc804337b maint: sort.c: deduplicate code for traversing numbers
* src/sort.c (traverse_raw_number): New function for traversing numbers.
(find_unit_order): Use traverse_raw_number() instead of open-coding it.
(debug_key): Likewise.
2016-07-18 22:09:07 +01:00
Kamil Dudka
502518b440 install: with -Z, set default SELinux context for created directories
* doc/coreutils.texi (install invocation): Update -Z documentation.
* src/install.c (make_ancestor): Set default security context before
calling mkdir() if the -Z option is given.
(process_dir): Call restorecon() on the destination directory if the
-Z option is given.
(usage): Update -Z documentation.
* tests/install/install-Z-selinux.sh: A new test for 'install -Z -D'
and 'install -Z -d' based on tests/mkdir/restorecon.sh.
* tests/local.mk: Reference the test.
* NEWS: Mention the improvement.
Reported at https://bugzilla.redhat.com/1339135
Fixes http://bugs.gnu.org/23868
2016-07-08 18:40:23 +01:00
Pádraig Brady
54c1397510 tests: avoid false failure on 32 bit in readdir() test
* tests/rm/rm-readdir-fail.sh: Since we use the returned dirent
from the readdir wrapper it must be the correct type and not
just cast.  Therefore setup so that we only have to define a
wrapper for readdir(), which works appropriately on 32 and 64 bit.
Issue reported by Bernhard Voelker, where rm was seen to invoke
rmdir() on invalid file names.
2016-07-06 18:13:08 +01:00
Assaf Gordon
383e4b2ce5 tests: improve recent seq EPIPE test
Follow-up to commit c92585b1: improve epipe test script, with
suggestions from Bernhard Voelker and Pádraig Brady.
see: http://lists.gnu.org/archive/html/coreutils/2016-04/msg00067.html .

* tests/misc/seq-epipe.sh: Avoid too many subshells,
  stricter validation of errors and output from seq,
  skip if trapping SIGPIPE is not supported.
2016-07-02 18:08:33 -04:00
Pádraig Brady
dfae782200 stty: fix sane setting of susp to ^z on Solaris
* src/stty.c: Disable setting of "swtch" to ^z as that
conflicts with and disables using ^z as "susp".
* NEWS: Mention the bug fix.
Reported and tested by Rich Burridge at:
http://bugs.gnu.org/23866
2016-06-29 10:00:05 +01:00
Peter Benie
26616776c0 tests: verify that fts diagnoses readdir() failures
* tests/rm/rm-readdir-fail.sh: A new test to simulate readdir()
failing immediately or after returning a few entries, and verifying
that rm does the appropriate thing.
This was initially reported at:
http://bugzilla.opensuse.org/show_bug.cgi?id=984910
where it was mentioned that readdir() may fail
when an NFS server has a poor readdir cookie implementation.
2016-06-26 21:48:22 +01:00
Pádraig Brady
ef9650170f all: update gnulib submodule and tests/init.sh to latest
* gnulib: Update to latest.
* NEWS: Specifically mention the fts readdir() fix
and reindent to standard indentation.
* tests/init.sh: Update from gnulib.
2016-06-26 20:58:41 +01:00
Paul Eggert
4cdb1703af maint: simplify partial writes etc. in 'yes'
* src/yes.c: Include full-write.h.
(main): Use full_write, not write, to simplify handling of partial
writes.  Don't bother using stdio to output data; just use
full_write with a buffer as large as needed.  Reuse operand
strings if possible, and if the buffer would otherwise be large.
2016-06-25 01:02:08 +02:00
Pádraig Brady
5845664c8c yes: handle short writes
* src/yes.c (main): Loop over the write buffer to
handle the case where write may write less than requested.
* NEWS: Mention the bug fix.
Reported by Paul Eggert.
2016-06-24 01:13:33 +01:00
Pádraig Brady
ba5767c2b8 yes: fix copy and paste issue with previous commit
* src/yes.c (main): Output 'y' not '-'.
* tests/misc/yes.sh: Add a test for default output.
2016-06-24 01:09:28 +01:00
Paul Eggert
818b2f4897 maint: work even if argc == INT_MAX
GCC 7 warned about undefined behavior in this unlikely case.
Problem reported by Jim Meyering in: http://bugs.gnu.org/23825
* src/md5sum.c (main):
* src/paste.c (main):
* src/yes.c (main):
Avoid undefined behavior when argc == INT_MAX.
2016-06-23 20:18:03 +02:00
Pádraig Brady
a3311c966e doc: clarify sort --key handling of default field separators
* doc/coreutils.texi (sort invocation): Mention in the summary
dicussion that --key is used to specify fields.  Give a summary
in the --key description, of the most common use case of specifying
a field, and that by default those fields include the blank separators
at the start of each field in the comparisons.
2016-06-01 11:56:47 +01:00
Assaf Gordon
6223bf94bf sort: modify 'leading spaces' debug warning scenarios
Print warning regardless of locale, avoid warning if key is zero width.
Problem reported by Karl Berry in http://bugs.gnu.org/23665 .

* src/sort.c: (key_warnings): change conditions for 'leading spaces'
warning.
* tests/misc/sort-debug-warn.sh: adjust tests accordingly.
2016-05-31 21:29:52 -04:00
Assaf Gordon
d548f87595 tests: sort-debug-warn: add progress information lines
Easier troubleshooting of individual 'sort --debug' messages.
Discussed in http://bugs.gnu.org/23665 .

* tests/misc/sort-debug-warn.sh: add progress number before each sort
invocation.
2016-05-31 21:29:52 -04:00
Pádraig Brady
7945e09e7b dircolors: output colors for any $TERM matching *color*
* src/dircolors.hin: Reduce the list by replacing all specific
mentions of "color" with the pattern "*color*".  This will also
cater for other entries like "konsole-256color".
Fixes http://bugs.gnu.org/23542
2016-05-15 21:26:19 +01:00
KOBAYASHI Takashi
43df058b91 nl: reset numbering for each section
* NEWS: Mention the bug fix.
* src/nl.c (proc_body, proc_footer): Reset numbering here too.
* doc/coreutils.texi (nl invocation): Adjust for behavior change.
* tests/misc/nl.sh: Add a test case.
2016-05-14 12:41:43 +01:00
Pádraig Brady
99dd47ec86 stat,tail: add support for the SMB2 remote file system
* stc/stat.c (human_fstype): Add file system ID definition,
and use "smb2" as the name.
* NEWS (Improvements): Mention the change.
Fixes http://bugs.gnu.org/23516
2016-05-12 09:52:12 +01:00
Jim Meyering
9a4df07016 maint: avoid new warning from gcc (GCC) 7.0.0 20160503 (experimental)
* src/id.c (main): When configured with --enable-gcc-warnings and using
the very latest gcc built from git, building would fail with this:
  src/id.c:200:8: error: assuming signed overflow does not occur when \
    simplifying conditional to constant [-Werror=strict-overflow]
     bool default_format = (just_user + just_group + just_group_list
          ^~~~~~~~~~~~~~
Rewrite to use bool-appropriate operators.
2016-05-04 08:05:54 -07:00
Pádraig Brady
dc9146c4a2 tests: avoid false failure when df lists no root file system
* tests/df/skip-duplicates.sh: Skip the test when there is no
'/' entry listed by df, which was seen in certain chroot setups.
2016-04-26 11:35:59 +01:00
Assaf Gordon
c92585b10b seq: detect and report I/O errors immediately
Ensure I/O errors are detected (and terminate seq), preventing seq
from infloop (or running for long time with a large
range) upon write errors or ignored SIGPIPE. Examples:

     seq 1 inf > /dev/full             (seq_fast)
     seq 1.1 0.1 inf >/dev/full        (print_numbers)

* src/seq.c (io_error): A new function to diagnose appropriate
stdio errors and exit the program with failure status.
(seq_fast, print_numbers): Explicitly check for write errors
and terminate the program with diagnostic.
* tests/misc/seq-io-errors.sh: Test error detection with /dev/full.
* tests/misc/seq-epipe.sh: Test error detection with broken pipes.
* tests/local.mk: Add new tests.
* NEWS: Mention the fix.
2016-04-24 18:19:50 -04:00
Pádraig Brady
8c8163838a stat,tail: add support for Windows Subsystem for Linux
* src/stat.c (human_fstype): Add file system ID definition,
and use "wslfs" as the name.
* NEWS (Improvements): Mention the change.
Fixes http://bugs.gnu.org/23273
2016-04-22 22:47:48 +01:00
Pádraig Brady
0f5d784bc6 yes: avoid redundant diagnostics on write error
* src/yes.c (main): For large inputs only write a single
diagnostic for write errors.
* tests/misc/yes.sh: Test when /dev/full is available.
2016-04-21 21:34:00 +01:00
Pádraig Brady
2ef6212519 sleep,timeout: support overflowing floating point values
* src/sleep.c (main): Allow ERANGE since we allow "inf" values.
* src/timeout.c (parse_duration): Likewise.
* tests/misc/sleep.sh: New file. Tests for sleep(1).
* tests/misc/timeout-parameters.sh: Add case for newly allowed
$LDBL_MAX.  Also use returns_ throughout the file.  Also avoid
small timeout values which might give false failures under load.
2016-04-21 19:41:58 +01:00
Pádraig Brady
ff6cc22d06 tests: avoid potential overflows with expr
* cfg.mk (sc_prohibit_expr_unsigned): expr uses intmax_t internally
when GMP is not available, so flag any uses of unsigned limits.
* tests/misc/timeout-parameters.sh: Remove the overflow related
to UINT_MAX as it's handled by the following case.  Change the
following case from 99... to $TIME_T_OFLOW to be more expressive
in what it's actually testing.  Directly check that commands succeed,
rather than inspecting $? afterwards.
* tests/dd/skip-seek-past-dev.sh: Guard against large device sizes.
* tests/id/setgid.sh: Protect: Guard against large group IDs.
* tests/misc/cut-huge-range.sh: Tweak comment to avoid syntax check.
It's tempting to simplify to just skip the test if expr fails,
but SIZE_MAX > INTMAX_MAX is the common case.
2016-04-21 19:34:18 +01:00
Pádraig Brady
163c70d970 tests: fix recent false failure due to a race
* tests/cp/parent-perm-race.sh: This new race introduced in
commit v8.25-5-g632eda5 is quite hard to hit, but is due to
`ls > fifo` doing write()/close()/exit() once `cp` has
open() the source fifo.  Then the subsequent comparison of the
destination file may fail due to the file being missing or empty.
Previously `ls` generated output that was independent of `cp`.
Now we must wait for `cp` to finish before inspecting the
destination file that it wrote.
2016-04-20 17:08:36 +01:00
Bernhard Voelker
85faa0f436 tests: let mkdir/p-v.sh fail when compare fails
* tests/mkdir/p-v.sh: Set fail=1 when compare fails: the latter only
sets a non-Zero return code; evaluating that is up to the caller.
2016-04-18 23:30:41 +02:00
Bernhard Voelker
9a2e8ac489 seq: do not allow NaN arguments
* src/seq.c (isnan): Define macro.
(scan_arg): Add check if the given argument is NaN, and exit with
a proper error diagnostic in such a case.
(usage): Document it.
* tests/misc/seq.pl: Add tests.
* doc/coreutils.texi (seq invocation): Document the change.
* NEWS (Changes in behavior): Mention the change.
2016-04-14 12:39:28 +02:00
Bernhard Voelker
81e589021d seq: do not allow 0 as increment value
* src/seq.c (main): Exit with an error diagnostic when the given
step value is Zero.
(usage): Document it.
* doc/coreutils.texi (seq invocation): Likewise.
* tests/misc/seq.pl: Add tests.
* NEWS (Changes in behavior): Mention the change.
Reported by Маренков Евгений in:
http://bugs.gnu.org/23110
2016-04-14 12:38:09 +02:00
Yigal Korman
8faf269250 stat,tail: add support for M1FS
* src/stat.c (human_fstype): Add file system ID definition.
* NEWS (Improvements): Mention the change, moving the previously added
"prl_fs" change note from "Changes in behavior" to here.
Fixes http://bugs.gnu.org/23283
2016-04-14 10:11:05 +02:00
Pádraig Brady
d33f1fbd67 stat: report type for "prl_fs" file systems
* src/stat.c (human_fstype): Identify the parallels file system.
Also tag as remote so that tail(1) doesn't use inotify, which
fails to detect changes made outside a VM.
Fixes http://bugs.gnu.org/23143
2016-03-31 16:38:17 +01:00
Paul Eggert
df88fce716 date ls pr: fix time zone abbrs on SysV platforms
The problematic code computed a struct tm in one time zone, and
then printed it or converted it to a string in another.  To be
portable the same time zone needs to be used for both operations.
On GNU platforms this is not an issue, but incorrect output can be
generated on System V style platforms like AIX where time zone
abbreviations are available only in the 'tzname' global variable.
Problem reported by Assaf Gordon in: http://bugs.gnu.org/23035
* NEWS: Document the bug.
* src/date.c (show_date):
* src/ls.c (long_time_expected_width, print_long_format):
* src/pr.c (init_header):
* src/stat.c (human_time): Use localtime_rz instead of localtime,
so that the time zone information is consistent for both localtime
and time-formatting functions like fprintftime and nstrftime.  For
'stat' this change is mostly just a code cleanup but it also
causes stat to also print nanoseconds when printing time stamps
that are out of localtime range, as this is more consistent with
what other programs do.  For programs other than 'stat' this fixes
bugs with time zone formats that use %Z.
* src/du.c, src/pr.c (localtz): New static var.
(main): Initialize it.
* src/du.c (show_date): New time zone argument, so that localtime
and fprintftime use the same time zone information.  All callers
changed.
* tests/misc/time-style.sh: New file.
* tests/local.mk (all_tests): Add it.
* tests/misc/date.pl: Test alphabetic time zone abbreviations.
2016-03-17 10:36:33 -07:00
Jim Meyering
c18b3699e1 maint: remove gl/lib/reg*.c.diff; no longer needed
* gl/lib/regcomp.c.diff: Remove file, now that gnulib's
regcomp.c compiles regex.c with -Wno-unused-parameter.
* gl/lib/regex_internal.h.diff: Likewise.
* gl/lib/regex_internal.c.diff: This file induced a change to ensure
that the "Idx" type was unsigned and to remove a few "VAR < 0"
comparisons.  These days, it is probably fine to stay in sync with
gnulib/glibc's copies
of these files, so remove these patches, too.
* gl/lib/regexec.c.diff: Likewise.
Prompted by a report by Assaf Gordon and a suggestion from Paul Eggert.
2016-03-15 07:36:12 -07:00
Eric Blake
e735d417fb build: update gnulib submodule to latest
Mainly for:
*bdb72bc6 set-permissions: fix compilation on Cygwin

* bootstrap: Sync with gnulib.
* gl/lib/regcomp.c.diff: Regenerate against latest gnulib.
2016-03-09 09:57:55 -07:00
Jim Meyering
68ede201e8 tests: avoid false-failure of split/filter.sh on XFS
* tests/split/filter.sh: Use OFF_T_MAX-1 rather than OFF_T_MAX
as the size of a test file, to avoid false failure on an XFS file
system (or any file system permitting a file of size OFF_T_MAX).
Reported as http://bugs.gnu.org/22931
2016-03-06 19:38:21 -08:00
Eric Blake
6475c51455 test: Document that -a and -o are undesirable
POSIX recommends avoiding -a and -o, for good reason.
src/test.c (usage): Mention that inherent ambiguities exist with
binary -a and -o.
Problem reported by Martin Gebert in: http://bugs.gnu.org/22909
2016-03-04 11:55:22 -07:00
Paul Eggert
a7f5d3d6d6 all: be less strict about usage if POSIX 2008
sort, tail, and uniq now support traditional usage like 'sort +2'
and 'tail +10' on systems conforming to POSIX 1003.1-2008 and later.
* NEWS: Document this.
* doc/coreutils.texi (Standards conformance, tail invocation)
(sort invocation, uniq invocation, touch invocation):
Document new behavior, or behavior's dependence on POSIX 1003.1-2001.
* src/sort.c (struct keyfield.traditional_used):
Rename from obsolete_used, since implementations are now allowed
to support it.  All uses changed.
(main): Allow traditional usage if _POSIX2_VERSION is 200809.
* src/tail.c (parse_obsolete_option): Distinguish between
traditional usage (which POSIX 2008 and later allows) and obsolete
(which it still does not).
* src/uniq.c (strict_posix2): New function.
(main): Allow traditional usage if _POSIX2_VERSION is 200809.
* tests/misc/tail.pl: Test for new behavior.
2016-02-23 01:05:10 -08:00
Paul Eggert
4c1995f1b6 doc: document sort -o F F danger
Problem reported by Yanyan Jiang 蒋炎岩 in: http://bugs.gnu.org/22769
* doc/coreutils.texi (sort invocation):
Mention possibility of 'sort -o F F' data loss during crashes.
2016-02-22 23:49:09 -08:00
Daniel Lockyer
587a1ba5df date: free timezone variable to avoid valgrind warning
* src/date.c (main): Free TZ variable to pacify valgrind, guarded
by IF_LINT.
2016-02-16 17:53:24 +01:00
Pádraig Brady
f91f2bf951 split: adjust recent --number changes
* src/split.c (lines_rr): Reinstate the conditional
setting of the WROTE boolean, as otherwise split -n r/1 would
consume all input when all --filter commands are stopped.
There was a test in place to check for this, but
it was incorrect as detailed below.
(input_file_size): Immediately disallow --number with
non seekable inputs, as such an invocation is not currently
generally supported and will fail as the data overflows
the internal buffer.
* tests/split/l-chunk.sh: Adjust to again disallow -n /dev/zero.
Also change all '&& fail=1' checks to use the 'returns_ 1' form.
* tests/split/filter.sh: Change the no longer supported /dev/zero
case to a regular $OFF_T_MAX file (supported on XFS for example).
Also fix the timeout(1) commands so they're not subject to
pipefail issues.
2016-02-15 22:03:15 -08:00
Göran Uddeborg
222e83056d stty: fix translated --help so the gettext header is not printed
* src/stty.c (usage): Remove an erroneous call to translate an
empty string, added in commit v8.23-112-g564f84a, which results
in the gettext header being printed for translated languages.
* THANKS.in: Remove the now committer.
* NEWS: Mention the bug fix.
2016-02-15 13:06:23 -08:00
Paul Eggert
632eda520f tests: don't wait forever on GNU/Hurd
* tests/cp/parent-perm-race.sh: Add timeouts so that the test does
not wait forever on GNU/Hurd.  This does not fix the underlying
bug but at least lets the tests make progress.
Problem reported by Nelson H.F. Beebe in: http://bugs.gnu.org/22624
Also, check that 'cp' actually copies the data; this is a better
test anyway, and simplifies the test code.
Also, avoid unlikely race if 'pid' is set in the environment.
2016-02-12 10:59:54 -08:00
Paul Eggert
62e7af0326 split: fix problems with /dev/zero
Problem reported by Nelson H.F. Beebe in: http://bugs.gnu.org/22624
Other problems also fixed: basically, the code got confused because
GNU/Linux reports that /dev/zero has size zero.
* src/split.c (input_file_size): Now takes struct stat *, not just
size.  Always store the first buffer.  All callers changed.  Treat
/dev/zero as an infinitely-large file, both on GNU/Linux where
fstat and lseek say its size is zero, and on GNU/Hurd where they
say the size is OFF_T_MAX.
(cwrite): Return true on success.
(bytes_split): Don't try to read past EOF, and stop if a write fails.
(lines_rr): Omit stray check for ignorable errno.
(main): Get file size only when n_units > 1, since that's the only
time it is needed.  Defer most of the work to input_file_size.
* tests/split/l-chunk.sh: Adjust tests to match new behavior
on oddball inputs.
2016-02-12 10:16:47 -08:00
Vincent Lefevre
380ab8453d doc: fix the --iso-8601 example in date --help
* src/date.c (usage): The colon is used in the timezone offset
since commit v8.24-64-g17bbf6c.
* THANKS.in: Remove committer.
Fixes http://bugs.gnu.org/22491
2016-01-29 23:12:08 -08:00
Pádraig Brady
6412d569dc build: avoid dynamic linking issue on Solaris sparc
Solaris Studio 12 on sparc (not x86) will not remove
unused functions, thus leaving a reference to an
undefined program_name symbol from emit_try_help().

* src/system.h (emit_try_help): Change from an inline function
to a macro, so that the inline function is not actually
defined in libstdbuf.c.
Fixes http://bugs.gnu.org/22430
2016-01-24 18:09:08 -08:00
Pádraig Brady
cfdac06196 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2016-01-20 10:56:02 +00:00
Pádraig Brady
68f73f2386 version 8.25
* NEWS: Record release date.
2016-01-20 10:31:56 +00:00
Pádraig Brady
f967d5bf05 tests: avoid false failure in tail inotify test
* tests/tail-2/wait.sh: Restrict inotify specific test portion
to local file systems and also not with ---disable-inotify specified.
Failure noticed on NFS.
2016-01-19 18:50:11 +00:00
Pádraig Brady
7c2e423409 tests: avoid false failure due to remove() ignoring u-w on NFS
* tests/rm/rm1.sh: Also remove the group write bit which
was required on one NFS setup at least.  Note u-w was
enough to deny file creation, g-w was also required to
deny file removal.
* tests/rm/cycle.sh: Likewise.
* tests/mv/perm-1.sh: Likewise.
2016-01-19 18:27:43 +00:00
Pádraig Brady
b4f10133bf tests: avoid false failure in preserve-slink-time.sh on GPFS
* tests/cp/preserve-slink-time.sh: Add a delay between the
ln and the cp so that there is enough difference between
the timestamps so GPFS won't discard the update.
Reported by Assaf Gordon.
2016-01-19 16:09:09 +00:00
Pádraig Brady
f0dc5ec6f9 tests: avoid false failure in shred-passes.sh
* tests/misc/shred-passes.sh: Specify an exact amount to shred,
to avoid running out of simulated random data on file systems
with a large st_blksize like GPFS for example.
Reported by Assaf Gordon.
2016-01-19 16:08:59 +00:00
Pádraig Brady
dbff2508b8 tail: disable inotify with only non existent files
tests/tail-2/F-headers.sh and test/tail-2/retry.sh fail on
on remote file systems due to tail going into inotify mode
due to not being able to determine the remoteness of the
non existent files.

* src/tail.c (any_non_remote_file): A new function used
to disable inotify when there are no open files, as
we can't determine remoteness in that case.
* NEWS: Mention the bug fix.
2016-01-19 14:07:10 +00:00
Pádraig Brady
6e2208e07a all: don't unconditionally use leaf optimization for NFS
* gnulib: Update to latest where the only change is to
not unconditionally enable leaf optimization for fts on NFS,
as it was seen to abort() with some NFS servers as per:
https://bugzilla.redhat.com/1299169
This affects utilities that traverse directories like
cp, rm, chmod etc.
* NEWS: Adjust the improvement message to leave only XFS.
2016-01-18 18:39:16 +00:00
Assaf Gordon
4e96050b76 tests: adjust memory limits in head-c.sh
* tests/misc/head-c.sh: Further increase the limit to 8MB over
the base test command.  5.1MB was seen as minimum extra needed
on FreeBSD 9.3 x86_64.
2016-01-18 18:29:47 +00:00
Pádraig Brady
3f02d93be2 tests: adjust delays to avoid false positives
* tests/rm/dangling-symlink.sh: The effective delay was only
1.5s.  So delay before the operation, and increase the iteration
count by 1 to increase the delay to 6.3s.  This failure was
noticed once on a FreeBSD 10.2 x86_64 virtual machine.
* tests/dd/stats.sh: Remove quotes on sleep argument
to ensure arguments are accumulated appropriately.
* tests/du/move-dir-while-traversing.sh: sleep before operation,
to increase the effective delay from 1.6s to 3.2s.
* tests/tail-2/flush-initial.sh: Likewise.
* tests/tail-2/pipe-f2.sh: Sleep first so that the effective delay
matches the commented value.
2016-01-18 15:32:17 +00:00
Pádraig Brady
cc05c3c16d test: skip test rather than fail with Solaris 10 sed
* tests/rm/r-root.sh: This test was seen to ERROR due to
sed input not having a terminating '\n'.  Therefore just skip
with diagnostics upon failure to adjust the error output with sed.
Reported by Assaf Gordon.
2016-01-18 13:07:27 +00:00
Pádraig Brady
1204da74e3 tests: fix false failure with spaces in absolute $PWD
* tests/install/create-leading.sh: Ensure $PWD is quoted.
Reported by `make dist-check`.
2016-01-16 17:45:57 +00:00
Pádraig Brady
b304e4ece8 build: update gnulib submodule to latest
Mainly for:

* dce117a sig2str: list all signals on FreeBSD >= 7
* cff4b38 acl-permissions: port to USE_ACL==0 platforms
2016-01-16 17:13:44 +00:00
Pádraig Brady
fa9ae62a9e tests: show mount list on failure for df tests
* init.cfg (dump_mount_list_): A new function to output the
system mount list.
* tests/df/df-symlink.sh: Call dump_mount_list_ upon failure.
* tests/df/over-mount-device.sh: Likewise.
* tests/df/problematic-chars.sh: Likewise.
* tests/df/skip-rootfs.sh: Likewise.
* tests/df/total-verify.sh: Likewise.
* tests/df/unreadable.sh: Likewise.
2016-01-16 13:53:48 +00:00
Pádraig Brady
2a5494271c tests: avoid false failure with BTRFS subvolumes
* tests/df/df-symlink.sh: Only check the symmetry of
the source <-> target lookup, when the source is only mounted once,
which isn't the case if '.' is a BTRFS subvolume for example.
Reported by Assaf Gordon on a default OpenSUSE 42.1 install.
2016-01-16 13:36:57 +00:00
Pádraig Brady
0d60653001 mv: consistently warn about multiply specified source dirs
* src/copy.c (copy internal): Remember directories irrespective
of their link count, because on some file systems like BTRFS,
directories always have a link count of 1.
2016-01-16 11:40:54 +00:00
Pádraig Brady
3aa84d02dd tests: remove a non portable localtime test
* tests/misc/date.pl: This test was dependent on perl
unconditionally calling the system localtime() as date(1) does.
However perl has its own configure checks in place to avoid buggy
localtime implementations.  Therefore comment out this test
as a FIXME for now.  This test was seen to fail on FreeBSD 10
where localtime() returns nonsense values instead of failing
for arguments >= 2^56.
2016-01-15 16:00:27 +00:00
Pádraig Brady
7648870f39 tests: adjust memory limits in head-c.sh
* tests/misc/head-c.sh: Further increase the limit, to account
for the fact that head(1) needs at least 1.576MB over the base test
command on FreeBSD 10.  4MB should be enough headroom while
still providing over allocation protection.
Reported by Assaf Gordon.
2016-01-15 14:19:48 +00:00
Pádraig Brady
4c7d82f1f1 tests: simplify invalid signal determination for kill -l
* src/operand2sig.c (operand2sig): Add a detailed comment explaining
why we validate even very large shell exit status values.
* tests/misc/kill.sh: Add a test case for the ksh scheme.
Simplify the INVALID signal number determination which also avoids
a false failure on systems like FreeBSD 10 with incomplete
signal list (caused by inaccurate NSIG).
2016-01-15 14:14:06 +00:00
Pádraig Brady
b955a4fb6d tests: support older fallocate number formats
* tests/cp/fiemap-extents.sh: Support RHEL6 fallocate
which doesn't support IEC suffixes like "MiB" on numbers.
Also add some extra framework_failure_ protections.
Reported by Assaf Gordon.
2016-01-15 14:14:05 +00:00
Pádraig Brady
89f7adb158 tests: avoid coredumps when determining memory limits
* init.cfg (get_min_ulimit_v_): Refactor ulimit call to...
(ulimit_supported_): ...here, and add calls to avoid coredumps.
2016-01-15 14:14:02 +00:00
Pádraig Brady
611e7e02bf sort: with --debug, flag setlocale() failures on OpenBSD
Locale categories are not equivalent on OpenBSD,
and LC_COLLATE only supports "C" for example.
Now LC_ALL is supported to set multiple other categories
on OpenBSD, so setlocale(LC_ALL, "") returns a string
indicating which categories were updated and which ignored.
Therefore...

* src/sort.c (main): ...Call setlocale(LC_COLLATE, "")
to explicitly check whether a specified LC_ALL or
LC_COLLATE environment variable value is supported
for the LC_COLLATE category.  Also use !! to explicitly
convert to bool to support c89 systems where bool is an int,
and thus would get values > 1.
Reported by Assaf Gordon.
2016-01-14 01:26:00 +00:00
Pádraig Brady
4ab8704dc0 maint: remove temporary doc/constants.texi-t during build
* doc/local.mk (constants.texi): Remove temp file.
2016-01-13 12:11:39 +00:00
Pádraig Brady
7ebc4d84c2 maint: fix old spelling mistakes in NEWS
* NEWS: s/descendent/descendant/; s/indiscriminite/indiscriminate/.
* cfg.mk (old_NEWS_hash): Update via `make update-NEWS-hash`.
2016-01-13 11:28:45 +00:00
Pádraig Brady
6ceb7ef87f doc: suggest dd "sync" flag to maximize "nocache" effectiveness
doc/coreutils.texi (dd invocation): Add oflag=sync to the streaming
example.  Also reference the "direct" flag.  Mention this is only
a request to the system.
* src/dd.c (usage): Mention the "sync" flag along with "nocache".
Also mention that it's only a request to drop the cache.
* THANKS.in: Add reporter Francois Rigault.
2016-01-13 11:16:39 +00:00
Pádraig Brady
a0c5313d60 doc: mention the '0#' printf flags with stat %a
* src/stat.c (usage): Mention the '#' and '0' flags are useful with %a.
* doc/coreutils.texi (stat invocation): Likewise.  Also give an example
printing unambiguous octal output.
Reported at http://bugs.debian.org/810539
2016-01-13 11:16:39 +00:00
Pádraig Brady
d506af44be mv: fix data loss with repeated source dir and same destination
commit v8.23-31-g90aa291 failed to consider this case,
where the previous rename has failed, thus causing the
following to remove the specified directory:

  mv dir dir dir

* src/copy.c (copy_internal): Assume this rename attempt has
succeeded, as a previous failure will already have been handled,
and we don't want to remove the source directory in this case.
* tests/cp/duplicate-sources.sh: Consolidate this test file to...
* tests/mv/dup-source.sh: ...here.  Add test cases for same
source and dest.
* tests/local.mk: Remove the consolidated test.
* NEWS: Mention the bug fix.

Reported at https://bugzilla.redhat.com/1297464
2016-01-13 11:16:37 +00:00
Pádraig Brady
2370c64a10 tests: include part of wc-files0.sh skipped by mistake
* tests/misc/wc-files0.sh: $fail is always set to 0,
so correct the test to include that part of the test case.
2016-01-13 11:11:36 +00:00
Pádraig Brady
3ed89ae932 wc: avoid ambiguous output with '\n' in file names
* src/wc.c (write_counts): Shell escape the file name
if it contains '\n' so only a single line per file is output.
* tests/misc/wc-files0.sh: Add a test case.
* NEWS: Mention the improvement.
2016-01-13 11:11:36 +00:00
Assaf Gordon
672663e1b0 numfmt: add the -z,--zero-terminated option
* doc/coreutils.texi (numfmt invocation): Reference the description.
* src/numfmt.c: Parameterize '\n' references.
* tests/misc/numfmt.pl: Add tests for character and field processing.
* NEWS: Mention the new feature.
2016-01-13 11:11:36 +00:00
Pádraig Brady
8297568ec6 paste: add the -z,--zero-terminated option
* doc/coreutils.texi (paste invocation): Reference -z description.
* src/paste.c (main): Parameterize the use of '\n'.
* tests/misc/paste.pl: Add test cases.
* NEWS: Mention the new feature.
2016-01-13 10:59:56 +00:00
Pádraig Brady
0e46753d7c comm: support NUL --output-delimiter for consistency
* src/comm.c (main): Track the output delimiter length,
so that it can be adjusted to 1 for the NUL delimiter.
Also rename the global variable from "delimiter" to
"col_sep" so its use is more obvious, and to distinguish
from the recently added "delim" global variable.
* tests/misc/comm.pl: Adjust accordingly.
2016-01-13 10:59:56 +00:00
Pádraig Brady
f3b4def577 comm: add the -z,--zero-terminated option
* doc/coreutils.texi (comm invocation): Reference option description.
* src/comm.c (main): Use readlinebuffer_delim() to support
a parameterized delimiter.
* tests/misc/comm.pl: Add test cases.
* NEWS: Mention the new feature.
2016-01-13 10:59:56 +00:00
Pádraig Brady
826c98b024 tac: support an empty (NUL) --separator
* doc/coreutils.texi (tac invocation): Mention the
NUL delineation with an empty --separator.
* src/tac.c (main): Allow an empty separator when -r not specified.
* tests/misc/tac.pl: Add test cases.
* NEWS: Mention the new feature.
Fixes http://bugs.gnu.org/8103
2016-01-13 10:59:56 +00:00
Pádraig Brady
a499a0ce58 cut: add the -z,--zero-terminated option
* doc/coreutils.texi (cut invocation): Reference the description.
* src/cut.c: Parameterize '\n' references.
* tests/misc/cut.pl: Add tests for character and field processing.
* NEWS: Mention the new feature.
2016-01-13 10:59:56 +00:00
Richard Russon
bc94551f63 head,tail: add the -z,--zero-terminated option
* doc/coreutils.texi: Reference the option description.
* src/head.c: Parameterize the delimiter character.
* src/tail.c: Likewise.
* tests/misc/head.pl: Add test case.
* tests/misc/tail.pl: Likewise.
* NEWS: Mention the new feature.
2016-01-13 10:59:55 +00:00
Pádraig Brady
b2eadd109c join,sort,uniq: with -z, treat '\n' as a field separator
* NEWS: Mention the change in behavior.
* doc/coreutils.texi (newlineFieldSeparator): A new description,
referenced from ({join,sort,uniq} invocation).
* src/system.h (field_sep): A new inline function to determine
if a character is a field separator.
* src/join.c (usage): s/whitespace/blank/ to be more accurate
wrt which characters are field separators.
(xfields): s/isblank/field_sep/.
* src/sort.c (inittables): Likewise.
* src/uniq.c (find_field): Likewise.
* tests/misc/join.pl: Adjust -z test, and add a test/example
for processing the whole record with field processing.
* tests/misc/sort.pl: Add -z test cases, including case with '\n'.
* tests/misc/uniq.pl: Add -z -f test case with \n.
2016-01-13 10:59:18 +00:00
Bernhard Voelker
d44ae88199 tests: fix races wrt output files of background processes
At least the false positive in tail-2/follow-stdin.sh could be seen
on a 4-core i5 system with -j8.  Fix similar cases. too.

* tests/tail-2/follow-stdin.sh: Empty the 'out' file in each iteration.
Otherwise, under heavy system load, 'check_tail_output' would see the
expected output from the previous round before tail would have the
chance to come up in the background.
While at it, move the creation of the 'exp' file out of the loop.
* tests/dd/stats.sh: Empty the output file of the background process
here, too.
* tests/misc/cat-buf.sh: Likewise.
* tests/misc/stdbuf.sh: Likewise.
* tests/tail-2/wait.sh: Likewise.
2016-01-10 01:51:27 +01:00
Pádraig Brady
3d7b822e4a stty: support "flusho" local setting
This is used to discard terminal output on FreeBSD based systems.

* src/stty.c (mode_info): Add FLUSHO where supported.
(usage): Document for "local" and "combination" settings.
* doc/coreutils.texi (local stty settings): Document,
mentioning that this option is supported but ignored on GNU/Linux.
2016-01-06 16:04:19 +00:00
Pádraig Brady
cb7d8b90a2 stty: support [-]drain setting to control waiting for pending Tx
Instead of commit v8.24-132-g5171bef which only provides
control to disable this behavior (with -I), provide
the symmetrical "[-]drain" special setting.

* src/stty.c (main): Parse the [-]drain setting instead of -I,
and treat like a global option.
(usage): Adjust accordingly.
* tests/misc/stty.sh: Test "drain" with and without options.
* NEWS: Mention the new feature.
2016-01-06 15:20:49 +00:00
Pádraig Brady
5171befcb1 stty: support -I, --immediate to not wait for pending transmission
In some cases an initial drain may block indefinitely as discussed at:
http://lists.gnu.org/archive/html/coreutils/2016-01/msg00007.html

* src/stty.c (main): Use TCSANOW rather than TCSADRAIN if -I specified.
(usage): Document the new option.
* doc/coreutils.texi (stty invocation): Likewise.
* tests/misc/stty.sh: Ensure -I is supported.
* NEWS: Mention the new feature.
2016-01-04 23:45:19 +00:00
Pádraig Brady
c6be0b3943 doc: avoid unwanted display of the 'coreutils' command info
* doc/coreutils.texi (coreutils): Remove this direntry
so that `info coreutils` will display the table of contents,
rather than the unlikely intended coreutils Multi-call invocation.
This also supports lookups like `info coreutils readlink`,
but note that only works with the standard info viewer,
and not with pinfo for example.
2016-01-03 12:58:39 +00:00
Pádraig Brady
1dd02b4f8c doc: mention in more places that -D will create --target-directory
* src/install.c (usage): Mention this commonly required functionality
in the -D option description.
* doc/coreutils.texi (install invocation): Likewise for the
--target-directory description.
2016-01-03 12:58:39 +00:00
Pádraig Brady
73055581c9 install: only attempt to create a target dir once
* src/install.c (main): As an optimization, when calling
install_file_in_dir() for each file, only attempt to create
the target directory once, as this is invariant over the loop.
2016-01-03 12:58:39 +00:00
Pádraig Brady
6c65ce4c64 install: fix relative copies to absolute directory with -D
* src/install.c (mkancesdirs_safe_wd): Unconditionally
restore the current working directory when possibly called
multiple times (from install_file_in_dir()).
* tests/install/create-leading.sh: Add a test case.
* NEWS: Mention the fix.
Fixes http://bugs.gnu.org/21497
2016-01-03 12:58:39 +00:00
Bernhard Voelker
50a950ba69 maint: fix sc_long_lines to warn about 100+ maximum line length again
Since commit v8.23-60-g414a8cf, the above check failed to find sources
where the length of the longest line is a 3 or more digit number.

* cfg.mk (sc_long_lines): Remove the '\' escape character before '{'
and '}', because this would mean literal '{' and '}' characters in
an extended regular expression in sed(1).
2016-01-03 00:18:58 +01:00
Pádraig Brady
aaf8d80f1d maint: avoid a sc_long_lines failure in recent commit
* src/dd.c (alloc_ibuf): Shorten line length.
2016-01-01 14:24:19 +00:00
Pádraig Brady
b16e999f55 maint: update all copyright year number ranges
Run "make update-copyright" and then...

* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
2016-01-01 14:10:41 +00:00
Paul Eggert
81dce30cba build: update gnulib submodule to latest 2015-12-31 14:13:45 -08:00
Paul Eggert
2dab6cd3c2 dd: append spaces to shorter status=progress line
Problem noted by Pádraig Brady in: http://bugs.gnu.org/22277#8
Also, make the output a bit more precise while we're at it.
* NEWS: Document this.
* src/dd.c (previous_time): Remove, replacing with ...
(next_time): New var.  All uses changed.
This avoids some rounding errors, and should be a bit faster.
(newline_pending): Remove, replacing with ...
(progress_len): New var.  All uses changed.
This lets us keep track of how many trailing spaces to append.
(print_xfer_stats): Get the time first thing, so that it's
closer to being correct.  Count the bytes output, and append
trailing spaces if needed.  Add remarks to translators about
translation lengths.
2015-12-31 14:09:36 -08:00
Paul Eggert
8f9bf30017 dd: summarize in --human-readable format too
Problem reported by Linda Walsh in: http://bugs.gnu.org/17505
* NEWS: Document this.
* doc/coreutils.texi (dd invocation): Use a simpler script.
Adjust output example to match new behavior.
* src/dd.c (human_size): Remove.
All uses changed to use human_readable and ...
(human_opts): ... this new constant.
(abbreviation_lacks_prefix): New function.
(print_xfer_stats): Use it.  Output both --si and --human-readable
summaries, but only if they have prefixes.
* tests/dd/reblock.sh, tests/dd/stats.sh: Test new behavior.
2015-12-31 11:49:55 -08:00
Pádraig Brady
26323928d9 build: update to latest gnulib
Mainly for these changes:
- freadptr: fix to work with ungetc on all uClibc configs
- fts: enable leaf optimization for XFS
- fts: ensure leaf optimization used for NFS
- strftime-tests: avoid false failure on OS X
- intprops-tests: avoid warnings (causing CI failures)

* NEWS: Update with items from above that are
significant from the previous coreutils release.
2015-12-23 01:07:48 +00:00
Pádraig Brady
3205bb178c doc: describe test operator precedence and associativity
* doc/coreutils.texi (Connectives for test): Add notes
on precedence and associativity.  Also mention the
portability caveats with these operators.
* cfg.mk: Avoid sc_prohibit_test_minus_ao for coreutils.texi.
Fixes http://bugs.gnu.org/22216
2015-12-22 16:54:18 +00:00
Pádraig Brady
f8a9c8c343 tests: avoid root test false failure without libxattr
* tests/cp/cp-mv-enotsup-xattr.sh: Exclude xattr copy verification
when libxattr is not available.
2015-12-17 16:59:46 +00:00
Bernhard Voelker
5148302771 build: rely on umask for setting permissions in tarball
Commit v8.24-116-g896006b changed the file permissions for the tarball
using ug+rw.  Better to let the umask decide whether the file should
be group-writeable or not.

* Makefile.am (dist-hook): Change chmod call from 'ug+rw' to '+rw'.
2015-12-17 12:46:59 +01:00
Pádraig Brady
cd6e49ced8 tests: avoid intermittent ulimit -v failures
* init.cfg (get_min_ulimit_v_): Increase the determined
virtual memory limit for the command by a page size
to avoid alignment issues causing false failures for
subsequent runs.
* tests/misc/cut-huge-range.sh: Be defensive and match
the cut invocations under test, more closely with the
form used to determine the VM memory limit.

This was noticed on i686 linux at:
http://hydra.nixos.org/build/28990456
2015-12-17 00:25:49 +00:00
Pádraig Brady
896006bf76 build: ensure all files are writable in the tarball
* Makefile.am (dist-hook): Ensure all files are writable
so that extracted tarballs are easy to remove, without
getting prompts about removing read-only files.
Reported by Benno Schulenberg.
2015-12-17 00:25:25 +00:00
Pádraig Brady
f9a6c5b3b6 maint: ensure emit_mandatory_arg_note() used if needed
* cfg.mk (sc_emit_mandatory_arg_note): Add new syntax check.
2015-12-15 17:44:45 +00:00
Pádraig Brady
070cec3234 maint: include 'env' commands in returns_ syntax check
* cfg.mk (sc_prohibit_and_fail_1): Remove 'env' from
the exclusion list.
* tests/misc/env.sh: Adjust accordingly.
* tests/misc/help-version.sh: Likewise.
2015-12-15 17:44:45 +00:00
Pádraig Brady
d3ddf7bce4 tests: improve kill tests
* tests/misc/kill.sh:
- verify kill -[lt] support multiple parameters.
- verify kill -[lt] fail with (some) invalid parameters.
- Use returns_1 ... || fail=1, rather than ... && fail=1.
2015-12-15 17:07:39 +00:00
Pádraig Brady
872c0df857 sort: fix --debug marking for -b -k1.x
We were erroneously skipping blanks in the marked comparison
_after_ the key start offset was applied.
* src/sort.c (debug_keys): Don't skip starting blanks
if already handled by begfield().
* tests/misc/sort-debug-keys.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/22155
2015-12-14 13:40:51 +00:00
Pádraig Brady
1118f32145 stat: report file system type for "overlayfs"
* src/stat.c (human_fstype): Add "overlayfs", and tag it as "remote"
to ensure that tail continues to use the more conservative polling mode.
* README-release: Remove a stale comment about updating fremote()
in tail.c.  Also give a link to *_SUPER_MAGIC definitions
not in the standard linux/magic.h location.
* NEWS: Mention that this file system is recognized.
2015-12-14 13:38:43 +00:00
Pádraig Brady
03bef91781 kill: add undocumented -L for compatibility
procps, bash >= 4.4, and util-linux >= 2.23
all have the -L option to output a table.

* src/kill.c (main): Have -L synonymous with -t.
Luckily there is no signal that begins with 'L'.
* tests/misc/kill.sh: Update the test.
2015-12-14 13:37:22 +00:00
Pádraig Brady
fc8e719973 tests: add tests for the kill command
* tests/misc/kill.sh: Add first tests for kill.
* tests/local.mk: Reference the new test.
2015-12-14 13:36:41 +00:00
Pádraig Brady
c609cd960d maint: fix incorrect spellings etc
* NEWS: Use a standard version specification.
* doc/coreutils.texi: Fix incorrect grammar.
* src/df.c: Update a stale comment.
* src/copy.c: Fix incorrect spellings.
* src/factor.c: Likewise.
* src/ls.c: Likewise.
* src/pr.c: Likewise.
* src/relpath.c: Likewise.
* src/shred.c: Likewise.
* src/sort.c: Likewise.
* src/split.c: Likewise.
* src/stdbuf.c: Likewise.
* tests/misc/seq-precision.sh: Likewise.
2015-12-14 13:36:23 +00:00
Pádraig Brady
5f87f1ac1c maint: remove form feed characters from sources
These are no longer useful and can impact viewing
patches in some mail programs for example.

* src/cksum.c: Remove ^L characters.
* src/comm.c: Likewise.
* src/kill.c Likewise.
* src/ln.c Likewise.
* src/nl.c Likewise.
* src/pr.c Likewise.
* src/ptx.c Likewise.
* src/split.c Likewise.
* src/tr.c Likewise.
* src/tsort.c Likewise.
* src/uniq.c Likewise.
* src/wc.c Likewise.
* cfg.mk (sc_prohibit-form-feed): A new syntax check.
2015-12-14 02:35:10 +00:00
Eric Blake
2c5d86a8b8 sort: promote '--debug'
* src/sort.c (usage): Mention --debug in KEYDEF paragraph.
2015-12-07 14:12:07 -07:00
Paul Eggert
c840d3ad89 doc: promote 'sort --debug'
* README, doc/coreutils.texi (Introduction, sort invocation):
Suggest 'sort --debug' more prominently.
2015-12-07 10:04:44 -08:00
Pádraig Brady
ad9dde0b25 doc: improve the description of sort --random-sort
* src/sort.c (usage): Avoid mentioning the implementation,
rather focusing on the result of the operation.
2015-12-04 20:42:17 +00:00
Paul Eggert
9735fed143 build: port to Studio C on Solaris 12
Reported by Rich Burridge in: http://bugs.gnu.org/22087
* configure.ac (HAVE_UT_HOST, HAVE_C_LINE, stdbuf):
Pacify picky compilers that complain about unreachable statements.
2015-12-03 13:56:16 -08:00
Bernhard Voelker
7c3f05cf6c doc: clarify behaviour of mv for existing target directories
* doc/coreutils.texi (mv invocation): Add a sentence to clarify that
mv(1) will only replace empty directories in the target, and fail with
a diagnostic otherwise.  Discussed at:
http://lists.gnu.org/archive/html/coreutils/2015-12/msg00000.html
2015-12-01 23:30:14 +01:00
Bernhard Voelker
f7ab20cd60 doc: avoid confusing K argument in the man pages of head and tail
The character 'K' representing numeric user input can be confusing,
especially in the context where it can be suffixed by the multipliers
K, M, G, etc.
Use NUM instead.

* doc/coreutils.texi (head invocation): Replace @var{k} by @var{num}.
Also change @var{count} in the paragraph about the obsolete option
syntax.
(tail invocation): Likewise.  Furthermore, adjust the option order to
alphabetical sorting.
* src/head.c (usage): s/K/NUM/ in as placeholder in the -c and -n
options.  Furthermore, print the actual DEFAULT_NUMBER instead of the
hard-coded 10.
* src/tail.c (usage): s/K/NUM/ in as placeholder in the -c and -n
options.  Add "[+]" to clarify that NUM may optionally be preceded by
this sign.  Remove the redundant explanation of the optional '+' prefix
for NUM, as that is now clear from the option description above.

Suggested by Dan Jacobson in http://bugs.gnu.org/22042
2015-11-30 22:09:29 +01:00
Bernhard Voelker
79c5b8f452 doc: reference each other in the man pages of head and tail
* man/head.x: Add "SEE ALSO" section referencing tail(1).
* man/tail.x: Add "SEE ALSO" section referencing head(1).

Suggested by Dan Jacobson in http://bugs.gnu.org/22041
2015-11-28 21:13:35 +01:00
Pádraig Brady
c1b3d65877 build: support reproducible builds with consistent man pages
Use a consistent date in the generated man pages
even if SOURCE_DATE_EPOCH is not set.

* Makefile.am: Generate .timestamp in the tarball.
* man/local.mk: Pass .timestamp if available to help2man.
* man/dummy-man: Don't bother with the year in the stub.

Reported in http://bugs.debian.org/806321
2015-11-28 00:11:06 +00:00
Pádraig Brady
93e83ff52f doc: update to latest help2man
Sync with version 1.47.3 which provides these significant changes:

- support for reproducible builds by using $SOURCE_DATE_EPOCH.
- Adjust spacing of italic text at roman/italic boundaries.
2015-11-27 11:42:53 +00:00
Pádraig Brady
f0d963da29 tests: for compare_(), use cmp -s where available
* tests/init.sh (compare_): Only fall back to cmp without
the POSIX defined -s option, where this is not available.
2015-11-25 15:12:37 +00:00
Pádraig Brady
34f20fcc4a build: avoid makeinfo unless required
* doc/local.mk (constants.texi): Avoid calling makeinfo unless
the constants derived from tail and shred have changed.
This avoids a dependence on makeinfo from patched sources,
and avoids an expensive makeinfo call for developers.
2015-11-25 15:12:37 +00:00
Pádraig Brady
bc1bf0fdc2 doc: clarify descriptions for tr --squeeze-repeats
* doc/coreutils.texi (uniq invocation): Fix the description of
problematic input to say "blank lines" rather than "two or more
blank lines".
(tr invocation): Clarify that -s only works with SET1 when
not translating (when SET2 not specified).  Also explicitly
state in examples where blank lines are deleted.
Also add "deleting" to the menu item.
* src/tr.c (usage): Improve the -s summary to say it always
operates on the last specified SET.
2015-11-25 15:12:35 +00:00
Pádraig Brady
5595024a2f doc: provide an example for prefixing all tail output lines
* doc/coreutils.texi (tail invocation): Provide an example using awk
to convert tail ==> file <== headers to file: prefixes on each line.
Suggested by Stephen Shirley.
2015-11-25 01:21:58 +00:00
Dmitry Monakhov
eea6b49210 copy: fix copying of extents beyond the apparent file size
fallocate can allocate extents beyond EOF via FALLOC_FL_KEEP_SIZE.
Where there is a gap (hole) between the extents, and EOF is within
that gap, the final hole wasn't reproduced, resulting in silent
data corruption in the copied file (size too small).

* src/copy.c (extent_copy): Ensure we don't process extents
beyond the apparent file size, since processing and allocating
those is not currently supported.
* tests/cp/fiemap-extents.sh: Renamed from tests/cp/fiemap-empty.sh
and re-enable parts checking the extents at and beyond EOF.
* tests/local.mk: Reference the renamed test.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/21790
2015-11-24 00:49:03 +00:00
Pádraig Brady
6df26278d6 md5sum,sha*sum: ensure --ignore-missing fails when no file verified
* src/md5sum.c (digest_check): Update a matched_checksums bool upon
matched checksum, and fail (loudly unless --status is specified)
if there were no matches.  Also change properly_formatted_lines
to a bool while at it since we don't need to track the plurality.
* tests/misc/md5sum.pl: Add a test case.
Suggested by Jim Meyering.
2015-11-23 18:06:38 +00:00
Luther Thompson
9fd0662faa md5sum,sha*sum: add --ignore-missing for checking a subset of files
* doc/coreutils.texi (md5sum invocation): Document the new option.
* src/md5sum.c (digest_file): Return an empty digest to indicate
a missing file.
(digest_check): Don't fail or output status given an empty checksum.
(usage): Document the new option.
(main): Process and validate the new option.
* tests/misc/md5sum.pl: Add new test cases.
* NEWS: Mention the new feature.
Fixes http://bugs.gnu.org/15604
2015-11-23 12:58:10 +00:00
Pádraig Brady
561f759b01 maint: allow 'sha*sum:' tag in commit summaries
To support "md5sum,sha*sum:"
Suggested by Bernhard Voelker.
2015-11-23 11:16:17 +00:00
Pádraig Brady
c7f049c503 doc: give a tee example for combining process substitution outputs
This can be useful if you want to further process data
from process substitutions. For example:
  datagen | tee >(md5sum --tag) > >(sha256sum --tag) | sort

* doc/coreutils.texi (tee invocation): Mention that -p is
useful with pipes that may not consume all data.
Add an example, similar to the one above.
* THANKS.in: Add Jirka Hladky.
2015-11-21 16:45:18 +00:00
Pádraig Brady
56d3269207 tests: avoid false failure on older NFS implementations
* tests/ls/stat-failed.sh: Skip the test if 'd' is returned as the type,
and document where this was seen.  Also flag failure to write small
temp files during the test as an error rather than a failure.
Fixes http://bugs.gnu.org/21130
2015-11-21 11:03:14 +00:00
Pádraig Brady
accb18329d build: fix VPATH build with --disable-dependency-tracking
* src/local.mk: Run `mkdir -p src` in all our explicit rules,
as in a VPATH build the src/ dir is only created at configure time
as a side effect of dependency tracking generation.
2015-11-19 00:25:46 +00:00
Jim Meyering
dab71a37d0 scripts: update versions of gettext and libtool 2015-11-17 11:42:37 +01:00
Jim Meyering
4a6ed21b15 maint: remove unmaintained file, c99-to-c89.diff
* src/c99-to-c89.diff: Remove file.
* src/local.mk (EXTRA_DIST): Remove it from this list.
* README (Pre-C99 build failure): Update section.
2015-11-17 11:42:37 +01:00
Assaf Gordon
4c5c6cad85 csplit: check and report fwrite errors with errno
discussed in:
http://lists.gnu.org/archive/html/coreutils/2015-10/msg00091.html

* src/csplit.c: (save_line_to_file): check fwrite failures, report
  and exit immediately instead of deferring to 'close_output'.
* tests/misc/csplit-io-err.sh: test fwrite failure using LD_PRELOAD.
* tests/local.mk: add new test.
2015-11-12 15:17:55 -05:00
Pádraig Brady
0daa359de8 stat: improve support for new Linux pseudo FS and ACFS
* src/stat.c (human_fstype): Add new file system ID definitions.
* NEWS: Mention the improvement.
2015-11-11 14:47:15 +00:00
Pádraig Brady
f720844207 tests: ensure programs are built before testing
programs may not be built due to missing system dependencies,
or any program can be excluded at configure time with
--enable-no-install-program.  So ensure we're not testing the
system versions in these cases.

* init.cfg (print_ver_): Call require_built_ first.
* tests/misc/tty-eof.pl: Skip programs not built.
* tests/Coreutils.pm (run_tests): Likewise.
* tests/misc/ls-misc.pl: Use 'env test' rather than abs path.
* tests/misc/test-diag.pl: Likewise.
* tests/local.mk: Adjust include order for dependencies.
* tests/misc/arch.sh: Remove redundant calls to require_built_.
* tests/misc/chroot-fail.sh: Likewise.
* tests/misc/groups-dash.sh: Likewise.
* tests/misc/groups-version.sh: Likewise.
* tests/misc/stdbuf.sh: Likewise.
* tests/cp/acl.sh: Remove problematic call to print_ver_ [gs]etfacl.
* tests/mv/acl.sh: Likewise.
* cfg.mk (sc_env_test_dependencies): A new syntax check to enforce
specifying dependencies with print_ver_ for programs
specified through the env command.
* du/bigtime.sh: Add new print_ver_ dependencies.
* du/max-depth.sh: Likewise.
* dd/ascii.sh: Likewise.
* tests/ls/capability.sh: Likewise.
* tests/ls/root-rel-symlink-color.sh: Likewise.
* tests/misc/chroot-fail.sh: Likewise.
* tests/misc/readlink-fp-loop.sh: Likewise.
* tests/misc/sort-debug-keys.sh: Likewise.
* tests/readlink/can-e.sh: Likewise.
* tests/readlink/can-f.sh: Likewise.
* tests/readlink/can-m.sh: Likewise.
* tests/tail-2/inotify-race.sh: Likewise.
* tests/tail-2/inotify-race2.sh: Likewise.
* tests/touch/no-create-missing.sh: Likewise.
* tests/touch/no-dereference.sh: Likewise.
* tests/misc/printenv.sh: Tweak to avoid syntax check trigger.
* tests/misc/help-version.sh: Likewise.
* tests/misc/yes.sh: Likewise.
* tests/misc/printf-quote.sh: Use previously unused $prog.
* configure.ac (EXTRA_MANS): Add $gl_no_install_prog to the list
so that check-x-vs-1 syntax check is satisfied.
2015-11-10 18:24:18 +00:00
Pádraig Brady
dcae88c009 maint: use standard spacing in shebang line in tests
It's better to be consistent even though spacing is insignificant:
http://www.in-ulm.de/~mascheck/various/shebang/#blankrequired
2015-11-10 13:03:33 +00:00
Pádraig Brady
41a4c714e4 tests: cleanup trapping of signal names
A side effect of this cleanup is we no longer
depend on our own kill command being built.

* init.cfg (require_trap_signame_): A new function to verify
that the shell supports specifying traps by signal name.
(require_kill_group_): A new function to ensure the shell
supports sending a signal to a group.
* tests/du/move-dir-while-traversing.sh: Ensure trap supports
signal names.
* tests/misc/stty-invalid.sh: Likewise.
* tests/misc/stty-pairs.sh: Likewise.
* tests/misc/stty-row-col.sh: Likewise.
* tests/misc/stty.sh: Likewise.
* tests/misc/sort-compress.sh: Likewise.  Also simplify trap call.
* tests/install/trap.sh: Likewise.
* tests/misc/timeout.sh: Likewise.
* tests/dd/stats.sh: Likewise.  Also use default kill command.
* tests/misc/timeout-group.sh: Likewise.
2015-11-10 12:52:50 +00:00
Pádraig Brady
eafaa2e88f tests: fix dirent d_type support verification
* init.cfg (require_dirent_d_type_): Don't use df -x
to exclude XFS, since this depends on a correct mtab
which is brittle and often not correct within chroots.
* tests/d_type-check: Check also the d_type of files,
which excludes XFS appropriately.  Specify all argument
and return types to avoid truncated pointers being passed,
which skipped the test due to crashes on x86_64 at least.
Simplify the C library lookup by reusing the interpreter's.

chroot issue reported at https://bugzilla.redhat.com/1263341
2015-11-06 16:40:42 +00:00
Pádraig Brady
d820706d44 maint: add a syntax check to avoid unstyled quoting
* src/paste.c (main): Use our styled wrapper for quotearg_colon().
* cfg.mk (sc_prohibit-quotearg): A new syntax check to avoid
future uses of unstyled quotearg to one of the internal slots,
and thus destined for diagnostic output.
2015-11-04 23:30:15 +00:00
Pádraig Brady
c3763e5219 paste: avoid confusing backslash quoting in diagnostic
* src/paste.c (main): Setting the quoting style to "escape"
went against the intent of the comment about presenting
doubled backslashes to the user.  Instead use "c-maybe"
which is the only mode which avoids doubled backslashes,
and provides protection against arbitrary control characters.
* tests/misc/paste.pl: Adjust accordingly.
2015-11-04 23:30:15 +00:00
Pádraig Brady
109b9220ce ls: default to --quoting=shell-escape for output to terminal
* src/ls.c (decode_switches): Set "shell-escape" if isatty().
* doc/coreutils.texi (ls invocation): Update the defaults description.
* NEWS: Mention the change in behavior.  It should not have
backwards compat issues, but mentioning here just in case.
2015-11-04 23:30:15 +00:00
Pádraig Brady
5ef0886411 printf: support the %q format to quote for shell
* src/printf.c (usage): Mention the new format.
(print_formatted): Handle the quoting by calling
out to the quotearg module with "shell-escape" mode.
* doc/coreutils.texi (printf invocation): Document %q.
* tests/misc/printf-quote.sh: New test.
* tests/local.mk: Reference new test.
* NEWS: Mention the new feature.
2015-11-04 23:30:15 +00:00
Pádraig Brady
697b8ce265 ls: avoid redundant processing when already escaping
This is mainly noticeable when the multi-byte code
within ls.c is triggered by multi-byte quotes.

$ seq 200000 | xargs touch
$ time ls-old -U --quoting=locale --hide-control-chars >/dev/null
real    0m0.483s
$ time ls-new -U --quoting=locale --hide-control-chars >/dev/null
real    0m0.430s

* src/ls.c (quote_name): Avoid rescanning the output looking for
unprintable chars when we know the quoting mode already escapes them.
* tests/misc/ls-misc.pl: Add tests for all quoting modes, with and
without -q, to verify this assumption.
2015-11-04 23:30:15 +00:00
Pádraig Brady
7549be4af7 ls: document and test new shell-escape quoting
* doc/coreutils.texi (ls invocation): Describe the new
'shell-escape' and 'shell-escape-always' quoting options.
* src/ls.c (usage): Mention the new quoting options.
* tests/misc/ls-misc.pl: Add a test for 'shell-escape'
2015-11-04 23:30:15 +00:00
Pádraig Brady
ed2326ac36 test: use consistent quoting
* src/test.c (test_syntax_error): Reuse verror() rather than
open coding the error output format.
(term): Don't hardcode '' quoting.
(main): Likewise.
2015-11-04 23:30:15 +00:00
Pádraig Brady
08e8fd7e38 all: avoid quoting file names when possible
Quote file names using the "shell-escape" or "shell-escape-always"
methods, which quote as appropriate for most shells,
and better support copy and paste of presented names.
The "always" variant is used when the file name is
embedded in an error message with surrounding spaces.

* cfg.mk (sc_error_shell_quotes): A new syntax check rule
to suggest quotef() where appropriate.
(sc_error_shell_always_quotes): Likewise for quoteaf().
* src/system.h (quotef): A new define to apply shell quoting
when needed.  I.E. when shell character or ':' is present.
(quoteaf): Likewise, but always quote.
* src/*.c: Use quotef() and quoteaf() rather than quote()
where appropriate.
* tests/: Adjust accordingly.
2015-11-04 23:30:14 +00:00
Pádraig Brady
1e8f9afac5 build: update gnulib submodule to latest
Includes support for "shell-escape" from quotearg
2015-11-04 23:30:12 +00:00
Pádraig Brady
646902b30d md5sum: ensure a single status line per file
* src/md5sum.c: Use the same file name escaping method used
when generating and checking checksums.  I.E. ensure a single line
per file by starting the line with '\' for any file name containing '\n'
and replacing those with "\\n".
* NEWS: Move the item from changes in behavior to improvements,
since this is no longer a backwards incompat change when
processing stdout status messages.
* tests/misc/md5sum.pl: Remove quotes from expected status output.
* tests/misc/sha1sum.pl: Likewise.
2015-11-04 02:03:43 +00:00
Pádraig Brady
ab40a941a0 all: replace most uses of quotearg_colon() with quote()
Related to commit v8.24-61-g6796698 this provides
more consistent quoting, as quotearg_colon() defaults
to "literal" quoting by default, while quote()
provides appropriate quoting for diagnostics by default.

* gl/modules/randread: Depend on quote module rather than quotearg.
* gl/lib/randread.c: Used quote() not quotearg_colon().
* src/: Likewise.
* src/shred.c: Likewise. Also avoid unnecessary quoting
introducing overhead when wiping names.
* cfg.mk: Relax the matching expression to allow
"qname" variables as used in shred.c to satisfy the check.
* tests/: Adjust accordingly.
2015-11-04 02:03:41 +00:00
Pádraig Brady
00eb7af8ea doc: fix texinfo for short options taking a parameter
* doc/coreutils.texi: (tail invocation): Add missing -s,
along with the existing --sleep-interval description.
(csplit invocation): s/--suffix/--suffix-format/.
(head invocation): Use same variable (COUNT) for -n and --head-count.
(seq invocation): Add opindex items for all options.
(ptx invocation): Likewise.
Fix typo s/--flac-truncation/--flag-truncation/.
(touch invocation): State explicitly that -d takes a parameter,
which also indicates that an '=' is not to be used
for the short option syntax.
(ls invocation): Likewise for the -w option.
Fixes http://bugs.gnu.org/21809
2015-11-02 10:12:12 +00:00
Pádraig Brady
3f5e0453e1 maint: allow 'all:' tag in commit summaries
To tag changes that are user visible
and affect all (or many) commands.
2015-10-29 00:18:13 +00:00
Pádraig Brady
b6db36b07f doc: clarify iso-8601 formats used by ls and du
* doc/coreutils.texi (du invocation): Remove 'like' from
mentions of ISO-8601 as the components are individually conformant.
(ls invocation): Likewise, except for --time-style=iso for recent
files, where the MM-DD component is not a valid ISO-8601 timestamp.
2015-10-28 13:58:14 +00:00
Pádraig Brady
17bbf6ce44 date: use extended format timezone for --iso-8601
* src/date.c (main): Use %:z rather than %z with --iso-8601
as the standard states to consistently use extended format.
Note either format can be parsed by date.
* tests/misc/date.pl: Adjust accordingly.
* doc/coreutils.texi (du invocation): Clarify that "iso"
time styles are only similar to ISO-8601.
(ls invocation): Likewise.
(date invocation): Adjust the comment stating
that only --rfc-3339 output can be parsed by date(1).
* NEWS: Mention the change in behavior.
Reported at http://bugs.debian.org/799479
2015-10-27 17:25:12 +00:00
Pádraig Brady
badff99041 doc: reference related commands from users(1) and groups(1)
* man/users.x: See also getent, who
* man/groups.x: See also getent
Addresses http://bugs.gnu.org/21735
2015-10-27 17:25:12 +00:00
Pádraig Brady
9459d9d811 copy,dd: simplify and optimize NUL bytes detection
* src/factor.c: Move LIKELY() definition to...
* src/system.h: ...here.
(is_nul): Reimplement with a version that doesn't
require a sentinel after the buffer, and which calls
down to (the system optimized) memcmp.
Performance analyzed at http://rusty.ozlabs.org/?p=560
* src/dd.c (alloc_obuf): Simplify the is_nul() call by
not needing to write the sentinel.
* src/copy.c (sparse_copy): Likewise.
(copy_reg): Simplify the buffer allocation by avoiding
consideration of the sentinel in the buffer size calculation.
2015-10-27 17:25:12 +00:00
Pádraig Brady
6796698c99 all: quote string arguments in error messages
These strings are often file names or other user specified
parameters, which can give confusing errors in
the presence of unexpected characters for example.

* cfg.mk (sc_error_quotes): A new syntax check rule.
* src/*.c: Wrap error() string arguments with quote().
* tests/: Adjust accordingly.
* NEWS: Mention the improvement.
2015-10-27 17:24:54 +00:00
Pádraig Brady
106d4bf159 md5sum: quote all printed file names
This is especially significant when using --check
with files generated on a windows system, where the \r
characters produce corrupted and confusing error messages.
This also ensures status messages are output on a single line.

* src/md5sum.c: Use quote() for printed file names.
* tests/misc/md5sum.pl: Adjust accordingly.
* NEWS: Mention the change in behavior.
Fixes http://bugs.gnu.org/21757
2015-10-27 13:20:50 +00:00
Pádraig Brady
e71be1292b ls: fix off by one error when determining max display columns
* src/ls.c (main): Account for the first column not including
a separator when calculating max_idx.
* tests/ls/w-option.sh: Add a test case.
* NEWS: Mention the bug fix.
2015-10-21 16:13:57 +01:00
Pádraig Brady
0e997681d4 ls: allow -w0 to mean no limit on line length
* src/ls.c (print_with_separator): Renamed from print_with_commas,
and parameterized to accept the separator to print.
Also fix an edge case where '\n' not printed when
the POS variable overflows SIZE_MAX.
(print_current_files): Degenerate -x and -C to using the
cheaper print_with_separator() in the -w0 case.
* doc/coreutils.texi (ls invocation): Document the new feature.
* tests/ls/w-option.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the improvement.
Fixes http://bugs.gnu.org/21325
2015-10-21 01:40:02 +01:00
Pádraig Brady
069961924e ls: detect terminal color support using glob patterns
* src/ls.c (know_term_type): Corresponding to commit v8.24-48-gc249a5a,
use fnmatch to inspect the dircolors database.  Noticed due to
failing tests/ls/color-{dtype-dir,term}.sh tests.
2015-10-19 12:59:09 +01:00
Pádraig Brady
31b3db53da tests: adjust recent change to csplit VM limit
* tests/misc/csplit-heap.sh: A little more memory is required
for the full run case.  Noticed with --enable-single-binary.
2015-10-19 11:25:42 +01:00
Pádraig Brady
b6757e83c4 maint: fixes to support improved sc_tight_scope
The gnulib provided sc_tight_scope target was ineffective,
as it was checking against an invalid blank regular expression,
and thus ignoring any extern function issues.  This is now
fixed up in gnulib, and so we need to fix our scoping issues
before the next gnulib update.

* cfg.mk: Setup and document the tight_scope config variables
appropriately.
* src/selinux.h: Since declared in *_SOURCES, use the two line
form for the extern function declarations.
* src/set-fields.h: Add the extern declarations, and since declared
in noinst_HEADERS use the single line form.
2015-10-19 10:25:14 +01:00
Pádraig Brady
66504d41aa tests: avoid failure when auto selecting factor tests
* tests/factor/run.sh: If this template is found through
`grep -El "print_ver_.* factor"` for example, then just skip it.
2015-10-19 10:24:12 +01:00
Pádraig Brady
07b73c689d factor: remove unreachable SQUFOF code at compile time
It was a little confusing as to whether the SQUFOF algorithm was
enabled, and in fact there were no options available to enable it.
Therefore clarify the 3 configurable behaviors for the code to
3 defines at the top of the program, and only include the SQUFOF
code if enabled at compile time.

$ size src/factor-before
   text    data     bss
  93997    1412    2504
$ size src/factor-after
   text    data     bss
  87885    1404    2504

* src/factor.c: Only include the SQUFOF factor code
when enabled via the USE_SQUFOF define.
* doc/coreutils.texi (factor invocation): Update note about
factor limits, as we can factor 128 bit numbers without GMP.
2015-10-19 10:24:12 +01:00
Pádraig Brady
e50f5273aa doc: reference shuf(1) from the sort (-R) man page
* man/sort.x: Cross reference with shuf(1).
* src/sort.c (usage): Mention shuf(1) with -R option.
Suggested in http://bugs.debian.org/641166
2015-10-19 00:05:18 +01:00
Bernhard Voelker
8802eb16e6 maint: avoid duplicate test runs
* tests/local.mk (all_tests): Remove the tests 'tests/id/setgid.sh' and
'tests/mkdir/smack-root.sh' because they are mentioned in the
'all_root_tests' list; these tests are skipped anyway during a non-root
run because flagged with 'require_root_'.
2015-10-18 18:48:23 +02:00
Paul Eggert
0cb602e33a doc: remove obsolete performance comment
sha512sum can be faster than sha256sum.
E.g., ‘dd if=/dev/zero bs=1024k count=1024 | time sha256sum’
reports 8.16 user CPU seconds on my host, whereas sha512sum
consumes 5.45 seconds (Fedora x86-64 on an AMD Phenom II X4 910e).
Although sha512sum is still considerably slower on x86, a good
chunk of uses are on 64-bit hosts and anyway there’s little point
to scaring people away from sha512sum nowadays.
* doc/coreutils.texi (sha2 utilities): Remove obsolete comment.
2015-10-16 12:07:07 -07:00
Jim Meyering
e8d7e20530 maint: avoid uniq.c warning from bleeding-edge gcc's -Wstrict-overflow
* src/uniq.c (main): Make the type of "nfiles" unsigned,
to avoid a brand new warning from a gcc I built from today's
sources (gcc version 6.0.0 20151015 (experimental) (GCC)):
src/uniq.c:523:14: error: assuming signed overflow does not occur \
  when simplifying conditional to constant [-Werror=strict-overflow]
           if (nfiles == 2)
              ^
2015-10-16 08:02:51 -07:00
Pádraig Brady
c249a5afc4 dircolors: support globbing of TERM entries
* src/dircolors.c (dc_parse_stream): Support globbing of
TERM entries, to allow entries like "TERM *256color*" for example.
* src/dircolors.hin: Reduce the internal list with globbing.
* tests/misc/dircolors.pl: New test cases.
* NEWS: Mention the improvement.
2015-10-16 12:23:30 +01:00
Pádraig Brady
3a68c3e990 tests: avoid false failure in rm/r-root.sh with gdb warnings
* tests/rm/r-root.sh: Skip the test if there are gdb warnings
that will impact further stderr checks.  For example some
buggy gdb versions may report "Got object file from memory
but can't read symbols: File truncated".  Also fix an incorrect
stderr check from the previous change.
Reported by Bernhard Voelker.
2015-10-15 11:55:18 +01:00
Pádraig Brady
2366daf725 tests: avoid false failure in rm/r-root.sh under load
* tests/rm/r-root.sh: Use gdb rather than timeout(1) as the
last resort protection against unlinkat() calls.  The timeout
of 2s was susceptible to false positives under load, and
gdb is stronger protection in any case.  We remove the
"expensive" tag on this test also since it should be robust.
Reported by Jim Meyering.
2015-10-15 08:44:22 +01:00
Pádraig Brady
0458701041 tests: avoid false failure in a tail test under load
* tests/tail-2/follow-stdin.sh: Use the standard tail
testing framework to avoid the race seen under very high load,
and also test the non inotify case.
Reported by Jim Meyering
2015-10-15 08:44:09 +01:00
Pádraig Brady
f9fb9acb0d tests: avoid false failures with default ACLs
To reproduce:
  setfacl -dm group::rx .
  setfacl -dm other::rx .
  make check

* init.cfg (require_no_default_acl_): A new function to skip
when default ACLs are detected, or if the getfacl utility is
not available then skip if any non LSM ACLs detected.
* tests/cp/existing-perm-race.sh: Call require_no_default_acl_.
* tests/mkdir/parents.sh: Likewise.
* tests/mkdir/perm.sh: Likewise.
2015-10-14 15:23:14 +01:00
Pádraig Brady
e6b3af647d tail: no longer warn about unrecognized file systems
* src/tail.c (fremote): No longer prompt the user to email
with the unrecognized file system constant, since we have
process in place to sync periodically with the latest Linux
constants, and the fall back polling mode is still fully functional.
2015-10-12 01:40:27 +01:00
Pádraig Brady
88eb88ee23 tests: avoid false failure when restorecon is ineffective
* tests/cp/cp-a-selinux.sh: Ensure we skip the portion of the test
depending on restorecon to be effective.  I.E. also skip when restorecon
warns, as it doesn't exit with error status when matchpathcon fails to
find a match for a file.  This is the case in /tmp on Fedora for
example, in which case the new destination that cp creates will have the
default security context of the process, rather than the explicit
context we set on the source file.
Details at: http://bugzilla.redhat.com/1247641
2015-10-10 17:05:37 +01:00
Pádraig Brady
934940b561 tests: make a long running test responsive to Ctrl-C
* tests/misc/sort-compress-hang.sh: Use --foreground with the
timeout(1) command (noting the caveats), to run the sort command
in the foreground program group, and thus be responsive to Ctrl-C.
This very_expensive_ test takes over a minute on a i3-2310M,
with RAM backed /tmp.
2015-10-10 11:21:34 +01:00
Pádraig Brady
c1dba59a79 tests: adjust recent changes to virtual memory limits
* tests/dd/no-allocate.sh: Account for timeout(1) when
determining the required mem, as timeout has additional shared libs.
This avoids the need for the hardcoded 4M addition to the limit.
* tests/misc/head-c.sh: Increase the base limit, to account for
the fact that head(1) will allocate some additional mem in this case.
* tests/misc/cut-huge-range.sh: Remove mention of specific limits.
* tests/misc/printf-surprise.sh: Likewise.
Reported by Dmitry V. Levin
2015-10-08 03:54:02 +01:00
Pádraig Brady
ce501787d4 csplit: remove erroneous mention of -m in --help
* src/csplit.c (usage): -m is not accepted, only --suppress-matched.
* tests/misc/csplit-suppress-matched.pl: Spelling fix.

Reported by Ondrej Oprala
2015-10-06 11:24:27 +01:00
Paul Eggert
88a7228bb2 tee: simplify argv handling
* src/tee.c (tee_files): Last arg is now char ** instead of char
const **, as that is a bit simpler.  All callers changed.  Modify
files[-1], not files[nfiles], as that is a bit faster and simpler.
Latter problem pointed out by Rainer Deyke in:
http://bugs.gnu.org/21611
2015-10-03 17:02:43 -07:00
Paul Eggert
ac81caaf77 build: update gnulib submodule to latest 2015-10-03 00:32:34 -07:00
Paul Eggert
f689642bac build: Pacify GCC 5 on 32-bit hosts
This pacifies GCC 5 in a better way, without disabling diagnostics.
* src/df.c (main): Tell compiler that optind is positive.
* src/shred.c (known): New function.
(dopass): Go back to off_t for file sizes.
Avoid integer overflow if we run off the end of the file.
Tell compiler that a write cannot write more bytes than requested.
2015-10-03 00:32:34 -07:00
Pádraig Brady
3ba68f9e64 tail: handle kernel dentry unlink race
Avoid the intermittent loss of "... has become inaccessible" messages.
That would cause tests/tail-2/assert.sh to fail sometimes,
mainly on uniprocessor systems.

* src/tail.c (tail_forever_inotify): Also monitor IN_DELETE
events on the directory, to avoid a dentry unlink()..open() race,
where the open() on the deleted file was seen to succeed after an,
unlink() and a subsequent IN_ATTRIB, was sent to tail.  Note an
IN_ATTRIB is sent on the monitored file to indicate the change in
number of links, and we can't just use a decrease in the number of
links to determine the file being unlinked, due to the possibility
of the file having multiple links.

Reported by Assaf Gordon and Ludovic Courtès.
Fixes http://bugs.gnu.org/21460
2015-10-03 03:03:24 +01:00
Pádraig Brady
00ac178893 build: avoid -Wstrict-overflow warnings with GCC 5.1 on 32 bit
* src/shred.c (dopass): With -O2, GCC 5.1 gives "assuming signed
overflow does not occur when simplifying conditional to constant"
warnings, in regard to the signed (off_t) variables.  Therefore
use unsigned (uintmax_t) instead, and a separate boolean to cater
for the special meaning of the negative part of the integer range.
Noticed at http://hydra.nixos.org/build/24983447
2015-10-03 02:54:51 +01:00
Pádraig Brady
8fe6f70f35 build: update gnulib submodule to latest
Includes a change to xalloc.h to avoid -Wstrict-overflow warnings
with GCC 5.1 on 32 bit with optimization enabled.  A subsequent
commit will fix similar issues in shred.
2015-10-03 02:54:44 +01:00
Dario Giovannetti
a960c31c7d dircolors: add xterm-termite entry
* src/dircolors.hin: Add "xterm-termite" as this VTE based terminal
emulator is quite different from xterm, despite the name.
For example "Termite supports italic text and it won't work if TERM
is set to xterm. Even the backspace key won't work properly anymore
for applications relying on terminfo".
Reported also by Lukas Sabota and Sven-Hendrik Haase.
2015-10-02 16:59:50 +01:00
Dave Chiluk
3babaf8387 df: prioritize mounts nearer the device root
In the presence of bind mounts of a device, the 4th "mount root" field
from /proc/self/mountinfo is now considered, so as to prefer mount
points closer to the root of the device.  Note on older systems with
an /etc/mtab file, the source device was listed as the originating
directory, and so this was not an issue.
Details at http://pad.lv/1432871

* src/df.c (filter_mount_list): When deduplicating mount entries,
only prefer sources nearer or at the root of the device, when the
target is nearer the root of the device.
* NEWS: Mention the change in behavior.
2015-09-23 01:02:44 +01:00
Pádraig Brady
982c79fa14 build: update gnulib submodule to latest
This includes a change to propagate the 4th "mount root"
field from /proc/self/mountinfo from the mountlist module,
which is needed in a subsequent commit in df.

* gl/lib/regcomp.c.diff: Regenerate against latest gnulib.
* gl/lib/regex_internal.c.diff: Likewise.
* gl/lib/regex_internal.h.diff: Likewise.
* cfg.mk: Exclude diffs from trailing whitespace check,
which is generally correct, and now needed.
2015-09-23 01:02:44 +01:00
Bernhard Voelker
9db234ad09 maint: use adaptive approach for ulimit -v based tests
When configured with either 'symlinks' or 'shebangs' as value for
the --enable-single-binary option, tests based on `ulimit -v` are
skipped.  The reason is that the multicall 'coreutils' binary requires
much more memory due to shared libraries being loaded, and the size of
the 'date' binary (~290KiB) compared to the multicall binary (~5MiB),
of course.  Finally, in the case of 'shebangs', the starting shell
requires more memory, too

Instead of using hard-coded values for the memory limit, use an
adaptive approach: first determine the amount of memory for a similar,
yet more trivial invocation of the command, and then do the real test
run using that limit (plus some buffer in some cases).

* init.cfg (require_ulimit_v_): Remove function.
(get_min_ulimit_v_): Add function to determine the minimum memory limit
required for a given command in an adaptive way.
* cfg.mk (sc_prohibit_test_ulimit_without_require_): Change the name
of the above function in the syntax-check rule.
* tests/cp/link-heap.sh: Use the above function to determine the
minimum memory required to run a command simpler than in the real test
run.  Use that limit plus a buffer there.  While at it, change to list
of commands in the subshell to fail also if the beginning `ulimit -v`
fails.
* tests/dd/no-allocate.sh: Likewise.
* tests/misc/csplit-heap.sh: Likewise.
* tests/misc/cut-huge-range.sh: Likewise.
* tests/misc/head-c.sh: Likewise.
* tests/misc/printf-surprise.sh: Likewise.
* tests/split/line-bytes.sh: Likewise.
* tests/rm/many-dir-entries-vs-OOM.sh: Likewise - doing it separately
for each program under test.
2015-09-22 23:23:26 +02:00
Pádraig Brady
50e61bfdb9 maint: avoid deprecation warning with <selinux/flask.h>
* src/runcon.c (main): As per the compile time warning from
libselinux-2.4-3, lookup the class with string_to_security_class(),
rather than using defines from flask.h.
2015-09-22 19:09:32 +01:00
Pádraig Brady
dee6b76010 sort,numfmt: with --debug, diagnose failure to set locale
* src/sort.c (main): With --debug, warn upon setlocale() failure,
which can happen due to incorrectly specified environment variables,
or due to memory exhaustion (simulated with ulimit -v), etc.
* tests/misc/sort-debug-warn.sh: Add a test case.
See also http://savannah.gnu.org/bugs/11004
2015-09-22 02:30:30 +01:00
Bernhard Voelker
d4a22dff9b du: avoid to stat all mount points if possible
du calls stat for each mount point at startup.  This would block or
even make du fail if stat for an unrelated mount point hangs.
The result is not needed in the normal case anyway and therefore
should be avoided.  Issue introduced in commit v8.19-2-gcf7e1b5.

* src/du.c (fill_mount_table): Move function up as it's not used ...
(mount_point_in_fts_cycle): ... here, i.e., the DI_MNT set is
initialized and filled only iff FTS has detected a directory cycle.
(main): Remove the initialization and filling of the DI_MNT set here,
and free the DI_MNT set only if it was used.
2015-09-18 13:29:17 +02:00
Paul Eggert
e4d8c99436 shred: don’t document -NUMBER option
The -NUMBER option was removed from ‘shred’ in 1999, but the
manual wasn’t updated to match.  Problem reported by Nick Rose in:
http://bugs.gnu.org/21502
* doc/coreutils.texi (shred invocation):
Remove documentation for -NUMBER option.
2015-09-17 00:38:13 -07:00
Assaf Gordon
ba24c42e13 numfmt: use new set-fields module to parse --field
numfmt --field=LIST can accept the same options as cut.

* bootstrap.conf: remove xlist, linked-list
* src/local.mk: link numfmt with set-fields
* src/numfmt.c: use set-fields.c instead of custom field parsing code.
  (include_field): adapt to new code.
* tests/misc/numfmt.pl: add new tests, adapt current tests to new
  error message wording from set-fields.c
2015-09-12 02:27:32 +00:00
Assaf Gordon
bd1bc2b3fe cut: refactor into set-fields module
Extract the functionality of parsing --field=LIST into a separate
module, to be used by other programs.

* src/cut.c: move field parsing code from here ...
* src/set-fields.{c,h}: ... to here.
  (set_fields): generalize by supporting multiple parsing/reporting
  options.
  (struct range_pair): rename to field_range_pair.
* src/local.mk: link cut with set-field.
* po/POTFILES.in: add set-field.c
* tests/misc/cut.pl: update wording of error messages
2015-09-12 02:27:32 +00:00
Pádraig Brady
5bbdcd2a02 maint: fix heap manipulations in previous commit
* src/sort.c (main): Ensure we don't free() and invalid
pointer when reading implicit stdin.  Also avoid
"definitely lost" valgrind warnings in the --files0-from case.
2015-09-08 12:56:04 +01:00
Pádraig Brady
a4b640549d maint: avoid "definitely lost" valgrind warnings
Since commit v8.23-19-g8defcee, main() will return,
rather than call exit(), this inducing "definitely lost"
warnings in valgrind's leak checker.  That precludes using
the following to flag memory leaks:

  valgrind --leak-check=full --error-exitcode=1 \
           --errors-for-leak-kinds=definite

* src/pr.c (main): In dev builds, explicitly free memory allocated.
* src/sort.c (main): Likewise.
* src/tail.c (main): Likewise.
* src/tsort.c (tsort): Likewise.
2015-09-04 17:04:03 +01:00
Pádraig Brady
26c11773a4 tests: test numfmt stdin behavior
* tests/misc/tty-eof.pl: Add numfmt to the list of programs
that accept input on stdin.
2015-09-03 01:11:39 +01:00
Pádraig Brady
895a56c531 ls,ptx: restrict quotearg use to file name output
* src/ls.c (getenv_quoting_style, decode_switches, parse_ls_color):
Use quote() rather than quotearg(), as the latter defaults to
outputting the input unquoted.
* src/ptx.c (main): Likewise.
2015-09-03 01:11:32 +01:00
Pádraig Brady
df3b9120b4 base64: no longer support hex or oct --wrap params
* src/base64.c (main): Support decimal numbers with leading zeros,
by disabling the auto detection of octal and hex.  It's not
envisaged that base conversion is needed for --wrap parameters,
and in the edge case it is, $((0x0)) shell constructs can be used.
* tests/misc/base64.pl: Adjust accordingly.
* NEWS: Mention the change in behavior.
2015-09-03 00:34:12 +01:00
Pádraig Brady
a8cc9ce3f2 base64: use stricter validation on wrap column
* src/base64.c (main): Use the higher level xnumtoumax()
rather than xstrtoumax(), which is simpler and improves
validation of input.  Also pass the _empty_ rather than NULL
string as the suffixes parameter so that invalid trailing
characters are not allowed.  For example -w08 is now
flagged as an error, rather than being interpreted as 0.
A subsequent commit will further improve verification
of numbers with leading zeros by dropping backwards compatibility
wrt auto parsing oct and hex numbers.
* tests/misc/base64.pl: Add tests for invalid wrap values.
2015-09-03 00:34:12 +01:00
Pádraig Brady
89c517d9e2 base32: A new program similar to base64
Suggested in https://bugzilla.redhat.com/1250113

* AUTHORS: Add base32.
* THANKS.in: Add suggester.
* README: Reference the new program.
* NEWS: Mention the new program.
* src/.gitignore: Ignore the new binary.
* bootstrap.conf: Reference the gnulib base32 module.
* build-aux/gen-lists-of-programs.sh: Add base32.
* man/base32.x: A new template.
* man/.gitignore: Ignore the new man page.
* man/local.mk: Reference the new man page.
* doc/coreutils.texi (base32 invocation): Document the new command.
* src/local.mk: Adjust to build base32 based on base64.c.
* src/base64.c: Parameterize to use the correct headers,
functions and buffer sizes, depending on which binary
is being built.
* tests/misc/base64.pl: Adjust to test both base32 and base64.
* tests/misc/tty-eof.pl: Add base32 as a program that
accepts input on stdin without any options specified.
* scripts/git-hooks/commit-msg: Add base32 to the template.
2015-09-03 00:33:19 +01:00
Pádraig Brady
affc8e8087 build: update gnulib submodule to latest
This includes a tweak to support building
the gnulib base32 module with -Wsuggest-attribute=const
2015-09-01 17:42:33 +01:00
Pádraig Brady
a83f703a9b doc: clarify in --help/man where short options take no param
* src/shred.c (usage): For -u, separate the decscription
of the short and long option, to clarify that the short option
takes no parameter.
* src/split.c (usage): Likewise for -d.
* src/tee.c (usage): Likewise for -p.
* src/uniq.c (usage): Likewise for -D.

Suggested by Stephane Chazelas
2015-08-31 18:10:41 +01:00
Bernhard Voelker
fd5f2b1569 tests: avoid FP of ls/stat-free-color.sh with newer glibc
Since glibc-2.22, specifically commit [0], the opendir() implementation
implicitly makes an additional stat call thus leading to a FP.
Seen on openSUSE:Tumbleweed since snapshot 20150821.

[0]
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=46f894d8c60a

* tests/ls/stat-free-color.sh: Change the test to verify that ls(1)
needs the same number of stat-like calls for a single, empty directory
argument as for one with a few directory entries (sub-directory,
regular file, symlink, etc.).
2015-08-30 22:49:35 +02:00
Pádraig Brady
da5505dd7f doc: clarify where ambiguous if short options take no param
* doc/coreutils.texi (split invocation): Clarify that -d takes no param.
(uniq invocation): Likewise for -D.
(shred invocation): Likewise for -u.
(tee invocation): Likewise for -p.
2015-08-27 16:12:58 +01:00
Paul Eggert
97678abb6b ls: allow -w18446744073709551616
Problem reported by Beco in: http://bugs.gnu.org/21325
* src/ls.c (set_line_length): New function.
(decode_switches): Use it to decode COLUMNS and -w.
2015-08-22 18:31:13 -07:00
Bernhard Voelker
4ec9ccad79 maint: add syntax check to ensure larger man/*.x files have a Copyright
* cfg.mk (sc_man_check_x_copyright): Add rule to ensure that non-trivial
.x files in the 'man/' subdirectory, i.e., files exceeding a line count
of 20 or a byte count of 1000, contain a proper Copyright notice.
2015-08-18 20:27:48 +02:00
Paul Eggert
037e3b9847 build: fprintftime/nstrftime API changes
* bootstrap.conf (gnulib_modules): Add time_rz,
since the main source code now uses timezone_t.
* src/date.c (batch_convert, main, show_date):
* src/ls.c (align_nstrftime, long_time_expected_width)
(print_long_format):
* src/stat.c (human_time):
Use timezone_t rather than boolean to specify which time zone
is wanted.
* src/ls.c (localtz): New static var.
(main): Initialize it.
2015-07-23 18:52:15 -07:00
Paul Eggert
7131a33952 build: update gnulib submodule to latest 2015-07-23 18:52:15 -07:00
Pádraig Brady
6d67649d86 doc: discourage use of uname -i and -p options
* src/uname.c (usage): State that the non POSIX -i and -p options
are non-portable.
* doc/coreutils.texi (uname invocation): Mention the discrepancies
even across GNU/Linux distros, and that the results should
be used as informational only, rather than impacting any
logic decisions.
Fixes http://bugs.gnu.org/13001
2015-07-22 01:55:14 +01:00
Pádraig Brady
0b0d38b762 doc: improve man page for realpath -m
* src/realpath.c (usage): Mention 'directory' in the --help
output, so that ENOTDIR errors may be more easily investigated,
by inspecting the man page.
Reported at http://pad.lv/1474519
2015-07-15 14:37:05 +01:00
Peter Bray
a652e7b63e tests: avoid test warning with perl >= 5.22
* doc/local.mk (sc-lower-case-var): Escape a literal
left curly bracket, needed with perl >= 5.22
Fixes http://bugs.gnu.org/21060
2015-07-15 11:39:49 +01:00
Peter Bray
9d2597161d sync: fix build with separate $(LIB_FDATASYNC)
* src/local.mk: Link with $(LIB_FDATASYNC) needed
on some Solaris 10 systems for example.
Fixes http://bugs.gnu.org/21059
2015-07-15 08:40:51 +01:00
Pádraig Brady
1a78f6a064 dircolors: add tmux entries
* src/dircolors.hin: tmux entries were added to ncurses in:
http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff;\
f=misc/terminfo.src;h=ce9bdc3b;hp=7e576ef1;hb=be512fa0;hpb=ee1bcda2
2015-07-09 17:52:51 +01:00
Pádraig Brady
5e5d454037 shred: fix pattern selection for certain iteration counts
This was detected in about 25% of runs with gcc -fsanitize=address

  ERROR: AddressSanitizer: global-buffer-overflow on address ...
  READ of size 4 at 0x000000416628 thread T0
    #0 0x40479f in genpattern src/shred.c:782
    #1 0x4050d9 in do_wipefd src/shred.c:921
    #2 0x406203 in wipefile src/shred.c:1175
    #3 0x406b84 in main src/shred.c:1316
    #4 0x7f3454a1ef9f in __libc_start_main (/lib64/libc.so.6+0x1ff9f)
    #5 0x4025d8 (/tmp/coreutils-8.23/src/shred+0x4025d8)
  0x000000416628 is located 56 bytes to the left of
  global variable '*.LC49' from 'src/shred.c' (0x416660) of size 17
  0x000000416628 is located 12 bytes to the right of
  global variable 'patterns' from 'src/shred.c' (0x416540) of size 220
  SUMMARY: AddressSanitizer: global-buffer-overflow src/shred.c:782

* src/shred.c (gen_patterns): Restrict pattern selection
to the K available, which regressed due to v5.92-1462-g65533e1.
* tests/misc/shred-passes.sh: Add a deterministic test case.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/20998
2015-07-07 03:26:58 +01:00
Pádraig Brady
c5ff0d989f maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2015-07-03 22:23:56 +01:00
Pádraig Brady
f2ef324811 version 8.24
* NEWS: Record release date.
2015-07-03 21:58:50 +01:00
Pádraig Brady
9a81dd803c maint: fix distclean-check failure due to THANKS
* Makefile.am: Remove our dependence on src/sort which
induces awkward dependencies for `make dist` since
THANKS will be rebuilt once src/sort is newer.
Instead we remove the problematic -f option to sort
which actually doesn't change the order given
our current input.
2015-07-03 21:08:26 +01:00
Pádraig Brady
db3f9596ff maint: avoid false syntax-check failure in distcheck
* cfk.mk (sc_tests_executable): Restrict the check to git files,
so we don't flag any gnulib files added to test/ during
`make distcheck`.
2015-07-03 17:36:26 +01:00
Pádraig Brady
11091122c5 tests: update gnulib submodule and tests/init.sh to latest
* gnulib: Update to latest, with fixes to tests edge cases.
* tests/init.sh: Update from gnulib.
2015-07-03 15:50:56 +01:00
Pádraig Brady
1d4289b3c1 tests: avoid side effects of $SHELL environment variable
Since non interactive shells don't generally set $SHELL,
its value is propagated through the tests and may cause issues;
for example if $SHELL implicitly adjusts $PATH when run.
Instead we set $SHELL to that determined by the posix-shell module,
and use that consistently for all test sub scripts,
including those created thorugh the `split --filter` command.

* tests/local.mk: Explicitly set $SHELL to $(PREFERABLY_POSIX_SHELL)
which defaults to $CONFIG_SHELL and thus usually /bin/sh.
* tests/envvar-check: Remove bash environment variables with
side effects, in case /bin/bash was selected for $SHELL.
* tests/misc/help-version.sh: Remove redundant initialization of $SHELL.
* tests/install/strip-program.sh: Use $SHELL for sub script.
* tests/misc/sort-compress-hang.sh: Likewise.
* tests/misc/sort-compress-proc.sh: Likewise.
* tests/misc/sort-compress.sh: Likewise.
* tests/misc/timeout-group.sh: Likewise.
* tests/rm/fail-eperm.xpl: Remove redundant elision of bash env vars.
* tests/misc/pwd-long.sh: Likewise.
2015-07-03 13:02:21 +01:00
Pádraig Brady
970b891702 tests: avoid false failures on OpenBSD 5.7
* tests/du/threshold.sh: Homogenize getopt error messages.
* tests/misc/numfmt.pl: Likewise.
* tests/mv/i-3.sh: Skip on *BSD not just FreeBSD.
2015-07-02 19:15:08 +01:00
Pádraig Brady
a645ce6c04 wc: fix reading of /proc files on aarch64
tests/misc/wc-proc.sh fails when the page size is 64K

* src/wc.c (wc): The lseek adjustment should be based on st_blksize,
rather than on the internal buffer size.  This is significant on
aarch64 where st_blksize in /proc is the 64K (the page size) and
thus larger than the internal buffer.
* src/split.c (main): Even though the similar processing is done
on the internal buffer size, that's based on st_blksize and
so fine in this regard.  Add an assert to enforce this.
Avoid this path for the undocumented ---io-blksize option.
2015-07-02 03:53:59 +01:00
Pádraig Brady
8bf2af685c build: update gnulib submodule to latest
Mainly with build fixes for FreeBSD and OS X.
2015-07-01 16:09:39 +01:00
Pádraig Brady
81c7fc4081 numfmt: increase precision on 32 bit FreeBSD
* m4/jm-macros.m4 (HAVE_FPSETPREC): Define if needed.
* src/numfmt.c (main): Call fpsetprec() if needed.
Fixes large-15 and large-16 test failures on 32 bit FreeBSD.
2015-07-01 12:29:59 +01:00
Pádraig Brady
491f54fb5a tests: avoid false failure on FreeBSD systems
* tests/misc/stty.sh: FreeBSD returns ENOTTY for
the TIOCEXT ioctl, so just avoid this option for now.
2015-07-01 12:27:29 +01:00
Pádraig Brady
f2db30e676 factor: ensure atomic output through pipes
The new tests/misc/factor-parallel.sh test was
seen to fail on FreeBSD (derived) systems, which was
due to split(1) --filter reading partial lines
through pipes, as factor(1) was writing a little
over PIPE_BUF each time.

* src/factor.c (lbuf): A new structure to internally buffer lines.
(lbuf_alloc): A new function to allocate enough at program start.
(lbuf_putint): A new function to buffer a uintmax_t.
(lbuf_flush): A new function to write directly to standard output.
(lbuf_putc): A new function to buffer a character and if enough
lines are buffered, then output complete lines <= PIPE_BUF,
and continue to buffer the rest.
(main): Call the internal buffer allocator, and register
the final flush from the internal buffer at program exit.
2015-07-01 12:27:29 +01:00
Pádraig Brady
e1358a7dd9 tests: fix false failure on slower systems
* tests/dd/stats.sh: Wait 20s for dd to write 250MB through a fifo,
rather than 10s for 500MB.  The failure was seen often on
a lightly loaded SPARC-Enterprise-T5220 running Solaris 10.
2015-07-01 12:27:29 +01:00
Jim Meyering
f303fb6bbb maint: stdbuf.c: avoid the OS X putenv function
* bootstrap.conf (gnulib_modules): Add setenv, to make this
module dependency explicit; setenv is also used by split.
* src/stdbuf.c (set_LD_PRELOAD) [__APPLE__]: Use the OS X setenv
function, rather than putenv, per that documentation:
https://developer.apple.com/\
library/mac/documentation/Darwin/Reference/ManPages/man3/putenv.3.html
2015-06-29 14:18:59 -07:00
Jim Meyering
46416bb7c3 build: numfmt.c: avoid a shadowing warning
* src/numfmt.c (parse_field_arg): Rename parameter s/optarg/arg/,
to avoid shadowing getopt's global variable.
Otherwise, building on OS X, with --enable-gcc-warnings, I saw this:

  In file included from src/numfmt.c:19:0:
  src/numfmt.c: In function 'parse_field_arg':
  ./lib/config.h:3109:25: error: declaration of 'rpl_optarg' shadows\
    a global declaration [-Werror=shadow]
2015-06-29 11:11:49 -07:00
Assaf Gordon
badecb3f6c numfmt: fix printf argument order
* src/numfmt.c (double_to_human): Fix the argument order
passed to snprintf, which happened to work on amd64 with
its separate va_arg storage area for floats¹,
but would fail tests for example on i686.

¹ https://blog.nelhage.com/2010/10/amd64-and-va_arg/
2015-06-29 12:59:19 +01:00
Pádraig Brady
eff511bd3c maint: clarify df's use of device IDs from /proc/self/mountinfo
* src/df.c (filter_mount_list): Clarify why we still stat even
though devices IDs may already be available.  Note using
/proc/self/mountinfo is still an advantage to get filtered items
with accurate device patchs in chroots and with bind mounts.
I.E. on older setups with static /etc/mtab, df will now
bypass that to get the more accuracte and dynamic info.
2015-06-28 03:56:41 +01:00
Pádraig Brady
e0c5ca485c chroot: quote argument in error diagnostic
* src/chroot.c (main): Quote the passed argument,
to avoid confusing error messages.
2015-06-26 19:35:46 +01:00
Pádraig Brady
f3a0e9ebb2 maint: clarify integer operations in recent commit
* src/factor.c (print_uintmaxes): Comment that the
value of n_out doesn't matter on error, and add an
explicit cast to avoid any future warnings.
Suggested by Jim Meyering RE commit v8.23-229-g4d2d6c5
2015-06-25 18:59:39 +01:00
Pádraig Brady
cacd9bf9c2 tests: avoid false failure when running as root
* tests/misc/sync.sh: Ensure dir is unreadable before
including the permission check.
2015-06-25 14:10:47 +01:00
Pádraig Brady
1d82751e2c tests: avoid false failures with LD_PRELOAD=libasan.so.2
The LD_PRELOAD checks by -fsanitize=address are overly strict:
https://groups.google.com/forum/#!topic/address-sanitizer/jEvOJgkDqQk
A workaround is to first export LD_PRELOAD=libasan.so.2
The tests below are adjusted so that workaround is not discarded.

* tests/cp/no-ctx.sh: Append to $LD_PRELOAD.
* tests/df/no-mtab-status.sh: Likewise.
* tests/df/skip-duplicates.sh: Likewise.
* tests/ls/getxattr-speedup.sh: Likewise.
* tests/rm/r-root.sh: Likewise.
* tests/cp/nfs-removal-race.sh: Likewise.  Also check that
LD_PRELOAD is effective to aid future maintainability
and avoid false failure if libasan.so.2 is not preloaded.
2015-06-25 13:41:24 +01:00
Pádraig Brady
381b797784 build: update to latest gnulib
Mainly for -fsanitize=address and -fsanitize=undefined fixes
2015-06-25 13:21:08 +01:00
Pádraig Brady
ad95353bf0 build: allow build to complete with -fsanitize=address
* src/make-prime-list.c (main): When building with
the above option, avoid this build stopping error:
"LeakSanitizer: detected memory leaks"
2015-06-25 02:46:07 +01:00
Pádraig Brady
77547ba7b2 maint: avoid undefined behavior in qsort call
GCC 5.1.1 -fsanitize=undefined with glibc 2.21 is returning:
"runtime error: null pointer passed as argument 1,
 which is declared to never be null"
* src/ptx.c (sort_found_occurs): Avoid the call with no entries.
2015-06-24 19:15:31 +01:00
Pádraig Brady
4d2d6c5b7c factor: avoid interspersed lines for parallel runs
* src/factor.c (n_out): A new global variable to track
how much data has been written to stdout.
(print_factors_single): Use n_out to determine whether
to flush the current (and previous) lines.
* tests/misc/factor-parallel.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
2015-06-24 17:04:01 +01:00
Pádraig Brady
32c97093db seq: handle exponents more consistently
src/seq.c (scan_arg): Set precision and width _after_ exponentiation.
For example, this will make '1.1e1 12' and '11 1.2e1' equivalent.
One can still set the precision by specifying extra precision on
the start value, or more naturally with a precision on a step value.
* tests/misc/seq-precision.sh: Add new cases.
2015-06-24 17:04:01 +01:00
Pádraig Brady
60c8e31d92 seq: use consistent output format with hex integers
* src/seq.c (scan_arg): Set precision to 0 for hex constants
(while avoiding hex floats).  This will use then use the
fast path for these arguments.  Note we also set the precision
of inf to 0 here, which ensures we use consistent precision
on output where possible.
* tests/misc/seq-precision.sh: Add corresponding test cases.
2015-06-24 17:03:59 +01:00
Pádraig Brady
fc6825b231 seq: support inf last item more generally/efficiently
* src/seq.c (main): Call seq_fast for infinite last value.
This implicitly avoids format conversion on the
999999 -> 1000000 transition.
* src/seq.c (seq_fast): Generalize the buffer handling,
and adjust to handle the "inf" last value specifics.
* tests/misc/seq-precision.sh: A new test.
* tests/local.mk: Reference the new test.
2015-06-24 17:03:35 +01:00
Pádraig Brady
53883af063 doc: list numfmt in the main menu with "Numeric operations"
* doc/coreutils.texi (main menu): Add numfmt.
2015-06-22 17:56:48 +01:00
Pádraig Brady
4f824b3f36 numfmt: don't hardcode floating point limits
* src/numfmt.c (MAX_UNSCALED_DIGITS): Set this to LDBL_DIG
rather than hardcoding at 18 for better portability.
* tests/misc/numfmt.pl: Restrict limit tests to supported platforms.
2015-06-22 17:22:04 +01:00
Pádraig Brady
bc9d16b79f numfmt: handle leading zeros correctly
* src/numfmt.c (simple_strtod_int): Don't count leading zeros
as significant digits.  Also have leading zeros as optional
for floating point numbers.
* tests/misc/numfmt.pl: Add test cases.
* NEWS: Mention the fix.
2015-06-22 02:21:02 +01:00
Pádraig Brady
a3c3e1e9e6 numfmt: avoid integer overflow when rounding
Due to existing limits this is usually triggered
with an increased precision.  We also add further
restrictions to the output of increased precision numbers.

* src/numfmt.c (simple_round): Avoid intmax_t overflow.
(simple_strtod_int): Count digits consistently
for precision loss and overflow detection.
(prepare_padded_number): Include the precision
when excluding numbers to output, since the precision
determines the ultimate values used in the rounding scheme
in double_to_human().
* tests/misc/numfmt.pl: Add previously failing test cases.
* NEWS: Mention the fix.
2015-06-22 02:02:05 +01:00
Pádraig Brady
0a279f6190 numfmt: support user specified output precision
* src/numfmt.c (usage): Update the --format description
to indicate precision is allowed.
(parse_format_string): Parse a precision specification
like the standard printf does.
(double_to_human): Honor the precision in --to mode.
* tests/misc/numfmt.pl: New tests.
* doc/coreutils.texi (numfmt invocation): Mention the new feature.
* NEWS: Likewise.
2015-06-21 04:16:29 +01:00
Dylan Cali
71063bc858 numfmt: implement support for field ranges
* src/numfmt.c: Replace field handling code with logic that understands
field range specifiers.  Instead of processing a single field and
printing line prefix/suffix around it, process each field in the line
checking whether it has been included for conversion.  If so convert and
print, otherwise just print the unaltered field.
(extract_fields): Removed.
(skip_fields): Removed.
(process_line): Gutted and heavily reworked.
(process_suffixed_number): FIELD is now passed as an arg instead of
using a global.
(parse_field_arg): New function that parses field range specifiers.
(next_field): New function that returns pointers to the next field in
a line.
(process_field): New function that wraps the field conversion logic
(include_field): New function that checks whether a field should be
converted
(compare_field): New function used for field value comparisons in a
gl_list.
(free_field): New function used for freeing field values in a gl_list.
Global variable FIELD removed.
New global variable all_fields indicates whether all fields should be
processed.
New global variable all_fields_after stores the first field of a N-
style range.
New global variable all_fields_before stores the last field of a -M
style range.
New global variable field_list stores explicitly specified fields to
process (N N,M or N-M style specifiers).
(usage): Document newly supported field range specifiers.
* bootstrap.conf: Include xlist and linked-list modules.  numfmt now
uses the gl_linked_list implementation to store the field ranges.
* tests/misc/numfmt.pl: Add tests for 'cut style' field ranges.
Adjust existing tests as partial output can occur before an error
Remove test for the 'invalid' field -5.. this is now a valid range.
* gnulib: update to avoid compiler warnings in linked-list.
* NEWS: Mention the new feature.
2015-06-19 19:59:21 +01:00
Pádraig Brady
5863426dcf doc: use correct units in df | numfmt example
* src/numfmt.c (usage): Don't scale output from df
so that numfmt outputs the correct values.
2015-06-19 14:50:36 +01:00
Pádraig Brady
6fadd46acd numfmt: handle suffixes consistently with --{from,to}-unit
* src/numfmt.c (unit_to_umax): Support SI (power of 10) suffixes
with the --from-unit and --to-unit options.  Treat suffixes like
is done with --from=auto, which for example will change the meaning
of --to-unit=G to that of --to-unit=Gi.  The suffix support was
previously undocumented and it's better to avoid the traditional
coreutils suffix handling in numfmt by default.
* doc/coreutils.texi: Document the new behavior.  Also fix a typo
mentioning {from,to}=units=.
* tests/misc/numfmt.pl: Adjust accordingly.
* NEWS: Mention the change in behavior.
2015-06-19 14:50:34 +01:00
Pádraig Brady
a262318f83 maint: remove stale online manual items at release
* gnulib: Update to get the new gnu-web-doc-update with --mirror option.
* README-release: Use the --mirror option in the instructions.
Also clarify and update various release steps.
2015-06-17 14:50:27 +01:00
Pádraig Brady
aee9826278 tail: display consistent diagnostics upon file replacement
* src/tail.c (recheck): Display diagnostices for replaced files
even with reused inodes which is a common case.
* tests/tail-2/F-vs-missing.sh: Use correct diagnostic in comment.
* tests/tail-2/F-vs-rename.sh: Likewise.
2015-06-09 11:46:29 +01:00
Pádraig Brady
6878ae412d tail: display file headers correctly with inotify
* src/tail.c (tail_forever_inotify): Use the fspec pointer to
distinguish previously output files, rather than a descriptor
from the inotify event.  That event descriptor was that of
the parent directory when files were created or renamed etc.
(check_fspec): Adjust for the new comparison.  Also show the
header when the file is truncated, since we show data
in this case also.
* tests/tail-2/F-headers.sh: A new test case.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
2015-06-09 11:14:57 +01:00
Pádraig Brady
8f2231aa24 maint: sync .gitignore items with gnulib entries
* .gitignore: Add entries for potentially generated headers.
Also remove a couple of items already present in lib/.gitignore.
* cfg.mk (sc_gitignore_missing): A new syntax check rule to
identify missing .gitignore entries.
(sc_gitignore_redundant): A new syntax check rule to
identify redundant .gitignore entries.
Reported by Tomas Nordin.
2015-06-07 17:24:21 +01:00
Pádraig Brady
3150ec900c tests: fix false failure in recent test adjustment
* configure.ac: Comment on why we link rather than run the test,
and remove the moot __ELF__ check since we never ran it anyway,
and the new CFLAGS and LDFLAGS are a more direct test of support.
* tests/misc/wc-parallel.sh: Fix a syntax error in the previous change.
* tests/misc/md5sum-parallel.sh: Use better error checking, consistent
with that used in wc-parallel.sh.
2015-06-06 14:27:54 +01:00
Paul Eggert
079652ee6b build: port to AIX
Problems reported by Michael Felt, and and part of this fix taken
from code suggested by Pádraig Brady in:
http://bugs.gnu.org/20733#112
* configure.ac (stdbuf_supported): Check for warnings, and
for -fPIC and -shared, for AIX.
* src/stat.c (STRUCT_STATVFS): Define to struct statvfs64 if
STATFS is statvfs64.
* src/sync.c (sync_arg) [_AIX]: Open in write mode,
since AIX fsync doesn't work on read-only file descriptors.
* tests/misc/wc-parallel.sh: Skip test if xargs -P does not work.
2015-06-06 00:46:13 -07:00
Paul Eggert
95413f7dff build: update gnulib submodule to latest 2015-06-06 00:46:13 -07:00
Paul Eggert
5998435209 build: update gnulib submodule to latest 2015-06-05 07:55:03 -07:00
Paul Eggert
7eaf8c8eec build: port single_binary_prog to POSIX shell
Problem reported privately by Michael Felt.
* Makefile.am (install-exec-hook):
* src/local.mk (src/coreutils_symlinks, src/coreutils_shebangs)
(clean-local):
Port to POSIX shell, which doesn't allow 'for i in ; do ...'.
2015-06-04 12:16:04 -07:00
Pádraig Brady
da355c9860 build: add a dependency on the gnulib tempname module
* bootstrap.conf: Add "tempname" which is needed by mktemp(1).
The explicit dependency supports running gnulib-tool with
the --conditional-dependencies option, used to minimize built
modules.  Note on a Fedora 22 system, that results in avoiding
redundant builds of: areadlinkat.o asnprintf.o fd-hook.o
fseterr.o printf-args.o printf-parse.o sockets.o vasnprintf.o.
However --conditional-dependencies is not enabled, since it
currently precludes the inclusion of gnulib tests.
2015-06-03 04:41:58 +01:00
Pádraig Brady
44f08f240e build: update to latest gnulib
Mainly with build fixes for Mac OS X.
2015-06-02 01:25:35 +01:00
Pádraig Brady
d796a29f2f tests: fix race in tail test without inotify
* tests/tail-2/wait.sh: Without inotify, skip a portion of the test
that checks that -F never outputs from a tailed descriptor
after the followed name is recreated, because tail_forever()
doesn't guarantee that.
Noticed at http://hydra.nixos.org/build/22766288
2015-06-01 17:02:02 +01:00
Pádraig Brady
b09f34b80f tests: fix false failure on loaded systems
* tests/misc/uniq-perf.sh: Use our standard 10s timeout,
which is sufficient to trigger the failure and also
avoids a false failure on slow/loaded systems.
Noticed at http://hydra.nixos.org/build/22766288
2015-06-01 15:38:23 +01:00
Pádraig Brady
b9842a6153 maint: avoid new coverity warnings
* src/sync.c (sync_arg): Initialise variable to avoid
unitialized access if assert is disabled.
* src/head.c (elide_tail_bytes_file): Support this function
with ---presume-input-pipe and larger files,
which regressed with commit v8.23-47-g2662702.
(elide_tail_lines_file): Likewise.
* src/dd.c (dd_copy): Explicitly don't try to ftruncate()
upon failure to lseek() (the existing check against
st_size was already protecting that).
* src/factor.c (factor_using_squfof): Assert (only when
linting due to performance) to avoid the implication of
divide by zero.
* src/od.c (read_block): Remove dead code.
* src/tac.c (tac_seekable): Likewise.
* src/ls.c (gobble_file): Likewise.
2015-05-30 00:41:09 +01:00
Pádraig Brady
17621b594a build: remove workarounds for unsupported gettext versions
Now that we depend on gettext >= 0.19.2 remove the workaround
for issues in autopoint 0.18.3.  Note the scheme currently used in
newer gettext (autopoint) to avoid these issues requires
autoconf >= 2.69, therefore we update this requirement also.

Note the gettext version dependence from gnulib comes from
gnulib using gettext macros, and coreutils indirectly depends on
the gettext module due to:
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=41dca647
bootstrap will then update m4/po.m4 and thus require a
supportng gettext version.

* bootstrap: Remove moot warning (resyncing with gnulib).
* configure.ac (AC_PREREQ): Change to 2.69 (now 3 years old).
2015-05-28 02:47:15 +01:00
Pádraig Brady
1aa71d9633 tests: ln/hard-to-sym FAIL rather than ERROR when ln fails
* tests/ln/hard-to-sym.sh: Only call framework_failure_ when ln
returns success.
2015-05-28 02:05:43 +01:00
Pádraig Brady
67db18ce0f copy: prefer our hardlink to symlink emulation on OS X 10.10
* src/copy.c (CAN_HARDLINK_SYMLINKS): Don't enable use of linkat()
on Darwin 14, as the gnulib fallback emulation there doesn't
preserve ownership and timestamps etc.  This fixes a test failure
in tests/cp/link-symlink.sh
* tests/cp/link-deref.sh: Adjust accordingly.
2015-05-28 01:42:15 +01:00
Pádraig Brady
a41172a5c4 maint: remove sys/types.h include order check
* src/system.h: This was inadvertently ineffective due to
a typo in commit v8.9-10-ge1aaf89 (Jan 2011), but has
not caused any issues, so remove.
2015-05-26 02:16:48 +01:00
Pádraig Brady
4ce7488e8d mkdir: fix -pZ with existing parent directories
When the parent directory exists and has a different
default context to the final directory, the context
was incorrectly left as that of the parent directory.

* src/mkdir.c (process_dir): Because defaultcon() is called for
existing ancestors (as it must be to avoid races), then we must
unconditionally call restorecon() on the last component due to
the already documented caveat with make_dir_parents().
Alternatively you could temp disable o->set_security_context
around make_dir_parents(), but that would be subject to races.
* tests (tests/mkdir/restorecon.sh): Add a TODO for improvement.
Reference mknod and mkfifo with print_ver_.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/20616
2015-05-23 02:04:24 +01:00
Assaf Gordon
b5f332cfe0 tests: df-output: accept multiple spaces in header
* tests/df/df-output.sh: Allow for multiple spaces in the header line
of 'df', resulting from alignment with disk sizes >= 10TB.
2015-05-22 20:45:23 +01:00
Pádraig Brady
edc5bc5020 tests: fix non POSIX constructs causing failures with dash
* tests/cp/no-ctx.sh: Scope of `var=val func` is inconsistent
across shells, so avoid that construct with functions.
* tests/df/no-mtab-status.sh: Likewise.
* tests/tail-2/inotify-race.sh: `read` needs an argument.
* tests/tail-2/inotify-race2.sh: Likewise.
2015-05-19 15:00:57 +01:00
Pádraig Brady
719c15a6f2 build: fix 'dist' and 'syntax-check' targets in VPATH build
* cfg.mk: Various syntax-check adjustments so that it's
not assumed the $builddir is the base distribution directory.
* Makefile.am: Likewise for the 'dist' target.
2015-05-17 16:00:48 +01:00
Pádraig Brady
524a86e4f5 build: avoid issues with case insensitive file systems
* cfg.mk (sc_case_insensitive_file_names): A new syntax-check rule.
* tests/tail-2/descriptor-vs-rename.sh: Rename from
tests/tail-2/f-vs-rename.sh
* tests/local.mk: Reference the renamed test.
Reported by Jim Meyering.
2015-05-17 15:50:27 +01:00
Bernhard Voelker
99dfd5a661 tests: fix check for local file system in inotify-rotate-resources.sh
* tests/tail-2/inotify-rotate-resources.sh: s/(is_local_dir)/\1_/
2015-05-14 21:31:10 +02:00
Pádraig Brady
7f0f58fdd6 tests: fix async allocation race on BTRFS
* tests/dd/sparse.sh: Sync files before checking allocations,
which may be done asynchronously on NFS and BTRFS at least.
Also mark this test as very expensive on remote file systems.
* tests/du/2g.sh: Likewise, also use fallocate if available
to efficiently allocate the large file, otherwise skip
on remote file systems.
* tests/tail-2/inotify-rotate-resources.sh: Use the more
standard is_local_dir_() to check remoteness.
* tests/cp/fiemap-empty.sh: Comment on the sync issue
for this currerntly unused test.
Fixes http://bugs.gnu.org/20570
2015-05-14 14:08:02 +01:00
Pádraig Brady
45b8fe430d timeout: with --foreground don't send SIGCONT
* src/timeout.c (cleanup): Don't send SIGCONT to the monitored program
when --foreground is specified, as it's generally not needed for
foreground programs, and can cause intermittent signal delivery
issues with monitors like GDB for example.
* doc/coreutils.texi (timeout invocation): Mention that SIGCONT
is not sent with --foreground.
* NEWS: Mention the behavior change.
2015-05-13 13:48:56 +01:00
Pádraig Brady
703747f892 split: auto set suffix len for --numeric-suffixes=<N --number=N
Supporting `split --numeric-suffixes=1 -n100` for example.

* doc/coreutils.texi (split invocation): Mention the two
use cases for the FROM parameter, and the consequences on
the suffix length determination.
* src/split.c (set_suffix_length): Use the --numeric-suffixes
FROM parameter in the suffix width calculation, when it's
less than the number of files specified in --number.
* tests/split/suffix-auto-length.sh: Add test cases.
Fixes http://bugs.gnu.org/20511
2015-05-13 12:43:40 +01:00
Assaf Gordon
79111d1553 doc: clarify the operation of wc -L
* src/wc.c (usage): State that it calculates display width.
* doc/coreutils.texi (wc invocation): Detail the distinct
items used to determine the display width.
2015-05-13 02:54:19 +01:00
Pádraig Brady
b28ff6a3c6 tail: consistently output all data for truncated files
Generally if logs are truncated, they're truncated to 0 length,
so output all existing data when our heuristic determines truncation.
Note with inotify, truncate() and write() are often determined
independently and so all data would be written if that was the case.

* src/tail.c (check_fspec): Reset file offset to 0 upon truncation.
(tail_forever): Likewise.
(recheck): Add a FIXME for the related issue where tail may lose
data due to tail discounting older log files too early.
* tests/tail-2/truncate.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the fix.
2015-05-11 23:16:14 +01:00
Pádraig Brady
cf06a872e7 tail: fix inotify startup races
The previous fixes to races in the various tail tests,
identified actual races in the tail inotify implementation.
With --follow=descriptor, if the tailed file was replaced before
the inotify watch was added, then any subsequent changes were ignored.
Similarly in --follow=name mode, all changes to a new name were
effectively ignored if that name was created after the original open()
but before the inotify_add_watch().

* src/tail.c (tail_forever_inotify): Fix 3 cases.
1. With -f, don't stop tailing when file removed before watch.
2. With -f, watch right file when file replaced before watch.
3. With -F, inspect correct file when replaced before watch.
Existing tests identify these when tail compiled with TAIL_TEST_SLEEP.
* tests/tail-2/inotify-rotate-resources.sh:
This test also identifies the issue with --follow=name
when TAIL_TEST_SLEEP is used.  Adjust so the test is immune
to such races, and also fail quicker on remote file systems.
* tests/tail-2/inotify-race2.sh: A new test using GDB,
based on inotify-race.sh, which tests the -F race
without needed recompilation with sleeps.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug.
2015-05-11 23:03:32 +01:00
Pádraig Brady
9069f4ec85 tests: cleanup background processes upon interruption
Reap background processes so that:
- Stray processes aren't left on the system
- Files aren't held open causing deletion issues on NFS
- Partitions used to run the tests from can be unmounted

* tests/tail-2/F-vs-missing.sh: Add the `kill && wait` of the
background $pid(s) to cleanup_().
* tests/tail-2/F-vs-rename.sh: Likewise.
* tests/tail-2/f-vs-rename.sh: Likewise.
* tests/tail-2/append-only.sh: Likewise.
* tests/tail-2/assert-2.sh: Likewise.
* tests/tail-2/assert.sh: Likewise.
* tests/tail-2/flush-initial.sh: Likewise.
* tests/tail-2/inotify-hash-abuse.sh: Likewise.
* tests/tail-2/inotify-hash-abuse2.sh: Likewise.
* tests/tail-2/inotify-race.sh: Likewise.
* tests/tail-2/inotify-rotate-resources.sh: Likewise.
* tests/tail-2/inotify-rotate.sh: Likewise.
* tests/tail-2/pid.sh: Likewise.
* tests/tail-2/pipe-f2.sh: Likewise.
* tests/tail-2/retry.sh: Likewise.
* tests/tail-2/symlink.sh: Likewise.
* tests/tail-2/tail-n0f.sh: Likewise.
* tests/tail-2/wait.sh: Likewise.
* tests/cp/existing-perm-race.sh: Likewise.
* tests/cp/file-perm-race.sh: Likewise.
* tests/cp/parent-perm-race.sh: Likewise.
* tests/cp/sparse-to-pipe.sh: Likewise.
* tests/dd/stats.sh: Likewise.
* tests/du/move-dir-while-traversing.sh: Likewise.
* tests/misc/cat-buf.sh: Likewise.
* tests/misc/help-version.sh: Likewise.
* tests/misc/printf-surprise.sh: Likewise.
* tests/misc/sort-compress-proc.sh: Likewise.
* tests/misc/sort-spinlock-abuse.sh: Likewise.
* tests/misc/stdbuf.sh: Likewise.
* tests/misc/tac-continue.sh: Likewise.
* tests/misc/timeout-group.sh: Likewise.
* tests/mv/i-3.sh: Likewise.
* tests/rm/dangling-symlink.sh: Likewise.
* tests/rm/isatty.sh: Likewise.
* cfg.mk (sc_prohibit_test_background_without_cleanup_):
A new syntax-check to ensure cleanup_() is defined
when background tasks are created in a test.
2015-05-11 23:02:16 +01:00
Pádraig Brady
fe02153e64 tests: avoid hung processes due to gdb SIGCONT handling
* tests/tail-2/inotify-race.sh: Add a `wait` to ensure that
we reap all background gdb and tail processes.  That resulted
in the test hanging intermittently and upon investigation was
due to gdb intermittently failing to terminate the child process
due to receiving a SIGCONT signal.  Therefore we avoid using
timeout(1) which sends that signal, and instead rely on tail's
inbuilt --pid monitoring on a background sleep process.
Given this new implementation, the VERY_EXPENSIVE guard was removed.
Related issues with this test hanging were previously discussed at:
https://lists.gnu.org/archive/html/bug-coreutils/2009-12/msg00025.html
2015-05-11 14:41:17 +01:00
Pádraig Brady
8ee3ca4bb9 tests: fix races in and standardize the tail tests
* tests/tail-2/F-vs-missing.sh: Use standard "fastpoll" options
(-s.1 --max-unchanged-stats=1) to speedup the non-inotify case.
Add the non-inotify case to the test. `wait` on the background
tail process to terminate which should avoid the need for the
non standard `retry_delay_ cleanup ...` on NFS.
* tests/tail-2/F-vs-rename.sh: Remove 'out' at the start of the loop,
to avoid a race in checking its contents.  Also ensure 'a' & 'b'
files are present before the tail process starts.  Use the standard
"fastpoll" options as above.
* tests/tail-2/f-vs-rename.sh: Likewise.
* tests/tail-2/append-only.sh: Use more standard variable names.
* tests/tail-2/flush-initial.sh: Use "fastpoll" options for
non-inotify platforms.  Also `wait` on the background tail to avoid
stray processes and file cleanup issues on NFS.
* tests/tail-2/inotify-hash-abuse.sh: Always run non-inotify case.
Use "fastpoll" options.  Use a more standard retry_delay_ instead
of a hardcoded sleep loop.  Add a `wait` on the background tail.
* tests/tail-2/inotify-hash-abuse2.sh: Likewise.
* tests/tail-2/inotify-rotate-resources.sh: Wait just on the
specific tail $pid needed.
* tests/tail-2/inotify-rotate.sh: Use "fastpoll" options.
* tests/tail-2/pid.sh: Use standard variable names.
Add a `wait` on the background tails.
* tests/tail-2/pipe-f2.sh: Likewise.
* tests/tail-2/tail-n0f.sh: Likewise.
* tests/tail-2/retry.sh: Use "fastpoll" options.
* tests/tail-2/symlink.sh: Likewise.
* tests/tail-2/wait.sh: Likewise.  Speedup by using sub second
parameters to timeout(1).  Improve the part ensuring that
-F never follows a renamed file.
* tests/tail-2/infloop-1.sh: Remove invalid test.  tail(1) was not
being passed the --pid=$yes_pid option, retry_delay_ wasn't used
to avoid races, and yes could write huge files before being killed.
* tests/local.mk: Remove the invalid test reference.
* tests/tail-2/assert-2.sh: Rewrite using retry_delay_().  Since
no longer hardcoding large delays, remove the VERY_EXPENSIVE tag.
* tests/tail-2/assert.sh: Likewise.
2015-05-11 14:41:17 +01:00
Paul Eggert
a976d7c9ab build: rewrite is_ENOTSUP without an #if directive
* src/system.h (is_ENOTSUP): Avoid in-function #if directive.
2015-05-10 08:34:16 -07:00
Jim Meyering
aa7f31fc4a build: avoid a warning form gcc's new -Wlogical-op
Without this change, very recent gcc (e.g., version 6.0.0 20150509)
would print the following when configured with --enable-gcc-warnings:

  src/copy.c:165:30: error: logical 'or' of equal expressions \
    [-Werror=logical-op]
    && (errno == EOPNOTSUPP || errno == ENOTSUP || errno == ENOSYS))
                           ^
* src/system.h (is_ENOTSUP): New function.
* src/copy.c (punch_hole): Use it.
* src/ls.c (errno_unsupported, gobble_file): Use it.
2015-05-09 22:49:07 -07:00
Pádraig Brady
e981643ae3 doc: standardize messages about the '-' stdin FILE
* src/system.h (emit_stdin_note): A new function, refactoring
the usage note about the '-' FILE implying stdin.
* src/base64.c (usage): Use the new function to emit the
note in a standard location and with standard separation.
* src/cat.c (usage): Likewise.
* src/csplit.c (usage): Likewise.
* src/cut.c (usage): Likewise.
* src/expand.c (usage): Likewise.
* src/fmt.c (usage): Likewise.
* src/head.c (usage): Likewise.
* src/md5sum.c (usage): Likewise.
* src/nl.c (usage): Likewise.
* src/od.c (usage): Likewise.
* src/paste.c (usage): Likewise.
* src/pr.c (usage): Likewise.
* src/ptx.c (usage): Likewise.
* src/shred.c (usage): Likewise.
* src/shuf.c (usage): Likewise.
* src/sort.c (usage): Likewise.
* src/sum.c (usage): Likewise.
* src/tac.c (usage): Likewise.
* src/tail.c (usage): Likewise.
* src/tsort.c (usage): Likewise.
* src/unexpand.c (usage): Likewise.
* src/wc.c (usage): Likewise.
* src/join.c (usage): Adjust the separation used for
the message referring to FILE1 or FILE2 as stdin.
* src/comm.c (usage): Add a message using the same
wording (translation) as used in join.
* src/split.c (usage): Reword to using FILE rather than
INPUT, allowing use of emit_stdin_note().  Also remove
the mention of "fixed-size" pieces as this isn't now
always the case.
Fixes http://pad.lv/1450179
2015-04-30 18:25:01 +01:00
Pádraig Brady
88a0354824 tests: don't skip df tests with /proc/self/mountinfo
* tests/df/no-mtab-status.sh: getmntent is no longer called
when /proc/self/mountinfo is present, thus causing the test
to be skipped.  Therefore wrap fopen() to ignore mountinfo,
and use the test genmntent table instead.
* tests/df/skip-duplicates.sh: Likewise.
2015-04-30 18:24:47 +01:00
Yunlian Jiang
c77a96ccba build: fix SINGLE_BINARY build when printf is a macro
* src/coreutils.c (usage): include coreutils.h outside
the printf call, because if it's a macro you will get the error:
embedding a #include directive within macro arguments is not supported
2015-04-28 23:48:30 +01:00
Pádraig Brady
bdf6837655 maint: avoid a new -Werror=return-type warning in yes.c
* src/yes.c (main): Simplify the logic so that the
compiler can see this function always returns a value.
This was seen with GCC 5.0 in SINGLE_BINARY mode.
2015-04-28 23:07:13 +01:00
Pádraig Brady
09152f2d75 tests: run ls capability coloring test irrespective of $LS_COLORS
* tests/ls/no-cap.sh: Ensure the test isn't skipped even if
capability coloring is disabled in the current $LS_COLORS.
Also just enable/disable capability coloring to avoid the
dircolors(1) overhead.
2015-04-28 21:30:25 +01:00
Pádraig Brady
824bcc6434 maint: use gnulib styling with the online manual
The equivalent styling added in v8.23-155-g3b98ee7,
is now applied to gnulib using projects by default.
2015-04-27 11:09:48 +01:00
Pádraig Brady
b817f62769 build: rely on gnulib to determine printf routines are safe
gnulib now only checks that the printf routines never crash,
which is all coreutils currrently requires, and so we revert
commit v8.23-81-gf57bfbb to let gnulib decide whether to replace
the system printf routines.
2015-04-27 11:00:07 +01:00
Pádraig Brady
0e7ac9a460 maint: fix printf format for signed integers
With GCC 5 and the newly added warnings from gnulib, ensure the
correct signed integer is passed for the printf format,
to avoid -Werror=format= failures.
2015-04-27 10:55:26 +01:00
Pádraig Brady
17fba994bd build: update gnulib submodule to latest
Fix file-has-acl build failure on RHEL/Centos 6.
Fix GCC 5 warnings with printf and in fts.c.
2015-04-27 10:27:16 +01:00
Pádraig Brady
0dcde34931 build: reduce gettext dependency to 0.19.2
* bootstrap.conf: 0.19.2 is available on openSUSE-13.2,
Debian-8.0, and Ubuntu-14.10.  Given there were issues
with earlier 0.19 gettext releases, set this as the new minimum.
* configure.ac (AM_GNU_GETTEXT_VERSION): Likewise.
Reported by Bernhard Voelker
2015-04-27 10:18:16 +01:00
Paul Eggert
997265d56e ls: on GNU/Linux, remove dependency on libacl
* src/local.mk (src_ls_LDADD): Change from LIB_ACL to LIB_HAS_ACL.
2015-04-26 22:10:46 -07:00
Paul Eggert
f0b437f3cc build: update gnulib submodule to latest
* bootstrap.conf (gnulib_modules): Add file-has-acl.
(buildreq): Bump autopoint and gettext to 0.19.4.
* configure.ac (AM_GNU_GETTEXT_VERSION):
Bump to 0.19.4.
* gl/lib/tempname.c.diff, gl/lib/tempname.h.diff:
Merge recent gnulib changes.
2015-04-26 22:10:38 -07:00
Michael Witten
02f678a350 doc: fix grammar issue in truncate info
* doc/coreutils.texi (truncate invocation): The word 'their' is
incorrect; 'each file' is the antecedent, and is singular,
so 'its' is the correct pronoun.
2015-04-23 20:13:50 +01:00
Pádraig Brady
1018d6a7e8 build: fix potential factor build failure on arm and mips
* src/longlong.h: Sync with the latest longlong.h from libgmp to:
- Use __builtin_c[lt]zl on arm64.
- Fix sparc64 vis3 build failure due to missing __clz_tab.
- Avoid a clang build issue on mips.
- Support thumb2 arm 32 bit system.
* src/cfg.mk (sc_ensure_comma_after_id_est): Exclude longlong.h
to ease merges.
2015-04-22 11:11:26 +01:00
Pádraig Brady
8878c4ef1b maint: avoid -Werror=strict-overflow warnings with GCC 5
All warnings were of the form: "assuming signed overflow does not occur
when simplifying conditional to constant [-Werror=strict-overflow]"

* src/dd.c (cache_round): Use an appropriately sized unsigned type,
to avoid possibility of undefined signed overflow.
* src/mknod.c (main): Likewise.
* src/pr.c (pad_down): Likewise.
* src/wc.c (main): Likewise.
* src/tail.c (main): Assert that argc >= 0 thus allowing the
compiler to assume without implication that argc - optind
is positive.
2015-04-22 11:11:19 +01:00
Pádraig Brady
01f4065b12 dircolors: add 'MISSING' to the default database
* src/dircolors.hin: Add the MISSING entry, to indicate
this as a possibility in new templates output from dircolors,
and also to ease comparison with existing databases that
generally do define a MISSING entry.
2015-04-17 23:51:32 +01:00
Andreas Gruenbacher
88e491044b doc: clarify how cp behaves with default ACLs
* doc/coreutils.texi (cp invocation): Mention that when copying files
without preserving permissions, the umask or a default ACL affect
the mode of new files.
* THANKS.in: Remove committer.
Related to http://bugs.gnu.org/8527
2015-04-13 09:39:37 +01:00
Pádraig Brady
1b1c40e1d6 df: fix --local hanging with inaccessible remote mounts
* src/df.c (filter_mount_list): With -l, avoid stating remote mounts.
* init.cfg: Avoid test hangs with inaccessible remote mounts.
* tests/df/no-mtab-status.sh: Skip with inaccessible remote mounts.
* tests/df/skip-rootfs.sh: Likewise.
* tests/df/total-verify.sh: Likewise.
* NEWS: Mention the bug fix.
Reported at http://bugzilla.redhat.com/1199679
2015-04-13 09:20:55 +01:00
Mitchel Humpherys
74bf6670eb doc: correct pluralization for mkfifo and mknod
* doc/coreutils.texi: `mkfifo' and `mknod' use the optContext macro
which adds a description for the SELinux security context in addition to
the single option already described in each case.  The result in both
cases is two options being introduced as `option' (singular).  Fix this
by introducing them as `options' (plural).
2015-04-09 08:49:34 +02:00
Pádraig Brady
bf180f8f5a df: fix use of uninitialized variable reported by valgrind
Conditional jump or move depends on uninitialised value(s)
    at 0x40380C: get_field_values (df.c:840)
    by 0x403E16: get_dev (df.c:994)
    by 0x404D65: get_all_entries (df.c:1364)
    by 0x405926: main (df.c:1714)

* src/df.c (get_dev): Initialize the fsu.fsu_bavail_top_bit_set
member, when adding placeholder entries.
(main): Avoid a "definitely lost" memory leak warning from valgrind,
reported by Bernhard Voelker.
2015-04-03 14:27:27 +01:00
Pádraig Brady
ccf1cd87f8 doc: clarify that ls --sort=time is newest first
* src/ls.c (usage): Add punctuation to avoid ambiguity in the
description of the --time option.  Mention that both the -u
and --sort=time default order is newest first.
2015-04-01 02:04:19 +01:00
Stephane Chazelas
d313a0b242 tail: fix -f to follow changes after a rename
* src/tail.c (tail_forever_inotify): Only monitor write()s and
truncate()s to files in --follow=descriptor mode, thus avoiding
the bug where we removed the watch on renamed files.
Also adjust the inotify event processing code that is
now significant only in --follow=name mode.
* tests/tail-2/F-vs-rename.sh: Improve this existing test by running
in both polling and inotify modes.
* tests/tail-2/f-vs-rename.sh: A new test based on the existing one.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug.
Fixes http://bugs.gnu.org/19760
2015-03-31 11:55:32 +01:00
Pádraig Brady
52209ee547 doc: move numfmt info to the 'Numeric operations' section
* doc/coreutils.texi: Move numfmt info to this section,
as numfmt functionality aligns more with seq and factor,
than fmt and pr etc.
2015-03-29 02:44:57 +01:00
Paul Eggert
9b2782ca6d nohup: clarify stdin redirection
Problem reported by Isaac Schwabacher in:
http://bugs.gnu.org/20214
* doc/coreutils.texi (nohup invocation): Clarify that when nohup's
stdin gets redirected, it's unreadable.
* doc/coreutils.texi (nohup invocation):
* src/nohup.c (usage): Don't promise /dev/null.
2015-03-27 15:02:35 -07:00
Assaf Gordon
cbed4b3376 tests: fix false test failure with df on Debian/kFreeBSD
* tests/fs/skip-duplicates.sh: On this platform .mnt_opts is significant
so define to empty to avoid a NULL deref in read_file_system_list().
Fixes http://bugs.gnu.org/20210
2015-03-27 09:43:42 +00:00
Christoph Anton Mitterer
41d0fc1c37 doc: disambiguate the ls --color description
* src/ls.c (usage): Avoid the implication that the
default ls behavior is to --color=always.
Reported in http://bugs.debian.org/781208
2015-03-26 09:51:50 +00:00
Pádraig Brady
bf11fd17a9 doc: clarify the date standard output formats
* src/date.c (usage): Use FMT rather than TIMESPEC as the parameter,
since it's simpler to understand and can be better aligned.
Give an example for the --iso-8601 output format.
Adjust the example used for the 3 standard formats to be unambiguous
with respect to day/mon ordering and use of leading zeros in the time.
Reorder the options descriptions slightly, so that the
3 standards options are together.
Indent the multi-line descriptions so that grouping is obvious.
Remove a redundant description of the --rfc-3339 format,
which is obvious in the existing example.
Separate these 3 standards options to their own translatable string
to simplify translation.
Change 'date and time' to 'date/time' in the --iso-8601 description
to be consistent with --rfc-3339 and to help avoid the implication
that the time is always output or even output by default.
Fixes http://bugs.gnu.org/20203
2015-03-26 08:40:31 +00:00
Pádraig Brady
3b98ee7e99 maint: apply basic styling to online manual
* README-release: Reference http://www.gnu.org/s/coreutils/manual.css
to apply basic styling to the online coreutils manual, consistent
with the Emacs documentation.
2015-03-24 10:25:54 +00:00
Pádraig Brady
88f170e0c0 doc: clarify the uniq -D man page description
* src/uniq.c (usage): The description was very confusing in the man page
due to the stripped newlines.  Add punctuation for clarification.
2015-03-24 10:25:48 +00:00
Pádraig Brady
56ff7a6760 wc: use a more adaptive wc -l implementation
* src/wc.c (wc): Allow any block to select the count implementation,
rather than just using the first 10 lines.  This also simplifies
the code from 3 loops to 2.
2015-03-24 10:23:29 +00:00
Dan Jacobson
01fb984887 doc: clarify default order for ls --sort=size
* src/ls.c (usage): Mention that default order is largest first.
Fixes http://bugs.gnu.org/20172
2015-03-23 09:03:58 +00:00
Pádraig Brady
9042ff441c maint: really fix wildcard quoting in sc_tests_executable
* cfg.mk (sc_tests_executable): The previous commit avoided
the globbing, but also passed on the quoted wildcards to find(1).
We could use eval to handle the quoting, though that's a bit
awkward and dangerous, so instead explicitly disable globbing
for the whole make target subshell.  Note noglob is not available
on solaris, where we fall back to set -f.  Note also that zsh
uses set -F for this, but that's moot here.  Also correct the
find(1) expression to include the -o between each wildcard.
2015-03-20 14:34:31 +00:00
Pádraig Brady
79e27fd67e maint: fix wildcard quoting in sc_tests_executable
* cfg.mk (sc_tests_executable): If there are files with
$TEST_EXTENSIONS in the current directory, then the
lack of quoting of the $test_extensions_rx contents
could result in globbing and an inconsequential run.
find(1) produces warnings only with more than one expansion.
2015-03-20 01:16:06 +00:00
Kristoffer Brånemyr
1025243b6a wc: speedup counting of short lines
Using a test file generated with:
  yes | head -n100M > 2x100M.txt

before> time wc -l 2x100M.txt
  real 0.842s
  user 0.810s
  sys  0.033s

after> time wc -l 2x100M.txt
  real 0.142s
  user 0.111s
  sys  0.031s

* src/wc.c (wc): Split the loop that deals with -l into 3.
The first is used at the start of the input to determine if
the average line length is < 15, and if so the second loop is
used to look for '\n' internally to wc.  For longer lines,
memchr is used as before to take advantage of system specific
optimizations which any outweigh function call overhead.
Note the first 2 loops could be combined, though in testing,
GCC 4.9.2 at least, wasn't sophisticated enough to separate
the loops based on the "check_len" invariant.
Note also __builtin_memchr() isn't significant here as
GCC currently only applies constant folding with that.
* NEWS: Mention the improvement.
2015-03-20 00:48:52 +00:00
Giuseppe Scrivano
e2e11119e0 yes: improve efficiency when all args aren't buffered
* src/yes.c (main): Even when the internal buffer isn't large enough,
output what we've buffered already, and interate over the rest.
This improves the performance in the edge case where there are
many small arguments that overflow the buffer.
* tests/misc/yes.sh: Add a test case for the many small arguments case.
2015-03-10 12:30:33 +00:00
Pádraig Brady
35217221c2 yes: output data more efficiently
yes(1) may be used to generate repeating patterns of text
for test inputs etc., so adjust to be more efficient.

Profiling the case where yes(1) is outputting small items
through stdio (which was the default case), shows the overhead
of continuously processing small items in main() and in stdio:

    $ yes >/dev/null & perf top -p $!
    31.02%  yes           [.] main
    27.36%  libc-2.20.so  [.] _IO_file_xsputn@@GLIBC_2.2.5
    14.51%  libc-2.20.so  [.] fputs_unlocked
    13.50%  libc-2.20.so  [.] strlen
    10.66%  libc-2.20.so  [.] __GI___mempcpy
     1.98%  yes           [.] fputs_unlocked@plta

Sending more data per stdio call improves the situation,
but still, there is significant stdio overhead due to memory copies,
and the repeated string length checking:

    $ yes "`echo {1..1000}`" >/dev/null & perf top -p $!
    42.26%  libc-2.20.so  [.] __GI___mempcpy
    17.38%  libc-2.20.so  [.] strlen
     5.21%  [kernel]      [k] __srcu_read_lock
     4.58%  [kernel]      [k] __srcu_read_unlock
     4.27%  libc-2.20.so  [.] _IO_file_xsputn@@GLIBC_2.2.5
     2.50%  libc-2.20.so  [.] __GI___libc_write
     2.45%  [kernel]      [k] system_call
     2.40%  [kernel]      [k] system_call_after_swapgs
     2.27%  [kernel]      [k] vfs_write
     2.09%  libc-2.20.so  [.] _IO_do_write@@GLIBC_2.2.5
     2.01%  [kernel]      [k] fsnotify
     1.95%  libc-2.20.so  [.] _IO_file_write@@GLIBC_2.2.5
     1.44%  yes           [.] main

We can avoid all stdio overhead by building up the buffer
_once_ and outputting that, and the profile below shows
the bottleneck moved to the kernel:

    $ src/yes >/dev/null & perf top -p $!
    15.42%  [kernel]      [k] __srcu_read_lock
    12.98%  [kernel]      [k] __srcu_read_unlock
     9.41%  libc-2.20.so  [.] __GI___libc_write
     9.11%  [kernel]      [k] vfs_write
     8.35%  [kernel]      [k] fsnotify
     8.02%  [kernel]      [k] system_call
     5.84%  [kernel]      [k] system_call_after_swapgs
     4.54%  [kernel]      [k] __fget_light
     3.98%  [kernel]      [k] sys_write
     3.65%  [kernel]      [k] selinux_file_permission
     3.44%  [kernel]      [k] rw_verify_area
     2.94%  [kernel]      [k] __fsnotify_parent
     2.76%  [kernel]      [k] security_file_permission
     2.39%  yes           [.] main
     2.17%  [kernel]      [k] __fdget_pos
     2.13%  [kernel]      [k] sysret_check
     0.81%  [kernel]      [k] write_null
     0.36%  yes           [.] write@plt

Note this change also ensures that yes(1) will only write
complete lines for lines shorter than BUFSIZ.

* src/yes.c (main): Build up a BUFSIZ buffer of lines,
and output that, rather than having stdio process each item.
* tests/misc/yes.sh: Add a new test for various buffer sizes.
* tests/local.mk: Reference the new test.
Fixes http://bugs.gnu.org/20029
2015-03-10 00:12:30 +00:00
Pádraig Brady
3c3b760c34 build: fix make dependencies for test.1
In certain parallel build situations this would give the error:
  help2man: can't get `--help' info from man/test.td/[
  Makefile:14189: recipe for target 'man/test.1' failed

* man/local.mk (test.1): Depend on `[` rather than `test`,
as `test --help` outputs nothing.  Also move dir.1 and vdir.1
back to the main list, as they're no more exceptions than
sha1sum etc.
2015-03-07 02:09:37 +00:00
Bernhard Voelker
c18b296e83 maint: be less strict about executable permissions of tests
With "umask 0027" or even "umask 0077", the git clone of coreutils
does not have the executable bit set for 'other' (or 'group).
Therefore, "make syntax-check" would fail.

* cfg.mk (sc_tests_executable): Change the -perm argument of find(1)
to only print the names of the files which are not executable by the
user, rather than insisting on ugo+x (octal 111).
2015-03-05 16:54:52 +01:00
Stéphane Aulery
e005719211 doc: mention persistence caveats in sync man page
* man/sync.x ([BUGS]): Mention the caveats and reference
the system call man pages for more details.
Fixes http://bugs.gnu.org/19995

Debian bug #507085 reported by jidanni@jidanni.org
2015-03-05 12:21:50 +00:00
Pádraig Brady
5e9c277f99 tee: generalize the --write-error option to --output-error
Adjust commit v8.23-140-gfdd6ebf to add the --output-error option
instead of --write-error, and treat open() errors like write() errors.

* doc/coreutils.texi (tee invocation): s/write-error/output-error/.
* src/tee.c (main): Exit on open() error if appropriate.
* tests/misc/tee.sh: Add a case to test open() errors.
* NEWS: Adjust for the more general output error behavior.

Suggested by Bernhard Voelker.
2015-03-04 13:24:21 +00:00
Jarosław Gruca
69410690b8 maint: update stale comment about ls color sequences
* src/ls.c (color_indicator[C_END]): Comment with the correct
sequence, which was used since commit v6.10-61-g483297d
Fixes http://bugs.gnu.org/19992
2015-03-04 11:47:59 +00:00
Shane M Seymour
e60547db04 tail,stat: improve support for the IBRIX file system
Note that IBRIX used to have a different magic number 0x013111A7
instead of the current 0x013111A8.  However, the former is no longer
used and the version of IBRIX it was used in is really ancient, so
it's extremely unlikely anyone is still using it.  Therefore, just
add the newer magic number.
Mark IBRIX as a 'remote' file system type as inotify support had
never been officially tested with it.

* src/stat.c (human_fstype): Add file system ID definition.
* NEWS: Mention the improvement.

Fixes http://bugs.gnu.org/19951
2015-02-27 18:54:01 +01:00
Pádraig Brady
fdd6ebf0ae tee: add --write-error to control handling of closed pipes
tee is very often used with pipes and this gives better control
when writing to them.  There are 3 classes of file descriptors
that tee can write to: files(1), pipes(2), and early close pipes(3).
Handling write errors to 1 & 2 is supported at present with the caveat
that failure writing to any pipe will terminate tee immediately.
Handling write errors to type 3 is not currently supported.
To improve the supported combinations we add these options:

 --write-error=warn
   Warn if error writing any output including pipes.
   Allows continued writing to still open files/pipes.
   Exit status is failure if any output had error.
 --write-error=warn-nopipe, -p
   Warn if error writing any output except pipes.
   Allows continued writing to still open files/pipes.
   Exit status is failure if any non pipe output had error.
 --write-error=exit
   Exit if error writing any output including pipes.
 --write-error=exit-nopipe
   Exit if error writing any output except pipes.

Use the "nopipe" variants when files are of types 1 and 3, otherwise
use the standard variants with types 1 and 2.  A caveat with the above
scheme is that a combination of pipe types (2 & 3) is not supported
robustly.  I.e. if you use the "nopipe" variants when using both type
2 and 3 pipes, then any "real" errors on type 2 pipes will not be
diagnosed.
  Note also a general issue with type 3 pipes that are not on tee's
stdout, is that shell constructs don't allow to distinguish early
close from real failures.  For example `tee >(head -n1) | grep -m1 ..`
can't distinguish between an error or an early close in "head" pipe,
while the fail on the grep part of the pipe is distinguished
independently from the resulting pipe errors.  This is a general
issue with the >() construct, rather than with tee itself.

* NEWS: Mention the new feature.
* doc/coreutils.texi (tee invocation): Describe the new option.
* src/tee.c (usage): Likewise.
(main): With --write-error ignore SIGPIPE, and handle
the various exit, diagnostics combinations.
* tests/misc/tee.sh: Tess all the new options.
Fixes http://bugs.gnu.org/11540
2015-02-24 18:12:22 +00:00
Bernhard Voelker
19d34d244b tee: close "-" file
This is a cleanup to the previous commit v8.23-138-g7ceaf1d.

* src/tee.c (tee_files): Do not exempt the "-" file from being closed,
as this is no longer stdout but a normal file.
2015-02-23 11:39:08 +01:00
Bernhard Voelker
7ceaf1d975 tee: treat '-' operand as file name as mandated by POSIX
Since v5.2.1-1247-g8dafbe5, tee(1) treated '-' as stdout while POSIX
explicitly requires to treat this as a file name.  Revert this change,
as the interleaved output - due to sending another copy of input to
stdout - is not considered to be useful.  Discussed in
http://lists.gnu.org/archive/html/coreutils/2015-02/msg00085.html

* src/tee.c (tee_files): Remove the special handling for "-" operands.
(usage): Remove the corresponding sentence.
* doc/coreutils.texi (common options): Remove the "tee -" example.
(tee invocation): Document that tee(1) now treats "-" as a file name.
* tests/misc/tee.sh: Add a test case for "tee -".
While at it, re-indent the above multi-argument processing case and
extend that to 13 operands, as POSIX mandates that, too.
* tests/misc/tee-dash.sh: Remove now-obsolete test.
* tests/local.mk (all_tests): Remove the above test.
* NEWS (Changes in behavior): Mention the change.
2015-02-20 14:00:41 +01:00
Pádraig Brady
3f2f05f067 tee: exit early if no more writable outputs
* src/tee.c (main): Don't continue reading if we can't
output anywhere.
* tests/misc/tee.sh: Ensure we exit when no more outputs.
* NEWS: Mention the change in behavior.
2015-02-18 23:41:27 +00:00
Pádraig Brady
ced120406f tests: support stderr verification with returns_()
* tests/init.sh (returns_): Disable tracing for this wrapper
function, so that stderr of the wrapped command is unchanged,
allowing for verification of the contents.
2015-02-18 23:36:34 +00:00
Bernhard Voelker
9f5dce8070 maint: prefer STREQ_LEN and STRPREFIX over strncmp in all cases
* cfg.mk (sc_prohibit_strncmp): Improve the search pattern: use
_sc_search_regexp to find all invocations of strncmp except when
used on a macro definition line; just match the function name with
an opening parenthesis.  Before, the expression missed places where
the comparison against 0 was in a subsequent line.
* src/system.h (STRNCMP_LIT): Shorten 'literal' to 'lit' to move
the whole definition of the macro into one line - thus making
sc_prohibit_strncmp pass.
(STRPREFIX): Add space before parenthesis.
* src/du.c (main): Prefer STREQ_LEN over strncmp.
* src/pinky.c (scan_entries): Likewise.
* src/tac.c (tac_seekable): Likewise.
* src/who.c (scan_entries): Likewise.
2015-02-17 08:50:34 +01:00
Pádraig Brady
321bd11352 stty: fix setting of 'extproc' on BSD
This setting is unusual on BSD as it's read normally in the local
flags returned by tcgetattr(), but can only be set with an ioctl.
Setting with tcsetattr() is ignored.

* src/stty.c (NO_SETATTR): A new flag to indicate the setting
is read and displayed like a normal termios flag, but is set
in some other manner.
(main): Skip tcsetattr() for this setting when this flag is set.
Also fixup the exiting 'extproc' processing to handle the
'-extproc' case correctly.
(sane_mode): Skip setting '-extproc' for 'sane' to avoid the error.
This isn't ideal but matches the operation of the BSD native stty.
2015-02-17 03:03:23 +00:00
Bernhard Voelker
3d4daddc70 maint: enhance '.mailmap' mappings for THANKS generation
* .mailmap (jeff.liu@oracle.com): There are 3 different names in the
'git log' output for this email address; choose "Jeff Liu" as canonical
form.
(Алексей Шилин): Convert name to latin1 ("Aleksej Shilin")
to improve the sort order of the generated 'THANKS' file.
2015-02-13 00:43:30 +01:00
Bernhard Voelker
a07026f62b maint: sort THANKS using our own gear
At least 'sort' on openSUSE/Fedora have a bug in the case-folding code
of their I18N downstream patch which leads to wrong sort results,
e.g. "Dániel" coming after "Dylan".

* Makefile.am (THANKS): Sort the final contributor list using our
own sort implementation - as others may result in a different order;
add a FIXME comment to remove this again once common platforms have
a functional 'sort -f'.  Add '-k1,1' for a better sort order.
While at it, save a grep and perl call to prepare the list from
'THANKS.in' by doing all in the first perl call.
2015-02-12 02:35:07 +01:00
Pádraig Brady
87635d6e45 maint: remove redundant diff filtering from sc_long_lines
* cfg.mk (sc_long_lines): diff files are now completely excluded,
so no need to filter portions of them.
Reported by Bernhard Voelker.
2015-02-11 13:26:38 +00:00
Pádraig Brady
7577d1582b build: update to latest gnulib
This includes a change to require --with-libmount
to be used with configure, due to the many libmount dependencies.

* bootstrap: Sync with gnulib to exit early on gnulib-tool error.
* gl/lib/tempname.c.diff: Adjust for gnulib changes.
* gl/lib/tempname.h.diff: Likewise.
* gl/modules/tempname: Likewise.
* doc/.gitignore: Add new gendocs_template_min gnulib script.
2015-02-11 03:58:55 +00:00
Pádraig Brady
f2e499db39 maint: exclude diff files from long lines check
* cfg.mk: Add .diff files to the exclusion expression
for sc_long_lines, since the gnulib code might be >= 80 chars.
Note 80 char lines trigger due to the added +/- diff marks.
Also normalize the $$ used in the other sc_long_lines exclusion
expressions.
2015-02-11 03:58:31 +00:00
Pádraig Brady
50820f8470 maint: avoid arbitrary memory access with buggy localtime()
* src/ls.c (align_nstrftime): Be defensive and validate the tm_mon
index before using to access the abmon array.  This was _not_ seen
to be an issue any system.  See https://bugzilla.redhat.com/1190454
2015-02-11 00:35:08 +00:00
Pádraig Brady
430bda3733 doc: give an example of using a seed for random operations
* doc/coreutils.texi (Random sources):  Give an example using openssl,
generating a reproducible arbitrary amount of randomly distributed
data, given a seed value.
2015-02-11 00:31:39 +00:00
Bernhard Voelker
99f76aec8a maint: make sc_dd_O_FLAGS more robust
The construct "diff ... || diff=1 || diff=" does not set the variable
in all cases.  This could be triggered with:

  $ env make diff=1 make sc_dd_O_FLAGS
  dd_O_FLAGS
  maint.mk: ./src/dd.c has inconsistent O_ flag lists
  cfg.mk:59: recipe for target 'sc_dd_O_FLAGS' failed
  make: *** [sc_dd_O_FLAGS] Error 1

* cfg.mk (sc_dd_O_FLAGS): Remember $? of the diff command directly
and check its value later rather than using the  above mentioned
mapping.
2015-02-09 10:42:10 +01:00
Bernhard Voelker
ebb71efc1e maint: make sc_THANKS_in_duplicates more robust
The previous commit v8.23-124-g7b1ca5f made the above syntax-check rule
fail, because that took the whole content of THANKS.in for comparison.

* cfg.mk (sc_THANKS_in_duplicates): Strip off the header (all before the
first empty line) and the footer (all past the next empty line) from
'THANKS.in' for the check.
2015-02-09 10:42:04 +01:00
Bernhard Voelker
7b1ca5ffd6 maint: sort contributors in THANKS.in
* THANKS.in: Document the preferred sort order as a comment
at the top of the file.  Change "Марк Коренберг" to latin1
("Mark Korenberg").  Sort all entries.
* cfg.mk (sc_THANKS_in_sorted): Add rule to ensure that
'THANKS.in' remains sorted.
2015-02-09 02:42:40 +01:00
Pádraig Brady
0f7ca66bc5 maint: document a caveat in the tail inotify implementation
* src/tail.c (main): Document another caveat with the
inotify implementation wrt multiple hardlinked files.
2015-02-06 10:42:11 +00:00
Pádraig Brady
235d52c3ea tail: return inotify resources where possible
Each user has a maximum number of inotify watches,
so handle the cases where we exhaust these resources.

* src/tail.c (tail_forever_inotify): Ensure we inotify_rm_watch()
the watch for an inode, when replacing with a new watch for a name.
Return all used inotify resources when reverting to polling.
Revert to polling upon first indication of inotify resource exhaustion.
Revert to polling on any inotify resource exhaustion.
Diagnose resource exhaustion correctly in all cases.
Avoid redundant reinsertion in the hash for unchanged watches
(where only attributes of the file are changed).
* tests/tail-2/retry.sh: Avoid false failure when reverting to polling.
* tests/tail-2/inotify-rotate.sh: Likewise.
* tests/tail-2/symlink.sh: Likewise.
* tests/tail-2/inotify-rotate-resources.sh: New test to check
that we're calling inotify_rm_watch() for replaced files.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
* THANKS.in: Thanks for reporting and problem identification.
2015-02-06 10:41:06 +00:00
Pádraig Brady
81609dc1ea tests: fix recent regression in tail inotify test
* tests/tail-2/inotify-rotate.sh (cleanup_fail_): Set fail=1
so that failures are identified.  Regression in v8.23-63-g111a2b9
Also use print_ver_ rather than open coding --verbose support.
Also check for more than a single 'b' which seems brittle.
2015-02-06 09:48:13 +00:00
Yury Usishchev
1d0f1b7ce1 build: ensure make-prime-list doesn't access out of bounds memory
The -fsanitize=address run associated with v8.22-75-gf940fec
failed to check make-prime-list, as src/primes.h is not
regenerated with `make clean`.  Running with -fsanitize=address
indicates a read 1 byte beyond the allocated buffer.

  $ rm src/make-prime-list.o
  $ make AM_CFLAGS=-fsanitize=address src/make-prime-list
  $ src/make-prime-list 5000

=================================================================
==13913==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x61e00000fa43 at pc 0x4016f5 bp 0x7fff9d9840e0 sp 0x7fff9d9840d0
READ of size 1 at 0x61e00000fa43 thread T0
    #0 0x4016f4 in main src/make-prime-list.c:214
    #1 0x7f98892c5fdf in __libc_start_main (/lib64/libc.so.6+0x1ffdf)
    #2 0x401774 (src/make-prime-list+0x401774)

0x61e00000fa43 is located 0 bytes to the right of 2499-byte
region [0x61e00000f080,0x61e00000fa43) allocated by thread T0 here:
    #0 0x7f98896ba7b7 in malloc (/lib64/libasan.so.1+0x577b7)
    #1 0x400f3f in xalloc src/make-prime-list.c:163
    #2 0x400f3f in main src/make-prime-list.c:198

SUMMARY: AddressSanitizer: heap-buffer-overflow
src/make-prime-list.c:214 main
Shadow bytes around the buggy address:
  0x0c3c7fff9ef0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c3c7fff9f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c3c7fff9f10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c3c7fff9f20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c3c7fff9f30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c3c7fff9f40: 00 00 00 00 00 00 00 00[03]fa fa fa fa fa fa fa
  0x0c3c7fff9f50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c3c7fff9f60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c3c7fff9f70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c3c7fff9f80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c3c7fff9f90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:     fa
  ...
==13913==ABORTING

* src/make-prime-list.c (main): Bounds check the incremented index,
before using to access the buffer.
Fixes http://bugs.gnu.org/19784
2015-02-05 23:22:46 +00:00
Pádraig Brady
658529a10e build: fix invalid gnulib patch
* gl/lib/tempname.c.diff: Fix recent breakage so it applies again.
Invalid patch was noticed at http://hydra.nixos.org/eval/1172233
* cfg.mk: Exempt diff files from these "id_est" syntax checks.
(sc_ensure_gl_diffs_apply): A new syntax check, to ensure all
patches under gl/ apply cleanly.  Note we use --fuzz=0 to check
patches apply cleanly for safety, due to the patch(1) issue detailed
in commit v8.21-117-g46f7e05
* gl/lib/regcomp.c.diff: Rediffed.
* gl/lib/regex_internal.c.diff: Likewise.
* gl/lib/regex_internal.h.diff: Likewise.
* gl/lib/regexec.c.diff: Likewise.
* gl/lib/tempname.h.diff: Likewise.
2015-02-03 10:18:28 +00:00
Bernhard Voelker
bfb4f5c8b7 tests: avoid a FP on aarch64 when comparing env/printenv output
The following test fails on aarch64 on openSUSE's OpenBuildService
due to glibc's execvp reversing the pointers of 'environ', i.e.,
the output of "env|tac" equals "env env" on that platform.

* tests/misc/printenv.sh: Use 'env env' to work around the behavior
on that platform.
While at it, fix the grep pattern which suppressed all environment
variables starting with an underscore "_" instead of "$_" (and
"$LD_PRELOAD") only.
2015-02-03 02:19:54 +01:00
Pádraig Brady
b3ecf3b1b2 dircolors: sync with Xiph file extensions
* src/dircolors.hin: Remove deprecated anx, axa, axv.  Add opus.
Suggested by Scott Teal.
2015-02-02 17:09:13 +00:00
Bernhard Voelker
a5c8cdff03 doc,maint: fix use of "i.e." in documentation and comments
To align with all other places (and correct grammar), change all
upper-case "I.E." to "I.e.".  Furthermore, ensure that "i.e." is
followed by a comma.  Finally, ensure to use a double-space before
"I.e.," at the beginning of a sentence.

The following was used to change all offending uses (apart from
old ChangeLog files):

  $ git grep -liF 'i.e.' \
      | xargs sed -i \
            -e 's/I\.E\./I.e./g' \
            -e 's/\. \(I\.e\.\)/.  \1/g' \
            -e 's/\([Ii]\.e\.\)\( \)/\1,\2/g' \
            -e 's/\([Ii]\.e\.\)$/\1,/g'

* cfg.mk (sc_prohibit_uppercase_id_est): Add new rule.
(sc_ensure_double_space_after_dot_before_id_est): Likewise.
(sc_ensure_comma_after_id_est): Likewise.
(old_NEWS_hash): Refresh hash via "make update-NEWS-hash".
* NEWS: Change use of "id est" abbreviation via the above command.
* README: Likewise.
* README-prereq: Likewise.
* doc/coreutils.texi: Likewise.
* gl/lib/rand-isaac.c: Likewise.
* gl/lib/tempname.c.diff: Likewise.
* man/stdbuf.x: Likewise.
* src/cat.c: Likewise.
* src/copy.c: Likewise.
* src/copy.h: Likewise.
* src/cp.c: Likewise.
* src/cut.c: Likewise.
* src/dd.c: Likewise.
* src/df.c: Likewise.
* src/fiemap.h: Likewise.
* src/longlong.h: Likewise.
* src/ls.c: Likewise.
* src/numfmt.c: Likewise.
* src/pr.c: Likewise.
* src/shred.c: Likewise.
* src/shuf.c: Likewise.
* src/split.c: Likewise.
* tests/Coreutils.pm: Likewise.
* tests/df/df-symlink.sh: Likewise.
* tests/df/skip-rootfs.sh: Likewise.
* tests/init.sh: Likewise.
* tests/ls/color-norm.sh: Likewise.
* tests/misc/basename.pl: Likewise.
* tests/misc/ls-misc.pl: Likewise.
* tests/misc/md5sum-bsd.sh: Likewise.
* tests/misc/shred-exact.sh: Likewise.
* tests/misc/sort.pl: Likewise.
* tests/misc/stdbuf.sh: Likewise.
* tests/misc/tac-continue.sh: Likewise.
* tests/rm/r-root.sh: Likewise.
* tests/tail-2/symlink.sh: Likewise.
2015-01-31 17:39:04 +01:00
Pádraig Brady
ecc8f81048 doc: clarify the output format for the *sum utilities
* src/md5sum.c (usage): Detail the reasons for the default
double space between checksum and file name.
* doc/coreutils.texi (md5sum invocation): Likewise.
Explicitly mention the 3 formats that --check supports.

Fixes http://bugs.gnu.org/19725
2015-01-29 19:06:57 +00:00
Giuseppe Scrivano
8b2bf5295f sync: support syncing specified arguments
* m4/jm-macros.m4 (coreutils_MACROS): Check for syncfs().
* man/sync.x: Add references to syncfs, fsync and fdatasync.
* doc/coreutils.texi (sync invocation): Document the new feature.
* src/sync.c: Include "quote.h".
(AUTHORS): Include myself.
(MODE_FILE, MODE_DATA, MODE_FILE_SYSTEM, MODE_SYNC): New enum values.
(long_options): Define.
(sync_arg): New function.
(usage): Describe that arguments are now accepted.
(main): Add arguments parsing and add support for fsync(2),
fdatasync(2) and syncfs(2).
* tests/misc/sync.sh: New (and only) test for sync.
* tests/local.mk: Reference the new test.
* AUTHORS: Add myself to sync's authors.
* NEWS: Mention the new feature.
2015-01-28 10:50:45 +00:00
Jim Meyering
44074d8f77 scripts: autotools-install: update
* scripts/autotools-install: Increase automake's version number
to 1.15 and add Stefano Lattarini's new GPG key ID.
Increase gettext's version to 0.19.4 and add Daiki Ueno's GPG key ID.
Also move VERSION definition "up" so that it is once again
automatically updated via the emacs hook snippet at the end
of the file.
2015-01-25 07:47:13 -08:00
Pádraig Brady
564f84a91a stty: only print supported options for combined options
* src/stty.c (usage): Don't reference unsupported options,
in the combined options descriptions.
* doc/coreutils.texi (stty invocation): Adjust for the
new order of the 'sane' and 'raw' combined options.
Also add -iutf8 to the 'sane' list.
2015-01-24 01:07:00 +00:00
Pádraig Brady
c6a722946d stty: document the 'status' character where supported
* src/stty.c (usage): On systems that support this setting (BSD),
display 'status' in the list of adjustable special characters.
* doc/coreutils.texi (stty invocation): Mention the option, and that
it's not currently supported on Linux.
2015-01-24 01:07:00 +00:00
Pádraig Brady
81e5b59d8c stty: document the 'discard' character setting
The equivalent of this is 'flush', but that was never documented
as an option (though was output with stty -a).  Therefore use
the more descriptive name, also generally used on BSD systems.
Note even though this setting seems ineffective on Linux, supporting
the setting is useful to allow terminal programs to receive
the default ^O character code.

* doc/coreutils.texi (stty invocation): Document the 'discard' option.
* src/stty.c (struct control_info): Add 'discard'; same as 'flush'.
(display_all): Show 'discard' rather than 'flush' char.
(display_changed): Likewise.
(usage): Document the 'discard' option.
2015-01-24 01:06:59 +00:00
Pádraig Brady
ed38d9d1ce stty: add support for extproc/LINEMODE
Add support for the "extproc" option which is well described at:
http://lists.gnu.org/archive/html/bug-readline/2011-01/msg00004.html

* src/stty.c (usage): Describe the extproc option if either the
Linux EXTPROC local option is defined, or the equivalent
BSD TIOCEXT ioctl is defined.
(main): Make the separate ioctl call for extproc on BSD.
* doc/coreutils.texi (stty invocation): Describe the option,
and reference the related RFC 1116.
* NEWS: Mention the new feature.
2015-01-24 01:06:59 +00:00
Bernhard Voelker
cdd21d31a3 tests: use returns_ function for new split test
* tests/split/record-sep.sh: Use the recently added returns_ function
to simplify the shell syntax in this test.  Also remove the redirection
of stdout/stderr to /dev/null as this eases analyzing errors.
2015-01-20 01:54:55 +01:00
Assaf Gordon
4c795d5439 split: new -t option to select record separator
* src/split.c (eolchar): A new variable to hold
the separator character (unibyte for now).
This is reference throughout rather than hardcoding '\n'.
(usage): Describe the new --separator option, and
mention records along with lines so there is no ambiguity
that all options treat lines and records equivalently.
(main): Have -t update eolchar, or default to '\n'.
* tests/split/record-sep.sh: New test case.
* tests/local.mk: Reference the new test.
* doc/coreutils.texi (split invocation): Document the new option.
Adjust --lines, --line-bytes, --number=[lr]/... to mention
they pertain to records if --separator is specified.
* NEWS: Mention the new feature.
2015-01-19 23:22:37 +00:00
Pádraig Brady
c4c2a09cc8 maint: fix typo in THANKS.in in previous commit
* THANKS.in: s/Stehpen/Stephen/
2015-01-19 23:18:46 +00:00
Pádraig Brady
4c77bd23e8 doc: clarify that du operands are interdependent
Following on from http://bugs.gnu.org/17546
make it more obvious that du may elide specified operands
to avoid double counting in the set.

* src/du.c (usage): Specify that du operates on the set of
operands, rather than each independently.
* doc/coreutils.texi (du invocation): Likewise.  Also state
that the number of entries printed may change due to the
order specified.  Currently, deeper items specified earlier
will result in them being displayed, but don't mention that
implementation detail in the documentation.
* THANKS.in: Add reporter.
Reported by Stephen Shirley
2015-01-19 11:10:02 +00:00
Bernhard Voelker
e84046dbe6 tests: use compare-vs-/dev/null instead of 'test -s'
When some program produces unexpected output, that use of
compare-vs-/dev/null will ensure that the surprising output is
printed in the test's output.  With "test -s err" only, one
would have to instrument and rerun in order to see the offending
output.

* cfg.mk (sc_prohibit_and_fail_1): Exempt 'compare' from this check.
* tests/dd/misc.sh: Change "tests -s ... || fail=1" to
"compare /dev/null ... && fail=1".
* tests/misc/nice.sh: Likewise.
* tests/rm/read-only.sh: Likewise.
* tests/tail-2/inotify-race.sh: Likewise.
* tests/touch/no-dereference.sh: Likewise.

Suggested by Jim Meyering in
http://lists.gnu.org/archive/html/coreutils/2015-01/msg00042.html
2015-01-14 17:38:12 +01:00
Pádraig Brady
58cff8a009 tests: add extra protection against unexpected exits
Many tests use `program ... && fail=1` to ensure expected
error situations are indicated.  However that would mask
an unexpected exit (like a crash).  Therefore explicitly
check the expected exit code.
Note where error messages are also verified, the extra
protection is not added.

* tests/init.sh (returns_): A new helper function to
check the return code of a command, and used
throughout the tests.
* cfg.mk (sc_prohibit_and_fail_1): Add a syntax check
to avoid new instances of this issue.
2015-01-14 12:20:32 +00:00
Pádraig Brady
924b1cadff tests: avoid skipping some df tests with libmount
* tests/df/no-mtab-status.sh: Provide libmount placeholders,
to avoid skipping the test when libmount is in use.
* tests/df/skip-duplicates.sh: Likewise.
* tests/df/skip-rootfs.sh: Comment that the test is moot
when libmount (/proc/self/mountinfo) is being used.
2015-01-12 01:24:29 +00:00
Pádraig Brady
eef0cd62dd maint: clean up some test issues identified with shellcheck
* tests/cp/cp-a-selinux.sh: Comment why unused variables are assigned.
Fix misspellings noticed while adjusting.
* tests/cp/fiemap-perf.sh: Fix quoting.
* tests/misc/shuf.sh: Avoid useless use of cat.
* tests/misc/printf-surprise.sh: Likewise.
2015-01-10 21:18:33 +00:00
Daiki Ueno
fb13cdc727 maint: adjustments related to previous shuf crash fix
* tests/misc/shuf.sh: Improve the test so it detects
crashes in more cases.
* NEWS: Mention the previous fix.
2015-01-08 14:16:01 +00:00
Assaf Gordon
ff97b62fe3 maint: skip long-lines syntax-check if unsupported
* cfg.mk(sc_long_lines): Skip if required wc and sed options
are not supported, which is currently the case on OS X.
2015-01-08 12:42:29 +00:00
Paul Eggert
63bc65fbe7 shuf: do not mishandle 'shuf -i0-0 1'
Problem reported by Daiki Ueno in: http://bugs.gnu.org/19520
* src/shuf.c (main): Avoid core dump if !input_range.
* tests/misc/shuf.sh: Test for this bug.
2015-01-05 19:40:21 -08:00
Bernhard Voelker
7f235156bc maint: update further copyright year number ranges
* bootstrap: Update copyright year manually (missing in previous
gnulib update).
* tests/init.sh: Likewise.

The entries in the exemption list are processed by
"grep -vEf ./.x-update-copyright", and therefore evaluated as an
extended regular expression (ERE).  Thus, the "bootstrap" entry
also matched for bootstrap.conf which we want to be updated.

* .x-update-copyright: Change all entries to EREs, i.e. including
the caret ^ and dollar sign $ meta-characters matching the beginning
and the end of a line.
* bootstrap.conf: Update copyright year by "make update-copyright".

Finally, the only one showing up with the following command should
be the COPYING file:
  $ git grep 'Copyright .* Free Software' | grep -v '2015 Free Software'
2015-01-01 19:56:25 +01:00
Pádraig Brady
272aa7cad6 doc: fix man page formatting for split CHUNKS options
* src/split.c (usage): Indent the info on CHUNKS so that
help2man can match it and align appropriately in its own section.
Fixes http://bugs.gnu.org/19228
2015-01-01 18:12:29 +00:00
Pádraig Brady
8c819693a5 build: update to latest gnulib
Pick up an errno adjustment in xstrtol() that fixes
a spurious test failure on Darwin 14.0.0.
Also update copyright year to 2015 avoiding a syntax-check failure.
2015-01-01 05:04:34 +00:00
Pádraig Brady
e0afeb0099 maint: update all copyright year number ranges
Run "make update-copyright" and then...

* tests/sample-test: Adjust to use the single most recent year.
* tests/du/bind-mount-dir-cycle-v2.sh: Fix case in copyright message,
so that year is updated automatically in future.
2015-01-01 04:52:17 +00:00
Pádraig Brady
1269bf5857 tests: fix possible 8 minute running time of inotify-rotate.sh
Commit v8.23-63-g111a2b9 removed the expensive tag on this test,
as it runs quickly on systems with inotify.  However without that
it would take about 8 minutes for the test to complete all iterations.

* tests/tail-2/inotify-rotate.sh: Tag as expensive without inotify.
Also adjust the polling parameters used on systems without inotify
so that the test completes within about 15 seconds.
2014-12-30 02:43:18 +00:00
Pádraig Brady
974c355c59 build: update to latest gnulib
Included in this are gnulib changes 3ea43e02 2768ceb7
which make the device IDs from /proc/self/mountinfo
available to df.  This can be leveraged by a subsequent
change to df to present a more accurate list of file systems.

* bootstrap: Merge from gnulib.
* src/ls.c (dev_ino_pop): s/obstack_blank/obstack_blank_fast/
as this API/ABI has changed, giving memory exhausted errors
if negative (large positive) numbers are passed to obstack_blank().
* tests/df/skip-duplicates.sh: Adjust as the new gnulib code
requires a non NULL mnt_opts even when mnt_type is not "none".
2014-12-30 02:21:47 +00:00
Pádraig Brady
fe14d42ec9 maint: remove duplicate names from THANKS
* .mailmap: Adjust so that there is only a single
entry per name in the generated THANKS.
2014-12-29 23:20:16 +00:00
Pádraig Brady
4111d3e4e0 doc: update the URL referencing SI prefixes
Identified at https://www.gnu.org/software/gnun/linc/linc.html

* doc/coreutils.texi (Block size): Fix the stale link.
2014-12-26 14:44:44 +00:00
Pádraig Brady
3b7c9d1a31 tests: fix error message check on some systems
http://hydra.nixos.org/build/18129583 identified (on OS X)
an incorrect test assumption in the previous commit.

* gl/lib/xdectoint.c (__xnumtoint): Suppress the EINVAL
error message as it's redundant in this context.
* tests/misc/tail.pl: Suppress _optionally_ appended
strerror messages.
* tests/fmt/base.pl: Likewise.
* tests/pr/pr-tests.pl: Likewise.
* tests/split/l-chunk.sh: Likewise.
2014-12-25 02:30:05 +00:00
Pádraig Brady
6894816c65 diagnose too-large numbers better
Following on from commit v8.23-82-gaddae94, consistently diagnose
numbers that are too large, so as to distinguish from other errors,
and make the limits obvious.

* gl/modules/xdectoint: A new module implementing xdecto[iu]max(),
which handles the common case of parsing a bounded integer and
exiting with a diagnostic on error.
* gl/lib/xdectoimax.c: The signed variant.
* gl/lib/xdectoint.c: The parameterized implementation.
* gl/lib/xdectoint.h: The interface.
* gl/lib/xdectoumax.c: The unsigned variant.
* bootstrap.conf: Reference the new module.
* cfg.mk (exclude_file_name_regexp--sc_require_config_h_first):
Exclude the parameterized templates.
* src/csplit.c: Output EOVERFLOW or ERANGE errors if appropriate.
* src/fmt.c: Likewise.
* src/fold.c: Likewise.
* src/head.c: Likewise.
* src/ls.c: Likewise.
* src/nl.c: Likewise.
* src/nproc.c: Likewise.
* src/shred.c: Likewise.
* src/shuf.c: Likewise.
* src/stdbuf.c: Likewise.
* src/stty.c: Likewise.
* src/tail.c: Likewise.
* src/truncate.c: Likewise.
* src/split.c: Likewise.
* src/pr.c: Likewise.
* tests/pr/pr-tests.pl: Adjust to avoid matching errno diagnostic.
* tests/fmt/base.pl: Likewise.
* tests/split/l-chunk.sh: Likewise.
* tests/misc/shred-negative.sh: Likewise.
* tests/misc/tail.pl: Likewise.  Also remove the redundant
existing ERR_SUBST from test err-6.
* tests/ls/hex-option.sh: Check HEX/OCT options.
* tests/misc/shred-size.sh: Likewise.
* tests/misc/stty-row-col.sh: Likewise.
2014-12-19 11:56:20 +00:00
KO Myung-Hun
178f8e79dc build: add $(EXEEXT) suffix to man page make targets
* man/local.mk: Add $(EXEEXT) suffix to the executables,
which is significant on OS/2 for example.
2014-12-19 02:04:18 +00:00
KO Myung-Hun
70d8d0f874 build: don't call OS/2 routines on all systems
* src/system.h: Add a missing __OS2__ ifdef guard.
Also adjust spacing around () to avoid a syntax-check failure.
2014-12-19 01:57:21 +00:00
KO Myung-Hun
92519ce058 build: expand a response file and a wildcard on OS/2
OS/2 traditional shells(cmd) do not expand a response file(@file)
or a wildcard.  Expand them in each utility itself.

* src/system.h (initialize_main): Define on OS/2. Expand a response
file and a wildcard.
2014-12-18 07:21:21 -08:00
Bernhard Voelker
8799c82d81 maint: fix how to request changes for THANKS.in
* THANKS.in: Change the comment at the top to send change requests
regarding this file to the main mailing list rather than referring
to cp's --help output for the mailing list's address - which does
not include that information anymore.
2014-12-16 10:42:54 +01:00
Paul Eggert
baff828afa dd: fix typo in previous change
Reported by Bernhard Voelker in:
http://lists.gnu.org/archive/html/bug-gnulib/2014-12/msg00191.html
* src/dd.c (scanargs): s/IN/OUT/.
2014-12-16 00:41:22 -08:00
Paul Eggert
addae94b3b dd: diagnose too-large numbers better
Reported by Isabella Parakiss in:
http://lists.gnu.org/archive/html/bug-gnulib/2014-12/msg00184.html
* src/dd.c (parse_integer): Return strtol_error code, not bool.
All callers changed.
(scanargs): Improve quality of diagnostic when a number is too large.
2014-12-15 23:44:17 -08:00
Pádraig Brady
f57bfbb237 build: use the system printf routines in most cases
glibc <= 2.5 would crash when passed invalid long double values,
therefore internal gnulib routines were used, essentially only by od,
to output such invalid values.  Later glibc versions don't crash,
as per https://sourceware.org/bugzilla/show_bug.cgi?id=4586
and subsequently od was adjusted to use the system printf routines
through the use of the ftoastr module with commit v8.7-22-ga71c22f.
Consequently our testing of this feature was moot, and use of
the gnulib printf replacement for printf(1), od(1) and error(3) etc.
was redundant.

* configure.ac (gl_printf_safe): Unset so that we don't check that
"nan" is output for these long double values.
* tests/misc/od-float.sh: Adjust all existing checks to fail if od
exits with failure status (like crashing for example).  Add a new case
for one of the problematic invalid long double values for x86_64.
We only check that od exits successfully at present, which may change
if https://sourceware.org/bugzilla/show_bug.cgi?id=17661 is resolved.
2014-12-10 17:45:50 +00:00
Pádraig Brady
5760532a2d maint: avoid -fsanitize=undefined warning in rand-isaac
* gl/lib/rand-isaac.c (isaac_refill): readisaac() purposefully passes
unaligned pointers to avoid memory copies.  This is only done on
platforms where this is defined, so avoid the associated
runtime warning generated with -fsanitize=undefined, which is:

  lib/rand-isaac.c:125:182: runtime error: store to misaligned address
  0x63100003d7fd for type 'isaac_word', which requires 8 byte alignment
  0x63100003d7fd: note: pointer points here
   47 ce ed a4 be be be  00 00 00 00 00 00 00 00  ...
               ^
2014-12-03 23:38:36 +00:00
Pádraig Brady
a6d9792997 maint: avoid signed overflow warning with -O3
Prompted by the implicit -O3 added by american-fuzzy-lop,
seen with GCC 4.9.2 on x86_64.

  src/pr.c: In function 'print_files.part.5':
  src/pr.c:1781:6: error: assuming signed overflow does not occur
  when simplifying conditional to constant [-Werror=strict-overflow]
     if (cols_ready_to_print () == 0)

This happens because cols_ready_to_print() is inlined
thus reducing the comparison to the N variable in print_page().
Now this can't overflow due to the protection when parsing the
specified column, but use an unsigned type to avoid the
apparent signed overflow.

* src/pr.c (cols_ready_to_print): Increment an unsigned type to
avoid the subsequent signed overflow warning.
2014-12-02 01:20:39 +00:00
Boris Ranto
dc1c0523a6 du: handle sub-bind-mount cycles gracefully
This patch fixes the handling of sub-bind-mount cycles which are
incorrectly detected as the file system errors.  If you bind mount the
directory 'a' to its subdirectory 'a/b/c' and then run 'du a/b' you
will get the circular dependency warning even though nothing is wrong
with the file system.  This happens because the first directory that is
traversed twice in this case is not a bind mount but a child of bind
mount.  The solution is to traverse all the directories in the cycle
that fts detected and check whether they are not a (bind) mount.

* src/du.c (mount_point_in_fts_cycle): New function that checks whether
any of the directories in the cycle that fts detected is a mount point.
* src/du.c (process_file): Update the function to use the new function
that looks up all the directories in the fts cycle instead of only the
last one.
* tests/du/bind-mount-dir-cycle-v2.sh: New test case that exhibits the
described behavior.
* tests/local.mk: Reference the new root test.
* NEWS: Mention the bug fix.
2014-12-02 01:01:35 +00:00
Pádraig Brady
6f16c63963 tests: avoid hardlink to symlink tests where not supported
These checks weren't correctly avoided in commit v8.23-66-g222d7ac

* tests/cp/same-file.sh: Avoid all hardlink to symlink tests
on platforms where that's not supported.
Identified by http://hydra.nixos.org/build/17636446
2014-11-29 22:45:55 +00:00
Pádraig Brady
458c5cbcff build: fix missing casts from recent change
* src/dd.c (alloc_[io]buf): I committed a stale patch that omitted
the casts needed on 32 bit.
Identified by http://hydra.nixos.org/build/17610188
2014-11-28 10:25:22 +00:00
Pádraig Brady
7d1fe8868e rm: fix prompted number of arguments to remove on some platforms
"zu" was output on solaris 8 for example rather than the number,
since coreutils-8.22.

* cfg.mk: Disallow %z, since we don't currently use the gnulib
fprintf module, so any usage with it is non portable.  Also
our usage with error() currently works only through an ancillary
dependency on the vfprintf gnulib module.
* src/rm.c (main): Use %PRIuMAX rather than %zu for portability.
* src/dd.c (alloc_[io]buf): Likewise for consistency.
* src/od.c (main): Likewise.
* src/split.c (set_suffix_length): Likewise.
* NEWS: Mention the rm bug fix.
Reported in http://bugs.gnu.org/19184
2014-11-27 14:25:00 +00:00
Pádraig Brady
a78d85386b tests: fix portability issue in dd/ascii test
Solaris 8 was seen to issue this error:
"printf: `&': illegal format character"

* test/dd/ascii.sh: Use the coreutils printf in this test
rather than the system one, to avoid portability issues.
2014-11-26 20:16:43 +00:00
Paul Eggert
d07d9f2434 build: port new rule for coreutils.h to old Bash
Reported by Ted Carr in: http://bugs.gnu.org/19184
* src/local.mk (src/coreutils.h):
Don't assume single_binary_progs is nonempty.
2014-11-25 21:16:48 -08:00
Tobias Stoeckmann
16e2347bd5 paste: fix possible truncated output with large files
If '\n' was present at the size_t boundary of a file,
then that and subsequent data would be discarded.

* src/paste.c (paste_parallel): Avoid the overflow issue
by changing the flag to a boolean rather than a count.
* NEWS: Mention the bug fix.
2014-11-24 09:31:49 +00:00
Pádraig Brady
2e81e62243 df: only suppress remote mounts of separate exports with --total
* src/df.c (filter_mount_list): Separate remote locations are
generally explicitly mounted, so list each even if they share
the same remote device and thus storage.  However with --total
keep the suppression to give a more accurate value for the
total storage available.
(usage): Expand on the new implications of --total and move
it in the options list according to alphabetic order.
doc/coreutils.texi (df invocation): Mention that --total impacts
on deduplication of remote file systems and also move location
according to alphabetic order.
* tests/df/skip-duplicates.sh: Add remote test cases.
* NEWS: Mention the change in behavior.

Reported in http://bugs.debian.org/737399
Reported in http://bugzilla.redhat.com/920806
Reported in http://bugzilla.opensuse.org/866010
Reported in http://bugzilla.opensuse.org/901905
2014-11-24 09:04:54 +00:00
Pádraig Brady
3ab3c7bb24 df: ensure -a shows all remote file system entries
commit v8.22-125-g9d736f8 printed placeholder "-" values
for device names that didn't match the preferred device name
for a particular mount point.  However that was seen to erroneously
suppress values for aliased host names or exports, common with
remote file systems.

* src/df.c (me_for_dev): Rename from devname_for_dev() so that
we can determine the remoteness as well as the name for the
preferred mount entry.
(get_dev): Don't output place holder values when both
current and preferred mount entries are remote.

Reported in http://bugs.debian.org/737399
2014-11-23 19:46:38 +00:00
Pádraig Brady
a78819af28 tests: add a case verifying mv on case insensitive file systems
* NEWS: Update the recent entry to also mention the avoidance
of incorrectly unlinking a multi-hardlinked "source" file when
presented with source and dest that only differ in case.
* src/copy.c (same_file_ok): Mention the case issue with same_name().
* tests/mv/hardlink-case.sh: Test the issue on HFS+.
* tests/local.mk: Reference the new test case.
* tests/mv/vfat: Remove an old related but unused test case.
2014-11-22 03:46:34 +00:00
Pádraig Brady
57c8196ef6 doc: mention how to avoid newlines impacting ls -1
* src/ls.c (usage): Mention the -b and -q options
in the -1 description.
* doc/coreutils.texi (ls invocation): Likewise.
2014-11-21 16:25:42 +00:00
Pádraig Brady
0e942fdba6 tests: chcon: avoid false failure with newer selinux
file_t is now mapped to unlabeled_t as per:
http://danwalsh.livejournal.com/68189.html

Therefore use the latter to ensure we match correctly.
This is needed on >= Fedora 21 for example,
while it also works on earlier releases.
2014-11-21 15:30:13 +00:00
Boris Ranto
222d7ac0c4 mv: fail when moving a file to a hardlink
We may run into a race condition if we treat hard links to the same file
as distinct files.  If we do 'mv a b' and 'mv b a' in parallel, both a
and b can disappear from the file system.  The reason is that in this
case the unlink on src is called and the system calls can end up being
run in the order where unlink(a) and unlink(b) are the last two system
calls.  Therefore exit with an error code so that we avoid the potential
data loss.

* src/copy.c (same_file_ok): Don't set unlink_src that was used by mv,
and return false for two hardlinks to a file in move_mode.
*src/copy.c (copy_internal): No longer honor the unlink_src option,
used only by mv.
NEWS: Mention the change in behavior.
* tests/cp/same-file.sh: Augment to cover the `cp -a hlsl1 sl1` case.
* tests/mv/hard-verbose.sh: Remove no longer needed test.
* tests/local.mk: Remove the reference to hard-verbose.sh.
* tests/mv/hard-4.sh: Adjust so we fail in this case.
* tests/mv/i-4.sh: Likewise.
* tests/mv/symlink-onto-hardlink-to-self.sh: Likewise.
2014-11-21 02:48:45 +00:00
Pádraig Brady
f43c072a04 maint: run strftime syntax check on newer systems
* cfg.mk (sc_strftime_check): Adjust regex to handle
newer glibc info formatting with different indentation
and quoting.
2014-11-18 03:38:29 +00:00
Pádraig Brady
840da8a7c6 maint: tests: fix comments about retry_delay_
* tests/tail-2/F-vs-missing.sh: Comment with the correct total delay.
* tests/tail-2/F-vs-rename.shi: Likewise.
* tests/tail-2/flush-initial.sh: Likewise.
* tests/tail-2/inotify-hash-abuse.sh: Likewise.
* tests/tail-2/pipe-f2.sh: Likewise.
* tests/misc/chroot-fail.sh: Initialize can_chroot_root in all cases.
2014-10-30 00:06:11 +00:00
Pádraig Brady
111a2b91da tests: make inotify-rotate more robust and efficient
* tests/tail-2/inotify-rotate.sh: Use retry_delay_
to employ an exponential backoff with a total delay of
up to 25.5s.  The 15s delay was seen to trigger a false
failure in http://hydra.nixos.org/build/16546517
Also remove the .1s sleep in each of the 50 iterations
to reduce the running time of the test and thus the
expensive_ tag on this test was removed.
Also ensure that we use the standard exit procedure
upon failure to avoid any erroneous diagnostics due
to persistent files on NFS.
2014-10-30 00:06:11 +00:00
Bernhard Voelker
02e281e1b2 tests: make du/move-dir-while-traversing more robust
* tests/du/move-dir-while-traversing.sh: Catch failure of retry_delay_
when waiting for the watcher to get ready.
2014-10-29 23:22:57 +01:00
Pádraig Brady
097897bd2c doc: mention that df -a includes duplicate file systems
* src/df.c (usage): Mention that duplicate file systems are shown
with this option, not just dummy file systems.
* doc/coreutils.texi (df invocation): For the --all option, expand
on the class of normally suppressed mount entries that it includes.

Reported in http://bugs.debian.org/737399
2014-10-27 14:12:17 +00:00
Pádraig Brady
414a8cf52f maint: improve sc_long_lines syntax-check speed
sc_long_lines was the slowest syntax check

before$ time make sc_long_lines
        long_lines
        real    0m2.740s

after $ time make sc_long_lines
        long_lines
        real    0m0.677s

* src/cfg.mk (sc_dd_max_sym_length): s/--max-line-length/-L/
for compat with BSDs.
(sc_long_lines): Prefilter with wc -L to only identify lines
in files that have lines longer than 80 characters.
2014-10-23 11:29:05 +01:00
Mike Frysinger
193560790c tests: d_type-check: don't hardcode the C library name
* tests/d_type-check: The hardcoded name doesn't hold true for all
Linux/glibc platforms, let alone Linux/non-glibc.
Use ctypes.util.find_library() instead to search for the library.
2014-10-23 03:30:23 +01:00
Bernhard Voelker
f1466d180b tests: avoid false failure when comparing /proc files
At least the MHz number in /proc/cpuinfo may change, thus leading to
a false positive failure when comparing the expected against the
actual output file.  Use an invariant file instead: /proc/version.

* tests/misc/head-c.sh: s/cpuinfo/version/
2014-10-17 08:02:57 +02:00
Pádraig Brady
437f247649 tests: fix test hang with unstable inodes in /proc
* cp/proc-zero-len.sh: Search the 'err' file
for the error to ignore, not stdin.
2014-10-16 10:42:17 +01:00
Pádraig Brady
d520929586 chroot: call chroot() unconditionally to handle bind mounted "/"
* src/chroot.c (is_root): Adjust to compare canonicalized paths
rather than inodes, to handle (return false in) the case where
we have a tree that is constructed by first bind mounting "/"
(thus having the same inode).
(main): Unconditionally call chroot() because it's safer
and of minimal performance benefit to avoid in this case.
This will cause inconsistency with some platforms
not allowing `chroot / true` for non root users.
* tests/misc/chroot-fail.sh: Adjust appropriately.
* NEWS: Mention the bug fixes.
Fixes http://bugs.gnu.org/18736
2014-10-16 00:45:32 +01:00
Pádraig Brady
84616da89d copy: avoid an extraneous error when reporting errors
* src/copy.c (copy_reg): If sparse_copy() failed, then an
erroneous error about failing to extend the file would be reported.
2014-10-15 02:19:48 +01:00
Pádraig Brady
cce161dc05 cp: read sparse files more efficiently with non regular destination
* src.copy.c (copy_reg): Use fiemap to read sparse files, even
if the output is not to a regular file.
* NEWS: Mention the improvement.
2014-10-15 02:19:48 +01:00
Pádraig Brady
eafa6ebf10 cp: avoid speculative preallocation with --sparse=always
With --sparse=always use fallocate(...PUNCH_HOLE...) to
avoid any permanent allocation due to speculative
preallocation employed by file systems such as XFS.

* m4/jm-macros.m4: Check for <linux/falloc.h> and fallocate().
* src/copy.c (punch_hole): A new function to try and punch
a hole at the specified offset if supported.
(create_hole): Call punch_hole() after requesting a hole.
(extent_copy): Likewise.
* NEWS: Mention the improvement.
2014-10-15 02:19:37 +01:00
Pádraig Brady
759b0ac9e7 copy: detect smaller holes than the copy buffer size
Previously cp would not detect runs of NULs that were
smaller than the buffer size used for I/O (currently 128KiB).

* src/copy.c (copy_reg): Use an independent hole_size, set to
st_blksize, to increase the chances of detecting a representable hole,
in a run of NULs read from the input.
(create_hole): A new function refactored from sparse_copy() and
extent_copy() so we have a single place to handle holes.
(sparse_copy): Adjust to loop over the larger input buffer
in chunks of the passed hole size.  Also adjust to only call
lseek once per hole, rather than at least once per input buffer.
* tests/cp/sparse.sh: Add test cases for various sparse chunk sizes.
* NEWS: Mention the improvement.
2014-10-15 02:19:16 +01:00
Wieland Hoffmann
cb4fc9356f doc: clarify that timeout limits are not 2038 seconds
* man/timeout.x: The 2038 that the sentence is referring to is the year
2038, not 2038 seconds (the default unit used for timeouts).
2014-10-09 19:44:48 +01:00
Pádraig Brady
16c7267d74 maint: avoid new signed overflow warning on 32 bit
Prompted by http://hydra.nixos.org/build/15682577
with GCC 4.8.3 on i686

  src/tac.c:557:6: error: assuming signed overflow does not occur
  when simplifying conditional to constant [-Werror=strict-overflow]
     if (bytes_copied < 0)

This happens because copy_to_temp() is inlined in tac_nonseekable(),
thus reducing the comparison to the bytes_copied variable in
copy_to_temp.  Now this can't overflow on either 32 or 64 bit
due to the protection of the preceding fwrite().  We could use a
guard like "if (bytes_copied <= OFF_T_MAX - bytes_read)" to avoid
the warning, but rather than a runtime branch, just use an unsigned
type to avoid apparent signed overflow on systems where the accumulation
is not promoted to unsigned (32 bit size_t, 64 bit off_t).

* src/tac.c (copy_to_temp): Increment an unsigned type to
avoid the subsequent signed overflow warning.
2014-10-08 12:48:51 +01:00
Jim Meyering
fcbbf1cdb8 tests: split/b-chunk.sh: avoid spurious fail on non-Linux
* tests/split/b-chunk.sh: Skip each file that does not exist.
Some systems lack /proc/version or /sys/kernel/profiling
2014-10-07 18:08:25 -07:00
Pádraig Brady
560dad02c3 maint: avoid syntax-check failures in previous patch
* tests/misc/od-j.sh: Non standard comparison order.
* tests/split/b-chunk.sh: Confusing input file name.
* tests/tail-2/tail-c.sh: Redundant require ulimit.
2014-10-08 01:14:57 +01:00
Paul Eggert
2662702b9e wc: don't miscount /sys and similar file systems
Fix similar problems in head, od, split, tac, and tail.
Reported by George Shuklin in: http://bugs.gnu.org/18621
* NEWS: Document this.
* src/head.c (elseek): Move up.
(elide_tail_bytes_pipe, elide_tail_lines_pipe): New arg
CURRENT_POS.  All uses changed.
(elide_tail_bytes_file, elide_tail_lines_file):
New arg ST and remove arg SIZE.  All uses changed.
* src/head.c (elide_tail_bytes_file):
* src/od.c (skip): Avoid optimization for /sys files, where
st_size is bogus and st_size == st_blksize.
Don't report error at EOF when not optimizing.
* src/head.c, src/od.c, src/tail.c: Include "stat-size.h".
* src/split.c (input_file_size): New function.
(bytes_split, lines_chunk_split, bytes_chunk_extract): New arg
INITIAL_READ.  All uses changed. Use it to double-check st_size.
* src/tac.c (tac_seekable): New arg FILE_POS.  All uses changed.
(copy_to_temp): Return size of temp file.  All uses changed.
* src/tac.c (tac_seekable):
* src/tail.c (tail_bytes):
* src/wc.c (wc):
Don't trust st_size; double-check by reading.
* src/wc.c (wc): New arg CURRENT_POS.  All uses changed.
* tests/local.mk (all_tests): Add tests/misc/wc-proc.sh,
tests/misc/od-j.sh, tests/tail-2/tail-c.sh.
* tests/misc/head-c.sh:
* tests/misc/tac-2-nonseekable.sh:
* tests/split/b-chunk.sh:
Add tests for problems with /proc and /sys files.
* tests/misc/od-j.sh, tests/misc/wc-proc.sh, tests/tail-2/tail-c.sh:
New files.
2014-10-07 16:47:37 -07:00
Bernhard Voelker
b020002b4b doc: document stat's output with the --terse option
* doc/coreutils.texi (stat invocation): Add a paragraph documenting
stat's output format when the --terse option is specified, both in
normal and in --file-system mode.

Reported by Dan Jacobson <jidanni@jidanni.org>
in http://bugs.gnu.org/18624
2014-10-04 17:12:58 +02:00
Nick Alcock
2d3ba46e58 tests: fix false failure for test referencing libdl
* init.cfg (gcc_shared_): -ldl has to be positioned after the object
files that may rely upon it.  This fixes tests/cp/nfs-removal-race.sh
which references dlsym() from libdl.
2014-10-02 16:35:09 +01:00
Bernhard Voelker
4f87ca916c maint: avoid double semicolon syntax check failure
A syntax-check recently added to gnulib would trigger a failure
(once gnulib gets updated here) for a statement introduced with
commit v8.23-43-gaf2a4ed:

  src/dd.c:806:  char const *time_fmt = _(", %g s, %s/s\n");;
  maint.mk: Double semicolon detected
  make: *** [sc_prohibit_double_semicolon] Error 1

* src/dd.c (print_xfer_stats): s/;;/;/
2014-10-02 02:34:48 +02:00
Federico Simoncelli
af2a4ed225 dd: new status=progress level to print stats periodically
* src/dd.c: Report the transfer progress every second when the
new status=progress level is used.  Adjust the handling and
description of the status= option so that they're treated as
mutually exclusive levels, rather than flags with implicit precedence.
* doc/coreutils.texi (dd invocation): Document the new progress
status level.  Reference the new level in the description of SIGUSR1.
* tests/dd/stats.sh: Add new test for status=progress.
* tests/dd/misc.sh: Change so status=none only takes precedence
if it's the last level specified.
* NEWS: Mention the feature.
2014-09-30 16:08:43 +01:00
Pádraig Brady
27d2c7383f dd: use more robust SIGUSR1 handling
* src/dd.c (ifd_reopen): A new wrapper to ensure we
don't exit upon receiving a SIGUSR1 in a blocking open()
on a fifo for example.
(iftruncate): Likewise for ftruncate().
(iread): Process signals also after a short read.
(install_signal_handlers): Install SIGINFO/SIGUSR1 handler
even if set to SIG_IGN, as this is what the parent can easily
set from a shell script that can send SIGUSR1 without the
possiblity of inadvertently killing the dd process.
* doc/coreutils.texi (dd invocation): Improve the example to
show robust usage wrt signal races and short reads.
* tests/dd/stats.sh: A new test for various signal races.
* tests/local.mk: Reference the new test.
* NEWS: Mention the fix.
2014-09-30 16:08:43 +01:00
Paul Eggert
4d8c4dfc21 test: check for Fedora 20 sort key bug
Problem reported by Göran Uddeborg in: http://bugs.gnu.org/18540
* tests/misc/sort.pl: New test 23.
2014-09-24 11:55:57 -07:00
David Sterba
b47231be68 mv: use reflink=auto mode by default
On some filesystems (BTRFS), moving a file within the filesystem may
cross subvolume boundaries and we can use a lightweight reflink copy,
similar to what cp(1) can do, which is faster than a full file copy.
This is enabled by default because it's only an optimization for
the fall back copy and does not break user expectations or usability.

* src/mv.c (cp_option_init): Set the reflink mode to AUTO.
* NEWS: Mention the improvement.
2014-09-24 11:48:22 +01:00
Pádraig Brady
1ff4d08892 stty: only list supported options in --help and man pages
* src/stty.c (usage): Exclude unsupported options from --help,
which for example impacts the "dsusp" and "cdtrdsr" options on Linux.
Fixes http://bugs.gnu.org/18506
2014-09-23 09:11:14 +01:00
Michal Nazarewicz
08a99aeb36 doc: fix use of "e.g." in stdbuf help message
"E.g." stands for latin "exempli gratia" which is typically read
as "for example".  "E.g." does not stand for the word "example".
As such, "for e.g." might be read as "for for example".

Fix this usage by simply replacing "e.g." with "example".
2014-09-23 09:08:34 +01:00
Bernhard Voelker
d2bcb04400 build: pass program name to help2man after other options
* man/local.mk (.x.1): Move the program name argument down after
the last option argument when calling $(run_help2man).
While the other way would be accepted for the GNU help2man program,
it is not for the 'dummy-man' script (called as a fallback on
systems lacking perl).
The wrong order was introduced in commit v8.21-119-gb3578fc while
adding the --info-page option.
2014-09-23 01:49:47 +02:00
Bernhard Voelker
bf2057b20b build: fix argument count check in dummy-man again
* man/dummy-man: Fix argument count check, now only permitting
exactly 1 argument, the program name.
Reported by Andreas Schwab <schwab@linux-m68k.org>
2014-09-23 01:44:51 +02:00
Alban Bedel
1f994f3014 build: fix an inverted test breaking dummy-man
* man/dummy-man: Fix argument count check,
allowing dummy-man to run (on systems without perl).
Fixes http://bugs.gnu.org/18531
2014-09-22 19:37:52 +01:00
Pádraig Brady
f51c44bd1e build: fix dependency issues with man page generation
* .gitignore: Remove reference to no longer generated make file.
* configure.ac: Don't bother generating placeholder make file.
* man/local.mk: Hardcode the man page deps list for normal builds
to be compatible with all make implementations and configure options.
Note in SINGLE_BINARY mode, all man pages will be generated on
any change to the coreutils binary, but development will generally
not be done in this mode, so this shouldn't be an issue.

Fixes http://bugs.gnu.org/18055
2014-09-19 23:18:10 +01:00
Jim Meyering
5682a7e73d maint: don't trigger gcc-5's new -Wlogical-not-parentheses warning
* src/dircolors.c (main): Parenthesize !VAR as LHS to "<",
to avoid triggering gcc's new -Wlogical-not-parentheses warning.
2014-09-19 13:02:49 -07:00
Pádraig Brady
756a928c8c cp: fix handling of -H with multiply specified source dirs
Following on from commit v5.92-729-g130dd06, also avoid
the erroneous directory hardlink warning with -H.

* src/copy.c (copy_internal): Also handle the -H case
for command line arguments.
* tests/cp/duplicate-sources.sh: Augment the test case.
* NEWS: Augment the news entry.
2014-09-19 11:25:23 +01:00
Pádraig Brady
90aa291c39 cp: issue correct warning and ignore duplicate source dirs
* src/copy.c (copy_internal): Handle the case where we have the
same destination directory as already encountered, which can only
be due to the corresponding source directory being specified multiple
times.
* tests/cp/duplicate-sources.sh: Add a test for the new multiply
specified directory case, and the existing multiply specified file case.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
2014-09-19 11:25:23 +01:00
Pádraig Brady
8e93dc6297 doc: output correct --help references with --program-prefix
* src/system.h (emit_ancillary_info): Take the invariant PROGRAM_NAME
as a parameter, so that consistent references are made to online docs
and texinfo nodes, when a --program-prefix is in place.  Note the
man pages don't need this fix as they're generated before the program
prefix is used.
* NEWS: Mention the improvements in references to online documentation.
2014-09-19 11:24:05 +01:00
Pádraig Brady
1f2647b8af doc: ensure the correct texinfo nodes are referenced in --help
* src/system.h (emit_ancillary_info): For commands that don't have
a 1:1 mapping with the texinfo node names, provide a mapping to
the correct node.
* doc/coreutils.texi: Add some extra cross references noticed while
checking this.
Fixes http://bugs.debian.org/762092
2014-09-19 11:24:05 +01:00
Bernhard Voelker
ed0c3c33c6 tests: fix false du failure on newer XFS
On XFS, when creating the ~2G test file 'big' in a for-loop by
appending 20M each time, the file ends up using ~4G - visible in
'st_blocks'.  The unused space would be reclaimed later.
This feature is called "speculative preallocation" which aims at
avoiding fragmentation.
According to the XFS FAQ [1], there are two particular aspects of
XFS speculative preallocation that are triggering this:

  1. "Applications that repeatedly trigger preallocation and reclaim
     cycles [after file close] can cause fragmentation.
     Therefore, this pattern is detected and causes the preallocation
     to persist beyond the lifecycle of the file descriptor."

  2. "Preallocation sizes grow as files grow larger."

[1] http://xfs.org/index.php/XFS_FAQ

Avoid one of the above by only doing a single close (reclaim cycle).

* tests/du/2g.sh: Similar to the fix for a dd test (see commit
v8.22-65-g7c03fe2), avoid speculative preallocation by creating
the 'big' file in one go instead of appending to it in the loop.
Remove debugging statements as the output with 'set -x' is
sufficient nowadays.
2014-09-16 18:50:29 +02:00
Paul Eggert
3b1ac4b1ed cat: allow copying empty files to themselves
Problem reported by Vincent Lefevre in: http://bugs.gnu.org/18449
* src/cat.c (main): Allow copying an empty file to itself.
* tests/misc/cat-self.sh: New test.
* tests/local.mk (all_tests): Add it.
2014-09-11 08:47:38 -07:00
Pádraig Brady
e8715100cb doc: reference online info pages directly from man pages
* src/system.h (emit_ancillary_info): Add a direct reference
to the corresponding online info documentation.  Corresponding
redirects were put in place on www.gnu.org to allow for concise links.
* help2man: Adjust to add the "online help" link (and subsequent
translation bugs link) to a "REPORTING BUGS" section.
Also add the concise links for further information in --help
to the "SEE ALSO" section, and dispense with the more verbose
default for that.
2014-09-11 10:53:06 +01:00
Pádraig Brady
e4627416b4 doc: adjust reference to info nodes in man pages
old form: coreutils '$cmd invocation'
new form: '(coreutils) $cmd invocation'

The old form erroneously referenced the node for the 'coreutils'
multi-call program.  Now that problematic node name was renamed
in commit v8.23-18-g72e470b, but the newer less ambiguous form
also has the advantage of working with the pinfo viewer for example.
Full discussion at http://bugs.gnu.org/18428

* man/local.mk: Adjust man page references to texinfo nodes.
* src/system.h: Adjust --help references to texinfo nodes.
2014-09-10 23:57:33 +01:00
Pádraig Brady
113ca3e892 maint: include libstdbuf.c in extraneous headers check
* cfg.mk (sc_system_h_headers): Don't exclude libstdbuf.c.
* src/libstdbuf.c: Remove headers already included in system.h.
2014-09-10 23:53:36 +01:00
Pádraig Brady
3cf19b5e5e build: adjust previous transformations on libstdbuf name
* src/local.mk (transform): commit v8.23-22-g6f9b018 discarded all
transformations on the libstdbuf.so name.  Be more conservative and
only exclude the $(program_transform_name) portion for libstdbuf.
2014-09-10 23:46:54 +01:00
Pádraig Brady
6f9b01873e build: avoid name transformations on libstdbuf
* src/local.mk (transform): Skip the transformation for libstdbuf
since that should not be subject to name clashes, and we need
to reference the name directly in LD_PRELOAD etc.
* configure.ac: Add a comment on the coupling of pkglibexec_PROGRAMS
to $(transform).
Issue reported at https://trac.macports.org/ticket/44922
Improved by Nick Bowler
2014-09-10 15:45:42 +01:00
Pádraig Brady
20f46a2e34 maint: fix syntax-check issues in recent commit
Avoid 2 new syntax-check failures introduced in commit v8.23-19-g8defcee

* cfg.mk (sc_some_programs_must_avoid_exit_failure): s/exit/return/.
* src/whoami.c (main): Reinstate translation marker for diagnostic.
2014-09-09 10:28:34 +01:00
Paul Eggert
c383c570c6 maint: avoid file-scope names of the form _[a-z]*
The C standard says this isn't portable, if you include
standard include files.
* build-aux/gen-single-binary.sh:
* src/coreutils-arch.c (single_binary_main_arch)
(single_binary_main_uname):
* src/coreutils-dir.c (single_binary_main_ls)
(_single_binary_main_dir):
* src/coreutils-vdir.c (single_binary_main_ls)
(_single_binary_main_vdir):
* src/coreutils.c (SINGLE_BINARY_PROGRAM):
Remove leading _ from single_binary prefix.
* src/numfmt.c (round_style): Rename from _round.  All uses changed.
(inval_style): Rename from _invalid.  All uses changed.
2014-09-08 20:48:44 -07:00
Paul Eggert
8defcee49b maint: prefer 'return status;' to 'exit (status);' in 'main'
* build-aux/gen-single-binary.sh: Don't use ATTRIBUTE_NORETURN
for main functions.
* src/base64.c, src/basename.c, src/cat.c, src/chcon.c, src/chgrp.c:
* src/chmod.c, src/chown.c, src/chroot.c, src/cksum.c, src/comm.c:
* src/cp.c, src/csplit.c, src/cut.c, src/date.c, src/dd.c, src/df.c:
* src/dircolors.c, src/dirname.c, src/du.c, src/echo.c, src/env.c:
* src/expand.c, src/expr.c, src/factor.c, src/fmt.c, src/fold.c:
* src/getlimits.c, src/groups.c, src/head.c, src/hostid.c:
* src/hostname.c, src/id.c, src/install.c, src/join.c, src/kill.c:
* src/link.c, src/ln.c, src/logname.c, src/ls.c, src/make-prime-list.c:
* src/md5sum.c, src/mkdir.c, src/mkfifo.c, src/mknod.c, src/mktemp.c:
* src/mv.c, src/nice.c, src/nl.c, src/nohup.c, src/nproc.c:
* src/numfmt.c, src/od.c, src/paste.c, src/pathchk.c, src/pinky.c:
* src/pr.c, src/printenv.c, src/printf.c, src/ptx.c, src/pwd.c:
* src/readlink.c, src/realpath.c, src/rm.c, src/rmdir.c, src/runcon.c:
* src/seq.c, src/shred.c, src/shuf.c, src/sleep.c, src/sort.c:
* src/split.c, src/stat.c, src/stdbuf.c, src/stty.c, src/sum.c:
* src/sync.c, src/tac.c, src/tail.c, src/tee.c, src/timeout.c:
* src/touch.c, src/tr.c, src/true.c, src/truncate.c, src/tsort.c:
* src/tty.c, src/uname.c, src/unexpand.c, src/uniq.c, src/unlink.c:
* src/uptime.c, src/users.c, src/wc.c, src/who.c, src/whoami.c:
In 'main' functions, Prefer 'return status;' to 'exit (status);'.
* src/coreutils-arch.c (_single_binary_main_uname)
(_single_binary_main_arch):
* src/coreutils-dir.c, src/coreutils-vdir.c (_single_binary_main_ls)
(_single_binary_main_dir, _single_binary_main_vdir):
Omit ATTRIBUTE_NORETURN.  Return a value.
* src/coreutils.c (SINGLE_BINARY_PROGRAM): Omit ATTRIBUTE_NORETURN.
(launch_program): Now static.
* src/dd.c (finish_up): New function.
(quit, main): Use it.
* src/getlimits.c (main): Return a proper exit status.
* src/test.c (test_main_return): New macro.
(main): Use it.
* src/logname.c, src/nohup.c, src/whoami.c:
Use 'error' to simplify exit status in 'main' function.
* src/yes.c (main): Use 'return' rather than 'error' to exit,
so that GCC doesn't suggest ATTRIBUTE_NORETURN.
2014-09-08 20:48:44 -07:00
Paul Eggert
72e470b9b5 doc: rename "coreutils invocation" to "Multi-call invocation"
This supports longstanding shell commands like
'info coreutils "touch invocation"'.
Problem reported by Vincent Lefevre via Bob Proulx in:
http://bugs.gnu.org/18428
* doc/coreutils.texi (Multi-call invocation):
Rename from "coreutils invocation".
2014-09-08 20:48:44 -07:00
Paul Eggert
943ca00bba doc: mention which commands are optional
* doc/coreutils.texi (coreutils invocation, df invocation)
(stty invocation, whoami invocation, nproc invocation)
(arch invocation, hostname invocation, hostid invocation)
(uptime invocation, chroot invocation, nice invocation)
(stdbuf invocation): Document that the command is installed
optionally.
2014-09-08 20:48:44 -07:00
Bernhard Voelker
9a1a715a00 doc: fix typos
* doc/coreutils.texi: Fix normal typos:
s/pseudorandom/pseudo-random/;
s/behaviour/behavior/;
s/linux-based/Linux-based/;
s/nonnegative/non-negative/.
Fix IEC's long name: s/Electronical/Electrotechnical/.
Wrap 'getopt' into the @code{} macro.
Fix a grammatical error (from myself): s/splitted/split/.
2014-09-07 01:35:52 +02:00
Paul Eggert
00441350f6 doc: spell "indeterminate" correctly
* doc/coreutils.texi (timeout invocation): Fix misspelling.
Reported by Yureruchihirosan via OKANO Takayoshi in:
http://bugs.gnu.org/18394
2014-09-03 09:52:55 -07:00
Pádraig Brady
8338c4dc4a maint: ensure fiemap extents flags are compared correctly
* src/extent-scan.c (extent_scan_read): Following on from the flags size
adjustment in commit v8.23-13-g1505b37, verify that the internal
representation of the flags is never truncated which could happen in the
unlikely case on 32 bit if the kernel flags ever expanded to 64 bits
which is theoretically possible given the reserved space.
2014-08-23 01:23:20 +01:00
Paul Eggert
1505b379af maint: avoid int64_t and similar types unless they're needed
C11 doesn't require them, even POSIX doesn't strictly require the
64-bit versions, and it makes the code a bit clearer if they're
used only when needed.
* src/copy.c (write_zeros, extent_copy):
* src/extent-scan.h (struct extent_info.ext_length):
Use off_t, not uint64_t, for a value derived from a file offset.
* src/extent-scan.h (struct extent_info.ext_flags)
Prefer plain unsigned int to uint32_t where either will do.
(struct extent_scan.ei_count):
Use size_t, not uint32_t, for a value bounded by SIZE_MAX.
* src/factor.c (MAGIC64, MAGIC63, MAGIC65):
Remove unnecessary casts to uint64_t.
2014-08-22 12:07:38 -07:00
Yurij Goncharuk
00d0c41d85 maint: refactor ls QUOTING_STYLE env var handling
* src/ls.c (main): As per the FIXME comment, move the
QUOTING_STYLE handling to a separate function.
2014-08-21 23:47:33 +01:00
Fridolin Pokorny
837bf406df doc: clarify that duplicate NFS mounts are skipped by df
* doc/coreutils.texi (df invocation): Add a sentence that eliding
duplicate entries for the same file system is not limited to bind
mounts, but also happens for remote file systems like NFS.
2014-08-21 11:45:57 +02:00
Pádraig Brady
ed1a495b3c df: improve mount point selection with inaccurate mount list
v8.23 has a test failure on Fedora rawhide build servers
in tests/df/skip-duplicate.sh.  This was due to no '/'
entry being output by df.  That was due to an inaccurate
/proc/mounts on the build environment as stat(/mnt/point)
identified all these /proc/mounts entries as having the
same device id:

  /                    rootfs
  /                    /dev/md1
  /dev                 devtmpfs
  /run                 tmpfs
  /boot                /dev/md0
  /proc/filesystems    /dev/md1

Since the device name on the right changes for a given id,
that causes the entries to be continually replaced, thus
resulting in no '/' entry.  I'm guessing this is due to
the mock environment bind mounting unneeded or sensitive
items to a dummy file on the host / (/dev/md1) though
have not looked into those details.

So rather than relying on an accurate /proc/mounts,
the attached patch takes a more conservative replacement
approach and only swaps a new device entry when the
mount point matches.  That should handle all practical
cases while also avoiding this situation.

* src/df.c (filter_mount_list): Only replace entries with
different device names when the mount point also matches.
2014-08-19 18:43:07 +01:00
Rasmus Borup Hansen
65d8e6906a cp: remove redundant possibly expensive heap deallocation
If the hash structures grow sufficiently large so that
the system is actively swapping, then the deallocation
can take a significant amount of time.  Details at:
http://lists.gnu.org/archive/html/coreutils/2014-08/msg00012.html

* src/cp.c (main): Only call hash deallocation routines
when in lint checking mode.
* THANKS.in: Remove as now in the git author list.
2014-08-11 15:58:34 +01:00
Reuben Thomas
9bcc626190 doc: indicate that FILE arguments are optional with rm -f
* src/rm.c (usage): s/FILE/[FILE]/.
Fixes http://bugs.gnu.org/18187
2014-08-04 11:42:45 +01:00
Anders Jonsson
f1fb49e80b numfmt: fix misspelling in --debug message
* src/numfmt.c (parse_format_string): s/overridding/overriding/.
Fixes http://bugs.gnu.org/18050
2014-08-03 21:56:52 +01:00
Paul Eggert
0660cfe128 tests: fix typo in tail-2/inotify-race
Reported by Andreas Schwab in: http://bugs.gnu.org/18057
* tests/tail-2/inotify-race.sh (break_src):
Use abs_top_srcdir, not abs_top_builddir.
2014-08-01 12:50:57 -07:00
Bernhard Voelker
0cf7b1d928 chroot: perform chdir("/") again unless new --skip-chdir is specified
Since commit v8.22-94-g99960ee, chroot(1) skips the chroot(2) syscall
for "/" arguments (and synonyms).  The problem is that it also skips
the following chdir("/") call in that case.  The latter breaks existing
scripts which expect "/" to be the working directory inside the chroot.
While the first part of the change - i.e., skipping chroot("/") - is
okay for consistency with systems where it might succeed for a non-root
user, the second part might be malicious, e.g.

  cd /home/user && chroot '/' bin/foo

In the "best" case, chroot(1) could not execute 'bin/foo' with ENOENT,
but in the worst case, chroot(1) would execute '/home/user/bin/foo' in
the case that exists - instead of '/bin/foo'.

Revert that second part of the patch, i.e., perform the chdir("/)
in the common case again - unless the new --skip-chdir option is
specified.  Restrict this new option to the case of "/" arguments.

* src/chroot.c (SKIP_CHDIR): Add enum.
(long_opts): Add entry for the new --skip-chdir option.
(usage): Add --skip-chdir option, and while at it, move the other
to options into alphabetical order.
(main): Accept the above new option, allowing it only in the case
when NEWROOT is the old "/".
Move down the chdir() call after the if-clause to ensure it is
run in any case - unless --skip-chdir is specified.
Add a 'newroot' variable for the new root directory as it is used
in a couple of places now.
* tests/misc/chroot-fail.sh: Invert the last tests which check the
working directory of the execvp()ed program when a "/"-like
argument was passed: now expect it to be "/" - unless --skip-chdir
is given.
* doc/coreutils.texi (chroot invocation): Document the new option.
Document that chroot(1) usually calls chdir("/") unless the new
--skip-chdir option is specified.  Sort options.
* NEWS (Changes in behavior): Mention the fix.
(New features): Mention the new option.
* init.cfg (nonroot_has_perm_): Add chroot's new --skip-chdir option.
* tests/cp/preserve-gid.sh (t1): Likewise.
* tests/cp/special-bits.sh: Likewise.
* tests/id/setgid.sh: Likewise.
* tests/misc/truncate-owned-by-other.sh: Likewise.
* tests/mv/sticky-to-xpart.sh: Likewise.
* tests/rm/fail-2eperm.sh: Likewise.
* tests/rm/no-give-up.sh: Likewise.
* tests/touch/now-owned-by-other.sh: Likewise.

Reported by Andreas Schwab in http://bugs.gnu.org/18062
2014-08-01 12:35:05 +02:00
Pádraig Brady
0cf66cbe85 build: avoid building stdbuf on cygwin
* configure.ac: Don't add stdbuf to the list of programs to build
if EXEEXT is set, as that is not handled in configure.ac for
libstdbuf.so yet (see bin_PRGRAMS handling in configure.ac).
Also the LD_PRELOAD mechanism will need to be adjusted to support
cygwin in any case, so avoid stdbuf completely in this case for now.
Problem reported by Eric Blake.
2014-07-31 11:00:55 +01:00
Eric Blake
d8a19e0336 doc: clarify that floating point parses "inf"
* doc/coreutils.texi (Floating point): Document handling of "inf",
"infinity", "NaN", and so on.
2014-07-29 16:57:55 -06:00
Paul Eggert
436db6237c maint: fix message translation glitches
Problem reported by Sebastian Rasmussen in: http://bugs.gnu.org/18054
* gl/lib/randread.c (randread_error): Don't put multiple string
literals inside _(...), as xgettext doesn't support that.
* src/chroot.c (main): In diagnostics, don't bother to distinguish
between setting the number of supplemental group IDs to a zero or
to a nonzero value, as the underlying system call is the same
either way.  This also makes the string easier to translate correctly.
2014-07-19 07:56:22 -07:00
Pádraig Brady
4fcc2f1781 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2014-07-18 23:22:56 +01:00
Pádraig Brady
22c8c23f40 version 8.23
* NEWS: Record release date.
2014-07-18 23:07:21 +01:00
Pádraig Brady
421e16ac0d build: port new bootstrap script to POSIX shells
* build-aux/gen-single-binary.sh: Avoid bash only constructs.
Reported by Assaf Gordon
2014-07-18 21:55:19 +01:00
Pádraig Brady
1b2438f0a1 tests: fix false failure with spaces in the test directory
* tests/misc/env.sh: Skip if we can't execute the generated shebang,
which would be the case if there are spaces in the directory hierarchy.
This is triggered by `make distcheck`
2014-07-18 19:24:39 +01:00
Pádraig Brady
09937e9d07 build: don't distribute generated coreutils.h
This issue was identified by the manifest comparisons
done by `make distcheck`

* src/local.mk (noinst_HEADERS): Remove coreutils.h from this always
distributed list.
(nodist_src_coreutils_SOURCES): Add coreutils.h as its contents
are determined at configure time, so pointless to distribute.
(src_coreutils_SOURCES): Define explicitly so that the corresponding
nodist_ variable is honored.
(DISTCLEANFILES): Add coreutils.h to this rather than CLEANFILES,
as its contents are determined at configure time.
2014-07-18 18:06:07 +01:00
Pádraig Brady
c0a29dd5f6 tests: fix false failure in cp --preserve=context test
With libselinux-2.2.1-6.fc20.x86_64, kernel-3.12.6-300.fc20.x86_64
`cp --preserve=context src dst` was seen to succeed when src and
dst where on the same fixed context file system, as lsetfilecon()
returned success in this case when the context wasn't being changed.

* tests/cp/cp-a-selinux.sh: Copy from a different file system to
most likely have a different context that will test context
setting logic correctly.
2014-07-18 13:01:45 +01:00
Pádraig Brady
49acb5a882 maint: avoid a syntax-check warning in previous commit
* cfg.mk: Avoid warning for @AMDEP_TRUE@ usage in man/local.mk
2014-07-18 04:35:52 +01:00
Paul Eggert
6202fcb99a build: port to non-GNU make
This fixes a problem with native Solaris 'make', which does not
grok '-include' lines (a GNU extension to POSIX 'make').
* configure.ac (man/dynamic-deps.mk): Create it, with an old
time stamp, if doing dynamic dependency tracking.
* man/local.mk (DISTCLEANFILES): Put man/dynamic-deps.mk here,
rather than in CLEANFILES.
(man/dynamic-deps.mk): Don't create it read-only, so that we
can easily touch it later.
Include it with '@AMDEP_TRUE@@am__include@', not with '-include',
as '-include' does not work with native Solaris 'make'.
2014-07-17 13:11:46 -07:00
Assaf Gordon
061882d73b numfmt: fix isblank() usage for some unibyte locales
* src/numfmt.c (simple_strtod_int): Replace isdigit() with c_isdigit()
to avoid locale concerns and -Wchar-subscripts warnings on cygwin.
Remove the now redundant locale guard.
(simple_strtod_human): Cast characters to unsigned so that the promoted
int value passed to isblank() is positive, allowing it to work correctly
for all characters in unibyte locales.  Previously character 0xA0,
i.e. non-breaking space, would be misclassified for example.
(process_suffixed_number): Likewise.
(skip_fields): Likewise.
Both issues were triggered by the -Wchar-subscripts warning on GCC 4.8.3
on cygwin, due to the is*() implementations used there, but the issue
is present on all platforms defaulting to signed chars.
* NEWS: Mention the bug fix.

Reported by Eric Blake
2014-07-16 22:35:17 +01:00
Pádraig Brady
37b36018d3 tests: fix portabilitiy issue in new od-endian test
* tests/misc/od-endian.sh: '\n' is not generally supported
in the replacement, so use the more portable "\\$NL".
2014-07-14 02:49:47 +01:00
Pádraig Brady
39f79234a1 tests: fix portability issue in new dd/ascii test
* tests/dd/ascii.sh: Quote so that '\\' is passed
to printf rather than a single '\', as that's not portable.
bash, dash, zsh and external solaris printf were seen to support
  printf '\%03o' 1 2
while ksh, freebsh shell and external GNU printf need the more portable
  printf '\\%03o' 1 2
Note we don't use env here to call the coreutils printf implementation,
as there are many printf calls, so relying on portable shell
implementations will be faster.
2014-07-14 02:24:59 +01:00
Pádraig Brady
2419df4139 tests: avoid hang when files created with wrong permissions
* tests/split/b-chunk.sh: Never show the rm prompt which would
hang the test suite.  This was seen when split erroneously
created files with no persmissions, which was triggered by
this compiler bug in clang 3.4:
http://llvm.org/bugs/show_bug.cgi?id=18346
2014-07-14 00:54:57 +01:00
Pádraig Brady
803ec30b95 maint: avoid clang -Wint-to-pointer-cast warning
* src/chroot.c: Explicitly cast int to pointer type.
2014-07-14 00:38:29 +01:00
Pádraig Brady
2c003e6d57 build: update gnulib submodule to latest
* gnulib: Sync recent cleanups and the fix for
missing df entries in the presence of bind mounts:
http://bugs.gnu.org/17833
* NEWS: Detail the df bug fix.
2014-07-13 21:12:59 +01:00
Pádraig Brady
fe08796d7c sort: avoid undefined operation with destroying locked mutex
This didn't seem to cause any invalid operation on GNU/Linux at least,
but depending on the implementation, mutex deadlocks could occur.
For example this might be the cause of lockups seen on Solaris:
http://lists.gnu.org/archive/html/coreutils/2013-03/msg00048.html

This was identified with valgrind 3.9.0 with this setup:

  seq 200000 > file.sort
  valgrind --tool=drd src/sort file.sort -o file.sort

With that, valgrind would _intermittently_ report the following:

 Destroying locked mutex: mutex 0x5419548, recursion count 1, owner 2.
    at 0x4C2E3F0: pthread_mutex_destroy(in vgpreload_drd-amd64-linux.so)
    by 0x409FA2: sortlines (sort.c:3649)
    by 0x409E26: sortlines (sort.c:3621)
    by 0x40AA9E: sort (sort.c:3955)
    by 0x40C5D9: main (sort.c:4739)
 mutex 0x5419548 was first observed at:
    at 0x4C2DE82: pthread_mutex_init(in vgpreload_drd-amd64-linux.so)
    by 0x409266: init_node (sort.c:3276)
    by 0x4092F4: init_node (sort.c:3286)
    by 0x4090DD: merge_tree_init (sort.c:3234)
    by 0x40AA5A: sort (sort.c:3951)
    by 0x40C5D9: main (sort.c:4739)

 Thread 2:
 The object at address 0x5419548 is not a mutex.
    at 0x4C2F4A4: pthread_mutex_unlock(in vgpreload_drd-amd64-linux.so)
    by 0x4093CA: unlock_node (sort.c:3323)
    by 0x409C85: merge_loop (sort.c:3531)
    by 0x409F8F: sortlines (sort.c:3644)
    by 0x409CE3: sortlines_thread (sort.c:3574)
    by 0x4E44F32: start_thread (in /usr/lib64/libpthread-2.18.so)
    by 0x514EEAC: clone (in /usr/lib64/libc-2.18.so)

* src/sort.c (sortlines): Move pthread_mutex_destroy() out to
merge_tree_destroy(), so that we don't overlap mutex destruction
with threads still operating on the nodes.
(sort): Call the destructors only with "lint" defined, as the
memory used will be deallocated implicitly at process end.
* NEWS: Mention the bug fix.
2014-07-13 21:09:14 +01:00
Shayan Pooya
eabcccc44b sort: fix two threading issues reported by valgrind
Neither issue impacts on the correct operation of sort.
The issues were detected by both valgrind 3.8.1 and 3.9.0 using:

  seq 200000 > file.sort
  valgrind --tool=drd src/sort file.sort -o file.sort

For tool usage and error details see:
 http://valgrind.org/docs/manual/drd-manual.html

* src/sort.c (queue_insert): Unlock mutex _after_ signalling the
associated condition variable.  Valgrind flags this with:
  "Probably a race condition: condition variable 0xffeffffb0 has been
   signaled but the associated mutex 0xffeffff88 is not locked by the
   signalling thread."
The explanation at the above URL is:
  "Sending a signal to a condition variable while no lock is held on
   the mutex associated with the condition variable.  This is a common
   programming error which can cause subtle race conditions and
   unpredictable behavior."
This should at least give more defined scheduling behavior.

(merge_tree_destroy): Make symmetrical with merge_tree_init() thus
destroying the correct mutex.  Valgrind flags this with:
  "The object at address 0x5476cf8 is not a mutex."
2014-07-13 21:09:14 +01:00
Pádraig Brady
dbd7c9452a maint: avoid an inconsequential mem leak
* src/df.c (get_disk): Avoid an inconsequential mem leak
spotted by coverity.  Also s/duplicities/duplicates/.
2014-07-13 21:03:57 +01:00
Jim Meyering
4d82df724e build: adjust new rule not to depend on bash-4.x
* man/local.mk (man/dynamic-deps.mk): Use the same code to
derive FOO from man/FOO.1 as in the .x.1 rule below.
Using the more concise "name=$${man:4: -2}" is not portable enough.
2014-07-13 10:30:24 -07:00
Alex Deymo
71e2ea7734 build: support building all tools in a single binary
Add the --enable-single-binary option to the configure file.
When enabled, this option builds a single binary file containing
the selected tools.  Which tool gets executed depends on the value
of argv[0] which can be set implicitly through symlinks to the
single program.

This setup reduces significantly the size of a complete coreutils
install, since code from lib/libcoreutils.a is not duplicated in
every one of the more than 100 binaries.  Runtime overhead is
increased due to more dynamic libraries being loaded, and extra
initialization being performed for all utils.  Also initially
a larger binary is loaded from storage, though this is usually
alleviated due to caching and lazy mmaping of unused blocks,
and in fact the single binary should have better caching
characteristics.

Comparing the size of the individual versus single binary on x86_64:
  $ cd src
  $ size coreutils
  $ size -t $(../build-aux/gen-lists-of-programs.sh --list-progs |
              grep -Ev '(coreutils|libstdbuf)') | tail -n1
     text    data     bss     dec     hex filename
  1097416    5388   88432 1191236  122d44 src/coreutils
  4901010  124964  163768 5189742  4f306e (TOTALS)

Storage requirements are reduced similarly:
  $ cd src
  $ du -h coreutils
  $ du -ch $(../build-aux/gen-lists-of-programs.sh --list-progs |
             grep -Ev '(coreutils|libstdbuf)') | tail -n1
  1.2M    coreutils
  5.3M    total

When installing, the makefile will create either symlinks or
shebangs based on the --enable-single-binary setting, for
each configured tool. In this way, all the tools are still
callable individually, but they are all implemented by the same
"coreutils" binary installed on the same directory.

* .gitignore: Add new generated files.
* Makefile.am: New rules to generate build-aux/gen-single-binary.sh
  and install symlinks.
* NEWS: Mention the new feature.
* README: Add "coreutils" to the list of utils.
* bootstrap.conf: Regenerate src/single-binary.mk
* build-aux/gen-lists-of-programs.sh: New --list-progs option.
* build-aux/gen-single-binary.sh: Regenerate
* configure.ac: New --enable-single-binary option and other variables.
Disallow --enable-single-binary=symlinks with --program-prefix et. al.
* man/coreutils.x: Manpage hook.
* man/local.mk: Add manpage hook and fix dependencies.
* src/coreutils.c: Multicall implementation.
* src/local.mk: New rules for the single binary option.
* tests/local.mk: Add $single_binary_progs to support
require_built_() from init.cfg
* tests/misc/env.sh: Avoid the use of symlink to echo.
* tests/misc/help-version.sh: Add exception for coreutils.
* tests/install/basic-1.sh: Really avoid using ginstall strip
functionality if there is an issue with the independent strip command.
* src/kill.c: Changes to call exit() in main.
* src/readlink.c: Likewise.
* src/shuf.c: Likewise.
* src/timeout.c: Likewise.
* src/truncate.c: Likewise.
2014-07-13 14:23:09 +01:00
Bernhard Voelker
9c128c0e49 maint: simplify parsing df's output in shell scripts
Avoid complicated and error-prone parsing of df's output via
sed(1), cut(1), etc., and instead use df's more modern --output
option.

* src/ioblksize.h (in a comment): Simplify the extraction of the
device name of the mounted file system from df's output.
* tests/dd/skip-seek-past-dev.sh: Likewise.
* tests/du/2g.sh: Likewise for the 'avail' column here.
Also avoid the deprecated use of "tail -NUM".
* tests/misc/stat-mount.sh: While at it, remove the determination
of the mount point of "." via df(1) plus sed(1) as it is unused
since commit v8.5-159-gf57cb37 anyway.  Instead, improve this test
by verifying that the output of "stat -c%m ." at least starts with
a slash '/'.
2014-07-04 01:54:45 +02:00
Pádraig Brady
8e2219b09c pwd: revert default mode back to -P
Revert commit v8.22-131-g3e89d5b as even though POSIX
states that the default mode should be -L,
common practice for stand-alone pwd implementations
is to default to -P.

* src/pwd.c (usage): Retain mention of the default mode of operation.

Suggested by Bob Proulx
2014-07-02 19:45:18 +01:00
Pádraig Brady
07e40d5de8 tests: avoid false failure with spaces in mount point paths
* tests/ls/readdir-mountpoint-inode.sh: Quote appropriately
to process mount points with spaces in the path.
Previously items like these would usually be skipped,
though if the path also contained a '-' for example,
that would stat stdin, thus producing a wrong inode
and a false failure.
Fixes http://bugs.gnu.org/17863
2014-07-02 19:45:18 +01:00
Pádraig Brady
39e2a4cff8 tests: avoid errors on systems without getmntent
* tests/df/no-mtab-status.sh: Skip if getmntent() not available.
* tests/df/skip-duplicates.sh: Likewise.
Fixes http://bugs.gnu.org/17863
2014-07-02 19:45:17 +01:00
Jim Meyering
04fc32f7e0 tests: use "env builtin" in place of "$abs_top_builddir/src/builtin"
This works for any program that might also be a shell built-in.
It is more concise.  In addition, it makes output more reproducible:
some diagnostics include argv[0], which will now be just the program
name, rather than the full absolute name of the executable.
* tests/misc/sort-compress.sh: Use env kill, rather than absolute name.
* tests/install/trap.sh: Likewise.
* tests/misc/timeout.sh: Likewise.
* tests/touch/no-dereference.sh: Do the same for two uses of "test".
* tests/touch/no-create-missing.sh: Likewise.
2014-07-02 09:07:26 -07:00
Alex Deymo
28d1dc5251 maint: fix context_t init warning on systems without selinux
On systems without libselinux, context_t is defined as an int type,
but defined as a pointer type by SELinux.

* src/chcon.c: Init with 0 rather than NULL to avoid warning.
2014-07-02 10:47:41 +01:00
Jim Meyering
149a3b2c78 tests: adapt tests to change in pwd's default
* tests/misc/pwd-option.sh (base): Initialize with -P,
now that -L is the default, to accommodate an initial
working directory with a symlink component.
* tests/misc/readlink-fp-loop.sh: Use $(env pwd -P) to get the
absolute working directory.  Using "env" ensures we do not invoke
any shell built-in, and PATH ensures we invoke the one from coreutils.
* tests/readlink/can-e.sh: Likewise.
* tests/readlink/can-f.sh: Likewise.
* tests/readlink/can-m.sh: Likewise.
2014-07-01 09:44:41 -07:00
Pádraig Brady
8e764584fd maint: fix const correctness warnings with security_context_t
The security_context_t type was always an artificial separation
from a standard char* string, and various libselinux using code
assumed both were synonymous.  In addition, prior to libselinux 2.3
function declarations were incorrect wrt constness of this type.
Here we replace security_context_t with char*, and also
provide a wrapper function to cater for the const issue on
older libselinux.

* src/system.h (se_const): A new function to avoid and identify
the const issue on older libselinux.
* src/copy.c: s/security_context_t/char */.
* src/cp.c: Likewise.
* src/id.c: Likewise.
* src/install.c: Likewise.
* src/ls.c: Likewise.
* src/mkdir.c: Likewise.
* src/mkfifo.c: Likewise.
* src/mknod.c: Likewise.
* src/runcon.c: Likewise.
* src/selinux.c: Likewise.
* tests/cp/no-ctx.sh: Likewise.
* src/chcon.c: Likesize.
2014-07-01 15:45:53 +01:00
Namhyung Kim
3106de5c78 chcon: avoid redundant context allocations
Since context is verified by security_check_context() it can be used in
change_file_context() without converting to context_t every time.

* src/chcon.c (change_file_context): Use specified_context directly.
2014-07-01 15:45:53 +01:00
Namhyung Kim
e4081e44e0 chcon: use security_check_context() for context validation
context_new() and _free() are used for checking validity of a
specified context.  libselinux provides security_check_context
for this purpose so use it.

Note that context_new() can fail for a valid context - e.g. ENOMEM.

* src/chcon.c (main): Use security_check_context().
2014-07-01 15:45:53 +01:00
Pádraig Brady
3e89d5bb9b pwd: assume -L mode by default, as per POSIX
* src/pwd.c (main): Adjust default mode to be "logical"
and independent of the POSIXLY_CORRECT env var.
(usage): Mention the default mode of operation.
* doc/coreutils.texi (pwd invocation): Adjust accordingly.
* tests/misc/pwd-option.sh: Likewise.
* NEWS: Mention the change in behavior.
2014-06-30 10:27:48 +01:00
Pádraig Brady
acb422bdd1 tests: use predetermined NON_ROOT_GID
* HACKING: GID is more useful in tests than group name, so rename
input param from NON_ROOT_GROUP to NON_ROOT_GID to make it obvious
that only a group ID is now acceptable, thus allowing GID lookups
to be avoided throughout the tests.
* init.cfg (require_root_): Likewise.
* tests/misc/truncate-owned-by-other.sh: Avoid looking up the GID.
* tests/touch/now-owned-by-other.sh: Likewise.
* tests/misc/chroot-credentials.sh: Likewise.  Also fix an instance
of comparison against NON_ROOT_GROUP which would have given a false
failure if a non numeric value was passed in.
* tests/id/setgid.sh: Use previously looked up gid as a more
accurate base for the subsequent adjustment, and move
the uid lookup within chroot, rather than having the overhead
of a separate `id` invocation.
2014-06-26 15:30:41 +01:00
Pádraig Brady
e7c7802964 maint: mention when the du cycle warning bug was introduced
* NEWS: Mention bug introduced in v8.1 (with commit v8.0-88-g8ba5d1a).
2014-06-26 12:07:15 +01:00
Petr Stodůlka
408461c0e7 id: output the effective group for the process
* src/id.c (print_full_info): When no user is specified,
output the effective group for the _process_, rather than
the default group from the system database, which may be different.
* tests/id/setgid.sh: Add a case for `id` as well as `id -G`.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/7320
Reported at http://bugzilla.redhat.com/1016163
2014-06-26 12:07:10 +01:00
Pádraig Brady
d71c12f1e4 df: report correct device in presence of eclipsed mounts
* src/df.c (last_device_for_mount): A new function to identify
the last device mounted for a mount point.
(get_disk): Use the above to discard mount entries for a device,
where a later mount entry uses a different device name than
that of the user specified device.
* tests/df/over-mount-device.sh: A new root test.
* tests/local.mk: Reference the new test.
* NEWS: Reword for all these related recent fixes.
Discussed at: http://bugs.gnu.org/16539#69
2014-06-25 09:55:12 +01:00
Pádraig Brady
828801a174 df: look for accessible mount points for specified devices
* src/df.c (get_disk): Include whether we can access the mount dir,
in the mount entry selection criteria.  This handles the case where
a device is (bind) mounted multiple times with the shortest mount path
not being accessible, while some of the other mount points are.
Discussed at: http://bugs.gnu.org/16539#63
2014-06-24 17:38:46 +01:00
Pádraig Brady
9d736f8dbf df: output placeholder values for inaccessible mount points
A system provided mount entry may be unavailable due to TOCTOU race,
or if another device has been over-mounted at that position, or due to
access permissions.  In all these cases output "-" placeholder values
rather than either producing an error, or in the over-mount case
outputting values for the wrong device.

* src/df.c (device_list): A new global list now updated by
filter_mount_list().
(filter_mount_list): Adjust to take a parameter as to whether
update the global mount list, or only the mount <-> device ID mapping.
(get_dev): Use the device ID mapping to ensure we're not outputting
stats for the wrong device.  Also output placeholder values when we
can't access a system specified mount point.
(get_all_entries): Set the DEVICE_ONLY param for filter_mount_list().
(devname_for_dev): A new function to search the mount <-> dev mapping.
* test/df/skip-duplicates.sh: Adjust accordingly.
* NEWS: Mention the bug fixes.

Discussed at: http://bugs.gnu.org/16539
2014-06-24 17:38:46 +01:00
Pádraig Brady
b7bb499496 du: ignore directory cycles due to bind mounts
* src/du.c (process_file): Treat cycles due to bind mounts
like cycles due to following symlinks.
* tests/du/bind-mount-dir-cycle.sh: Adjust accordingly.
* NEWS: Mention the change in behavior.
Reported at http://bugzilla.redhat.com/836557
2014-06-24 14:39:34 +01:00
Pádraig Brady
6635f0b0f7 doc: state in ls --help, that -h affects --size format
* src/ls.c (usage): State that --human changes --size format.
Fixes http://bugs.gnu.org/17838
2014-06-24 10:39:49 +01:00
Pádraig Brady
fd0a650403 doc: clarify chgrp restrictions
* doc/coreutils.texi (chown invocation): Mention the system dependent
restrictions on setting groups.
(chgrp invocation): Likewise. Reference the 'chown' superset.
* man/chgrp.x: Cross reference chown(1) which is the superset interface,
and also chown(2) which gives details of the platform restrictions.
Fixes http://bugs.gnu.org/17495
2014-06-19 19:56:58 +01:00
Pádraig Brady
4f8d74eb1b df: use all of the last device details provided
* src/df.c (filter_mount_list): Recent commit v8.22-108-g25a2c94
failed to copy file system type along with the updated device name.
Therefore simply replace the existing mount entry with the
current one with all the latest device details.  Note the name,
even if not shorter in this entry, will be replaced with a shorter
name in a subsequent mount entry.
* tests/df/skip-duplicates.sh: Add a test case.
2014-06-18 18:05:16 +01:00
Pádraig Brady
5ad16c2a0f seq: fix incorrect output with start or end of -0
* src/seq.c (main): Avoid seq_fast() with a start or end of -0.
* tests/misc/seq.pl: Add test cases.
* NEWS: Mention the fix.
Fixes http://bugs.gnu.org/17800
2014-06-18 18:05:02 +01:00
Pádraig Brady
8a51bd3736 tail: fix --follow to use polling mode for VXFS
Veritas File System can run in single instance or clustered mode,
so mark as remote to avoid using inotify for the latter case.

* src/stat.c (human_fstype): Tag VXFS as remote, to use polling
for the clustered variant (VXCFS).
* NEWS: Mention the bug fix.

Reported by Ondřej Vašík in http://bugzilla.redhat.com/1104244
Fixes http://bugs.gnu.org/17770
2014-06-13 10:12:39 +01:00
Pádraig Brady
4f169fe49b maint: suppress a theoretical buffer overflow warning
* src/numfmt.c (double_to_human): The printf format is built up in
a stack buffer which is big enough to hold any of the possible formats.
However the size parameter passed to snprintf was too big by 1
when GROUP was true.  So decrease the buffer available to snprintf
to avoid this theoretical in practise but valid coverity warning.
2014-06-12 00:39:13 +01:00
Pádraig Brady
e919da5aee tests: fix version printing for ginstall in one test
* tests/install/d-slashdot.sh: 'ginstall' is the binary name
in the build directory, not 'install'.
2014-06-11 23:50:00 +01:00
Bernhard Voelker
15d092f94a install: allow options -D and -t to be used together
* src/install.c (install_file_in_file_parents): Factor out the
creation of any parent directories into ...
(mkancesdirs_safe_wd): ... this new function.
(install_file_in_dir): Add the parameter 'mkdir_and_install', and
call the above new function if it evaluates to true.
(main): During parsing of the -t option, move the check whether
the target_directory exists down  after the option parsing loop,
and do not complain about stat(optarg,...) failing if -D was given.
Pass 'mkdir_and_install' to install_file_in_dir().
* doc/coreutils.texi (install invocation): Remove the (false)
restriction that -D would be ignored together with -t.  Instead,
clarify install's new bahavior.
Fix the node's reference in the top-level @direntry for consistency.
* src/install/basic-1.sh: Add tests for the now-allowed combination
of the -D and -t options.
* NEWS: Mention the improvement.
2014-06-11 15:48:39 +02:00
Pádraig Brady
696f539e62 build: update gnulib submodule and tests/init.sh to latest
* gnulib: Update to latest.
* tests/init.sh: Update from gnulib.
2014-06-11 12:18:45 +01:00
Pádraig Brady
0216f8397f build: update GCC warnings
* configure.ac: Remove the -Wsuggest-attribute=pure
enablement on GCC >= 4.7, as that was moot since
gnulib was already enabling that warning in its default set.
The false positive was seen with 4.6.2, but confirmed
not present in 4.6.3, so that's sufficiently old to
just leave this enabled unconditionally.

Remove the -Wsuggest-attribute={const,noreturn}
enablement, as gnulib already has those in the default set.

Enable the -Wlogical-op warning for GCC >= 4.8.0
as that is confirmed OK with coreutils at least, due to
fixing: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43772

Remove the -Wno-logical-op override since the main
-Wlogical-op flag is now sufficient to control this warning
as of GCC 4.6.3 at least.
2014-06-11 00:49:38 +01:00
Pádraig Brady
9a6a486e65 tests: consolidate tests for true and false
* src/true.c (main): Add a comment about the possibility
of true returning EXIT_FAILURE due to write failure.
* tests/misc/false-status.sh: Fix so we're testing
the tool and not the shell builtin.  Add a case for true(1).
* tests/misc/help-version.sh: Skip /dev/full test
for true as well as false since the exit status is tested separately.
Also remove the iterations for different LC_MESSAGES, as this was only
applied for false(1).  Translations are not honored in the test dir
and so would need separate handling in any case.
2014-06-03 18:39:57 +01:00
Ben Walton
1239ac573d maint: avoid compiler warnings with some assert() implementations
* src/df.c (get_dev): asssert() on Solaris 10 is not marked as
__noreturn__ and thus the compiler may think V is uninitialized
later on in the function.
* THANKS.in: Remove the now committer.
2014-06-02 20:44:07 +01:00
Ben Walton
a6ee674d64 build: be more specific about .git repo before enabling warnings
* configure.ac: When looking for a .git checkout, exclude repos that
contain a .tarball-version file as these are probably releases
that are imported into git for patch management.
2014-06-02 19:00:43 +01:00
Pádraig Brady
5c6cf94ba5 cut: restore special case handling of -f with -d$'\n'
commits v8.20-98-g51ce0bf and v8.20-99-gd302aed changed cut(1)
to process each line independently and thus promptly output
each line without buffering.  As part of those changes we removed
the special handling of --delimiter=$'\n' --fields=... which
could be used to select arbitrary (ranges of) lines, so as to
simplify and optimize the implementation while also matching the
behavior of different cut(1) implementations.

However that GNU behavior was in place for a long time, and
could be useful in certain cases like making a separated list like
`seq 10 | cut -f1- -d$'\n' --output-delimiter=,` although other tools
like head(1) and paste(1) are more suited to this operation.
This patch reinstates that functionality but restricts the
"line behind" buffering behavior to only the -d$'\n' case.

We also fix the following related edge case to be more consistent:

  before> printf "\n" | cut -s -d$'\n' -f1- | wc -l
  2
  before> printf "\n" | cut    -d$'\n' -f1- | wc -l
  1
  after > printf "\n" | cut -s -d$'\n' -f1- | wc -l
  1
  after > printf "\n" | cut    -d$'\n' -f1- | wc -l
  1

* src/cut.c (cut_fields): Adjust as discussed above.
* tests/misc/cut.pl: Likewise.
* NEWS: Mention the change in behavior both for v8.21
and this effective revert.
* cfg.mk (old_NEWS_hash): Adjust for originally omitted v8.21 entry.
* src/paste.c: s/delimeter/delimiter/ comment typo fix.
2014-06-01 12:14:39 +01:00
Pádraig Brady
39d1c9576a stat: avoid redundant stat() calls
* src/stat.c (find_bind_mount): NAME is invariant in the loop,
so only stat(NAME) outside the loop.
2014-06-01 12:14:24 +01:00
Pádraig Brady
25a2c948b2 df: use the last device name provided by the system
The device name reported for a particular mount entry
may no longer be valid if the mount point was subsequently
mounted on a different device.  Therefore honor the order
of the mount list returned by the system and use the last
reported device name.

* src/df.c (filter_mount_list): When discarding the current
mount entry, ensure that a new device name is not also discarded.
* tests/df/skip-duplicates.sh: Add a test case.  Also fix
a false failure in the edge case of a system with only a
single file system.
* NEWS: Mention the fix.
2014-05-29 16:01:30 +01:00
Pádraig Brady
e4314774fd stdbuf: support OS X
* src/stdbuf.c (set_LD_PRELOAD): Adjust to use Mac OS X
specific environment variables on __APPLE__ platforms.
Fixes http://bugs.gnu.org/17590
2014-05-26 16:38:18 +01:00
Jim Meyering
b50186ef7d build: uname: avoid shadowing warning
* src/uname.c (main) [__APPLE__]: Rename inner "s" to "cs",
to avoid gcc shadowing warning.
2014-05-26 08:01:09 -07:00
Pádraig Brady
442fafa54c doc: clarify --zero-terminated option
* src/join.c (usage): Reword to avoid implication that
the NUL byte is only generated as the output delimeter.
* src/sort.c (usage): Likewise.
* src/shuf.c (usage): Likewise. Also since we're changing the
translation string take the opportunity to separate out
the description to a separate string to reduce translation overhead.
* src/uniq.c (usage): Likewise.
* src/stty.c (usage): s/null/NUL/ for consistency.
* src/basename.c (usage): Reword for accuracy/consistency.
* src/dirname.c (usage): Likewise.
* src/du.c (usage): Likewise.
* src/env.c (usage): Likewise.
* src/printenv.c (usage): Likewise.
* src/readlink.c (usage): Likewise.
* src/realpath.c (usage): Likewise.
* doc/coreutils.texi: Consolidate/share the descriptions of
--null, --zero and --zero-terminated.
2014-05-26 12:31:50 +01:00
Jim Meyering
347b392bd0 build: libstdbuf.so: avoid new OS X link failure
* src/local.mk (src_libstdbuf_so_LDADD): Add $(LIBINTL),
to avoid link failure on OS X.
2014-05-25 15:15:18 -07:00
Jim Meyering
74ca6e84c0 cat,cp,split: use a larger buffer for copying
* src/ioblksize.h (IO_BUFSIZE): Double the size, to 128KB.
Add four more columns to the blksize-vs-bandwidth table
2014-05-25 09:36:58 -07:00
Paul Eggert
0c5de1ab5b doc: use nicer quotes
* doc/coreutils.texi: Add "@documentencoding UTF-8".
2014-05-24 08:44:12 -07:00
Pádraig Brady
56c9a43ac2 stat,tail: improve support for LogFS and ConfigFS
* src/stat.c (human_fstype): Add new file system ID definitions.
* NEWS: Mention the improvement.
2014-05-23 00:20:43 +01:00
Pádraig Brady
695a0b5502 maint: enforce consistent width and case of file system constants
* src/stat.c (human_fstype): Adjust a couple of existing constants
to be a consistent width and capitalization so that the
src/fs-magic-compare target works without reporting false positives.
* cfg.mk (sc_fs-magic-compare): A new syntax check to enforce this.

Improved by: Jim Meyering
2014-05-22 11:16:07 +01:00
Pádraig Brady
1ab31d1ec1 stdbuf: support compilers other than __GNUC__
__SUNPRO_C >= 0x590 /*12.0*/ supports __attribute((constructor))
required by stdbuf, so use a more direct check for this.

Note ensure that --libexecdir is set to the appropriate
install location for libstdbuf.so so that stdbuf works
when installed on the system like it does when running
tests in the build directory.

* configure.ac (stdbuf_supported): Use a test prog to determine support.
* src/libstdbuf.c (stdbuf): Define appropriately for non GCC compilers,
and provide early feedback (compilation warning) if trying to compile
libstdbuf without the necessary support.
* src/stdbuf.c (set_LD_PRELOAD): Add a note on having stdbuf
look for libstdbuf.so in the default lib search path.
* cfg.mk (sc_prohibit-gl-attributes): Adjust so we can exclude
libstdbuf.so from prohibiting '__attribute', since we want
this form to avoid silently eliding this required attribute on non GCC.

Reported and tested by Rich Burridge.
2014-05-21 18:29:38 +01:00
Pádraig Brady
7a63d6395a tests: use chroot --user rather than internal setuidgid tool
* init.cfg (require_root_): Adjust to use chroot, and make
`require_built_ chroot` implicit when chroot used in the test.
* po/POTFILES.in: Remove reference to setuidgid tool.
* src/.gitignore: Likewise.
* src/local.mk: Likewise.
* src/setuidgid.c: Remove.
* tests/cp/preserve-gid.sh: s/setuidgid/chroot --user/.
* tests/cp/special-bits.sh: Likewise.
* tests/id/setgid.sh: Likewise.
* tests/misc/truncate-owned-by-other.sh
* tests/mv/sticky-to-xpart.sh: Likewise.
* tests/rm/fail-2eperm.sh: Likewise.
* tests/rm/no-give-up.sh: Likewise.
* tests/touch/now-owned-by-other.sh: Likewise.
* tests/misc/chroot-fail.sh: Skip if chroot not built.
2014-05-21 11:18:27 +01:00
Pádraig Brady
0c4729516b chroot: make changing root check more robust
* src/chroot.c (is_root): A new helper function to
determine if the passed argument is the root directory
based on inode comparison.
(main): Use the new helper rather than comparing strings.
* tests/misc/chroot-fail.sh: Add cases for alternative root paths.
2014-05-21 11:18:27 +01:00
Pádraig Brady
aa1a72706b chroot: exit immediately upon failure
* src/chroot.c (main): Consistently exit with failure status immediately
upon hitting a terminal issue, rather than diagnosing multiple issues
lest users think previous failing actions are optional.
2014-05-21 11:18:26 +01:00
Pádraig Brady
ce0c08b52d chroot: with --userspec clear root's supplemental groups
It's dangerous and confusing to leave root's supplemental
groups in place when specifying other users with --userspec.
In the edge case that that is desired one can explicitly
specify --groups.

Also we implicitly set the system defined supplemental groups
for a user.  The existing mechanism where supplemental groups
needed to be explicitly specified is confusing and not general
when the lookup needs to be done within the chroot.

Also we extend the --groups syntax slightly to allow clearing
the set of supplementary groups using --groups=''.

* src/chroot.c (setgroups): On systems without supplemental groups,
clearing then is a noop and so should return success.
(main): Lookup the primary GID with getpwuid() when just a numeric
uid is specified, and also infer the USERNAME from this call,
needed when we're later looking up the supplemental groups for a user.
Support clearing supplemental groups, either implicitly for
unknown users, or explicitly when --groups='' is specified.
* tests/misc/chroot-credentials.sh: Various new test cases
* doc/coreutils.texi (chroot invocation): Adjust for the new behavior.
* NEWS: Mention the change in behavior.
2014-05-21 11:18:26 +01:00
Pádraig Brady
99960eeab9 chroot: don't chdir() if not changing root
This allows chroot to be used as a light weight tool
to change user identification for a command,
while not changing the current working directory.
It also makes `chroot / true` consistently succeed on
all platforms for non root users.

* src/chroot.c (main): If the same root is specified. i.e. '/'
then don't change the current working directory, and avoid the
overhead of the other redundant calls.
* tests/misc/chroot-fail.sh: Remove failure guard previously
needed on some systems.  Also add an explicit case to ensure
we don't change directory.
* NEWS: Mention the change in behavior.
2014-05-16 22:01:31 +01:00
Pádraig Brady
ffd1a1d8de maint: avoid clang -Wtautological-constant-out-of-range-compare warning
* src/df.c (decode_output_arg): Use only enum constants to avoid
clang "warning: comparison of constant -1 with expression of
type 'display_field_t' is always false"
2014-05-13 23:23:30 +01:00
Pádraig Brady
cbfb34c7d3 df: ignore non file system entries in /proc/mounts
Linux with network namespaces contains entries in /proc/mounts like:
  proc net:[4026532464] proc rw,nosuid,nodev,noexec,relatime 0 0
resulting in a failure to stat 'net:[...]', inducing a warning
and an exit with failure status.

* src/df.c (get_dev): Ignore all relative mount points.
* tests/df/skip-duplicates.sh: Add an entry to test relative dirs.
2014-05-13 23:23:30 +01:00
Pádraig Brady
fb902297f5 df: fix handling of symlinks in mount list
The symlink handling in commit v8.21-172-g33660b4 was incomplete
in the case where there were symlinks in the mount list itself.
For example, in the case where /dev/mapper/fedora-home was in the
mount list and that in turn was a symlink to /dev/dm-2, we have:

  before> df --out=source /dev/mapper/fedora-home
          devtmpfs

  after > df --out=source /dev/mapper/fedora-home
          /dev/mapper/fedora-home

* src/df.c (get_disk): Compare canonicalized device names from
the mount list.  Note we still display the non canonicalized name,
even if longer, as we assume that is the most representative.
* tests/df/df-symlink.sh: This could theoretically fail on some systems
depending on the content of the mount list, but adjust to fail on any
system where symlinks are present in the mount list for the current dir.
2014-05-13 23:23:30 +01:00
Pádraig Brady
2dc5d044a8 df: also deduplicate virtual file systems
* src/df.c (filter_mountlist): Remove the constraint that
a '/' needs to be in the device name for a mount entry to
be considered for deduplication.  Virtual file systems also
have storage associated with them (like tmpfs for example),
and thus need to be deduplicated since they will be shown
in the default df output and subject to --total processing also.
* test/df/skip-duplicates.sh: Add a test to ensure we deduplicate
all entries, even for virtual file systems.  Also avoid possible
length operations on many remote file systems in the initial
check of df operation.  Also avoid the assumption that "/root"
is on the same file system as "/".
* NEWS: Mention the change in behavior.
2014-05-13 23:23:30 +01:00
Pádraig Brady
6b3003a9da tests: fix spurious failure with leading spaces in file names
* tests/ls/stat-vs-dirent.sh: This test lists all parent directories,
and would spuriously fail if any of those had a file name with a
leading space as the first entry.  There is only ever a single space
between the right aligned inode number and the file name, so
process accordingly.
2014-05-13 09:58:33 +01:00
Assaf Gordon
2ccc60a28e build: avoid bootstrap error with gettext 0.18.3.1
* bootstrap: Create critical bootstrap files for autopoint,
before gnulib re-generates them, avoiding the issue.  See:
http://lists.gnu.org/archive/html/coreutils/2013-11/msg00038.html
http://savannah.gnu.org/bugs/?40083
https://pad.lv/1311895
2014-05-12 19:14:34 +01:00
Jim Meyering
d7cfcbef7e shred: don't infloop upon negative size
* src/shred.c (main): With the preceding change, shred -s-2 FILE
would write 64KB blocks forever -- or until disk full. This change
makes shred reject a negative size.
* tests/misc/shred-negative.sh: New file.
* tests/local.mk (all_tests): Add it.
2014-05-10 12:36:16 -07:00
Paul Eggert
a7603fa652 shred: fix overflow checking of command-line options
* src/shred.c (main): Limit -n (number of passes) value to
ULONG_MAX, not to UINT32_MAX, since the vars are unsigned long.
Limit the -s (file size) value to OFF_T_MAX.
2014-05-10 11:43:15 -07:00
Bernhard Voelker
03440189a0 tests: improve new ascii test of dd
* tests/dd/ascii.sh: Avoid unnecessary subshells.  Catch dd's
exit code.  Remove testing artifact.  In the case of a comparison
failure, show the differences in octal format in addition to
"binary files differ".  Simplify the creation of the 'in' file.
2014-05-07 18:42:03 +02:00
Paul Eggert
3974c0932d dd: fix conv=ascii, conv=ebcdic, conv=ibm to match POSIX
Problem reported by Don Baggett in <http:/bugs.gnu.org/17422>.
* NEWS:
* doc/coreutils.texi (dd invocation): Document this.
* src/dd.c (conversions): conv=ascii implies conv=unblock.
conv=ebcdic and conv=ibm imply conv=block.
(ascii_to_ebcdic, ebcdic_to_ascii): Correct to match
POSIX 1003.1-2013.
* tests/dd/ascii.sh: New file.
* tests/local.mk (all_tests): Add it.
2014-05-06 18:38:46 -07:00
Pádraig Brady
8840a00cd7 tests: improve diagnostics when asserting empty files
* tests/chmod/c-option.sh: Use `compare /dev/null ... || fail=1`
rather than `test -s ... && fail=1`, so that the file contents
are output, thus improving diagnostics for failing tests.
* tests/cp/acl.sh: Likewise.
* tests/cp/cp-a-selinux.sh: Likewise.
* tests/cp/cp-mv-enotsup-xattr.sh: Likewise.
* tests/cp/reflink-perm.sh: Likewise.
* tests/dd/misc.sh: Likewise.
* tests/misc/env-null.sh: Likewise.
* tests/misc/env.sh: Likewise.
* tests/misc/nice.sh: Likewise.
* tests/misc/nohup.sh: Likewise.
* tests/misc/printenv.sh: Likewise.
* tests/misc/xattr.sh: Likewise.
* tests/mv/update.sh: Likewise.
* tests/rm/deep-2.sh: Likewise.
* tests/rm/read-only.sh: Likewise.
* tests/split/r-chunk.sh: Likewise.
* tests/tail-2/follow-stdin.sh: Likewise.
* tests/tail-2/inotify-race.sh: Likewise.
* tests/tail-2/wait.sh: Likewise.
* tests/touch/no-dereference.sh: Likewise.

* cfg.mk (sc_prohibit_test_empty:): New syntax-check.
* tests/cp/proc-zero-len.sh: Adjust to avoid false syntax-check failure.
* tests/cp/proc-zero-len.sh: Likewise.
* tests/mv/part-symlink.sh: Likewise.
* tests/tail-2/infloop-1.sh: Likewise.
2014-05-07 00:06:00 +01:00
Pádraig Brady
0b04ff22ed mv,cp: preserve symlink xattrs when copying across file systems
* src/copy.c (copy_internal): Include the copy_attr() call for symlinks.
This should not dereference symlinks, since llistxattr() is used
in attr_copy_file() in libattr, and so should copy all but the filtered
extended attributes.  Note we don't just move the copy_attr() call
before the set_owner() call, as that would break capabilities
for non symlinks.
* tests/cp/cp-mv-enotsup-xattr.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/16131
2014-05-06 10:26:50 +01:00
Jarkko Sakkinen
a03a51c44c tests: initial SMACK tests
* init.cfg (require_smack_): New function.
* local.mk: Referenced new tests.
* tests/id/smack.sh: SMACK tests (new file).
* tests/mkdir/smack-no-root.sh: SMACK tests (new file).
* tests/mkdir/smack-root.sh: SMACK tests (new file).
2014-05-05 14:26:15 +01:00
Jim Meyering
7182e4470a maint: autotools-install: update tool version numbers to latest
* scripts/autotools-install (tarballs): Update to latest.
2014-05-04 14:50:58 -07:00
Jim Meyering
7514a315ef maint: don't let envvar setting break ChangeLog generation
* Makefile.am (gen-ChangeLog): Clear amend_git_log when we
don't set it, so that an envvar setting cannot cause trouble.
2014-05-03 09:31:46 -07:00
Pádraig Brady
be9f38bf6c numfmt: improve processing throughput by 800%
The devmsg() calls that took quote_n() arguments,
didn't normally output anything, but still incurred
the overhead of those quote_n() calls.

* src/numfmt.c (devmsg): Move the inline function
with _internal_ enablement check to...
* src/system.h: ...here as a variadic macro, with
the enablement check at the outer level.
* src/factor.c: As per numfmt.c but there is no
performance change in this case.
* NEWS: Mention the significant performance improvement.
2014-05-02 02:02:20 +01:00
Pádraig Brady
10a9652435 numfmt: support zero padding using --format="%010f"
* src/numfmt.c (setup_padding_buffer): Simplify the code by not
explicitly dealing with heap exhaustion.
(parse_format_string): Likewise.  Handle multiple grouping
modifiers as does the standard printf.  Handle the new leading
zero --format modifier.
(double_to_human): Use more defensive coding against overwriting
stack buffers.  Honor the leading zeros width.
(usage): Mention the leading zero --format modifier.
(main): Allow --padding in combo with a --format (width),
as the number of leading zeros are useful independent of
the main field width.
* doc/coreutils.texi (numfmt invocation): Likewise.
* tests/misc/numfmt.pl: Add new test cases.
* NEWS: Mention the improvement.
2014-05-02 01:59:31 +01:00
Pádraig Brady
59eacf2764 doc: clarify the pr --page-width descriptions
* doc/coreutils.texi (pr invocation): Clarify that -w or -W
will be rounded down so that each column has the same width.
Adjust the wording for -W, to avoid the implication that the
width of -S is insignificant to the page width.
* src/pr.c (usage): Add a period to avoid ambiguity in
the man page output.
2014-04-29 19:33:41 +01:00
Pádraig Brady
f940fece04 ptx: fix whitespace trimming with multiple files
This issue was identified by running the test suite with
http://code.google.com/p/address-sanitizer/
which is included in GCC 4.8 and enabled with -fsanitize=address

This was checked on Fedora 20 with GCC 4.8 as follows:

  $ yum install libasan  # http://bugzilla.redhat.com/991003
  $ rm -f src/ptx.o
  $ make check AM_CFLAGS='-fsanitize=address' SUBDIRS=. VERBOSE=yes
  $ failure identified in tests/test-suite.log

To see this particular failure triggered with multiple files:

  $ src/ptx <(echo a) <(echo a) 2>&1 | asan_symbolize.py -d

=================================================================
==32178==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x60200000e74f at pc 0x435442 bp 0x7fffe8a1b290 sp 0x7fffe8a1b288
READ of size 1 at 0x60200000e74f thread T0
    #0 0x435441 in define_all_fields coreutils/src/ptx.c:1425
    #1 0x7fa206d31d64 in __libc_start_main ??:?
    #2 0x42f77c in _start ??:?
0x60200000e74f is located 1 bytes to the left of 3-byte region
[0x60200000e750,0x60200000e753) allocated by thread T0 here:
    #0 0x421809 in realloc ??:?
    #1 0x439b4e in fread_file coreutils/lib/read-file.c:97
Shadow bytes around the buggy address:
  0x0c047fff9c90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9ca0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9cb0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9cc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9cd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fd fd
=>0x0c047fff9ce0: fa fa 03 fa fa fa fd fd fa[fa]03 fa fa fa 00 00
  0x0c047fff9cf0: fa fa 04 fa fa fa 04 fa fa fa fd fa fa fa fd fa
  0x0c047fff9d00: fa fa 00 fa fa fa fd fa fa fa 00 fa fa fa 00 fa
  0x0c047fff9d10: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff9d20: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff9d30: fa fa fd fa fa fa 00 fa fa fa 00 fa fa fa 00 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:     fa
  Heap right redzone:    fb
  Freed heap region:     fd
  Stack left redzone:    f1
  Stack mid redzone:     f2
  Stack right redzone:   f3
  Stack partial redzone: f4
  Stack after return:    f5
  Stack use after scope: f8
  Global redzone:        f9
  Global init order:     f6
  Poisoned by user:      f7
  ASan internal:         fe
==32178==ABORTING

The initial report and high level analysis were from Jim Meyering...

  "The underlying problem is that swallow_file_in_memory()
  is setting the contents of the global text_buffer for the first file,
  then updating it (clobbering old value) for the second file.
  Yet, some pointers to the initial buffer have been squirreled away
  and later, one of them (keyafter) is presumed to point into
  the new "text_buffer", which it does not.  The subsequent
  SKIP_WHITE_BACKWARDS use backs up "cursor" and goes out of bounds."

* src/ptx.c (text_buffers): Maintain references for the limits of each
buffer corresponding to each file, rather than just the last processed.
(struct OCCURS): Add a member to map back to the corresponding file.
Note normally this could be computed from the "reference" member
rather than needing the extra storage, however this is not possible
when in --references mode.
(find_occurs_in_text): Reference the array rather than a single entry.
(define_all_fields): Likewise.  Also avoid computing the file index
since this is now stored directly.
(main): Update text_buffers[] array rather than a single text_buffer.
* tests/misc/ptx-overrun.sh: Even though this issue is already triggered
with AddressSanitizer, add a new case to demonstrate the whitespace
trimming issue, and to trigger without AddressSanitizer.
Fixes https://bugs.gnu.org/16171
2014-04-29 09:50:58 +01:00
Pádraig Brady
2f8d53a798 maint: make ChangeLog generation more robust
* Makefile.am (gen-ChangeLog): Sync changes from GNU hello,
to ensure exit status is propagated, and to support an optional
git-log-fix file.
2014-04-25 01:27:07 +01:00
Edgars Irmejs
0c6928f703 maint: remove trailing comma from enum to make gl/ c89 compat
* gl/lib/fadvise.c (fadvice_t): This might go to gnulib some day so
remove the trailing comma.
Fixes http://bugs.gnu.org/17329
2014-04-25 01:25:44 +01:00
Assaf Gordon
ea55db1a23 doc: clarify meaning of stat's mtime and ctime formats
* src/stat.c (usage): s/modification time/data modification time/;
s/change time/status change time/
* doc/coreutils.texi: Ditto.
2014-04-22 16:53:47 +01:00
Pádraig Brady
14613e2fd1 tests: make ls tests independent of COLORTERM env
Since the recent commit v8.22-68-g08783f1, ls coloring
is now dependent on the COLORTERM environment variable.

* tests/envvar-check: Unset COLORTERM from test environment.
* tests/ls/color-dtype-dir.sh: Ensure coloring is used.
* tests/misc/ls-misc.pl: Likewise.

Prompted by the continuous integration build failure at:
http://hydra.nixos.org/build/10397646
2014-04-18 11:23:37 +01:00
Pádraig Brady
f6bcfef3d2 doc: disambiguate chmod man page reference to (a) users
* man/chmod.x: Don't rely on the bold markup for 'a' to
distinguish it as that's not done in all cases.
2014-04-17 20:54:02 +01:00
David Michael
ce74356bae dircolors: add hurd and mach-gnu-color terminal types
mach-color was replaced by mach-gnu-color in Hurd in 2012.
mach-color is left for compatibility and corresponding
definitions for mach-color are still found in ncurses.

* src/dircolors.hin: Add hurd and mach-gnu-color.
2014-04-17 20:52:19 +01:00
Guilherme de Almeida Suckevicz
08783f100f ls: don't output colors with unknown TERM env variable
--colors controls whether to output colors depending on
whether we're connected to a terminal or not, while this
change gives control over which terminals we output colors to.

* NEWS: Mention the change in behavior.
* src/ls.c (known_term_type): A new function to search the static
list from dircolors.h
(parse_ls_colors): Honor the TERM when both LS_COLORS and COLORTERM
are non empty.
* tests/ls/color-term.sh: A new test.
* tests/local.mk: Reference the new test.
Fixes http://bugs.gnu.org/15992
2014-04-17 02:16:04 +01:00
Benno Schulenberg
943f3592ca doc: improve remove prompt translator comment
* src/remove.c (prompt): Explain where the difficulty with translating
these two strings resides, and suggest an alternative: the one that
Paul Eggert first proposed back in 2002, which seems fully resistant.
2014-04-16 23:34:42 +01:00
Bernhard Voelker
02807c611e maint: df: avoid sizeof(char**) static analysis warning
* src/df.c (alloc_table_row): Use the size of char** to enlarge
the table.  Spotted by Coverity.
2014-04-16 10:43:09 +02:00
Pádraig Brady
7c03fe2c9f tests: fix false dd conv=sparse failure on newer XFS
* tests/dd/sparse.sh: When testing that a hole is created,
use an existing sparse destination file, so that we're
not write extending the file size, and thus avoiding
speculative preallocation which can result in smaller
holes than requested.
Workaround suggested by Brian Foster
2014-04-11 23:52:08 +01:00
Pádraig Brady
e9cb3eb6ce maint: avoid static analysis warnings in ln.c
* src/ln.c (do_link): It's not obvious that record_file() is a noop
in the symlink case (in that case dest_set is NULL and so ignored).
So to make it obvious, and to avoid false positives seen in coverity,
add the explicit condition here.
2014-04-10 17:11:25 +01:00
Pádraig Brady
d2980924ac maint: document timeout --preserve-status in v8.21 NEWS
* NEWS: Add the omitted new feature.
* cfk.mk (old_NEWS_hash): Adjust accordingly.
2014-04-09 22:13:52 +01:00
Pádraig Brady
30acfcab50 doc: clarify in --help that -Z doesn't take an argument
* NEWS: Fix a confusing old entry.
* cfg.mk (old_NEWS_hash): Adjust accordingly.
* src/cp.c (usage): Separate the -Z and --context descriptions.
* src/install.c: Likewise.
* src/mkdir.c: Likewise.
* src/mkfifo.c: Likewise.
* src/mknod.c: Likewise.
Fixes http://bugs.gnu.org/17220
2014-04-09 14:17:06 +01:00
Pádraig Brady
d695bc8bc6 maint: various cleanups
* tests/misc/numfmt.pl: Fix comment misspelling.
* src/cut.c: Likewise.
* src/tsort.c (detect_loop): Replace an fprintf() with error().
2014-04-05 01:59:39 +01:00
Pádraig Brady
b85eb8d683 shred: overwrite inode storage used by some file systems
* doc/coreutils.texi (shred invocation): Mention some reasons
why clearing slack space might be useful.
* src/shred.c (do_wipefd): Add initial writes for each pass
for small regular files in case the storage for those is
in the inode, and thus a larger write up to a block size would
bypass that.  Move the direct I/O control to...
(dopass): ... here so we can avoid enabling it for these small
initial writes.  It's better to retry direct I/O for each pass
anyway to handle the case where direct I/O is disabled for only
the last portion of a file when the size is not a multiple of
the block size.  Note we don't avoid the sync for the initial
write as it will be small but more importantly could be on a
different part of the disk and so worth doing independently
to ensure the write is not discarded.
* tests/misc/shred-exact.sh: Check some more direct I/O cases.
* NEWS: Mention the improvements.
The inode storage issue was mentioned by Paul Eggert.
2014-04-05 01:56:07 +01:00
Pádraig Brady
217618e8bf shred: avoid a data pass on empty files
* src/shred.c (do_wipefd): Don't increase the size written
for an empty file up to a full block.  Also increase the size
to OFF_T_MAX in the edge case where we do overflow.
* NEWS: Mention the shred improvements from recent changes.
* tests/misc/shred-passes.sh: Adjust as we no longer
write a BLKSIZE of data for empty files.
2014-04-04 05:32:41 +01:00
Paul Eggert
d0294ff3b9 cp: don't reserve a device number
* src/copy.c (copy_internal): Replace dev_t arg DEVICE with struct
stat pointer arg PARENT.  All callers changed.  This removes an
unwarranted assumption that dev_t values of 0 cannot occur in file
systems.  See: http://bugs.gnu.org/17179
2014-04-03 09:48:52 -07:00
Paul Eggert
7c3e6be6d7 shred: shred one block even for empty files
* src/shred.c (do_wipefd): Shred one block of empty regular files.
This reverts an unintended part of the previous change.
2014-04-03 09:43:20 -07:00
Paul Eggert
88545ad025 shred: port to GNU/Linux behavior with tape drives
See: http://bugs.gnu.org/17149
* src/shred.c [__linux__]: Include <sys/mtio.h>.
(dorewind): New function, which works around the lseek problem with
tape drives on GNU/Linux, the same way that dd does.
(dopass): Use it.  New arg ST, needed for dorewind.  All uses changed.
(do_wipefd): Don't rely on undefined behavior on integer overflow
of file sizes.  Use INT_ADD_OVERFLOW instead.
2014-04-02 23:28:59 -07:00
Paul Eggert
9111dd2499 head: port to Darwin and use simpler seeks
This removes an unportable assumption that if lseek succeeds, the
file is capable of seeking.  See: http://bugs.gnu.org/17145
* src/head.c (elseek): New function, for consistency in reporting
lseek failures.
(elide_tail_bytes_file, elide_tail_lines_seekable)
(elide_tail_lines_file, head_lines, head): Use it.
(elide_tail_bytes_file, elide_tail_lines_file):
New args CURRENT_POS and SIZE.  All uses changed.  Don't bother
invoking lseek, since we know the file's pos and size now.
(elide_tail_bytes_file): Change a local from uintmax_t to off_t,
since it fits.
(head): Use lseek only on regular files, since its behavior on
unseekable devices is implementation-defined.
* NEWS: Document this.
2014-04-02 07:45:58 -07:00
Paul Eggert
d08381bc26 head: fix bug with head -c-N when stdin is not at start
* src/head.c (elide_tail_bytes_file): Fix typo in lseek invocation.
* tests/misc/head-c.sh: Add test for this bug.
* NEWS: Document this.
2014-03-31 10:24:07 -07:00
Pádraig Brady
2d8ae88a22 mv: fix issues with previous prompt adjustments
* src/copy.c (overwrite_ok): Fix the gettext calls so
that the second string is tagged for translation.
Display the correct "replace ..." prompt when in move_mode.
* tests/mv/i-3.sh: Display the output on failure to ease debugging.
2014-03-26 08:23:23 -07:00
Bernhard Voelker
5de5d8a5c0 ptx: avoid --format long option falling through into --help
* src/ptx.c (main): Add a 'break' after the --format handling case.
Otherwise it would fall through into the usage case.
* tests/misc/ptx.pl: Add test cases for --format=tex and --format=roff.
* NEWS (Bug fixes): Mention the fix.
Bug introduced in 1999-04-04 commit, SH-UTILS-1_16f-269-gd815c15.
Spotted by coverity (MISSING_BREAK).
2014-03-26 11:29:53 +01:00
Bernhard Voelker
25c2f0d617 basename: mention that the -s option implies -a in usage
* src/basename.c (usage): Mention that -s implies -a.
(main): Add "fall through" comment to case 's'.

Spotted by coverity: MISSING_BREAK.
2014-03-26 11:26:58 +01:00
Paul Eggert
7f669b40c9 cp: simplify overwrite logic
* src/copy.c (overwrite_ok): Rename from overwrite_prompt.  Invoke
yesno instead of having the caller do it; that's cleaner.  Return
bool, not void.  All callers changed.
2014-03-24 23:18:41 -07:00
Paul Eggert
4b25fdbdab cp: improve quality of overwrite prompt
* src/copy.c (overwrite_prompt): New arg X.  All callers changed.
Use X to improve the quality of the prompt (Bug#17087).
* tests/mv/i-2.sh, tests/mv/i-3.sh: Change test to match new prompt.
2014-03-24 23:18:41 -07:00
Pádraig Brady
5f9a5b3f03 split: avoid unnecessary input buffering
Input buffering is best avoided because it introduces
delayed processing of output for intermittent input,
especially when the output size is less than that of
the input buffer.  This is significant when output
is being further processed which could happen if split
is writing to precreated fifos, or through --filter.

If input is arriving quickly from a pipe then this will
already be buffered before we read it, so fast arriving
input shouldn't be a performance issue.

* src/split.c (lines_split, lines_bytes_split, bytes_split,
lines_chunk_split, bytes_chunk_extract): s/full_read/safe_read/.
* THANKS.in: Mention the reporter.
* NEWS: Mention the improvement.
2014-03-24 09:10:20 +00:00
Pádraig Brady
b010481e1f doc: clarify the operation of uniq -uD
The description of -u was inaccurate when combined with -D:

  $ printf '%s\n' '1 a' '2 a' | uniq -uD -f1
  1 a

* doc/coreutils.texi (uniq invocation): Clarify that it's
the last repeated line that is suppressed from the output.

Fixes http://bugs.gnu.org/17022
2014-03-19 19:07:53 +00:00
Edward Welbourne
c9e410761d doc: avoid regex ambiguity in chmod mode description
* man/chmod.x: s/[+-=]/[-+=]/
* doc/perm.texi (Symbolic Modes): Likewise.
* THANKS.in: Remove patch owner.
Fixes http://bugs.gnu.org/17041
2014-03-19 19:07:44 +00:00
Pádraig Brady
137a423975 chroot: always diagnose failure to set supplemental groups
* src/chroot.c (setgroups): Change this replacement to
fail when called so that platforms like Interix without support for
supplemental groups don't silently ignore a --groups option.
2014-03-19 02:41:24 +00:00
Dylan Simon
09eda9ed9d chmod: fix erroneous warnings with -R --changes
For files with "special" bits set, we would stat the relative
file name in the wrong directory, giving an erroneous ENOENT diagnostic.
This issue was introduced with commit v5.92-653-gc1994c1
which changed fts to not change directory on traversal.

* src/chmod.c (mode_changed): Use fts->fts_cwd_fd with fstatat rather
than stat.  All callers changed.
* tests/chmod/c-option.sh: Add a test case.
* NEWS: Mention the fix.
Fixes http://bugs.gnu.org/17035
2014-03-19 02:33:44 +00:00
Bernhard Voelker
5b790fda0e maint: fix typo in comment in fadvise.c
* gl/lib/fadvise.c: s/the the/the/, indroduced in commit
v8.22-40-g4f21182.  Promted by sc_prohibit_doubled_word.
While at it, also s/be candidate/be a candidate/.
2014-03-19 00:44:44 +00:00
Paul Eggert
ea916c70a5 stat: port birthtime to Solaris 11
Problem reported by Rich Burridge.
* src/stat.c [HAVE_GETATTRAT]: Include <attr.h>, <sys/nvpair.h>.
(print_statfs, print_stat, print_it):
Pass fd, too, for the benefit of get_birthtime.
All uses changed.
(get_birthtime): New function, for porting to Solaris 11.
(print_stat): Use it.

* configure.ac (getattrat, LIB_NVPAIR): New checks.
* src/local.mk (src_stat_LDADD): Add $(LIB_NVPAIR).
2014-03-18 16:12:48 -07:00
Jim Meyering
0093ac8d57 ln: with -sr, don't segfault for a TARGET of ''
Prior to this change, "ln -sr '' F" would segfault, attempting
to read path2[1] in relpath.c's path_common_prefix function.
This problem arises whenever canonicalize_filename_mode returns
NULL.
* src/ln.c (convert_abs_rel): Call relpath only when
both canonicalize_filename_mode calls return non-NULL.
* tests/ln/relative.sh: Add a test to trigger this failure.
* THANKS.in: List reporter's name/address.
* NEWS (Bug fixes): Mention it.
Reported by Erik Bernstein in 739752@bugs.debian.org.
Fixes http://bugs.gnu.org/17010.
2014-03-13 20:05:10 -07:00
Jim Meyering
4f211822dd maint: avoid "attribute-const"-suggesting warning from gcc
* gl/lib/fadvise.c: Use a pragma to turn off this warning option:
-Wsuggest-attribute=const.  Without this change, building with
--enable-gcc-warnings would evoke this error:

    lib/fadvise.c:25:1: error: function might be candidate for\
    attribute 'const' [-Werror=suggest-attribute=const]
2014-03-13 10:15:28 -07:00
Jim Meyering
42d2377b81 scripts: autotools-install: update
* scripts/autotools-install: Update version numbers of latest
automake and gettext packages.
2014-03-13 10:15:28 -07:00
Pádraig Brady
e972be3c4b chroot: improve --userspec and --groups look-up
- Support arbitrary numbers in --groups, consistent with
  what is already done for --userspec
- Avoid look-ups entirely for --groups items with a leading '+'
- Support names that are actually numbers in --groups
- Ignore an empty --groups="" option for consistency with --userspec
- Look up both inside and outside the chroot with inside taking
  precedence.  The look-up outside may load required libraries
  to complete the look-up inside the chroot.  This can happen for
  example with a 32 bit chroot on a 64 bit system, where the
  32 bit NSS plugins within the chroot fail to load.

* src/chroot.c (parse_additional_groups): A new function refactored
from set_addition_groups(), to just do the parsing.  The actual
setgroups() call is separated out for calling from the chroot later.
(main): Call parse_user_spec() and parse_additional_groups()
both outside and inside the chroot for the reasons outlined above.
* tests/misc/chroot-credentials.sh: Ensure arbitrary numeric IDs
can be specified without causing look-up errors.
* NEWS: Mention the improvements.
* THANKS.in: Add Norihiro Kamae who initially reported the issue
with a proposed patch.
Also thanks to Dmitry V. Levin for his diagnosis and sample patch.
2014-03-13 14:07:45 +00:00
Aleksej Serdjukov
08140ecd48 doc: fix typo in texinfo docs
* doc/coreutils.texi (Operating on characters): s/This/These/.
Fixes http://bug.gnu.org/16973
2014-03-09 17:53:00 +00:00
Pádraig Brady
b929b7ba53 doc: fix readpath typo in texinfo contents
* docs/coreutils.texi: s/readpath/realpath/
Fixes http://bugs.gnu.org/16964
2014-03-07 18:06:44 +00:00
Pádraig Brady
056d6de78f tests: avoid the :> construct which can hide errors
On most shells `:>file || framework_failure_` will not evaluate
the framework_failure_ even if there was an error writing the file.
shells which do evaluate the failure are ksh 93u+ and bash 4.2,
while shells wich don't include bash 4.3, solaris, freebsd, dash.

Furthermore this construct is problematic on Solaris 10 sh,
which will try to optimize away a `:' command in a loop
after the first iteration, even if it is redirected.

* tests/cp/link-deref.sh: Remove the leading colon on redirections.
* tests/cp/reflink-perm.sh: Likewise.
* tests/id/zero.sh: Likewise.
* tests/install/install-C.sh: Likewise.
* tests/misc/env.sh: Likewise.
* tests/misc/md5sum-bsd.sh: Likewise.
* tests/misc/runcon-no-reorder.sh: Likewise.
* tests/mv/partition-perm.sh: Likewise.
* tests/rm/r-root.sh: Likewise.
* tests/split/l-chunk.sh: Likewise.
* tests/split/line-bytes.sh: Likewise.
* tests/tail-2/inotify-rotate.sh: Likewise.
* tests/tail-2/retry.sh: Likewise.
* tests/tail-2/symlink.sh: Likewise.
* tests/tail-2/wait.sh: Likewise.
* tests/touch/read-only.sh: Likewise.
+ cfg.mk (sc_prohibit_colon_redirection): A new syntax check
to avoid further instances of this creeping in.
2014-03-05 19:02:20 +00:00
Pádraig Brady
5dce6bdfaf tests: fix false failure in nohup.sh in non tty builds
* tests/misc/nohup.sh: When running tests without a controlling tty,
an exec failure is triggered in a subshell, which causes POSIX
shells to immediately exit the subshell.  This was brought
to notice by the newly conforming bash 4.3.
Fixes http:/bugs.gnu.org/16940
2014-03-05 18:08:17 +00:00
Pádraig Brady
849c1c5b16 doc: improve df --human and --si, help and man page
* src/df.c (usage): Adjust the --human and --si descriptions
to not depend on each other.  Also include an example that is
illustrative of the rounding, suffix, width, and localized fractions.
* src/system.h (emit_size_note). Adjust so that it's obvious the
description is pertaining to the input SIZE argument, and not
to any sizes that might be output by df for example.
Fixes http://bugs.gnu.org/16922
2014-03-03 16:39:18 +00:00
Pádraig Brady
a4faa6a0a3 date: fix crash or infinite loop when parsing a malformed TZ=""
* NEWS: Mention the fix.
* gnulib: Update to incorporate the fix.
This is the only change in this gnulib update.
* tests/misc/date.pl: Add a test for this case.

Fixes http://bugs.gnu.org/16872
2014-02-27 23:56:28 +00:00
Paul Eggert
7bbfd17355 cp: copy files by inode only if that facility is available
* src/copy.c (copy_dir): Use the new SAVEDIR_SORT_FASTREAD, not
SAVEDIR_SORT_INODE.  Problem reported by Bernhard Voelker in:
http://lists.gnu.org/archive/html/coreutils/2014-02/msg00037.html
2014-02-27 00:07:59 -08:00
Paul Eggert
9946f5cae0 build: update gnulib submodule to latest 2014-02-27 00:07:42 -08:00
Paul Eggert
069723c5ee cp: copy files by inode
Problem reported by Bernhard Voelker in:
http://lists.gnu.org/archive/html/coreutils/2014-02/msg00034.html
* src/copy.c (copy_dir): Adjust to recent gnulib change.
2014-02-26 11:31:25 -08:00
Paul Eggert
f81a79f194 build: update gnulib submodule to latest 2014-02-26 11:31:19 -08:00
Bernhard Voelker
5475e6083f shuf: convert error diagnostic to lowercase
* src/shuf.c (main): s/No/no/, introduced by commit v8.22-25-g9f60f37.
* NEWS: Also adjust the NEWS for that recent commit to make it
clear this was new bug rather than a regression.

Prompted by the syntax-check rule sc_error_message_uppercase
2014-02-26 11:26:24 +00:00
Bernhard Voelker
df5e69705f doc: add dd example for failing disks
* doc/coreutils.texi (dd invocation): Add an example for how to call
dd to save data from a failing disk.  Mention GNU 'ddrescue' as one
of the more specialized tools in such a case.
2014-02-26 07:55:04 +01:00
Paul Eggert
9f60f37a28 shuf: with -r, don't dump core if the input is empty
Problem reported by valiant xiao in <http://bugs.gnu.org/16855>.
* NEWS: Document this.
* src/shuf.c (main): With -r, report an error if the input is empty.
* tests/misc/shuf.sh: Test for the bug.
2014-02-23 15:35:27 -08:00
Paul Eggert
85c925ef54 doc: fix problems with @w and @kbd (Bug#16802)
* doc/coreutils.texi: Prefer '@allowcodebreaks false' to '@w'.
Also, don't use @kbd except for keyboard input.
2014-02-20 18:24:33 -08:00
Pádraig Brady
9654b67a54 cp: with --link always use linkat() if available
* src/copy.c (copy_reg): If linkat() is available it doesn't
matter about the gnulib emulation provided, and thus the
LINK_FOLLOWS_SYMLINKS should not have significance here.
This was noticed on FreeBSD and the consequence is that
cp --link will create hardlinks to symlinks there, rather
than emulating with symlinks to symlinks.
* tests/cp/link-deref.sh: Adjust the checks to cater
for all cases where hardlinks to symlinks are supported.
2014-02-10 10:02:34 +00:00
Pádraig Brady
6e824a6619 head,tail: consistently diagnose write errors
If we can't output more data, we should immediately
diagnose the issue and exit rather than consuming all
of input (in some cases).

* src/tail.c (xwrite_stdout): Also diagnose the case where
only some data is written.  Also clearerr() to avoid the
redundant less specific error from atexit (close_stdout);
* src/head.c (xwrite_stdout): Copy this new function from tail,
and use it to write all output.
* tests/misc/head-write-error.sh: A new test to ensure we
exit immediately on write error.
* tests/local.mk: Reference the new test.
2014-02-09 21:37:24 +00:00
Алексей Шилин
476ce37019 head: fix --lines=-0 outputting nothing if no newline at EOF
* src/head.c (elide_tail_lines_pipe): Just output all input in
this case to avoid the issue and also avoid redundant '\n' processing.
(elide_tail_lines_seekable): Likewise.
* tests/misc/head-elide-tail.pl: Add tests for no '\n' at EOF.
* NEWS: Mention the fix.
Fixes http://bugs.gnu.org/16329
2014-02-09 20:22:33 +00:00
John
17d92a9106 dircolors: add a new entry to colorize 'm4a' files
* src/dircolors.hin: Add entry for mpeg4 audio files.
Fixes http://bugs.gnu.org/16700
2014-02-09 20:07:41 +00:00
Niels Möller
b370924c03 od: add an --endian option to control byte swapping
* src/od.c (main): Handle the new --endian option,
taking "little" and "big" as parameters.
(usage): Describe the new option.
(PRINT_FIELDS): Adjust to swap bytes if required.
* tests/misc/od-endian.sh: A new test to verify
the byte swapping operations for hex (ints) and floats
for all sizes between 1 and 16 inclusive.
* test/local.mk: Reference the new test.
* doc/coreutils.texi (od invocation): Describe the new option.
* NEWS: Mention the new feature.
2014-02-09 11:29:24 +00:00
Pádraig Brady
b938b6e289 stat,tail: improve support for HFS+ and HFSX
* src/stat.c (human_fstype): Add new file system ID definitions.
* NEWS: Mention the improvement.
Fixes http://bugs.gnu.org/16336
2014-01-29 01:17:53 +00:00
Assaf Gordon
9bc386382c tests: skip chown/separator with conflicting group IDs
* tests/chown/separator.sh: skip test if the user's group has
multiple entries.
Fixes http://bugs.gnu.org/16532
2014-01-24 17:14:04 +00:00
Pádraig Brady
be97f3e0ef build: suppress an erroneous warning --with-selinux=no
* m4/jm-macros.m4: Don't check the SELinux cached variables
--without-selinux.
Reported-by: Bernhard Voelker
2014-01-21 11:03:34 +00:00
Pádraig Brady
9a115f3e24 build: remove no longer used spawn-pipe files from POTFILES.in
This should have been part of the previous commit v8.22-14-gf18999b

* po/POTFILES.in: Remove gnulib files no longer used.
Prompted by the continuous integration build failure at:
http://hydra.nixos.org/build/8288209/
2014-01-17 17:33:01 +00:00
Pádraig Brady
f18999b4c5 build: avoid unneeded spawn-pipe gnulib module
* bootstrap.conf: Reference the used pipe-posix module
rather than the uneeded and larger spawn-pipe module,
which the pipe module is the deprecated equivalent of.
2014-01-17 16:25:30 +00:00
Chengwei Yang
6fab28dce4 doc: clarify SMACK related --help and documentation
* src/ls.c: Remove all mention of SELinux since ls
should treat all security context labels equally.
* doc/coreutils.texi (ls invocation): Likewise.
(id invocation): Clarify that -Z outputs the context
inherited by the process, rather than one specific to a user.
Note for SMACK this can be set instead by the SMACK64EXEC label,
in the unusual case where this is set on the id executable.
* src/id.c (usage): Likewise.
* src/mkdir.c (usage): Clarify that -Z is specific to SELinux,
while --context=CTX is also supported for SMACK.
* src/mkfifo.c (usage): Likewise.
* src/mknod.c (usage): Likewise.
2014-01-17 16:13:18 +00:00
Pádraig Brady
7fa1641db0 ln: fix replacing symbolic links whose targets can't exist
* src/ln.c (errno_nonexisting): A new function to determine if
the errno implies that a file doesn't or can't (currently) exist.
(target_directory_operand): Use the new function to expand the
set of errors we handle.
* tests/ln/sf-1.sh: Add test cases for the newly handled errors.
* THANKS.in: Mention the reporter.
* NEWS: Mention the bug fix.
2014-01-17 11:52:42 +00:00
Pádraig Brady
745de6dca5 tests: restrict a recent SELinux test to SELinux systems
* tests/cp/no-ctx.sh: Since the test diagnoses whether the
intercepted lgetfilecon() calls are actually called or not,
restrict the test to systems where that occurs.
The test cases are minimal on non SELinux systems and should
be well covered by other tests.
Reported-by: Bernhard Voelker
2014-01-14 13:51:15 +00:00
Nicolas Iooss
d718331e59 copy: fix a segfault in SELinux context copying code
* src/selinux.c (restorecon_private): On ArchLinux the
`fakeroot cp -a file1 file2` command segfaulted due
to getfscreatecon() returning a NULL context.
So map this to the sometimes ignored ENODATA error,
rather than crashing.
* tests/cp/no-ctx.sh: Add a new test case.
* tests/local.mk: Reference the new test.
* NEWS: Mention the fix.
Fixes http://bugs.gnu.org/16335
2014-01-13 23:11:37 +00:00
Pádraig Brady
ba25b75dc2 maint: tests: refactor gcc commands for building shared lib
* init.cfg (gcc_shared_): A new function refactored from tests.
(require_gcc_shared_): Adjust to call gcc_shared_() to build the
test library, and remove that library before the function returns.
* tests/cp/nfs-removal-race.sh: Call the new gcc_shared_().
* tests/df/no-mtab-status.sh: Likewise.
* tests/df/skip-duplicates.sh: Likewise.
* tests/ls/getxattr-speedup.sh: Likewise.
* tests/rm/r-root.sh: Likewise.
2014-01-13 23:11:17 +00:00
Pádraig Brady
243128dbf0 copy: fix SELinux context preservation for existing directories
* src/copy.c (copy_internal): Use the global process context
to set the context of existing directories before they're populated.
This is more consistent with the new directory case, and fixes
a bug for existing directories where we erroneously set the
context to the last copied descendent, rather than to that of
the source directory itself.
* tests/cp/cp-a-selinux.sh: Add a test for this case.
* NEWS: Mention the fix.
* THANKS.in: Add reporter Michal Trunecka.
2014-01-13 12:52:26 +00:00
Bernhard Voelker
5d7591d0ed tests: improve test for a working setfacl
Prompted by a test framework failure of tests/mkdir/p-acl.sh on armv7l:
The previous test for a working setfacl was not sufficient in some
circumstances.

* init.cfg (require_setfacl_): Call setfacl twice with conflictive
ACL specs, and use ACL specs which can't be mapped into regular file
permission bits.  Document the reasons.
2014-01-10 16:48:25 +01:00
Bernhard Voelker
d134211979 tests: avoid FP failure when cp fails for /proc/cpuinfo
On emulated aarch64 systems like in the qemu-based OpenBuildService
of openSUSE, cp fails to copy /proc/cpuinfo because the inode number
changes between the initial stat() call and copying the file:

  $ cp /proc/cpuinfo exp
  cp: skipping file '/proc/cpuinfo', as it was \
  replaced while being copied

* tests/cp/proc-zero-len.sh: When cp fails, check on the above
error message to skip the test.
2014-01-09 02:14:17 +01:00
Bernhard Voelker
299924fc22 maint: fix copyright holder and year in selinux sources
* src/selinux.c: As the copyright is assigned to the FSF for all
of coreutils, replace the copyright holder from "Red Hat, Inc."
to "Free Software Foundation, Inc.".  Prompted by a warning of
'make update-copyright'.  Also update the copyright year.
2014-01-02 22:20:08 +01:00
Bernhard Voelker
275c078fb4 maint: update all copyright year number ranges
Run "make update-copyright", but then also run this,
  perl -pi -e 's/2\d\d\d-//' tests/sample-test
to make that one script use the single most recent year number.
2014-01-02 22:19:59 +01:00
Bernhard Voelker
68f96c0db1 maint: prevent update-copyright from updating files from gnulib
The files 'bootstrap' and 'tests/init.sh' are taken from the
gnulib submodule.  Therefore, 'make update-copyright' there should
already have updated the copyright year in these 2 files.

* .x-update-copyright: Add entries for the above mentioned files.
2014-01-02 22:19:45 +01:00
Bernhard Voelker
fad018bac1 build: update gnulib submodule, bootstrap and tests/init.sh to latest
* gnulib: Update to latest.
* bootstrap: Update from gnulib.
* tests/init.sh: Likewise.
2014-01-02 20:31:07 +01:00
Pádraig Brady
c3e9f60a49 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2013-12-13 15:20:31 +00:00
1032 changed files with 62397 additions and 99148 deletions

85
.github/ISSUE_TEMPLATE.txt vendored Normal file
View File

@@ -0,0 +1,85 @@
Please **do not** send pull-requests or open new issues on Github.
Github is a downstream mirror and is not frequently monitored,
all development is coordinated upstream on GNU resources.
* Send general questions or suggestions to: coreutils@gnu.org .
* Send bugs reports to: bug-coreutils@gnu.org .
## Bug reports
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 behavior (which are often
mistaken for bugs).
* Online Manual:
https://www.gnu.org/software/coreutils/manual/html_node/index.html
* Search the archives for previous questions and answers:
* Coreutils Mailing list (General usage and advice):
https://lists.gnu.org/archive/html/coreutils/
* Bug reports Mailing List:
https://lists.gnu.org/archive/html/bug-coreutils/
* Open Bugs:
https://debbugs.gnu.org/cgi/pkgreport.cgi?which=pkg&data=coreutils
* Translation related issues:
https://translationproject.org/domain/coreutils.html
## Effective bug reports
* Include a descriptive subject line (e.g. the program with which
you experience a problem, and what the problem is).
* Include the version of the program (e.g. the output of `PROG --version`).
* Include the operating system and the type of hardware you are using
(e.g. the output of `uname -a`).
* Include the exact command and parameters you have used.
* Clearly explain what is the output you expected to get, and what is
the actual result you encountered.
* Include as much information as possible to reproduce the problem.
If the problem happens on a very large input file, try to provide
a minimal example (a subset of the input file) that still causes the problem.
*Do not* include attachments over 40kB.
* List policy is reply-to-all, and non-subscribers may post.
* There may be a moderation delay for a first-time post, whether or not
you subscribe.
## Mailing List Etiquette
When sending messages to coreutils@gnu.org or bug-coreutils@gnu.org :
* Send messages as plain text.
* Do not send messages encoded as HTML nor encoded as base64 MIME nor
included as multiple formats.
* Avoid sending large messages, such as log files, system call trace
output, and other content resulting in messages over about 40 kB.
* Avoid sending screenshots (e.g. PNG files). When reporting errors
you encounter on the terminal, copy and paste the text to your message.
<!--
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
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/>.
-->

105
.github/PULL_REQUEST_TEMPLATE.txt vendored Normal file
View File

@@ -0,0 +1,105 @@
Please *do not* send pull-requests or open new issues on Github.
See "hacking resources" below for recommended alternatives.
Github is a downstream mirror and is not frequently monitored,
all development is coordinated upstream on GNU resources.
* Send general questions or suggestions to: coreutils@gnu.org .
* Send bugs reports to: <bug-coreutils@gnu.org>
Before sending the bug, please consult the FAQ and Mailing list
archives (see below). Often these perceived bugs are simply due to
wrong program usage.
Please remember that development of Coreutils is a volunteer effort,
and you can also contribute to its development. For information about
contributing to the GNU Project, please read
[How to help GNU](https://www.gnu.org/help/].
## Getting Help
* 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 behavior (which are often
mistaken for bugs).
* Online Manual:
https://www.gnu.org/software/coreutils/manual/html_node/index.html
* Search the archives for previous questions and answers:
* Coreutils Mailing list (General usage and advice):
https://lists.gnu.org/archive/html/coreutils/
* Bug reports Mailing List:
https://lists.gnu.org/archive/html/bug-coreutils/
* Open Bugs: https://debbugs.gnu.org/cgi/pkgreport.cgi?which=pkg&data=coreutils
* Translation related issues:
https://translationproject.org/domain/coreutils.html
## Mailing List Etiquette
When sending messages to coreutils@gnu.org or bug-coreutils@gnu.org :
* Send messages as plain text.
* Do not send messages encoded as HTML nor encoded as base64 MIME nor
included as multiple formats.
* Include a descriptive subject line.
* Avoid sending large messages, such as log files, system call trace
output, and other content resulting in messages over about 40 kB.
* Avoid sending screenshots (e.g. PNG files). When reporting errors
you encounter on the terminal, copy and paste the text to your message.
* List policy is reply-to-all, and non-subscribers may post.
* There may be a moderation delay for a first-time post, whether or not
you subscribe.
## Hacking resources
files contain information about hacking and contributing to GNU coreutils:
https://git.savannah.gnu.org/cgit/coreutils.git/tree/HACKING
https://git.savannah.gnu.org/cgit/coreutils.git/tree/README-hacking
Please read them first.
Before suggesting a new feature, read the list of rejected features requests:
https://www.gnu.org/software/coreutils/rejected_requests.html
Send a patch as an email attachment. Patches can be generated with
`git format-patch` (the HACKING links above provide examples of generating
a patch).
## Copyright Assignment
If your change is significant (i.e., if it adds more than ~10 lines),
then you'll have to have a copyright assignment on file with the FSF.
To learn more see https://www.gnu.org/licenses/why-assign.html .
The HACKING file (above) contains more details about how to initial
the copyright assignment process. Coreutils maintainers can also help
in this matter.
<!--
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
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/>.
-->

70
.gitignore vendored
View File

@@ -1,15 +1,19 @@
*.I[12]
*.[EIOX]
*.[EIOXao]
*.bak
*.gcda
*.gcno
*.o
*/.deps/
*~
._bootmp
.deps
.gdb-history
.kludge-stamp
.version
/*.patch
/.Tpo
/.am*
/.re-list
/.sc-start-*
/ABOUT-NLS
/ChangeLog
/GNUmakefile
@@ -18,6 +22,7 @@
/aclocal.m4
/autom4te.cache
/build-aux/.gitignore
/build-aux/ar-lib
/build-aux/compile
/build-aux/config.guess
/build-aux/config.rpath
@@ -30,56 +35,83 @@
/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
/coreutils-*.tar.xz.sig
/doc/coverage
/doc/manual
/gnulib-tests
/lib/.dirstamp
/lib/.gitignore
/lib/alloca.h
/lib/arg-nonnull.h
/lib/arpa
/lib/binary-io.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/fts_.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
/lib/iconv_open-irix.h
/lib/iconv_open-osf.h
/lib/iconv_open-solaris.h
/lib/iconv_open-zos.h
/lib/inttypes.h
/lib/langinfo.h
/lib/libcoreutils.a
/lib/limits.h
/lib/link-warning.h
/lib/locale.h
/lib/malloc/
/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
/lib/printf.c
/lib/progname.c
/lib/progname.h
/lib/pthread.h
/lib/ref-add.sed
/lib/ref-del.sed
/lib/sched.h
/lib/se-context.h
/lib/se-label.h
/lib/se-selinux.h
/lib/selinux
/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
/lib/stdlib.h
/lib/string.h
@@ -87,13 +119,19 @@
/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
/lib/unitypes.h
/lib/uniwidth
/lib/uniwidth.h
/lib/unused-parameter.h
/lib/utime.h
/lib/warn-on-use.h
/lib/wchar.h
/lib/wctype.h
@@ -119,7 +157,6 @@
/m4/lib-link.m4
/m4/lib-prefix.m4
/m4/lock.m4
/m4/longlong.m4
/m4/nls.m4
/m4/po.m4
/m4/printf-posix.m4
@@ -155,10 +192,17 @@
/po/remove-potcdate.sed
/po/remove-potcdate.sin
/po/stamp-po
/src/coreutils.h
/src/coreutils_shebangs
/src/coreutils_symlinks
/src/crctab.c
/src/cu-progs.mk
/src/fs-def
/src/fs-kernel-magic
/src/fs-latest-magic.h
/src/make-prime-list
/src/fs-magic
/src/primes.h
/src/single-binary.mk
/src/version.c
/src/version.h
/stamp-h1
@@ -166,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,4 +1,5 @@
# Map git author names and email addresses to canonical/preferred form.
<jim@meyering.net> <meyering@meta.com>
<jim@meyering.net> <meyering@fb.com>
<jim@meyering.net> <meyering@iou.iou>
<jim@meyering.net> <meyering@redhat.com>
@@ -12,7 +13,7 @@ Paul Eggert <eggert@cs.ucla.edu> <eggert@CS.UCLA.EDU>
Evan Hunt <ethanol@armory.com> Evan Hunt <jim@meyering.net>
<P@draigBrady.com> <P@draigBrady.com (trivial change)>
Pádraig Brady <p@draigBrady.com> <P@draigBrady.com>
Pádraig Brady <P@draigBrady.com>
<chen.guo.0625@gmail.com> <chenguo4@yahoo.com>
<chen.guo.0625@gmail.com> <chenguo4@ucla.edu>
<schwab@linux-m68k.org> <schwab@suse.de>
@@ -27,9 +28,18 @@ Pádraig Brady <p@draigBrady.com> <P@draigBrady.com>
<karl@gnu.org> <karl@freefriends.org>
<stephane.raimbault@gmail.com> <stephane.raimbault@makina-corpus.com>
<jarkko.sakkinen@iki.fi> <jarkko.sakkinen@linux.intel.com>
<tobias@stoeckmann.org> <tobias@bugol.de>
<cjwatson@debian.org> <cjwatson@ubuntu.com>
# Prefer spelled-out middle name and its address.
Arne Henrik Juul <arnej@imf.unit.no> Arne H. Juul <arnej@solan.unit.no>
# Had email as name.
Dan Jacobson <jidanni@jidanni.org> jidanni@jidanni.org <jidanni@jidanni.org>
# Consolidate names of same email address.
Jeff Liu <jeff.liu@oracle.com> jeff.liu <jeff.liu@oracle.com>
Jeff Liu <jeff.liu@oracle.com> Jie Liu <jeff.liu@oracle.com>
# Convert to latin1 for a better 'THANKS' sort order.
Aleksej Shilin <rootlexx@mail.ru> Алексей Шилин <rootlexx@mail.ru>

View File

@@ -1 +1 @@
8.21
9.7

View File

@@ -1,6 +1,6 @@
# Suppress valgrind diagnostics we don't care about.
# Copyright (C) 2003-2013 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
@@ -13,7 +13,7 @@
# 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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
{
libc_dl_open

View File

@@ -1,2 +1,6 @@
COPYING
man/help2man
^COPYING$
^bootstrap$
^doc/fdl\.texi$
^man/help2man$
^src/longlong\.h$
^tests/init\.sh$

12
AUTHORS
View File

@@ -2,16 +2,20 @@ 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: Pádraig Brady, Samuel Neves
base32: Simon Josefsson
base64: Simon Josefsson
basename: David MacKenzie
basenc: Simon Josefsson, Assaf Gordon
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: Q. Frank Xia
cksum: Pádraig Brady, Q. Frank Xia
comm: Richard M. Stallman, David MacKenzie
coreutils: Alex Deymo
cp: Torbjörn Granlund, David MacKenzie, Jim Meyering
csplit: Stuart Kemp, David MacKenzie
cut: David M. Ihnat, David MacKenzie, Jim Meyering
@@ -23,7 +27,7 @@ dircolors: H. Peter Anvin
dirname: David MacKenzie, Jim Meyering
du: Torbjörn Granlund, David MacKenzie, Paul Eggert, Jim Meyering
echo: Brian Fox, Chet Ramey
env: Richard Mlynarik, David MacKenzie
env: Richard Mlynarik, David MacKenzie, Assaf Gordon
expand: David MacKenzie
expr: Mike Parker, James Youngman, Paul Eggert
factor: Paul Rubin, Torbjörn Granlund, Niels Möller
@@ -40,7 +44,7 @@ join: Mike Haertel
kill: Paul Eggert
link: Michael Stone
ln: Mike Parker, David MacKenzie
logname: FIXME: unknown
logname: David MacKenzie
ls: Richard M. Stallman, David MacKenzie
md5sum: Ulrich Drepper, Scott Miller, David Madore
mkdir: David MacKenzie
@@ -82,7 +86,7 @@ stat: Michael Meskes
stdbuf: Pádraig Brady
stty: David MacKenzie
sum: Kayvan Aghaiepour, David MacKenzie
sync: Jim Meyering
sync: Jim Meyering, Giuseppe Scrivano
tac: Jay Lepreau, David MacKenzie
tail: Paul Rubin, David MacKenzie, Ian Lance Taylor, Jim Meyering
tee: Mike Parker, Richard M. Stallman, David MacKenzie

View File

@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
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 <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
@@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,379 +0,0 @@
2008-12-16 Jim Meyering <meyering@redhat.com>
NB: ChangeLog files are no longer manually maintained.
See HACKING for details.
2008-02-07 Jim Meyering <meyering@redhat.com>
We *do* need two different version files.
One for tarball-only, the other to be updated any time we
get a new value of $(VERSION).
* Makefile.am (dist-hook): Create .tarball-version in dist tarball.
* GNUmakefile (_curr-ver): Make git-version-gen use it.
* .gitignore: Ignore it.
Fix a typo in description of size suffixes: s/GB/G/.
* doc/coreutils.texi (od invocation, head invocation, tail invocation):
Spotted by Bert Wesarg.
* NEWS [6.9.90]: Mention the added feature that head, od, split and
tail now accept the standard size suffixes (kB, M, MB, G, GB, and
so on for T, P, Y, Z, and Y) on arguments to selected options.
2008-02-06 Steven Schubiger <schubiger@gmail.com>
mkdir, split: write --verbose output to stdout, not stderr.
* src/mkdir.c (verbose_output): New function.
(announce_mkdir): Use it.
* src/split.c (usage): Update.
* src/split.c (cwrite): Write to stdout, not stderr.
* doc/coreutils.texi (split invocation): Remove the mention
of --verbose output being printed to stderr.
* tests/mkdir/p-v: Redirect stdout, not stderr.
* tests/misc/split-a: Likewise.
* NEWS: Mention this change.
* TODO: Remove this item.
2008-02-04 Jim Meyering <meyering@redhat.com>
* Makefile.maint (announcement): Remove stale comment.
2008-02-02 Jim Meyering <meyering@redhat.com>
Clarify a comment.
* tests/sort/Test.pm: Replace a vague ChangeLog reference with a URL.
2008-01-31 Bob Proulx <bob@proulx.com>
Improve wording of date and time man page.
* man/date.x: Improve compact description of the --date=STRING.
* man/touch.x: Likewise.
Suggested by A. Costa.
2008-01-31 Jim Meyering <meyering@redhat.com>
Remove alignment constraint from the sha*_read_ctx functions.
* lib/sha256.c (set_uint32): New function.
(sha256_read_ctx, sha224_read_ctx): Use it.
* lib/sha512.c (set_uint64): New function.
(sha512_read_ctx, sha384_read_ctx): Use it.
* lib/sha256.h: Remove warning about alignment constraint.
* lib/sha512.h: Likewise.
Prompted by similar changes in gnulib's sha1 and md[45] modules.
Adapt to new version of vc-list-files.
* tests/check.mk (vc_exe_in_TESTS): Adapt to new constraint
that vc-list-files be run only from $(top_srcdir).
Pull vc-list-files from gnulib.
* bootstrap.conf (gnulib_modules): Add vc-list-files.
* build-aux/vc-list-files: Remove file.
Improve the cp/parent-perm test.
* tests/cp/parent-perm: Also check that perms of existing dest
dirs are changed to match those of corresponding src dir
2008-01-30 Paul Eggert <eggert@cs.ucla.edu>
Don't modify argv in dd due to ',' in arguments.
* src/dd.c: Include quotearg.h.
(operand_matches): New function.
(parse_symbols, operand_is): Use it.
(parse_symbols): 1st arg is now const pointer. Don't modify it.
msgid arg is now just the message, not a format.
(scanargs): Add some 'const's to check for problems like the above.
2008-01-30 Jim Meyering <meyering@redhat.com>
* src/c99-to-c89.diff: Adjust remove.c offsets, again.
Now that system.h defines is_empty_dir, include "openat.h".
* src/system.h: Include "openat.h" here, ...
* src/chcon.c: ... not here.
* src/chmod.c: Likewise.
* src/chown-core.c: Likewise.
* src/remove.c: Likewise.
* src/c99-to-c89.diff: Adjust remove.c offsets.
Improve "rmdir --ignore-fail-on-non-empty"
* src/rmdir.c (remove_parents, main): With --ignore-fail-on-non-empty,
suppress a diagnostic also for other errno values, which can arise
with read-only media or when the parent directory has the immutable
attribute (set via chattr +i).
(errno_may_be_empty, ignorable_failure): New functions.
* src/remove.c (is_empty_dir): Move function to ...
* src/system.h (is_empty_dir): ...here, and make it inline.
Suggested by Josselin Mouette in <http://bugs.debian.org/350541>
via Bob Proulx.
* NEWS: Mention the improvement.
2008-01-29 Paul Eggert <eggert@cs.ucla.edu>
Don't modify argv in dd.
* src/dd.c (operand_is): New function.
(scanargs): Use it so that we don't need to modify argv, as a nicety.
Problem reported by Adam Goode in
<http://lists.gnu.org/archive/html/bug-coreutils/2008-01/msg00264.html>.
2008-01-29 Jim Meyering <meyering@redhat.com>
* Makefile.am (BUILT_SOURCES): Ensure that .version exists.
Reported by Bob Proulx.
2008-01-29 Bob Proulx <bob@proulx.com>
Improve the man pages of --date=STRING for 'date' and 'touch'.
* man/date.x: Add a compact description of the --date=STRING.
* man/touch.x: Likewise.
Reported by A. Costa in http://bugs.debian.org/363011
2008-01-29 Michael Stone <mstone@debian.org>
Improve the description of when dd outputs its final statistics.
* doc/coreutils.texi (dd invocation): Say that dd prints stats
upon normal termination and upon SIGINT.
2008-01-29 Jim Meyering <meyering@redhat.com>
Avoid "make distcheck" failure: newly-created man/*.1 files not removed
* Makefile.am (EXTRA_DIST): Add .version.
(.version): New rule.
(dist-hook): Don't create $(distdir)/.version here, now that it's
being distributed.
* man/Makefile.am (common_dep): Use ../.version, not ../VERSION.
(../VERSION): Remove rule.
* GNUmakefile (dummy): Create .version, not VERSION.
Add an extra "...:= $(shell..." statement to ensure that
.version exists even when the preceding code is not run.
* .gitignore: Remove both .version and VERSION.
ls: don't segfault on files in /proc with an old libselinux
* src/ls.c (gobble_file): Work around a bug in libselinux1-2.0.15
whereby getfilecon returns 0 yet sets the context to NULL.
Reported by Jan Moringen via Michael Stone in
http://bugs.debian.org/463043
* tests/ls/Makefile.am (TESTS): Add proc-selinux-segfault.
* tests/ls/proc-selinux-segfault: Test for the above fix.
* NEWS: Mention the fix.
2008-01-26 Jim Meyering <meyering@redhat.com>
Work around Darwin9's set-GID-like group ownership inheritance.
This avoids another spurious Mac OS 10.5.1 (Darwin 9.1) test failure.
* tests/cp/preserve-gid: Accept a group ID of 0, as well.
Reported by Elias Pipping.
Emit "info coreutils 'PROG invocation'" into the man page,
rather than just "info PROG". The latter would often fail
or simply display the man page.
* man/help2man: Change the template.
Prompted by http://bugs.debian.org/399684
chcon: correct description of --no-dereference (-h) option.
* src/chcon.c (usage): Remove invalid reference to lchown.
Reported by Göran Uddeborg.
Ensure that each version string change propagates to man pages.
* man/Makefile.am (common_dep): Don't depend on configure.ac for
version changes. Instead, depend on ../VERSION.
(../VERSION): New rule.
* Makefile.am (DISTCLEANFILES): Define.
* GNUmakefile: Update ./VERSION.
* .gitignore: List VERSION.
Reported by Sven Joachim.
Avoid cp/preserve-gid test failure on Mac OS 10.5.1 (Darwin 9.1)
* tests/cp/preserve-gid: Set group as well as owner on ".".
Reported by Elias Pipping.
Improve a warning about non-portable "mv" usage.
* doc/coreutils.texi (mv invocation): Adjust the warning: moving a
dir-symlink-specified-with-a-trailing-slash works in a surprising
manner only on some systems. Reported by Tomas Pospisek in
http://bugs.debian.org/343652.
2008-01-26 Mike Frysinger <vapier@gentoo.org>
* src/dircolors.hin (TERM): Add jfbterm.
2008-01-23 Jim Meyering <meyering@redhat.com>
Clean up build-related rules.
* Makefile.cfg (gnulib_dir): Update comment.
* Makefile.maint (announcement) [cl_date, utc_date]: Don't set
now-unused variables.
* TODO: Update the note on getgrouplist.
2008-01-23 Zvi Har'El <rl@math.technion.ac.il>
Add a ";", so "make install" works with --enable-install-program=su.
* src/Makefile.am (install_su): Add a semicolon. (tiny change)
2008-01-23 Jim Meyering <meyering@redhat.com>
Avoid misinterpreting mgetgroups failure in running root-only tests.
* src/setuidgid.c (main): Don't misinterpret as size_t an error
return from mgetgroups. Reported by Theodoros V. Kalamatianos.
* README: Remove/convert a few stray mentions of CVS.
2008-01-22 Jim Meyering <meyering@redhat.com>
Require automake-1.10.1, for its support of dist-lzma.
* configure.ac (AM_INIT_AUTOMAKE): Require 1.10.1.
Version 6.10.
* NEWS: Record release date.
* README-hacking: Update to reflect existence of automake-1.10.1.
2008-01-18 Jim Meyering <meyering@redhat.com>
Update README.
* README: Remove a note about failing tests on SunOS 4.
On Mac OS 10.5.1 (Darwin 9.1), you'll need --disable-acl.
(Running tests as root): Recommend using "check-root", not "check".
2008-01-17 Jim Meyering <meyering@redhat.com>
Do not define-away __attribute__ when __STRICT_ANSI__ is set.
* src/system.h (__attribute__): Remove the __STRICT_ANSI__ disjunct.
It has been unnecessary since approximately gcc-2.6, and now, leaving
it would cause gcc -Werror -ansi to fail to compile csplit.c.
* gl/lib/randread.c (__attribute__): Likewise.
2008-01-16 Jim Meyering <meyering@redhat.com>
* NEWS: Mention the configure.ac fix.
* TODO: Add an introduction.
Remove a few entries. Update a few others.
2008-01-13 Jim Meyering <meyering@redhat.com>
Remove each output redirection target before writing to it.
* tests/check.mk (vc_exe_in_TESTS): Remove t1 and t2 _first_,
in case they exist beforehand and are not writable.
* build-aux/check.mk (am__check_pre): Likewise, remove $@-t.
2008-01-13 Elias Pipping <pipping@gentoo.org>
* configure.ac: Correct a non-portable use of sed.
2008-01-12 Mike Frysinger <vapier@gentoo.org>
* src/dircolors.hin (image formats): Add the .svg suffix.
2008-01-12 Jim Meyering <meyering@redhat.com>
Use new version of announce-gen.
* Makefile.maint (announcement): Remove use of the
--gnulib-snapshot-time-stamp option.
Use new --gnulib-version option instead.
(gnulib-version): New variable.
2008-01-11 Jim Meyering <meyering@redhat.com>
* Version 6.9.92.
* tests/tr/Test.pm: Prefer en_US.ISO-8859-1 to en_US.iso88591.
Suggestions from James Youngman and Pádraig Brady in
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/12218/focus=12227
2008-01-10 Jim Meyering <meyering@redhat.com>
* README-hacking: Add Git to the list of required tools.
2008-01-08 Paul Eggert <eggert@cs.ucla.edu>
Fix a minor race condition when using cp -p --parents.
* src/cp.c (make_dir_parents_private): If stat fails on the parent
directory, do not add it to the list of directories whose modes
might need fixing later. Also, do not bother invoking 'stat'
unless the stat results might be needed later.
2008-01-08 Jim Meyering <meyering@redhat.com>
parent-perm: avoid a bizarre test failure.
* tests/cp/parent-perm: Accommodate the situation in which
chmod ("dir", 02755) returns 0 yet fails to set the S_ISGID bit.
Remove uses of now-undefined Makefile variable.
* src/Makefile.am (dir_LDADD, ls_LDADD, vdir_LDADD): Remove uses
of no-longer-defined variable, $(LIB_ACL_TRIVIAL).
2008-01-07 Jim Meyering <meyering@redhat.com>
cp (but not copy.c): plug a small leak.
* src/cp.c (do_copy) [--parents]: Free the attribute list.
Make a racy test failure less likely to happen.
* tests/misc/tty-eof: Uncomment a debug "warn".
This change happens to make this test far less likely to fail.
With that statement commented out, this test would fail about
20% of the time on my desktop. Now, it's gone 100 iterations
in a row with no failure.
* NEWS: Mention the cp bug fix.
2008-01-07 Jan Blunck <jblunck@suse.de>
cp --parents: don't use uninitialized memory when restoring permissions
* src/cp.c (make_dir_parents_private): Always stat each source
directory, in case its permissions are required in re_protect,
when setting permissions of a just-created destination directory.
2008-01-07 Jim Meyering <meyering@redhat.com>
cp: add a test for today's bug fix.
* tests/cp/parent-perm: New script. Test today's change.
Based on reproducer from Jan Blunck.
* tests/cp/Makefile.am (TESTS): Add parent-perm.
2008-01-06 Jim Meyering <meyering@redhat.com>
touch: add a test for today's change.
* tests/touch/now-owned-by-other: New script. Test today's change.
* tests/touch/Makefile.am (TESTS): Add now-owned-by-other.
* tests/Makefile.am (all_t): Add td, a new root-only test.
(td): New target.
* NEWS: Mention the improvement.
2008-01-06 Paul Eggert <eggert@cs.ucla.edu>
touch: ignore "-d now" option, when appropriate
* src/touch.c (main): Treat "-d now" as if it were absent, if
neither -a nor -m is specified. Problem reported by Dan Jacobson in:
http://lists.gnu.org/archive/html/bug-coreutils/2008-01/msg00010.html
2008-01-05 Jim Meyering <meyering@redhat.com>
Avoid tr case-conversion failure in some locales.
* src/tr.c (skip_construct): New function.
(main): When processing a pair of case-converting classes, don't
iterate through the elements of each [:upper:] or [:lower:] class.
Reported by Gerald Pfeifer in
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/12218>.
* tests/tr/Test.pm [tolower-F]: New test for the above fix.
[upcase-xtra, dncase-xtra]: New tests, for a related code path.
* NEWS: Mention the tr bug fix.
2008-01-02 Jim Meyering <jim@meyering.net>
* .gitignore: Ignore lzma-compressed files, too.
Update copyright date.
* tests/sample-test: Likewise.
* doc/coreutils.texi: Likewise.
-----
Copyright (C) 2008-2013 Free Software Foundation, Inc.
Copying and distribution of this file, with or without
modification, are permitted provided the copyright notice
and this notice are preserved.

71
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.6.4, then you'd do well to get a newer version.
At worst, just download the latest stable release from
http://git.or.cz/ and build from source.
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:
@@ -224,7 +223,7 @@ keep the maximum line length at 72 or smaller, so that the generated
ChangeLog lines, each with its leading TAB, will not exceed 80 columns.
As for the ChangeLog-style content, please follow these guidelines:
http://www.gnu.org/software/guile/changelogs/guile-changelogs_3.html
https://www.gnu.org/prep/standards/standards.html#Change-Logs
Try to make the summary line fit one of the following forms:
@@ -389,7 +388,7 @@ Send patches to the address listed in --help output
Please follow the guidelines in the "Sending your patches." section of
git's own SubmittingPatches:
http://git.kernel.org/?p=git/git.git;a=blob;f=Documentation/SubmittingPatches
https://github.com/git/git/blob/master/Documentation/SubmittingPatches
Add documentation
@@ -406,7 +405,7 @@ active voice, not a passive one. I.e., say "print the frobnozzle",
not "the frobnozzle will be printed".
Please add comments per the GNU Coding Standard:
http://www.gnu.org/prep/standards/html_node/Comments.html
https://www.gnu.org/prep/standards/html_node/Comments.html
Minor syntactic preferences
@@ -418,7 +417,7 @@ Minor syntactic preferences
character ;-) ]
In writing arithmetic comparisons, use "<" and "<=" rather than
">" and ">=". For some justification, read this:
http://thread.gmane.org/gmane.comp.version-control.git/3903/focus=4126
http://www.gelato.unsw.edu.au/archives/git/0505/4507.html
const placement:
Write "Type const *var", not "const Type *var".
@@ -444,7 +443,7 @@ as possible. If you add a new test file (as opposed to adding a test to
an existing test file) add the new test file to 'tests/local.mk'.
Note to run tests/misc/new-test in isolation you can do:
make TESTS=tests/misc/new-test SUBDIRS=. VERBOSE=yes
make check TESTS=tests/misc/new-test SUBDIRS=. VERBOSE=yes
Variables that are significant for tests with their default values are:
@@ -453,7 +452,7 @@ Variables that are significant for tests with their default values are:
RUN_VERY_EXPENSIVE_TESTS=no
SHELL=/bin/sh
NON_ROOT_USERNAME=nobody
NON_ROOT_GROUP=$(id -g $NON_ROOT_USERNAME)
NON_ROOT_GID=$(id -g $NON_ROOT_USERNAME)
COREUTILS_GROUPS=$(id -G)
There are hundreds of tests in the tests/ directories. You can use
@@ -480,18 +479,18 @@ The forms to choose from are in gnulib's doc/Copyright/ directory.
If you want to assign a single change, you should use the file,
doc/Copyright/request-assign.changes:
http://www.gnu.org/software/gnulib/Copyright/request-assign.changes
https://www.gnu.org/software/gnulib/Copyright/request-assign.changes
If you would like to assign past and future contributions to a project,
you'd use doc/Copyright/request-assign.future:
http://www.gnu.org/software/gnulib/Copyright/request-assign.future
https://www.gnu.org/software/gnulib/Copyright/request-assign.future
You may make assignments for up to four projects at a time.
In case you're wondering why we bother with all of this, read this:
http://www.gnu.org/licenses/why-assign.html
https://www.gnu.org/licenses/why-assign.html
Run "make syntax-check", or even "make distcheck"
@@ -526,7 +525,7 @@ to configure your editor to highlight any offending characters in the
files you edit. If you use Emacs, customize its font-lock mode
or use its WhiteSpace mode:
http://www.emacswiki.org/emacs/WhiteSpace
https://www.emacswiki.org/emacs/WhiteSpace
If you use vim, add this to ~/.vimrc:
@@ -601,25 +600,23 @@ option is always to improve tests. You never know what you might
uncover when you improve test coverage, and even if you don't find
any bugs your contribution is sure to be appreciated.
A good way to quickly assess current test coverage is to use "lcov"
to generate HTML coverage reports. Follow these steps:
A good way to quickly assess current test coverage, for standard
and root only tests, is to follow these steps (requires lcov to be installed):
# configure with coverage information
./configure CFLAGS="-g -fprofile-arcs -ftest-coverage"
make
# run whatever tests you want, i.e.:
make check
# run lcov
lcov -t coreutils -q -d lib -b `pwd` -o lib.lcov -c
lcov -t coreutils -q -d src -b `pwd` -o src.lcov -c
# generate HTML from the output
genhtml -p `pwd` -t coreutils -q --output-directory lcov-html *.lcov
# Do a standard run as the current user
make -j$(nproc) coverage
Then just open the index.html file (in the generated lcov-html directory)
in your favorite web browser.
# Add the root only tests
sudo make -j$(nproc) build-coverage NON_ROOT_USERNAME=$USER SUBDIRS=.
# Generate the report with the combined results
make gen-coverage
# view the HTML report:
xdg-open doc/coverage/index.html
========================================================================
Copyright (C) 2009-2013 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-2013 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
@@ -13,43 +13,25 @@
# 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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
ALL_RECURSIVE_TARGETS =
SUBDIRS = po . gnulib-tests
changelog_etc = \
ChangeLog-2005 \
ChangeLog-2006 \
ChangeLog-2007 \
ChangeLog-2008 \
build-aux/ChangeLog-2007 \
doc/ChangeLog-2007 \
lib/ChangeLog-2007 \
m4/ChangeLog-2007 \
old/fileutils/ChangeLog \
old/fileutils/ChangeLog-1997 \
old/fileutils/NEWS \
old/sh-utils/ChangeLog \
old/sh-utils/ChangeLog.0 \
old/sh-utils/NEWS \
old/textutils/ChangeLog \
old/textutils/NEWS \
po/ChangeLog-2007
EXTRA_DIST = \
$(changelog_etc) \
.mailmap \
.prev-version \
.version \
.vg-suppressions \
README-install \
THANKS.in \
THANKS-to-translators \
THANKStt.in \
bootstrap \
bootstrap.conf \
build-aux/gen-lists-of-programs.sh \
build-aux/gen-single-binary.sh \
cfg.mk \
dist-check.mk \
maint.mk \
@@ -57,6 +39,7 @@ EXTRA_DIST = \
thanks-gen
gen_progs_lists = $(top_srcdir)/build-aux/gen-lists-of-programs.sh
gen_single_binary = $(top_srcdir)/build-aux/gen-single-binary.sh
# Keep these in sync with bootstrap.conf:bootstrap_post_import_hook().
# Use '$(top_srcdir)/m4' and '$(srcdir)/src' for the benefit of non-GNU
@@ -70,6 +53,10 @@ $(srcdir)/src/cu-progs.mk: $(gen_progs_lists)
$(AM_V_GEN)rm -f $@ $@-t \
&& $(SHELL) $(gen_progs_lists) --automake >$@-t \
&& chmod a-w $@-t && mv -f $@-t $@
$(srcdir)/src/single-binary.mk: $(gen_single_binary) $(srcdir)/src/local.mk
$(AM_V_GEN)rm -f $@ $@-t \
&& $(SHELL) $(gen_single_binary) $(srcdir)/src/local.mk >$@-t \
&& chmod a-w $@-t && mv -f $@-t $@
ACLOCAL_AMFLAGS = -I m4
@@ -93,23 +80,32 @@ BUILT_SOURCES = .version
.version:
$(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@
# Arrange so that .tarball-version appears only in the distribution
# tarball, and never in a checked-out repository.
# Have no read-only files in the tarball to allow easy removal.
# Have .tarball-version based versions 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_at)perl -pi -e '$(rm_subst)' $(distdir)/Makefile.in
$(AM_V_at)touch $(distdir)/doc/constants.texi \
$(distdir)/doc/coreutils.info
gen_start_date = 2008-02-08
gen_start_ver = 8.31
.PHONY: gen-ChangeLog
gen-ChangeLog:
$(AM_V_GEN)if test -d .git; then \
$(top_srcdir)/build-aux/gitlog-to-changelog \
--amend=$(srcdir)/build-aux/git-log-fix \
--since=$(gen_start_date) > $(distdir)/cl-t; \
rm -f $(distdir)/ChangeLog; \
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
log_fix="$(srcdir)/build-aux/git-log-fix"; \
test -e "$$log_fix" \
&& amend_git_log="--amend=$$log_fix" \
|| amend_git_log=; \
$(top_srcdir)/build-aux/gitlog-to-changelog $$amend_git_log \
-- v$(gen_start_ver)~.. > $(distdir)/cl-t && \
{ printf '\n\nSee the source repo for older entries\n' \
>> $(distdir)/cl-t && \
rm -f $(distdir)/ChangeLog && \
mv $(distdir)/cl-t $(distdir)/ChangeLog; } \
fi
ALL_RECURSIVE_TARGETS += distcheck-hook
@@ -123,7 +119,7 @@ THANKS-to-translators: po/LINGUAS THANKStt.in
$(AM_V_GEN)( \
cat $(srcdir)/THANKStt.in; \
for lang in `cat $(srcdir)/po/LINGUAS`; do \
echo http://translationproject.org/team/$$lang.html; \
echo https://translationproject.org/team/$$lang.html; \
done; \
) > $@-tmp && mv $@-tmp $@
@@ -137,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"
@@ -146,19 +143,24 @@ check-ls-dircolors:
# current locale considers to be equal.
ASSORT = LC_ALL=C sort
# Extract all lines up to the first one starting with "##".
prologue = perl -ne '/^\#\#/ and exit; print' $(srcdir)/THANKS.in
# FIXME: avoid dependency to build our own 'sort' for 'make dist' ...
# when common platforms have a functional case-folding implementation:
# $ test 'abácad' = "$(printf '%s\n' 'ab' 'ác' 'ad' \
# | LC_ALL=en_US.UTF-8 sort -f \
# | tr -d '\n')" && echo GOOD || echo BAD
# Note we don't enable case folding (-f) in the sort below, due to bugs
# in the I18N patch used in many distros (as of 2015). Also using our
# own src/sort here would induce awkward dependencies for `make dist`.
THANKS: THANKS.in Makefile.am .mailmap thanks-gen .version
$(AM_V_GEN)rm -f $@-t $@; \
{ \
$(prologue); echo; \
{ perl -ne '/^$$/.../^$$/ and print' $(srcdir)/THANKS.in \
| grep -v '^$$' | perl -pe 's/ +/\0/'; \
perl -ne '/^\#\#/ and exit; print' $(srcdir)/THANKS.in; echo; \
{ perl -ne '/^$$/.../^$$/ and !/^$$/ and s/ +/\0/ and print' \
$(srcdir)/THANKS.in; \
git log --pretty=format:'%aN%x00%aE' \
| $(ASSORT) -u; \
} | $(srcdir)/thanks-gen \
| LC_ALL=en_US.UTF-8 sort -f; \
| LC_ALL=en_US.UTF-8 sort -k1,1; \
echo; \
printf ';; %s\n' 'Local Variables:' 'coding: utf-8' End:; \
} > $@-t && chmod a-w $@-t && mv $@-t $@
@@ -177,6 +179,25 @@ check-git-hook-script-sync:
rm -rf $$t; \
test $$fail = 0
# If we are building a single-binary, create symlinks or shebangs for
# the selected tools when installing.
install-exec-hook:
$(AM_V_at)ctrans=$$(printf coreutils | sed -e "$(transform)"); \
for p in x $(single_binary_progs); do \
test $$p = x && continue; \
ptrans=$$(printf '%s' "$$p" | sed -e "$(transform)"); \
rm -f $(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?; \
if test "x$(single_binary_install_type)" = xshebangs; then \
printf '#!%s --coreutils-prog-shebang=%s\n' \
$(bindir)/$$ctrans$(EXEEXT) $$p \
>$(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?; \
chmod a+x,a-w $(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?;\
else \
$(LN_S) -s $$ctrans$(EXEEXT) \
$(DESTDIR)$(bindir)/$$ptrans$(EXEEXT) || exit $$?; \
fi \
done
noinst_LIBRARIES =
MOSTLYCLEANFILES =
CLEANFILES =
@@ -184,6 +205,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

2229
NEWS

File diff suppressed because it is too large Load Diff

203
README
View File

@@ -7,28 +7,27 @@ arbitrary limits.
The programs that can be built with this package are:
[ arch base64 basename cat chcon chgrp chmod chown chroot cksum comm cp
csplit cut date dd df dir dircolors dirname du echo env expand expr
factor false fmt fold groups head hostid hostname id install join kill
link ln logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl nohup
nproc numfmt od paste pathchk pinky pr printenv printf ptx pwd readlink
realpath rm rmdir runcon seq sha1sum sha224sum sha256sum sha384sum sha512sum
shred shuf sleep sort split stat stdbuf stty sum sync tac tail tee test
timeout touch tr true truncate tsort tty uname unexpand uniq unlink
uptime users vdir wc who whoami yes
[ arch b2sum base32 base64 basename basenc cat chcon chgrp chmod chown
chroot cksum comm coreutils cp csplit cut date dd df dir dircolors dirname
du echo env expand expr factor false fmt fold groups head hostid hostname
id install join kill link ln logname ls md5sum mkdir mkfifo mknod mktemp
mv nice nl nohup nproc numfmt od paste pathchk pinky pr printenv printf ptx
pwd readlink realpath rm rmdir runcon seq sha1sum sha224sum sha256sum
sha384sum sha512sum shred shuf sleep sort split stat stdbuf stty sum sync
tac tail tee test timeout touch tr true truncate tsort tty uname unexpand
uniq unlink uptime users vdir wc who whoami yes
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.
These programs are intended to conform to POSIX (with BSD and other
extensions), like the rest of the GNU system. By default they conform
to older POSIX (1003.2-1992), and therefore support obsolete usages
like "head -10" and "chown owner.group file". This default is
overridden at build-time by the value of <unistd.h>'s _POSIX2_VERSION
macro, and this in turn can be overridden at runtime as described in
Like the rest of the GNU system, these programs mostly conform to
POSIX, with BSD and other extensions. For closer conformance, or
conformance to a particular POSIX version, set the POSIXLY_CORRECT
and the _POSIX2_VERSION environment variables, as described in
the documentation under "Standards conformance".
The ls, dir, and vdir commands are all separate executables instead of
@@ -59,117 +58,36 @@ files (man/*.x) are welcome. However, the authoritative documentation
is in texinfo form in the doc directory.
*****************************************
On Mac OS X 10.5.1 (Darwin 9.1), test failure
-----------------------------------------
***************
Feature requests:
---------------
Mac OS X 10.5.1 (Darwin 9.1) provides only partial (and incompatible)
ACL support, so although "./configure && make" succeeds, "make check"
exposes numerous failures. The solution is to turn off ACL support
manually via "./configure --disable-acl". For details, see
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/12292/focus=12318>.
*****************************************
Test failure with NLS and gettext <= 0.17
-----------------------------------------
Due to a conflict between libintl.h and gnulib's new xprintf module,
when you configure with NLS support, and with a gettext installation
older than 0.17.1 (not yet released, at the time of this writing),
then some tests fail, at least on NetBSD 1.6. To work around it in
the mean time, you can configure with --disable-nls. For details,
see <http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/12015/>.
***********************
Pre-C99 build failure
-----------------------
There is a new, implicit build requirement:
To build the coreutils from source, you should 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.
If that happens, simply[*] apply the included patch using the following
command, and then run make again:
cd src && patch < c99-to-c89.diff
[*] however, as of coreutils-7.1, the "c99-to-c89.diff" file is no longer
maintained, so even if the patches still apply, the result will be an
incomplete conversion. It's been 10 years. Get a decent compiler! ;-)
***********************
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 build failure
------------------------
If you use /usr/bin/make on an OSF/1 4.0d system, it will fail due
to the presence of the "[" target. That version of make appears to
treat "[" as some syntax relating to locks. To work around that,
the best solution is to use GNU make. Otherwise, simply remove
all mention of "[$(EXEEXT)" from src/Makefile.
*************************************************
"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
***************
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
the problem on your own, please compress and attach it to the rest of
your bug report.
IMPORTANT: if you take the time to report a test failure,
please be sure to include the output of running 'make check'
in verbose mode for each failing test. For example,
@@ -178,12 +96,9 @@ 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.
Send bug reports, questions, comments, etc. to bug-coreutils@gnu.org.
If you would like to suggest a patch, see the files README-hacking
and HACKING for tips.
***************************************
@@ -191,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
@@ -203,46 +118,20 @@ reproduce whatever problem prompted it. Plus, you'll earn lots of
karma if you include a test case to exercise any bug(s) you fix.
Here are instructions for checking out the latest development sources:
http://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:
http://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.
https://savannah.gnu.org/git/?group=coreutils
For general documentation on the coding and usage standards
this distribution follows, see the GNU Coding Standards,
http://www.gnu.org/prep/standards_toc.html.
this distribution follows, see the GNU Coding Standards at:
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-2013 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

@@ -1,58 +1,64 @@
-*- outline -*-
Building from a Git repository -*- outline -*-
These notes intend to help people working on the checked-out sources.
These requirements do not apply when building from a distribution tarball.
See also HACKING for more detailed contribution guidelines.
If this package has a file HACKING, please also read that file for
more detailed contribution guidelines.
* Requirements
We've opted to keep only the highest-level sources in the GIT repository.
This eases our maintenance burden, (fewer merges etc.), but imposes more
We've opted to keep only the highest-level sources in the Git repository.
This eases our maintenance burden (fewer merges etc.), but imposes more
requirements on anyone wishing to build from the just-checked-out sources.
Note the requirements to build the released archive are much less and
are just the requirements of the standard ./configure && make procedure.
(The requirements to build from a release are much less and are just
the requirements of the standard './configure && make' procedure.)
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 supports your architecture. See also README-valgrind.
Valgrind <https://valgrind.org/> is also highly recommended, if
Valgrind supports your architecture. See also README-valgrind
(if present).
While building from a just-cloned source tree may require installing a
few prerequisites, later, a plain 'git pull && make' should be sufficient.
few prerequisites, later, a plain 'git pull && make' typically suffices.
* First GIT checkout
* First Git checkout
You can get a copy of the source repository like this:
$ git clone git://git.sv.gnu.org/coreutils
$ cd coreutils
$ git clone https://git.savannah.gnu.org/git/<packagename>
$ cd <packagename>
As an optional step, if you already have a copy of the gnulib git
repository, then you can use it as a reference to reduce download
time and disk space requirements:
where '<packagename>' stands for 'coreutils' or whatever other package
you are building.
$ 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:
$ ./bootstrap
To use the most-recent gnulib (as opposed to the gnulib version that
To use the most-recent Gnulib (as opposed to the Gnulib version that
the package last synchronized to), do this next:
$ git submodule foreach git pull origin master
$ git commit -m 'build: update gnulib submodule to latest' gnulib
And there you are! Just
As an optional step, if you already have a copy of the Gnulib Git
repository, then you can use it as a reference to reduce download
time and file system space requirements:
$ ./configure --quiet #[--enable-gcc-warnings] [*]
$ make
$ make check
$ export GNULIB_REFDIR=/path/to/gnulib
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
$ ./configure --quiet #[--disable-gcc-warnings] [*]
$ make #[check]
At this point, there should be no difference between your local copy,
and the GIT master copy:
and the Git master copy:
$ git diff
@@ -60,27 +66,29 @@ should output no difference.
Enjoy!
[*] The --enable-gcc-warnings option is useful only with glibc
and with a very recent version of gcc. You'll probably also have
to use recent system headers. If you configure with this option,
and spot a problem, please be sure to send the report to the bug
reporting address of this package, and not to that of gnulib, even
if the problem seems to originate in a gnulib-provided file.
[*] By default GCC warnings are enabled when building from Git.
If you get warnings with recent GCC and Glibc with default
configure-time options, please report the warnings to the bug
reporting address of this package instead of to bug-gnulib,
even if the problem seems to originate in a Gnulib-provided file.
If you get warnings with other configurations, you can run
'./configure --disable-gcc-warnings' or 'make WERROR_CFLAGS='
to build quietly or verbosely, respectively.
-----
* Submitting patches
If you develop a fix or a new feature, please send it to the
appropriate bug-reporting address as reported by the --help option of
each program. One way to do this is to use vc-dwim
<http://www.gnu.org/software/vc-dwim/>), as follows.
<https://www.gnu.org/software/vc-dwim/>), as follows.
Run the command "vc-dwim --help", copy its definition of the
"git-changelog-symlink-init" function into your shell, and then run
this function at the top-level directory of the package.
Run the command "vc-dwim --initialize" from the top-level directory
of this package's git-cloned hierarchy.
Edit the (empty) ChangeLog file that this command creates, creating a
properly-formatted entry according to the GNU coding standards
<http://www.gnu.org/prep/standards/html_node/Change-Logs.html>.
<https://www.gnu.org/prep/standards/html_node/Change-Logs.html>.
Make your changes.
@@ -94,7 +102,7 @@ each program. One way to do this is to use vc-dwim
-----
Copyright (C) 2002-2013 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
@@ -107,4 +115,4 @@ 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 <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.

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

@@ -1,21 +1,13 @@
As of 2002-09-01, the GNU fileutils, textutils, and sh-utils
packages have been merged into one, called the GNU coreutils.
See http://www.gnu.org/software/coreutils/ for a description.
On 2002-09-01, the GNU fileutils, textutils, and sh-utils
packages were merged into one, called the GNU coreutils.
See https://www.gnu.org/software/coreutils/coreutils.html for a description.
Here's the FAQ list:
http://www.gnu.org/software/coreutils/faq/
https://www.gnu.org/software/coreutils/faq/
For information on the mailing lists associated with the
coreutils package, see these:
coreutils package, including archive locations, see these:
http://mail.gnu.org/mailman/listinfo/coreutils-announce
http://mail.gnu.org/mailman/listinfo/bug-coreutils
http://mail.gnu.org/mailman/listinfo/coreutils
mailing list archives are here:
http://news.gmane.org/gmane.comp.gnu.coreutils.announce
http://news.gmane.org/gmane.comp.gnu.core-utils.bugs (up to the minute)
http://mail.gnu.org/pipermail/bug-coreutils/ (updated every 12 hours)
http://news.gmane.org/gmane.comp.gnu.coreutils.general
http://mail.gnu.org/pipermail/coreutils/ (updated every 12 hours)
https://lists.gnu.org/mailman/listinfo/coreutils-announce
https://lists.gnu.org/mailman/listinfo/bug-coreutils
https://lists.gnu.org/mailman/listinfo/coreutils

View File

@@ -1,64 +1,41 @@
This gives some notes on obtaining the tools required for development.
I.E. the tools checked for by the bootstrap script and include:
These tools can be used by the 'bootstrap' and 'configure' scripts,
as well as by 'make'. They include:
- Autoconf <http://www.gnu.org/software/autoconf/>
- Automake <http://www.gnu.org/software/automake/>
- Bison <http://www.gnu.org/software/bison/>
- Gettext <http://www.gnu.org/software/gettext/>
- Git <http://git.or.cz/>
- Gperf <http://www.gnu.org/software/gperf/>
- Gzip <http://www.gnu.org/software/gzip/>
- Perl <http://www.cpan.org/>
- Rsync <http://samba.anu.edu.au/rsync/>
- Tar <http://www.gnu.org/software/tar/>
- Texinfo <http://www.gnu.org/software/texinfo/>
- Autoconf <https://www.gnu.org/software/autoconf/>
- Automake <https://www.gnu.org/software/automake/>
- Bison <https://www.gnu.org/software/bison/>
- Gettext <https://www.gnu.org/software/gettext/>
- Git <https://git-scm.com/>
- Gperf <https://www.gnu.org/software/gperf/>
- Gzip <https://www.gnu.org/software/gzip/>
- Help2man <https://www.gnu.org/software/help2man/>
- M4 <https://www.gnu.org/software/m4/>
- Make <https://www.gnu.org/software/make/>
- Perl <https://www.cpan.org/>
- Tar <https://www.gnu.org/software/tar/>
- Texinfo <https://www.gnu.org/software/texinfo/>
- Wget <https://www.gnu.org/software/wget/>
- XZ Utils <https://tukaani.org/xz/>
Note please try to install/build official packages for your system.
If these programs are not available use the following instructions
to build them and install the results into a directory that you will
then use when building this package.
It is generally better to use official packages for your system.
If a package is not officially available you can build it from source
and install it into a directory that you can then use to build this
package. If some packages are available but are too old, install the
too-old versions first as they may be needed to build newer versions.
Even if the official version of a package for your system is too old,
please install it, as it may be required to build the newer versions.
The examples below install into $HOME/coreutils/deps/, so if you are
going to follow these instructions, first ensure that your $PATH is
set correctly by running this command:
Here is an example of how to build a program from source. This
example is for Autoconf; a similar approach should work for the other
developer prerequisites. This example assumes Autoconf 2.71; it
should be OK to use a later version of Autoconf, if available.
prefix=$HOME/coreutils/deps
prefix=$HOME/prefix # (or wherever else you choose)
export PATH=$prefix/bin:$PATH
* autoconf *
# Note Autoconf 2.62 or newer is needed to build automake-1.11.2
# but we specify 2.64 here as that's what coreutils requires.
# Please use the latest stable release version as indicated by git tags.
git clone --depth=1 git://git.sv.gnu.org/autoconf.git
cd autoconf
git checkout v2.64
autoreconf -vi
wget https://ftp.gnu.org/pub/gnu/autoconf/autoconf-2.71.tar.gz
gzip -d <autoconf-2.71.tar.gz | tar xf -
cd autoconf-2.71
./configure --prefix=$prefix
make install
* automake *
# Note help2man is required to build automake fully
git clone git://git.sv.gnu.org/automake.git
cd automake
git checkout v1.11.2
./bootstrap
./configure --prefix=$prefix
make install
This package uses XZ utils (successor to LZMA) to create
a compressed distribution tarball. Using this feature of Automake
requires version 1.10a or newer, as well as the xz program itself.
* xz *
git clone git://ctrl.tukaani.org/xz.git
cd xz
./autogen.sh
./configure --prefix=$prefix
make install
Now you can build this package as described in README-hacking.
Once the prerequisites are installed, you can build this package as
described in README-hacking.

View File

@@ -16,7 +16,7 @@ Here are most of the steps we (maintainers) follow when making a release.
* Ensure that you've pushed all changes that belong in the release
and that the NixOS/Hydra autobuilder is reporting all is well:
http://hydra.nixos.org/jobset/gnu/coreutils-master
https://hydra.nixos.org/jobset/gnu/coreutils-master
* Run bootstrap one last time. This downloads any new translations:
@@ -25,15 +25,25 @@ Here are most of the steps we (maintainers) follow when making a release.
FIXME: enable excluded programs like arch? to get their manual pages?
* Check for new file system types by running the following command on
a system with the most recent kernel possible, or with the latest
upstream include/uapi/linux/magic.h made available at src/fs-latest-magic.h
a system with the most recent kernel possible (e.g., Fedora rawhide):
make src/fs-magic-compare
If it reports new file system magic numbers, add them to src/stat.c.
If it is a remote file system, add the new S_MAGIC_* name you created
in stat.c to the list of remote file system types in src/tail.c's
fremote function.
Or download the latest header first like:
kgit='https://git.kernel.org/cgit/linux/kernel/git'
wget -q $kgit/torvalds/linux.git/plain/include/uapi/linux/magic.h \
-O src/fs-latest-magic.h
If it finds a new file system magic number, add it to src/stat.c.
If it is a remote file system tag it as such.
Note there may be some new file systems magic values not defined
in that linux/magic.h file, which can be seen at:
https://www.livegrep.com/search/linux\
?q=%23define+.*_SUPER_MAGIC+-file%3Amagic\.h
* Pre-release testing:
@@ -41,7 +51,8 @@ FIXME: enable excluded programs like arch? to get their manual pages?
one non-SELinux system:
n=$(( ($(nproc) + 1) / 2 ))
sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k -j$(nproc) check-root\
sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER \
make -k -j$(nproc) check-root SUBDIRS=. \
&& make distcheck \
&& make -j$n check RUN_VERY_EXPENSIVE_TESTS=yes RUN_EXPENSIVE_TESTS=yes
@@ -59,8 +70,8 @@ FIXME: enable excluded programs like arch? to get their manual pages?
make syntax-check
* Set the date, version number, and release type [stable/alpha/beta] on
line 3 of NEWS, commit that, and tag the release by running e.g.,
* To set the date, version number, and release type [stable/alpha/beta] on
line 3 of NEWS, commit that, and tag the release; run:
build-aux/do-release-commit-and-tag X.Y stable
@@ -79,6 +90,16 @@ FIXME: enable excluded programs like arch? to get their manual pages?
soon post. Start with the template, $HOME/announce-coreutils-X.Y
that was just created by that "make" command.
For generating counts use:
oldrel=$(cat .prev-version)
printf "There have been %d commits by %d people %s\n" \
$(($(git log --oneline v$oldrel.. | wc -l) - 3)) \
$(git shortlog v$oldrel.. | grep "^[^ ]" | wc -l) \
"in the [X] weeks since $oldrel"
git shortlog v$oldrel.. | sed -n 's/:$//p' |
sed 's/^/ /' | column -c 70 | expand
Once all the builds and tests have passed,
* Run the gnupload command that was suggested by your "make stable" run above.
@@ -110,15 +131,15 @@ Once all the builds and tests have passed,
Then go here to approve it:
https://savannah.gnu.org/news/approve.php?group=coreutils
* Send the announcement email message.
* Send the announcement email message (signed with the release key)
* Approve the announcement here:
http://lists.gnu.org/mailman/admindb/coreutils-announce
https://lists.gnu.org/mailman/admindb/coreutils-announce
* After each non-alpha release, update the on-line manual accessible via
http://www.gnu.org/software/coreutils/manual/
https://www.gnu.org/software/coreutils/manual/
by running this:
build-aux/gnu-web-doc-update
build-aux/gnu-web-doc-update --mirror

View File

@@ -1,7 +1,7 @@
#! /bin/bash
# Convert this package for use with valgrind.
# Copyright (C) 2002-2013 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
@@ -14,7 +14,7 @@
# 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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
@@ -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

@@ -4,13 +4,16 @@ have contributed improvements to the documentation, actual code, and even
complete programs. Those contributions are described in the version control
logs and ChangeLog files. If your name has been left out, if you'd rather
not be listed, or if you'd prefer a different address be used, please send a
note to the bug-report mailing list (as seen at end of e.g., cp --help).
note to the GNU coreutils mailing list <coreutils@gnu.org>.
##
## There is no need to list here any name that appears as an Author in
## "git log" output. Those are automatically added when this template
## is used to generate the THANKS file. Note that numerous people listed
## here would have been listed as commit authors if we had been using git
## for version control when they contributed.
##
## Let's keep the list in this order ... which sc_THANKS_in_sorted ensures:
## $ LC_ALL=en_US.UTF-8 src/sort -f -k1,1
??? kytek@cybercomm.net
A Costa agcosta@gis.net
@@ -22,7 +25,6 @@ Adam Klein aklein@debian.org
Adam Sampson ats@offog.org
Adrian Bunk bunk@stusta.de
AIDA Shinra shinra@j10n.org
Akim Demaille demaille@inf.enst.fr
Alain Magloire alain@qnx.com
Alan Iwi iwi@atm.ox.ac.uk
Alan Jenkins alan-jenkins@tuffmail.co.uk
@@ -33,19 +35,17 @@ aldomel aldomel@ix.netcom.com
Alen Muzinic zveki@fly.cc.fer.hr
Alexander Nguyen vinh@seas.ucla.edu
Alexander V. Lukyanov lav@netis.ru
Allen Hewes allen@decisiv.net
Axel Dörfler axeld@pinc-software.de
Alexandre Duret-Lutz duret_g@epita.fr
Alexey Solovyov alekso@math.uu.se
Alexey Vyskubov alexey@pippuri.mawhrin.net
Alfred M. Szmidt ams@kemisten.nu
Allen Hewes allen@decisiv.net
Ambrose Feinstein ambrose@google.com
Amr Ali amr.ali.cc@gmail.com
Anders Kaseorg andersk@mit.edu
Andi Kleen freitag@alancoxonachip.com
Andre Novaes Cunha Andre.Cunha@br.global-one.net
Andreas Frische andreasfrische@gmail.com
Andreas Gruenbacher ag@bestbits.at
Andreas Jaeger jaeger@gnu.org
Andreas Luik luik@isa.de
Andreas Stolcke stolcke@ICSI.Berkeley.EDU
@@ -72,12 +72,12 @@ Arun Sharma arun.sharma@intel.com
Arvind Autar Autar022@planet.nl
Augey Mikus mikus@dqc.org
Austin Donnelly Austin.Donnelly@cl.cam.ac.uk
Axel Dörfler axeld@pinc-software.de
Axel Kittenberger Anshil@gmx.net
Barry Kelly http://barrkel.blogspot.com/
Barry Kelly http://blog.barrkel.com/
Bauke Jan Douma bjdouma@xs4all.nl
Ben Elliston bje@air.net.au
Ben Harris bjh21@netbsd.org
Ben Walton bwalton@artsci.utoronto.ca
Bengt Martensson bengt@mathematik.uni-Bremen.de
Benjamin Cutler cutlerbc@simla.colostate.edu
Bernard Giroud bernard.giroud@creditlyonnais.ch
@@ -95,6 +95,7 @@ Bjorn Helgaas helgaas@rsn.hp.com
Bob McCracken kerouac@ravenet.com
Branden Robinson branden@necrotic.deadbeast.net
Brendan O'Dea bod@compusol.com.au
Brian Foster bfoster@redhat.com
Brian Kimball bfk@footbag.org
Brian M. Carlson sandals@crustytoothpaste.ath.cx
Brian Silverman bsilverman@conceptxdesign.com
@@ -110,6 +111,7 @@ Charles Karney karney@pppl.gov
Charles Randall crandall@matchlogic.com
Chas. Owens chas.owens@gmail.com
Chip Salzenberg chip@valinux.com
Choi Jongu zoopi01@gmail.com
Chris Clayton chris2553@googlemail.com
Chris Faylor cgf@cygnus.com
Chris J. Bednar cjb@AdvancedDataSolutions.com
@@ -118,6 +120,7 @@ Chris Lesniewski ctl@mit.edu
Chris Sylvain csylvain@umm.edu
Chris Yeo cyeo@biking.org
Christi Alice Scarborough christi@chiark.greenend.org.uk
Christian Brauner christian.brauner@canonical.com
Christian Harkort christian.harkort@web.de
Christian Jullien eligis@orange.fr
Christian Krackowizer ckrackowiz@std.schuler-ag.com
@@ -130,7 +133,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
@@ -138,6 +141,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
@@ -158,14 +162,15 @@ 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
Deepak Goel deego@gnufans.org
Denis Excoffier denis.excoffier@airbus.com
Denis Excoffier gcc@Denis-Excoffier.org
Denis McKeon dmckeon@swcp.com
Dennis Henriksen opus@flamingo.osrl.dk
Dennis Clarke dclarke@blastwave.org
Dennis Henriksen opus@flamingo.osrl.dk
Dennis Smit ds@nerds-incorporated.org
Derek Clegg dclegg@next.com
Dick Streefland dick_streefland@tasking.com
@@ -179,20 +184,23 @@ Doug McLaren dougmc@comco.com
Dragos Harabor dharabor@us.oracle.com
Duncan Roe duncanr@optimation.com.au
Edward Schwartz edmcman@cmu.edu
Edward Welbourne eddy@opera.com
Edzer Pebesma Edzer.Pebesma@rivm.nl
Egmont Koblinger egmont@uhulinux.hu
Eirik Fuller eirik@hackrat.com
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
Eric Bergen eric.bergen@gmail.com
Eric G. Miller egm2@jps.net
Eric Pemente pemente@northpark.edu
Eric S. Raymond esr@snark.thyrsus.com
Erik Bennett bennett@cvo.oneworld.com
Erik Bernstein erik@fscking.org
Erik Corry erik@kroete2.freinet.de
Felix Lee flee@teleport.com
Felix Rauch Valenti frauch@cse.unsw.edu.au
@@ -203,7 +211,9 @@ Florian Schlichting fschlich@cis.fu-berlin.de
Florin Iucha fiucha@hsys.mic.ro
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
@@ -223,18 +233,17 @@ 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
Göran Uddeborg goeran@uddeborg.se
Guochun Shi gshi@ncsa.uiuc.edu
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
Guochun Shi gshi@ncsa.uiuc.edu
H. J. Lu hjl@valinux.com
Hans Ginzel hans@matfyz.cz
Hans Lermen lermen@fgan.de
@@ -249,22 +258,24 @@ Herbert Xu herbert@gondor.apana.org.au
Holger Berger hberger@ess.nec.de
Hon-Yin Kok hkok@yoda.unl.edu
Hugh Daniel hugh@xanadu.com
Ian Bruce ian.bruce@myrealbox.com
Iain Calder ic56@rogers.com
Ian Bruce ian.bruce@myrealbox.com
Ian Jackson ijackson@chiark.greenend.org.uk
Ian Kent ikent@redhat.com
Ian Lance Taylor ian@cygnus.com
Ian Turner vectro@pipeline.com
Iida Yosiaki iida@gnu.org
Illia Bobyr ibobyr@google.com
Ilya N. Golubev gin@mo.msk.ru
Ingo Saitz ingo@debian.org
Ivan Labath labath3@st.fmph.uniba.sk
Ivo Timmermans ivo@debian.org
Jack Howarth howarth.mailing.lists@gmail.com
Jacky Fong jacky.fong@utoronto.ca
James james@albion.glarp.com
James Antill jmanti%essex.ac.uk@seralph21.essex.ac.uk
James Lemley James.Lemley@acxiom.com
James Hunt jamesodhunt@hotmail.com
James james@albion.glarp.com
James Lemley James.Lemley@acxiom.com
James Ralston ralston@pobox.com
James Sneeringer jvs@ocslink.com
James Tanis jtt@soscorp.com
@@ -273,12 +284,12 @@ Jamie McClelland jm@mayfirst.org
Jan Engelhardt jengelh@medozas.de
Jan Fedak J.Fedak@sh.cvut.cz
Jan Moringen jan.moringen@uni-bielefeld.de
Jan Nieuwenhuizen janneke@gnu.org
Jan-Pawel Wrozstinski jpwroz@gmail.com
Janos Farkas chexum@shadow.banki.hu
Jan-Pawel Wrozstinski jpwroz@gmail.com
Jari Aalto jari.aalto@cante.net
Jarkko Hietaniemi jhi@epsilon.hut.fi
Jarod Wilson jwilson@redhat.com
Jason Smith jasonmsmith@google.com
Jean Charles Delepine delepine@u-picardie.fr
Jean-Pierre Tosoni jpt.7196@gmail.com
Jeff Moore jbm@mordor.com
@@ -295,6 +306,7 @@ Jesse Thilo jgt2@eecs.lehigh.edu
Jie Xu xuj@iag.net
Jim Blandy jimb@cyclic.com
Jim Dennis jimd@starshine.org
Jirka Hladky jhladky@redhat.com
Joakim Rosqvist dvljrt@cs.umu.se
Jochen Hein jochen@jochen.org
Joe Orton joe@manyfish.co.uk
@@ -302,6 +314,7 @@ Joerg Sonnenberger joerg@britannica.bec.de
Joey Hess joeyh@debian.org
Johan Boule bohan@bohan.dyndns.org
Johan Danielsson joda@pdc.kth.se
Johannes Altmanninger aclopte@gmail.com
John Bley jbb6@acpub.duke.edu
John Gatewood Ham zappaman@alphabox.compsci.buu.ac.th
John Gotts jgotts@umich.edu
@@ -324,9 +337,10 @@ Josselin Mouette joss@debian.org
Juan F. Codagnone juam@arnet.com.ar
Juan M. Guerrero st001906@hrz1.hrz.tu-darmstadt.de
Julian Bradfield jcb@inf.ed.ac.uk
Julian Büning julian.buening@rwth-aachen.de
Jungshik Shin jshin@pantheon.yale.edu
Jürgen Fluk louis@dachau.marco.de
Juraj Marko jmarko@redhat.com
Jürgen Fluk louis@dachau.marco.de
Jurriaan thunder7@xs4all.nl
Justin Pryzby justinpryzby@users.sourceforge.net
jvogel jvogel@linkny.com
@@ -340,13 +354,14 @@ Karsten Thygesen karthy@kom.auc.dk
Kaveh R. Ghazi ghazi@caip.rutgers.edu
Keith M. Briggs keith.briggs@bt.com
Keith Owens kaos@audio.apana.org.au
Keith Thompson kst@cts.com
Keith Thompson Keith.S.Thompson@gmail.com
Ken Irving ken.irving@alaska.edu
Ken Pizzini kenp@halcyon.com
Kevin Mudrick kmudrick@healthmarketscience.com
Kirk Kelsey kirk.kelsey@0x4b.net
Kjetil Torgrim Homme kjetilho@ifi.uio.no
Konrad Wróblewski coni@o2.pl
Kristin E Thomas kristint@us.ibm.com
Kjetil Torgrim Homme kjetilho@ifi.uio.no
Kristoffer Rose kris@diku.dk
Ladislav Hagara ladislav.hagara@unob.cz
Larry McVoy lm@sgi.com
@@ -363,15 +378,14 @@ M. P. Suzuki mpsuzuki@hiroshima-u.ac.jp
Maciej Kwapulinski pikpok@univ.gda.pl
Manas Garg manas@cygsoft.com
Manfred Hollstein manfred@s-direktnet.de
Марк Коренберг socketpair@gmail.com
Marc Boucher marc@mbsi.ca
Marc Haber mh+debian-bugs@zugschlus.de
Marc Mengel mengel@fnal.gov
Marc Lehman schmorp@schmorp.de
Marc Mengel mengel@fnal.gov
Marc Olzheim marcolz@stack.nl
Marcel Böhme http://www.comp.nus.edu.sg/~mboehme
Marcel Böhme https://www.comp.nus.edu.sg/~mboehme
Marco Franzen Marco.Franzen@Thyron.com
Marcus Brinkmann http://www.marcus-brinkmann.de
Marcus Brinkmann https://www.marcus-brinkmann.de
Marcus Daniels marcus@ee.pdx.edu
Mark A. Thomas thommark@access.digex.net
Mark Conty Mark_Conty@cargill.com
@@ -382,15 +396,16 @@ Mark Hewitt mhewitt@armature.com
Mark Hounschell markh@compro.net
Mark Hubbart discord@mac.com
Mark Kettenis kettenis@phys.uva.nl
Mark Korenberg socketpair@gmail.com
Mark Melahn mmelahn@gmail.com
Mark Nudelman marknu@flash.net
Mark W. Eichin eichin@cygnus.com
Markus Demleitner msdemlei@auriga.ari.uni-heidelberg.de
Martin martin@dresden.nacamar.de
Martin Buck martin.buck@ascom.ch
Martin Gallant martyg@goodbit.net
Martin Hippe martin.hippe@schlund.de
Martin Jacobs martin.jacobs@arcor.de
Martin martin@dresden.nacamar.de
Martin Michlmayr tbm@cyrius.com
Martin Mitchell martin@debian.org
Martin P.J. Zinser zinser@decus.de
@@ -398,6 +413,8 @@ 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
Matt McCutchen matt@mattmccutchen.net
@@ -406,20 +423,18 @@ Matt Pham mattvpham@gmail.com
Matt Schalit mschalit@pacbell.net
Matt Swift swift@alum.mit.edu
Matthew Arnison maffew@cat.org.au
Matthew M. Boedicker matthewm@boedicker.org
Matthew Braun matthew@ans.net
Matthew Clarke Matthew_Clarke@mindlink.bc.ca
Matthew M. Boedicker matthewm@boedicker.org
Matthew Pfeiffer spferical@gmail.com
Matthew S. Levine mslevine@theory.lcs.mit.edu
Matthew Smith matts@bluesguitar.org
Matthew Swift swift@alum.mit.edu
Matthias Urlichs smurf@noris.de
Matti Aarnio matti.aarnio@zmailer.org
Mathias Brodala info@noctus.net
Mattias Wadenstein maswan@acc.umu.se
Max Chang maxchang@ucla.edu
Meelis Roos mroos@tartu.cyber.ee
Michael michael@aplatform.com
Michael ??? michael@roka.net
Michael Bacarella mbac@netgraft.com
Michael Deutschmann michael@talamasca.ocis.net
Michael Elizabeth Chastain mec.gnu@mindspring.com
@@ -430,6 +445,8 @@ Michael J. Croghan mcroghan@usatoday.com
Michael J. Daniel michael.j.daniel@comcast.net
Michael McFarland sidlon@yahoo.com
Michael McLagan mmclagan@invlogic.com
Michael michael@aplatform.com
Michael ??? michael@roka.net
Michael Mol mikemol@gmail.com
Michael Piefel piefel@informatik.hu-berlin.de
Michael Price mprice@atl.lmco.com
@@ -441,6 +458,7 @@ Michael Veksler mveksler@techunix.technion.ac.il
Michail Litvak mci@owl.openwall.com
Michal Politowski mpol@charybda.icm.edu.pl
Michal Svec msvec@suse.cz
Michal Trunecka mtruneck@redhat.com
Michel Robitaille robitail@IRO.UMontreal.CA
Michiel Bacchiani bacchian@raven.bu.edu
Mike Castle dalgoda@ix.netcom.com
@@ -463,10 +481,12 @@ Nicolas François nicolas.francois@centraliens.net
Niklas Edmundsson nikke@acc.umu.se
Nikola Milutinovic Nikola.Milutinovic@ev.co.yu
Nikolaus Rath Nikolaus@rath.org
Nikos Mavrogiannopoulos nmav@redhat.com
Nima Nikzad nnikzad@ucla.edu
Noah Friedman friedman@splode.com
Noel Cragg noel@red-bean.com
Norbert Kiesel nkiesel@tbdnetworks.com
Norihiro Kamae norihiro@nagater.net
Olatunji Oluwabukunmi Ruwase tjruwase@stanford.edu
Olav Morkrid olav@funcom.com
Ole Laursen olau@hardworking.dk
@@ -503,11 +523,10 @@ Petr Uzel petr.uzel@suse.cz
Petter Reinholdtsen pere@hungry.com
Phelippe Neveu pneveu@pcigeomatics.com
Phil Richards phil.richards@vf.vodafone.co.uk
Philipp Gortan gortan@gmail.com
Philippe De Muyter phdm@macqel.be
Philippe Schnoebelen Philippe.Schnoebelen@imag.fr
Phillip Jones mouse@datastacks.com
Philipp Gortan gortan@gmail.com
Philipp Thomas pth@suse.de
Piergiorgio Sartor sartor@sony.de
Pieter Bowman bowman@math.utah.edu
Piotr Gackiewicz gacek@intertele.pl
@@ -519,7 +538,6 @@ Raimonds Miltins raimonds@pro-9.com
Rainer Orth ro@TechFak.Uni-Bielefeld.DE
Ralf W. Stephan stephan@tmt.de
Ralph Loader loader@maths.ox.ac.uk
Rasmus Borup Hansen rbh@intomics.com
Raul Miller moth@magenta.com
Raúl Núñez de Arenas Coronado raul@pleyades.net
Rich Burridge rich.burridge@oracle.com
@@ -549,7 +567,7 @@ Ross Ridge rridge@calum.csclub.uwaterloo.ca
Rudolf Kastl rkastl@redhat.com
Sahil Amoli sahilamoli@gmail.com
Sami Farin sfarin@ratol.fi
Samuel Tardieu sam@rfc1149.net
Samuel Neves sneves@dei.uc.pt
Samuel Thibault samuel.thibault@ens-lyon.org
Samuli Karkkainen Samuli.Karkkainen@hut.fi
Sander van Malssen svm@kozmix.ow.nl
@@ -570,6 +588,7 @@ Stéphane Chazelas Stephane_CHAZELAS@yahoo.fr
Stephen Depooter sbdep@myrealbox.com
Stephen Eglen eglen@pcg.wustl.edu
Stephen Gildea gildea@stop.mail-abuse.org
Stephen Shirley kormat@gmail.com
Stephen Smoogen smooge@mindspring.com
Steve McConnel steve@acadcomp.sil.org
Steve McIntyre steve@einval.com
@@ -578,8 +597,8 @@ Steven Drake sbd@users.sourceforge.net
Steven G. Johnson stevenj@alum.mit.edu
Steven Mocking ufo@quicknet.nl
Steven Parkes smparkes@smparkes.net
Steven Schveighoffer schveiguy@yahoo.com
Steven P Watson steven@magelico.net
Steven Schveighoffer schveiguy@yahoo.com
Stuart Citrin ctrn3e8@gmail.com
Stuart Kemp skemp@peter.bmc.com
Stuart Shelton stuart@shelton.me
@@ -587,8 +606,8 @@ Sven Breuner sven.breuner@itwm.fraunhofer.de
Szakacsits Szabolcs szaka@sienet.hu
Tadayoshi Funaba tadf@kt.rim.or.jp
TAKAI Kousuke takai@vlsi.kuee.kyoto-u.ac.jp
Theodore Ts'o tytso@rsts-11.mit.edu
The Wanderer inverseparadox@comcast.net
Theodore Ts'o tytso@rsts-11.mit.edu
Thomas Bushnell thomas@gnu.ai.mit.edu
Thomas Goerlich thomas@schnappmatik.de
Thomas Hood jdthood@yahoo.co.uk
@@ -617,7 +636,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
@@ -627,9 +646,7 @@ Ulrich Hermisson ulrich_hermisson@hotmail.com
Urs Thuermann urs@isnogud.escape.de
Uwe H. Steinfeld usteinfeld@gmx.net
Vesselin Atanasov vesselin@bgnet.bg
Ville Skyttä ville.skytta@iki.fi
Vin Shelton acs@alumni.princeton.edu
Vincent Lefevre vincent@vinc17.org
Vineet Chadha chadha@acis.ufl.edu
Vitali Lovich vlovich@gmail.com
Vitaly A. Ostanin vyt@altlinux.org
@@ -655,6 +672,7 @@ Xu Zhongxing xu_zhong_xing@163.com
Yang Ren ryang@redhat.com
Yanko Kaneti yaneti@declera.com
Yann Dirson dirson@debian.org
Youngjun Song mastojun@gmail.com
Yutaka Amanai yasai-itame1942@jade.plala.or.jp
;; Local Variables:

29
TODO
View File

@@ -7,18 +7,14 @@ before embarking on a big project.
==================================================
Modify chmod so that it does not change an inode's st_ctime
when the selected operation would have no other effect.
First suggested by Hans Ecke <http://hans.ecke.ws> in
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/2920
Discussed more recently on <http://bugs.debian.org/497514>.
document the following in coreutils.texi:
[
pinky
First suggested by Hans Ecke <https://hans.ecke.ws> in
https://lists.gnu.org/r/bug-coreutils/2004-09/msg00145.html
Discussed more recently on <https://bugs.debian.org/497514>.
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,10 +45,10 @@ 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:
http://mail.gnu.org/archive/html/bug-fileutils/2003-03/msg00030.html
https://lists.gnu.org/r/bug-fileutils/2003-03/msg00030.html
I don't plan to do that, since a few tests demonstrate no significant benefit.
printf: consider adapting builtins/printf.def from bash
@@ -67,10 +63,6 @@ lib/strftime.c: Since %N is the only format that we need but that
would expand /%(-_)?\d*N/ to the desired string and then pass the
resulting string to glibc's strftime.
unexpand: [http://www.opengroup.org/onlinepubs/007908799/xcu/unexpand.html]
printf 'x\t \t y\n'|unexpand -t 8,9 should print its input, unmodified.
printf 'x\t \t y\n'|unexpand -t 5,8 should print "x\ty\n"
sort: Investigate better sorting algorithms; see Knuth vol. 3.
We tried list merge sort, but it was about 50% slower than the
@@ -90,14 +82,11 @@ sort: Investigate better sorting algorithms; see Knuth vol. 3.
Mathematical Monthly 66 (1959), 387-389.
shred: Update shred as described here to conform to DoD 5220 rules:
http://lists.gnu.org/archive/html/bug-coreutils/2007-05/msg00075.html
https://lists.gnu.org/r/bug-coreutils/2007-05/msg00075.html
Remove suspicious uses of alloca (ones that may allocate more than
about 4k)
Adapt these contribution guidelines for coreutils:
http://sources.redhat.com/automake/contribute.html
Improve test coverage.
See HACKING for instructions on generating an html test coverage report.
Find a program that has poor coverage and improve.
@@ -150,7 +139,7 @@ pr's use of nstrftime can make it malloc a very large (up to SIZE_MAX) buffer
-----
Copyright (C) 2002-2013 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
@@ -163,4 +152,4 @@ 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 <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.

2013
bootstrap

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
# Bootstrap configuration.
# Bootstrap configuration. -*- sh -*-
# Copyright (C) 2006-2013 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
@@ -13,61 +13,82 @@
# 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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# We don't need these modules.
avoided_gnulib_modules='
--avoid=canonicalize-lgpl
--avoid=dummy
--avoid=mbuiter
--avoid=mbuiterf
'
# gnulib modules used by this package.
gnulib_modules="
$avoided_gnulib_modules
acl
alignof
acl-permissions
alignalloc
alignasof
alloca
announce-gen
areadlink-with-size
areadlinkat-with-size
argmatch
argv-iter
assert
assert-h
assure
attribute
autobuild
backup-rename
backupfile
base32
base64
bool
btoc32
buffer-lcm
c-strcase
c-strtod
c-strtold
calloc-gnu
c32iscntrl
c32isspace
c32width
canon-host
canonicalize
chmodat
chown
cloexec
chownat
cl-strtod
cl-strtold
closein
closeout
config-h
configmake
copy-file-range
crc-x86_64
crypto/md5
crypto/sha1
crypto/sha3
crypto/sha256
crypto/sha512
crypto/sm3
cycle-check
d-ino
d-type
di-set
diacrit
dirfd
dirname
do-release-commit-and-tag
dtimespec-bound
dtoastr
dup2
endian
environ
error
euidaccess
exclude
exitfail
explicit_bzero
faccessat
fadvise
fchdir
@@ -78,30 +99,31 @@ gnulib_modules="
fcntl-safer
fd-reopen
fdatasync
fdl
fdopen
fdutimensat
file-has-acl
file-type
fileblocks
filemode
filenamecat
filevercmp
flexmember
fnmatch-gnu
fopen-safer
fprintftime
fpurge
free-posix
freopen
freopen-safer
fseeko
fstatat
fsusage
fsync
ftello
ftoastr
ftruncate
fts
full-read
full-write
getgroups
gethrxtime
getline
getloadavg
@@ -109,37 +131,35 @@ gnulib_modules="
getndelim2
getopt-gnu
getpagesize
getpass-gnu
gettext-h
gettime
gettimeofday
getugroups
getusershell
gettime-res
git-version-gen
gitlog-to-changelog
gnu-make
gnu-web-doc-update
gnumakefile
gnupload
group-member
hard-locale
hash
hash-pjw
hashcode-file-inode
heap
host-os
human
idcache
idx
ignore-value
inttostr
inttypes
inttypes-h
isapipe
isatty
isblank
issymlink
issymlinkat
largefile
lchmod
lchown
ldtoastr
lib-ignore
libgmp
linebuffer
link
link-follow
@@ -150,120 +170,139 @@ gnulib_modules="
malloc-gnu
manywarnings
mbrlen
mbrtoc32
mbrtowc
mbsalign
mbschr
mbslen
mbswidth
mbszero
mcel-prefer
memcasecmp
memchr
memcmp2
mempcpy
memrchr
mgetgroups
minmax
mkancesdirs
mkdir
mkdir-p
mkdirat
mkfifo
mkfifoat
mknod
mkostemp
mkstemp
mktime
modechange
mountlist
mpsort
netinet_in
non-recursive-gnulib-prefix-hack
nproc
nstrftime
nullptr
obstack
open
openat-safer
parse-datetime
parse-datetime2
pathmax
perl
physmem
pipe
pipe-posix
pipe2
posix-shell
posixtm
posixver
priv-set
progname
propername
pthread
putenv
propername-lite
pthread-cond
pthread-mutex
pthread-thread
pthread_sigmask
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
savedir
savewd
select
selinux-at
setenv
settime
sig2str
sigaction
skipchars
smack
ssize_t
statat
stat-macros
stat-size
stat-time
stdbool
stdc_leading_zeros
stdc_trailing_zeros
stdckdint-h
stdlib-safer
stpcpy
stpncpy
str_endswith
strdup-posix
strftime
strncat
strnlen
strnumcmp
strpbrk
strsignal
strtod
strtoimax
strtoumax
symlink
sys_ioctl
sys_resource
sys_stat
sys_wait
termios
symlinkat
sys_ioctl-h
sys_resource-h
sys_stat-h
sys_types-h
sys_wait-h
targetdir
tempname
termios-h
time_rz
timer-time
timespec
tzset
tmpdir
uname
unicodeio
unistd-safer
unlink-busy
unlinkat
unlinkdir
unlocked-io
unsetenv
update-copyright
uptime
useless-if-before-free
userspec
utimecmp
utimens
utimensat
vasprintf-posix
vc-list-files
verify
verror
version-etc-fsf
wcswidth
wcwidth
winsz-ioctl
winsz-termios
write-any-file
xalignalloc
xalloc
xfreopen
xbinary-io
xdectoint
xfts
xgetcwd
xgetgroups
@@ -273,11 +312,15 @@ gnulib_modules="
xprintf
xprintf-posix
xreadlink
xsetenv
xstrtod
xstrtoimax
xstrtol
xstrtol-error
xstrtold
xstrtoumax
xvasprintf
year2038-recommended
yesno
"
@@ -301,33 +344,35 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
--from-code=UTF-8\\\
'
# Append these, since we use the propername module.
# Append these, since we use the propername-lite module.
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\
--makefile-name=gnulib.mk
--makefile-name=gnulib.mk --automake-subdir
"
# Build prerequisites
buildreq="\
autoconf 2.64
automake 1.11.2
autopoint -
autopoint 0.19.2
bison -
gettext 0.18.1
git 1.4.4
gettext 0.19.2
git 1.5.5
gperf -
gzip -
makeinfo 4.13
m4 -
makeinfo 6.1
texi2pdf 6.1
patch -
perl 5.5
rsync -
tar -
wget -
xz -
"
@@ -344,8 +389,22 @@ bootstrap_post_import_hook ()
&& chmod a-w $tmp-1 $tmp-2 \
&& mv -f $tmp-1 $m4f && mv -f $tmp-2 $mkf)
# Massage lib/gnulib.mk before using it later in the bootstrapping process.
build-aux/prefix-gnulib-mk --lib-name=$gnulib_name lib/$gnulib_mk
# If "AM_GNU_GETTEXT(external" or "AM_GNU_GETTEXT([external]" appears
# in configure.ac, remove a file unnecessarily imported by autopoint.
if grep '^[ ]*AM_GNU_GETTEXT(\[*external]*[,)]' \
configure.ac >/dev/null 2>&1; then
rm -f m4/longlong.m4
fi
# Regenerate src/single-binary.mk
(mkf=src/single-binary.mk tmp=single-binary.tmp \
&& rm -f $mkf $tmp \
&& 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
}
@@ -362,6 +421,13 @@ bootstrap_epilogue()
perl -pi -e 's/if LC_ALL=C grep .GNU .PACKAGE.*; then/if true; then/' \
po/Makefile.in.in
# Add dummy 'install-html' target, required for packages using
# non-recursive makefiles with older gettext.
# See https://bugs.gnu.org/25690
if ! grep -w 'install-html' po/Makefile.in.in ; then
printf 'install-%s:;\n' dvi ps pdf html >> po/Makefile.in.in
fi
# Install our git hooks, as long as "cp" accepts the --backup option,
# so that we can back up any existing files.
case $(cp --help) in *--backup*) backup=1;; *) backup=0;; esac

View File

@@ -1,241 +0,0 @@
2007-09-29 Eric Blake <ebb9@byu.net>
* check.mk (%.log): Also allow suffix-less tests, on platforms
where $(EXEEXT) is not empty.
2007-09-15 Jim Meyering <jim@meyering.net>
* vc-list-files: Remove mercurial support.
Check for CVS first. Adjust comments.
2007-01-30 Jim Meyering <jim@meyering.net>
* vc-list-files: Select column 2, not 3 (hg-0.9.3's manifest format
now has only two columns).
2006-10-14 Jim Meyering <jim@meyering.net>
* vc-list-files: Don't filter git-ls-files output through cut.
Add a comment about cvsu.
2006-08-22 Paul Eggert <eggert@cs.ucla.edu>
* .cvsignore: New file.
2006-08-20 Paul Eggert <eggert@cs.ucla.edu>
* compile, config.guess, config.rpath, config.sub, depcomp:
* install-sh, mdate-sh, missing, texinfo.tex:
Remove from CVS, since ../bootstrap generates them automatically.
2006-08-15 Paul Eggert <eggert@cs.ucla.edu>
* ChangeLog: Add copyright notice.
* vc-list-files: Likewise.
* mkinstalldirs: Remove; no longer needed.
2006-08-09 Paul Eggert <eggert@cs.ucla.edu>
* texinfo.tex: Update from gnulib.
2006-07-25 Jim Meyering <jim@meyering.net>
* vc-list-files: Handle git repositories, too.
2006-07-19 Jim Meyering <jim@meyering.net>
* vc-list-files: Command line args correspond to an "include"
list, not an exclude list.
2006-07-14 Jim Meyering <jim@meyering.net>
* vc-list-files: New file.
2006-07-08 Paul Eggert <eggert@cs.ucla.edu>
* config.guess, config.sub, install-sh, texinfo.tex:
Update from gnulib.
2006-05-29 Jim Meyering <jim@meyering.net>
* config.guess, config.rpath, config.sub, install-sh:
* mkinstalldirs, texinfo.tex: Update from gnulib.
2006-02-14 Paul Eggert <eggert@cs.ucla.edu>
* install-sh: Update from gnulib.
2006-01-31 Jim Meyering <jim@meyering.net>
* config.guess, missing, texinfo.tex: Update from gnulib.
2006-01-10 Paul Eggert <eggert@cs.ucla.edu>
* config.guess, config.sub, depcomp, texinfo.tex: Sync from gnulib.
2005-12-13 Paul Eggert <eggert@cs.ucla.edu>
* config.guess: Sync from gnulib.
2005-12-07 Jim Meyering <jim@meyering.net>
* cvsu: New file.
2005-11-12 Jim Meyering <jim@meyering.net>
* config.guess, install-sh: Update from gnulib.
2005-10-23 Jim Meyering <jim@meyering.net>
* compile: New file, used to build sha* programs from md5sum.c.
2005-10-13 Jim Meyering <jim@meyering.net>
* texinfo.tex: Sync from gnulib.
2005-09-21 Paul Eggert <eggert@cs.ucla.edu>
* install-sh, config.guess: Sync from gnulib.
2005-07-01 Jim Meyering <jim@meyering.net>
* config.guess, config.sub, mdate-sh, missing, mkinstalldirs:
* texinfo.tex: Update from gnulib.
2005-06-02 Paul Eggert <eggert@cs.ucla.edu>
* config.guess, config.sub, texinfo.tex: Sync from gnulib.
2005-05-20 Paul Eggert <eggert@cs.ucla.edu>
* config.guess: Sync from gnulib.
2005-05-15 Paul Eggert <eggert@cs.ucla.edu>
* depcomp, install-sh, mdate-sh, missing, pmkinstalldirs:
Sync from gnulib (scriptversion change only).
2005-05-14 Paul Eggert <eggert@cs.ucla.edu>
* config.guess, config.sub: Sync from gnulib.
2005-05-01 Paul Eggert <eggert@cs.ucla.edu>
* config.guess, config.sub, texinfo.tex: Sync from gnulib.
2005-03-20 Paul Eggert <eggert@cs.ucla.edu>
* config.rpath: Sync from gnulib.
2005-02-25 Paul Eggert <eggert@cs.ucla.edu>
* config.guess, config.sub, depcomp, install-sh, mdate-sh, missing,
mkinstalldirs: Sync from gnulib.
2005-01-21 Paul Eggert <eggert@cs.ucla.edu>
* config.sub: Sync from gnulib.
2004-12-17 Jim Meyering <jim@meyering.net>
* install-sh: Sync from gnulib.
2004-12-16 Paul Eggert <eggert@cs.ucla.edu>
* mdate-sh: Sync from gnulib.
2004-11-23 Paul Eggert <eggert@cs.ucla.edu>
* config.sub, texinfo.tex: Sync from gnulib.
2004-11-17 Paul Eggert <eggert@cs.ucla.edu>
* config.guess, config.sub: Sync from gnulib.
2004-11-10 Paul Eggert <eggert@cs.ucla.edu>
* texinfo.tex: Sync from gnulib.
2004-11-02 Paul Eggert <eggert@cs.ucla.edu>
* texinfo.tex: Sync from gnulib.
2004-10-29 Paul Eggert <eggert@cs.ucla.edu>
* config.guess, install-sh, texinfo.tex: Sync from gnulib.
2004-10-03 Paul Eggert <eggert@cs.ucla.edu>
* config.guess, config.sub, install-sh, missing, texinfo.tex:
Sync from gnulib.
2004-09-24 Jim Meyering <jim@meyering.net>
* cvsu: Remove file. The version of cvsu from the cvsutils package
does the same job with --find --type=... options.
* cvsu: New file, used by rules in coreutils' Makefile.maint.
2004-08-05 Paul Eggert <eggert@cs.ucla.edu>
* config.guess, config.sub, install-sh, texinfo.tex: Sync from gnulib.
2004-03-30 Paul Eggert <eggert@twinsun.com>
* config.guess, config.sub, install-sh, texinfo.tex: Sync from gnulib.
2003-08-16 Paul Eggert <eggert@twinsun.com>
* config.rpath, texinfo.tex: Sync with gnulib.
2003-04-21 Jim Meyering <jim@meyering.net>
* depcomp: New version, now that this file is on the list
in ../Makefile.cfg.
2003-01-12 Jim Meyering <jim@meyering.net>
Lots of syntactic clean-up, mostly from Karl Berry.
* install-sh: Use consistent indentation, two spaces per level.
(scriptversion): New variable.
Change initializations like `variable=""' to `variable='.
(usage): New variable.
Use `test', not `['.
Use `test -z "$var"', not `[ x"$var" = x ]'.
Use `test -n "$var"', not `[ x"$var" != x ]'.
Alphabetize case entries.
Accept --help and --version options.
Remove unnecessary `else :' clauses.
Add a `Local variables' eval block to help emacs users update
the time-stamp variable added above.
2002-12-20 Jim Meyering <jim@meyering.net>
* install-sh: Set the execute bit on this file.
Reported by Vin Shelton.
2002-11-09 Jim Meyering <jim@meyering.net>
Make it work even when names contain spaces or shell metachars.
* install-sh: Write diagnostics to stderr, not stdout.
Normalize spacing in diagnostics: use one space (not two, and not a TAB)
after the leading `install:'.
Add double quotes around `$src' here: $doit $instcmd "$src" "$dsttmp"
Merge in some changes from the version in automake.
* install-sh: Remove unnecessary quotes around `case' argument.
Use `[ cond1 ] || [ cond2 ]' rather than `[ cond1 -o cond2 ]'.
Use `:' rather than `true'.
2002-02-17 Jim Meyering <jim@meyering.net>
* config.guess (main): Don't use `head -1'; it's no longer portable.
Use `sed 1q' instead.
-----
Copyright (C) 2002-2013 Free Software Foundation, Inc.
Copying and distribution of this file, with or without
modification, are permitted provided the copyright notice
and this notice are preserved.

View File

@@ -17,6 +17,7 @@ set -e
# use "--enable-install-program=A,B" when invoking configure.
disabled_by_default_progs='
arch
coreutils
hostname
'
@@ -31,7 +32,7 @@ build_if_possible_progs='
pinky
stdbuf
stty
uptime
timeout
users
who
'
@@ -40,7 +41,10 @@ build_if_possible_progs='
# be buildable without problems on any target system.
normal_progs='
[
b2sum
base64
base32
basenc
basename
cat
chcon
@@ -117,7 +121,6 @@ normal_progs='
tail
tee
test
timeout
touch
tr
true
@@ -128,6 +131,7 @@ normal_progs='
unexpand
uniq
unlink
uptime
vdir
wc
whoami
@@ -178,6 +182,12 @@ END
echo default__progs += $progsdir/$p
done
;;
1,--list-progs)
for p in $disabled_by_default_progs $build_if_possible_progs \
$normal_progs; do
echo $p
done
;;
*)
echo "$0: invalid usage" >&2; exit 2
;;

119
build-aux/gen-single-binary.sh Executable file
View File

@@ -0,0 +1,119 @@
#!/bin/sh
# Generate the list of rules for the single-binary option based on all the other
# binaries found in src/local.mk.
#
# We need to duplicate the specific rules to build each program into a new
# static library target. We can't reuse the existing target since we need to
# create a .a file instead of linking the program. We can't do this at
# ./configure since the file names need to be available when automake runs
# to let it generate all the required rules in Makefile.in. The configure
# step will select which ones will be used to build, but they need to be
# generated beforehand.
#
# Instead of maintaining a duplicated list of rules, we generate the
# single-binary required rules based on the normal configuration found on
# src/local.mk with this script.
if test "x$1" = "x"; then
echo "Usage: $0 path/to/src/local.mk" >&2
exit 1
fi
set -e
LOCAL_MK=$1
GEN_LISTS_OF_PROGRAMS="`dirname "$0"`/gen-lists-of-programs.sh"
ALL_PROGRAMS=$($GEN_LISTS_OF_PROGRAMS --list-progs \
| grep -v -F -e coreutils -e libstdbuf.so \
| tr '[' '_')
# Compute default SOURCES. automake will assume the source file for the
# src_${cmd} target to be src/${cmd}.c, but we will add rules to generate
# the lib src_libsinglebin_${cmd}_a which won't match the autogenerated source
# file. This loop will initialize the default source file and will be reset
# later if needed.
for cmd in $ALL_PROGRAMS; do
eval "src_${cmd}_SOURCES=src/${cmd}.c"
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_[_[:alnum:]]+ +\+?=' > /dev/null; then
var=$(echo $l | cut -f 1 -d ' ')
value=$(echo $l | cut -f 2- -d =)
if [ "$value" != " \$(LDADD)" ]; then
oldvalue=""
if echo $l | grep -F '+=' >/dev/null; then
eval "oldvalue=\${$var}"
fi
value=$(echo "$value" | sed "s/'/'\"'\"'/g")
eval "$var='$oldvalue "$value"'"
fi
fi
done < $LOCAL_MK
me=`echo "$0" | sed 's,.*/,,'`
echo "## Automatically generated by $me. DO NOT EDIT BY HAND!"
# Override the sources for some tools, to use smaller variants
override_single() {
from="$1"; to="$2";
eval "src_${from}_SOURCES='src/coreutils-${from}.c'"
eval "src_from_LDADD=\$src_${from}_LDADD"
eval "src_${from}_LDADD='$src_from_LDADD src/libsinglebin_${to}.a'"
eval "src_libsinglebin_${from}_a_DEPENDENCIES='src/libsinglebin_${to}.a'"
echo "src_libsinglebin_${from}_a_DEPENDENCIES = src/libsinglebin_${to}.a"
}
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"
echo noinst_LIBRARIES += src/libsinglebin_${cmd}.a
base="src_libsinglebin_${cmd}_a"
# SOURCES
var=src_${cmd}_SOURCES
eval "value=\$$var"
echo "${base}_SOURCES = $value"
# LDADD
var=src_${cmd}_LDADD
eval "value=\$$var"
if [ "x$value" != "x" ]; then
echo "${base}_ldadd = $value"
fi
# DEPENDENCIES
var=src_libsinglebin_${cmd}_a_DEPENDENCIES
eval "value=\$$var"
if [ "x$value" = "x" ]; then
echo "$var = \$(src_${cmd}_DEPENDENCIES)"
fi
# CFLAGS
# Hack any other program defining a main() replacing its main by
# single_binary_main_$PROGRAM_NAME.
echo "${base}_CFLAGS = \"-Dmain=single_binary_main_${cmd} (int, char **);" \
" int single_binary_main_${cmd}\" " \
"-Dusage=_usage_${cmd} \$(src_coreutils_CFLAGS)"
var=src_${cmd}_CFLAGS
eval "value=\$$var"
if [ "x$value" != "x" ]; then
echo "${base}_CFLAGS += $value"
fi
# CPPFLAGS
var=src_${cmd}_CPPFLAGS
eval "value=\$$var"
if [ "x$value" != "x" ]; then
echo "${base}_CPPFLAGS = $value"
fi
done
exit 0

View File

@@ -1,57 +1,3 @@
# This file is expected to be used via gitlog-to-changelog's --amend=FILE
# option. It specifies what changes to make to each given SHA1's commit
# log and metadata, using Perl-eval'able expressions.
3a169f4c5d9159283548178668d2fae6fced3030
# fix title:
s/all tile types/all file types/
e181802521d4e19e367dbe8cfa877296bb5dafb2
# fix the title!
s,seq:,factor:,
3ece0355d52e41a1b079c0c46477a32250278c11
# correct the URL
s,<http.+?>,<http://bugs.debian.org/412688>,
# This is wrong now only in the git log. The ChangeLog-2008
# entry was also erroneous, but has been corrected.
# ed5c4e770a27862813c0182be8680abeb005d15b
# # Wrong bug ID:
# s,/363011,/350541,
# # in this:
# # Suggested by Josselin Mouette in <http://bugs.debian.org/363011>
# This was wrong only in the git log. The ChangeLog entry was
# is from 2007, and so was recorded (correctly) in ChangeLog-2007.
# 1379ed974f1fa39b12e2ffab18b3f7a607082202
# # Due to a bug in vc-dwim, I mis-attributed a patch by Paul to myself.
# # Change the author to be Paul. Note the escaped "@":
# s,Jim .*>,Paul Eggert <eggert\@cs.ucla.edu>,
209850fd7e1e89cf8937310878bd22d70e3588a5
s/isspace/isblank/
# in this:
# * tests/misc/uniq: New file. Test for the above, but only
# when isspace(0240).
760bc6f7e73014e934a744a9d46ea8dbf5ba25c8
s/Now, each/Now, the/;
s!(elicits.*)\.!first $1, and the second works properly.!
# change the log from this:
# Without this, `truncate -s '> -1' F` would truncate F to length 0,
# and `truncate -s " +1" F` would truncate F to 1 byte. Now, each
# elicits a diagnostic.
# to this:
# Without this, `truncate -s '> -1' F` would truncate F to length 0,
# and `truncate -s " +1" F` would truncate F to 1 byte. Now, the
# first elicits a diagnostic, and the second works properly.
# Credit initial reporter of a related issue, now that the BZ is public.
1e18d8416f9ef43bf08982cabe54220587061a08
s,by ,by Nao Nishijima in http://bugzilla.redhat.com/766461\nand by ,
# I was unable to apply the c-set using normal methods, so
# applied it with patch and then forgot to reset the Author.
51a4b04954ad5ad12de1d1b82a3603fc350a3bfa
s,Jim .*>,Ondrej Oprala <ooprala\@redhat.com>,

561
cfg.mk
View File

@@ -1,5 +1,5 @@
# Customize maint.mk -*- makefile -*-
# Copyright (C) 2003-2013 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
@@ -12,18 +12,21 @@
# 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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Used in maint.mk's web-manual rule
manual_title = Core GNU utilities
# Use the direct link. This is guaranteed to work immediately, while
# it can take a while for the faster mirror links to become usable.
url_dir_list = http://ftp.gnu.org/gnu/$(PACKAGE)
url_dir_list = https://ftp.gnu.org/gnu/$(PACKAGE)
# Exclude bundled external projects from syntax checks
VC_LIST_ALWAYS_EXCLUDE_REGEX = src/(blake2/.*|longlong.h)$$
# 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".
bootstrap-tools = autoconf,automake,gnulib,bison
@@ -45,14 +48,20 @@ export VERBOSE = yes
# 4914152 9e
export XZ_OPT = -8e
old_NEWS_hash = 6ae04dc3907ea1290f12e6b1507cc42c
old_NEWS_hash = 0e74b03eaf11d9d281aaa0e7cc544bb4
# Add an exemption for sc_makefile_at_at_check.
_makefile_at_at_check_exceptions = ' && !/^cu_install_program =/'
_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:
@@ -61,23 +70,22 @@ sc_dd_O_FLAGS:
perl -nle '/^ +\| (O_\w*)$$/ and print $$1' $(dd); } | sort > $@.1
@{ echo O_NOFOLLOW; perl -nle '/{"[a-z]+",\s*(O_\w+)},/ and print $$1' \
$(dd); } | sort > $@.2
@diff -u $@.1 $@.2 || diff=1 || diff=; \
@diff -u $@.1 $@.2; diff=$$?; \
rm -f $@.1 $@.2; \
test "$$diff" \
&& { echo '$(ME): $(dd) has inconsistent O_ flag lists'>&2; \
exit 1; } || :
test "$$diff" = 0 \
|| { echo '$(ME): $(dd) has inconsistent O_ flag lists'>&2; \
exit 1; }
# Ensure that dd's definition of LONGEST_SYMBOL stays in sync
# with the strings from the two affected variables.
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) ) \
|sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \
| wc --max-line-length); \
@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 --max-line-length); \
|tr -d '"' | wc -L); \
if test "$$len" = "$$max"; then :; else \
echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
exit 1; \
@@ -96,7 +104,8 @@ sc_prohibit_jm_in_m4:
# Ensure that each root-requiring test is run via the "check-root" rule.
sc_root_tests:
@t1=sc-root.expected; t2=sc-root.actual; \
grep -nl '^ *require_root_$$' `$(VC_LIST) tests` | sort > $$t1; \
grep -nl '^ *require_root_$$' `$(VC_LIST) tests` | \
sed 's|.*/tests/|tests/|' | sort > $$t1; \
for t in $(all_root_tests); do echo $$t; done | sort > $$t2; \
st=0; diff -u $$t1 $$t2 || st=1; \
rm -f $$t1 $$t2; \
@@ -112,17 +121,44 @@ 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.
sc_tests_executable:
@test_extensions_rx=`echo $(TEST_EXTENSIONS) \
| sed -e "s/ / -o -name */g" -e "s/^/-name */"`; \
find tests/ \( $$test_extensions_rx \) \! -perm -111 -print \
| sed -e "s/^/$(ME): Please make test executable: /" | grep . \
@set -o noglob 2>/dev/null || set -f; \
cd $(srcdir); \
find_ext="-name '' "`printf -- "-o -name *%s " $(TEST_EXTENSIONS)`;\
find $(srcdir)/tests/ \( $$find_ext \) \! -perm -u+x -print \
| { sed "s|^$(srcdir)/||"; git ls-files $(srcdir)/tests/; } \
| sort | uniq -d \
| sed -e "s/^/$(ME): Please make test executable: /" | grep . \
&& exit 1; :
# Ensure all gnulib patches apply cleanly
sc_ensure_gl_diffs_apply_cleanly:
@find $(srcdir)/gl/ -name '*.diff' | while read p; do \
patch --fuzz=0 -f -s -d $(srcdir)/gnulib/ -p1 --dry-run < "$$p" >&2 \
|| { echo "$$p" >&2; echo 'To refresh all gl patches run:' \
'make refresh-gnulib-patches' >&2; exit 1; } \
done
# Avoid :>file which doesn't propagate errors
# Also :>file was seen to trigger EXIT trap on cygwin
sc_prohibit_colon_redirection:
@cd $(srcdir)/tests && GIT_PAGER= git grep -En ': *>[^>]' \
&& { echo '$(ME): '":> will hide errors or may trigger EXIT" >&2; \
exit 1; } \
|| :
# Ensure emit_mandatory_arg_note() is called if required
sc_ensure_emit_mandatory_arg_note:
@cd $(srcdir)/src && GIT_PAGER= git \
grep -l -- '^ *-[^-].*--.*[^[]=' *.c \
| xargs grep -L emit_mandatory_arg_note | grep . \
&& { echo '$(ME): '"emit_mandatory_arg_note() missing" 1>&2; \
exit 1; } || :
# Create a list of regular expressions matching the names
# of files included from system.h. Exclude a couple.
.re-list:
@@ -146,7 +182,7 @@ sc_system_h_headers: .re-list
trap 'rc=$$?; rm -f .re-list; exit $$rc' 0; \
$(gl_trap_); \
grep -nE -f .re-list \
$$($(VC_LIST_EXCEPT) | grep '^\($(srcdir)/\)\?src/') \
$$($(VC_LIST_EXCEPT) | grep -E '^($(srcdir)/)?src/') \
&& { echo '$(ME): the above are already included via system.h'\
1>&2; exit 1; } || :; \
fi
@@ -159,6 +195,67 @@ 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 -E -n '$(error_fns) *\(.*%s.*, [^(]*\);$$' \
*.c | grep -v ', q' \
&& { echo '$(ME): '"Use quote() for error string arguments" 1>&2; \
exit 1; } \
|| :
# Files in src/ should quote all file names in error() output
# using quotef(), to provide quoting only when necessary,
# but also provide better support for copy and paste when used.
sc_error_shell_quotes:
@cd $(srcdir)/src && \
{ GIT_PAGER= git grep -E \
'$(error_fns) \(.*%s[:"], .*(name|file)[^"]*\);$$' *.c; \
GIT_PAGER= git grep -E \
' quote[ _].*file' *.c; } \
| grep -Ev '(quotef|q[^ ]*name)' \
&& { echo '$(ME): '"Use quotef() for colon delimited names" 1>&2; \
exit 1; } \
|| :
# Files in src/ should quote all file names in error() output
# using quoteaf() when the name is separated with spaces,
# to distinguish the file name at issue and
# to provide better support for copy and paste.
sc_error_shell_always_quotes:
@cd $(srcdir)/src && GIT_PAGER= git grep -E \
'$(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_fns) \([^%]*[^:] %s[ "]' *.c | grep 'quotef' \
&& { echo '$(ME): '"Use quoteaf() for space delimited names" 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.
# Instead use quotef(), or quoteaf() or in edge cases quotearg_n_style_colon().
# A more general PCRE would be @prohibit='quotearg_.*(?!(style|buffer))'
sc_prohibit-quotearg:
@prohibit='quotearg(_n)?(|_colon|_char|_mem) ' \
in_vc_files='\.c$$' \
halt='Unstyled diagnostic quoting detected' \
$(_sc_search_regexp)
sc_prohibit-skip:
@prohibit='\|\| skip ' \
halt='Use skip_ not skip' \
$(_sc_search_regexp)
sc_sun_os_names:
@grep -nEi \
'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
@@ -173,7 +270,7 @@ au_dotdot = authors-dotdot
au_actual = authors-actual
sc_check-AUTHORS: $(all_programs)
@locale=en_US.UTF-8; \
LC_ALL=$$locale ./src/cat --version \
LC_ALL=$$locale ./src/factor --version \
| grep ' Torbjorn ' > /dev/null \
&& { echo "$@: skipping this check"; exit 0; }; \
rm -f $(au_actual) $(au_dotdot); \
@@ -197,55 +294,70 @@ 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
# Ensure %j is not used for intmax_t as it's not universally supported.
# There are issues on HPUX for example. But note that %ju was used between
# coreutils 8.13 (2011-10) and 8.20 (2012-10) without any reported issue,
# and the particular issue this check is associated with was for %*jx.
# So we may be able to relax this restriction soon.
sc_prohibit-j-printf-format:
@cd $(srcdir)/src && GIT_PAGER= git grep -n '%[0*]*j[udx]' *.c \
&& { echo '$(ME): Use PRI*MAX instead of %j' 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.
# TODO: move the check for _GL... attributes to gnulib.
sc_prohibit-gl-attributes:
@cd $(srcdir) && GIT_PAGER= git grep -En \
"__attribute |__(unused|pure|const)__" src gl/lib/*.[ch] \
&& { echo '$(ME): Use _GL... attribute macros' 1>&2; exit 1; } \
|| :
@prohibit='__attribute |__(unused|pure|const)__' \
in_vc_files='\.[ch]$$' \
halt='Use _GL... attribute macros' \
$(_sc_search_regexp)
# Ensure that <attributes.h> macros are used in .c files.
sc_prohibit-_gl-attributes:
@prohibit='_GL_ATTRIBUTE' \
in_vc_files='\.c$$' \
halt='Use ATTRIBUTE_... instead of _GL_ATTRIBUTE_...' \
$(_sc_search_regexp)
# Prefer the STRUCT_UTMP typedef over struct gl_utmp.
sc_prohibit-struct-gl_utmp:
@prohibit='struct gl_utmp' \
in_vc_files='\.[ch]$$' \
halt='Use STRUCT_UTMP, not struct gl_utmp' \
$(_sc_search_regexp)
# Prefer the const declaration form, with const following the type
sc_prohibit-const-char:
@prohibit='const char \*' \
in_vc_files='\.[ch]$$' \
halt='Use char const *, not const char *' \
$(_sc_search_regexp)
# Look for lines longer than 80 characters, except omit:
# - program-generated long lines in diff headers,
# - urls
# - the fdl.texi file copied from gnulib,
# - the help2man script copied from upstream,
# - tests involving long checksum lines, and
# - the 'pr' test cases.
LINE_LEN_MAX = 80
FILTER_LONG_LINES = \
/^[^:]*\.diff:[^:]*:@@ / d; \
\|^[^:]*man/help2man:| d; \
\|^[^:]*tests/misc/sha[0-9]*sum.*\.pl[-:]| d; \
\|^[^:]*NEWS:.*https\{,1\}://| d; \
\|^[^:]*doc/fdl.texi:| d; \
\|^[^:]*man/help2man:| d; \
\|^[^:]*tests/cksum/sha[0-9]*sum.*\.pl[-:]| d; \
\|^[^:]*tests/pr/|{ \|^[^:]*tests/pr/pr-tests:| !d; };
sc_long_lines:
@files=$$($(VC_LIST_EXCEPT)) \
halt='line(s) with more than $(LINE_LEN_MAX) characters; reindent'; \
@wc -L /dev/null >/dev/null 2>/dev/null \
|| { echo "$@: skipping: wc -L not supported"; exit 0; }; \
sed -r 1q /dev/null 2>/dev/null \
|| { echo "$@: skipping: sed -r not supported"; exit 0; }; \
files=$$($(VC_LIST_EXCEPT) | xargs wc -L | sed -rn '/ total$$/d;\
s/^ *(8[1-9]|9[0-9]|[0-9]{3,}) //p'); \
halt='line(s) with more than 80 characters; reindent'; \
for file in $$files; do \
expand $$file | grep -nE '^.{$(LINE_LEN_MAX)}.' | \
expand $$file | grep -nE '^.{80}.' | \
sed -e "s|^|$$file:|" -e '$(FILTER_LONG_LINES)'; \
done | grep . && { msg="$$halt" $(_sc_say_and_exit) } || :
sc_standard_outputs: $(ALL_MANS)
@grep -E 'std(in|out|err)' man/*.1 doc/*.texi \
&& { echo 1>&2 '$@: use "standard ....." in user docs'; exit 1; } || :
@grep -E '[Ss]tandard (in|out|err)([^op]|$$)' man/*.1 doc/*.texi \
&& { echo 1>&2 '$@: use "standard ..put" in user docs'; exit 1; } || :
@grep -E '_\("[^"]*std(in|out|err)' src/*.c \
&& { echo 1>&2 '$@: use "standard ..put" in messages'; exit 1; } || :
# Option descriptions should not start with a capital letter.
# One could grep source directly as follows:
# grep -E " {2,6}-.*[^.] [A-Z][a-z]" $$($(VC_LIST_EXCEPT) | grep '\.c$$')
@@ -254,6 +366,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
@@ -272,6 +389,20 @@ check-x-vs-1:
| $(ASSORT) -u | diff - $$t || { rm $$t; exit 1; }; \
rm $$t
# Ensure that non-trivial .x files in the 'man/' subdirectory,
# i.e., files exceeding a line count of 20 or a byte count of 1000,
# contain a Copyright notice.
.PHONY: sc_man_check_x_copyright
sc_man_check_x_copyright:
@status=0; \
cd $(srcdir) && wc -cl man/*.x | head -n-1 \
| awk '$$1 >= 20 || $$2 >= 1000 {print $$3}' \
| xargs grep -L 'Copyright .* Free Software Foundation' \
| grep . \
&& { echo 1>&2 '$@: exceeding file size/line count limit' \
'- please add a copyright note'; status=1; }; \
exit $$status
# Writing a portable rule to generate a manpage like '[.1' would be
# a nightmare, so filter that out.
all-progs-but-lbracket = $(filter-out [,$(patsubst src/%,%,$(all_programs)))
@@ -290,6 +421,12 @@ check-programs-vs-x:
done; \
exit $$status
# Ensure we can check out on case insensitive file systems
sc_case_insensitive_file_names: src/uniq
@git -C $(srcdir) ls-files | sort -f | src/uniq -Di | grep . && \
{ echo "$(ME): the above file(s) conflict on case insensitive" \
" file systems" 1>&2; exit 1; } || :
# Ensure that the end of each release's section is marked by two empty lines.
sc_NEWS_two_empty_lines:
@sed -n 4,/Noteworthy/p $(srcdir)/NEWS \
@@ -309,35 +446,35 @@ sc_prohibit_operator_at_end_of_line:
halt='found operator at end of line' \
$(_sc_search_regexp)
# Don't use "readlink" or "readlinkat" directly
sc_prohibit_readlink:
@prohibit='\<readlink(at)? \(' \
halt='do not use readlink(at); use via xreadlink or areadlink*' \
$(_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)
# Ensure that date's --help output stays in sync with the info
# documentation for GNU strftime. The only exception is %N,
# documentation for GNU strftime. The only exception is %N and %q,
# which date accepts but GNU strftime does not.
#
# "info foo" fails with error, but not "info foo >/dev/null".
extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
sc_strftime_check:
@if test -f $(srcdir)/src/date.c; then \
grep '^ %. ' $(srcdir)/src/date.c | sort \
| $(extract_char) > $@-src; \
{ echo N; \
info libc date calendar format 2>/dev/null|grep '^ `%.'\'\
| $(extract_char); } | sort > $@-info; \
if test $$(stat --format %s $@-info) != 2; then \
if info libc date calendar format 2>/dev/null | \
grep "^ *['\`]%.'$$" >$@-tmp; then \
{ echo N; echo q; $(extract_char) $@-tmp; }| sort \
>$@-info; \
grep '^ %. ' $(srcdir)/src/date.c | sort \
| $(extract_char) > $@-src; \
diff -u $@-src $@-info || exit 1; \
else \
echo '$(ME): skipping $@: libc info not installed' 1>&2; \
fi; \
rm -f $@-src $@-info; \
rm -f $@-info $@-src $@-tmp; \
fi
# Indent only with spaces.
@@ -346,14 +483,50 @@ sc_prohibit_tab_based_indentation:
halt='TAB in indentation; use only spaces' \
$(_sc_search_regexp)
# Enforce lowercase 'e' in "I.e.".
sc_prohibit_uppercase_id_est:
@prohibit='I\.E\.' \
halt='Uppercase "Id Est" abbreviation; use "I.e.," instead' \
$(_sc_search_regexp)
# Enforce double-space before "I.e." at the beginning of a sentence.
sc_ensure_dblspace_after_dot_before_id_est:
@prohibit='\. I\.e\.' \
halt='Single space after dot before "i.e."; use ". i.e." instead' \
$(_sc_search_regexp)
# Enforce comma after "i.e." (at least before a blank or at EOL).
sc_ensure_comma_after_id_est:
@prohibit='[Ii]\.e\.( |$$)' \
halt='Missing comma after "i.e."; use "i.e.," instead' \
$(_sc_search_regexp)
# The SEE ALSO section of a man page should not be terminated with
# 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:' \
@@ -362,23 +535,51 @@ 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)
# Ensure that tests don't use `cmd ... && fail=1` as that hides crashes.
# The "exclude" expression allows common idioms like `test ... && fail=1`
# and the 2>... portion allows commands that redirect stderr and so probably
# independently check its contents and thus detect any crash messages.
sc_prohibit_and_fail_1:
@prohibit='&& fail=1' \
exclude='(returns_|stat|kill|test |EGREP|grep|compare|2> *[^/])' \
halt='&& fail=1 detected. Please use: returns_ 1 ... || fail=1' \
in_vc_files='^tests/' \
$(_sc_search_regexp)
# Ensure that tests don't use `cmd ... || fail` as that's a noop.
sc_prohibit_or_fail:
@prohibit='\|\| fail$$' \
exclude=':#' \
halt='|| fail detected. Please use: || fail=1' \
in_vc_files='^tests/' \
$(_sc_search_regexp)
# Ensure that env vars are not passed through returns_ as
# that was seen to fail on FreeBSD /bin/sh at least
sc_prohibit_env_returns:
@prohibit='=[^ ]* returns_ ' \
exclude='_ returns_ ' \
halt='Passing env vars to returns_ is non portable' \
in_vc_files='^tests/' \
$(_sc_search_regexp)
# The mode part of a setfacl -m option argument must be three bytes long.
# I.e., an argument of user:bin:rw or user:bin:r will make Solaris 10's
# 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 . && \
@@ -387,6 +588,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'}" \
@@ -394,7 +607,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)
@@ -404,9 +617,23 @@ sc_prohibit_verbose_version:
halt='use the print_ver_ function instead...' \
$(_sc_search_regexp)
# Enforce print_ver_ tracking of dependencies
# Each coreutils specific program a test requires
# should be tagged by calling through env(1).
sc_env_test_dependencies:
@cd $(top_srcdir) && GIT_PAGER= git grep -E \
"env ($$(build-aux/gen-lists-of-programs.sh --list-progs | \
grep -vF '[' |paste -d'|' -s))" tests | \
sed "s/\([^:]\):.*env \([^)' ]*\).*/\1 \2/" | uniq | \
while read test prog; do \
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)
@@ -416,33 +643,49 @@ sc_prohibit_test_backticks:
halt='use $$(...), not `...` in tests/' \
$(_sc_search_regexp)
# Ensure that compare is used to check empty files
# so that the unexpected contents are displayed
sc_prohibit_test_empty:
@prohibit='test -s.*&&' in_vc_files='^tests/' \
halt='use `compare /dev/null ...`, not `test -s ...` in tests/' \
$(_sc_search_regexp)
# Programs like sort, ls, expr use PROG_FAILURE in place of EXIT_FAILURE.
# Others, use the EXIT_CANCELED, EXIT_ENOENT, etc. macros defined in system.h.
# In those programs, ensure that EXIT_FAILURE is not used by mistake.
sc_some_programs_must_avoid_exit_failure:
@grep -nw EXIT_FAILURE \
$$(git grep -El '[^T]_FAILURE|EXIT_CANCELED' src) \
| grep -vE '= EXIT_FAILURE|exit \(.* \?' | grep . \
@cd $(srcdir) \
&& grep -nw EXIT_FAILURE \
$$(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; } || :
# Ensure that tests call the require_ulimit_v_ function if using ulimit -v
# Ensure that tests call the get_min_ulimit_v_ function if using ulimit -v
sc_prohibit_test_ulimit_without_require_:
@(git grep -l require_ulimit_v_ tests; \
git grep -l 'ulimit -v' tests) \
@(git -C $(srcdir) grep -l get_min_ulimit_v_ tests; \
git -C $(srcdir) grep -l 'ulimit -v' tests) \
| sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
" should match require_ulimit_v_ with ulimit -v" 1>&2; exit 1; } || :
" should match get_min_ulimit_v_ with ulimit -v" 1>&2; exit 1; } || :
# Ensure that tests call the cleanup_ function if using background processes
sc_prohibit_test_background_without_cleanup_:
@(git -C $(srcdir) grep -El '( &$$|&[^&]*=\$$!)' tests; \
git -C $(srcdir) grep -l 'cleanup_()' tests | sed p) \
| sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
" should use cleanup_ for background processes" 1>&2; exit 1; } || :
# Ensure that tests call the print_ver_ function for programs which are
# actually used in that test.
sc_prohibit_test_calls_print_ver_with_irrelevant_argument:
@git grep -w print_ver_ tests \
@git -C $(srcdir) grep -w print_ver_ tests \
| sed 's#:print_ver_##' \
| { fail=0; \
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; \
@@ -527,11 +770,9 @@ sc_space_before_open_paren:
# Similar to the gnulib maint.mk rule for sc_prohibit_strcmp
# Use STREQ_LEN or STRPREFIX rather than comparing strncmp == 0, or != 0.
sc_prohibit_strncmp:
@grep -nE '! *str''ncmp *\(|\<str''ncmp *\(.+\) *[!=]=' \
$$($(VC_LIST_EXCEPT)) \
| grep -vE ':# *define STR(N?EQ_LEN|PREFIX)\(' && \
{ echo '$(ME): use STREQ_LEN or STRPREFIX instead of str''ncmp' \
1>&2; exit 1; } || :
@prohibit='^[^#].*str''ncmp *\(' \
halt='use STREQ_LEN or STRPREFIX instead of str''ncmp' \
$(_sc_search_regexp)
# Enforce recommended preprocessor indentation style.
sc_preprocessor_indentation:
@@ -550,19 +791,94 @@ sc_preprocessor_indentation:
# someone who was initially listed only in THANKS.in later authors a commit,
# this rule detects that their pair may now be removed from THANKS.in.
sc_THANKS_in_duplicates:
@{ git log --pretty=format:%aN | sort -u; \
cut -b-36 THANKS.in | sed '/^$$/d;s/ *$$//'; } \
@{ git -C $(srcdir) log --pretty=format:%aN | sort -u; \
cut -b-36 $(srcdir)/THANKS.in \
| sed '/^$$/,/^$$/!d;/^$$/d;s/ *$$//'; } \
| sort | uniq -d | grep . \
&& { echo '$(ME): remove the above names from THANKS.in' \
1>&2; exit 1; } || :
# Ensure the contributor list stays sorted. However, if the system's
# en_US.UTF-8 locale data is erroneous, give a diagnostic and skip
# this test. This affects OS X, up to at least 10.11.6.
# Use our sort as other implementations may result in a different order.
sc_THANKS_in_sorted:
@printf 'a\n.b\n'|LC_ALL=en_US.UTF-8 src/sort -c 2> /dev/null \
&& { \
sed '/^$$/,/^$$/!d;/^$$/d' $(srcdir)/THANKS.in > $@.1 && \
LC_ALL=en_US.UTF-8 src/sort -f -k1,1 $@.1 > $@.2 && \
diff -u $@.1 $@.2; diff=$$?; \
rm -f $@.1 $@.2; \
test "$$diff" = 0 \
|| { echo '$(ME): THANKS.in is unsorted' 1>&2; exit 1; }; \
} \
|| { echo '$(ME): this system has erroneous locale data;' \
'skipping $@' 1>&2; }
# 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)
# Ensure we keep hex constants as 4 or 8 bytes for consistency
# and so that make src/fs-magic-compare works consistently
sc_fs-magic-compare:
@sed -n 's|.*/\* \(0x[0-9A-Fa-f]\{1,\}\) .*\*/|\1|p' \
$(srcdir)/src/stat.c | grep -Ev '^0x([0-9A-F]{4}){1,2}$$' \
&& { echo '$(ME): Constants in src/stat.c should be 4 or 8' \
'upper-case chars' 1>&2; exit 1; } || :
# Ensure gnulib generated files are ignored
# TODO: Perhaps augment gnulib-tool to do this in lib/.gitignore?
sc_gitignore_missing:
@{ sed -n '/^\/lib\/.*\.h$$/{p;p}' $(srcdir)/.gitignore; \
find lib -name '*.in*' ! -name '*~' ! -name 'sys_*' | \
sed 's|^|/|; s|_\(.*in\.h\)|/\1|; s/\.in//' | \
sed 's|/fts\.h$$|/fts_.h|'; } | \
sort | uniq -u | grep . && { echo '$(ME): Add above' \
'entries to .gitignore' >&2; exit 1; } || :
# Flag redundant entries in .gitignore
# Disabled for now as too aggressive flagging
# entries like /lib/arg-nonnull.h
#sc_gitignore_redundant:
# @{ grep ^/lib $(srcdir)/.gitignore; \
# sed 's|^|/lib|' $(srcdir)/lib/.gitignore; } | \
# 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]$$' \
halt='Form Feed (^L) detected' \
$(_sc_search_regexp)
# debbugs.gnu.org/cgi/bugreport.cgi?bug=... -> bugs.gnu.org/...
# bugzilla.redhat.com/show_bug.cgi?id=... -> bugzilla.redhat.com/...
# sourceware.org/bugzilla/show_bug.cgi?id=... -> sourceware.org/PR...
# gcc.gnu.org/bugzilla/show_bug.cgi?id=... -> gcc.gnu.org/PR...
sc_prohibit-long-form-bug-urls:
@prohibit='http.*(bugreport|show_bug)\.cgi' \
halt='use short form bug url' \
$(_sc_search_regexp)
# Override the default Cc: used in generating an announcement.
announcement_Cc_ = $(translation_project_), \
coreutils@gnu.org, coreutils-announce@gnu.org
@@ -578,14 +894,19 @@ update-copyright-env = \
exclude_file_name_regexp--sc_space_tab = \
^(tests/pr/|tests/misc/nl\.sh$$|gl/.*\.diff$$|man/help2man$$)
exclude_file_name_regexp--sc_bindtextdomain = \
^(gl/.*|lib/euidaccess-stat|src/make-prime-list)\.c$$
exclude_file_name_regexp--sc_trailing_blank = ^(tests/pr/|man/help2man)
^(gl/.*|lib/euidaccess-stat|src/make-prime-list|src/cksum)\.c$$
exclude_file_name_regexp--sc_trailing_blank = \
^(tests/pr/|gl/.*\.diff$$|man/help2man)
_x_system_h := (system|copy|chown-core|find-mount-point)\.h
_x_system_c := (libstdbuf|make-prime-list)\.c
exclude_file_name_regexp--sc_system_h_headers = \
^src/((system|copy)\.h|libstdbuf\.c|make-prime-list\.c)$$
^src/($(_x_system_h)|$(_x_system_c))$$
_src = (false|lbracket|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
_src := (false|lbracket|chown-(chgrp|chown)
_src := $(_src)|ls-(dir|ls|vdir)|make-prime-list|tac-pipe|uname-(arch|uname))
_gl_src = (xdecto.max|cl-strtold)
exclude_file_name_regexp--sc_require_config_h_first = \
(^lib/buffer-lcm\.c|src/$(_src)\.c)$$
(^lib/buffer-lcm\.c|gl/lib/$(_gl_src)\.c|src/$(_src)\.c)$$
exclude_file_name_regexp--sc_require_config_h = \
$(exclude_file_name_regexp--sc_require_config_h_first)
@@ -601,15 +922,15 @@ 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 = doc/.*\.texi$$
exclude_file_name_regexp--sc_prohibit_atoi_atof = ^lib/euidaccess-stat\.c$$
# longlong.h is maintained elsewhere.
_ll = ^src/longlong\.h$$
exclude_file_name_regexp--sc_useless_cpp_parens = $(_ll)
exclude_file_name_regexp--sc_long_lines = $(_ll)
exclude_file_name_regexp--sc_space_before_open_paren = $(_ll)
tbi_1 = ^tests/pr/|(^gl/lib/reg.*\.c\.diff|\.mk|^man/help2man)$$
tbi_1 = ^tests/pr/|(\.mk|^man/help2man)$$
tbi_2 = ^scripts/git-hooks/(pre-commit|pre-applypatch|applypatch-msg)$$
tbi_3 = (GNU)?[Mm]akefile(\.am)?$$|$(_ll)
exclude_file_name_regexp--sc_prohibit_tab_based_indentation = \
@@ -623,8 +944,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 = \
@@ -633,6 +955,20 @@ exclude_file_name_regexp--sc_prohibit_operator_at_end_of_line = \
exclude_file_name_regexp--sc_error_message_uppercase = ^src/factor\.c$$
exclude_file_name_regexp--sc_prohibit_atoi_atof = ^src/make-prime-list\.c$$
# Exception here as we don't want __attribute elided on non GCC for stdbuf
# and we don't want to depend on gnulib for make-prime-list
exclude_file_name_regexp--sc_prohibit-gl-attributes = \
^src/(make-prime-list|libstdbuf)\.c$$
exclude_file_name_regexp--sc_prohibit_uppercase_id_est = \.diff$$
exclude_file_name_regexp--sc_ensure_dblspace_after_dot_before_id_est = \.diff$$
exclude_file_name_regexp--sc_ensure_comma_after_id_est = \.diff|$(_ll)$$
exclude_file_name_regexp--sc_long_lines = \.diff$$|$(_ll)|$(_cksum)|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)
@@ -642,12 +978,23 @@ gnulib-tests_CFLAGS = $(GNULIB_TEST_WARN_CFLAGS)
# Configuration to make the tight-scope syntax-check rule work with
# non-recursive make.
export _gl_TS_headers = $(srcdir)/cfg.mk
# Note _gl_TS_headers use _single line_ extern function declarations,
# while *_SOURCES use the _two line_ form.
export _gl_TS_headers = $(noinst_HEADERS)
# Add exceptions for --enable-single-binary renamed functions.
_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
# 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)
_gl_TS_other_headers = 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
# 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-2013 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
@@ -14,26 +14,28 @@
# 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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
dnl Written by Jim Meyering.
AC_PREREQ([2.64])
AC_PREREQ([2.69])
# Make inter-release version strings look like, e.g., v6.9-219-g58ddd, which
# indicates that it is built from the 219th delta (in _some_ repository)
# following the v6.9 tag, and that 58ddd is a prefix of the commit SHA1.
# The explicit URL can be removed when autoconf > 2.69 is released.
AC_INIT([GNU coreutils],
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
[bug-coreutils@gnu.org])
[bug-coreutils@gnu.org],
[coreutils],
[https://www.gnu.org/software/coreutils/])
AC_CONFIG_SRCDIR([src/ls.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
AM_INIT_AUTOMAKE([1.11.2 no-dist-gzip dist-xz color-tests parallel-tests
subdir-objects])
AM_INIT_AUTOMAKE([1.11.2 dist-xz color-tests parallel-tests subdir-objects])
AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
dnl POSIXCHECK is worthwhile for maintainers, but adds several seconds
@@ -50,22 +52,39 @@ m4_syscmd([test "${GNULIB_POSIXCHECK+set}" = set])
m4_if(m4_sysval, [0], [], [dnl
gl_ASSERT_NO_GNULIB_POSIXCHECK])
AC_PROG_CC_STDC
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.
# FIXME: this is suboptimal. Ideally, we would be able to call gl_PERL
# with an ACTION-IF-NOT-FOUND argument ...
cu_have_perl=yes
case $PERL in *"/missing "*) cu_have_perl=no;; esac
AM_CONDITIONAL([HAVE_PERL], [test $cu_have_perl = yes])
AM_CONDITIONAL([HAVE_PERL], [test "$gl_cv_prog_perl" != no])
# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
# ------------------------------------------------
@@ -85,11 +104,59 @@ AC_DEFUN([gl_GCC_VERSION_IFELSE],
]
)
AC_ARG_ENABLE([single-binary],
[AS_HELP_STRING([--enable-single-binary=[shebangs|symlinks]],
[Compile all the tools in a single binary, reducing the overall size.
When compiled this way, shebangs (default when enabled) or symlinks are
installed for each tool that points to the single binary.])],
[gl_single_binary=no ;
case $enableval in
yes) gl_single_binary=shebangs ;;
no|shebangs|symlinks) gl_single_binary=$enableval ;;
*) AC_MSG_ERROR([bad value $enableval for single-binary option.
Options are: symlinks, shebangs, no.]) ;;
esac],
[gl_single_binary=no]
)
AC_ARG_ENABLE([single-binary-exceptions],
[AS_HELP_STRING([--enable-single-binary-exceptions=PROG_LIST],
[When used with --enable-single-binary, exclude the PROG_LIST from
it, so these programs are compiled as separated files
(comma-separated, default none))])],
[gl_single_binary_exceptions=$enableval],
[gl_single_binary_exceptions=]
)
if test "$gl_single_binary" = 'symlinks'; then
if ! test "`echo ls | sed \"$program_transform_name\"`" = 'ls'; then
AC_MSG_ERROR([program name transformations are not currently supported
with --enable-single-binary=symlinks.])
fi
fi
AM_CONDITIONAL([SINGLE_BINARY], [test "$gl_single_binary" != no])
AC_ARG_ENABLE([bold-man-page-references],
[AS_HELP_STRING([--disable-bold-man-page-references],
[When generating man pages, do not apply bold style around any
references like name(1) etc.])],
[gl_bold_manpages=yes ;
case $enableval in
no|yes) gl_bold_manpages=$enableval ;;
*) AC_MSG_ERROR([bad value $enableval for bold-man-page-references.
Options are: yes, no.]) ;;
esac],
[gl_bold_manpages=yes]
)
AM_CONDITIONAL([BOLD_MAN_REFS], [test "$gl_bold_manpages" != no])
AC_ARG_ENABLE([gcc-warnings],
[AS_HELP_STRING([--enable-gcc-warnings],
[turn on many GCC warnings (for developers; best with GNU make)])],
[AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
[control generation of GCC warnings. The TYPE 'no' disables
warnings (default for non-developer builds); 'yes' generates
cheap warnings if available (default for developer builds);
'expensive' in addition generates expensive-to-compute warnings
if available.])],
[case $enableval in
yes|no) ;;
no|yes|expensive) ;;
*) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
esac
gl_gcc_warnings=$enableval],
@@ -100,88 +167,56 @@ AC_ARG_ENABLE([gcc-warnings],
# we're running from a git repo, then auto enable the warnings.
gl_gcc_warnings=no
gl_GCC_VERSION_IFELSE([4], [6],
[test -d "$srcdir"/.git && gl_gcc_warnings=yes])]
[test -d "$srcdir"/.git \
&& ! test -f "$srcdir"/.tarball-version \
&& gl_gcc_warnings=yes])]
)
if test "$gl_gcc_warnings" = yes; then
# 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])
nw=
ew=
AS_IF([test $gl_gcc_warnings != expensive],
[# -fanalyzer and related options slow GCC considerably.
ew="$ew -fanalyzer -Wno-analyzer-malloc-leak"])
# This, $nw, is the list of warnings we disable.
nw="$nw -Wdeclaration-after-statement" # too useful to forbid
nw="$nw -Waggregate-return" # anachronistic
nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
nw="$nw -Wc++-compat" # We don't care about C++ compilers
nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
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
nw="$nw -Wpadded" # Our structs are not padded
nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
nw="$nw -Wlogical-op" # any use of fwrite provokes this
nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
nw="$nw -Wvla" # warnings in gettext.h
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
# things I might fix soon:
nw="$nw -Wfloat-equal" # sort.c, seq.c
nw="$nw -Wmissing-format-attribute" # copy.c
nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
nw=$ew
nw="$nw -Wstack-protector" # not worth working around for pre GCC 15
nw="$nw -Wformat-overflow=2" # False alarms due to GCC bug 110333
nw="$nw -Wformat-truncation=2" # False alarm in ls.c, probably related
nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
nw="$nw -Wsuggest-attribute=format" # warns about copy.c and factor.c
# Suppress noreturn warnings with single binaries; otherwise
# GCC complains about the renamed 'main' not being declared noreturn
# because 'main_exit' calls 'exit' when linting.
if test "$gl_single_binary" != no; then
nw="$nw -Wsuggest-attribute=noreturn"
fi
# Using -Wstrict-overflow is a pain, but the alternative is worse.
# For an example, see the code that provoked this report:
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
# https://gcc.gnu.org/PR33498
# 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'])
AS_VAR_APPEND([ws], [' -Wtrailing-whitespace'])
gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
for w in $ws; do
gl_WARN_ADD([$w])
done
gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
gl_WARN_ADD([-Wsuggest-attribute=const])
gl_WARN_ADD([-Wsuggest-attribute=noreturn])
gl_WARN_ADD([-Wno-format-nonliteral])
# Enable this warning only with gcc-4.7 and newer. With 4.6.2 20111027,
# it suggests test.c's advance function may be pure, even though it
# increments a global variable. Oops.
# Normally we'd write code to test for the precise failure, but that
# requires a relatively large input to make gcc exhibit the failure.
gl_GCC_VERSION_IFELSE([4], [7], [gl_WARN_ADD([-Wsuggest-attribute=pure])])
# In spite of excluding -Wlogical-op above, it is enabled, as of
# gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
gl_WARN_ADD([-Wno-logical-op])
# 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])
AC_SUBST([WARN_CFLAGS])
AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
@@ -196,23 +231,21 @@ if test "$gl_gcc_warnings" = yes; then
# We use a slightly smaller set of warning options for lib/.
# Remove the following and save the result in GNULIB_WARN_CFLAGS.
nw=
nw="$nw -Wstrict-overflow"
nw="$nw -Wuninitialized"
nw=$ew
nw="$nw -Wduplicated-branches" # Too many false alarms
nw="$nw -Wformat-truncation=2"
nw="$nw -Wunused-macros"
nw="$nw -Wmissing-prototypes"
nw="$nw -Wold-style-definition"
# FIXME: it may be easy to remove this, since it affects only one file:
# the snprintf call at ftoastr.c:132.
nw="$nw -Wdouble-promotion"
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
AC_SUBST([GNULIB_WARN_CFLAGS])
# For gnulib-tests, the set is slightly smaller still.
nw=
nw="$nw -Wstrict-prototypes"
# It's not worth being this picky about test programs.
nw="$nw -Wmissing-variable-declarations"
nw="$nw -Wsuggest-attribute=cold"
nw="$nw -Wsuggest-attribute=const"
nw="$nw -Wsuggest-attribute=format"
nw="$nw -Wsuggest-attribute=pure"
gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
[$GNULIB_WARN_CFLAGS], [$nw])
@@ -226,6 +259,8 @@ AC_CHECK_FUNCS([chroot],
gl_ADD_PROG([optional_bin_progs], [chroot]))
AC_CHECK_FUNCS([gethostid],
gl_ADD_PROG([optional_bin_progs], [hostid]))
AC_CHECK_FUNCS([sigsuspend],
gl_ADD_PROG([optional_bin_progs], [timeout]))
gl_WINSIZE_IN_PTEM
@@ -244,7 +279,8 @@ void unset_TZ (void)
if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
to++;
}
int main()
int
main ()
{
time_t now = time ((time_t *) 0);
int hour_GMT0, hour_unset;
@@ -276,6 +312,64 @@ 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])
# Assume that if getattrat exists, it's compatible with Solaris 11.
AC_CHECK_FUNCS([getattrat])
if test $ac_cv_func_getattrat = yes; then
LIB_NVPAIR=-lnvpair
AC_SUBST([LIB_NVPAIR])
fi
# glibc >= 2.28 and linux kernel >= 4.11
AC_CHECK_FUNCS([statx])
# SCO-ODT-3.0 is reported to need -los to link programs using initgroups
AC_CHECK_FUNCS([initgroups])
if test $ac_cv_func_initgroups = no; then
@@ -309,6 +403,15 @@ case $utils_cv_func_setpriority,$ac_cv_func_nice in
gl_ADD_PROG([optional_bin_progs], [nice])
esac
if test "$cross_compiling" = yes || test -c /dev/stdin <.; then
AC_DEFINE([DEV_FD_MIGHT_BE_CHR], [1],
[Define to 1 if /dev/std{in,out,err} and /dev/fd/N, if they exist, might be
character-special devices whose minor device number is the file
descriptor number, such as on Solaris. Leave undefined if they are
definitely the actual files. This determination should be done after any
symbolic links are followed.])
fi
AC_DEFUN([coreutils_DUMMY_1],
[
AC_REQUIRE([gl_READUTMP])
@@ -320,34 +423,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; return !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; return !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
@@ -373,10 +448,12 @@ yes
AC_MSG_CHECKING([c_line in struct termios])
AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
#define _XOPEN_SOURCE
#endif
#include <sys/types.h>
#include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
#define _XOPEN_SOURCE
#endif
#include <sys/types.h>
#include <termios.h>
struct termios t;
int s = sizeof t.c_line;]])],
[su_cv_sys_c_line_in_termios=yes],
[su_cv_sys_c_line_in_termios=no])])
AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
@@ -411,28 +488,259 @@ 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>])
cu_GMP
# 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])
fi
# Limit stdbuf to ELF systems with GCC
AC_MSG_CHECKING([whether this is an ELF system])
AC_EGREP_CPP([yes], [#if __ELF__
yes
#endif], [elf_sys=yes], [elf_sys=no])
AC_MSG_RESULT([$elf_sys])
if test "$elf_sys" = "yes" && \
test "$GCC" = "yes"; then
# Build stdbuf only if supported
ac_save_CFLAGS=$CFLAGS
ac_save_LDFLAGS=$LDFLAGS
cu_save_c_werror_flag=$ac_c_werror_flag
AC_LANG_WERROR
# Detect warnings about ignored "constructor" attributes.
gl_WARN_ADD([-Werror], [CFLAGS])
gl_WARN_ADD([-errwarn], [CFLAGS])
# Put this message here, after gl_WARN_ADD's chatter.
AC_MSG_CHECKING([whether this system supports stdbuf])
CFLAGS="-fPIC $CFLAGS"
LDFLAGS="-shared $LDFLAGS"
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([[
static int stdbuf = 0;
void __attribute__ ((constructor))
stdbuf_init (void)
{
stdbuf = 1;
}]],[[
if (stdbuf != 1)
return 1;]])
],
[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
# 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 <stdio.h>
#include <sys/auxv.h>
#include <asm/hwcap.h>
#include <arm_neon.h>
int
main (void)
{
uint64x2_t a;
poly64_t shift64 = vget_lane_p64(vcreate_p64(0xB8BC6765), 0);
a = vreinterpretq_u64_p128(vmull_p64(shift64, vreinterpretq_p128_u64(a)));
return (getauxval(AT_HWCAP) & HWCAP_PMULL) > 0;
}
]])
],[
utils_cv_vmull_intrinsic_exists=yes
],[
utils_cv_vmull_intrinsic_exists=no
])])
AC_MSG_RESULT([$utils_cv_vmull_intrinsic_exists])
if test $utils_cv_vmull_intrinsic_exists = yes; then
AC_DEFINE([USE_VMULL_CRC32], [1],
[CRC32 calculation by vmull hardware instruction enabled])
fi
AM_CONDITIONAL([USE_VMULL_CRC32],
[test $utils_cv_vmull_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
ac_save_CFLAGS=$CFLAGS
CFLAGS="-mavx -mpclmul $CFLAGS"
AC_MSG_CHECKING([if pclmul intrinsic exists])
AC_CACHE_VAL([utils_cv_pclmul_intrinsic_exists],[
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <x86intrin.h>
int
main (void)
{
__m128i a, b;
a = _mm_clmulepi64_si128 (a, b, 0x00);
a = _mm_shuffle_epi8 (a, b);
return __builtin_cpu_supports ("pclmul");
}
]])
],[
utils_cv_pclmul_intrinsic_exists=yes
],[
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 $utils_cv_pclmul_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
ac_save_CFLAGS=$CFLAGS
CFLAGS=" -mavx2 -mvpclmulqdq $CFLAGS"
AC_MSG_CHECKING([if avx2 pclmul intrinsic exists])
AC_CACHE_VAL([utils_cv_avx2_pclmul_intrinsic_exists],[
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <x86intrin.h>
int
main (void)
{
__m256i a, b;
a = _mm256_clmulepi64_epi128 (a, b, 0x00);
a = _mm256_shuffle_epi8 (a, b);
return __builtin_cpu_supports ("avx2") &&
__builtin_cpu_supports ("vpclmulqdq");
}
]])
],[
utils_cv_avx2_pclmul_intrinsic_exists=yes
],[
utils_cv_avx2_pclmul_intrinsic_exists=no
])])
AC_MSG_RESULT([$utils_cv_avx2_pclmul_intrinsic_exists])
if test $utils_cv_avx2_pclmul_intrinsic_exists = yes; then
AC_DEFINE([USE_AVX2_CRC32], [1],
[CRC32 calculation by avx2 hardware instructions enabled])
fi
AM_CONDITIONAL([USE_AVX2_CRC32],
[test $utils_cv_avx2_pclmul_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
ac_save_CFLAGS=$CFLAGS
CFLAGS=" -mavx512bw -mavx512f -mvpclmulqdq $CFLAGS"
AC_MSG_CHECKING([if avx512 pclmul intrinsic exists])
AC_CACHE_VAL([utils_cv_avx512_pclmul_intrinsic_exists],[
AC_LINK_IFELSE(
[AC_LANG_SOURCE([[
#include <x86intrin.h>
int
main (void)
{
__m512i a, b;
a = _mm512_set_epi8 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
a = _mm512_clmulepi64_epi128 (a, b, 0x00);
a = _mm512_shuffle_epi8 (a, b);
return (__builtin_cpu_supports ("avx512bw")
&& __builtin_cpu_supports ("avx512f")
&& __builtin_cpu_supports ("vpclmulqdq"));
}
]])
],[
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 $utils_cv_avx2_intrinsic_exists = yes])
CFLAGS=$ac_save_CFLAGS
############################################################################
@@ -445,6 +753,8 @@ m4_include([m4/cu-progs.m4])
# Now that we know which programs will actually be built, determine
# which optional helper progs should be compiled.
# Note it adding to pkglibexec_PROGRAMS, $(transform) in src/local.mk
# may need to be updated accordingly.
case " $optional_bin_progs " in
*' stdbuf '*) pkglibexec_PROGRAMS='src/libstdbuf.so';;
*) pkglibexec_PROGRAMS='';;
@@ -464,7 +774,55 @@ man1_MANS=`
# Not installed by "make install", but must be built when creating
# a distribution tarball.
EXTRA_MANS=`for p in $no_install_progs_default; do echo man/$p.1; done`
EXTRA_MANS=`for p in $no_install_progs_default $gl_no_install_prog; do
echo man/$p.1
done`
# Replace all the programs by the single binary and symlinks if specified.
single_binary_progs=
single_binary_libs=
single_binary_deps=
single_binary_install_type=
if test "$gl_single_binary" != no; then
man1_MANS="$man1_MANS man/coreutils.1"
# Convert the list to a space separated list
gl_single_binary_exceptions=`echo $gl_single_binary_exceptions | tr ',' ' '`
single_binary_progs=`echo $optional_bin_progs`
optional_bin_progs="coreutils"
for prog in $gl_single_binary_exceptions; do
# Fail if requested to exclude a program than was not part of coreutils.
case " $single_binary_progs " in
*" $prog "*)
gl_REMOVE_PROG([single_binary_progs], [$prog]) ;
gl_ADD_PROG([optional_bin_progs], [$prog]) ;;
*) AC_MSG_ERROR(['$prog' is not being compiled.]) ;;
esac
done
# single_binary_libs holds the list of libs required by the selected
# programs, such as for example -lrt.
single_binary_libs=`
for p in $single_binary_progs; do
# Convert '[' to '_'
test x"$p" = x'@<:@' && p='_'
printf '$(src_libsinglebin_%s_a_ldadd) ' "$p"
done`
# single_binary_deps holds the list of libsinglebin_*.a files that have the
# compiled code of each selected program in a "library" format.
single_binary_deps=`
for p in $single_binary_progs; do
# Convert '[' to '_'
test x"$p" = x'@<:@' && p='_'
printf 'src/libsinglebin_%s.a ' "$p"
done`
single_binary_install_type="$gl_single_binary"
fi
AC_SUBST([single_binary_progs], [$single_binary_progs])
AC_SUBST([single_binary_libs], [$single_binary_libs])
AC_SUBST([single_binary_deps], [$single_binary_deps])
AC_SUBST([single_binary_install_type], [$single_binary_install_type])
# The programs built and installed by "make && make install".
# Since this is AC_SUBST'd, Automake won't be able to perform rewrite
@@ -493,7 +851,7 @@ AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
# As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
# translatable strings, we must use need-formatstring-macros here.
AM_GNU_GETTEXT([external], [need-formatstring-macros])
AM_GNU_GETTEXT_VERSION([0.18.1])
AM_GNU_GETTEXT_VERSION([0.19.2])
# For a test of uniq: it uses the $LOCALE_FR envvar.
gt_LOCALE_FR

View File

@@ -120,6 +120,10 @@ my-distcheck: $(DIST_ARCHIVES) $(local-check)
)
(cd $(t) && mv $(distdir) $(distdir).old \
&& $(amtar_extract_) - ) < $(preferred_tarball_)
# With post-v1.15 automake, "distclean" would fail to remove .deps
# directories, leading to a spurious failure of the following recursive diff.
# FIXME: remove this, once automake is fixed.
find $(t)/$(distdir).old $(t)/$(distdir) -name .deps | xargs -r rmdir
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
-rm -rf $(t)
rmdir $(tmpdir)/$(PACKAGE) $(tmpdir)

7
doc/.gitignore vendored
View File

@@ -1,3 +1,4 @@
/.dirstamp
/constants.texi
/coreutils.aux
/coreutils.cp
@@ -12,12 +13,14 @@
/coreutils.op
/coreutils.pdf
/coreutils.pg
/coreutils.ps
/coreutils.t2d/
/coreutils.t2p/
/coreutils.toc
/coreutils.tp
/coreutils.vr
/fdl.texi
/gendocs_template
/gendocs_template_min
/parse-datetime.texi
/stamp-vti
/version.texi
/.dirstamp

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

505
doc/fdl.texi Normal file
View File

@@ -0,0 +1,505 @@
@c The GNU Free Documentation License.
@center Version 1.3, 3 November 2008
@c This file is intended to be included within another document,
@c hence no sectioning command or @node.
@display
Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
@uref{https://fsf.org/}
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@end display
@enumerate 0
@item
PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document @dfn{free} in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
This License is a kind of ``copyleft'', which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
@item
APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The ``Document'', below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as ``you''. You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
A ``Modified Version'' of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A ``Secondary Section'' is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject. (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
The ``Invariant Sections'' are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
The ``Cover Texts'' are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
A ``Transparent'' copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not ``Transparent'' is called ``Opaque''.
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, La@TeX{} input
format, SGML or XML using a publicly available
DTD, and standard-conforming simple HTML,
PostScript or PDF designed for human modification. Examples
of transparent image formats include PNG, XCF and
JPG@. Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, SGML or
XML for which the DTD and/or processing tools are
not generally available, and the machine-generated HTML,
PostScript or PDF produced by some word processors for
output purposes only.
The ``Title Page'' means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
The ``publisher'' means any person or entity that distributes copies
of the Document to the public.
A section ``Entitled XYZ'' means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as ``Acknowledgements'',
``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
of such a section when you modify the Document means that it remains a
section ``Entitled XYZ'' according to this definition.
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
@item
VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
@item
COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
@item
MODIFICATIONS
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
@enumerate A
@item
Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
@item
List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
@item
State on the Title page the name of the publisher of the
Modified Version, as the publisher.
@item
Preserve all the copyright notices of the Document.
@item
Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
@item
Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
@item
Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
@item
Include an unaltered copy of this License.
@item
Preserve the section Entitled ``History'', Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled ``History'' in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
@item
Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the ``History'' section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
@item
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
the Title of the section, and preserve in the section all the
substance and tone of each of the contributor acknowledgements and/or
dedications given therein.
@item
Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
@item
Delete any section Entitled ``Endorsements''. Such a section
may not be included in the Modified Version.
@item
Do not retitle any existing section to be Entitled ``Endorsements'' or
to conflict in title with any Invariant Section.
@item
Preserve any Warranty Disclaimers.
@end enumerate
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
You may add a section Entitled ``Endorsements'', provided it contains
nothing but endorsements of your Modified Version by various
parties---for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
@item
COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled ``History''
in the various original documents, forming one section Entitled
``History''; likewise combine any sections Entitled ``Acknowledgements'',
and any sections Entitled ``Dedications''. You must delete all
sections Entitled ``Endorsements.''
@item
COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
@item
AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an ``aggregate'' if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
@item
TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
If a section in the Document is Entitled ``Acknowledgements'',
``Dedications'', or ``History'', the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
@item
TERMINATION
You may not copy, modify, sublicense, or distribute the Document
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense, or distribute it is void, and
will automatically terminate your rights under this License.
However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, receipt of a copy of some or all of the same material does
not give you any rights to use it.
@item
FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
@uref{https://www.gnu.org/licenses/}.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License ``or any later version'' applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation. If the Document
specifies that a proxy can decide which future versions of this
License can be used, that proxy's public statement of acceptance of a
version permanently authorizes you to choose that version for the
Document.
@item
RELICENSING
``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any
World Wide Web server that publishes copyrightable works and also
provides prominent facilities for anybody to edit those works. A
public wiki that anybody can edit is an example of such a server. A
``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the
site means any set of copyrightable works thus published on the MMC
site.
``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit
corporation with a principal place of business in San Francisco,
California, as well as future copyleft versions of that license
published by that same organization.
``Incorporate'' means to publish or republish a Document, in whole or
in part, as part of another Document.
An MMC is ``eligible for relicensing'' if it is licensed under this
License, and if all works that were first published under this License
somewhere other than this MMC, and subsequently incorporated in whole
or in part into the MMC, (1) had no cover texts or invariant sections,
and (2) were thus incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site
under CC-BY-SA on the same site at any time before August 1, 2009,
provided the MMC is eligible for relicensing.
@end enumerate
@page
@heading ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
@smallexample
@group
Copyright (C) @var{year} @var{your name}.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
@end group
@end smallexample
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the ``with@dots{}Texts.''@: line with this:
@smallexample
@group
with the Invariant Sections being @var{list their titles}, with
the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
being @var{list}.
@end group
@end smallexample
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
@c Local Variables:
@c ispell-local-pdict: "ispell-dict"
@c End:

View File

@@ -1,7 +1,7 @@
# Make coreutils documentation. -*-Makefile-*-
# This is included by the top-level Makefile.am.
# Copyright (C) 1995-2013 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
@@ -14,7 +14,7 @@
# 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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
info_TEXINFOS = doc/coreutils.texi
@@ -22,7 +22,12 @@ doc_coreutils_TEXINFOS = \
doc/perm.texi \
doc/parse-datetime.texi \
doc/constants.texi \
doc/fdl.texi
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,
@@ -37,12 +42,13 @@ AM_MAKEINFOFLAGS = --no-split
doc/constants.texi: $(top_srcdir)/src/tail.c $(top_srcdir)/src/shred.c
$(AM_V_GEN)LC_ALL=C; export LC_ALL; \
$(MKDIR_P) doc && \
{ sed -n -e 's/^#define \(DEFAULT_MAX[_A-Z]*\) \(.*\)/@set \1 \2/p' \
{ sed -n -e \
's/.*\(DEFAULT_MAX[_A-Z]*\)[ =]* \([0-9]*\).*/@set \1 \2/p' \
$(top_srcdir)/src/tail.c && \
sed -n -e \
's/.*\(DEFAULT_PASSES\)[ =]* \([0-9]*\).*/@set SHRED_\1 \2/p'\
$(top_srcdir)/src/shred.c; } > $@-t \
&& mv $@-t $@
&& { cmp $@-t $@ >/dev/null 2>&1 || mv $@-t $@; rm -f $@-t; }
MAINTAINERCLEANFILES += doc/constants.texi
@@ -113,8 +119,8 @@ sc-avoid-zeroes:
# The leading backslash exemption is to permit in-macro uses like
# @var{\varName\} where the upper case letter is part of a parameter name.
find_upper_case_var = \
'/\@var{/ or next; \
while (/\@var{(.+?)}/g) \
'/\@var\{/ or next; \
while (/\@var\{(.+?)}/g) \
{ \
$$v = $$1; \
$$v =~ /[A-Z]/ && $$v !~ /^\\/ and (print "$$ARGV:$$.:$$_"), $$m = 1 \

View File

@@ -1,6 +1,6 @@
@c File mode bits
@c Copyright (C) 1994-2013 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
@@ -70,38 +70,36 @@ In addition to the three sets of three permissions listed above, the
file mode bits have three special components, which affect only
executable files (programs) and, on most systems, directories:
@enumerate
@item
@table @asis
@item The @dfn{set-user-ID bit} (@dfn{setuid bit}).
@cindex set-user-ID
@cindex setuid
Set the process's effective user ID to that of the file upon execution
(called the @dfn{set-user-ID bit}, or sometimes the @dfn{setuid bit}).
On execution, set the process's effective user ID to that of the file.
For directories on a few systems, give files created in the directory
the same owner as the directory, no matter who creates them, and set
the set-user-ID bit of newly-created subdirectories.
@item
@item The @dfn{set-group-ID bit} (@dfn{setgid bit}).
@cindex set-group-ID
@cindex setgid
Set the process's effective group ID to that of the file upon execution
(called the @dfn{set-group-ID bit}, or sometimes the @dfn{setgid bit}).
On execution, set the process's effective group ID to that of the file.
For directories on most systems, give files created in the directory
the same group as the directory, no matter what group the user who
creates them is in, and set the set-group-ID bit of newly-created
subdirectories.
@item
@item The @dfn{restricted deletion flag} or @dfn{sticky bit}.
@cindex sticky
@cindex swap space, saving text image in
@cindex text image, saving in swap space
@cindex restricted deletion flag
Prevent unprivileged users from removing or renaming a file in a directory
unless they own the file or the directory; this is called the
@dfn{restricted deletion flag} for the directory, and is commonly
unless they own the file or the directory; this is commonly
found on world-writable directories like @file{/tmp}.
For regular files on some older systems, save the program's text image on the
swap device so it will load more quickly when run; this is called the
@dfn{sticky bit}.
@end enumerate
swap device so it will load more quickly when run, so that the image
is ``sticky''.
@end table
In addition to the file mode bits listed above, there may be file attributes
specific to the file system, e.g., access control lists (ACLs), whether a
@@ -148,7 +146,7 @@ their previous values, and perhaps on the current @code{umask} as well
The format of symbolic modes is:
@example
@r{[}ugoa@dots{}@r{][}+-=@r{]}@var{perms}@dots{}@r{[},@dots{}@r{]}
@r{[}ugoa@dots{}@r{][}-+=@r{]}@var{perms}@dots{}@r{[},@dots{}@r{]}
@end example
@noindent
@@ -494,10 +492,47 @@ the file to all users.
As an
alternative to giving a symbolic mode, you can give an octal (base 8)
number that represents the mode.
This number is always interpreted in octal; you do not have to add a
leading @samp{0}, as you do in C. Mode @samp{0055} is the same as
mode @samp{55}. (However, modes of five digits or more, such as
@samp{00055}, are sometimes special. @xref{Directory Setuid and Setgid}.)
The permissions granted to the user,
to other users in the file's group,
and to other users not in the file's group each require three
bits: one bit for read, one for write, and one for execute/search permission.
These three bits are represented as one octal digit;
for example, if all three are present, the resulting 111 (in binary)
is represented as the digit 7 (in octal). The three special
mode bits also require one bit each, and they are as a group
represented as another octal digit. Here is how the bits are arranged,
starting with the highest valued bit:
@example
Value in Corresponding
Mode Mode Bit
Special mode bits:
4000 Set user ID
2000 Set group ID
1000 Restricted deletion flag or sticky bit
The file's owner:
400 Read
200 Write
100 Execute/search
Other users in the file's group:
40 Read
20 Write
10 Execute/search
Other users not in the file's group:
4 Read
2 Write
1 Execute/search
@end example
For example, numeric mode @samp{4751} corresponds to symbolic mode
@samp{u=srwx,g=rx,o=x}, and numeric mode @samp{664} corresponds to symbolic mode
@samp{ug=rw,o=r}. Numeric mode @samp{0} corresponds to symbolic mode
@samp{a=}.
A numeric mode is usually shorter than the corresponding symbolic
mode, but it is limited in that normally it cannot take into account the
@@ -507,43 +542,10 @@ to this general limitation. @xref{Directory Setuid and Setgid}.
Also, operator numeric modes can take previous file mode bits into
account. @xref{Operator Numeric Modes}.
The permissions granted to the user,
to other users in the file's group,
and to other users not in the file's group each require three
bits, which are represented as one octal digit. The three special
mode bits also require one bit each, and they are as a group
represented as another octal digit. Here is how the bits are arranged,
starting with the lowest valued bit:
@example
Value in Corresponding
Mode Mode Bit
Other users not in the file's group:
1 Execute/search
2 Write
4 Read
Other users in the file's group:
10 Execute/search
20 Write
40 Read
The file's owner:
100 Execute/search
200 Write
400 Read
Special mode bits:
1000 Restricted deletion flag or sticky bit
2000 Set group ID on execution
4000 Set user ID on execution
@end example
For example, numeric mode @samp{4755} corresponds to symbolic mode
@samp{u=rwxs,go=rx}, and numeric mode @samp{664} corresponds to symbolic mode
@samp{ug=rw,o=r}. Numeric mode @samp{0} corresponds to symbolic mode
@samp{a=}.
Numeric modes are always interpreted in octal; you do not have to add a
leading @samp{0}, as you do in C@. Mode @samp{0055} is the same as
mode @samp{55}. However, modes of five digits or more, such as
@samp{00055}, are sometimes special (@pxref{Directory Setuid and Setgid}).
@node Operator Numeric Modes
@section Operator Numeric Modes

909
doc/sort-version.texi Normal file
View File

@@ -0,0 +1,909 @@
@c GNU Version-sort ordering documentation
@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
@c any later version published by the Free Software Foundation; with no
@c Invariant Sections, no Front-Cover Texts, and no Back-Cover
@c Texts. A copy of the license is included in the ``GNU Free
@c Documentation License'' file as part of this distribution.
@c Written by Assaf Gordon
@node Version sort ordering
@chapter Version sort ordering
@node Version sort overview
@section Version sort overview
@dfn{Version sort} puts items such as file names and lines of
text in an order that feels natural to people, when the text
contains a mixture of letters and digits.
Lexicographic sorting usually does not produce the order that one expects
because comparisons are made on a character-by-character basis.
Compare the sorting of the following items:
@example
Lexicographic sort: Version Sort:
a1 a1
a120 a2
a13 a13
a2 a120
@end example
Version sort functionality in GNU Coreutils is available in the @samp{ls -v},
@samp{ls --sort=version}, @samp{sort -V}, and
@samp{sort --version-sort} commands.
@node Using version sort in GNU Coreutils
@subsection Using version sort in GNU Coreutils
Two GNU Coreutils programs use version sort: @command{ls} and @command{sort}.
To list files in version sort order, use @command{ls}
with the @option{-v} or @option{--sort=version} option:
@example
default sort: version sort:
$ ls -1 $ ls -1 -v
a1 a1
a100 a1.4
a1.13 a1.13
a1.4 a1.40
a1.40 a2
a2 a100
@end example
To sort text files in version sort order, use @command{sort} with
the @option{-V} or @option{--version-sort} option:
@example
$ cat input
b3
b11
b1
b20
lexicographic order: version sort order:
$ sort input $ sort -V input
b1 b1
b11 b3
b20 b11
b3 b20
@end example
To sort a specific field in a file, use @option{-k/--key} with
@samp{V} type sorting, which is often combined with @samp{b} to
ignore leading blanks in the field:
@example
$ cat input2
100 b3 apples
2000 b11 oranges
3000 b1 potatoes
4000 b20 bananas
$ sort -k 2bV,2 input2
3000 b1 potatoes
100 b3 apples
2000 b11 oranges
4000 b20 bananas
@end example
@node Version sort and natural sort
@subsection Version sort and natural sort
In GNU Coreutils, the name @dfn{version sort} was chosen because it is based
on Debian GNU/Linux's algorithm of sorting packages' versions.
Its goal is to answer questions like
``Which package is newer, @file{firefox-60.7.2} or @file{firefox-60.12.3}?''
In Coreutils this algorithm was slightly modified to work on more
general input such as textual strings and file names
(see @ref{Differences from Debian version sort}).
In other contexts, such as other programs and other programming
languages, a similar sorting functionality is called
@uref{https://en.wikipedia.org/wiki/Natural_sort_order,natural sort}.
@node Variations in version sort order
@subsection Variations in version sort order
Currently there is no standard for version sort.
That is: there is no one correct way or universally agreed-upon way to
order items. Each program and each programming language can decide its
own ordering algorithm and call it ``version sort'', ``natural sort'',
or other names.
See @ref{Other version/natural sort implementations} for many examples of
differing sorting possibilities, each with its own rules and variations.
If you find a bug in the Coreutils implementation of version-sort, please
report it. @xref{Reporting version sort bugs}.
@node Version sort implementation
@section Version sort implementation
GNU Coreutils version sort is based on the ``upstream version''
part of
@uref{https://www.debian.org/doc/debian-policy/ch-controlfields.html#version,
Debian's versioning scheme}.
This section describes the GNU Coreutils sort ordering rules.
The next section (@ref{Differences from Debian version
sort}) describes some differences between GNU Coreutils
and Debian version sort.
@node Version-sort ordering rules
@subsection Version-sort ordering rules
The version sort ordering rules are:
@enumerate
@item
The strings are compared from left to right.
@item
First the initial part of each string consisting entirely of non-digit
bytes is determined.
@enumerate A
@item
These two parts (either of which may be empty) are compared lexically.
If a difference is found it is returned.
@item
The lexical comparison is a lexicographic comparison of byte strings,
except that:
@enumerate a
@item
ASCII letters sort before other bytes.
@item
A tilde sorts before anything, even an empty string.
@end enumerate
@end enumerate
@item
Then the initial part of the remainder of each string that contains
all the leading digits is determined. The numerical values represented by
these two parts are compared, and any difference found is returned as
the result of the comparison.
@enumerate A
@item
For these purposes an empty string (which can only occur at the end of
one or both version strings being compared) counts as zero.
@item
Because the numerical value is used, non-identical strings can compare
equal. For example, @samp{123} compares equal to @samp{00123}, and
the empty string compares equal to @samp{0}.
@end enumerate
@item
These two steps (comparing and removing initial non-digit strings and
initial digit strings) are repeated until a difference is found or
both strings are exhausted.
@end enumerate
Consider the version-sort comparison of two file names:
@file{foo07.7z} and @file{foo7a.7z}. The two strings will be broken
down to the following parts, and the parts compared respectively from
each string:
@example
foo @r{vs} foo @r{(rule 2, non-digits)}
07 @r{vs} 7 @r{(rule 3, digits)}
. @r{vs} a. @r{(rule 2)}
7 @r{vs} 7 @r{(rule 3)}
z @r{vs} z @r{(rule 2)}
@end example
Comparison flow based on above algorithm:
@enumerate
@item
The first parts (@samp{foo}) are identical.
@item
The second parts (@samp{07} and @samp{7}) are compared numerically,
and compare equal.
@item
The third parts (@samp{.} vs @samp{a.}) are compared
lexically by ASCII value (rule 2.B).
@item
The first byte of the first string (@samp{.}) is compared
to the first byte of the second string (@samp{a}).
@item
Rule 2.B.a says letters sorts before non-letters.
Hence, @samp{a} comes before @samp{.}.
@item
The returned result is that @file{foo7a.7z} comes before @file{foo07.7z}.
@end enumerate
Result when using sort:
@example
$ cat input3
foo07.7z
foo7a.7z
$ sort -V input3
foo7a.7z
foo07.7z
@end example
See @ref{Differences from Debian version sort} for
additional rules that extend the Debian algorithm in Coreutils.
@node Version sort is not the same as numeric sort
@subsection Version sort is not the same as numeric sort
Consider the following text file:
@example
$ cat input4
8.10
8.5
8.1
8.01
8.010
8.100
8.49
Numerical Sort: Version Sort:
$ sort -n input4 $ sort -V input4
8.01 8.01
8.010 8.1
8.1 8.5
8.10 8.010
8.100 8.10
8.49 8.49
8.5 8.100
@end example
Numeric sort (@samp{sort -n}) treats the entire string as a single numeric
value, and compares it to other values. For example, @samp{8.1}, @samp{8.10} and
@samp{8.100} are numerically equivalent, and are ordered together. Similarly,
@samp{8.49} is numerically less than @samp{8.5}, and appears before first.
Version sort (@samp{sort -V}) first breaks down the string into digit and
non-digit parts, and only then compares each part (see annotated
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}) --
which are numerically equal. Hence, @samp{8.01} and @samp{8.1}
are grouped together.
Similarly, comparing @samp{8.5} to @samp{8.49} -- the @samp{8}
and @samp{.} parts are identical, then the numeric values @samp{5} and
@samp{49} are compared. The resulting @samp{5} appears before @samp{49}.
This sorting order (where @samp{8.5} comes before @samp{8.49}) is common when
assigning versions to computer programs (while perhaps not intuitive
or ``natural'' for people).
@node Version sort punctuation
@subsection Version sort punctuation
Punctuation is sorted by ASCII order (rule 2.B).
@example
$ touch 1.0.5_src.tar.gz 1.0_src.tar.gz
$ ls -v -1
1.0.5_src.tar.gz
1.0_src.tar.gz
@end example
Why is @file{1.0.5_src.tar.gz} listed before @file{1.0_src.tar.gz}?
Based on the version-sort ordering rules, the strings are broken down
into the following parts:
@example
1 @r{vs} 1 @r{(rule 3, all digits)}
. @r{vs} . @r{(rule 2, all non-digits)}
0 @r{vs} 0 @r{(rule 3)}
. @r{vs} _src.tar.gz @r{(rule 2)}
5 @r{vs} empty string @r{(no more bytes in the file name)}
_src.tar.gz @r{vs} empty string
@end example
The fourth parts (@samp{.} and @samp{_src.tar.gz}) are compared
lexically by ASCII order. The @samp{.} (ASCII value 46) is
less than @samp{_} (ASCII value 95) -- and should be listed before it.
Hence, @file{1.0.5_src.tar.gz} is listed first.
If a different byte appears instead of the underscore (for
example, percent sign @samp{%} ASCII value 37, which is less
than dot's ASCII value of 46), that file will be listed first:
@example
$ touch 1.0.5_src.tar.gz 1.0%zzzzz.gz
1.0%zzzzz.gz
1.0.5_src.tar.gz
@end example
The same reasoning applies to the following example, as @samp{.} with
ASCII value 46 is less than @samp{/} with ASCII value 47:
@example
$ cat input5
3.0/
3.0.5
$ sort -V input5
3.0.5
3.0/
@end example
@node Punctuation vs letters
@subsection Punctuation vs letters
Rule 2.B.a says letters sort before non-letters
(after breaking down a string to digit and non-digit parts).
@example
$ cat input6
a%
az
$ sort -V input6
az
a%
@end example
The input strings consist entirely of non-digits, and based on the
above algorithm have only one part, all non-digits
(@samp{a%} vs @samp{az}).
Each part is then compared lexically,
byte-by-byte; @samp{a} compares identically in both
strings.
Rule 2.B.a says a letter like @samp{z} sorts before
a non-letter like @samp{%} -- hence @samp{az} appears first (despite
@samp{z} having ASCII value of 122, much larger than @samp{%}
with ASCII value 37).
@node The tilde @samp{~}
@subsection The tilde @samp{~}
Rule 2.B.b says the tilde @samp{~} (ASCII 126) sorts
before other bytes, and before an empty string.
@example
$ cat input7
1
1%
1.2
1~
~
$ sort -V input7
~
1~
1
1%
1.2
@end example
The sorting algorithm starts by breaking down the string into
non-digit (rule 2) and digit parts (rule 3).
In the above input file, only the last line in the input file starts
with a non-digit (@samp{~}). This is the first part. All other lines
in the input file start with a digit -- their first non-digit part is
empty.
Based on rule 2.B.b, tilde @samp{~} sorts before other bytes
and before the empty string -- hence it comes before all other strings,
and is listed first in the sorted output.
The remaining lines (@samp{1}, @samp{1%}, @samp{1.2}, @samp{1~})
follow similar logic: The digit part is extracted (1 for all strings)
and compares equal. The following extracted parts for the remaining
input lines are: empty part, @samp{%}, @samp{.}, @samp{~}.
Tilde sorts before all others, hence the line @samp{1~} appears next.
The remaining lines (@samp{1}, @samp{1%}, @samp{1.2}) are sorted based
on previously explained rules.
@node Version sort ignores locale
@subsection Version sort ignores locale
In version sort, Unicode characters are compared byte-by-byte according
to their binary representation, ignoring their Unicode value or the
current locale.
Most commonly, Unicode characters are encoded as UTF-8 bytes; for
example, GREEK SMALL LETTER ALPHA (U+03B1, @samp{α}) is encoded as the
UTF-8 sequence @samp{0xCE 0xB1}). The encoding is compared
byte-by-byte, e.g., first @samp{0xCE} (decimal value 206) then
@samp{0xB1} (decimal value 177).
@example
$ touch aa az "a%" "aα"
$ ls -1 -v
aa
az
a%
aα
@end example
Ignoring the first letter (@samp{a}) which is identical in all
strings, the compared values are:
@samp{a} and @samp{z} are letters, and sort before
all other non-digits.
Then, percent sign @samp{%} (ASCII value 37) is compared to the
first byte of the UTF-8 sequence of @samp{α}, which is 0xCE or 206). The
value 37 is smaller, hence @samp{a%} is listed before @samp{aα}.
@node Differences from Debian version sort
@section Differences from Debian version sort
GNU Coreutils version sort differs slightly from the
official Debian algorithm, in order to accommodate more general usage
and file name listing.
@node Hyphen-minus and colon
@subsection Hyphen-minus @samp{-} and colon @samp{:}
In Debian's version string syntax the version consists of three parts:
@example
[epoch:]upstream_version[-debian_revision]
@end example
The @samp{epoch} and @samp{debian_revision} parts are optional.
Example of such version strings:
@example
60.7.2esr-1~deb9u1
52.9.0esr-1~deb9u1
1:2.3.4-1+b2
327-2
1:1.0.13-3
2:1.19.2-1+deb9u5
@end example
If the @samp{debian_revision part} is not present,
hyphens @samp{-} are not allowed.
If epoch is not present, colons @samp{:} are not allowed.
If these parts are present, hyphen and/or colons can appear only once
in valid Debian version strings.
In GNU Coreutils, such restrictions are not reasonable (a file name can
have many hyphens, a line of text can have many colons).
As a result, in GNU Coreutils hyphens and colons are treated exactly
like all other punctuation, i.e., they are sorted after
letters. @xref{Version sort punctuation}.
In Debian, these characters are treated differently than in Coreutils:
a version string with hyphen will sort before similar strings without
hyphens.
Compare:
@example
$ touch 1ab-cd 1abb
$ ls -v -1
1abb
1ab-cd
$ if dpkg --compare-versions 1abb lt 1ab-cd
> then echo sorted
> else echo out of order
> fi
out of order
@end example
For further details, see @ref{Comparing two strings using Debian's
algorithm} and @uref{https://bugs.gnu.org/35939,GNU Bug 35939}.
@node Special priority in GNU Coreutils version sort
@subsection Special priority in GNU Coreutils version sort
In GNU Coreutils version sort, the following items have
special priority and sort before all other strings (listed in order):
@enumerate
@item The empty string
@item The string @samp{.} (a single dot, ASCII 46)
@item The string @samp{..} (two dots)
@item Strings starting with dot (@samp{.}) sort before
strings starting with any other byte.
@end enumerate
Example:
@example
$ printf '%s\n' a "" b "." c ".." ".d20" ".d3" | sort -V
.
..
.d3
.d20
a
b
c
@end example
These priorities make perfect sense for @samp{ls -v}: The special
files dot @samp{.} and dot-dot @samp{..} will be listed
first, followed by any hidden files (files starting with a dot),
followed by non-hidden files.
For @samp{sort -V} these priorities might seem arbitrary. However,
because the sorting code is shared between the @command{ls} and @command{sort}
program, the ordering rules are the same.
@node Special handling of file extensions
@subsection Special handling of file extensions
GNU Coreutils version sort implements specialized handling
of strings that look like file names with extensions.
This enables slightly more natural ordering of file
names.
The following additional rules apply when comparing two strings where
both begin with non-@samp{.}. They also apply when comparing two
strings where both begin with @samp{.} but neither is @samp{.} or @samp{..}.
@enumerate
@item
A suffix (i.e., a file extension) is defined as: a dot, followed by an
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
without them, using version sort (see @ref{Version-sort ordering
rules}) without special priority (see @ref{Special priority in GNU
Coreutils version sort}).
@item
If the suffix-less strings do not compare equal, this comparison
result is used and the suffixes are effectively ignored.
@item
If the suffix-less strings compare equal, the suffixes are restored
and the entire strings are compared using version sort.
@end enumerate
Examples for rule 1:
@itemize
@item
@samp{hello-8.txt}: the suffix is @samp{.txt}
@item
@samp{hello-8.2.txt}: the suffix is @samp{.txt}
(@samp{.2} is not included because the dot is not followed by a letter)
@item
@samp{hello-8.0.12.tar.gz}: the suffix is @samp{.tar.gz} (@samp{.0.12}
is not included)
@item
@samp{hello-8.2}: no suffix (suffix is an empty string)
@item
@samp{hello.foobar65}: the suffix is @samp{.foobar65}
@item
@samp{gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2}: the suffix is
@samp{.fc9.tar.bz2} (@samp{.7rc2} is not included as it begins with a digit)
@item
@samp{.autom4te.cfg}: the suffix is the entire string.
@end itemize
Examples for rule 2:
@itemize
@item
Comparing @samp{hello-8.txt} to @samp{hello-8.2.12.txt}, the
@samp{.txt} suffix is temporarily removed from both strings.
@item
Comparing @samp{foo-10.3.tar.gz} to @samp{foo-10.tar.xz}, the suffixes
@samp{.tar.gz} and @samp{.tar.xz} are temporarily removed from the
strings.
@end itemize
Example for rule 3:
@itemize
@item
Comparing @samp{hello.foobar65} to @samp{hello.foobar4}, the suffixes
(@samp{.foobar65} and @samp{.foobar4}) are temporarily removed. The
remaining strings are identical (@samp{hello}). The suffixes are then
restored, and the entire strings are compared (@samp{hello.foobar4} comes
first).
@end itemize
Examples for rule 4:
@itemize
@item
When comparing the strings @samp{hello-8.2.txt} and @samp{hello-8.10.txt}, the
suffixes (@samp{.txt}) are temporarily removed. The remaining strings
(@samp{hello-8.2} and @samp{hello-8.10}) are compared as previously described
(@samp{hello-8.2} comes first).
@slanted{(In this case the suffix removal algorithm
does not have a noticeable effect on the resulting order.)}
@end itemize
@b{How does the suffix-removal algorithm effect ordering results?}
Consider the comparison of hello-8.txt and hello-8.2.txt.
Without the suffix-removal algorithm, the strings will be broken down
to the following parts:
@example
hello- @r{vs} hello- @r{(rule 2, all non-digits)}
8 @r{vs} 8 @r{(rule 3, all digits)}
.txt @r{vs} . @r{(rule 2)}
empty @r{vs} 2
empty @r{vs} .txt
@end example
The comparison of the third parts (@samp{.} vs
@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.
A more natural result is that @file{hello-8.txt} should come before
@file{hello-8.2.txt}, and this is where the suffix-removal comes into play:
The suffixes (@samp{.txt}) are removed, and the remaining strings are
broken down into the following parts:
@example
hello- @r{vs} hello- @r{(rule 2, all non-digits)}
8 @r{vs} 8 @r{(rule 3, all digits)}
empty @r{vs} . @r{(rule 2)}
empty @r{vs} 2
@end example
As empty strings sort before non-empty strings, the result is @samp{hello-8}
being first.
A real-world example would be listing files such as:
@file{gcc_10.fc9.tar.gz}
and @file{gcc_10.8.12.7rc2.fc9.tar.bz2}: Debian's algorithm would list
@file{gcc_10.8.12.7rc2.fc9.tar.bz2} first, while @samp{ls -v} will list
@file{gcc_10.fc9.tar.gz} first.
These priorities make sense for @samp{ls -v}:
Versioned files will be listed in a more natural order.
For @samp{sort -V} these priorities might seem arbitrary. However,
because the sorting code is shared between the @command{ls} and @command{sort}
program, the ordering rules are the same.
@node Comparing two strings using Debian's algorithm
@subsection Comparing two strings using Debian's algorithm
The Debian program @command{dpkg} (available on all Debian and Ubuntu
installations) can compare two strings using the @option{--compare-versions}
option.
To use it, create a helper shell function (simply copy & paste the
following snippet to your shell command-prompt):
@example
compver() @{
if dpkg --compare-versions "$1" lt "$2"
then printf '%s\n' "$1" "$2"
else printf '%s\n' "$2" "$1"
fi
@}
@end example
Then compare two strings by calling @command{compver}:
@example
$ compver 8.49 8.5
8.5
8.49
@end example
Note that @command{dpkg} will warn if the strings have invalid syntax:
@example
$ compver "foo07.7z" "foo7a.7z"
dpkg: warning: version 'foo07.7z' has bad syntax:
version number does not start with digit
dpkg: warning: version 'foo7a.7z' has bad syntax:
version number does not start with digit
foo7a.7z
foo07.7z
$ compver "3.0/" "3.0.5"
dpkg: warning: version '3.0/' has bad syntax:
invalid character in version number
3.0.5
3.0/
@end example
To illustrate the different handling of hyphens between Debian and
Coreutils algorithms (see
@ref{Hyphen-minus and colon}):
@example
$ compver abb ab-cd 2>/dev/null $ printf 'abb\nab-cd\n' | sort -V
ab-cd abb
abb ab-cd
@end example
To illustrate the different handling of file extension: (see @ref{Special
handling of file extensions}):
@example
$ compver hello-8.txt hello-8.2.txt 2>/dev/null
hello-8.2.txt
hello-8.txt
$ printf '%s\n' hello-8.txt hello-8.2.txt | sort -V
hello-8.txt
hello-8.2.txt
@end example
@node Advanced version sort topics
@section Advanced Topics
@node Reporting version sort bugs
@subsection Reporting version sort bugs
If you suspect a bug in GNU Coreutils version sort (i.e., in the
output of @samp{ls -v} or @samp{sort -V}), please first check the following:
@enumerate
@item
Is the result consistent with Debian's own ordering (using @command{dpkg}, see
@ref{Comparing two strings using Debian's algorithm})? If it is, then this
is not a bug -- please do not report it.
@item
If the result differs from Debian's, is it explained by one of the
sections in @ref{Differences from Debian version sort}? If it is,
then this is not a bug -- please do not report it.
@item
If you have a question about specific ordering which is not explained
here, please write to @email{coreutils@@gnu.org}, and provide a
concise example that will help us diagnose the issue.
@item
If you still suspect a bug which is not explained by the above, please
write to @email{bug-coreutils@@gnu.org} with a concrete example of the
suspected incorrect output, with details on why you think it is
incorrect.
@end enumerate
@node Other version/natural sort implementations
@subsection Other version/natural sort implementations
As previously mentioned, there are multiple variations on
version/natural sort, each with its own rules. Some examples are:
@itemize
@item
Natural Sorting variants in
@uref{https://rosettacode.org/wiki/Natural_sorting,Rosetta Code}.
@item
Python's @uref{https://pypi.org/project/natsort/,natsort package}
(includes detailed description of their sorting rules:
@uref{https://natsort.readthedocs.io/en/master/howitworks.html,
natsort -- how it works}).
@item
Ruby's @uref{https://github.com/github/version_sorter,version_sorter}.
@item
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},
@uref{https://metacpan.org/pod/CPAN::Version,CPAN::Version}.
@item
PHP has a built-in function
@uref{https://www.php.net/manual/en/function.natsort.php,natsort}.
@item
NodeJS's @uref{https://www.npmjs.com/package/natural-sort,natural-sort package}.
@item
In zsh, the
@uref{https://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers,
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{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).
@item
Using Debian's sorting algorithm in:
@itemize
@item
python: @uref{https://stackoverflow.com/a/4957741,
Stack Overflow Example #4957741}.
@item
NodeJS: @uref{https://www.npmjs.com/package/deb-version-compare,
deb-version-compare}.
@end itemize
@end itemize
@node Related source code
@subsection Related source code
@itemize
@item
Debian's code which splits a version string into
@code{epoch/upstream_version/debian_revision} parts:
@uref{https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/parsehelp.c#n191,
parsehelp.c:parseversion()}.
@item
Debian's code which performs the @code{upstream_version} comparison:
@uref{https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/version.c#n140,
version.c}.
@item
Gnulib code (used by GNU Coreutils) which performs the version comparison:
@uref{https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/filevercmp.c,
filevercmp.c}.
@end itemize

View File

@@ -1,6 +1,6 @@
/* buffer-lcm.c - compute a good buffer size for dealing with two files
Copyright (C) 2002-2013 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
@@ -13,7 +13,7 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */

76
gl/lib/cl-strtod.c Normal file
View File

@@ -0,0 +1,76 @@
/* Convert string to double in the current locale, falling back on the C locale.
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
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. */
#include <config.h>
#include "cl-strtod.h"
#include <c-strtod.h>
#include <errno.h>
#include <stdlib.h>
#if LONG
# define CL_STRTOD cl_strtold
# define DOUBLE long double
# define C_STRTOD c_strtold
# define STRTOD strtold
#else
# define CL_STRTOD cl_strtod
# define DOUBLE double
# define C_STRTOD c_strtod
# define STRTOD strtod
#endif
/* This function acts like strtod or strtold, except that it falls
back on the C locale if the initial prefix is not parsable in
the current locale. If the prefix is parsable in both locales,
it uses the longer parse, breaking ties in favor of the current locale.
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 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.
If the prefix cannot be parsed, return 0 and possibly set errno to EINVAL.
If the number overflows, return an extreme value and set errno to ERANGE.
If the number underflows, return a value close to 0 and set errno to ERANGE.
If there is some other error, return 0 and set errno. */
DOUBLE
CL_STRTOD (char const *nptr, char **restrict endptr)
{
char *end;
DOUBLE d = STRTOD (nptr, &end);
if (*end)
{
int strtod_errno = errno;
char *c_end;
DOUBLE c = C_STRTOD (nptr, &c_end);
if (end < c_end)
d = c, end = c_end;
else
errno = strtod_errno;
}
if (endptr)
*endptr = end;
return d;
}

4
gl/lib/cl-strtod.h Normal file
View File

@@ -0,0 +1,4 @@
double cl_strtod (char const *, char **restrict)
_GL_ATTRIBUTE_NONNULL ((1));
long double cl_strtold (char const *, char **restrict)
_GL_ATTRIBUTE_NONNULL ((1));

2
gl/lib/cl-strtold.c Normal file
View File

@@ -0,0 +1,2 @@
#define LONG 1
#include "cl-strtod.c"

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-2013 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
@@ -12,7 +12,7 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include "fadvise.h"

View File

@@ -1,5 +1,5 @@
/* Declare an access pattern hint for files.
Copyright (C) 2010-2013 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
@@ -12,9 +12,8 @@
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 <http://www.gnu.org/licenses/>. */
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>
@@ -48,7 +47,7 @@ typedef enum {
FADVISE_NOREUSE = POSIX_FADV_NOREUSE,
FADVISE_DONTNEED = POSIX_FADV_DONTNEED,
FADVISE_WILLNEED = POSIX_FADV_WILLNEED,
FADVISE_RANDOM = POSIX_FADV_RANDOM,
FADVISE_RANDOM = POSIX_FADV_RANDOM
} fadvice_t;
#else
typedef enum {
@@ -57,7 +56,7 @@ typedef enum {
FADVISE_NOREUSE,
FADVISE_DONTNEED,
FADVISE_WILLNEED,
FADVISE_RANDOM,
FADVISE_RANDOM
} fadvice_t;
#endif

View File

@@ -1,6 +1,6 @@
/* Invoke open, but return either a desired file descriptor or -1.
Copyright (C) 2005-2013 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
@@ -13,7 +13,7 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */

View File

@@ -1,6 +1,6 @@
/* Invoke open, but return either a desired file descriptor or -1.
Copyright (C) 2005-2013 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
@@ -13,10 +13,10 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
#include <sys/types.h>
int fd_reopen (int, char const *, int, mode_t);
int fd_reopen (int, char const *, int, mode_t) _GL_ATTRIBUTE_NONNULL ();

View File

@@ -1,6 +1,6 @@
/* Barebones heap implementation supporting only insert and pop.
Copyright (C) 2010-2013 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
@@ -13,7 +13,7 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Full implementation: GDSL (http://gna.org/projects/gdsl/) by Nicolas
Darnis <ndarnis@free.fr>. */
@@ -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,18 +107,18 @@ 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)
if (child < count && compare (array[child], array[child + 1]) < 0)
child++;
if (compare (array[child], element) <= 0)
@@ -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-2013 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
@@ -13,14 +13,22 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* 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 *heap_alloc (int (*) (void const *, void const *), size_t);
void heap_free (struct heap *);
int heap_insert (struct heap *heap, void *item);
void *heap_remove_top (struct heap *heap);
struct heap;
void heap_free (struct heap *) _GL_ATTRIBUTE_NONNULL ();
struct heap *heap_alloc (int (*) (void const *, void const *), idx_t)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (heap_free, 1)
_GL_ATTRIBUTE_RETURNS_NONNULL;
int heap_insert (struct heap *heap, void *item) _GL_ATTRIBUTE_NONNULL ();
void *heap_remove_top (struct heap *heap) _GL_ATTRIBUTE_NONNULL ();

View File

@@ -1,278 +0,0 @@
/* Align/Truncate a string in a given screen width
Copyright (C) 2009-2013 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 <http://www.gnu.org/licenses/>. */
/* Written by Pádraig Brady. */
#include <config.h>
#include "mbsalign.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>
#ifndef MIN
# define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
/* 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, const char* 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 (const char *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;
const char *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 (const char *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,59 +0,0 @@
/* Align/Truncate a string in a given screen width
Copyright (C) 2009-2013 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 <http://www.gnu.org/licenses/>. */
#include <stddef.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 (const char *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags);
char *
ambsalign (const char *src, size_t *width, mbs_align_t align, int flags);

View File

@@ -1,6 +1,6 @@
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
Copyright (C) 1999-2013 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
@@ -14,7 +14,7 @@
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 <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
Written by Colin Plumb and Paul Eggert. */
@@ -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.
* --------------------------------------------------------------------
@@ -35,13 +35,18 @@
#include "rand-isaac.h"
#include <limits.h>
#include <string.h>
/* The minimum of two sizes A and B. */
static inline size_t
min (size_t a, size_t b)
{
return (a < b ? a : b);
}
/* If the platform supports unaligned access,
then don't have -fsanitize=undefined warn about it. */
#undef ATTRIBUTE_NO_WARN_SANITIZE_UNDEFINED
#if !(_STRING_ARCH_unaligned || _STRING_INLINE_unaligned) \
|| __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 9)
# define ATTRIBUTE_NO_WARN_SANITIZE_UNDEFINED /* empty */
#else
# define ATTRIBUTE_NO_WARN_SANITIZE_UNDEFINED \
__attribute__ ((__no_sanitize_undefined__))
#endif
/* A if 32-bit ISAAC, B if 64-bit. This is a macro, not an inline
function, to prevent undefined behavior if the unused argument
@@ -81,7 +86,7 @@ ind (isaac_word const *m, isaac_word x)
}
/* Use and update *S to generate random data to fill RESULT. */
void
void ATTRIBUTE_NO_WARN_SANITIZE_UNDEFINED
isaac_refill (struct isaac_state *s, isaac_word result[ISAAC_WORDS])
{
/* Caches of S->a and S->b. */
@@ -96,7 +101,7 @@ isaac_refill (struct isaac_state *s, isaac_word result[ISAAC_WORDS])
/* The central step. S->m is the whole state array, while M is a
pointer to the current word. OFF is the offset from M to the
word ISAAC_WORDS/2 words away in the SM array, i.e. +/-
word ISAAC_WORDS/2 words away in the SM array, i.e., +/-
ISAAC_WORDS/2. A and B are state variables, and R the result.
This updates A, B, M[I], and R[I]. */
#define ISAAC_STEP(i, off, mix) \

View File

@@ -1,6 +1,6 @@
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
Copyright (C) 1999-2013 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
@@ -14,7 +14,7 @@
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 <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
Written by Colin Plumb and Paul Eggert. */
@@ -59,7 +59,8 @@ struct isaac_state
isaac_word a, b, c; /* Extra variables */
};
void isaac_seed (struct isaac_state *);
void isaac_refill (struct isaac_state *, isaac_word[ISAAC_WORDS]);
void isaac_seed (struct isaac_state *) _GL_ATTRIBUTE_NONNULL ();
void isaac_refill (struct isaac_state *, isaac_word[ISAAC_WORDS])
_GL_ATTRIBUTE_NONNULL ();
#endif

View File

@@ -1,6 +1,6 @@
/* Generate random integers.
Copyright (C) 2006-2013 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
@@ -13,7 +13,7 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
@@ -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. */
@@ -106,13 +106,6 @@ static inline randint shift_left (randint x)
return HUGE_BYTES ? 0 : x << CHAR_BIT;
}
/* Return X shifted right by CHAR_BIT bits. */
static inline randint
shift_right (randint x)
{
return HUGE_BYTES ? 0 : x >> CHAR_BIT;
}
/* Consume random data from *S to generate a random number in the range
0 .. GENMAX. */
@@ -148,9 +141,9 @@ randint_genmax (struct randint_source *s, randint genmax)
/* Increase RANDMAX by appending random bytes to RANDNUM and
UCHAR_MAX to RANDMAX until RANDMAX is no less than
GENMAX. This may lose up to CHAR_BIT bits of information
if shift_right (RANDINT_MAX) < GENMAX, but it is not
worth the programming hassle of saving these bits since
GENMAX is rarely that large in practice. */
if (HUGE_BYTES ? 0 : RANDINT_MAX >> CHAR_BIT) < GENMAX,
but it is not worth the programming hassle of saving
these bits since GENMAX is rarely that large in practice. */
i = 0;
@@ -205,7 +198,7 @@ randint_genmax (struct randint_source *s, randint genmax)
void
randint_free (struct randint_source *s)
{
memset (s, 0, sizeof *s);
explicit_bzero (s, sizeof *s);
free (s);
}

View File

@@ -1,6 +1,6 @@
/* Generate random integers.
Copyright (C) 2006-2013 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
@@ -13,7 +13,7 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
@@ -32,11 +32,17 @@ typedef uintmax_t randint;
struct randint_source;
struct randint_source *randint_new (struct randread_source *);
struct randint_source *randint_all_new (char const *, size_t);
void randint_free (struct randint_source *) _GL_ATTRIBUTE_NONNULL ();
int randint_all_free (struct randint_source *) _GL_ATTRIBUTE_NONNULL ();
struct randint_source *randint_new (struct randread_source *)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (randint_free, 1)
_GL_ATTRIBUTE_NONNULL () _GL_ATTRIBUTE_RETURNS_NONNULL;
struct randint_source *randint_all_new (char const *, size_t)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (randint_all_free, 1);
struct randread_source *randint_get_source (struct randint_source const *)
_GL_ATTRIBUTE_PURE;
randint randint_genmax (struct randint_source *, randint genmax);
_GL_ATTRIBUTE_NONNULL () _GL_ATTRIBUTE_PURE;
randint randint_genmax (struct randint_source *, randint genmax)
_GL_ATTRIBUTE_NONNULL ();
/* Consume random data from *S to generate a random number in the range
0 .. CHOICES-1. CHOICES must be nonzero. */
@@ -46,7 +52,4 @@ randint_choose (struct randint_source *s, randint choices)
return randint_genmax (s, choices - 1);
}
void randint_free (struct randint_source *);
int randint_all_free (struct randint_source *);
#endif

View File

@@ -1,6 +1,6 @@
/* Generate random permutations.
Copyright (C) 2006-2013 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
@@ -13,32 +13,24 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
#include <config.h>
#include "hash.h"
#include "randperm.h"
#include <limits.h>
#include <stdbit.h>
#include <stdckdint.h>
#include <stdint.h>
#include <stdlib.h>
#include "attribute.h"
#include "hash.h"
#include "xalloc.h"
/* Return the ceiling of the log base 2 of N. If N is zero, return
an unspecified value. */
static size_t _GL_ATTRIBUTE_CONST
ceil_lg (size_t n)
{
size_t b = 0;
for (n--; n != 0; n /= 2)
b++;
return b;
}
/* 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. */
@@ -48,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. */
size_t lg_n = ceil_lg (n);
unsigned int lg_n = stdc_bit_width (n) + 1;
/* Upper bound on number of bits needed to generated the first H elements. */
size_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;
}
@@ -104,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
@@ -112,10 +106,10 @@ sparse_new (size_t size_hint)
index I in array V. */
static void
sparse_swap (sparse_map *sv, size_t* v, size_t i, size_t j)
sparse_swap (sparse_map *sv, size_t *v, size_t i, size_t j)
{
struct sparse_ent_ *v1 = hash_delete (sv, &(struct sparse_ent_) {i,0});
struct sparse_ent_ *v2 = hash_delete (sv, &(struct sparse_ent_) {j,0});
struct sparse_ent_ *v1 = hash_remove (sv, &(struct sparse_ent_) {i,0});
struct sparse_ent_ *v2 = hash_remove (sv, &(struct sparse_ent_) {j,0});
/* FIXME: reduce the frequency of these mallocs. */
if (!v1)
@@ -149,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)
@@ -159,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:
@@ -204,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,4 +1,6 @@
#include "randint.h"
#include <stddef.h>
#include <stdlib.h>
size_t randperm_bound (size_t, size_t) _GL_ATTRIBUTE_CONST;
size_t *randperm_new (struct randint_source *, size_t, size_t);
size_t *randperm_new (struct randint_source *, size_t, size_t)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;

View File

@@ -1,6 +1,6 @@
/* Generate buffers of random data.
Copyright (C) 2006-2013 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
@@ -13,7 +13,7 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
@@ -28,46 +28,27 @@
#include <error.h>
#include <exitfail.h>
#include <fcntl.h>
#include <quotearg.h>
#include <stdalign.h>
#include <stdbool.h>
#include <quote.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <sys/random.h>
#include "gettext.h"
#define _(msgid) gettext (msgid)
#include "assure.h"
#include "minmax.h"
#include "rand-isaac.h"
#include "stdio-safer.h"
#include "unlocked-io.h"
#include "xalloc.h"
#ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
# define __attribute__(x) /* empty */
# endif
#endif
#ifndef ATTRIBUTE_NORETURN
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
#endif
#ifndef MIN
# define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#if _STRING_ARCH_unaligned
# define ALIGNED_POINTER(ptr, type) true
#if _STRING_ARCH_unaligned || _STRING_INLINE_unaligned
# define POINTER_IS_ALIGNED(ptr, type) true
#else
# define ALIGNED_POINTER(ptr, type) ((size_t) (ptr) % alignof (type) == 0)
#endif
#ifndef NAME_OF_NONCE_DEVICE
# define NAME_OF_NONCE_DEVICE "/dev/urandom"
# 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
@@ -120,14 +101,13 @@ struct randread_source
/* The default error handler. */
static void ATTRIBUTE_NORETURN
static void
randread_error (void const *file_name)
{
if (file_name)
error (exit_failure, errno,
_(errno == 0 ? "%s: end of file" : "%s: read error"),
quotearg_colon (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
@@ -143,51 +123,40 @@ simple_new (FILE *source, void const *handler_arg)
return s;
}
/* Put a nonce value into BUFFER, with size BUFSIZE, but do not get
more than BYTES_BOUND bytes' worth of random information from any
nonce device. */
/* Put a nonce value into BUFFER, with size BUFSIZE.
Return true on success, false (setting errno) on failure. */
static void
get_nonce (void *buffer, size_t bufsize, size_t bytes_bound)
static bool
get_nonce (void *buffer, size_t bufsize)
{
char *buf = buffer;
ssize_t seeded = 0;
/* Get some data from FD if available. */
int fd = open (NAME_OF_NONCE_DEVICE, O_RDONLY | O_BINARY);
if (0 <= fd)
char *buf = buffer, *buflim = buf + bufsize;
while (buf < buflim)
{
seeded = read (fd, buf, MIN (bufsize, bytes_bound));
if (seeded < 0)
seeded = 0;
close (fd);
}
/* If there's no nonce device, use a poor approximation
by getting the time of day, etc. */
#define ISAAC_SEED(type, initialize_v) \
if (seeded < bufsize) \
{ \
type v; \
size_t nbytes = MIN (sizeof v, bufsize - seeded); \
initialize_v; \
memcpy (buf + seeded, &v, nbytes); \
seeded += nbytes; \
}
ISAAC_SEED (struct timeval, gettimeofday (&v, NULL));
ISAAC_SEED (pid_t, v = getpid ());
ISAAC_SEED (pid_t, v = getppid ());
ISAAC_SEED (uid_t, v = getuid ());
ISAAC_SEED (uid_t, v = getgid ());
#ifdef lint
/* Normally we like having the extra randomness from uninitialized
parts of BUFFER. However, omit this randomness if we want to
avoid false-positives from memory-checking debugging tools. */
memset (buf + seeded, 0, bufsize - seeded);
#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)
return false;
}
return true;
}
/* Body of randread_free, broken out to pacify gcc -Wmismatched-dealloc. */
static int
randread_free_body (struct randread_source *s)
{
FILE *source = s->source;
explicit_bzero (s, sizeof *s);
free (s);
return source ? fclose (source) : 0;
}
/* Create and initialize a random data source from NAME, or use a
reasonable default source if NAME is null. BYTES_BOUND is an upper
@@ -198,21 +167,21 @@ get_nonce (void *buffer, size_t bufsize, size_t bytes_bound)
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);
@@ -220,9 +189,25 @@ 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;
get_nonce (s->buf.isaac.state.m, sizeof s->buf.isaac.state.m,
bytes_bound);
if (! get_nonce (s->buf.isaac.state.m,
sizeof s->buf.isaac.state.m))
{
int e = errno;
randread_free_body (s);
errno = e;
return nullptr;
}
isaac_seed (&s->buf.isaac.state);
}
@@ -296,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)
@@ -340,8 +325,5 @@ randread (struct randread_source *s, void *buf, size_t size)
int
randread_free (struct randread_source *s)
{
FILE *source = s->source;
memset (s, 0, sizeof *s);
free (s);
return (source ? fclose (source) : 0);
return randread_free_body (s);
}

View File

@@ -1,6 +1,6 @@
/* Generate buffers of random data.
Copyright (C) 2006-2013 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
@@ -13,7 +13,7 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
@@ -24,10 +24,14 @@
struct randread_source;
struct randread_source *randread_new (char const *, size_t);
void randread (struct randread_source *, void *, size_t);
void randread_set_handler (struct randread_source *, void (*) (void const *));
void randread_set_handler_arg (struct randread_source *, void const *);
int randread_free (struct randread_source *);
int randread_free (struct randread_source *) _GL_ATTRIBUTE_NONNULL ();
struct randread_source *randread_new (char const *, size_t)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (randread_free, 1);
void randread (struct randread_source *, void *, size_t)
_GL_ATTRIBUTE_NONNULL ();
void randread_set_handler (struct randread_source *, void (*) (void const *))
_GL_ATTRIBUTE_NONNULL ();
void randread_set_handler_arg (struct randread_source *, void const *)
_GL_ATTRIBUTE_NONNULL ((1));
#endif

View File

@@ -1,67 +0,0 @@
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 6d5525a..c9331d4 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -539,7 +539,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
size_t errbuf_size;
#else /* size_t might promote */
size_t
-regerror (int errcode, const regex_t *_Restrict_ preg,
+regerror (int errcode, const regex_t *_Restrict_ preg _UNUSED_PARAMETER_,
char *_Restrict_ errbuf, size_t errbuf_size)
#endif
{
@@ -1421,7 +1421,7 @@ calc_first (void *extra, bin_tree_t *node)
/* Pass 2: compute NEXT on the tree. Preorder visit. */
static reg_errcode_t
-calc_next (void *extra, bin_tree_t *node)
+calc_next (void *extra _UNUSED_PARAMETER_, bin_tree_t *node)
{
switch (node->token.type)
{
@@ -2807,8 +2807,10 @@ build_range_exp (const reg_syntax_t syntax,
static reg_errcode_t
internal_function
# ifdef RE_ENABLE_I18N
-build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
- Idx *coll_sym_alloc, const unsigned char *name)
+build_collating_symbol (bitset_t sbcset,
+ re_charset_t *mbcset _UNUSED_PARAMETER_,
+ Idx *coll_sym_alloc _UNUSED_PARAMETER_,
+ const unsigned char *name)
# else /* not RE_ENABLE_I18N */
build_collating_symbol (bitset_t sbcset, const unsigned char *name)
# endif /* not RE_ENABLE_I18N */
@@ -3392,7 +3394,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
static reg_errcode_t
parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
- re_token_t *token, int token_len, re_dfa_t *dfa,
+ re_token_t *token, int token_len,
+ re_dfa_t *dfa _UNUSED_PARAMETER_,
reg_syntax_t syntax, bool accept_hyphen)
{
#ifdef RE_ENABLE_I18N
@@ -3479,8 +3482,10 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
static reg_errcode_t
#ifdef RE_ENABLE_I18N
-build_equiv_class (bitset_t sbcset, re_charset_t *mbcset,
- Idx *equiv_class_alloc, const unsigned char *name)
+build_equiv_class (bitset_t sbcset,
+ re_charset_t *mbcset _UNUSED_PARAMETER_,
+ Idx *equiv_class_alloc _UNUSED_PARAMETER_,
+ const unsigned char *name)
#else /* not RE_ENABLE_I18N */
build_equiv_class (bitset_t sbcset, const unsigned char *name)
#endif /* not RE_ENABLE_I18N */
@@ -3886,7 +3891,7 @@ free_token (re_token_t *node)
and its children. */
static reg_errcode_t
-free_tree (void *extra, bin_tree_t *node)
+free_tree (void *extra _UNUSED_PARAMETER_, bin_tree_t *node)
{
free_token (&node->token);
return REG_NOERROR;

View File

@@ -1,25 +0,0 @@
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index 7e8c1bc..e68c9da 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -16,6 +16,8 @@
You should have received a copy of the GNU General Public License along
with this program; if not, see <http://www.gnu.org/licenses/>. */
+#include "verify.h"
+#include "intprops.h"
static void re_string_construct_common (const char *str, Idx len,
re_string_t *pstr,
RE_TRANSLATE_TYPE trans, bool icase,
@@ -1393,7 +1395,10 @@ static void
internal_function
re_node_set_remove_at (re_node_set *set, Idx idx)
{
- if (idx < 0 || idx >= set->nelem)
+ verify (! TYPE_SIGNED (Idx));
+ /* if (idx < 0)
+ return; */
+ if (idx >= set->nelem)
return;
--set->nelem;
for (; idx < set->nelem; idx++)

View File

@@ -1,14 +0,0 @@
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 439444c..7242084 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -827,7 +827,8 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx)
# ifndef NOT_IN_libc
static int
internal_function __attribute__ ((pure, unused))
-re_string_elem_size_at (const re_string_t *pstr, Idx idx)
+re_string_elem_size_at (const re_string_t *pstr _UNUSED_PARAMETER_,
+ Idx idx _UNUSED_PARAMETER_)
{
# ifdef _LIBC
const unsigned char *p, *extra;

View File

@@ -1,45 +0,0 @@
diff --git a/lib/regexec.c b/lib/regexec.c
index 7d130a0..a58d454 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -16,6 +16,8 @@
You should have received a copy of the GNU General Public License along
with this program; if not, see <http://www.gnu.org/licenses/>. */
+#include "verify.h"
+#include "intprops.h"
static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
Idx n) internal_function;
static void match_ctx_clean (re_match_context_t *mctx) internal_function;
@@ -374,8 +376,11 @@ re_search_2_stub (struct re_pattern_buffer *bufp,
Idx len = length1 + length2;
char *s = NULL;
- if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0))
- return -2;
+ verify (! TYPE_SIGNED (Idx));
+ if (BE (len < length1, 0))
+ return -2;
+ /* if (BE (length1 < 0 || length2 < 0 || stop < 0, 0))
+ return -2; */
/* Concatenate the strings. */
if (length2 > 0)
@@ -426,11 +431,14 @@ re_search_stub (struct re_pattern_buffer *bufp,
Idx last_start = start + range;
/* Check for out-of-range. */
- if (BE (start < 0 || start > length, 0))
- return -1;
+ verify (! TYPE_SIGNED (Idx));
+ /* if (BE (start < 0, 0))
+ return -1; */
+ if (BE (start > length, 0))
+ return -1;
if (BE (length < last_start || (0 <= range && last_start < start), 0))
last_start = length;
- else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0))
+ else if (BE (/* last_start < 0 || */ (range < 0 && start <= last_start), 0))
last_start = 0;
__libc_lock_lock (dfa->lock);

View File

@@ -1,5 +1,5 @@
/* root-dev-ino.c -- get the device and inode numbers for '/'.
Copyright (C) 2003-2013 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
@@ -12,7 +12,7 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
@@ -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-2013 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
@@ -13,7 +13,7 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef ROOT_DEV_INO_H
# define ROOT_DEV_INO_H 1
@@ -22,24 +22,24 @@
# include "same-inode.h"
struct dev_ino *
get_root_dev_ino (struct dev_ino *root_d_i);
get_root_dev_ino (struct dev_ino *root_d_i) _GL_ATTRIBUTE_NONNULL ();
/* These macros are common to the programs that support the
--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 \
{ \
if (STREQ (Dirname, "/")) \
error (0, 0, _("it is dangerous to operate recursively on %s"), \
quote (Dirname)); \
quoteaf (Dirname)); \
else \
error (0, 0, \
_("it is dangerous to operate recursively on %s (same as %s)"), \
quote_n (0, Dirname), quote_n (1, "/")); \
quoteaf_n (0, Dirname), quoteaf_n (1, "/")); \
error (0, 0, _("use --no-preserve-root to override this failsafe")); \
} \
while (0)

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 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
@@ -12,24 +12,22 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* 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
static inline ssize_t
smack_new_label_from_self (char **label)
smack_new_label_from_self (MAYBE_UNUSED char **label)
{
return -1;
}
static inline int
smack_set_label_for_self (const char *label)
smack_set_label_for_self (MAYBE_UNUSED char const *label)
{
return -1;
}
@@ -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-2013 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
@@ -13,7 +13,7 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
@@ -21,6 +21,8 @@
#include "strnumcmp-in.h"
#include <limits.h>
/* Compare strings A and B as integers without explicitly converting
them to machine numbers, to avoid overflow problems and perhaps
improve performance. */
@@ -28,5 +30,5 @@
int
strintcmp (char const *a, char const *b)
{
return numcompare (a, b, -1, -1);
return numcompare (a, b, CHAR_MAX + 1, CHAR_MAX + 1);
}

View File

@@ -1,6 +1,6 @@
/* Compare numeric strings. This is an internal include file.
Copyright (C) 1988-2013 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
@@ -13,7 +13,7 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Mike Haertel. */
@@ -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;
}
@@ -106,16 +97,16 @@ fraccompare (char const *a, char const *b, char decimal_point)
/* Compare strings A and B as numbers without explicitly converting
them to machine numbers, to avoid overflow problems and perhaps
improve performance. DECIMAL_POINT is the decimal point and
THOUSANDS_SEP the thousands separator. A DECIMAL_POINT of -1
causes comparisons to act as if there is no decimal point
THOUSANDS_SEP the thousands separator. A DECIMAL_POINT outside
'char' range causes comparisons to act as if there is no decimal point
character, and likewise for THOUSANDS_SEP. */
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-2013 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
@@ -13,7 +13,7 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
@@ -23,7 +23,7 @@
/* Externally-visible name for numcompare. */
int _GL_ATTRIBUTE_PURE
int
strnumcmp (char const *a, char const *b,
int decimal_point, int thousands_sep)
{

View File

@@ -1,2 +1,4 @@
int strintcmp (char const *, char const *) _GL_ATTRIBUTE_PURE;
int strnumcmp (char const *, char const *, int, int);
int strintcmp (char const *, char const *)
_GL_ATTRIBUTE_NONNULL () _GL_ATTRIBUTE_PURE;
int strnumcmp (char const *, char const *, int, int)
_GL_ATTRIBUTE_NONNULL () _GL_ATTRIBUTE_PURE;

76
gl/lib/targetdir.c Normal file
View File

@@ -0,0 +1,76 @@
/* Target directory operands for coreutils
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#define TARGETDIR_INLINE _GL_EXTERN_INLINE
#include <targetdir.h>
#include <attribute.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#ifdef O_PATH
enum { O_PATHSEARCH = O_PATH };
#else
enum { O_PATHSEARCH = O_SEARCH };
#endif
/* Must F designate the working directory? */
ATTRIBUTE_PURE static bool
must_be_working_directory (char const *f)
{
/* Return true for ".", "./.", ".///./", etc. */
while (*f++ == '.')
{
if (*f != '/')
return !*f;
while (*++f == '/')
continue;
if (!*f)
return true;
}
return false;
}
/* Return a file descriptor open to FILE, for use in openat.
As an optimization, return AT_FDCWD if FILE must be the working directory.
As a side effect, possibly set *ST to the file's status.
Fail and set errno if FILE is not a directory.
On failure return -2 if AT_FDCWD is -1, -1 otherwise. */
int
target_directory_operand (char const *file, struct stat *st)
{
if (must_be_working_directory (file))
return AT_FDCWD;
int fd = open (file, O_PATHSEARCH | O_DIRECTORY);
/* On platforms lacking O_PATH, using O_SEARCH | O_DIRECTORY to
open an overly-protected non-directory can fail with either
EACCES or ENOTDIR. Prefer ENOTDIR as it makes for better
diagnostics. */
if (O_PATHSEARCH == O_SEARCH && fd < 0 && errno == EACCES)
errno = stat (file, st) < 0 || S_ISDIR (st->st_mode) ? EACCES : ENOTDIR;
return fd - (AT_FDCWD == -1 && fd < 0);
}

43
gl/lib/targetdir.h Normal file
View File

@@ -0,0 +1,43 @@
/* Target directory operands for coreutils
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
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 <fcntl.h>
#include <sys/stat.h>
#ifndef _GL_INLINE_HEADER_BEGIN
# error "Please include config.h first."
#endif
_GL_INLINE_HEADER_BEGIN
#ifndef TARGETDIR_INLINE
# define TARGETDIR_INLINE _GL_INLINE
#endif
/* Return a file descriptor open to FILE, for use in openat.
As an optimization, return AT_FDCWD if FILE must be the working directory.
As a side effect, possibly set *ST to the file's status.
Fail and set errno if FILE is not a directory.
On failure return -2 if AT_FDCWD is -1, -1 otherwise. */
extern int target_directory_operand (char const *file, struct stat *st);
/* Return true if FD represents success for target_directory_operand. */
TARGETDIR_INLINE _GL_ATTRIBUTE_PURE bool
target_dirfd_valid (int fd)
{
return fd != -1 - (AT_FDCWD == -1);
}
_GL_INLINE_HEADER_END

View File

@@ -1,193 +0,0 @@
diff --git a/lib/tempname.c b/lib/tempname.c
index 26a38ce..5944ee0 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -20,6 +20,7 @@
#if !_LIBC
# include <config.h>
# include "tempname.h"
+# include "randint.h"
#endif
#include <sys/types.h>
@@ -47,6 +48,7 @@
# error report this to bug-gnulib@gnu.org
#endif
+#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -175,14 +177,21 @@ __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
}
#endif /* _LIBC */
+static inline bool _GL_ATTRIBUTE_PURE
+check_x_suffix (char const *s, size_t len)
+{
+ return len <= strspn (s, "X");
+}
+
/* These are the characters used in temporary file names. */
static const char letters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
/* Generate a temporary file name based on TMPL. TMPL must match the
- rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
+ rules for mk[s]temp (i.e. end in at least X_SUFFIX_LEN "X"s,
+ possibly with a suffix).
The name constructed does not exist at the time of the call to
- __gen_tempname. TMPL is overwritten with the result.
+ this function. TMPL is overwritten with the result.
KIND may be one of:
__GT_NOCREATE: simply verify that the name does not exist
@@ -193,23 +202,24 @@ static const char letters[] =
We use a clever algorithm to get hard-to-predict names. */
int
-__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
+gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind,
+ size_t x_suffix_len)
{
- int len;
+ size_t len;
char *XXXXXX;
- static uint64_t value;
- uint64_t random_time_bits;
unsigned int count;
int fd = -1;
int save_errno = errno;
struct_stat64 st;
+ struct randint_source *rand_src;
/* A lower bound on the number of temporary files to attempt to
generate. The maximum total number of temporary file names that
can exist for a given template is 62**6. It should never be
necessary to try all of these combinations. Instead if a reasonable
number of names is tried (we define reasonable as 62**3) fail to
- give the system administrator the chance to remove the problems. */
+ give the system administrator the chance to remove the problems.
+ This value requires that X_SUFFIX_LEN be at least 3. */
#define ATTEMPTS_MIN (62 * 62 * 62)
/* The number of times to attempt to generate a temporary file. To
@@ -221,43 +231,28 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
#endif
len = strlen (tmpl);
- if (len < 6 + suffixlen || memcmp (&tmpl[len - 6 - suffixlen], "XXXXXX", 6))
+ if (len < x_suffix_len + suffixlen
+ || ! check_x_suffix (&tmpl[len - x_suffix_len - suffixlen],
+ x_suffix_len))
{
__set_errno (EINVAL);
return -1;
}
/* This is where the Xs start. */
- XXXXXX = &tmpl[len - 6 - suffixlen];
+ XXXXXX = &tmpl[len - x_suffix_len - suffixlen];
/* Get some more or less random data. */
-#ifdef RANDOM_BITS
- RANDOM_BITS (random_time_bits);
-#else
- {
- struct timeval tv;
- __gettimeofday (&tv, NULL);
- random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec;
- }
-#endif
- value += random_time_bits ^ __getpid ();
+ rand_src = randint_all_new (NULL, x_suffix_len);
+ if (! rand_src)
+ return -1;
- for (count = 0; count < attempts; value += 7777, ++count)
+ for (count = 0; count < attempts; ++count)
{
- uint64_t v = value;
-
- /* Fill in the random bits. */
- XXXXXX[0] = letters[v % 62];
- v /= 62;
- XXXXXX[1] = letters[v % 62];
- v /= 62;
- XXXXXX[2] = letters[v % 62];
- v /= 62;
- XXXXXX[3] = letters[v % 62];
- v /= 62;
- XXXXXX[4] = letters[v % 62];
- v /= 62;
- XXXXXX[5] = letters[v % 62];
+ size_t i;
+
+ for (i = 0; i < x_suffix_len; i++)
+ XXXXXX[i] = letters[randint_genmax (rand_src, sizeof letters - 2)];
switch (kind)
{
@@ -272,7 +267,7 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
break;
case __GT_NOCREATE:
- /* This case is backward from the other three. __gen_tempname
+ /* This case is backward from the other three. This function
succeeds if __xstat fails because the name does not exist.
Note the continue to bypass the common logic at the bottom
of the loop. */
@@ -281,11 +276,15 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
if (errno == ENOENT)
{
__set_errno (save_errno);
- return 0;
+ fd = 0;
+ goto done;
}
else
- /* Give up now. */
- return -1;
+ {
+ /* Give up now. */
+ fd = -1;
+ goto done;
+ }
}
continue;
@@ -297,13 +296,32 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
if (fd >= 0)
{
__set_errno (save_errno);
- return fd;
+ goto done;
}
else if (errno != EEXIST)
- return -1;
+ {
+ fd = -1;
+ goto done;
+ }
}
+ randint_all_free (rand_src);
+
/* We got out of the loop because we ran out of combinations to try. */
__set_errno (EEXIST);
return -1;
+
+ done:
+ {
+ int saved_errno = errno;
+ randint_all_free (rand_src);
+ __set_errno (saved_errno);
+ }
+ return fd;
+}
+
+int
+__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
+{
+ return gen_tempname_len (tmpl, suffixlen, flags, kind, 6);
}

View File

@@ -1,12 +0,0 @@
diff --git a/lib/tempname.h b/lib/tempname.h
index 7972562..7ced9a9 100644
--- a/lib/tempname.h
+++ b/lib/tempname.h
@@ -46,5 +46,7 @@
We use a clever algorithm to get hard-to-predict names. */
extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
+extern int gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind,
+ size_t x_suffix_len);
#endif /* GL_TEMPNAME_H */

5
gl/lib/xdectoimax.c Normal file
View File

@@ -0,0 +1,5 @@
#define __xdectoint xdectoimax
#define __xnumtoint xnumtoimax
#define __xdectoint_t intmax_t
#define __xstrtol xstrtoimax
#include "xdectoint.c"

96
gl/lib/xdectoint.c Normal file
View File

@@ -0,0 +1,96 @@
/* Convert decimal strings with bounds checking and exit on error.
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
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include "xdectoint.h"
#include <errno.h>
#include <inttypes.h>
#include <stdlib.h>
#include <error.h>
#include <quote.h>
#include <xstrtol.h>
/* Parse numeric string N_STR of base BASE, and return the value.
The value is between MIN and MAX.
Strings can have multiplicative SUFFIXES if specified.
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,
int flags)
{
__xdectoint_t tnum, r;
strtol_error s_err = __xstrtol (n_str, nullptr, base, &tnum, suffixes);
/* Errno value to report if there is an overflow. */
int overflow_errno;
if (s_err != LONGINT_INVALID)
{
if (tnum < min)
{
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;
}
}
int e = s_err == LONGINT_OVERFLOW ? overflow_errno : 0;
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.
Exit on parse error or if MIN or MAX are exceeded.
Strings can have multiplicative SUFFIXES if specified.
ERR is printed along with N_STR on error. */
__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, 0);
}

57
gl/lib/xdectoint.h Normal file
View File

@@ -0,0 +1,57 @@
/* Convert decimal strings with bounds checking and exit on error.
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
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef XDECTOINT_H_
# define XDECTOINT_H_ 1
# 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, int flags) \
_GL_ATTRIBUTE_NONNULL ((1, 6));
_DECLARE_XDECTOINT (xdectoimax, intmax_t)
_DECLARE_XDECTOINT (xdectoumax, uintmax_t)
_DECLARE_XNUMTOINT (xnumtoimax, intmax_t)
_DECLARE_XNUMTOINT (xnumtoumax, uintmax_t)
#endif /* not XDECTOINT_H_ */

5
gl/lib/xdectoumax.c Normal file
View File

@@ -0,0 +1,5 @@
#define __xdectoint xdectoumax
#define __xnumtoint xnumtoumax
#define __xdectoint_t uintmax_t
#define __xstrtol xstrtoumax
#include "xdectoint.c"

View File

@@ -1,6 +1,6 @@
/* xfts.c -- a wrapper for fts_open
Copyright (C) 2003-2013 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
@@ -13,17 +13,16 @@
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 <http://www.gnu.org/licenses/>. */
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
#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,10 +1,11 @@
#include <stdbool.h>
#include "fts_.h"
FTS *
xfts_open (char * const *, int options,
int (*) (const FTSENT **, const FTSENT **));
int (*) (const FTSENT **, const FTSENT **))
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (fts_close, 1)
_GL_ATTRIBUTE_NONNULL ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
bool
cycle_warning_required (FTS const *fts, FTSENT const *ent)
_GL_ATTRIBUTE_PURE;
_GL_ATTRIBUTE_NONNULL () _GL_ATTRIBUTE_PURE;

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:

24
gl/modules/cl-strtod Normal file
View File

@@ -0,0 +1,24 @@
Description:
Convert string to double in current or C locale.
Files:
lib/cl-strtod.c
lib/cl-strtod.h
Depends-on:
c-strtod
configure.ac:
AC_REQUIRE([AC_C_RESTRICT])
Makefile.am:
lib_SOURCES += cl-strtod.c
Include:
"cl-strtod.h"
License:
GPL
Maintainer:
all

25
gl/modules/cl-strtold Normal file
View File

@@ -0,0 +1,25 @@
Description:
Convert string to long double in current or C locale.
Files:
lib/cl-strtod.c
lib/cl-strtod.h
lib/cl-strtold.c
Depends-on:
c-strtold
configure.ac:
AC_REQUIRE([AC_C_RESTRICT])
Makefile.am:
lib_SOURCES += cl-strtold.c
Include:
"cl-strtod.h"
License:
GPL
Maintainer:
all

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,27 +0,0 @@
Description:
Align/Truncate a string in a given screen width.
Files:
lib/mbsalign.c
lib/mbsalign.h
Depends-on:
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,7 +6,10 @@ lib/randperm.c
lib/randperm.h
Depends-on:
assert-h
randint
stdc_bit_width
stdint-h
xalloc
hash

View File

@@ -8,15 +8,16 @@ lib/randread.c
lib/randread.h
Depends-on:
alignasof
bool
error
exitfail
inline
fopen-safer
gettimeofday
quotearg
stdalign
stdbool
stdint
getrandom
quote
minmax
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

@@ -10,7 +10,7 @@ configure.ac:
# Check whether libsmack is available
LIB_SMACK=
AC_ARG_ENABLE([libsmack],
AC_HELP_STRING([--disable-libsmack], [disable libsmack support]))
AS_HELP_STRING([--disable-libsmack], [disable libsmack support]))
if test "X$enable_libsmack" != "Xno"; then
AC_CHECK_LIB([smack], [smack_new_label_from_self],
[AC_CHECK_LIB([smack], [smack_new_label_from_path],

View File

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

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