summaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)AuthorLines
2022-01-07df: tiny simplificationPaul Eggert-4/+1
* src/df.c (LOG_EQ): Remove. All callers replaced by ==.
2022-01-02maint: update all copyright year number rangesPádraig Brady-139/+139
Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2021-12-31date: new option --resolutionPaul Eggert-11/+29
* NEWS, doc/coreutils.texi (Options for date): Mention this. * src/date.c (RESOLUTION_OPTION): New constant. (DEBUG_DATE_PARSING_OPTION): Rename from DEBUG_DATE_PARSING. All uses changed. (long_options, usage, main): Support --resolution.
2021-12-31date: %-N now means suppress extra digitsPaul Eggert-2/+38
* NEWS, doc/coreutils.texi: Mention this. * bootstrap.conf (gnulib_modules): Add gettime-res. * src/date.c (res_width, adjust_resolution): New functions. (main): Adjust %-N to be %9N, or whatever, before using it.
2021-12-31build: port to AIX 7.1Paul Eggert-3/+8
This fixes a porting bug introduced in 2019-08-12T03:29:00Z!bruno@clisp.org. Problem discovered on AIX 7.1. * src/local.mk (LDADD): Add $(LIB_MBRTOWC), since pretty much every command uses quotearg or mbrtowc or whatever. (src_sort_LDADD): Add $(LIBPMULTITHREAD) and $(LIB_PTHREAD_SIGMASK) instead of $(LIBTHREAD).
2021-12-27all: fix adjustment of /proc/$pid/cmdline by single binaryMax Filippov-2/+3
When configured with --enable-single-binary tools issue incorrect prctl: prctl(PR_SET_KEEPCAPS, ...) = -1 EINVAL (Invalid argument) PR_SET_MM_ARG_START is not a prctl 'option' parameter, it's 'arg2' parameter for the option PR_SET_MM. It also has to have 'arg4' and 'arg5' set to 0 explicitly, otherwise the kernel also returns -EINVAL. * src/coreutils.c (launch_program): Fix prctl arguments. * NEWS: Mention the improvement. Fixes https://bugs.gnu.org/52800
2021-12-24ls: improve doc for =WHENPaul Eggert-9/+7
* src/ls.c (usage): Improve clarity of =WHEN args (Bug#52782).
2021-12-24doc: colorize -> colorPaul Eggert-5/+5
Living so close to Hollywood I know that "colorize" means adding color to something that was already monochrome, whereas "color" means to give color to something. Coreutils apps color text instead of colorizing it.
2021-12-20maint: syntax-check requires "char const *", not "const char *"Jim Meyering-10/+10
* gl/lib/mbsalign.c (mbs_align_pad): Adjust. * src/chroot.c (is_root): Adjust. * src/digest.c (main): Adjust. * src/relpath.c (buffer_or_output) Adjust. * src/ls.c (print_name_with_quoting, get_color_indicator): Adjust.
2021-12-20maint: split a long lineJim Meyering-1/+2
* src/test.c (three_arguments): Split long line.
2021-12-19id: improve doc for when USER is omittedPaul Eggert-1/+1
* src/id.c (usage): “current user” → “current process” (Bug#52656).
2021-12-18maint: use GNU style for spacingPaul Eggert-88/+88
2021-12-14maint: factor.c: avoid new GCC 12 warningJim Meyering-1/+1
* src/factor.c (millerrabin2): Mark as ATTRIBUTE_PURE, per advice from GCC 12.
2021-12-07uname: port to recent macOSPaul Eggert-36/+39
Problem reported by Jakub Sokołowski (bug #52330). * src/uname.c [__APPLE__]: Don’t include sys/syctl.h, mach/machine.h, mach-o/arch.h. (print_element_env): New function. With __APPLE__, it defers to the env var UNAME_MACHINE (if given) for uname -m, and similarly for -nrsv. (main): Use it. For -p with __APPLE__, rely on predefined macros and omit any 64-bit indication, for compatibility with macOS uname.
2021-11-21cp: clone on macOSPaul Eggert-0/+12
* configure.ac: Check for fclonefileat. * src/copy.c [HAVE_FCLONEFILEAT && !USE_XATTR]: Include <sys/clonefile.h>. (copy_reg): If possible, use fclonefileat to clone.
2021-11-21cp: streamline cloning by skipping fstatPaul Eggert-19/+18
* src/copy.c (copy_reg): Attempt clone_file before fstat of dest, so that if clone_file succeeds we can skip the fstat.
2021-11-20cp: fix --preserve=ownership permissions bugPaul Eggert-23/+31
This fixes a bug that I introduced in 2006-12-06T19:44:08Z!eggert@cs.ucla.edu. * src/copy.c (USE_XATTR): New macro. (copy_reg): Use it to help the compiler. Prefer open u+w to a later chmod u=rw; u+r isn’t needed for xattr. For the later u-r, do only one (or zero) chmod calls instead of two (or one). In the last chmod, respect the umask instead of ignoring it. * tests/cp/preserve-mode.sh: Test for the bug.
2021-11-18maint: prefer MAYBE_UNUSEDPaul Eggert-48/+51
Prefer MAYBE_UNUSED to _GL_UNUSED, since the C2x syntax will be [[maybe_unused]] at the start of the declaration, and we want to look forward to that. All uses of _GL_UNUSED either changed to MAYBE_UNUSED, or (when not needed) removed.
2021-11-18cp: fix security context racePaul Eggert-29/+21
This fixes an issue introduced in the fix for Bug#11100. * NEWS: Mention this. * src/copy.c (copy_reg): Fix obscure bug where open-without-CREAT failed with ENOENT and we forget to call set_process_security_ctx before calling open-with-CREAT. Also, don’t bother to unlink DST_NAME if open failed with ENOENT; and if unlink fails with ENOENT, don’t consider that to be an error (someone else could have removed the file for us, and that’s OK). Also, don’t worry about move mode, since we use O_EXCL|O_CREAT and so won’t open an existing file.
2021-11-16cp: minor clarity tweakPaul Eggert-1/+1
* src/copy.c (copy_reg): Use cached data_copy_required.
2021-11-16cp: fix ptrdiff_t/ssize_t theoretical glitchesPaul Eggert-3/+2
* src/copy.c (sparse_copy): Use system.h’s SSIZE_MAX. Don’t assume SSIZE_MAX <= PTRDIFF_MAX.
2021-11-01maint: fix recent syntax-check failuresPádraig Brady-3/+1
* cfg.mk (exclude_file_name_regexp--sc_system_h_headers): Add chown-core.h to the regexp, to better decouple from system.h. * src/env.c: Remove minmax.h include already included in system.h. * src/libstdbuf.c: Likewise. * src/prog-fprintf.h: Remove doubled semicolon.
2021-10-31maint: use minmax.h instead of rolling our ownPaul Eggert-9/+1
* gl/lib/mbsalign.c, gl/lib/randread.c, src/system.h (MAX, MIN): Remove; include minmax.h instead. * gl/modules/mbsalign, gl/modules/randread (Depends-on): Add minmax. * src/factor.c (MIN): Remove.
2021-10-31maint: add function attributes to .h filesPaul Eggert-25/+42
Add _GL_ATTRIBUTE_NONNULL, _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DALLOC_FREE, _GL_ATTRIBUTE_RETURNS_NONNULL to .h files when appropriate. * gl/lib/mbsalign.h, gl/lib/randperm.h, src/chown-core.h: Include stdlib.h, for the benefit of _GL_ATTRIBUTE_DALLOC_FREE. * gl/lib/randread.c (randread_free_body): New static function. (randread_new, randread_free): Use it. * src/copy.c (valid_options): Remove assert that is no longer needed because it is now checked statically.
2021-10-31maint: enable -Wsuggest-attribute=formatPaul Eggert-21/+30
* configure.ac (WERROR_CFLAGS): Enable -Wsuggest-attribute=format for lib/ and src/. * src/copy.c (copy_attr_error, copy_attr_allerror): Add ATTRIBUTE_FORMAT. (copy_attr): Ignore -Wsuggest-attribute=format in the small section of code that needs it ignored. * src/test.c (test_syntax_error): Mark with ATTRIBUTE_FORMAT. (binary_operator): Omit unnecessary NULL args, pacifying -Wsuggest-attribute=format.
2021-10-31maint: modernize attribute usagePaul Eggert-30/+26
* src/system.h (__attribute__): Remove. Replace all uses that rely on this by _GL_ATTRIBUTE_xxx or ATTRIBUTE_xxx. (ATTRIBUTE_WARN_UNUSED_RESULT): Remove. Replace all uses by NODISCARD.
2021-10-31b2sum: simplify attribute usagePaul Eggert-11/+5
* src/blake2/blake2.h (BLAKE2_PACKED): Simplify, and port better to older GCC, by using _GL_ATTRIBUTE_PACKED.
2021-10-31maint: prefer attribute.h in .c filesPaul Eggert-67/+119
This will help us make the transition to C2x, where some attributes must come at the start of function decls. Leave the attributes alone in .h files for now, as the Gnulib tradition is to not expose attribute.h to users. * bootstrap.conf (gnulib_modules): Add ‘attribute’. * gl/lib/randperm.c, src/make-prime-list.c, src/system.h: Include attribute.h. * gl/lib/strnumcmp.c (strnumcmp): Remove _GL_ATTRIBUTE_PURE here, as this belongs in the .h file. * gl/lib/strnumcmp.h (strnumcmp): Add _GL_ATTRIBUTE_PURE here. * src/sort.c (human_numcompare, numcompare): Now ATTRIBUTE_PURE; discovered due to strnumcmp.h change. * gl/lib/randperm.c, src/copy.c, src/dd.c, src/df.c, src/digest.c: * src/env.c, src/expr.c, src/factor.c, src/ls.c: * src/make-prime-list.c, src/numfmt.c, src/od.c, src/pathchk.c: * src/pinky.c, src/pr.c, src/ptx.c, src/realpath.c, src/relpath.c: * src/seq.c, src/sort.c, src/stat.c, src/stty.c, src/system.h: * src/tr.c, src/uniq.c, src/wc.c: In .c files, crefer ATTRIBUTE_CONST to _GL_ATTRIBUTE_CONST, and similarly for ATTRIBUTE_FORMAT and ATTRIBUTE_PURE. * src/system.h (FALLTHROUGH): Remove; attribute.h defines it.
2021-10-31sort: --debug: add warnings about sign, radix, and grouping charsPádraig Brady-2/+87
New warnings are added related to the handling of thousands grouping characters, decimal points, and sign characters. Examples now diagnosed are: $ printf '0,9\n1,a\n' | sort -nk1 --debug -t, -s sort: key 1 is numeric and spans multiple fields sort: field separator ‘,’ is treated as a group separator in numbers 1,a _ 0,9 ___ $ printf '1,a\n0,9\n' | LC_ALL=fr_FR.utf8 sort -gk1 --debug -t, -s sort: key 1 is numeric and spans multiple fields sort: field separator ‘,’ is treated as a decimal point in numbers 0,9 ___ 1,a __ $ printf '1.0\n0.9\n' | LC_ALL=fr_FR.utf8 sort -s -k1,1g --debug sort: note numbers use ‘,’ as a decimal point in this locale 0.9 _ 1.0 _ $ LC_ALL=fr_FR.utf8 sort -n --debug /dev/null sort: text ordering performed using ‘fr_FR.utf8’ sorting rules sort: note numbers use ‘,’ as a decimal point in this locale sort: the multi-byte number group separator in this locale \ is not supported $ sort --debug -t- -k1n /dev/null sort: key 1 is numeric and spans multiple fields sort: field separator ‘-’ is treated as a minus sign in numbers sort: note numbers use ‘.’ as a decimal point in this locale $ sort --debug -t+ -k1g /dev/null sort: key 1 is numeric and spans multiple fields sort: field separator ‘+’ is treated as a plus sign in numbers sort: note numbers use ‘.’ as a decimal point in this locale * src/sort.c (key_warnings): Add the warnings above. * tests/misc/sort-debug-warn.sh: Add test cases. Also check that all sort invocations succeed. * NEWS: Mention the improvement. Addresses https://bugs.gnu.org/51011
2021-10-30cp: revert unnecessary FreeBSD workaroundPaul Eggert-4/+3
That was a false alarm due to a bug in FreeBSD 9.1 truss; see Pádraig Brady’s report (Bug#51433#29). * src/copy.c (lseek_copy, infer_scantype): Don’t bother checking whether lseek returned -1. This doesn’t entirely revert the previous change, as it keeps the code simplification of the previous change while reverting the check for -1.
2021-10-29cp: defend better against FreeBSD 9.1 zfs bugPaul Eggert-9/+6
Problem reported by Pádraig Brady (Bug#51433#14). * src/copy.c (lseek_copy, infer_scantype): Report an error if lseek with SEEK_DATA or SEEK_HOLE returns less than -1, as this is an lseek bug.
2021-10-22doc: say that printf(1) is preferred over echo(1)Pádraig Brady-0/+4
* src/echo.c (usage): Say printf(1) is preferred due to being more standard and robust. * man/echo.x [SEE ALSO]: Reference printf(1). * doc/coreutils.texi (echo invocation): Mention in the summary that echo is not robust when outputting any string, and that printf is preferred. Also expand on the examples showing how to output a single '-n' string. Addresses https://bugs.gnu.org/51311
2021-10-12timeout: ensure --foreground -k exits with status 137Pádraig Brady-0/+5
* src/timeout.c (main): Propagate the killed status from the child. * doc/coreutils.texi (timeout invocation): Remove the description of the --foreground specific handling of SIGKILL, now that it's consistent with the default mode of operation. * tests/misc/timeout.sh: Add a test case. * NEWS: Mention the change in behavior. Fixes https://bugs.gnu.org/51135
2021-10-10sort: fix unlikely bug when '\377' < 0Paul Eggert-10/+13
* gl/lib/strintcmp.c (strintcmp): Don’t assume that the input cannot contain ((char) -1), as this equals '\377' when char is signed (assuming 8-bit char). * src/sort.c (decimal_point): Now char, to make it clear that it’s always in char range now. (NON_CHAR): New constant. (traverse_raw_number): Return char not unsigned char; this is simpler and could be faster. All callers changed. (main): Do not convert decimal_point and thousands_sep to unsigned char, as this can mishandle comparisons on machines where char is signed and the input data contains ((char) -1). Use NON_CHAR, not -1, as an out-of-range value for thousands_sep.
2021-10-02maint: switch to C11-style _NoreturnPaul Eggert-25/+9
Use C11-style _Noreturn instead of the old ATTRIBUTE_NORETURN macro. This pacifies clang on OpenBSD 6.9, which otherwise complains "'noreturn' function does return" in some places. * gl/lib/randread.c, src/system.h (ATTRIBUTE_NORETURN): Remove. All uses either removed as GCC no longer needs them, or changed to C11-style _Noreturn since Gnulib arranges for _Noreturn globally nowadays.
2021-10-02ls: port to OpenBSDPaul Eggert-2/+2
Problem reported by Brian Callahan (Bug#50972). * src/ls.c (decode_switches): Don’t assume __GNUC_PREREQ.
2021-09-24chmod: fix exit status when ignoring symlinksPádraig Brady-2/+2
* src/chmod.c: Reorder enum so CH_NOT_APPLIED can be treated as a non error. * tests/chmod/ignore-symlink.sh: A new test. * tests/local.mk: Reference the new test. * NEWS: Mention the bug fix. Fixes https://bugs.gnu.org/50784
2021-09-24cksum: fix -a crc on 64 bit big endian systemsPádraig Brady-1/+2
* src/cksum.c (crc_sum_stream): On sparc64 for example, a crc of 0 was printed due to mismatch in size of variable copied between generator and output functions. uint_fast32_t is generally 64 bits on 64 bit systems, so we copy through an int to ensure we don't use the wrong end of a 64 bit variable. Reported by Nelson H. F. Beebe
2021-09-21tail: fix detection of closed stdout on macOSPádraig Brady-1/+24
* bootstrap.conf: We only need poll on Linux and AIX where poll is not replaced. Also resinstate dependence on select so we can use it unconditionally. * src/tail.c (check_output_alive): Reinstate use of select() by default as poll was seen to be ineffective for this application on macOS. Fixes https://bugs.gnu.org/50714
2021-09-21maint: clean up c++ style commentsPádraig Brady-11/+2
* src/expand-common.h: Remove commented variables. * src/remove.h: Change to C style comment. * src/tail.c: Likewise.
2021-09-20doc: drop extraneous single quotes in helpJim Meyering-15/+15
* src/digest.c (usage) [cksum --help]: Drop single quotes around each checksum name. * src/tee.c (usage) [tee --help]: Likewise.
2021-09-20cksum: list Pádraig as coauthorJim Meyering-1/+3
* src/digest.c (AUTHORS) [HASH_ALGO_CKSUM]: Add Pádraig as cksum coauthor. * AUTHORS: Likewise.
2021-09-20doc: fix --help formatting for checksum utilsPádraig Brady-19/+22
* src/digest.c (usage): Indicate that --length and --algorithm require arguments. Emit corresponding emit_mandatory_arg_note(). Use consistent alignment.
2021-09-20cksum: support more transparent emulation of older utilsPádraig Brady-11/+6
* src/digest.c: Allow using the --untagged option with --check, so that `cksum -a md5 --untagged` used to emulate md5sum for example, may be augmented with the --check option. Also support the --tag option with cksum, to allow overriding a previous --untagged setting. * doc/coreutils.texi: Adjust accordingly. * tests/misc/cksum-a.sh: Likewise.
2021-09-16rmdir: fix uninitialized memory causing incorrect errorPádraig Brady-1/+2
* src/rmdir.c (main): Only inspect the returned stat structure, when stat(2) returns success.
2021-09-16build: avoid new chmod.c warnings from upcoming GCC12Jim Meyering-1/+1
Here are the warnings: src/chmod.c:175:3: error: 'ch.new_mode' may be used uninitialized in\ this function [-Werror=maybe-uninitialized] 175 | strmode (ch->new_mode, perms); src/chmod.c:178:3: error: 'ch.old_mode' may be used uninitialized in\ this function [-Werror=maybe-uninitialized] 178 | strmode (ch->old_mode, old_perms); * src/chmod.c (process_file): Initialize ch. Its new_mode and old_mode fields could indeed be used uninitialized to form mode strings, but those are used only when built from initialized members.
2021-09-16digest: ignore empty lines when checkingPádraig Brady-0/+5
* src/digest.c (digest_check): Treat empty lines like comments, as commented checksum files very often have empty lines. * tests/misc/md5sum.pl: Adjust accordingly.
2021-09-16factor: sync longlong.h adjustments from upstreamPádraig Brady-31/+28
* src/longlong.h: Sync changes from: https://gmplib.org/repo/gmp/log/tip/longlong.h
2021-09-16stat,tail: add support for the secretmem file systemPádraig Brady-0/+2
* src/stat.c (human_fstype): Add case for the 'secretmem' file system type. * NEWS: Mention the Improvement.
2021-09-16cksum: fix --check with non tagged format checksumsPádraig Brady-1/+1
* 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.