summaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)AuthorLines
2023-08-28maint: spelling fixes, including author namesPaul Eggert-71/+67
Most of this just affects commentary and documentations. The only significant behavior change is translating author names via proper_name_lite rather than proper_name_utf8, or not translating them at all. proper_name_lite is good enough for coreutils and avoids the bloat that had coreutils not using Gnulib proper_name. * bootstrap.conf (gnulib_modules): Use propername-lite instead of propername. (XGETTEXT_OPTIONS): Look for proper_name_lite instead of for proper_name_utf8. * cfg.mk (local-checks-to-skip): Remove sc_proper_name_utf8_requires_ICONV, since we no longer use proper_name_utf8. (old_NEWS_hash): Update. (sc_check-I18N-AUTHORS): Remove; no longer needed.
2023-08-28test: omit unreachable codePaul Eggert-1/+0
* src/test.c (unary_operator): Omit unreachable ‘return false;’. Oracle Solaris Studio 12.6 warns about it.
2023-08-27all: avoid duplicated write errors on FreeBSDPádraig Brady-2/+4
* src/system.h (write_error): Also call fpurge(), which was seen to be needed on FreeBSD 13.1 to avoid duplicated write errors. * src/head.c (xwrite_stdout): Likewise. * bootstrap.conf: Depend on fpurge. Reported by Bruno Haible.
2023-08-27build: fix link errors of sort, split on CentOS 5 and Solaris 10Bruno Haible-0/+2
* src/local.mk (src_sort_LDADD, src_split_LDADD): Add $(CLOCK_TIME_LIB).
2023-08-27build: fix compilation error on AIX 7.1Bruno Haible-1/+4
* src/copy.c (copy_internal): Don't test for ENOTEMPTY if it has the same value as EEXIST.
2023-08-21cp: with --sparse=never, avoid COW and copy offloadPádraig Brady-0/+9
* src/cp.c (main): Set default reflink mode appropriately with --sparse=never. * src/copy.c (infer_scantype): Add a comment to related code. * tests/cp/sparse-2.sh: Add a test case. * NEWS: Mention the bug.
2023-08-15uptime: simplify following gnulib changesBruno Haible-30/+0
* build-aux/gen-lists-of-programs.sh (build_if_possible_progs): Remove uptime. (normal_progs): Add uptime. * configure.ac: Remove GNULIB_BOOT_TIME invocation. * m4/boottime.m4: Remove file. * src/uptime.c: Don't include <sys/sysctl.h>, <OS.h>. (print_uptime): Don't call sysctl, get_system_info, as Gnulib's readutmp module now does this.
2023-08-15uptime: be more generous about read_utmp failurePaul Eggert-31/+46
* src/uptime.c (print_uptime): Check for overflow when computing uptime. Use C99-style decl after statements. Do not let an idx_t value go negative. (print_uptime, uptime): Be more generous about read_utmp failures, or when read_utmp does not report the boot time. Instead of failing, warn but keep going, printing the information that we did get, and then exit with nonzero status. (print_uptime): Return the desired exit status. Caller changed.
2023-08-15uptime: Include VM sleep time in the "up" durationBruno Haible-30/+6
* src/uptime.c: Don't include c-strtod.h. (print_uptime): Don't read /proc/uptime, because the value it provides does not change when a date adjustment occurs. * bootstrap.conf (gnulib_modules): Remove 'uptime'.
2023-08-14build: fix recent compilation error on GNU/HurdBruno Haible-1/+1
* src/copy.c (set_author): Revert change from MACH_PORT_NULL to MACH_PORT_nullptr from commit 16b5ca6e (2023-06-29).
2023-08-11pinky,users,who: optimize read_utmp invocationBruno Haible-1/+4
When we are only interested in entries of type USER_PROCESS, tell read_utmp that it does not need to determine the boot time. * src/pinky.c (short_pinky): Pass option READ_UTMP_USER_PROCESS. * src/users.c (users): Likewise. * src/who.c (who): Likewise, if calling list_entries_who.
2023-08-08who: simplify based on readutmp changesPaul Eggert-64/+44
* src/pinky.c (time_string, print_entry, scan_entries, short_pinky): * src/uptime.c (print_uptime, uptime): * src/users.c (list_entries_users, users): * src/who.c (UT_TYPE_RUN_LVL, UT_TYPE_INIT_PROCESS) (UT_TYPE_LOGIN_PROCESS, UT_TYPE_DEAD_PROCESS, UT_TYPE_NEW_TIME) (time_string, print_user, print_boottime) (make_id_equals_comment, print_deadprocs, print_login) (print_initspawn, print_clockchange, print_runlevel) (list_entries_who, scan_entries, who): Simplify, partly by using plain -> rather than macros.
2023-08-08pinky,who: omit pragmaPaul Eggert-12/+0
* src/pinky.c, src/who.c: Omit no-longer-needed -Wstringop-overread pragma.
2023-08-08maint: Simplify after gnulib changedBruno Haible-49/+22
Update gnulib submodule to latest. All of UT_USER_SIZE, UT_ID_SIZE, UT_LINE_SIZE, UT_HOST_SIZE are now -1. * src/pinky.c (print_entry): Remove code for bounded-length ut_line, ut_user, ut_host. (scan_entries): Remove code for bounded-length ut_user. * src/who.c (print_line): Remove userlen, linelen arguments. (print_user): Remove code for bounded-length ut_line, ut_user, ut_host. (make_id_equals_comment): Remove code for bounded-length ut_id. (print_boottime, print_deadprocs, print_login, print_initspawn, print_clockchange, print_runlevel, print_heading): Update print_line invocations. (scan_entries): Remove code for bounded-length ut_line.
2023-08-03maint: Update after gnulib module 'readutmp' changedPaul Eggert-90/+154
(This patch is coauthored with Bruno Haible, with original version at <https://bugs.gnu.org/64937#>.) This updates the gnulib submodule to latest. For year-2038 safety on Linux/{x86,arm}, this adds an --enable-systemd option to ‘configure’. The idea is that this sort of thing will become the default after it has been tested more. * configure.ac: Don't test whether struct utmp and struct utmpx have the ut_host field; this is now done in gnulib's readutmp module. * src/local.mk: Link the programs 'pinky', 'uptime', 'users', 'who' with $(READUTMP_LIB). * src/pinky.c, src/who.c: Test HAVE_STRUCT_XTMP_UT_HOST instead of HAVE_UT_HOST. * src/pinky.c (print_entry): * src/who.c (print_user, print_deadprocs, print_login) (print_initspawn, scan_entries): Support the situation where ut_line is a 'char *' rather than a 'char[]' of fixed size. Likewise for ut_user and ut_host. (make_id_equals_comment): Likewise for ut_id. * src/pinky.c (print_entry): * src/who.c (print_user): Open /dev to simplify looking up its entries. Don’t use printf if the output might in theory be longer than INT_MAX. * src/pinky.c (scan_entries, short_pinky): * src/uptime.c (print_uptime, uptime): * src/users.c (list_entries_users, users): * src/who.c (who): Use idx_t where new read_utmp needs it. * src/system.h (STREQ_LEN): Add comment that last arg can be -1.
2023-08-02uptime: fix Y5881633 bugPaul Eggert-8/+8
* src/uptime.c (print_uptime): Prefer signed types. Fix unlikely bug on platforms with 32-bit long and 64-bit time_t if the idle time exceeds 2**31 days (about 6 million years...).
2023-08-02pinky: fix "d" typoPaul Eggert-2/+2
Problem reported by Bruno Haible (bug#65003). * src/pinky.c (idle_string): Fix recently-introduced typo: missing "d" for "days".
2023-08-01maint: minor comment cleanupsDragan Simic-12/+12
* src/cut.c: Adjust a few comments slightly, simply to have their trailing whitespace the same as in the majority of the comments.
2023-08-01cut: promptly diagnose write errors, continuedDragan Simic-13/+23
* src/cut.c: Complete the error-handling improvements started in commit e0a4a60af5, by adding a couple of remaining checks for putchar(). While there, sprinkle a few rather useful comments, and perform a few small code cleanups, to make the code and the comments more uniform and more conformant to the official coding style. Also make the help message slightly more uniform.
2023-08-01pinky: fix buffer size on 32 bit buildsPádraig Brady-1/+1
* src/pinky.c (idle_string): Use the correct buffer size following the recent int type adjustment.
2023-08-01od: fix issues with recent format string changesPádraig Brady-3/+2
* src/ioblksize.h: Avoid syntax check with redundant idx.h inclusion. * src/od.c (FMT_BYTES_ALLOCATED): Increase by two to avoid: error: '%s' directive writing between 1 and 2 bytes into a region of size between 1 and 4 [-Werror=format-overflow=] (maint): Use %td to print idx_t rather than invalid %jt format.
2023-07-31pinky: prefer signed typesPaul Eggert-2/+2
* src/pinky.c (idle_string): Prefer intmax_t to unsigned long int; this avoids an overflow on platforms where unsigned long is 32 bits and time_t is 64 bits (the bug could occur on such a system that was idle for more than 6 million years, so it’s a bit hard to supply a test case...).
2023-07-31pathchk: prefer signed typesPaul Eggert-19/+15
* src/pathchk.c (validate_file_name): Prefer signed types.
2023-07-31numfmt: prefer signed typesPaul Eggert-12/+11
* src/numfmt.c (suffix_power_char, powerld, expld) (simple_strtod_int, double_to_human, prepare_padded_number) (process_suffixed_number): Prefer signed types. (process_suffixed_number): Fix an unlikely bug if an arg has exactly 2**32 spaces at the start.
2023-07-31mktemp,seq: prefer signed typesPaul Eggert-3/+2
* src/mktemp.c (main): * src/seq.c (main): Prefer signed types.
2023-07-31kill: prefer signed typesPaul Eggert-3/+3
* src/kill.c (list_signals): Prefer signed types. This avoids undefined behavior on theoretical platforms where unsigned and signed int have different representations.
2023-07-31groups,id: don’t assume gid_t fits in unsigned longPaul Eggert-2/+10
* src/group-list.c (print_group): Convert to intmax_t or uintmax_t, not to unsigned long.
2023-07-31dircolors,du,expr: prefer signed typesPaul Eggert-17/+16
* src/dircolors.c (dc_parse_stream): * src/du.c (max_depth, main): * src/expr.c (main): Prefer signed types.
2023-07-31od: prefer signed typesPaul Eggert-31/+26
* src/od.c: Include stdckdint.h. (bytes_to_oct_digits, bytes_to_signed_dec_digits) (bytes_to_unsigned_dec_digits, bytes_to_hex_digits): Use ‘char’ for these small constants. (simple_strtoi): Rename from simple_strtoul. Convert to int instead of unsigned long; that’s good enough. All uses changed. Simplify by using ckd_mul and ckd_add to check for overflow. (main): Prefer signed types to unsigned.
2023-07-31cksum,df,digest: prefer signed typesPaul Eggert-3/+3
* src/cksum.c (main): * src/df.c (decode_output_arg): * src/digest.c (valid_digits): Prefer idx_t to unsigned types when the value is an index into an array.
2023-07-31join: prefer signed typesPaul Eggert-61/+51
* src/join.c (struct outlist, struct field, struct line) (struct seq, autocount_1, autocount_2, join_field_1, join_field_2) (extract_field, keycmp, check_order, init_linep, free_spareline) (getseq, delseq, prfield, prfields, prjoin, join, add_field) (string_to_join_field, decode_field_spec, add_field_list) (set_join_field, main): Prefer signed integers to unsigned.
2023-07-31factor: prefer signed typesPaul Eggert-63/+60
When it’s easy, prefer signed types to unsigned, as they are less confusing and allow overflow checking. * src/factor.c (struct mp_factors, udiv_qrnnd) (count_leading_zeros, count_trailing_zeros) (factor_insert_multiplicity, mp_factor_clear, mp_factor_insert) (factor_insert_refind, factor_using_division) (mp_factor_using_division, powm2, millerrabin, millerrabin2) (mp_millerrabin, prime_p, prime2_p, mp_prime_p, isqrt, isqrt2) (invtab, q_freq, factor_using_squfof, strto2uintmax) (print_factors_single, main): Prefer signed integers to unsigned.
2023-07-31maint: include idx.h everywherePaul Eggert-5/+1
* src/system.h: Include idx.h here, instead of in every file that currently uses idx_t. This should make it easier to use idx_t in the future.
2023-07-31who: fix only-theoretical overflowPaul Eggert-2/+2
Change stzncpy’s implementation to match its comment, in the case where SRC + LEN would overflow. This case never happens in coreutils. * src/system.h (stzncpy): Work even if SRC + LEN would overflow.
2023-07-31tac: handle short reads on inputPádraig Brady-1/+2
This can be reproduced by getting the read() above 2G, which induces a short read, thus triggering the erroneous failure. $ truncate -s 5G 5G $ cat 5G | TMPDIR=$PWD tac | wc -c tac: /tmp/tacFt7txA: read error: Illegal seek 0 With the fix in place we now get: $ cat 5G | TMPDIR=$PWD src/tac | wc -c 5368709120 * src/tac.c (tac_seekable): Use full_read() to handle short reads. * NEWS: Mention the bug fix. Reported at https://bugs.debian.org/1042546
2023-07-31uptime: output correct user count on OpenBSDBruno Haible-7/+0
* src/uptime.c (print_uptime, uptime): Always call read_utmp and count the result. * NEWS: Mention the fix (text by Bruno Haible).
2023-07-22mv: better diagnostic for 'mv dir x' failurePaul Eggert-3/+17
Problem reported by Nir Oren <https://bugs.gnu.org/64785>. * src/copy.c (copy_internal): Use a more-specific diagnostic when a rename fails due to a problem that must be due to the destination, avoiding user confusion in cases like 'mv dir x' where x is a nonempty directory. * tests/mv/dir2dir.sh: Adjust to match.
2023-07-20doc: clarify tail -n/-c +NUM operationPádraig Brady-2/+5
tail -n/-c +NUM, is different from tail -n/-c NUM, and head -n/-c NUM, and head -n/c -NUM, in that it specifies a 1 based index rather than a count to skip/include. So clarify this in tail --help and tail info manual. Note we also mention this gotcha at: https://www.pixelbeat.org/docs/coreutils-gotchas.html#tail * doc/coreutils.texi (tail invocation): Give examples for -c/-n +NUM, to make it clear one has to specify a number 1 larger than might be expected. * src/tail.c (usage): State the skip at start edge case more clearly in the -n description. -c is not often used with tail so we leave full explanation of that to the info manual. Also split the string to simplify translation.
2023-07-18split: honor $TMPDIR for temp filesPádraig Brady-2/+4
* bootstrap.conf: Depend on tmpdir rather than tmpfile, as the standard tmpfile() doesn't honor $TMPDIR. * src/split.c (copy_to_tmpfile): Adjust to call temp_stream() rather than tmpfile(); * NEWS: Mention the improvement.
2023-07-18tac: fall back to /tmp if $TMPDIR is unavailablePádraig Brady-120/+175
This also refactors temp_stream() to its own module, in preparation for use by split. * src/tac.c: Refactor temp_stream() out to ... * src/temp-stream.c: ... A new module mostly refactored from tac, but uses tmpdir to more robustly support $TMPDIR, while falling back to /tmp if not available. * src/temp-stream.h: The new module interface. * src/local.mk: Reference the new module from tac. * tests/tac/tac.pl: Adjust to non failing missing $TMPDIR. * po/POTFILES.in: Reference the new module with translatable strings. * NEWS: Mention the user visible improvements to tac TMPDIR handling.
2023-07-17join: promptly diagnose write errorsPádraig Brady-0/+3
* src/join.c (prjoin): Check for write errors after each line. * tests/misc/write-errors.sh: enable the test for join. * NEWS: Mention the improvement.
2023-07-17comm: promptly diagnose write errorsPádraig Brady-9/+12
* src/comm.c (writeline): Simplify by removing the unneeded STREAM parameter. Call write_error() upon ferror(). (compare_files): Adjust to simplified writeline(). * tests/misc/write-errors.sh: Enable comm test. * NEWS: Mention the improvement.
2023-07-17cut: promptly diagnose write errorsPádraig Brady-10/+22
* src/cut.c (cut_bytes): Diagnose errors from fwrite() and putchar(). (cut_fields): Likewise. * tests/misc/write-errors.sh: Enable the test for cut, and augment to cover both cut_bytes() and cut_fields(). * NEWS: Mention the improvement.
2023-07-17uniq: promptly diagnose write errorsPádraig Brady-3/+6
* src/uniq.c (write_line): Check the output from fwrite() immediately. (check_file): Likewise. * tests/misc/write-errors.sh: Enable the test case. * NEWS: Mention the improvement.
2023-07-17od: promptly diagnose write errorsPádraig Brady-2/+6
* src/od.c (dump): Check for write errors after each block written, to exit early even with large / unbounded inputs. * tests/misc/write-errors.sh: enable od check. * NEWS: Mention the improvement. Fixes https://bugs.gnu.org/64540
2023-07-17all: avoid repeated diagnostic upon write errorPádraig Brady-46/+40
* cfg.mk (sc_some_programs_must_avoid_exit_failure): Adjust to avoid false positive. (sc_prohibit_exit_write_error): A new syntax check to prohibit open coding error(..., "write error"); instead directing to use... * src/system.h (write_error): ... a new function to clear stdout errors before we explicitly diagnose a write error and exit. * src/basenc.c: Use write_error() to ensure no repeated diagnostics. * src/cat.c: Likewise. * src/expand.c: Likewise. * src/factor.c: Likewise. * src/paste.c: Likewise. * src/seq.c: Likewise. * src/shuf.c: Likewise. * src/split.c: Likewise. * src/tail.c: Likewise. * src/tr.c: Likewise. * src/unexpand.c: Likewise. * tests/misc/write-errors.sh: Remove TODOs for the fixed utilities: expand, factor, paste, shuf, tr, unexpand.
2023-07-13cksum: improve problematic_chars functionJim Meyering-1/+2
* src/digest.c (problematic_chars): Implement using strcspn, and traversing S only once, rather than once per escaped byte.
2023-07-12maint: give a new function the "pure" attributePádraig Brady-0/+1
* src/digest.c (problematic_chars): This recently introduced function does not modify state so is pure, even though GCC 13.1 at least did not warn about that attribute being appropriate.
2023-07-11cksum: escape filenames with a leading '\' in --check statusPádraig Brady-9/+14
* src/digest.c (digest_check): Also escape in the case that the file name contains '\'. * tests/cksum/md5sum-bsd.sh: Add a test case. * doc/coreutils.texi (md5um invocation): Clarify escaping operation. * NEWS: Mention the bug fix. Fixes https://bugs.gnu.org/64392
2023-07-09cksum: support transparent emulation of older utilsPádraig Brady-18/+10
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.