]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
23 months agocp,mv,install: a bit more up-to-date source stat
Paul Eggert [Tue, 5 Sep 2023 06:03:52 +0000 (23:03 -0700)] 
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.

23 months agocp,mv,install: fix chmod on Linux CIFS
Paul Eggert [Sat, 2 Sep 2023 20:27:45 +0000 (13:27 -0700)] 
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.

23 months agocp,mv,install: fix chown on Linux CIFS
Paul Eggert [Fri, 1 Sep 2023 22:05:21 +0000 (15:05 -0700)] 
cp,mv,install: fix chown on Linux CIFS

* src/copy.c (chown_failure_ok): Also treat EACCES as OK.

23 months agomaint: simplify set_owner
Paul Eggert [Fri, 1 Sep 2023 16:14:02 +0000 (09:14 -0700)] 
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.

23 months agochown: port to mingw and MSVC 14
Paul Eggert [Fri, 1 Sep 2023 16:11:32 +0000 (09:11 -0700)] 
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.

23 months agomaint: avoid syntax check failure
Pádraig Brady [Thu, 31 Aug 2023 20:59:02 +0000 (21:59 +0100)] 
maint: avoid syntax check failure

* tests/misc/numfmt.pl: Keep lines <= 80 chars.

23 months agomaint: Gnulib module gc
Paul Eggert [Thu, 31 Aug 2023 00:51:42 +0000 (17:51 -0700)] 
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.

23 months agomaint: assume non-rare encodings
Paul Eggert [Thu, 31 Aug 2023 00:41:42 +0000 (17:41 -0700)] 
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.

23 months agomaint: tune for single thread & locale
Paul Eggert [Wed, 30 Aug 2023 23:59:39 +0000 (16:59 -0700)] 
maint: tune for single thread & locale

* configure.ac (GNULIB_EXCLUDE_SINGLE_THREAD)
(GNULIB_REGEX_SINGLE_THREAD, GNULIB_WCHAR_SINGLE_LOCALE):
Define.

23 months agomaint: regularize struct initializers
Paul Eggert [Wed, 30 Aug 2023 14:39:34 +0000 (07:39 -0700)] 
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.

23 months agomaint: rely on Gnulib fdatasync
Paul Eggert [Wed, 30 Aug 2023 14:16:49 +0000 (07:16 -0700)] 
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.

23 months agomaint: use modern Gnulib LIB_ macros
Paul Eggert [Wed, 30 Aug 2023 14:15:09 +0000 (07:15 -0700)] 
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.

23 months agokill: rely on Gnulib strsignal
Paul Eggert [Wed, 30 Aug 2023 13:51:18 +0000 (06:51 -0700)] 
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.

23 months agomaint: remove rename macro
Paul Eggert [Wed, 30 Aug 2023 06:52:07 +0000 (23:52 -0700)] 
maint: remove rename macro

* src/copy.h (rename) [RENAME_TRAILING_SLASH_BUG]:
Remove: unused, now that Gnulib takes care of this.

23 months agomaint: remove need for mbsalign
Paul Eggert [Wed, 30 Aug 2023 06:52:07 +0000 (23:52 -0700)] 
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.

23 months agomaint: post-release administrivia
Pádraig Brady [Tue, 29 Aug 2023 14:23:14 +0000 (15:23 +0100)] 
maint: post-release administrivia

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

23 months agoversion 9.4 v9.4
Pádraig Brady [Tue, 29 Aug 2023 13:36:22 +0000 (14:36 +0100)] 
version 9.4

* NEWS: Record release date.

23 months agomaint: spelling fixes, including author names
Paul Eggert [Mon, 28 Aug 2023 19:42:23 +0000 (12:42 -0700)] 
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.

23 months agotest: omit unreachable code
Paul Eggert [Mon, 28 Aug 2023 19:40:57 +0000 (12:40 -0700)] 
test: omit unreachable code

* src/test.c (unary_operator): Omit unreachable ‘return false;’.
Oracle Solaris Studio 12.6 warns about it.

23 months agotests: avoid test failure on Android
Bruno Haible [Mon, 28 Aug 2023 10:07:18 +0000 (12:07 +0200)] 
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.

23 months agosort: port sort-merge-fdlimit test to Solaris 10
Paul Eggert [Mon, 28 Aug 2023 03:49:33 +0000 (20:49 -0700)] 
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.

23 months agosort: port sort-continue test back to Solaris 10
Paul Eggert [Mon, 28 Aug 2023 02:13:42 +0000 (19:13 -0700)] 
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.

23 months agotests: avoid false failure on cygwin
Pádraig Brady [Sun, 27 Aug 2023 19:22:32 +0000 (20:22 +0100)] 
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.

23 months agocksum: adjust tests and docs to binary mode handling
Pádraig Brady [Sun, 27 Aug 2023 18:52:13 +0000 (19:52 +0100)] 
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.

23 months agoall: avoid duplicated write errors on FreeBSD
Pádraig Brady [Sun, 27 Aug 2023 15:01:27 +0000 (16:01 +0100)] 
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.

23 months agotests: avoid false failure where sleep is a shell builtin
Pádraig Brady [Sun, 27 Aug 2023 15:22:37 +0000 (16:22 +0100)] 
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.

23 months agobuild: fix link errors of sort, split on CentOS 5 and Solaris 10
Bruno Haible [Sat, 26 Aug 2023 23:10:13 +0000 (01:10 +0200)] 
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).

23 months agobuild: fix compilation error on AIX 7.1
Bruno Haible [Sat, 26 Aug 2023 19:01:48 +0000 (21:01 +0200)] 
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.

23 months agobuild: update with gnulib fixes
Pádraig Brady [Sun, 27 Aug 2023 15:09:07 +0000 (16:09 +0100)] 
build: update with gnulib fixes

* gnulib: Update to incorporate gnulib fixes
from Bruno Haible from his coreutils 9.4 pre-release testing.

23 months agodoc: remove older ChangeLog items
Pádraig Brady [Thu, 24 Aug 2023 11:10:49 +0000 (12:10 +0100)] 
doc: remove older ChangeLog items

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

23 months agoshred: fix operation on Solaris with 64 bit builds
Pádraig Brady [Wed, 23 Aug 2023 14:21:01 +0000 (15:21 +0100)] 
shred: fix operation on Solaris with 64 bit builds

* NEWS: Mention the bug fix.
* gl/lib/randread.c (get_nonce): Limit getrandom() <= 1024 bytes.

23 months agobuild: update gnulib submodule to latest
Pádraig Brady [Tue, 22 Aug 2023 10:56:45 +0000 (11:56 +0100)] 
build: update gnulib submodule to latest

* gnulib: Update to latest

23 months agodoc: reorg texinfo for the checksumming utilities
Pádraig Brady [Mon, 21 Aug 2023 13:51:49 +0000 (14:51 +0100)] 
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.

23 months agodoc: cksum: remove -b description from texinfo
Pádraig Brady [Mon, 21 Aug 2023 13:56:20 +0000 (14:56 +0100)] 
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.

23 months agocp: with --sparse=never, avoid COW and copy offload
Pádraig Brady [Mon, 21 Aug 2023 12:39:14 +0000 (13:39 +0100)] 
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.

23 months agomaint: comment spelling fix
Pádraig Brady [Sat, 19 Aug 2023 15:45:17 +0000 (16:45 +0100)] 
maint: comment spelling fix

* tests/split/l-chunk-root.sh: Fix recently introduced typo.

23 months agomaint: remove extraneous line in NEWS
Pádraig Brady [Wed, 16 Aug 2023 10:47:54 +0000 (11:47 +0100)] 
maint: remove extraneous line in NEWS

* NEWS: Remove extraneous line.

23 months agouptime: simplify following gnulib changes
Bruno Haible [Tue, 15 Aug 2023 22:20:05 +0000 (15:20 -0700)] 
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.

23 months agomaint: update uptime NEWS
Paul Eggert [Tue, 15 Aug 2023 22:20:05 +0000 (15:20 -0700)] 
maint: update uptime NEWS

* NEWS: Update as per Bruno Haible <https://bugs.gnu.org/65255#14>.

23 months agotests: fix false failure due to locale on alpine
Pádraig Brady [Tue, 15 Aug 2023 15:44:26 +0000 (16:44 +0100)] 
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

23 months agouptime: be more generous about read_utmp failure
Paul Eggert [Tue, 15 Aug 2023 21:00:54 +0000 (14:00 -0700)] 
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.

23 months agouptime: Include VM sleep time in the "up" duration
Bruno Haible [Tue, 15 Aug 2023 19:01:13 +0000 (12:01 -0700)] 
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'.

23 months agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 15 Aug 2023 18:45:40 +0000 (11:45 -0700)] 
build: update gnulib submodule to latest

23 months agomaint: fix typo in NEWS
Bernhard Voelker [Tue, 15 Aug 2023 11:35:13 +0000 (13:35 +0200)] 
maint: fix typo in NEWS

* NEWS: s|/who/log/wtmp|/var/log/tmp|, introduced in commit 85edb4afbd1.

23 months agodoc: reference install(1) and cp(1) from each other
Bernhard Voelker [Tue, 15 Aug 2023 11:22:42 +0000 (13:22 +0200)] 
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

23 months agobuild: fix recent compilation error on GNU/Hurd
Bruno Haible [Mon, 14 Aug 2023 18:59:41 +0000 (20:59 +0200)] 
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).

23 months agomaint: avoid syntax-check failure
Pádraig Brady [Mon, 14 Aug 2023 13:03:35 +0000 (14:03 +0100)] 
maint: avoid syntax-check failure

* po/POTFILES.in: Cater to lib/file-type.c adjustments
as suggested by sc_po_check.

23 months agobuild: fix link errors with gcc < 4.8
Bruno Haible [Sun, 13 Aug 2023 23:45:39 +0000 (01:45 +0200)] 
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.

23 months agodoc: improve NEWS discussion of systemd
Paul Eggert [Sun, 13 Aug 2023 06:50:50 +0000 (23:50 -0700)] 
doc: improve NEWS discussion of systemd

23 months agobuild: update gnulib submodule to latest
Paul Eggert [Sun, 13 Aug 2023 06:38:16 +0000 (23:38 -0700)] 
build: update gnulib submodule to latest

23 months agomaint: allow use of printf C99 integer size specifiers
Pádraig Brady [Sat, 12 Aug 2023 10:21:50 +0000 (11:21 +0100)] 
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.

23 months agodoc: separate out description of 2038 time stamp change
Pádraig Brady [Fri, 11 Aug 2023 13:27:59 +0000 (14:27 +0100)] 
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.

23 months agopinky,users,who: optimize read_utmp invocation
Bruno Haible [Thu, 10 Aug 2023 11:50:57 +0000 (13:50 +0200)] 
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.

2 years agowho: simplify based on readutmp changes
Paul Eggert [Wed, 9 Aug 2023 03:03:40 +0000 (20:03 -0700)] 
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.

2 years agopinky,who: omit pragma
Paul Eggert [Wed, 9 Aug 2023 02:32:49 +0000 (19:32 -0700)] 
pinky,who: omit pragma

* src/pinky.c, src/who.c:
Omit no-longer-needed -Wstringop-overread pragma.

2 years agomaint: Simplify after gnulib changed
Bruno Haible [Tue, 8 Aug 2023 16:56:39 +0000 (18:56 +0200)] 
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.

2 years agomaint: Update after gnulib module 'readutmp' changed
Paul Eggert [Fri, 4 Aug 2023 01:35:29 +0000 (18:35 -0700)] 
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.

2 years agouptime: fix Y5881633 bug
Paul Eggert [Wed, 2 Aug 2023 13:51:55 +0000 (06:51 -0700)] 
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...).

2 years agopinky: fix "d" typo
Paul Eggert [Wed, 2 Aug 2023 13:47:13 +0000 (06:47 -0700)] 
pinky: fix "d" typo

Problem reported by Bruno Haible (bug#65003).
* src/pinky.c (idle_string): Fix recently-introduced typo:
missing "d" for "days".

2 years agomaint: minor comment cleanups
Dragan Simic [Tue, 1 Aug 2023 09:07:42 +0000 (11:07 +0200)] 
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.

2 years agocut: promptly diagnose write errors, continued
Dragan Simic [Tue, 1 Aug 2023 09:07:41 +0000 (11:07 +0200)] 
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.

2 years agomaint: reformat text width in HACKING
Dragan Simic [Tue, 1 Aug 2023 09:07:40 +0000 (11:07 +0200)] 
maint: reformat text width in HACKING

* HACKING: Adjust line lengths.

2 years agopinky: fix buffer size on 32 bit builds
Pádraig Brady [Tue, 1 Aug 2023 13:54:15 +0000 (14:54 +0100)] 
pinky: fix buffer size on 32 bit builds

* src/pinky.c (idle_string): Use the correct buffer size
following the recent int type adjustment.

2 years agood: fix issues with recent format string changes
Pádraig Brady [Tue, 1 Aug 2023 12:30:02 +0000 (13:30 +0100)] 
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.

2 years agopinky: prefer signed types
Paul Eggert [Tue, 1 Aug 2023 00:51:03 +0000 (17:51 -0700)] 
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...).

2 years agopathchk: prefer signed types
Paul Eggert [Tue, 1 Aug 2023 00:47:01 +0000 (17:47 -0700)] 
pathchk: prefer signed types

* src/pathchk.c (validate_file_name): Prefer signed types.

2 years agonumfmt: prefer signed types
Paul Eggert [Tue, 1 Aug 2023 00:46:15 +0000 (17:46 -0700)] 
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.

2 years agomktemp,seq: prefer signed types
Paul Eggert [Tue, 1 Aug 2023 00:43:05 +0000 (17:43 -0700)] 
mktemp,seq: prefer signed types

* src/mktemp.c (main):
* src/seq.c (main): Prefer signed types.

2 years agokill: prefer signed types
Paul Eggert [Mon, 31 Jul 2023 23:38:02 +0000 (16:38 -0700)] 
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.

2 years agogroups,id: don’t assume gid_t fits in unsigned long
Paul Eggert [Mon, 31 Jul 2023 23:36:38 +0000 (16:36 -0700)] 
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.

2 years agodircolors,du,expr: prefer signed types
Paul Eggert [Mon, 31 Jul 2023 23:35:32 +0000 (16:35 -0700)] 
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.

2 years agood: prefer signed types
Paul Eggert [Mon, 31 Jul 2023 23:33:38 +0000 (16:33 -0700)] 
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.

2 years agocksum,df,digest: prefer signed types
Paul Eggert [Mon, 31 Jul 2023 23:30:24 +0000 (16:30 -0700)] 
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.

2 years agojoin: prefer signed types
Paul Eggert [Mon, 31 Jul 2023 23:29:49 +0000 (16:29 -0700)] 
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.

2 years agofactor: prefer signed types
Paul Eggert [Mon, 31 Jul 2023 20:43:19 +0000 (13:43 -0700)] 
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.

2 years agomaint: include idx.h everywhere
Paul Eggert [Mon, 31 Jul 2023 18:24:08 +0000 (11:24 -0700)] 
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.

2 years agowho: fix only-theoretical overflow
Paul Eggert [Mon, 31 Jul 2023 18:21:25 +0000 (11:21 -0700)] 
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.

2 years agotac: handle short reads on input
Pádraig Brady [Mon, 31 Jul 2023 11:41:26 +0000 (12:41 +0100)] 
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

2 years agouptime: output correct user count on OpenBSD
Bruno Haible [Sun, 30 Jul 2023 14:30:08 +0000 (16:30 +0200)] 
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).

2 years agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 31 Jul 2023 16:13:23 +0000 (09:13 -0700)] 
build: update gnulib submodule to latest

2 years agobuild: update gnulib submodule to latest
Paul Eggert [Sun, 30 Jul 2023 00:12:39 +0000 (17:12 -0700)] 
build: update gnulib submodule to latest

* NEWS: Mention a bug that this fixes.

2 years agomv: better diagnostic for 'mv dir x' failure
Paul Eggert [Sat, 22 Jul 2023 20:39:17 +0000 (13:39 -0700)] 
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.

2 years agodoc: clarify tail -n/-c +NUM operation
Pádraig Brady [Thu, 20 Jul 2023 13:50:56 +0000 (14:50 +0100)] 
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.

2 years agomaint: add a syntax check to prevent use of NULL
Pádraig Brady [Tue, 18 Jul 2023 22:08:42 +0000 (23:08 +0100)] 
maint: add a syntax check to prevent use of NULL

* cfg.mk (sc_prohibit_NULL): Direct to use nullptr instead.

2 years agotests: split: provide more isolated /tmp handling
Pádraig Brady [Tue, 18 Jul 2023 11:40:57 +0000 (12:40 +0100)] 
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.

2 years agosplit: honor $TMPDIR for temp files
Pádraig Brady [Tue, 18 Jul 2023 17:55:30 +0000 (18:55 +0100)] 
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.

2 years agotac: fall back to /tmp if $TMPDIR is unavailable
Pádraig Brady [Tue, 18 Jul 2023 14:39:05 +0000 (15:39 +0100)] 
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.

2 years agomaint: add syntax check to ensure safe mkstemp usage
Pádraig Brady [Tue, 18 Jul 2023 17:38:42 +0000 (18:38 +0100)] 
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.

2 years agojoin: promptly diagnose write errors
Pádraig Brady [Sat, 15 Jul 2023 20:55:23 +0000 (21:55 +0100)] 
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.

2 years agocomm: promptly diagnose write errors
Pádraig Brady [Sat, 15 Jul 2023 20:43:07 +0000 (21:43 +0100)] 
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.

2 years agocut: promptly diagnose write errors
Pádraig Brady [Sat, 15 Jul 2023 20:23:55 +0000 (21:23 +0100)] 
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.

2 years agouniq: promptly diagnose write errors
Pádraig Brady [Sat, 15 Jul 2023 20:10:38 +0000 (21:10 +0100)] 
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.

2 years agood: promptly diagnose write errors
Pádraig Brady [Tue, 11 Jul 2023 11:46:50 +0000 (12:46 +0100)] 
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

2 years agoall: avoid repeated diagnostic upon write error
Pádraig Brady [Sat, 15 Jul 2023 19:41:44 +0000 (20:41 +0100)] 
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.

2 years agotests: ensure utilties exit promptly upon write error
Pádraig Brady [Tue, 11 Jul 2023 12:28:53 +0000 (13:28 +0100)] 
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.

2 years agocksum: improve problematic_chars function
Jim Meyering [Fri, 14 Jul 2023 05:29:52 +0000 (22:29 -0700)] 
cksum: improve problematic_chars function

* src/digest.c (problematic_chars): Implement using strcspn,
and traversing S only once, rather than once per escaped byte.

2 years agomaint: give a new function the "pure" attribute
Pádraig Brady [Wed, 12 Jul 2023 19:34:47 +0000 (20:34 +0100)] 
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.

2 years agocksum: escape filenames with a leading '\' in --check status
Pádraig Brady [Sat, 1 Jul 2023 16:01:18 +0000 (17:01 +0100)] 
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

2 years agocksum: support transparent emulation of older utils
Pádraig Brady [Sat, 8 Jul 2023 14:14:12 +0000 (15:14 +0100)] 
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.

2 years agomaint: avoid static analysis failure for ignored dup2 return
Pádraig Brady [Sat, 8 Jul 2023 12:42:51 +0000 (13:42 +0100)] 
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.