]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
3 years agotail: simplify -fsanitize=leak pacification
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
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.

3 years agotac: simplify -fsanitize=leak pacification
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
tac: simplify -fsanitize=leak pacification

* src/tac.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.

3 years agoshuf: simplify -fsanitize=leak pacification
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
shuf: simplify -fsanitize=leak pacification

* src/shuf.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.

3 years agonumfmt: simplify -fsanitize=leak pacification
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
numfmt: simplify -fsanitize=leak pacification

* src/numfmt.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.

3 years agomktemp: simplify -fsanitize=leak pacification
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
mktemp: simplify -fsanitize=leak pacification

* src/mktemp.c (main) [lint]: Omit unnecessary cleanup.
Use main_exit, not return.

3 years agodd: simplify -fsanitize=leak pacification
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
dd: simplify -fsanitize=leak pacification

* src/dd.c (cleanup) [lint]: Omit unnecessary cleanup.
(main): Use main_exit, not return.

3 years agocp: simplify cp/install/ln/mv pacification
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
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.

3 years agochmod: pacify -fsanitizer=leak
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
chmod: pacify -fsanitizer=leak

* src/chmod.c (main): Use main_exit, not return.

3 years agoyes: pacify -fsanitizer=leak
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
yes: pacify -fsanitizer=leak

* src/yes.c (main): Use main_exit, not return.

3 years agotsort: pacify -fsanitizer=leak
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
tsort: pacify -fsanitizer=leak

* src/tsort.c (detect_loop): Free removed successor.

3 years agosort: pacify -fsanitizer=leak
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
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.

3 years agosplit: pacify -fsanitizer=leak
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
split: pacify -fsanitizer=leak

* src/split.c (lines_rr): New arg FILESP.  All uses changed.
(main): Use main_exit, not return.  Omit unnecessary alignfree.

3 years agoptx: pacify -fsanitizer=leak
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
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.

3 years agoseq: pacify -fsanitizer=leak
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
seq: pacify -fsanitizer=leak

* src/seq.c (seq_fast): If successful, exit rather than returning true.
Callers changed.
(main): Use main_exit, not return.

3 years agotsort: pacify -fsanitizer=leak
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
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.

3 years agotr: pacify -fsanitizer=leak
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
tr: pacify -fsanitizer=leak

* src/tr.c (main): Use main_exit, not return.

3 years agostat: pacify -fsanitizer=leak
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
stat: pacify -fsanitizer=leak

* src/stat.c (main):  Use main_exit, not return.

3 years agocomm: pacify -fsanitizer=leak
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
comm: pacify -fsanitizer=leak

* src/comm.c (compare_files): Move exiting code here ...
(main): ... from here, to pacify gcc -fsanitize=leak.

3 years agoexpr: lint cleanup, and introducing main_exit
Paul Eggert [Mon, 31 Jan 2022 16:42:07 +0000 (08:42 -0800)] 
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.

3 years agocksum: use more exact selection of digest algorithms
Pádraig Brady [Sun, 30 Jan 2022 20:19:48 +0000 (20:19 +0000)] 
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.

3 years agobuild: update gnulib submodule to latest
Pádraig Brady [Sun, 30 Jan 2022 20:24:27 +0000 (20:24 +0000)] 
build: update gnulib submodule to latest

To provide argmatch_exact() that does not
use abbreviated matching, to be used by cksum.

3 years agomv: when installing to dir use dir-relative names
Paul Eggert [Sat, 29 Jan 2022 19:40:17 +0000 (11:40 -0800)] 
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.

3 years agocp: fix comment typo
Paul Eggert [Sat, 29 Jan 2022 19:40:16 +0000 (11:40 -0800)] 
cp: fix comment typo

3 years agodoc: NEWS: explain _why_ copy_file_range() is used
Pádraig Brady [Fri, 28 Jan 2022 15:13:25 +0000 (15:13 +0000)] 
doc: NEWS: explain _why_ copy_file_range() is used

* NEWS: Mention why we're making the change in behavior in cat(1).

3 years agobuild: update gnulib submodule to latest
Pádraig Brady [Fri, 28 Jan 2022 15:07:14 +0000 (15:07 +0000)] 
build: update gnulib submodule to latest

To fix a syntax-check false failure

3 years agodd: synchronize output after write errors
Paul Eggert [Fri, 28 Jan 2022 08:01:07 +0000 (00:01 -0800)] 
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.

3 years agodd: output final progress before syncing
Paul Eggert [Fri, 28 Jan 2022 02:34:09 +0000 (18:34 -0800)] 
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.

3 years agocat: prefer copy_file_range to read+write
Paul Eggert [Thu, 27 Jan 2022 21:00:41 +0000 (13:00 -0800)] 
cat: prefer copy_file_range to read+write

* src/cat.c (copy_cat): New function.
(main): Use it.

3 years agocsplit: improve integer overflow checking
Paul Eggert [Thu, 27 Jan 2022 20:06:21 +0000 (12:06 -0800)] 
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.

3 years agomaint: simplify memory alignment
Paul Eggert [Thu, 27 Jan 2022 20:06:21 +0000 (12:06 -0800)] 
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.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 24 Jan 2022 05:11:44 +0000 (21:11 -0800)] 
build: update gnulib submodule to latest

3 years agocopy: remove unnecessary ‘free’
Paul Eggert [Sun, 23 Jan 2022 19:24:35 +0000 (11:24 -0800)] 
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.

3 years agodd: simplify conv=swab code
Paul Eggert [Wed, 19 Jan 2022 18:51:25 +0000 (10:51 -0800)] 
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].

3 years agodd: improve integer overflow checking
Paul Eggert [Tue, 18 Jan 2022 21:22:02 +0000 (13:22 -0800)] 
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.

3 years agoshred: fix declaration typo
Paul Eggert [Mon, 17 Jan 2022 03:56:17 +0000 (19:56 -0800)] 
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.

3 years agocat: prefer signed to unsigned
Paul Eggert [Sun, 16 Jan 2022 20:34:25 +0000 (12:34 -0800)] 
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.

3 years agocat: improve style
Paul Eggert [Sun, 16 Jan 2022 20:08:04 +0000 (12:08 -0800)] 
cat: improve style

* cat.c: Improve style a bit, mostly by assuming C99-style
declarations after statements

3 years agodoc: csplit: clarify [OFFSET] syntax
Pádraig Brady [Thu, 27 Jan 2022 13:05:39 +0000 (13:05 +0000)] 
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

3 years agobuild: allow readlinkat calls
Paul Eggert [Sat, 15 Jan 2022 20:12:21 +0000 (12:12 -0800)] 
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.

3 years agocp: rely on Gnulib for copy_file_range workaround
Paul Eggert [Sat, 15 Jan 2022 01:43:52 +0000 (17:43 -0800)] 
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.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 15 Jan 2022 01:34:33 +0000 (17:34 -0800)] 
build: update gnulib submodule to latest

3 years agodoc: fix pluralization typo
Paul Eggert [Fri, 14 Jan 2022 23:47:26 +0000 (15:47 -0800)] 
doc: fix pluralization typo

3 years agocp: fix two typos in previous change
Paul Eggert [Fri, 14 Jan 2022 23:17:17 +0000 (15:17 -0800)] 
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.

3 years agocp: omit unnecessary stat of destination
Paul Eggert [Fri, 14 Jan 2022 16:51:13 +0000 (08:51 -0800)] 
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.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Thu, 13 Jan 2022 19:39:15 +0000 (11:39 -0800)] 
build: update gnulib submodule to latest

3 years agocp: when copying to dir use dir-relative names
Paul Eggert [Wed, 12 Jan 2022 18:57:32 +0000 (10:57 -0800)] 
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.

3 years agocp: tweak internal name
Paul Eggert [Wed, 12 Jan 2022 21:52:23 +0000 (13:52 -0800)] 
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.

3 years agoscripts: fix typo in commit-msg git-hook script
Daniel Knittl-Frank [Wed, 12 Jan 2022 18:30:21 +0000 (19:30 +0100)] 
scripts: fix typo in commit-msg git-hook script

Commit 2f438fa9f53250fb3c8b39a95eedd627b5569ca4 (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".

3 years agodf: tiny simplification
Paul Eggert [Wed, 5 Jan 2022 22:35:31 +0000 (14:35 -0800)] 
df: tiny simplification

* src/df.c (LOG_EQ): Remove.  All callers replaced by ==.

3 years agomaint: update all copyright year number ranges
Pádraig Brady [Sun, 2 Jan 2022 15:42:45 +0000 (15:42 +0000)] 
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.

3 years agobuild: update gnulib submodule to latest
Pádraig Brady [Sun, 2 Jan 2022 15:28:34 +0000 (15:28 +0000)] 
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

3 years agodate: new option --resolution
Paul Eggert [Fri, 31 Dec 2021 08:45:03 +0000 (00:45 -0800)] 
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.

3 years agodate: %-N now means suppress extra digits
Paul Eggert [Fri, 31 Dec 2021 08:45:03 +0000 (00:45 -0800)] 
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.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Fri, 31 Dec 2021 08:45:03 +0000 (00:45 -0800)] 
build: update gnulib submodule to latest

3 years agodoc: Document , vs . in date --rfc-3339=ns
Paul Eggert [Fri, 31 Dec 2021 08:45:03 +0000 (00:45 -0800)] 
doc: Document , vs . in date --rfc-3339=ns

3 years agobuild: port to AIX 7.1
Paul Eggert [Fri, 31 Dec 2021 08:45:03 +0000 (00:45 -0800)] 
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).

3 years agobuild: be more careful about Perl
Paul Eggert [Tue, 28 Dec 2021 10:03:21 +0000 (02:03 -0800)] 
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.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 28 Dec 2021 09:53:44 +0000 (01:53 -0800)] 
build: update gnulib submodule to latest

3 years agoall: fix adjustment of /proc/$pid/cmdline by single binary
Max Filippov [Mon, 27 Dec 2021 11:58:28 +0000 (11:58 +0000)] 
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

3 years agols: improve doc for =WHEN
Paul Eggert [Fri, 24 Dec 2021 23:25:29 +0000 (15:25 -0800)] 
ls: improve doc for =WHEN

* src/ls.c (usage): Improve clarity of =WHEN args (Bug#52782).

3 years agodoc: colorize -> color
Paul Eggert [Fri, 24 Dec 2021 17:47:18 +0000 (09:47 -0800)] 
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.

3 years agomaint: update tests/init.sh from gnulib
Bernhard Voelker [Mon, 20 Dec 2021 22:13:36 +0000 (23:13 +0100)] 
maint: update tests/init.sh from gnulib

* tests/init.sh: Sync from gnulib/tests/init.sh.
A recent gnulib update (4f497bf3c) missed this.

3 years agomaint: syntax-check requires "char const *", not "const char *"
Jim Meyering [Mon, 20 Dec 2021 20:48:33 +0000 (12:48 -0800)] 
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.

3 years agomaint: split a long line
Jim Meyering [Mon, 20 Dec 2021 20:44:44 +0000 (12:44 -0800)] 
maint: split a long line

* src/test.c (three_arguments): Split long line.

3 years agomaint: commit-msg: compute UTF-8-aware line-length
Jim Meyering [Mon, 20 Dec 2021 01:19:01 +0000 (17:19 -0800)] 
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.

3 years agoid: improve doc for when USER is omitted
Paul Eggert [Sun, 19 Dec 2021 17:12:59 +0000 (09:12 -0800)] 
id: improve doc for when USER is omitted

* src/id.c (usage): “current user” → “current process” (Bug#52656).

3 years agomaint: use GNU style for spacing
Paul Eggert [Sat, 18 Dec 2021 17:34:31 +0000 (09:34 -0800)] 
maint: use GNU style for spacing

3 years agobuild: non-recursive Automake in a less hacky way
Bruno Haible [Thu, 16 Dec 2021 16:24:30 +0000 (08:24 -0800)] 
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.

3 years agobuild: update bootstrap to latest
Paul Eggert [Thu, 16 Dec 2021 16:20:15 +0000 (08:20 -0800)] 
build: update bootstrap to latest

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Thu, 16 Dec 2021 16:20:04 +0000 (08:20 -0800)] 
build: update gnulib submodule to latest

3 years agomaint: factor.c: avoid new GCC 12 warning
Jim Meyering [Sun, 12 Dec 2021 03:48:10 +0000 (19:48 -0800)] 
maint: factor.c: avoid new GCC 12 warning

* src/factor.c (millerrabin2): Mark as ATTRIBUTE_PURE,
per advice from GCC 12.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 14 Dec 2021 20:40:25 +0000 (12:40 -0800)] 
build: update gnulib submodule to latest

* NEWS: Mention the bugfix.

3 years agomv: Bug#52410 fix
Paul Eggert [Fri, 10 Dec 2021 22:08:58 +0000 (14:08 -0800)] 
mv: Bug#52410 fix

The recent Gnulib update fixed this bug reported by Vincent Vermilya.
* tests/mv/backup-dir.sh: Test for Bug#52410.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Fri, 10 Dec 2021 21:59:01 +0000 (13:59 -0800)] 
build: update gnulib submodule to latest

3 years agouname: port to recent macOS
Paul Eggert [Mon, 6 Dec 2021 22:39:22 +0000 (14:39 -0800)] 
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.

3 years agocp: clone on macOS
Paul Eggert [Sun, 21 Nov 2021 23:07:18 +0000 (15:07 -0800)] 
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.

3 years agocp: streamline cloning by skipping fstat
Paul Eggert [Sun, 21 Nov 2021 20:31:07 +0000 (12:31 -0800)] 
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.

3 years agocp: fix --preserve=ownership permissions bug
Paul Eggert [Sat, 20 Nov 2021 21:48:40 +0000 (13:48 -0800)] 
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.

3 years agomaint: prefer MAYBE_UNUSED
Paul Eggert [Fri, 19 Nov 2021 05:36:47 +0000 (21:36 -0800)] 
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.

3 years agocp: fix security context race
Paul Eggert [Wed, 17 Nov 2021 21:22:06 +0000 (13:22 -0800)] 
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.

3 years agomaint: update NEWS for macOS fix
Paul Eggert [Wed, 17 Nov 2021 01:06:16 +0000 (17:06 -0800)] 
maint: update NEWS for macOS fix

3 years agocp: minor clarity tweak
Paul Eggert [Wed, 17 Nov 2021 00:51:21 +0000 (16:51 -0800)] 
cp: minor clarity tweak

* src/copy.c (copy_reg): Use cached data_copy_required.

3 years agocp: fix ptrdiff_t/ssize_t theoretical glitches
Paul Eggert [Wed, 17 Nov 2021 00:10:21 +0000 (16:10 -0800)] 
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.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 16 Nov 2021 06:23:11 +0000 (22:23 -0800)] 
build: update gnulib submodule to latest

3 years agomaint: fix nonnull decl
Paul Eggert [Tue, 16 Nov 2021 05:30:15 +0000 (21:30 -0800)] 
maint: fix nonnull decl

* gl/lib/randread.h (randread_new): Do not mark with
_GL_ATTRIBUTE_RETURNS_NONNULL, since it can return NULL.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 15 Nov 2021 23:13:11 +0000 (15:13 -0800)] 
build: update gnulib submodule to latest

3 years agotests: avoid false failure in env-signal-handler.sh
Pádraig Brady [Sat, 13 Nov 2021 12:15:17 +0000 (12:15 +0000)] 
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

3 years agomaint: fix recent syntax-check failures
Pádraig Brady [Mon, 1 Nov 2021 13:36:43 +0000 (13:36 +0000)] 
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.

3 years agomaint: use minmax.h instead of rolling our own
Paul Eggert [Mon, 1 Nov 2021 05:30:38 +0000 (22:30 -0700)] 
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.

3 years agomaint: add function attributes to .h files
Paul Eggert [Mon, 1 Nov 2021 05:30:38 +0000 (22:30 -0700)] 
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.

3 years agomaint: enable -Wsuggest-attribute=format
Paul Eggert [Mon, 1 Nov 2021 05:30:38 +0000 (22:30 -0700)] 
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.

3 years agomaint: modernize attribute usage
Paul Eggert [Mon, 1 Nov 2021 05:30:38 +0000 (22:30 -0700)] 
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.

3 years agomaint: remove unused __attribute__ defn
Paul Eggert [Mon, 1 Nov 2021 05:30:38 +0000 (22:30 -0700)] 
maint: remove unused __attribute__ defn

* gl/lib/randread.c (__attribute__): Remove; no longer
used after the recent _Noreturn change.

3 years agob2sum: simplify attribute usage
Paul Eggert [Mon, 1 Nov 2021 05:30:38 +0000 (22:30 -0700)] 
b2sum: simplify attribute usage

* src/blake2/blake2.h (BLAKE2_PACKED): Simplify, and port better
to older GCC, by using _GL_ATTRIBUTE_PACKED.

3 years agomaint: prefer attribute.h in .c files
Paul Eggert [Mon, 1 Nov 2021 05:30:38 +0000 (22:30 -0700)] 
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.

3 years agosort: --debug: add warnings about sign, radix, and grouping chars
Pádraig Brady [Sun, 10 Oct 2021 17:35:59 +0000 (18:35 +0100)] 
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

3 years agomaint: modernize README-{hacking,prereq}
Paul Eggert [Sat, 30 Oct 2021 23:28:25 +0000 (16:28 -0700)] 
maint: modernize README-{hacking,prereq}

3 years agocp: revert unnecessary FreeBSD workaround
Paul Eggert [Sat, 30 Oct 2021 17:00:10 +0000 (10:00 -0700)] 
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.

3 years agocp: defend better against FreeBSD 9.1 zfs bug
Paul Eggert [Sat, 30 Oct 2021 01:01:34 +0000 (18:01 -0700)] 
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.

3 years agodoc: say that printf(1) is preferred over echo(1)
Pádraig Brady [Thu, 21 Oct 2021 12:05:47 +0000 (13:05 +0100)] 
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