]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
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

3 years agodoc: timeout --kill-after: clarify disabled timeouts
Pádraig Brady [Tue, 12 Oct 2021 13:47:44 +0000 (14:47 +0100)] 
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

3 years agotimeout: ensure --foreground -k exits with status 137
Pádraig Brady [Tue, 12 Oct 2021 13:32:57 +0000 (14:32 +0100)] 
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

3 years agodoc: timeout --foreground: add clarification on exit status
Pádraig Brady [Mon, 11 Oct 2021 21:04:38 +0000 (22:04 +0100)] 
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

3 years agosort: fix unlikely bug when '\377' < 0
Paul Eggert [Sun, 10 Oct 2021 22:59:56 +0000 (15:59 -0700)] 
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.

3 years agobuild: update gnulib submodule to latest
Paul Eggert [Sun, 3 Oct 2021 01:46:26 +0000 (18:46 -0700)] 
build: update gnulib submodule to latest

3 years agomaint: switch to C11-style _Noreturn
Paul Eggert [Sun, 3 Oct 2021 01:41:10 +0000 (18:41 -0700)] 
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.

3 years agols: port to OpenBSD
Paul Eggert [Sun, 3 Oct 2021 01:07:27 +0000 (18:07 -0700)] 
ls: port to OpenBSD

Problem reported by Brian Callahan (Bug#50972).
* src/ls.c (decode_switches): Don’t assume __GNUC_PREREQ.

3 years agodoc: adjust ls --zero option order in texinfo
Pádraig Brady [Sun, 26 Sep 2021 12:48:03 +0000 (13:48 +0100)] 
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.

3 years agotests: cp/sparse-perf: make more robust and add zfs comments
Pádraig Brady [Sat, 25 Sep 2021 13:23:37 +0000 (14:23 +0100)] 
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.

3 years agochmod: fix exit status when ignoring symlinks
Pádraig Brady [Fri, 24 Sep 2021 19:57:41 +0000 (20:57 +0100)] 
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

3 years agomaint: post-release administrivia
Pádraig Brady [Fri, 24 Sep 2021 12:58:11 +0000 (13:58 +0100)] 
maint: post-release administrivia

* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.

3 years agoversion 9.0 v9.0
Pádraig Brady [Fri, 24 Sep 2021 12:35:26 +0000 (13:35 +0100)] 
version 9.0

* NEWS: Record release date.

3 years agotests: sparse-perf: avoid false failure
Pádraig Brady [Thu, 23 Sep 2021 15:19:35 +0000 (16:19 +0100)] 
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.

3 years agocksum: fix -a crc on 64 bit big endian systems
Pádraig Brady [Thu, 23 Sep 2021 21:45:53 +0000 (22:45 +0100)] 
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

3 years agotail: fix detection of closed stdout on macOS
Pádraig Brady [Tue, 21 Sep 2021 13:01:34 +0000 (14:01 +0100)] 
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

3 years agomaint: clean up c++ style comments
Pádraig Brady [Tue, 21 Sep 2021 15:18:05 +0000 (16:18 +0100)] 
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.

3 years agotests: date-debug: avoid a false failure on solaris
Pádraig Brady [Mon, 20 Sep 2021 22:35:23 +0000 (23:35 +0100)] 
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.

3 years agodoc: drop extraneous single quotes in help
Jim Meyering [Sat, 18 Sep 2021 16:27:27 +0000 (09:27 -0700)] 
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.

3 years agocksum: list Pádraig as coauthor
Jim Meyering [Sat, 18 Sep 2021 16:30:53 +0000 (09:30 -0700)] 
cksum: list Pádraig as coauthor

* src/digest.c (AUTHORS) [HASH_ALGO_CKSUM]: Add Pádraig as
cksum coauthor.
* AUTHORS: Likewise.

3 years agotests: env-s.pl: avoid spurious failure on OS X
Jim Meyering [Mon, 20 Sep 2021 05:44:25 +0000 (22:44 -0700)] 
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.

3 years agobuild: update gnulib submodule to latest
Pádraig Brady [Mon, 20 Sep 2021 15:31:48 +0000 (16:31 +0100)] 
build: update gnulib submodule to latest

* gnulib: Update to latest.
Fixes "extern inline" and "rpl_free" issues.

3 years agodoc: fix --help formatting for checksum utils
Pádraig Brady [Mon, 20 Sep 2021 12:56:39 +0000 (13:56 +0100)] 
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.

3 years agocksum: support more transparent emulation of older utils
Pádraig Brady [Mon, 20 Sep 2021 10:54:08 +0000 (11:54 +0100)] 
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.

3 years agotests: avoid rare race in tail-2/F-vs-rename.sh
Pádraig Brady [Fri, 17 Sep 2021 12:31:25 +0000 (13:31 +0100)] 
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.

3 years agomaint: remove duplicate from THANKS.in
Pádraig Brady [Fri, 17 Sep 2021 12:38:04 +0000 (13:38 +0100)] 
maint: remove duplicate from THANKS.in

* THANKS.in: Now that Tianjia Zhang has a commit in the repo.

3 years agotests: fix typo in cksum-a.sh
Tianjia Zhang [Fri, 17 Sep 2021 03:06:58 +0000 (11:06 +0800)] 
tests: fix typo in cksum-a.sh

* tests/misc/cksum-a.sh: fix typo md5um to md5sum.

3 years agotests: fix rare false failure in tail-2/F-vs-rename
Pádraig Brady [Fri, 17 Sep 2021 00:22:54 +0000 (01:22 +0100)] 
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").

3 years agotests: port removed-directory test to FreeBSD
Pádraig Brady [Thu, 16 Sep 2021 23:17:03 +0000 (00:17 +0100)] 
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.

3 years agormdir: fix uninitialized memory causing incorrect error
Pádraig Brady [Thu, 16 Sep 2021 22:31:07 +0000 (23:31 +0100)] 
rmdir: fix uninitialized memory causing incorrect error

* src/rmdir.c (main): Only inspect the returned stat structure,
when stat(2) returns success.

3 years agobuild: avoid new chmod.c warnings from upcoming GCC12
Jim Meyering [Thu, 16 Sep 2021 20:23:46 +0000 (13:23 -0700)] 
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.

3 years agodigest: ignore empty lines when checking
Pádraig Brady [Thu, 16 Sep 2021 11:29:12 +0000 (12:29 +0100)] 
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.

3 years agofactor: sync longlong.h adjustments from upstream
Pádraig Brady [Thu, 16 Sep 2021 14:42:05 +0000 (15:42 +0100)] 
factor: sync longlong.h adjustments from upstream

* src/longlong.h: Sync changes from:
https://gmplib.org/repo/gmp/log/tip/longlong.h

3 years agostat,tail: add support for the secretmem file system
Pádraig Brady [Thu, 16 Sep 2021 14:21:05 +0000 (15:21 +0100)] 
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.

3 years agomaint: sync help2man to latest version
Pádraig Brady [Thu, 16 Sep 2021 14:03:23 +0000 (15:03 +0100)] 
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.

3 years agodoc: remove older ChangeLog items
Pádraig Brady [Thu, 16 Sep 2021 13:49:19 +0000 (14:49 +0100)] 
doc: remove older ChangeLog items

* Makefile.am: Update the oldest documented version
to 8.25 which is now about 5 years old.

3 years agotests: ensure returns_ check failures are propagated
Pádraig Brady [Thu, 16 Sep 2021 11:21:16 +0000 (12:21 +0100)] 
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.

3 years agocksum: fix --check with non tagged format checksums
Pádraig Brady [Thu, 16 Sep 2021 10:40:51 +0000 (11:40 +0100)] 
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.

3 years agocksum: fix off-by-1 bug with \r stripping
Paul Eggert [Thu, 16 Sep 2021 07:17:18 +0000 (00:17 -0700)] 
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.

3 years agomaint: prefer rawmemchr to memchr when easy
Paul Eggert [Wed, 15 Sep 2021 21:09:03 +0000 (14:09 -0700)] 
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.

3 years agosplit: avoid NULL + 1
Paul Eggert [Wed, 15 Sep 2021 20:44:46 +0000 (13:44 -0700)] 
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.

3 years agodigest: support windows format checksum files
Pádraig Brady [Tue, 14 Sep 2021 21:52:09 +0000 (22:52 +0100)] 
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.

3 years agodoc: improve --help indenting in checksum utils
Pádraig Brady [Tue, 14 Sep 2021 16:14:02 +0000 (17:14 +0100)] 
doc: improve --help indenting in checksum utils

* src/digest.c (usage): Indent multi-line descriptions for clarity.

3 years agocksum: operate in binary mode only
Pádraig Brady [Mon, 13 Sep 2021 14:24:24 +0000 (15:24 +0100)] 
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.

3 years agocksum: use --tag format by default
Pádraig Brady [Mon, 13 Sep 2021 11:57:34 +0000 (12:57 +0100)] 
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.

3 years agocksum: support --zero in default mode
Pádraig Brady [Sun, 12 Sep 2021 15:57:12 +0000 (16:57 +0100)] 
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.

3 years agodigest: support -length specifiers on all digest tags
Pádraig Brady [Sat, 11 Sep 2021 15:38:50 +0000 (16:38 +0100)] 
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.

3 years agocksum: support digest detection for tagged format
Pádraig Brady [Sat, 11 Sep 2021 15:19:39 +0000 (16:19 +0100)] 
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.

3 years agomaint: simplify b2sum to only handle BLAKE2b
Pádraig Brady [Fri, 10 Sep 2021 13:45:33 +0000 (14:45 +0100)] 
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.

3 years agodigest: add support for sm3
Pádraig Brady [Tue, 7 Sep 2021 14:45:01 +0000 (15:45 +0100)] 
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>
3 years agocksum: add --algorithm option to select digest mode
Pádraig Brady [Mon, 6 Sep 2021 14:17:12 +0000 (15:17 +0100)] 
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.