Compare commits

...

260 Commits
v8.29 ... v8.32

Author SHA1 Message Date
Pádraig Brady
8d13292a73 version 8.32
* NEWS: Record release date.
2020-03-05 13:23:50 +00:00
Pádraig Brady
c8539d36c7 tests: don't rely on system env(1) being present
* tests/misc/env-S.pl: `env -i env` will call the system env
due to the path being cleared, so pass the absolute path
of our env binary under test to avoid that.  This was seen
to be an issue on Guix where /usr/bin/env was not available.
2020-03-04 18:00:38 +00:00
Pádraig Brady
0ea65e29dc basenc: avoid undefined behaviour in z85 processing
* src/basenc.c (z85_decode_ctx_init): Ensure we're working
with unsigned, as otherwise ubsan triggers with:
  src/basenc.c:767:18: runtime error: signed integer overflow:
  43 * 52200625 cannot be represented in type 'int'
(z85_encode): Likewise to avoid the usban error:
  src/basenc.c:630:26: runtime error:
  left shift of 134 by 24 places cannot be represented in type 'int'
2020-03-04 12:38:27 +00:00
Pádraig Brady
f2034aa9bb tests: avoid a false failure on OpenIndiana 11
* tests/misc/timeout-parameters.sh: Split the large timeout
handling to ...
* tests/misc/timeout-large-parameters.sh: ... here, so that
the 3 second delay is contained in its own test, and if
the test is skipped due invalid handling within timeout(1),
it will be more apparent.
Also adjust the check so we skip whenever the kernel timer
fires immediately, to handle the buggy OpenIndiana 11 kernel also.
Reported by Bruno Haible.
2020-03-01 23:36:05 +00:00
Pádraig Brady
ab305f746e tests: avoid a hang on GNU/Hurd from 2019
* tests/du/8gb.sh: Add a timeout around:
`dd bs=1 seek=8G of=big < /dev/null`
2020-03-01 22:04:20 +00:00
Pádraig Brady
04e2b9b1a6 tests: use bash in some scripts to avoid false failures
* init.cfg (require_bash_as_SHELL_): A new function to replace
SHELL for the current test, with bash if available.
This is useful on OpenIndiana 11 where /bin/sh was seen
to have races in handling of SIGPIPE.
* tests/misc/seq-epipe.sh: Use the new function to enforce bash.
* tests/misc/env-signal-handler.sh: Likewise.
Reported by Bruno Haible
2020-03-01 22:02:39 +00:00
Pádraig Brady
5cdab9f26b tests: improve test coverage for ls stat checks
* tests/ls/stat-free-color.sh: Check for the availability
of various stat calls individually, and add statx() and fstatat64()
to the list to check.  Fix the stat counting logic to
ignore lines like "+++ exited with 0 +++".
* tests/ls/stat-free-symlinks.sh: Check syscalls other than stat().
2020-03-01 13:06:01 +00:00
Bruno Haible
e840c78685 tests: enable 4 more tests to be executed on FreeBSD
* init.cfg (gcc_shared_libs_): New variable.
(gcc_shared_): Use it, instead of hardcoding -ldl.
(require_gcc_shared_): Determine the suitable value
for gcc_shared_libs_.
2020-03-01 10:56:12 +00:00
Pádraig Brady
ea1c1b7515 tests: fix incorrect || fail pattern in tests
* tests/ls/stat-free-symlinks.sh: s/|| fail/|| fail=1/.
* tests/misc/tee.sh: Likewise.
* tests/touch/relative.sh: Likewise.
* cfg.mk (sc_prohibit_or_fail): A new syntax-check to avoid this.
2020-02-29 22:45:00 +00:00
Pádraig Brady
de73a867ca tests: avoid false failures on darwin 19.2.0
With these adjustments, all tests pass on macOS Catalina.

* tests/dd/sparse.sh: Adjust so that systems like apfs that
don't create holes < 16 MiB do not fail erroneously.
* tests/touch/trailing-slash.sh: Darwin was seen to dereference
symlinks to files when given a trailing slash, so avoid
that particular case.
2020-02-29 22:45:00 +00:00
Bruno Haible
54bf2c2f1a tests: fix test failure on FreeBSD 12
* tests/misc/csplit-io-err.sh: Limit the effect of the fwrite
override to streams != stderr, as fwrite is in the error() path there.
2020-02-29 22:39:47 +00:00
Jan Nieuwenhuizen
516cdf38af build: once again distribute .tar.gz files
* configure.ac: Reenable distribution of gzip-compressed
tarballs, for Guix bootstrapping reasons as discussed at:
https://lists.gnu.org/r/coreutils/2020-02/msg00042.html
* THANKS.in: Remove me, as now a committer.
* NEWS (Build-related): Mention this.
2020-02-27 21:55:57 +00:00
Pádraig Brady
cc4c55e4bc maint: ensure .deps/ in the project root is ignored by git
* .gitignore: s|*/.deps/|.deps|
2020-02-27 16:44:03 +00:00
Pádraig Brady
8de80feb51 doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.23 which is now about 5 years old.
2020-02-27 16:11:42 +00:00
Colin Watson
05a99f7d7f ls: issue error message on removed directory
If the current directory has been removed, then "ls" confusingly
produced no output and no error message, indistinguishable from
running on an empty directory.

* src/ls.c (print_dir): Report ENOENT on GNU/Linux if readdir
finds no directory entries at all, not even "." or "..",
and a recheck with the getdents syscall returns ENOENT.
We recheck with getdents() as POSIX states that
"The directory entries for dot and dot-dot are optional".
* tests/ls/removed-directory.sh: New file.
* tests/local.mk (all_tests): Add new test.
* NEWS: Mention the change in behavior.
Reported by Owen Thomas.
2020-02-27 14:11:37 +00:00
Pádraig Brady
93db70867d build: update to latest gnulib
* bootstrap.conf: Adjust for changes to fchmodat and fchownat,
which are now separated from chmodat and chownat respectively.
2020-02-25 14:26:39 +00:00
Pádraig Brady
ead8464e3a b2sum: sync better with upstream
* src/blake2/blake2-impl.h: Sync load16() implementation,
which doesn't change code generation.
Also leverage (builtin) memcpy to more efficiently
move data on little endian systems,
giving a 2% win with GCC 9.2.1 on an i3-2310M.
2020-02-25 13:51:21 +00:00
Pádraig Brady
9134993562 factor: sync longlong.h adjustments from upstream
* src/longlong.h: Sync changes from:
https://gmplib.org/repo/gmp/log/tip/longlong.h
mips64: Provide r6 asm code as default expression yields.
arm32: Define sub_ddmmss separately for non-thumb (no rsc instruction).
powerpc: Add "CLOBBER" descriptions for some registers.
x86: Fix criterion for when to use mulx in umul_ppmm.
2020-02-25 11:55:38 +00:00
Pádraig Brady
75f79010cd stat,tail: sync file system constants from the linux kernel
* src/stat.c: Add magic constants for "binderfs", "dma-buf-fs",
"erofs", "ppc-cmm-fs", and "z3fold".
* NEWS: Mention the improvement.
2020-02-25 00:03:40 +00:00
Pádraig Brady
8e81d44b52 uniq: avoid strcoll() to improve performance and consistency
strcoll() is only significant to uniq(1) if it returns 0,
and it generally only does so with buggy locales or mismatched
locales and data.  Some systems may have strcoll()
return 0 for equivalent normalized unicode forms,
but for consistency across platforms strcoll() is avoided.
The various cases are defined in the new test.
This is consistent with newer POSIX standards as discussed at:
https://www.austingroupbugs.net/view.php?id=963

* src/uniq.c: s/xstrcoll/memcmp/.
* tests/local.mk: Reference the new test.
* tests/misc/uniq-collate.sh: Add a new test.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/38627
2020-02-24 10:12:42 +00:00
Pádraig Brady
61c49d3693 doc: clarify that '%a' stat format outputs mode bits
* src/stat.c (usage): Mention permission bits rather than
"access" so there is no confusion with ACLs etc.
Also indicate we output the file type with '%A'.
* doc/coreutils.texi (stat invocation): Likewise.
Also indicate '%A' is similar to `ls -ld` output.
Addresses https://bugs.gnu.org/39613
2020-02-15 11:24:15 +00:00
Pádraig Brady
3150f4a82e tests: fix test for symlink
* tests/cp/preserve-gid.sh: s/-l/-L/.
Reported by Kamil Dudka
2020-02-10 15:06:21 +00:00
Kamil Dudka
b96b1a4728 tests: ensure tests/cp/preserve-gid.sh works with single binary
* tests/cp/preserve-gid.sh: If configured with --enable-single-binary
copy the coreutils single binary, instead of the cp one-line launcher.

Discussed at https://bugzilla.redhat.com/1800597
Fixes https://bugs.gnu.org/39485
2020-02-09 14:19:35 +00:00
Pádraig Brady
304bc557af maint: avoid syntax-check failure in previous commit
* configure.ac: Restrict lines to 80 chars.
2020-02-09 14:19:35 +00:00
Jim Meyering
d7da53c47e build: suppress new FP warning from gcc-10.0.1
* configure.ac (GNULIB_WARN_CFLAGS): Add -Wno-return-local-addr
to avoid FP warning about careadlinkat.c. Discussed starting in
https://lists.gnu.org/r/coreutils/2020-02/msg00006.html
2020-02-08 17:52:48 -08:00
Pádraig Brady
fa6d154b7b build: update to latest gnulib
Pick up recent build fixes to avoid sysctl.h inclusion on glibc systems,
restrict the max file size supported by read-file to PTRDIFF_MAX,
and to avoid a -Werror=unused failure in test-canonicalize.
2020-02-04 19:12:33 +00:00
Pádraig Brady
ab108667ba tests: avoid false failure due to varying /proc/kallsyms
* tests/cp/proc-short-read.sh: Switch to using /proc/cpuinfo,
rather than /proc/kallsyms which was seen to vary in some cases.
Fixes https://bugs.gnu.org/39357
2020-02-04 19:11:37 +00:00
Pádraig Brady
1f443fe572 rmdir: fix --ignore-fail-on-non-empty with permissions errors
Since v6.10-21-ged5c4e7 `rmdir --ignore-fail-on-non-empty`
had reversed the failure status for directories that failed
to be removed for permissions reasons.  I.E. it would have
returned a failure status for such non empty dirs, and vice versa.

* src/rmdir.c (errno_may_be_non_empty): Rename from the
more confusing errno_may_be_empty(), and remove the EEXIST
case (specific to Solaris), which is moot here since
handled in errno_rmdir_non_empty().
(ignorable_failure): Fix the logic error so that
_non_ empty dirs are deemed to have ignorable failures.
(main): Fix clobbering of errno by is_empty_dir().
(remove_parents): Likewise.
* tests/rmdir/ignore.sh: Add a test case.
* THANKS.in: Add reporter who fixed the errno handling.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/39364
2020-02-04 19:11:37 +00:00
Pádraig Brady
709b4d9d8d build: avoid vector performance warnings in randperm
* configure.ac: Add -Wno-vector-operation-performance to suppress the
following gcc-9.2 error in gl/lib/randperm.c:
  error: vector operation will be expanded piecewise
2020-02-03 19:38:02 +00:00
Pádraig Brady
18c9382801 build: avoid including sysctl.h on glibc
* src/uname.c: Avoid unneeded header with GLIBC,
which has been deprecated since glibc-2.30.
* src/uptime.c: Likewise.
2020-02-03 19:38:02 +00:00
Pádraig Brady
2cecc3cc99 ls: support --time=creation to show/sort birth time
* src/ls.c (usage): Reorganize help for --time,
and add description for --time=birth.
(do_statx): Store btime in mtime if available.
(get_stat_btime): A new function to read the creation time
from the appropriate stat structure member.
(cmp_btime): A new function to compare birth time.
(print_long_format): Output '?' when birth time unavailable.
* doc/coreutils.texi: Document --time={birth,creation}.
* tests/local.mk: Reference the new test.
* tests/ls/birthtime.sh: Add a new test.
* NEWS: Mention the new feature.
2020-02-03 19:37:56 +00:00
Chris Meyering
dda53d75a8 build: rearrange yes(1) code to prevent GCC 10 warning
* src/yes.c (main): Convert for loop to do-while in order to indicate
that the loop will be run at least once.
This avoids the following warning after the second loop:
src/yes.c:110:20: error: writing 1 byte into a region of size 0
2020-01-30 18:38:18 +00:00
Emil Engler
fbbf81ec00 maint: add lib/iconv_open-zos.h to .gitignore
* .gitignore: Add file newly generated by gnulib commit 49e78fc
2020-01-01 23:59:40 +00:00
Pádraig Brady
0d77e1b7ea build: auto enable use of openssl with >= version 3
* configure.ac: Set --with-openssl=auto-gpl-compat as the default,
so that openssl is used for md5sum etc., with openssl >= 3,
which is newly licensed under ASL v2.
* gnulib: Update to include "auto-gpl-compat" support.
2020-01-01 22:14:45 +00:00
Pádraig Brady
ff2f85273a maint: adjust to split out xstrtol-error gnulib module
* bootstrap.conf: Depend on the new module split from xstrtol.
* src/df.c: Include "xstrtol-error.h" for xstrtol_fatal.
* src/du.c: Likewise.
* src/ls.c: Likewise.
* src/od.c: Likewise.
* src/pr.c: Likewise.
* src/sort.c: Likewise.
2020-01-01 14:36:12 +00:00
Pádraig Brady
aaba82431c maint: update all copyright year number ranges
Run "make update-copyright" and then...

* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
2020-01-01 14:16:56 +00:00
Bernhard Voelker
7490e94aa7 doc: add example to demonstrate sub-second sleep times
* doc/coreutils.texi (sleep invocation): Add an example to demonstrate
how to use the floating-point and the scientific notation to sleep
for sub-second times, e.g. milli-, micro- and nanoseconds.

Inspired by Stephane Chazelas in:
  https://lists.gnu.org/r/coreutils/2019-12/msg00005.html
2019-12-08 17:44:37 +01:00
Pádraig Brady
ec5ab42604 maint: fix syntax-check failure from recent adjustment
* cfg.mk (old_NEWS_hash): Regenerate after commit v8.31-56-gc1e1965.
2019-12-02 16:21:08 +00:00
Kamil Dudka
5118a2e392 chcon: do not validate security context if SELinux is disabled
* src/chcon.c (main): Skip call of security_check_context()
in case SELinux is disabled to avoid unnecessary failure.

Bug: https://bugzilla.redhat.com/1777831
2019-12-02 16:21:05 +00:00
Paul Eggert
ad591a52b4 doc: remove colon from node name
* doc/sort-version.texi (Minus/Hyphen and Colon characters):
Rename from “Minus/Hyphen @samp{-} and Colon @samp{:} characters”,
as texi2any 6.6 complains about colons in node names.
2019-11-11 16:54:19 -08:00
Paul Eggert
0103fb0244 shred: modernize documentation
* doc/coreutils.texi (shred invocation):
Modernize discussion to today’s technology (Bug#38168).
* src/shred.c (usage): Omit lengthy duplication of the manual’s
discussion of file systems and storage devices, as that became out
of sync with the manual.  Instead, just cite the manual.
2019-11-11 16:54:19 -08:00
Paul Eggert
04b136e298 all: improve parsing of numeric arguments
This addresses a longstanding "update all callers" FIXME in
lib/xstrtol.c, by having programs check that numbers do not
have unknown suffixes.  The problem was also reported for
'shuf' by my student Maggie Huang while reimplementing a shuf
subset in Python as an exercise in UCLA Computer Science 35L:
https://web.cs.ucla.edu/classes/fall19/cs35L/assign/assign3.html
This patch also improves the portability of the code to unusual
platforms where ULONG_MAX < SIZE_MAX.
* NEWS: Mention user-visible changes.
* src/chgrp.c (parse_group):
* src/chroot.c (parse_additional_groups):
* src/du.c (main):
* src/install.c (get_ids):
* src/join.c (string_to_join_field):
* src/ls.c (decode_switches):
* src/md5sum.c (split_3):
* src/shuf.c (main):
* src/sort.c (specify_nthreads):
* src/uniq.c (size_opt, main):
Use uintmax_t instead of unsigned long, for portability
to oddball platforms where unsigned long is not wide enough.
* src/du.c (main):
* src/expr.c (mpz_init_set_str) [!HAVE_GMP]:
* src/install.c (get_ids):
* src/ls.c (decode_switches):
* src/mknod.c (main):
* src/ptx.c (main):
* src/shuf.c (main):
* src/sort.c (specify_nmerge, specify_nthreads):
Reject numbers with suffixes.
* src/md5sum.c (split_3): Simplify.
2019-10-22 15:04:43 -07:00
Paul Eggert
ed2db6886b stdbuf: improve size checking
* bootstrap.conf (gnulib_modules): Add minmax.
* src/libstdbuf.c: Include stdint.h, minmax.h.
(apply_mode): Don’t assume SIZE_MAX <= ULONG_MAX.
Improve checking for invalid sizes.
2019-10-22 15:04:43 -07:00
Paul Eggert
74163ea677 shuf: improve randperm overflow checking
* gl/lib/randperm.c: Include randperm.h first, since it’s the API.
Include stdint.h, count-leading-zeros.h, verify.h.
(floor_lg): Rename from ceil_log (which was not actually
implementing the ceiling!) and implement the floor using
count_leading_zeros.
(randperm_bound): Use floor_lg, not ceil_log.  Use uintmax_t
instead of size_t in case the size gets large on a 32-bit host.
* gl/modules/randperm (Depends-on): Add count-leading-zeros, stdint.
2019-10-22 15:04:43 -07:00
Paul Eggert
565dd395c3 build: don’t worry about logical-op checking
* configure.ac: Remove code tailoring --enable-gcc-warnings
to GCC 4.7 and earlier, as developers no longer need to worry
about GCCs that old.
2019-10-22 15:04:43 -07:00
Paul Eggert
6716a79773 build: re-enable type-limits checking
* configure.ac: When --enable-gcc-warnings is used, omit
-Wno-type-limits.  The need for -Wno-type-limits has passed, now
that intprops.h uses builtin primitives for GCC 5 and later, given
that recent GCCs issue type-limits warnings only for non-constant
expressions.  --enable-gcc-warnings is not intended for use with
old compilers, so we can drop -Wno-type-limits now.
2019-10-22 15:04:42 -07:00
Paul Eggert
c1e19656c8 shuf: fix bug with ‘-r -n 0’
‘shuf -r -n 0 file’ would mistakenly read from standard input.
Problem reported by my student Jingnong Qu while reimplementing a
shuf subset in Python as an exercise in UCLA Computer Science 35L:
https://web.cs.ucla.edu/classes/fall19/cs35L/assign/assign3.html
* NEWS: Mention the fix.  Also, ASCIIfy a previous item.
* src/shuf.c (main): Fix bug.
* tests/misc/shuf.sh: Add a test case for the bug.
2019-10-21 13:20:35 -07:00
Jeff Layton
a99ab26611 ls: use statx instead of stat when available
statx allows ls to indicate interest in only certain inode metadata.
This is potentially a win on networked/clustered/distributed
file systems. In cases where we'd have to do a full, heavyweight stat()
call we can now do a much lighter statx() call.

As a real-world example, consider a file system like CephFS where one
client is actively writing to a file and another client does an
ls --color in the same directory. --color means that we need to fetch
the mode of the file.

Doing that with a stat() call means that we have to fetch the size and
mtime in addition to the mode. The MDS in that situation will have to
revoke caps in order to ensure that it has up-to-date values to report,
which disrupts the writer.

This has a measurable affect on performance. I ran a fio sequential
write test on one cephfs client and had a second client do "ls --color"
in a tight loop on the directory that held the file:

Baseline -- no activity on the second client:

WRITE: bw=76.7MiB/s (80.4MB/s), 76.7MiB/s-76.7MiB/s (80.4MB/s-80.4MB/s),
       io=4600MiB (4824MB), run=60016-60016msec

Without this patch series, we see a noticable performance hit:

WRITE: bw=70.4MiB/s (73.9MB/s), 70.4MiB/s-70.4MiB/s (73.9MB/s-73.9MB/s),
       io=4228MiB (4433MB), run=60012-60012msec

With this patch series, we gain most of that ground back:

WRITE: bw=75.9MiB/s (79.6MB/s), 75.9MiB/s-75.9MiB/s (79.6MB/s-79.6MB/s),
       io=4555MiB (4776MB), run=60019-60019msec

* src/stat.c: move statx to stat struct conversion to new header...
* src/statx.h: ...here.
* src/ls.c: Add wrapper functions for stat/lstat/fstat calls,
and add variants for when we are only interested in specific info.
Add statx-enabled functions and set the request mask based on the
output format and what values are needed.
* NEWS: Mention the Improvement.
2019-10-09 22:07:42 +01:00
Paul Eggert
86ee5548c1 truncate: avoid integer-overflow assumptions
* src/truncate.c (do_ftruncate): Simplify overflow checking,
and don’t rely on theoretically-nonportable assumptions
like assuming that OFF_MAX < UINTMAX_MAX.
2019-10-03 12:41:51 -07:00
Paul Eggert
ba1ea8caee numfmt: avoid unlikely integer overflow
* src/numfmt.c (parse_format_string): Report overflow if
pad < -LONG_MAX, since that can’t be negated.
2019-10-03 12:41:51 -07:00
Paul Eggert
ac2b4a43e6 nl: fix integer-overflow bug
Problem reported by Roland Illig (Bug#37585)
* src/nl.c (print_lineno): Don’t rely on undefined behavior when
checking for integer overflow.
2019-10-03 12:41:51 -07:00
Paul Eggert
bb23a7563f cp: simplify integer overflow checking
* src/copy.c (sparse_copy): Use INT_ADD_WRAPV instead
of doing overflow checking by hand.
2019-10-03 12:41:51 -07:00
Pádraig Brady
1c8050cc4d seq: use faster processing for integer steps from 2 to 200
* src/seq.c: (seq_fast): Accept STEP as a parameter and use that
to skip the output of generated numbers.
(main): Relax to using seq_fast for integer steps between 1 and 200.
For larger steps the throughput was faster using the standard
incrementing procedure.
(cmp): Use the equivalent but faster memcmp for equal len strings.
* tests/misc/seq.pl: Update fast path cases.
Addresses https://bugs.gnu.org/37241
2019-09-08 18:59:24 +01:00
Pádraig Brady
49b1010cc0 maint: use consistent header ordering and spacing in NEWS
* NEWS: Move "Changes in behavior" before "New features",
and ensure there is only a single blank line between sections.
2019-09-08 18:59:21 +01:00
Paul Eggert
f2dfea7e99 build: update gnulib submodule to latest 2019-08-15 02:50:33 -07:00
Assaf Gordon
b8609c7cf2 scripts: document how to build older versions on newer systems
Based on https://lists.gnu.org/r/coreutils/2019-08/msg00011.html .

* scripts/build-older-versions/README.older-versions: Documentation
* scripts/build-older-versions/build-older-versions.sh: Helper script.
* scripts/build-older-versions/.gitignore: Ignore build directory.
* scripts/build-older-versions/coreutils-5.0-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-5.97-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-6.10-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-6.11-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-6.12-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-7.2-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.13-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.17-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.18-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.24-on-glibc-2.28.diff,
scripts/build-older-versions/coreutils-8.4-on-glibc-2.28.diff: Patches.
2019-08-15 01:15:20 -06:00
Bruno Haible
a3d070fa32 build: adjust for recent gnulib pthread changes
Discussed in https://lists.gnu.org/r/coreutils/2019-08/msg00030.html .

* bootstrap.conf (gnulib_modules): Replace 'pthread' with
pthread-* modules.
* src/sort.c: Remove GNULIB_defined_pthread_functions conditional.
2019-08-12 15:10:46 -06:00
Assaf Gordon
725c8d6bed date: mention military timezone changes from gnulib
Gnulib commits f1f10d47be8762e4ca17c8957a0520b08d28abfb and
0673d8ab42c9bb0cf618a21b537cdd8fb976fb73 negated the meaning of
military timezones parsed in gnu date.
See https://lists.gnu.org/r/bug-gnulib/2019-08/msg00005.html and
https://lists.gnu.org/r/coreutils/2019-08/msg00021.html

* NEWS: Mention this user-visible change.
* tests/misc/date.pl: Add tests for the new behavior.
2019-08-10 21:14:20 -06:00
Bernhard Voelker
3cbddd58fd maint: add lib/argmatch.h to po/POTFILES.in
* po/POTFILES.in (lib/argmatch.h): Add to avoid sc_po_check error:
    "maint.mk: you have changed the set of files with translatable \
     diagnostics;"
2019-08-10 21:07:59 -06:00
Assaf Gordon
961d668eea gnulib: update to latest 2019-08-10 21:07:59 -06:00
Pádraig Brady
becf0db0da doc: clarify that truncate creates sparse files
* src/truncate.c (usage): Explicitly mention "sparse".
* doc/coreutils.texi (truncate invocation): Likewise.
Addresses https://bugs.gnu.org/36963
2019-08-08 13:34:54 +01:00
Mike Swanson
eb5a9ebaf1 dircolors: recognize the WebP image format
* src/dircolors.hin: Add .webp for the WebP image format.
Fixes https://bugs.gnu.org/36899
2019-08-07 07:17:27 +02:00
Bernhard Voelker
a574029110 maint: fix error in syntax-check checking
The previous commit introduced a bug into the following syntax-check,
and thus effectively turned it off:

  $ make sc_prohibit_test_calls_print_ver_with_irrelevant_argument; \
      echo $?
  prohibit_test_calls_print_ver_with_irrelevant_argument
  fatal: cannot change to 'grep': No such file or directory
  0

* cfg.mk (sc_prohibit_test_calls_print_ver_with_irrelevant_argument):
Remove changing directory, and pass $(srcdir) as argument to 'git -C'.
2019-08-06 16:11:01 -07:00
Akim Demaille
0e2d4e1425 maint: fix issues in syntax-check
* cfg.mk (sc_prohibit_colon_redirection): Don't expect `|` to denote
the pipe character in git grep.
(sc_tests_executable)
(sc_case_insensitive_file_names)
(sc_some_programs_must_avoid_exit_failure)
(sc_prohibit_test_background_without_cleanup_)
(sc_prohibit_test_calls_print_ver_with_irrelevant_argument)
(sc_prohibit_test_ulimit_without_require_)
(sc_prohibit_test_background_without_cleanup_)
(sc_THANKS_in_duplicates)
*sc_prohibit_test_calls_print_ver_with_irrelevant_argument):
Don't expect builddir to be a descendant of srcdir.
(sc_strftime_check): Don't check file size against 0 when "N\nq\n" was
already put in the file.
* THANKS.in: Remove me.
2019-08-04 11:11:16 -07:00
Assaf Gordon
07f811a3c0 seq: fix superfluous output line
Under certain circumstances seq prints an extra line when the output
format has custom format with characters following the printed numbers:

    $ seq -f "%g " 1000000 1000000
     1e+06
     1e+06

This is due to the "print_extra_number" logic using strings to determine
whether a 'extra number' is needed, but only one string was trimmed
when using a custom printf format.

Prompted by https://lists.gnu.org/r/coreutils/2019-08/msg00001.html

* NEWS: Mention fix.
* src/seq.c (print_numbers): Trim the 'x0_str' string before comparing
it to the previous 'x_str' string.
* tests/misc/seq-extra-number.sh: Add this scenario.
* tests/local.mk (all_tests): Add new test.
2019-08-02 18:29:25 -06:00
Bernhard Voelker
c0f2219d3a doc: improve new version sort chapter
* doc/sort-version.texi: Fix some typos, avoid overly long lines in
the generated PDF, enclose some sample strings in @samp{...} for better
readability, etc.  This also avoids an sc-avoid-builtin error:
s/builtin/built-in/
2019-07-22 08:52:52 +02:00
Assaf Gordon
3264d4ca0d doc: add "version sort ordering" chapter
* doc/sort-version.texi: New file.
* doc/local.mk (doc_coreutils_TEXINFOS): Add new file.
* doc/coreutils.texi: @include new file, replace previous "Details about
version sort" section.
2019-07-15 13:28:20 -06:00
Andreas Dilger
a1a5e9a32e stat: don't explicitly request file size for filenames
When calling 'stat -c %N' to print the filename, don't explicitly
request the size of the file via statx(), as it may add overhead on
some filesystems.  The size is only needed to optimize an allocation
for the relatively rare case of reading a symlink name, and the worst
effect is a somewhat-too-large temporary buffer may be allocated for
areadlink_with_size(), or internal retries if buffer is too small.

The file size will be returned by statx() on most filesystems, even
if not requested, unless the filesystem considers this to be too
expensive for that file, in which case the tradeoff is worthwhile.

* src/stat.c: Don't explicitly request STATX_SIZE for filenames.
2019-07-12 19:51:09 +01:00
Paul Eggert
3ae38a5995 od: use fseek on non-regular files
Problem reported by Szőts Ákos (Bug#36291).
* NEWS: Mention this.
* src/od.c (skip): Try fseek even on files that do not have usable
sizes, falling back on fread if fseek fails.
2019-06-19 18:48:54 -07:00
Paul Eggert
a3a454b9d9 doc: mention ls -l user/group justification
* doc/coreutils.texi (What information is listed):
Document justification of user and group columns in ls -l output
(Bug#36220).
2019-06-18 00:32:25 -07:00
Jeff Layton
0b9bac90d8 stat: fix enabling of statx logic
* src/stat.c: STATX_INO isn't defined until stat.h is included.
Move the test down so it works properly.
2019-06-14 22:43:46 +01:00
Assaf Gordon
0251229bfd tests: avoid false-positive in date-debug test
When debugging an invalid date due to DST switching, the intermediate
'normalized time' should not be checked - its value can differ between
systems (e.g. glibc vs musl).

Reported by Niklas Hambüchen in
https://lists.gnu.org/r/coreutils/2019-05/msg00031.html
Analyzed by Rich Felker in
https://lists.gnu.org/r/coreutils/2019-05/msg00039.html

* tests/misc/date-debug.sh: Replace the exact normalized time
with 'XX:XX:XX' so different values would not trigger test failure.
2019-06-12 21:14:34 -06:00
Jeff Layton
6cc35de16f stat: Use statx where available and support --cached
* src/stat.c: Drop statbuf argument from out_epoch_sec().
Use statx() rather than [lf]stat() where available,
so a separate call is not required to get birth time.
Set STATX_* mask bits only for things we want to print,
which can be more efficient on some file systems.
Add a new --cache= command-line option that sets the appropriate hint
flags in the statx call.  These are primarily used with network
file systems to indicate what level of cache coherency is desired.
The new option is available unconditionally for better portability,
and ignored where not implemented.
* doc/coreutils.texi: Add documention for --cached.
* man/stat.x (SEE ALSO): Mention statx().
* NEWS: Mention the new feature.
2019-06-10 22:59:28 +01:00
Pádraig Brady
bb481a0c1d doc: fix description of tail -f on truncated files
* doc/coreutils.texi (tail invocation): Update to match
the new behavior following commit v8.23-189-gb28ff6a
2019-06-09 12:42:15 +01:00
Pádraig Brady
738a746d82 split: fix failure for certain number of specified files
* src/split.c (set_suffix_length): Use a more standard
zero based logN calculation for the number of units.
* tests/split/suffix-auto-length.sh: Add a test case.
* THANKS.in: Mention the reporter.
* NEWS: Mention the fix.
Fixes https://bugs.gnu.org/35291
2019-06-08 22:58:01 +01:00
Paul Eggert
00d72e6122 dd: be more careful about signal handling
Problem reported by Hans Henrik Bergan (Bug#36007).
* NEWS: Mention this.
* src/dd.c (iclose, ifdatasync, ifstat, ifsync):
New functions, which are more careful about SIGINT.
(cleanup): Use iclose instead of close.
(finish_up): Process signals first.
(skip, dd_copy, main): Use ifstat instead of fstat.
(dd_copy): Use ifdatasync and ifsync instead of fdatasync and fsync.
2019-05-30 13:54:18 -07:00
Paul Eggert
4c223ab4b6 maint: fix version number in NEWS 2019-05-29 16:45:16 -07:00
Paul Eggert
3b1046f80f cp: fix /dev/stdin problem on Solaris
Problem reported by Jakub Kulik (Bug#35713).
* NEWS: Mention this.
* configure.ac (DEV_FD_MIGHT_BE_CHR): New macro.
* src/copy.c (DEV_FD_MIGHT_BE_CHR): Default to false.
(follow_fstatat): New function.
(copy_internal): Use it.
* src/copy.h (XSTAT): Remove; no longer used.
2019-05-28 13:44:40 -07:00
Kevin Locke
3a87ad5124 doc: clarify dd sparse detection is by *output* block
The wording of the dd --help text suggests that output will be skipped
for sparse *input* blocks (i.e. that NUL-checking is done on input
blocks) while the code actually checks/skips all-NUL *output* blocks.[1]

* src/dd.c (usage): Update the --help text to clarify the above.
* tests/dd/sparse.sh: Ensure sparseness is controlled with obs.

[1]: https://superuser.com/a/1136358
2019-05-26 12:53:26 +01:00
Martin Castillo
4f38974aaf doc: fix typo in sort set operations example
* doc/coreutils.texi (sort invocation): Add a missing -u
option to uniq.
Addresses https://bugs.gnu.org/35849
2019-05-22 14:44:56 +01:00
Paul Eggert
a60af87f24 b2sum: port blake2b-ref.c to HP-UX aCC
Continue the fix for Bug#35650.
* src/blake2/blake2b-ref.c [HAVE_CONFIG_H]: Include <config.h>.
2019-05-17 07:58:32 -07:00
Paul Eggert
de54e1a809 b2sum: sync better with upstream
* src/blake2/b2sum.c: Reorder source code to minimize diffs from:
https://github.com/BLAKE2/BLAKE2/blob/master/b2sum/b2sum.c
2019-05-15 12:58:13 -07:00
Paul Eggert
5f261e239f b2sum: port to HP-UX aCC
Its support for the -include option is flaky.  Problem reported by
Michael Osipov (Bug#35650).  Plus, we could run into other
compilers that don’t support any option like -include.  Change the
code so that -include is not needed.  Although this causes us to
depart from the upstream version, we’re already doing that for
other reasons.
* configure.ac (USE_XLC_INCLUDE): Remove, as there’s no
guarantee a compiler will support something like -include.
* src/blake2/b2sum.c [HAVE_CONFIG_H]: Include <config.h>.
* src/local.mk (src_b2sum_CPPFLAGS): Add -DHAVE_CONFIG_H.
Do not use -include or a substitute.
2019-05-15 12:42:58 -07:00
Paul Eggert
5b96efab90 stdbuf: port configure-time checking to HP-UX aCC
Problem reported by Michael Osipov (Bug#35650).
* configure.ac: Use AC_LANG_WERROR to pay attention to compiler
and linker warnings when testing whether stdbuf will work.
2019-05-14 09:21:33 -07:00
Paul Eggert
6e97d361b4 b2sum: port to HP-UX C
* src/blake2/blake2.h (BLAKE2_PACKED):
Don’t assume __attribute__ ((packed)) works on non-Microsoft
compilers.  Instead, assume it works only if we have good
reason to assume so, and fall back on Microsoft (or not packing)
otherwise.  In practice, not packing is good enough and the
BLAKE2_PACKED macro is mostly just for documentation.
2019-05-11 13:55:54 -07:00
Paul Eggert
6f4c2e06ae cp: port fiemap.h to C99
* src/extent-scan.c (extent_scan_read): Adjust to change in
struct fiemap.
* src/fiemap.h (struct fiemap): Use FLEXIBLE_ARRAY_MEMBER
to port to C99.
2019-05-11 13:55:54 -07:00
Paul Eggert
2fd0be3621 basenc: port to C99
* src/basenc.c: Various minor style cleanups.
(struct base_decode_context): Do not use anonymous unions, as
they’re not in C99.  Use a named union instead.  All uses changed.
2019-05-11 13:55:54 -07:00
Paul Eggert
a970a97737 maint: adjust to recent verify_true removal
* src/system.h (X2NREALLOC, X2REALLOC, DECIMAL_DIGIT_ACCUMULATE):
Use verify_expr instead of verify_true, which has been removed.
(DECIMAL_DIGIT_ACCUMULATE): Remove unnecessary size check.
2019-05-11 13:55:54 -07:00
Paul Eggert
39073add8f build: update gnulib submodule to latest 2019-05-11 13:55:54 -07:00
Bernhard Voelker
7d8adb20f6 gnulib: update to the latest
* gnulib: Update to latest, mainly for:
  > mountlist: make parsing /proc/self/mountinfo more robust
* NEWS: Mention the fix.

Fixes https://bugs.gnu.org/33468
2019-04-19 10:21:43 +02:00
Shugo Maeda
6d78a28078 factor: output immediately if stdout is a tty but stdin is not
* src/factor.c (lbuf_putc): Use line buffered mode if the standard
output is a terminal in the same way as the stdio library.
User programs might use pty only for the standard out
like the example of Ruby's PTY module:
https://docs.ruby-lang.org/en/2.6.0/PTY.html#module-PTY-label-Example
* NEWS: Mention the fix.
Fixes https://bugs.gnu.orv/35046
2019-03-31 15:49:48 -07:00
Pádraig Brady
ebf70f297c maint: fix syntax check failure
* src/ln.c: Remove leading TAB.
2019-03-30 15:07:14 -07:00
Martin Castillo
ba36d5118f maint: tee: use STDIN_FILENO rather than 0
* src/tee.c (tee_files): Use the name rather than the value.
Addresses https://bugs.gnu.org/35041
2019-03-30 15:04:42 -07:00
Paul Eggert
59e01d13e6 dd: improve doc of stderr output
* doc/coreutils.texi (dd invocation):
Document stderr output more carefully.
Say that conv=block can lose input data.
2019-03-19 20:09:02 -07:00
Kamil Dudka
ae61b10663 md5sum,b2sum,sha*sum: --help: add note about binary/text mode
* src/md5sum.c (usage): Make it clear that there is no difference
between binary mode and text mode on GNU systems.

Bug: https://bugzilla.redhat.com/406981
Bug: https://bugzilla.redhat.com/1688740
2019-03-18 08:48:57 +01:00
Paul Eggert
1a69508711 doc: add NEWS item for Solaris symlink fix 2019-03-17 13:25:10 -07:00
Paul Eggert
3e0dff3925 ln: port to symlink ("x", ".") failing with EINVAL
Problem reported by John Marino (Bug#34894).
* src/ln.c (main): Port ln -s to Solaris symlink function,
where symlink ("x", ".") fails with errno == EINVAL.
2019-03-17 13:22:32 -07:00
Pádraig Brady
4a21102470 doc: add a NEWS entry for the ln O_DIRECTORY fix
* NEWS: Mention the bugfix.
2019-03-16 14:21:40 -07:00
Paul Eggert
6a707feee8 ln: port to platforms lacking O_DIRECTORY
* src/ln.c (main): Port to older platforms lacking
support for POSIX.1-2008’s O_DIRECTORY flag (Bug#34876).
2019-03-16 11:24:58 -07:00
Kamil Dudka
6bd78f27fd doc: improve wording of the --kibibytes option description
Bug: https://bugzilla.redhat.com/1527391 , https://bugs.gnu.org/33646

* doc/coreutils.texi (General output formatting): Improve wording of
'--kibibytes' option.
2019-03-15 12:26:02 -06:00
Bernhard Voelker
5b9d747261 maint: sync extra files from gnulib
Some files are physically copied from gnulib, and should get sync'ed
after each update to latest gnulib.  This was forgotten during recent
updates.

* COPYING: Merge from gnulib/doc/COPYINGv3.
* tests/init.sh: Merge from gnulib/tests/init.sh.
2019-03-11 11:39:29 +01:00
Pádraig Brady
ab8c604765 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2019-03-10 17:08:36 -07:00
Pádraig Brady
cf28242fd5 version 8.31
* NEWS: Record release date.
2019-03-10 16:34:41 -07:00
Pádraig Brady
5f47cda3ab tests: test-N: include subsecond values in gating check
* tests/misc/test-N.sh: The subsecond values for atime and mtime
were potentially seen to differ on newlyl created files.
So we include the subsecond portion when comparing stat values.
2019-03-10 15:05:26 -07:00
Pádraig Brady
a971cd4ff7 tests: wc-nbsp: fix false failures on various systems
* tests/misc/wc-nbsp.sh: Add gating checks for all characters,
as there are disparate classifications on various systems:
SunOS 5.10 treats \u202F, \u2060 as !iswprint()
SunOS 5.10 treats \u00A0, \u2007 as iswspace()
AIX 7.2, Darwin 17.4.0, NetBSD 7.1 treat \u2060 as !iswprint()
2019-03-09 20:59:21 -08:00
Pádraig Brady
66e2daa689 tests: tail-2/pipe-f: avoid false failure closing stdout
* tests/tail-2/pipe-f.sh: Check closing stdout with >&-
is effective, which avoids a false failure on NetBSD 7.1
Reported by Assaf Gordon
2019-03-06 22:26:30 -08:00
Pádraig Brady
a376de95c3 tests: tac-2-nonseekable: ensure we don't block indefinitely
* tests/misc/tac-2-nonseekable.sh: Add a timeout to both
protect and check whether we can close stdin correctly.
2019-03-06 22:00:53 -08:00
Pádraig Brady
daa46dbe7d tests: id/zero: avoid false failure due to sed differences
* tests/id/zero.sh: sed on OSX will output a \n even
if the input doesn't have a \n on the last "line".
So ensure we always have a trailing '\n' to avoid the disparity.
2019-03-06 22:00:53 -08:00
Pádraig Brady
b918a20234 tests: test-N: fix false positives on some systems
Testing by Assaf Gordon on OSX showed the atime wasn't
being updated when explicitly set back in time.
Also Debian 8.11 / mips64 was seen to not update the
mtime when truncating an empty file.

* tests/misc/test-N.sh: Isolate from different timestamping
behaviors of various (file) systems, by correlating
the timestamps with stat(1) before using `test -N`.
2019-03-06 22:00:53 -08:00
Assaf Gordon
bf2f64c7d5 doc: replace @hashchar{} with actual hash character
Very old makeinfo-4.13 fails with:
  ./doc/coreutils.texi:2286: Unknown command `hashchar'.
  ./doc/coreutils.texi:2286: Misplaced {.
  ./doc/coreutils.texi:2286: Misplaced }.

Reported Bernhard Voelker in
https://lists.gnu.org/r/coreutils/2019-03/msg00016.html .

* doc/coreutils.texi (basenc invocation): Replace @hashchar{} with
actual hash character.  The special syntax is only required
when referring to #line directives.
2019-03-06 21:59:27 -08:00
Pádraig Brady
4bb49f04a1 build: avoid statx related build failure on AIX
* src/stat.c (get_birthtime): Check also for STATX_BTIME define,
as a different statx is available on AIX 7.2.
2019-03-06 10:53:00 -08:00
Pádraig Brady
16358bc19c tests: wc-nbsp.sh: avoid failure on FreeBSD
* tests/misc/wc-nbsp.sh: FreeBSD and OS X don't
treat non breaking space as printable characters.
So use wc -L to determine printability before
testing non breaking space functionality.
2019-03-06 10:52:17 -08:00
Pádraig Brady
4bbbe49074 build: fix env build where SIGNUM_BOUND is not constant
* src/env.c (initialize_signals): A new function to initialize
the signals array on the heap, to avoid a build failure on
opensolaris, where SIGNUM_BOUND is not a constant.
2019-03-06 09:00:44 -08:00
Pádraig Brady
efa3e5dda6 doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.22 which is now about 5 years old.
2019-03-04 01:28:42 -08:00
Pádraig Brady
7c35a36bf4 build: revert recent change with distributed man page handling
* man/local.mk: commit f114495e added an extra check to ensure
a binary was working before using it to generate the man page.
However this was not working for the false(1) command,
and also one can generally specify that one should not
be using generated commands on the current system by passing
'cross_compiling=yes' to the configure invocation.
2019-03-04 01:15:51 -08:00
Pádraig Brady
6bf6d7f461 env: add --list-signal-handling to output non default handling
* src/env.c (main): Output blocked or ignored signals
before a command is executed.
* doc/coreutils.texi (env invocation): Add the option.
* tests/misc/env-signal-handler.sh: Add a test case.
* NEWS: Mention the new feature.
2019-03-04 00:37:42 -08:00
Assaf Gordon
95adadd9a4 env: new options --{default,ignore,block}-signal[=SIG]
New options to set signal handlers for the command being executed.
--block-signal suggested by Paul Eggert in http://bugs.gnu.org/34488#71
--default-signal is useful to overcome the POSIX limitation that shell
must not override inherited signal state, e.g. the second 'trap' here is
a no-op:

   trap '' PIPE && sh -c 'trap - PIPE ; seq inf | head -n1'

Instead use:

   trap '' PIPE && sh -c 'env --default-signal=PIPE seq inf | head -n1'

Similarly, the following will prevent CTRL-C from terminating the
program:

   env --ignore-signal=INT seq inf > /dev/null

See https://bugs.gnu.org/34488#8

* NEWS: Mention new options.
* doc/coreutils.texi (env invocation): Document new options.
* man/env.x: Add example of --default-signal=SIG usage.
(SEE ALSO): Mention sigprocmask.
* src/env.c (signals): New global variable.
(longopts): Add new options.
(usage): Print new options.
(parse_signal_params): Parse comma-separated list of signals, store in
signals variable.
(reset_signal_handlers): Set each signal to SIG_DFL/SIG_IGN.
(parse_block_signal_params): Parse command-line options.
(set_signal_proc_mask): Call sigprocmask to block/unblock signals.
(main): Process new options.
* src/local.mk (src_env_SOURCES): Add operand2sig.c.
* tests/misc/env-signal-handler.sh: New test.
* tests/local.mk (all_tests): Add new test.
2019-03-04 00:37:07 -08:00
Martin Bukatovic
186896d65f stat: print birth time on systems supporting statx
* configure.ac: Check for statx(), available on glibc >= 2.28.
* src/stat.c (get_birthtime): Call statx() when available.
* NEWS: Mention the improvement.
2019-03-03 23:33:51 -08:00
Pádraig Brady
811493e2a9 df: support different file system encodings when not using tty
* src/df.c (replace_problematic_chars): A new wrapper to be
more conservative in our replacement when not connected to a tty.
* tests/df/problematic-chars.sh: Add a test case.
2019-03-03 22:31:08 -08:00
Pádraig Brady
0d6be4b01f maint: tidy up recent additions to NEWS
* NEWS: Move date change to improvements and fix nohup grammar.
2019-03-03 19:21:37 -08:00
Bernhard Voelker
4ae1369516 doc: further clarify 'yes' alternative in seq invocation
* doc/coreutils.texi (node seq invocation): Clarify to use the tool
'yes'; otherwise the reader may interpret the sentence as if one
could pass 'yes' as the INCREMENT value.
2019-02-27 18:51:30 +01:00
Pádraig Brady
a5202bd585 wc: treat non breaking space as a word separator
* src/wc.c (iswnbspace): A new function to match
characters in this class.
(isnbspace): Likewise for single byte charsets.
(main): Initialize posixly_correct from the environment,
to allow disabling honoring NBSP in non C locales.
(wc): Call is[w]nbspace() along with is[w]space.
* bootstrap.conf: Ensure btowc is available.
* tests/misc/wc-nbsp.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the change in behavior.
2019-02-25 22:49:44 -08:00
Paul Eggert
2ab2f7a422 doc: more date +%F clarifications
* doc/coreutils.texi (Date conversion specifiers):
Plain %F is actually like %+4Y-%m-%d.
(Padding and other flags): Mention POSIX restrictions.
* src/date.c (usage): Document recent changes.
2019-02-25 10:21:07 -08:00
Paul Eggert
d5c820109e doc: give date +%+F example
* doc/coreutils.texi (Padding and other flags):
Give example for + conversion specification.
2019-02-25 08:03:38 -08:00
Paul Eggert
3e7fd6650e doc: fix typo in previous patch 2019-02-25 00:25:25 -08:00
Paul Eggert
b1e7af28eb date: ‘+’ conversion specification flag
The recent Gnulib update fixed Bug#34608; document and test this.
* NEWS: Mention the change.
* doc/coreutils.texi (Padding and other flags):
Update doc to cover new flag and other POSIX.1-2017 changes.
* tests/misc/date.pl (date-century-plus): New test.
2019-02-24 23:59:55 -08:00
Paul Eggert
c50c4ab9e1 build: update gnulib submodule to latest 2019-02-24 23:59:55 -08:00
Bernhard Voelker
44af84263e all: detect --help and --version more consistently
For select programs which accept only --help and --version options
(in addition to non-option arguments), process these options before
any other options.

Before:

  $ dd bs=1 --help
  dd: unrecognized option '--help'
  Try 'dd --help' for more information.

  $ yes me --help
  me --help
  me --help
  ...

After:
Any occurrence of '--help' in the arguments (prior to '--') will
show the help screen.

Discussed in https://bugs.gnu.org/33468 .

* NEWS: Mention change.
* src/cksum.c, src/dd.c, src/hostid.c, src/hostname.c, src/link.c,
src/logname.c, src/nohup.c, src/sleep.c, src/tsort.c, src/unlink.c,
src/uptime.c, src/users.c, src/whoami.c, src/yes.c (main): Replace
parse_long_options() + getopt_long() calls with
parse_gnu_standard_options_only(); Remove <getopt.h> inclusion;
Remove empty 'struct long_options' variable;
* tests/misc/help-version-getopt.sh: Add test.
* tests/local.mk (all_tests): Reference it.
2019-02-24 19:32:29 +01:00
Pádraig Brady
36b99b6113 gnulib: update to the latest
update to a version with parse_gnu_standard_options_only()
2019-02-23 18:55:53 -08:00
Martin Castillo
f473489f48 doc: fix join examples in texinfo
* doc/coreutils.texi (join invocation): Fix various errors.
Fixes https://bugs.gnu.org/34583
Fixes https://bugs.gnu.org/34584
2019-02-19 23:29:04 -08:00
Daming Yang
b1ac478653 ls: better align month abbreviations containing digits
* src/ls.c (abmon_init): Align numeric abbreviations right.
* NEWS: Mention the improvement.
2019-02-18 20:06:05 -08:00
Pádraig Brady
5e1a554712 sort: clarify in --debug; only text comparisons affected
* src/sort.c (main): Adjust the debug info regarding locales,
to clarify that only textual comparisons are affected.
* tests/misc/sort-debug-warn.sh: Adjust accordingly.
Fixes https://bugs.gnu.org/34490
2019-02-17 19:17:17 -08:00
Pádraig Brady
636cbdb77b comm,join: ensure warnings are apparent upon exit
* src/comm.c (main): Output a warning right before exit,
in case previous errors have scrolled from view.
* src/join.c (main): Likewise.
* tests/misc/comm.pl: Addjust accordingly.
* tests/misc/join.pl: Likewise.
Fixes https://bugs.gnu.org/34347
2019-02-11 22:56:21 -08:00
Filipp Gunbin
620112526b doc: fix typo referencing RFC 2822
* doc/coreutils.texi (date invocation): s/822/2822/.
Fixes https://bugs.gnu.org/34438
2019-02-11 22:56:08 -08:00
Pádraig Brady
2193e0b9fb gnulib: update to use new strtold module
* gnulib: Update to make the new strtold module available.
* bootstrap.conf: strtod is now a dependency of c-strtod,
which in turn is a dependency of cl-strtod.  This treats
strtold and strtod similarly.
* gl/lib/cl-strtod.c: Adjust to assume strtold is available.
* tests/misc/sort-float.sh: Likewise.
* src/sort.c: Likewise.
(nan_compare): Adjust comment to indicate
we still have to init padding bits as per
https://sourceware.org/bugzilla/show_bug.cgi?id=13246
2019-02-10 20:32:59 -08:00
Pádraig Brady
03fbb5ecec seq: output decimal points consistently with invalid locales
* src/seq.c (print_numbers): Only reset the locale if it
was successfully set originally.
* tests/misc/seq-locale.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the fix.
2019-02-03 17:18:08 -08:00
Pádraig Brady
027eeec7b0 build: ensure sys/select.h is included
bootstrap.conf: Explicitly depend on select, rather than transitively.
* src/tail.c: Unconditionally include select.h as we use select()
outside inotify contexts now.
2019-02-03 17:18:08 -08:00
Pádraig Brady
2e8f885a2a stat,tail: fix android build and support inotify
* src/extract-magic: Treat android like linux,
which fixes the build by ensuring the constants are defined.
* src/stat.c: Support all constants on android, including
the android specific "sdcardfs".
* src/tail.c: Fix inclusion of statfs headers to be independent
of inotify availability, as fremote() is used on linux even
if inotify has been disabled.  Also enable fremote() on android.
* NEWS: Mention the improvment.
Fixes https://bugs.gnu.org/34239
2019-02-03 17:18:08 -08:00
Pádraig Brady
90933c8eb0 tests: add test for locale decimal processing
* tests/misc/sleep.sh: Check locale processing of printf, sleep,
and timeout, when the french locale data is available.
2019-01-30 17:49:05 -08:00
Pádraig Brady
001897e7e2 build: fix recent build failure on systems without strtold
Recently introduced in commit v8.30-50-geb73e23

* gl/lib/cl-strtod.c: Fall back to strtod() on systems
without strtold() (like we already do in sort).
2019-01-30 17:49:05 -08:00
Pádraig Brady
ca80339454 maint: fix new syntax-check failure from recent change
* cfg.mk: Exclude cl-strtold.c wrapper from requiring config.h
2019-01-27 20:42:09 -08:00
Paul Eggert
8adc7ccf7c printf,seq: remove c-strtod dependency
* gl/modules/cl-strtold (Files): Add lib/cl-strtod.c, lib/cl-strtod.h.
(Depends-on): Remove cl-strtod.
(configure.ac): Redquire AC_C_RESTRICT.
2019-01-26 23:19:47 -08:00
Paul Eggert
eb73e23f31 printf,seq: improve long double accuracy
This fixes a thinko in the previous patch.
* gl/lib/cl-strtod.c (STRTOD): New macro.
(CL_STRTOD): Use it.
2019-01-26 23:19:47 -08:00
Paul Eggert
3fe8bc09be printf,seq,sleep,tail,timeout: accept current-locale floats
These commands now accept floating-point numbers in the
current locale, as well as in the C locale.
Compatibility problem reported by Robert Elz.
* NEWS: Document this.
* bootstrap.conf (gnulib_modules): Add cl-strtod, cl-strtold.
Remove c-strtold.
* doc/coreutils.texi (Floating point, tail invocation)
(printf invocation, timeout invocation, sleep invocation)
(seq invocation): Document this.
* gl/lib/cl-strtod.c, gl/lib/cl-strtod.h, gl/lib/cl-strtold.c:
* gl/modules/cl-strtod, gl/modules/cl-strtold: New files.
* src/printf.c, src/seq.c, src/sleep.c, src/tail.c, src/timeout.c:
Include cl-strtod.h instead of c-strtod.
* src/printf.c (vstrtold):
* src/seq.c (scan_arg, print_numbers):
* src/sleep.c (main):
* src/tail.c (parse_options):
* src/timeout.c (parse_duration):
Use cl_strtold instead of c_strtold.
2019-01-26 22:41:09 -08:00
Paul Eggert
3cd48057c7 doc: update Goldberg URL
* doc/coreutils.texi (Floating point): Update URL.
2019-01-25 11:32:46 -08:00
Paul Eggert
643a7325ec sleep: improve doc
Problem reported by Robert Elz.
* doc/coreutils.texi (sleep invocation):
Say that arguments must be non-negative, which means they cannot
be arbitrary floating-point numbers.  Mention POSIX, not
“historical implementations” that are no longer of practical
interest.  List the extensions to POSIX.
* src/sleep.c (usage): Omit needless words, removing dubious
commentary about “most implementations” and incorrect commentary
about “arbitrary”.  Details about exactly which numbers are
allowed can be found in the documentation.
2019-01-25 11:17:18 -08:00
Pádraig Brady
fa50623394 tail: fix handling of broken pipes with SIGPIPE ignored
* init.cfg (trap_sigpipe_or_skip_): A new function refactored from...
* tests/misc/printf-surprise.sh: ...here.
* tests/misc/seq-epipe.sh. Likewise.
* src/tail.c (die_pipe): Ensure we exit upon sending SIGPIPE.
* tests/tail-2/pipe-f.sh: Ensure we exit even if SIGPIPE is ignored.
* NEWS: Mention the bug fix.
2019-01-20 12:53:24 -08:00
Ayappan
17983b2cb3 tail: fix recent ineffective AIX change
* src/tail.c: Fix commit v8.30-40-gd5ab4cb which was ineffective.
Fixes http://bugs.gnu.org/33946
2019-01-20 00:45:32 -08:00
Pádraig Brady
d26dece5d8 build: ensure VLAs are not used
Fail developer builds if VLAs are used,
as there are portability concerns to consider with them.

* configure.ac: Enable -Wvla which is implicit in the full list added.
* m4/jm-macros.m4: Define GNULIB_NO_VLA which disables use of
VLAs within gnulib code.
2019-01-19 21:15:01 -08:00
Pádraig Brady
94fa0aa0d0 gnulib: update to the latest
* gnulib: Update to a version supporting GNULIB_NO_VLA
* bootstrap: Sync with latest
2019-01-19 21:07:04 -08:00
Bernhard Voelker
f114495e3e build: use distributed man pages when running with --help fails
When building against an incompatible GLIBC version compared to that
on the build host, then running the just-built binary might fail
although it is the same platform - thus CROSS_COMPILING is false.
As a result, generating the man pages fails.

* man/local.mk (.x.1): Add a check to verify that running the utility
with --help succeeds, otherwise falling back to using 'dummy-man'.
2019-01-16 08:26:01 +01:00
Pádraig Brady
39ca7731e2 ls: with --group-directories-first, also group symlinked dirs
* src/ls.c (is_linked_directory): A new function to
also consider symlinked directories.
(main): Rename check_symlink_color to check_symlink_mode,
and enable that with --group-directories-first.
(DIRFIRST_CHECK): Adjust to use is_linked_directory,
rather than just is_directory.
(gobble_file): Simplify to always update f->linkmode
if the stat() succeeds.
* tests/ls/group-dirs.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the change in behavior.
Suggested by Amin Bandali in
https://lists.gnu.org/r/coreutils/2018-12/msg00017.html
2019-01-12 19:23:45 -08:00
Pádraig Brady
d5ab4cbe42 tail: don't exit immediately with filters on AIX
* src/tail.c: Fix the check_output_available check on AIX.
Note we don't use poll for all systems as the overhead
of adding the gnulib poll module wouldn't be worth it
just for this single use.
* tests/tail-2/pipe-f.sh: Fix the test which always passed
due to only the exit code of sleep being checked.
* NEWS: Mention the bug fix and rearrange alphabetically.
Fixes http://bugs.gnu.org/33946
2019-01-12 19:23:41 -08:00
Assaf Gordon
d045ce5166 basenc: allocate buffers on heap
Allocate the encoding/decoding buffers dynamically on the heap instead
of using variable-length-array (VLA) on the stack.
Discussed in https://lists.gnu.org/r/coreutils/2019-01/msg00004.html .

* src/basenc.c (do_encode,do_decode): Allocate inbuf/outbuf using
xmalloc, and free if using LINT.
2019-01-05 17:14:07 -07:00
Pádraig Brady
daaae12e3b doc: adjust URLs in help to avoid wrapping
* src/system.h: Adjust lines containing URLs so that
they don't wrap on 80 column terminals.  One could also
use .UR macros, but these aren't universally available.
Note the adjustments here need to be compatible with
the pattern matching done in help2man.
Addresses https://bugs.gnu.org/33914
2019-01-04 08:15:56 -08:00
Assaf Gordon
8dfcf38af1 maint: update all copyright year number ranges
Run "make update-copyright" and then...

* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
2019-01-01 16:51:48 -07:00
Bernhard Voelker
1f9152a50f maint: mention base32 in the title line of common basenc.c
* src/basenc.c: Do the above, and remove a redundant comment.
2019-01-01 16:32:27 -07:00
Assaf Gordon
67c537b91c base64,base32: fix 'extra operand' error message
In the following invocation, 'a' is the input file, and 'b' is the extra
operand:

  $ base64 a b

Report 'b' in the error message instead of 'a':

  $ base64 a b
  base64: extra operand 'b'

Discussed in https://lists.gnu.org/r/coreutils/2018-12/msg00008.html .

* src/basenc.c (main): If there is more than one non-option operand,
report the second one (assuming the first is a the input file name).
* tests/misc/base64.pl: Add tests.
* tests/misc/basenc.pl: Adjust expectedc error message in tests.
* NEWS: Mention bugfix.
2019-01-01 16:32:27 -07:00
Pádraig Brady
d1de5857c7 doc: mention that more than 8 colors are supported by ls
* src/dircolors.hin: Mention any codes supported by the terminal
are allowed.
Addresses https://bugs.gnu.org/33915
2018-12-31 05:17:23 -08:00
Assaf Gordon
2f438fa9f5 basenc: A new program complementary to base64/base32
Encodes/decodes data in various common formats:
base64,base64url,base32,base32,base16,base2,z85.

Discussed here:
https://lists.gnu.org/r/coreutils/2018-11/msg00014.html
https://lists.gnu.org/r/coreutils/2018-12/msg00019.html

* AUTHORS: Add basenc.
* README: Reference the new program.
* NEWS: Mention the new program.
* build-aux/gen-lists-of-programs.sh: Add basenc.
* doc/coreutils.texi: (basenc invocation): Document the new command.
* man/.gitignore: Ignore the generated man page.
* man/basenc.x: A new template, with few examples.
* man/local.mk: Reference the new man page.
* scripts/git-hooks/commit-msg: Allow basenc as program prefix.
* src/.gitignore: Ignore the new binary.
* src/basenc.c:
(usage): Mention new options.
(main): Handle new options.
(isbase*, base*_length, base*_encode, base*_decode_ctx): Implement new
encoding/decoding formats.
* src/local.mk: Add new program.
* tests/local.mk: Add new test.
* tests/misc/basenc.pl: New tests.
* tests/misc/help-version.sh (basenc_setup): use '--version' for default
invocation (basenc errors with no parameters).
2018-12-27 23:46:02 -07:00
Assaf Gordon
21c59d6845 maint: rename base64.c to basenc.c
In preparation for adding 'basenc' program.
Suggested in https://lists.gnu.org/r/coreutils/2018-11/msg00019.html .

* src/base64.c: Rename to src/basenc.c.
* src/local.mk: Update base*_SOURCES definitions.
* po/POTFILEs.in: Rename base64 to basenc.
2018-12-21 15:26:11 -07:00
Paul Eggert
69df9e20e2 shred,sort,split: add NEWS item 2018-12-15 12:42:50 -08:00
Paul Eggert
a6756257ef shred,sort,split: fix ftruncate error reporting
Problem reported for split by Scott Worley (Bug#33761):
* src/shred.c (do_wipefd):
Also report an error if ftruncate fails	on a shared memory object.
* src/sort.c (get_outstatus): New function.
(stream_open, avoid_trashing_input): Use it.
* src/sort.c (stream_open):
* src/split.c (create):
If ftruncate fails, do not report an error
unless it is a regular file or a shared memory object.
2018-12-15 12:14:49 -08:00
Bernhard Voelker
4711c49312 sync: add NEWS and test for the fix in the previous commit
* NEWS (Bug fixes): Mention the fix in commit 94d364f157.
While at it, remove duplicate "Changes in behavior" heading.
* tests/misc/sync.sh: Add a test with a write-only file for the fix.
2018-11-06 17:02:26 -08:00
Paul Eggert
94d364f157 sync: fix open fallback bug
Problem caught by Coverity Analysis
and reported by Kamil Dudka (Bug#33287).
* src/sync.c (sync_arg): Fix typo in fallback code.
2018-11-06 10:35:31 -08:00
Paul Eggert
806b0d1580 ln: use linkat and symlinkat
Open a target directory and use its file descriptor in linkat,
symlinkat, etc. syscalls, instead of constructing long file names
by concatenating the target directory name to a basename.
This avoids O(N²) behavior with ‘ln F1 F2 ... Fn DIR’ when DIR is
a long file name with many slashes.  It also avoids some races if
DIR is renamed while ln is running.
* bootstrap.conf (gnulib_modules): Add openat-safer.
* src/ln.c: Include fcntl-safer.h.
(O_PATHSEARCH): New constant.
(errno_nonexisting, target_directory_operand): Remove; no longer used.
(atomic_link, do_link): New arg DESTDIR_FD.  All uses changed.
(do_link): New arg DEST_BASE.  All uses changed.
(main): Open target directory and use its file descriptor
as DESTDIR_FD.
2018-10-28 01:46:11 -07:00
Paul Eggert
d9a4d98371 build: update gnulib submodule to latest
* src/copy.c (copy_internal):
* src/cp.c (do_copy):
* src/ln.c (do_link):
Adjust to Gnulib API change.
2018-10-28 01:46:11 -07:00
Bernhard Voelker
bdd54b4ee0 tests: provide 100% coverage for echo
*  src/echo.c (usage): Assert that STATUS is always EXIT_SUCCESS.
* tests/misc/echo.sh: Add further tests for all hex and escape and
escape characters.

To get coverage statistics, run:
  make coverage -j 4 TESTS=tests/misc/echo.sh SUBDIRS=.
  xdg-open doc/coverage/src/echo.c.gcov.frameset.html
2018-10-27 05:02:54 -07:00
Pádraig Brady
8d328706c6 echo: always process escapes when POSIXLY_CORRECT is set
* src/echo.c (main): Always enable backslash processing if
POSIXLY_CORRECT is set.
* tests/misc/echo.sh: Add (the first) test for the echo command.
* tests/local.mk: Reference the new test.
* tests/misc/printf.sh: Update a stale comment.
* doc/coreutils.texi (echo invocation). Mention that POSIXLY_CORRECT
now always enables backslash processing.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/32703
Issue identified by Eric Blake.
2018-10-27 03:05:24 -07:00
Bernhard Voelker
1a674a036b test: add -N unary operator
Bash knows 'test -N FILE'.  Add it to GNU 'test' as well.

* src/test.c (unary_operator): Add a case for 'N'.
(usage): Document it.
* doc/coreutils.texi (node File characteristic tests): Likewise.
* NEWS (New features): Likewise.
* tests/misc/test-N.sh: Add a test.
* tests/local.mk (all_tests): Reference it.
2018-10-26 11:05:25 +02:00
Bernhard Voelker
7fd7709a7a test: simplify redundant code
Remove the function 'test_unop', as the cases therein are redundant to
those handled by 'unary_operator'; exception: the cases 'o' and 'N':
they had been present in test_unop and handling the commands
  test -N STR
  test -o STR
and
  test x = x -a -N STR
  test x = x -a -o STR
which ran into an error later on anyway.
With this commit, the error diagnostic will change from ...
  $ /usr/bin/test -N STR
  /usr/bin/test: extra argument '-N'
  $ /usr/bin/test -o STR
  /usr/bin/test: extra argument '-o'
... to ...
  $ src/test -N STR
  src/test: '-N': unary operator expected
  $ src/test -o STR
  src/test: '-o': unary operator expected

* src/test.c (test_unop): Remove.
(unary_operator): Fail with test_syntax_error in the default case.
(term): Directly call unary_operator.
(two_arguments): Likewise.
* tests/misc/test-diag.pl: Adjust error diagnostic.
2018-10-26 10:54:11 +02:00
Bernhard Voelker
88c32fa68e test: remove support for the ambigous -a unary operator
* src/test.c (unary_operator): Remove case 'a'.
(test_unop): Likewise.
* NEWS (Changes in behavior): Document the change.

Discussed at https://bugs.gnu.org/33097
2018-10-26 10:53:57 +02:00
Bernhard Voelker
6bc89f5f85 test: avoid FP in chroot-credentials.sh for different group list order
On my openSUSE:Tumbleweed system, I get a false positive test failure
in the above 'check-root' test because the group lists inside and
outside the chroot have a different order:

  ++ chroot --userspec=berny / id -G
  ++ id -G berny
  + test '100 454 457 480 492' = '100 480 492 457 454'
  + fail=1

* tests/misc/chroot-credentials.sh (num_sort): Add function to sort
group lists, and use it in the test cases which test multiple groups.
2018-10-21 14:55:51 +02:00
Paul Eggert
8ea92f2a1d doc: tidy up setuid commentary
* doc/perm.texi (Mode Structure): Improve wording.
(Numeric Modes): Don’t say “on execution” (Bug#9594).
2018-10-20 10:59:17 -07:00
Paul Eggert
571f63f501 ln: avoid directory hard-link races
Previously, 'ln A B' did 'stat("B"), lstat("A"), link("A","B")'
where the stat and lstat were necessary to avoid hard-linking
directories on systems that can hard-link directories.
Now, in situations that prohibit hard links to directories,
'ln A B' merely does 'link("A","B")'.  The new behavior
avoids some races and should be more efficient.
This patch was inspired by Bug#10020, which was about 'ln'.
* bootstrap.conf (gnulib_modules): Add unlinkdir.
* src/force-link.c (force_linkat, force_symlinkat): New arg for
error number of previous try.  Return error number, 0, or -1 if
error, success, or success after removal.  All callers changed.
* src/ln.c: Include priv-set.h, unlinkdir.h.
(beware_hard_dir_link): New static var.
(errnoize, atomic_link): New functions.
(target_directory_operand): Use errnoize for simplicity.
(do_link): New arg for error number of previous try.  All callers
changed.  Do each link atomically if possible.
(main): Do -r check earlier.  Remove linkdir privileges so we can
use a single linkat/symlinkat instead of a racy substitute for the
common case of 'ln A B' and 'ln -s A B'.  Set beware_hard_dir_link
to disable this optimization.
2018-10-19 12:38:34 -07:00
Paul Eggert
cbc427485e cp: 'cp -il A B' no longer fails if user OKs it
* NEWS: Mention the change.
* src/copy.c (copy_internal): Replace the link if the
user has okayed it.
2018-10-19 12:38:34 -07:00
Paul Eggert
9c3730e601 build: update gnulib submodule to latest
* gl/modules/tempname.diff: Update to match Gnulib.
2018-10-19 12:38:33 -07:00
Paul Eggert
4d5db7193c doc: add chmod examples
Discussed in https://bugs.gnu.org/11043 .

* doc/coreutils.texi (chmod invocation): Add examples.
2018-10-17 14:31:04 -06:00
Bjarni Ingi Gislason
dedb3973e3 doc: fix minor mistakes in "env.x"
* man/env.x (OPTIONS): Fix a spelling mistake.  Protect a period at the
beginning of a line.
2018-10-02 01:09:44 +02:00
Achilles Gaikwad
a32a756a58 id: support multiple specified users
$ id root nobody
  uid=0(root) gid=0(root) groups=0(root)
  uid=99(nobody) gid=99(nobody) groups=99(nobody)

* src/id.c (main): Make variables opt_zero, just_group_list,
just_group, use_real, just_user global to be used in a new
function.
(print_stuff): New function that will print user and group
information for the specified USER.
When using -G option delimit each record with two NULs.
Restructure the code in the file to have global variables
followed by functions.
* tests/id/zero.sh: Add test cases to check the usage
of -z option with multiple users.
* tests/id/uid.sh: Add a test case to ensure all users
are queried in the presence of errors.
* doc/coreutils.texi: Document the interface changes.
* NEWS: Mention the new feature.
2018-09-29 22:39:26 -07:00
Stéphane Campinas
7262994810 doc: csplit: clarify handling of regexps with negative offsets
* doc/coreutils.texi (csplit invocation): Detail the behavior
with regexp patterns and negative offsets, which differs from
line number patterns, to avoid looping on the input.  For example:
  $ seq 50 | csplit -s - /15/-5 /12/
  csplit: ‘/12/’: match not found
2018-09-24 23:48:56 -07:00
Pádraig Brady
f7b2502100 doc: csplit: clarify input may not be reproducible from output
* doc/coreutils.texi (csplit invocation): Clarify that
portions of the input may be skipped and thus the input
may not be reproducible by just concatenating the output files.
Fixes https://bugs.gnu.org/32317
2018-09-23 21:17:04 -07:00
Paul Eggert
e5dae2c6b0 df: omit redundant comparison
Trivial inefficiency reported by Bruno Haible in:
http://lists.gnu.org/r/bug-gnulib/2018-07/msg00109.html
* src/df.c (hide_problematic_chars): Omit redundant test.
2018-07-27 12:03:52 -07:00
Paul Eggert
25c74a37ca df: tune slightly
* src/df.c (get_header, get_dev):
Avoid calling mbswidth twice when once will do.
2018-07-26 18:19:45 -07:00
Paul Eggert
1ecf7abe4a df: avoid multibyte character corruption on macOS
This improves on the earlier fix for the problem reported by
Chih-Hsuan Yen (Bug#32236), by also looking for other control
characters and for encoding errors.
* src/df.c: Include wchar.h and wctype.h instead of c-ctype.h.
(hide_problematic_chars): Process the string as multibyte.
Use iswcntrl, not c_iscntrl.
2018-07-26 18:19:45 -07:00
Chih-Hsuan Yen
437555061c df: avoid multibyte character corruption on macOS
* src/df.c (hide_problematic_chars): Use c_iscntrl() as
passing 8 bit characters to iscntrl() is not supported on macOS.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/32236
2018-07-26 10:24:41 -07:00
Wodry
46d6bd0c0a doc: improve documentation of binary prefixes
* doc/coreutils.texi (Common options):
* src/dd.c, src/head.c, src/od.c, src/stdbuf.c, src/tail.c (usage):
* src/system.h (emit_size_note):
Mention binary prefixes (Bug#32242).
Copyright-paperwork-exempt: Yes
2018-07-22 08:37:15 -07:00
Pádraig Brady
49b682bdd8 tests: avoid false failure on sparc 32 bit
* tests/rm/rm-readdir-fail.sh: Skip the test entirely on 32 bit,
so we avoid conflating the 32bit and 64 bit types, as that
triggers alignment issues (SIGBUS) on Gentoo sparc.
Fixes https://bugs.gnu.org/29886
2018-07-21 12:36:46 -07:00
Paul Eggert
4397410532 build: update gnulib submodule to latest
* bootstrap.conf, src/copy.c, src/mv.c, src/shred.c:
Adjust to renaming of renameat2 to renameatu.
2018-07-05 09:52:14 -07:00
Pádraig Brady
351ac1256b tests: fix skipping in some tests
* tests/cp/cp-a-selinux.sh: Use 'skip_' rather than the probably
undefined 'skip'.
* tests/du/2g.sh: Likewise.
* tests/install/install-Z-selinux.sh: Likewise.
* tests/misc/chcon.sh: Likewise.
* tests/misc/selinux.sh: Likewise.
* tests/mkdir/restorecon.sh: Likewise.
* cfg.mk (sc_prohibit-skip): A new syntax check to catch the issue.
2018-07-04 17:48:41 -07:00
Jim Meyering
19ceb7b89e maint: init.cfg: fix a minor test-related quoting bug
* init.cfg (require_membership_in_two_groups_): This fixes a bug
introduced by me in v8.15-8-gdd0e4c562.  Luckily, the consequence
of low-probability triggering the bug was the mere added backslash
in the diagnostic: "...but running id -G\ either...".  It would be
triggered in a test failure for one who is a member of only one or
fewer groups.
2018-07-01 20:09:17 -07:00
Pádraig Brady
83322567de maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2018-07-01 18:28:37 -07:00
Pádraig Brady
53793cd35f version 8.30
* NEWS: Record release date.
2018-07-01 17:56:07 -07:00
Pádraig Brady
89f7fcd055 tests: standardize perl usage in tests
* tests/cp/fiemap-FMR.sh: Ensure perl is parameterized to $PERL,
and ensure require_perl_ is used, so tests are skipped appropriately.
* tests/cp/preserve-gid.sh: Likewise.
* tests/du/long-from-unreadable.sh: Likewise.
* tests/misc/env-S-script.sh: Likewise.
* tests/misc/sort-benchmark-random.sh: Likewise.
* tests/rm/deep-2.sh: Likewise.
2018-06-30 18:57:43 -07:00
Pádraig Brady
3246bc08a6 maint: copy: avoid new static analyzer warnings
* src/copy.c (copy_internal): Use the lint protected src_mode,
rather than accessing the src_sb again.  Also unconditionally
populate src_sb when !x->move_mode and in lint mode.
Reported by Kamil Dudka with coverity and clang analyzer.
2018-06-30 18:57:43 -07:00
Pádraig Brady
68cf7ad5ad maint: fix recent stale comments and spelling mistakes
* doc/coreutils.texi: s/seperator/separator/.
* tests/misc/env-S.pl: Likewise.
* src/env.c: Fix stale comment.
2018-06-30 18:56:39 -07:00
Pádraig Brady
1755ffb7b6 maint: disable overly agressive sc_gitignore_redundant
* cfg.mk (sc_gitignore_redundant): Disabled for now as too
aggressive flagging entries like /lib/arg-nonnull.h in
a newly checked out repo.
2018-06-27 02:38:59 -07:00
Pádraig Brady
a68efd1283 env: adjust diagnostics provided for shebang usage
* src/env.c (main): Don't process '-' specially since
that causes an issue on the openbsd getopt implementation
where a lone '-' is now processed as an option, and anyway
it doesn't particuarly help diagnosing common shebang
usage issues.  Also don't restrict the extra diagnostics
for shebang usage to the case with 3 arguments, as
further arguments can be passed to a script.
* tests/misc/env-S.pl: Adjust accordingly.
2018-06-27 02:38:59 -07:00
Assaf Gordon
4b7595d751 tests: accept getopt errors without single-quotes
On OpenBSD 6.2, invalid single options produce error messages
without single quotes:

    $ ./src/chroot -/
    chroot: unknown option -- /

As opposed to other systems:

    ./src/chroot: invalid option -- '/'

Modify the grep search to accept this.

* tests/misc/usage_vs_getopt.sh (checkprg): Change the grep pattern
to accomodate no-single-quotes cases.
2018-06-27 02:38:59 -07:00
Pádraig Brady
d542945c3a tests: fix false failures when perl not available
* tests/local.mk: Reference the stub that skips perl tests,
with the correct path.
2018-06-27 02:38:59 -07:00
Pádraig Brady
6d6095f33a tests: fix false failure with limited shebang lines
* tests/misc/env-S-script.sh: Provide a wrapper to
emulate shebang processing, but without length limits,
which are 127 on Linux for example.
2018-06-27 02:38:58 -07:00
Pádraig Brady
91d78a570f maint: update gnulib to latest
* gnulib: Update to latest, which incorporates
a thread linking fix from Bruno Haible,
which was seen on newer Ubuntu systems.
2018-06-27 00:48:03 -07:00
Assaf Gordon
3e5dcddba7 tests: remove unused Data::Dumper perl module
The module is not needed anymore (was used during development).
Despite being a Perl core module, platforms like CentOS don't install
it by default.  Reported by Bruno Haible at
https://lists.gnu.org/r/coreutils/2018-06/msg00093.html.

* tests/misc/csplit-suppress-matched.pl: Remove Data::Dumper.
2018-06-27 00:41:08 -07:00
Carlos Santos
2ed7c28679 maint: fix -Werror=suggest-attribute=malloc in expr.c
Add attribute 'malloc' to mpz_get_str to prevent
the following on GCC 8.1.1

  src/expr.c:117:1: error: function might be candidate for attribute
    'malloc' if it is known to return normally
      [-Werror=suggest-attribute=malloc]
   mpz_get_str (char const *str, int base, mpz_t z)
   ^~~~~~~~~~~
  cc1: all warnings being treated as errors

* src/expr.c (mpz_get_str): Add _GL_ATTRIBUTE_MALLOC.
2018-06-24 21:23:05 -07:00
Pádraig Brady
932ec637a6 maint: update gnulib to latest
* gnulib: Update to latest.
* .gitignore: Add new entries.
* bootstrap.conf: Enable wchar-single, which will enable more
efficient replacements of wcwidth and mbrtowc, as we indicate
that the charset will no change between invocations of these functions.
2018-06-24 21:22:44 -07:00
Pádraig Brady
da07736952 maint: sync longlong.h from gmp repo
* src/longlong.h: Sync changes.  No functional change.
2018-06-24 17:43:17 -07:00
Pádraig Brady
07df260421 maint: avoid false positive in src/fs-magic-compare
* src/local.mk (fs_normalize_perl_subst): `make src/fs-magic-compare`
was reporting incorrectly that AFS was not being handled.
Add a mapping to our KAFS identifier.
* .gitignore: Add intermediate files from `make src/fs-magic-compare`
2018-06-24 17:43:17 -07:00
Bernhard Voelker
5fb8eb091f tests: initialize fail=0 to avoid "unary operator expected" errors
With an uninitialized variable 'fail', the unquoted use like
  test $fail = 1
lead to the shell error
  "unary operator expected".

The uninitialized 'fail' variable was a side effect of
  https://git.sv.gnu.org/cgit/gnulib.git/commit/?id=e91c0d4f9
which was pulled into coreutils-v8.26 with
  https://git.sv.gnu.org/cgit/coreutils.git/commit/?id=ef9650170
Coreutils test code relied and relies on 'fail' to be initialized,
so initialize that variable here.

* tests/local.mk (TESTS_ENVIRONMENT): Initialize fail=0.
2018-06-23 22:37:42 +02:00
Jim Meyering
cb1f253e63 maint: do not depend directly on gnulib's now-unused ftello module
* bootstrap.conf (gnulib_modules): Remove ftello, since it is
no longer used directly, since v8.9-11-geab97b307.
2018-06-21 15:51:19 -07:00
Pádraig Brady
ac7bd90cee tests: provide an option to relax the need for gdb
* tests/rm/r-root.sh: gdb provides extra protection,
but is not strictly necessary.  So provide an option
for maintainers to relax the requirements.
2018-06-20 21:18:32 -07:00
Pádraig Brady
c932e5c9ec rm: add --preserve-root=all to protect mounts
* src/remove.c (rm_fts): With the --preserve-root=all extension,
reject command line arguments that are mount points.
* src/remove.h (rm_options): Add preserve_all_root to store config.
* src/mv.c (rm_option_init): Init preserve_all_root to false.
* src/rm.c (main): Init preserve_all_root as per option.
(usage): Describe the new option.
* src/remove.c (rm_fts): Lookup the parent device id,
and reject the cli argument if a separate file system.
* tests/rm/one-file-system.sh: Add a test case.
* NEWS: Mention the new feature.
2018-06-20 21:18:32 -07:00
Adam Borowski
163df41d45 cp: add --reflink=never to force standard copy mode
This mode is currently the default, but most if not all users of
reflink-capable filesystems want --reflink=auto, which is often
encapsulated into an alias.  Adding --reflink=never allows overriding
such an alias.

* doc/coreutils.texi (cp invocation): Describe the new option.
* src/cp.c: Support --reflink=never.
* tests/cp/reflink-auto.sh: Add a test case.
* NEWS: Mention the new feature.
2018-06-20 21:17:19 -07:00
Assaf Gordon
668306ed86 env: add -S/--split-string option
Adopted from FreeBSD's env(1), useful for specifing multiple
parameters on a shebang (#!) script line, e.g:

   #!/usr/bin/env -S perl -w -T

Discussed in https://lists.gnu.org/r/coreutils/2018-04/msg00011.html

* src/env.c (valid_escape_sequence,escape_char,scan_varname,
  extract_varname,validate_split_str,build_argv,
  parse_split_string): New functions.
  (main): Process new option and call parse_split_string.
  (usage): Mention new option.
* tests/misc/env-S.pl: Test new option from the command line.
* tests/misc/env-S-script.sh: Test new option from shebang scripts.
* tests/local.mk (all_tests): Add new tests.
* man/env.x (OPTIONS): Show a brief example of -S usage and point to
the full documentation for more information.
* doc/coreutils.texi (env invocation): Detail usage of -S/--split-string
option.
* NEWS: Mention new option.
2018-06-20 21:15:31 -07:00
Assaf Gordon
a0118a71bb env: add -v/--debug option
Prints verbose information about each step:

  $ env -v -uFOO  -C /tmp BAR=BAZ date -u
  env: unset:    FOO
  env: setenv:   BAR=BAZ
  env: chdir:    '/tmp'
  env: executing: date
  env:    arg[0]= ‘date’
  env:    arg[1]= ‘-u’
  Sun Apr 22 08:52:30 UTC 2018

Inspired by FreeBSD's env(1).

* src/env.c (usage): Mention new option.
  (main): Print debug information if requested.
* NEWS: Mention new option.
* doc/coreutils.texi (env invocation): Mention -v/--debug.
2018-06-20 21:14:47 -07:00
Assaf Gordon
068b46e73b maint: refactor unsetenv call in env
Keep unset envvars (-uFOO) in an array for later deletion,
instead of reiterating over argv.  Done in preparation for
'-S string' feature. Related to '-u' discussion in
https://lists.gnu.org/r/coreutils/2018-04/msg00013.html

* src/env.c (append_unset_var,unset_envvars): New functions.
 (main): Use new functions.
2018-06-20 21:14:10 -07:00
Kaxandra Labat
24053fbd8f ls: ignore case when coloring file extensions
* src/ls.c (get_color_indicator): s/STREQ_LEN/c_strncasecmp/
* src/dircolors.hin: Remove a now redundant entry.
* tests/ls/color-ext.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the change in behavior.
2018-06-20 21:02:30 -07:00
Pádraig Brady
c744c65f50 md5sum,b2sum,sha*sum: support -z,--zero option
* doc/coreutils.texi (md5sum invocation): Describe the new option,
and how it's not supported by --check, and how it disables escaping.
* src/md5sum.c (delim): A new global to parmeterize the out delimiter.
(main): Don't enable file name escaping with -z, and output '\0'.
* tests/misc/md5sum-newline.pl: Add a test case.
* NEWS: Mention the new feature.
2018-06-20 21:01:14 -07:00
Pádraig Brady
77517a9917 wc: optimize processing of ASCII in multi byte locales
===== Benchmark setup (on GNU/Linux) ====
$ yes áááááááááááááááááááá | head -n100000 > mbc.txt
$ yes 12345678901234567890 | head -n100000 > num.txt

===== Before ====
$ time src/wc -Lm < mbc.txt
real    0m0.186s
$ time src/wc -m < mbc.txt
real    0m0.186s
$ time src/wc -Lm < num.txt
real    0m0.055s
$ time src/wc -m < num.txt
real    0m0.056s

==== After ====
$ time src/wc -Lm < mbc.txt
real    0m0.196s
$ time src/wc -m < mbc.txt
real    0m0.173s
$ time src/wc -Lm < num.txt
real    0m0.031s
$ time src/wc -m < num.txt
real    0m0.028s

* src/wc.c (wc): Only call wide variant functions like
iswprint() and wcwidth() for non is_basic() characters.
I.E. non ISO C "basic character set" characters.
This is especially significant on OSX where wcwidth()
is very expensive (about 10x in tests).
* NEWS: Mention the improvement.
Suggested by Eric Fischer.
2018-06-20 21:00:39 -07:00
Paul Eggert
21682faa5e doc: port test.1 to doclifter
* man/test.x: Use \& instead of quoting (Bug#31803).
2018-06-14 12:07:38 -07:00
Paul Eggert
de73c801f3 doc: port man pages to doclifter
Problem reported by Eric S. Raymond (Bug#31803).
* man/test.x: Add SYNOPSIS section, since help2man
understandably gets confused by the square brackets.
* src/ln.c (usage): Omit parenthetical "(Nth form)" in usage,
as it confuses doclifter.
2018-06-13 16:01:14 -07:00
Pádraig Brady
5e7b8928b7 cp: preserve existing permissions with --no-preserve=mode
This issue was introduced in commit v8.19-145-g24ebca6

* src/copy.c (copy_internal): With --no-preserve=mode,
only reset permissions for newly created files.
(copy_reg): Likewise.
* NEWS: Mention the fix.
* tests/cp/preserve-mode.sh: Add a test case.
Fixes https://bugs.gnu.org/31675
2018-06-03 16:27:37 -07:00
Pádraig Brady
c8eb21c9c0 tests: fix periodic false failure in month alignment
* tests/ls/abmon-align.sh: Base relative month adjustment
from the middle of the month, to avoid failures due
to months being repeated.
Fixes https://bugs.gnu.org/31644
2018-05-29 10:14:07 -07:00
Bjarni Ingi Gislason
fb1ca34140 doc: formatting fixes in "du.x" and "rm.x"
Avoid warnings from: groff -b -e -mandoc -T utf8 -rF0 -t -w w -z

* man/du.x: Change ".BR" to ".B" if there is only one argument.
Protect an end-of-sentence indicator (.?!) with '\&'
if it does not mean an end of a sentence.
Change '--' to '\-\-' if it indicates an option.
* man/rm.x: Change '\=' to '='.
2018-05-25 21:19:46 -07:00
Pádraig Brady
c732388fa1 cp: with --force; replace self referential symlinks
* src/copy.c (copy_internal): Don't fail immediately upon
getting ELOOP when running stat() on the destination,
rather proceeding if -f specified, allowing the link
to be removed.  If the loop is not in the final component
of the destination path, we still fail but at the
subsequent unlink() stage.
* doc/coreutils.texi (cp invocation): Adjust wording to say
that --force doesn't work with dangling links, rather than
all links that can't be traversed.
* tests/cp/thru-dangling.sh: Add a test case.
* NEWS: Mention the change in behavior.
Discussed in https://bugs.gnu.org/31335
2018-05-17 20:52:09 -07:00
Pádraig Brady
d3daa95096 cp: fix symlink checks when overwriting files
Ensure this _does_ recreate the symlink
  Given "path1" and "path2" are on different devices.
  $ touch "path1/file"
  $ cd path2/; ln -s path1/file
  $ cp -dsf path1/file .

Ensure this does _not_ overwrite file
  $ touch file
  $ ln -s file l1
  $ cp -sf l1 file

* src/copy.c (same_file_ok): Remove device ids from consideration,
instead deferring to future EXDEV with --link or allowing
the first case above to work.
Also ensure that we do not exist this function too early,
when the destination file is not a symlink, which protects
against the second case.
* tests/cp/cross-dev-symlink.sh: Add a test for the first case.
* tests/cp/same-file.sh: Add a test for the second case above.
* NEWS: Mention the bug fixes.
* THANKS.in: Mention the reporters who also analyzed the code.
Fixes https://bugs.gnu.org/31364
2018-05-15 09:55:19 -07:00
Pádraig Brady
a391007511 cp: ensure --remove-destination doesn't traverse symlinks
* src/cp.c (target_directory_operand): Allow through inaccessible
arguments with -f or --remove.
* doc/coreutils.texi (cp invocation): Clarify that -f doesn't directly
impact the removal of non-traversable symlinks.
* tests/cp/dir-rm-dest.sh: Test the new behavior.
* tests/cp/thru-dangling.sh: Enforce -f behavior wrt symlinks.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/31335
2018-05-15 09:52:44 -07:00
Pádraig Brady
694d10b71e maint: make chmod/chgrp/chown leak free under valgrind
* src/chmod.c: Deallocate the mode change array in dev mode.
* src/chown.c: Make chopt_free() actually deallocate, but
only call in dev mode.
* src/chgrp.c: Likewise.
2018-05-14 23:51:13 -07:00
Pádraig Brady
a5d158ab8f doc: improve formatting of nl --help
* src/nl.c (usage): Better delineate the information.
2018-05-14 21:33:37 -07:00
Paul Eggert
f6cb50cc99 who: simplify port to GCC 8
* src/who.c (make_id_equals_comment): Use simpler workaround
for GCC bug 85602.  Suggested by Martin Sebor in:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85602#c3
2018-05-14 13:49:58 -07:00
Pádraig Brady
ea7ae28b10 build: make GCC 8 adjustments more portable
* src/chown-core.h (chopt_free): Just define away this noop.
* src/chown-core.c (chopt_free): Remove the empty implementation.
2018-05-03 18:59:53 -07:00
Paul Eggert
3299901cde build: update gnulib submodule to latest 2018-05-03 17:50:11 -07:00
Paul Eggert
9781fcd532 maint: port to GCC 8
* src/chown-core.h (chopt_free, gid_to_name, uid_to_name):
No longer const.
* src/make-prime-list.c (xalloc): Add malloc attribute.
* src/who.c (make_id_equals_comment): Work around GCC bug 85602
by using mempcpy rather than strncat.  Although the old code
was correct, strncat raises so many hackles that it’s not
worth maintaining its use here.
2018-05-03 13:04:15 -07:00
Paul Eggert
e0566c5fea maint: remove strpbrk module
* bootstrap.conf (gnulib_modules): Remove obsolete module strpbrk.
2018-05-03 13:04:15 -07:00
Paul Eggert
ad9b283247 build: update gnulib submodule to latest 2018-05-03 13:04:14 -07:00
Pádraig Brady
22424dde74 doc: retroactively adjust info about tail and closed output
* NEWS: Expand on the 8.28 description of how tail more
responsively reacts to closed output, and move from "Improvements"
to "Changed behavior".
* cfg.mk (old_NEWS_hash): Regenerate.
Fixes https://bugs.gnu.org/31225
2018-04-20 17:54:14 -07:00
Pádraig Brady
3968f28dfd doc: timeout --help: mention 0 DURATION disables timeout
* src/timeout.c (usage): Mention that a duration of 0 disables
the associated timeout, which is both concise info and useful
functionality as timeouts are frequently configured.
2018-04-18 20:11:23 -07:00
Eric Blake
e6017741e9 doc: retroactively document -e/-u addition in NEWS
Prompted by https://bugs.gnu.org/31045

* NEWS: Update 8.8 blurb to mention other split additions.
* cfg.mk (old_NEWS_hash): Regenerate.
2018-04-05 21:38:51 -07:00
Paul Eggert
a8a52e2f05 doc: Clarify octal bits in permissions
* doc/perm.texi (Numeric Modes): Briefly explain octal.
Reorder description to make it more intuitive (Bug#29069).
2018-04-03 08:41:14 -07:00
Tobias Stoeckmann
d1a754c827 cut: improve large file support on 32 bit
Increase max range from SIZE_MAX to UINTMAX_MAX, which will
allow cut to support line lengths up to the max file size
on all systems. The inherent SIZE_MAX limitation in cut was
removed with the enhancements in https://bugs.gnu.org/13127.
Also numfmt gets similarly increased --field ranges due to
shared code.

* src/cut.c: s/size_t/uintmax_t/.
* src/numfmt.c: Likewise.
* src/set-fields.c: Likewise.
* src/set-fields.h: Likewise.
* tests/misc/cut-huge-range.sh: Adjust accordingly.
* tests/misc/numfmt.pl: Likewise.
* NEWS: Mention the improvement.
2018-03-28 00:00:09 -07:00
Pádraig Brady
30e91a10ea tests: avoid a recent syntax-check failure
* tests/ls/a-option.sh: s/framework_failure/&_/.
2018-03-27 23:54:14 -07:00
Paul Eggert
8d6acfd853 ls: -A now overrides -a
Problem reported by Karl Berry (Bug#30963).
* NEWS: Mention this.
* src/ls.c (decode_switches): Implement this.
* tests/ls/a-option.sh: New file.
* tests/local.mk (all_tests): Add it.
2018-03-27 15:05:22 -07:00
Roland Hieber
49b126bfc5 doc: fix two typos in github templates
* .github/ISSUE_TEMPLATE.txt: Fix typo "coreitils" in the URL to the bug
tracker.
* .github/PULL_REQUEST_TEMPLATE.txt: Likewise.
2018-03-24 08:37:19 +01:00
Pádraig Brady
5ed2018360 ls: increase the allowed abmon width from 5 to 12
This will impact relatively few languages,
and will make Arabic or Catalan etc.
output unambiguous abbreviated month names.

* src/ls.c (MAX_MON_WIDTH): Increase from 5 to 12.
* NEWS: Mention the bug fix.
* tests/ls/abmon-align.sh: Augment to check for ambiguous output.
Fixes https://bugs.gnu.org/30814
2018-03-16 03:16:43 -07:00
Brent Petit
0753c3f6dc stat,tail: add support for the EXFS file system
Enhanced XFS (EXFS) is a version of XFS maintained by HPE.
EXFS uses a unique magic number to allow the use of community
XFS, and EXFS filesystems at the same time.

* src/stat.c (human_fstype): Add file system ID definition,
and use "exfs" as the name.
* NEWS: Mention the Improvement.
2018-03-14 09:15:59 -07:00
Paul Eggert
b1fa4aa63c build: update gnulib submodule to latest 2018-03-06 15:22:26 -08:00
Paul Eggert
2eaf3a14a5 stat: work around IBM xlC bug
Problem reported by John Wiersba (Bug#30718)
* src/stat.c (human_time): Avoid giving an integer constant
expression a name, as it runs afoul of a bug in IBM XL C/C++ for
AIX 12.01.0000.0002.
2018-03-05 15:51:06 -08:00
Bernhard Voelker
1f52607fc3 maint: adjust email address of Keith Thompson in THANKS.in
* THANKS.in (Keith Thompson): Update email address as requested by
himself at https://lists.gnu.org/r/coreutils/2018-03/msg00004.html
2018-03-04 20:36:32 +01:00
Pádraig Brady
0a85449dde cp: set appropriate default permissions for special files
This issue was introduced in commit v8.19-145-g24ebca6

* src/copy.c (copy_internal): When setting default permissions
to use with --no-preserve=mode, only set executable bits for
directories or sockets.
* NEWS: Mention the fix.
* tests/cp/preserve-mode.sh: Add a test case.
Fixes https://bugs.gnu.org/30534
2018-02-24 18:15:26 -08:00
Pádraig Brady
33f17ab9db doc: use consistent example format in manual
* doc/coreutils.texi: Use @example consistently
as we don't need the smaller or fixed width representation.
This is especially true for the synopsis of commands.
@smallexample is rendered left aligned for HTML
which is awkward to read with the center aligned main content.
2018-01-21 11:40:57 -08:00
Paul Eggert
4bc50727f0 mv: clarify ‘mv -n A A’ change 2018-01-10 00:51:54 -08:00
Paul Eggert
bedd9bb652 mv: fewer syscalls for ‘mv a b’
This builds on a previous patch for mv atomicity (Bug#29961).
It merely improves performance; it does not fix bugs.
* src/copy.h (struct cp_options): New members last_file, rename_errno.
* src/copy.c (copy_internal): Support new rename_errno member
for the copy options.  Avoid calling stat when new members
suggest it’s not needed.
(cp_options_default): Initialize new members.
* src/mv.c: Include renameat2.h.
(main): With two arguments, first call ‘renamat2 (AT_FDCWD, "a",
AT_FDCWD, "b", RENAME_NOREPLACE)’.  Use its results to skip
remaining processing if possible; for example, if it succeeds
there is no need to stat either "a" or "b".  Also, set
x.last_file when it is the last file to rename.
2018-01-10 00:51:54 -08:00
Paul Eggert
29baf25aa0 mv: improve -n atomicity
Problem reported by Kamil Dudka (Bug#29961).
* NEWS: Mention this.
* src/copy.c: Include renameat2.h.
(copy_internal): If mv, try renameat2 first thing, with
RENAME_NOREPLACE.  If this works, skip most of the remaining code.
Also, fail quickly if it fails with EEXIST, and we are using -n.
2018-01-10 00:51:54 -08:00
Michael Orlitzky
bc2fd97964 doc: warn about following symlinks recursively in chown/chgrp
In both chown and chgrp (which shares its code with chown), operating
on symlinks recursively has a window of vulnerability where the
destination user or group can change the target of the operation.
Warn about combining the --dereference, --recursive, and -L flags.

* doc/coreutils.texi (warnOptDerefWithRec): Add macro.
(node chown invocation): Add it to --dereference and -L.
(node chgrp invocation): Likewise.

See also: CVE-2017-18018
2018-01-10 08:45:24 +01:00
Paul Eggert
b88f8d1101 cp: remove ASSIGN_BASENAME_STRDUPA
* src/cp.c (do_copy): Just use ASSIGN_STRDUPA, as this simplifies
the code and uses less memory.
2018-01-05 22:57:21 -08:00
Paul Eggert
7e244891b0 mv: -n overrides -u
* NEWS: Mention these fixes.
* doc/coreutils.texi (cp invocation, mv invocation):
Mention that -n is silent, and that it overrides -u.
* src/cp.c, src/mv.c (main): -n overrides -u.
2018-01-04 13:57:58 -08:00
Paul Eggert
3f9b1b86b1 tr: add -A, for compatibility with AIX tr
Problem reported by Michael (Bug#29946).
* src/tr.c (main): Add undocumented -A option.
2018-01-03 11:04:03 -08:00
Michael Orlitzky
7597cfa482 doc: clarify chown/chgrp --dereference defaults
* doc/coreutils.texi: the documentation for the --dereference
  flag of chown/chgrp states that it is the default mode of
  operation. Document that this is only the case when operating
  non-recursively.
2018-01-03 19:11:07 +01:00
Pádraig Brady
bd4dd61a17 tests: avoid false failure with xargs on AIX
* tests/misc/shred-remove.sh: AIX xargs defaults to using
'_' to indicate end of input, thus ignoring it.
Rather than specifying -E to avoid this behavior, simplify
by removing sed and xargs usage.
2018-01-02 14:07:00 +00:00
Pádraig Brady
ece7157933 maint: update all copyright year number ranges
Run "make update-copyright" and then...

* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.
2018-01-01 15:57:22 +00:00
Pádraig Brady
1d7db19cba maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2017-12-27 18:26:39 +00:00
838 changed files with 11446 additions and 3588 deletions

View File

@@ -28,7 +28,7 @@ Before reporting a new bug, please check the following resources:
https://lists.gnu.org/archive/html/bug-coreutils/
* Open Bugs:
https://debbugs.gnu.org/cgi/pkgreport.cgi?which=pkg&data=coreitils
https://debbugs.gnu.org/cgi/pkgreport.cgi?which=pkg&data=coreutils
* Translation related issues:
https://translationproject.org/domain/coreutils.html
@@ -68,7 +68,7 @@ When sending messages to coreutils@gnu.org or bug-coreutils@gnu.org :
<!--
Copyright (C) 2017 Free Software Foundation, Inc.
Copyright (C) 2017-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -36,7 +36,7 @@ contributing to the GNU Project, please read
* Bug reports Mailing List:
https://lists.gnu.org/archive/html/bug-coreutils/
* Open Bugs: https://debbugs.gnu.org/cgi/pkgreport.cgi?which=pkg&data=coreitils
* Open Bugs: https://debbugs.gnu.org/cgi/pkgreport.cgi?which=pkg&data=coreutils
* Translation related issues:
https://translationproject.org/domain/coreutils.html
@@ -88,7 +88,7 @@ in this matter.
<!--
Copyright (C) 2017 Free Software Foundation, Inc.
Copyright (C) 2017-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

11
.gitignore vendored
View File

@@ -4,9 +4,9 @@
*.gcda
*.gcno
*.o
*/.deps/
*~
._bootmp
.deps
.gdb-history
.kludge-stamp
.version
@@ -45,7 +45,10 @@
/lib/.dirstamp
/lib/.gitignore
/lib/alloca.h
/lib/arg-nonnull.h
/lib/arpa/inet.h
/lib/byteswap.h
/lib/c++defs.h
/lib/charset.alias
/lib/config.h
/lib/config.hin
@@ -65,6 +68,7 @@
/lib/iconv_open-irix.h
/lib/iconv_open-osf.h
/lib/iconv_open-solaris.h
/lib/iconv_open-zos.h
/lib/inttypes.h
/lib/langinfo.h
/lib/libcoreutils.a
@@ -104,7 +108,9 @@
/lib/unitypes.h
/lib/uniwidth
/lib/uniwidth.h
/lib/unused-parameter.h
/lib/utime.h
/lib/warn-on-use.h
/lib/wchar.h
/lib/wctype.h
/m4/.cvsignore
@@ -170,6 +176,9 @@
/src/coreutils_shebangs
/src/cu-progs.mk
/src/fs-latest-magic.h
/src/fs-def
/src/fs-kernel-magic
/src/fs-magic
/src/libsinglebin_*.a
/src/make-prime-list
/src/primes.h

View File

@@ -1 +1 @@
8.28
8.31

View File

@@ -1,6 +1,6 @@
# Suppress valgrind diagnostics we don't care about.
# Copyright (C) 2003-2017 Free Software Foundation, Inc.
# Copyright (C) 2003-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -6,6 +6,7 @@ b2sum: Padraig Brady, Samuel Neves
base32: Simon Josefsson
base64: Simon Josefsson
basename: David MacKenzie
basenc: Simon Josefsson, Assaf Gordon
cat: Torbjorn Granlund, Richard M. Stallman
chcon: Russell Coker, Jim Meyering
chgrp: David MacKenzie, Jim Meyering
@@ -26,7 +27,7 @@ dircolors: H. Peter Anvin
dirname: David MacKenzie, Jim Meyering
du: Torbjorn Granlund, David MacKenzie, Paul Eggert, Jim Meyering
echo: Brian Fox, Chet Ramey
env: Richard Mlynarik, David MacKenzie
env: Richard Mlynarik, David MacKenzie, Assaf Gordon
expand: David MacKenzie
expr: Mike Parker, James Youngman, Paul Eggert
factor: Paul Rubin, Torbjörn Granlund, Niels Möller

View File

@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
@@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@@ -617,7 +617,7 @@ and root only tests, is to follow these steps (requires lcov to be installed):
xdg-open doc/coverage/index.html
========================================================================
Copyright (C) 2009-2017 Free Software Foundation, Inc.
Copyright (C) 2009-2020 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or

View File

@@ -1,6 +1,6 @@
# Make coreutils. -*-Makefile-*-
# Copyright (C) 1990-2017 Free Software Foundation, Inc.
# Copyright (C) 1990-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -93,7 +93,7 @@ dist-hook: gen-ChangeLog
$(AM_V_at)touch $(distdir)/doc/constants.texi \
$(distdir)/doc/coreutils.info
gen_start_ver = 8.20
gen_start_ver = 8.23
.PHONY: gen-ChangeLog
gen-ChangeLog:
$(AM_V_GEN)if test -d .git; then \

301
NEWS
View File

@@ -1,5 +1,290 @@
GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 8.32 (2020-03-05) [stable]
** Bug fixes
cp now copies /dev/fd/N correctly on platforms like Solaris where
it is a character-special file whose minor device number is N.
[bug introduced in fileutils-4.1.6]
dd conv=fdatasync no longer reports a "Bad file descriptor" error
when fdatasync is interrupted, and dd now retries interrupted calls
to close, fdatasync, fstat and fsync instead of incorrectly
reporting an "Interrupted system call" error.
[bugs introduced in coreutils-6.0]
df now correctly parses the /proc/self/mountinfo file for unusual entries
like ones with '\r' in a field value ("mount -t tmpfs tmpfs /foo$'\r'bar"),
when the source field is empty ('mount -t tmpfs "" /mnt'), and when the
filesystem type contains characters like a blank which need escaping.
[bugs introduced in coreutils-8.24 with the introduction of reading
the /proc/self/mountinfo file]
factor again outputs immediately when stdout is a tty but stdin is not.
[bug introduced in coreutils-8.24]
ln works again on old systems without O_DIRECTORY support (like Solaris 10),
and on systems where symlink ("x", ".") fails with errno == EINVAL
(like Solaris 10 and Solaris 11).
[bug introduced in coreutils-8.31]
rmdir --ignore-fail-on-non-empty now works correctly for directories
that fail to be removed due to permission issues. Previously the exit status
was reversed, failing for non empty and succeeding for empty directories.
[bug introduced in coreutils-6.11]
'shuf -r -n 0 file' no longer mistakenly reads from standard input.
[bug introduced with the --repeat feature in coreutils-8.22]
split no longer reports a "output file suffixes exhausted" error
when the specified number of files is evenly divisible by 10, 16, 26,
for --numeric, --hex, or default alphabetic suffixes respectively.
[bug introduced in coreutils-8.24]
seq no longer prints an extra line under certain circumstances (such as
'seq -f "%g " 1000000 1000000').
[bug introduced in coreutils-6.10]
** Changes in behavior
Several programs now check that numbers end properly. For example,
'du -d 1x' now reports an error instead of silently ignoring the 'x'.
Affected programs and options include du -d, expr's numeric operands
on non-GMP builds, install -g and -o, ls's TABSIZE environment
variable, mknod b and c, ptx -g and -w, shuf -n, and sort --batch-size
and --parallel.
date now parses military time zones in accordance with common usage:
"A" to "M" are equivalent to UTC+1 to UTC+12
"N" to "Y" are equivalent to UTC-1 to UTC-12
"Z" is "zulu" time (UTC).
For example, 'date -d "09:00B" is now equivalent to 9am in UTC+2 time zone.
Previously, military time zones were parsed according to the obsolete
rfc822, with their value negated (e.g., "B" was equivalent to UTC-2).
[The old behavior was introduced in sh-utils 2.0.15 ca. 1999, predating
coreutils package.]
ls issues an error message on a removed directory, on GNU/Linux systems.
Previously no error and no entries were output, and so indistinguishable
from an empty directory, with default ls options.
uniq no longer uses strcoll() to determine string equivalence,
and so will operate more efficiently and consistently.
** New Features
ls now supports the --time=birth option to display and sort by
file creation time, where available.
od --skip-bytes now can use lseek even if the input is not a regular
file, greatly improving performance in some cases.
stat(1) supports a new --cached= option, used on systems with statx(2)
to control cache coherency of file system attributes,
useful on network file systems.
** Improvements
stat and ls now use the statx() system call where available, which can
operate more efficiently by only retrieving requested attributes.
stat and tail now know about the "binderfs", "dma-buf-fs", "erofs",
"ppc-cmm-fs", and "z3fold" file systems.
stat -f -c%T now reports the file system type, and tail -f uses inotify.
** Build-related
gzip-compressed tarballs are distributed once again
* Noteworthy changes in release 8.31 (2019-03-10) [stable]
** Bug fixes
'base64 a b' now correctly diagnoses 'b' as the extra operand, not 'a'.
[bug introduced in coreutils-5.3.0]
When B already exists, 'cp -il A B' no longer immediately fails
after asking the user whether to proceed.
[This bug was present in "the beginning".]
df no longer corrupts displayed multibyte characters on macOS.
[bug introduced with coreutils-8.18]
seq no longer outputs inconsistent decimal point characters
for the last number, when locales are misconfigured.
[bug introduced in coreutils-7.0]
shred, sort, and split no longer falsely report ftruncate errors
when outputting to less-common file types. For example, the shell
command 'sort /dev/null -o /dev/stdout | cat' no longer fails with
an "error truncating" diagnostic.
[bug was introduced with coreutils-8.18 for sort and split, and
(for shared memory objects only) with fileutils-4.1 for shred]
sync no longer fails for write-only file arguments.
[bug introduced with argument support to sync in coreutils-8.24]
'tail -f file | filter' no longer exits immediately on AIX.
[bug introduced in coreutils-8.28]
'tail -f file | filter' no longer goes into an infinite loop
if filter exits and SIGPIPE is ignored.
[bug introduced in coreutils-8.28]
** Changes in behavior
cksum, dd, hostid, hostname, link, logname, sleep, tsort, unlink,
uptime, users, whoami, yes: now always process --help and --version options,
regardless of any other arguments present before any optional '--'
end-of-options marker.
nohup now processes --help and --version as first options even if other
parameters follow.
'yes a -- b' now outputs 'a b' instead of including the end-of-options
marker as before: 'a -- b'.
echo now always processes backslash escapes when the POSIXLY_CORRECT
environment variable is set.
When possible 'ln A B' now merely links A to B and reports an error
if this fails, instead of statting A and B before linking. This
uses fewer system calls and avoids some races. The old statting
approach is still used in situations where hard links to directories
are allowed (e.g., NetBSD when superuser).
ls --group-directories-first will also group symlinks to directories.
'test -a FILE' is not supported anymore. Long ago, there were concerns about
the high probability of humans confusing the -a primary with the -a binary
operator, so POSIX changed this to 'test -e FILE'. Scripts using it were
already broken and non-portable; the -a unary operator was never documented.
wc now treats non breaking space characters as word delimiters
unless the POSIXLY_CORRECT environment variable is set.
** New features
id now supports specifying multiple users.
'date' now supports the '+' conversion specification flag,
introduced in POSIX.1-2017.
printf, seq, sleep, tail, and timeout now accept floating point
numbers in either the current or the C locale. For example, if the
current locale's decimal point is ',', 'sleep 0,1' and 'sleep 0.1'
now mean the same thing. Previously, these commands accepted only
C-locale syntax with '.' as the decimal point. The new behavior is
more compatible with other implementations in non-C locales.
test now supports the '-N FILE' unary operator (like e.g. bash) to check
whether FILE exists and has been modified since it was last read.
env now supports '--default-signal[=SIG]', '--ignore-signal[=SIG]', and
'--block-signal[=SIG], to setup signal handling before executing a program.
env now supports '--list-signal-handling' to indicate non-default
signal handling before executing a program.
** New commands
basenc is added to complement existing base64,base32 commands,
and encodes and decodes printable text using various common encodings:
base64,base64url,base32,base32hex,base16,base2,z85.
** Improvements
ls -l now better aligns abbreviated months containing digits,
which is common in Asian locales.
stat and tail now know about the "sdcardfs" file system on Android.
stat -f -c%T now reports the file system type, and tail -f uses inotify.
stat now prints file creation time when supported by the file system,
on GNU Linux systems with glibc >= 2.28 and kernel >= 4.11.
* Noteworthy changes in release 8.30 (2018-07-01) [stable]
** Bug fixes
'cp --symlink SRC DST' will again correctly validate DST.
If DST is a regular file and SRC is a symlink to DST,
then cp will no longer allow that operation to clobber DST.
Also with -d, if DST is a symlink, then it can always be replaced,
even if it points to SRC on a separate device.
[bugs introduced with coreutils-8.27]
'cp -n -u' and 'mv -n -u' now consistently ignore the -u option.
Previously, this option combination suffered from race conditions
that caused -u to sometimes override -n.
[bug introduced with coreutils-7.1]
'cp -a --no-preserve=mode' now sets appropriate default permissions
for non regular files like fifos and character device nodes etc.,
and leaves mode bits of existing files unchanged.
Previously it would have set executable bits on created special files,
and set mode bits for existing files as if they had been created.
[bug introduced with coreutils-8.20]
'cp --remove-destination file symlink' now removes the symlink
even if it can't be traversed.
[bug introduced with --remove-destination in fileutils-4.1.1]
ls no longer truncates the abbreviated month names that have a
display width between 6 and 12 inclusive. Previously this would have
output ambiguous months for Arabic or Catalan locales.
'ls -aA' is now equivalent to 'ls -A', since -A now overrides -a.
[bug introduced in coreutils-5.3.0]
'mv -n A B' no longer suffers from a race condition that can
overwrite a simultaneously-created B. This bug fix requires
platform support for the renameat2 or renameatx_np syscalls, found
in recent Linux and macOS kernels. As a side effect, 'mv -n A A'
now silently does nothing if A exists.
[bug introduced with coreutils-7.1]
** Changes in behavior
'cp --force file symlink' now removes the symlink even if
it is self referential.
ls --color now matches file extensions case insensitively.
** New features
cp --reflink now supports --reflink=never to enforce a standard copy.
env supports a new -v/--debug option to show verbose information about
each processing step.
env supports a new -S/--split-string=S option to split a single argument
string into multiple arguments. Used to pass multiple arguments in scripts
(shebang lines).
md5sum accepts a new option: --zero (-z) to delimit the output lines with a
NUL instead of a newline character. This also disables file name escaping.
This also applies to sha*sum and b2sum.
rm --preserve-root now supports the --preserve-root=all option to
reject any command line argument that is mounted to a separate file system.
** Improvements
cut supports line lengths up to the max file size on 32 bit systems.
Previously only offsets up to SIZE_MAX-1 were supported.
stat and tail now know about the "exfs" file system, which is a
version of XFS. stat -f --format=%T now reports the file system type,
and tail -f uses inotify.
wc avoids redundant processing of ASCII text in multibyte locales,
which is especially significant on macOS.
* Noteworthy changes in release 8.29 (2017-12-27) [stable]
** Bug fixes
@@ -152,6 +437,13 @@ GNU coreutils NEWS -*- outline -*-
expr supports multibyte strings for all string operations.
** Changes in behavior
tail -f now exits immediately if the output is piped and the reader of
the pipe terminates. That allows `tail -f file | grep -q foo` to return
responsively, but does make `tail -f file | :` exit immediately without
waiting for data. Instead one should now `tail -f file | grep -q .`
** Improvements
mv --verbose now distinguishes rename and copy operations.
@@ -159,9 +451,6 @@ GNU coreutils NEWS -*- outline -*-
stat -f -c %l, used to output the max file name length on a file system,
is now supported on FreeBSD and OpenBSD.
tail -f now exits immediately if the output is piped
and the reader of the pipe terminates.
tail -f no longer erroneously warns about being ineffective
when following a single tty, as the simple blocking loop used
is effective in this case.
@@ -1743,7 +2032,9 @@ GNU coreutils NEWS -*- outline -*-
** New features
split accepts the --number option to generate a specific number of files.
split accepts the --number/-n option to generate a specific number of
files, as well as the --elide-empty-files/-e and --unbuffered/-u
options to fine-tune the resulting output.
* Noteworthy changes in release 8.7 (2010-11-13) [stable]
@@ -4849,7 +5140,7 @@ packages, see ./old/*/NEWS.
========================================================================
Copyright (C) 2001-2017 Free Software Foundation, Inc.
Copyright (C) 2001-2020 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or

20
README
View File

@@ -7,15 +7,15 @@ arbitrary limits.
The programs that can be built with this package are:
[ arch b2sum base32 base64 basename cat chcon chgrp chmod chown chroot cksum
comm coreutils cp csplit cut date dd df dir dircolors dirname du echo env
expand expr factor false fmt fold groups head hostid hostname id install
join kill link ln logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl
nohup nproc numfmt od paste pathchk pinky pr printenv printf ptx pwd
readlink realpath rm rmdir runcon seq sha1sum sha224sum sha256sum sha384sum
sha512sum shred shuf sleep sort split stat stdbuf stty sum sync tac tail
tee test timeout touch tr true truncate tsort tty uname unexpand uniq
unlink uptime users vdir wc who whoami yes
[ arch b2sum base32 base64 basename basenc cat chcon chgrp chmod chown
chroot cksum comm coreutils cp csplit cut date dd df dir dircolors dirname
du echo env expand expr factor false fmt fold groups head hostid hostname
id install join kill link ln logname ls md5sum mkdir mkfifo mknod mktemp
mv nice nl nohup nproc numfmt od paste pathchk pinky pr printenv printf ptx
pwd readlink realpath rm rmdir runcon seq sha1sum sha224sum sha256sum
sha384sum sha512sum shred shuf sleep sort split stat stdbuf stty sum sync
tac tail tee test timeout touch tr true truncate tsort tty uname unexpand
uniq unlink uptime users vdir wc who whoami yes
See the file NEWS for a list of major changes in the current release.
@@ -232,7 +232,7 @@ the address on the last line of --help output.
========================================================================
Copyright (C) 1998-2017 Free Software Foundation, Inc.
Copyright (C) 1998-2020 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or

View File

@@ -93,7 +93,7 @@ each program. One way to do this is to use vc-dwim
-----
Copyright (C) 2002-2017 Free Software Foundation, Inc.
Copyright (C) 2002-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
#! /bin/bash
# Convert this package for use with valgrind.
# Copyright (C) 2002-2017 Free Software Foundation, Inc.
# Copyright (C) 2002-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -25,7 +25,6 @@ Adam Klein aklein@debian.org
Adam Sampson ats@offog.org
Adrian Bunk bunk@stusta.de
AIDA Shinra shinra@j10n.org
Akim Demaille demaille@inf.enst.fr
Alain Magloire alain@qnx.com
Alan Iwi iwi@atm.ox.ac.uk
Alan Jenkins alan-jenkins@tuffmail.co.uk
@@ -261,6 +260,7 @@ Ian Kent ikent@redhat.com
Ian Lance Taylor ian@cygnus.com
Ian Turner vectro@pipeline.com
Iida Yosiaki iida@gnu.org
Illia Bobyr ibobyr@google.com
Ilya N. Golubev gin@mo.msk.ru
Ingo Saitz ingo@debian.org
Ivan Labath labath3@st.fmph.uniba.sk
@@ -279,12 +279,12 @@ Jamie McClelland jm@mayfirst.org
Jan Engelhardt jengelh@medozas.de
Jan Fedak J.Fedak@sh.cvut.cz
Jan Moringen jan.moringen@uni-bielefeld.de
Jan Nieuwenhuizen janneke@gnu.org
Janos Farkas chexum@shadow.banki.hu
Jan-Pawel Wrozstinski jpwroz@gmail.com
Jari Aalto jari.aalto@cante.net
Jarkko Hietaniemi jhi@epsilon.hut.fi
Jarod Wilson jwilson@redhat.com
Jason Smith jasonmsmith@google.com
Jean Charles Delepine delepine@u-picardie.fr
Jean-Pierre Tosoni jpt.7196@gmail.com
Jeff Moore jbm@mordor.com
@@ -309,6 +309,7 @@ Joerg Sonnenberger joerg@britannica.bec.de
Joey Hess joeyh@debian.org
Johan Boule bohan@bohan.dyndns.org
Johan Danielsson joda@pdc.kth.se
Johannes Altmanninger aclopte@gmail.com
John Bley jbb6@acpub.duke.edu
John Gatewood Ham zappaman@alphabox.compsci.buu.ac.th
John Gotts jgotts@umich.edu
@@ -348,7 +349,7 @@ Karsten Thygesen karthy@kom.auc.dk
Kaveh R. Ghazi ghazi@caip.rutgers.edu
Keith M. Briggs keith.briggs@bt.com
Keith Owens kaos@audio.apana.org.au
Keith Thompson kst@cts.com
Keith Thompson Keith.S.Thompson@gmail.com
Ken Irving ken.irving@alaska.edu
Ken Pizzini kenp@halcyon.com
Kevin Mudrick kmudrick@healthmarketscience.com
@@ -419,6 +420,7 @@ Matthew Arnison maffew@cat.org.au
Matthew Braun matthew@ans.net
Matthew Clarke Matthew_Clarke@mindlink.bc.ca
Matthew M. Boedicker matthewm@boedicker.org
Matthew Pfeiffer spferical@gmail.com
Matthew S. Levine mslevine@theory.lcs.mit.edu
Matthew Smith matts@bluesguitar.org
Matthew Swift swift@alum.mit.edu

2
TODO
View File

@@ -143,7 +143,7 @@ pr's use of nstrftime can make it malloc a very large (up to SIZE_MAX) buffer
-----
Copyright (C) 2002-2017 Free Software Foundation, Inc.
Copyright (C) 2002-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

297
bootstrap
View File

@@ -1,10 +1,10 @@
#! /bin/sh
# Print a version string.
scriptversion=2017-09-19.08; # UTC
scriptversion=2019-01-04.17; # UTC
# Bootstrap this package from checked-out sources.
# Copyright (C) 2003-2017 Free Software Foundation, Inc.
# Copyright (C) 2003-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -47,6 +47,8 @@ PERL="${PERL-perl}"
me=$0
default_gnulib_url=git://git.sv.gnu.org/gnulib
usage() {
cat <<EOF
Usage: $me [OPTION]...
@@ -76,6 +78,37 @@ contents are read as shell variables to configure the bootstrap.
For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
are honored.
Gnulib sources can be fetched in various ways:
* If this package is in a git repository with a 'gnulib' submodule
configured, then that submodule is initialized and updated and sources
are fetched from there. If \$GNULIB_SRCDIR is set (directly or via
--gnulib-srcdir) and is a git repository, then it is used as a reference.
* Otherwise, if \$GNULIB_SRCDIR is set (directly or via --gnulib-srcdir),
then sources are fetched from that local directory. If it is a git
repository and \$GNULIB_REVISION is set, then that revision is checked
out.
* Otherwise, if this package is in a git repository with a 'gnulib'
submodule configured, then that submodule is initialized and updated and
sources are fetched from there.
* Otherwise, if the 'gnulib' directory does not exist, Gnulib sources are
cloned into that directory using git from \$GNULIB_URL, defaulting to
$default_gnulib_url.
If \$GNULIB_REVISION is set, then that revision is checked out.
* Otherwise, the existing Gnulib sources in the 'gnulib' directory are
used. If it is a git repository and \$GNULIB_REVISION is set, then that
revision is checked out.
If you maintain a package and want to pin a particular revision of the
Gnulib sources that has been tested with your package, then there are two
possible approaches: either configure a 'gnulib' submodule with the
appropriate revision, or set \$GNULIB_REVISION (and if necessary
\$GNULIB_URL) in $me.conf.
Running without arguments will suffice in most cases.
EOF
}
@@ -129,18 +162,11 @@ bootstrap_post_import_hook() { :; }
# Override it via your own definition in bootstrap.conf.
bootstrap_epilogue() { :; }
# The command to download all .po files for a specified domain into
# a specified directory. Fill in the first %s is the domain name, and
# the second with the destination directory. Use rsync's -L and -r
# options because the latest/%s directory and the .po files within are
# all symlinks.
# The command to download all .po files for a specified domain into a
# specified directory. Fill in the first %s with the destination
# directory and the second with the domain name.
po_download_command_format=\
"rsync --delete --exclude '*.s1' -Lrtvz \
'translationproject.org::tp/latest/%s/' '%s'"
# Fallback for downloading .po files (if rsync fails).
po_download_command_format2=\
"wget --mirror -nd -q -np -A.po -P '%s' \
"wget --mirror --level=1 -nd -nv -A.po -P '%s' \
https://translationproject.org/latest/%s/"
# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
@@ -170,7 +196,15 @@ source_base=lib
m4_base=m4
doc_base=doc
tests_base=tests
gnulib_extra_files=''
gnulib_extra_files="
build-aux/install-sh
build-aux/mdate-sh
build-aux/texinfo.tex
build-aux/depcomp
build-aux/config.guess
build-aux/config.sub
doc/INSTALL
"
# Additional gnulib-tool options to use. Use "\newline" to break lines.
gnulib_tool_option_extras=
@@ -264,24 +298,18 @@ case "$0" in
*) test -r "$0.conf" && . ./"$0.conf" ;;
esac
# Extra files from gnulib, which override files from other sources.
test -z "${gnulib_extra_files}" && \
gnulib_extra_files="
build-aux/install-sh
build-aux/mdate-sh
build-aux/texinfo.tex
build-aux/depcomp
build-aux/config.guess
build-aux/config.sub
doc/INSTALL
"
if test "$vc_ignore" = auto; then
vc_ignore=
test -d .git && vc_ignore=.gitignore
test -d CVS && vc_ignore="$vc_ignore .cvsignore"
fi
if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" = x; then
use_gnulib=false
else
use_gnulib=true
fi
# Translate configuration into internal form.
# Parse options.
@@ -612,95 +640,101 @@ git_modules_config () {
test -f .gitmodules && git config --file .gitmodules "$@"
}
if $use_git; then
gnulib_path=$(git_modules_config submodule.gnulib.path)
test -z "$gnulib_path" && gnulib_path=gnulib
fi
# Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a
# submodule, for use in the rest of the script.
case ${GNULIB_SRCDIR--} in
-)
# Note that $use_git is necessarily true in this case.
if git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
git submodule init -- "$gnulib_path" || exit $?
git submodule update -- "$gnulib_path" || exit $?
elif [ ! -d "$gnulib_path" ]; then
echo "$0: getting gnulib files..."
trap cleanup_gnulib 1 2 13 15
shallow=
git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
cleanup_gnulib
trap - 1 2 13 15
if $use_gnulib; then
if $use_git; then
gnulib_path=$(git_modules_config submodule.gnulib.path)
test -z "$gnulib_path" && gnulib_path=gnulib
fi
GNULIB_SRCDIR=$gnulib_path
;;
*)
# Use GNULIB_SRCDIR directly or as a reference.
if $use_git && test -d "$GNULIB_SRCDIR"/.git && \
git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
if git submodule -h|grep -- --reference > /dev/null; then
# Prefer the one-liner available in git 1.6.4 or newer.
git submodule update --init --reference "$GNULIB_SRCDIR" \
"$gnulib_path" || exit $?
else
# This fallback allows at least git 1.5.5.
if test -f "$gnulib_path"/gnulib-tool; then
# Since file already exists, assume submodule init already complete.
git submodule update -- "$gnulib_path" || exit $?
else
# Older git can't clone into an empty directory.
rmdir "$gnulib_path" 2>/dev/null
git clone --reference "$GNULIB_SRCDIR" \
"$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
&& git submodule init -- "$gnulib_path" \
&& git submodule update -- "$gnulib_path" \
|| exit $?
# Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a
# submodule, for use in the rest of the script.
case ${GNULIB_SRCDIR--} in
-)
# Note that $use_git is necessarily true in this case.
if git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
git submodule init -- "$gnulib_path" || exit $?
git submodule update -- "$gnulib_path" || exit $?
elif [ ! -d "$gnulib_path" ]; then
echo "$0: getting gnulib files..."
trap cleanup_gnulib 1 2 13 15
shallow=
if test -z "$GNULIB_REVISION"; then
git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
fi
git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \
|| cleanup_gnulib
trap - 1 2 13 15
fi
GNULIB_SRCDIR=$gnulib_path
;;
*)
# Use GNULIB_SRCDIR directly or as a reference.
if $use_git && test -d "$GNULIB_SRCDIR"/.git && \
git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..."
if git submodule -h|grep -- --reference > /dev/null; then
# Prefer the one-liner available in git 1.6.4 or newer.
git submodule update --init --reference "$GNULIB_SRCDIR" \
"$gnulib_path" || exit $?
else
# This fallback allows at least git 1.5.5.
if test -f "$gnulib_path"/gnulib-tool; then
# Since file already exists, assume submodule init already complete.
git submodule update -- "$gnulib_path" || exit $?
else
# Older git can't clone into an empty directory.
rmdir "$gnulib_path" 2>/dev/null
git clone --reference "$GNULIB_SRCDIR" \
"$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
&& git submodule init -- "$gnulib_path" \
&& git submodule update -- "$gnulib_path" \
|| exit $?
fi
fi
GNULIB_SRCDIR=$gnulib_path
fi
;;
esac
if test -d "$GNULIB_SRCDIR"/.git && test -n "$GNULIB_REVISION" \
&& ! git_modules_config submodule.gnulib.url >/dev/null; then
(cd "$GNULIB_SRCDIR" && git checkout "$GNULIB_REVISION") || cleanup_gnulib
fi
;;
esac
# $GNULIB_SRCDIR now points to the version of gnulib to use, and
# we no longer need to use git or $gnulib_path below here.
# $GNULIB_SRCDIR now points to the version of gnulib to use, and
# we no longer need to use git or $gnulib_path below here.
if $bootstrap_sync; then
cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
echo "$0: updating bootstrap and restarting..."
case $(sh -c 'echo "$1"' -- a) in
a) ignored=--;;
*) ignored=ignored;;
esac
exec sh -c \
'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
$ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \
"$0" "$@" --no-bootstrap-sync
}
if $bootstrap_sync; then
cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
echo "$0: updating bootstrap and restarting..."
case $(sh -c 'echo "$1"' -- a) in
a) ignored=--;;
*) ignored=ignored;;
esac
exec sh -c \
'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
$ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \
"$0" "$@" --no-bootstrap-sync
}
fi
gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
<$gnulib_tool || exit $?
fi
gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
<$gnulib_tool || exit $?
# Get translations.
download_po_files() {
subdir=$1
domain=$2
echo "$me: getting translations into $subdir for $domain..."
cmd=$(printf "$po_download_command_format" "$domain" "$subdir")
eval "$cmd" && return
# Fallback to HTTPS.
cmd=$(printf "$po_download_command_format2" "$subdir" "$domain")
cmd=$(printf "$po_download_command_format" "$subdir" "$domain")
eval "$cmd"
}
@@ -898,36 +932,47 @@ fi
# Import from gnulib.
gnulib_tool_options="\
--import\
--no-changelog\
--aux-dir $build_aux\
--doc-base $doc_base\
--lib $gnulib_name\
--m4-base $m4_base/\
--source-base $source_base/\
--tests-base $tests_base\
--local-dir $local_gl_dir\
$gnulib_tool_option_extras\
"
if test $use_libtool = 1; then
case "$gnulib_tool_options " in
*' --libtool '*) ;;
*) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
esac
fi
echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules \
|| die "gnulib-tool failed"
if $use_gnulib; then
gnulib_tool_options="\
--no-changelog\
--aux-dir=$build_aux\
--doc-base=$doc_base\
--lib=$gnulib_name\
--m4-base=$m4_base/\
--source-base=$source_base/\
--tests-base=$tests_base\
--local-dir=$local_gl_dir\
$gnulib_tool_option_extras\
"
if test $use_libtool = 1; then
case "$gnulib_tool_options " in
*' --libtool '*) ;;
*) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
esac
fi
echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules \
|| die "gnulib-tool failed"
for file in $gnulib_files; do
symlink_to_dir "$GNULIB_SRCDIR" $file \
|| die "failed to symlink $file"
done
for file in $gnulib_files; do
symlink_to_dir "$GNULIB_SRCDIR" $file \
|| die "failed to symlink $file"
done
fi
bootstrap_post_import_hook \
|| die "bootstrap_post_import_hook failed"
# Don't proceed if there are uninitialized submodules. In particular,
# the next step will remove dangling links, which might be links into
# uninitialized submodules.
#
# Uninitialized submodules are listed with an initial dash.
if $use_git && git submodule | grep '^-' >/dev/null; then
die "some git submodules are not initialized. " \
"Run 'git submodule init' and bootstrap again."
fi
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
# The following requires GNU find 4.2.3 or newer. Considering the usual
@@ -1020,7 +1065,7 @@ bootstrap_epilogue
echo "$0: done. Now you can run './configure'."
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"

View File

@@ -1,6 +1,6 @@
# Bootstrap configuration.
# Copyright (C) 2006-2017 Free Software Foundation, Inc.
# Copyright (C) 2006-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -38,14 +38,17 @@ gnulib_modules="
backup-rename
base32
base64
btowc
buffer-lcm
c-strcase
c-strtod
c-strtold
cl-strtod
cl-strtold
calloc-gnu
canon-host
canonicalize
chmodat
chown
chownat
cloexec
closein
closeout
@@ -74,8 +77,6 @@ gnulib_modules="
faccessat
fadvise
fchdir
fchmodat
fchownat
fclose
fcntl
fcntl-safer
@@ -100,7 +101,6 @@ gnulib_modules="
fstatat
fsusage
fsync
ftello
ftoastr
ftruncate
fts
@@ -165,6 +165,7 @@ gnulib_modules="
memcmp2
mempcpy
memrchr
minmax
mgetgroups
mkancesdirs
mkdir
@@ -183,6 +184,7 @@ gnulib_modules="
nstrftime
obstack
open
openat-safer
parse-datetime
pathmax
perl
@@ -195,7 +197,10 @@ gnulib_modules="
priv-set
progname
propername
pthread
pthread-cond
pthread-mutex
pthread-thread
pthread_sigmask
putenv
quote
quotearg
@@ -211,7 +216,7 @@ gnulib_modules="
remove
rename
renameat
renameat2
renameatu
rmdir
root-dev-ino
rpmatch
@@ -220,6 +225,7 @@ gnulib_modules="
save-cwd
savedir
savewd
select
selinux-at
setenv
settime
@@ -238,9 +244,7 @@ gnulib_modules="
strdup-posix
strncat
strnumcmp
strpbrk
strsignal
strtod
strtoimax
strtoumax
symlinkat
@@ -259,6 +263,7 @@ gnulib_modules="
unistd-safer
unlink-busy
unlinkat
unlinkdir
unlocked-io
unsetenv
update-copyright
@@ -272,6 +277,7 @@ gnulib_modules="
verify
verror
version-etc-fsf
wchar-single
wcswidth
wcwidth
winsz-ioctl
@@ -292,6 +298,7 @@ gnulib_modules="
xstrtod
xstrtoimax
xstrtol
xstrtol-error
xstrtold
xstrtoumax
year2038

View File

@@ -45,6 +45,7 @@ normal_progs='
b2sum
base64
base32
basenc
basename
cat
chcon

70
cfg.mk
View File

@@ -1,5 +1,5 @@
# Customize maint.mk -*- makefile -*-
# Copyright (C) 2003-2017 Free Software Foundation, Inc.
# Copyright (C) 2003-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -48,7 +48,7 @@ export VERBOSE = yes
# 4914152 9e
export XZ_OPT = -8e
old_NEWS_hash = 8c2a749f657a6bd541e8b9c5227fe26f
old_NEWS_hash = d914d8ae972de9e5f77e9398a39de945
# Add an exemption for sc_makefile_at_at_check.
_makefile_at_at_check_exceptions = ' && !/^cu_install_prog/ && !/dynamic-dep/'
@@ -121,6 +121,7 @@ sc_tests_list_consistency:
# Ensure that all version-controlled test scripts are executable.
sc_tests_executable:
@set -o noglob 2>/dev/null || set -f; \
cd $(srcdir); \
find_ext="-name '' "`printf -- "-o -name *%s " $(TEST_EXTENSIONS)`;\
find $(srcdir)/tests/ \( $$find_ext \) \! -perm -u+x -print \
| { sed "s|^$(srcdir)/||"; git ls-files $(srcdir)/tests/; } \
@@ -138,8 +139,8 @@ sc_ensure_gl_diffs_apply_cleanly:
# Avoid :>file which doesn't propagate errors
sc_prohibit_colon_redirection:
@cd $(srcdir)/tests && GIT_PAGER= git grep -n ': *>.*||' \
&& { echo '$(ME): '"The leading colon in :> will hide errors" 1>&2; \
@cd $(srcdir)/tests && GIT_PAGER= git grep -En ': *>.*\|\|' \
&& { echo '$(ME): '"The leading colon in :> will hide errors" >&2; \
exit 1; } \
|| :
@@ -250,6 +251,11 @@ sc_prohibit-quotearg:
halt='Unstyled diagnostic quoting detected' \
$(_sc_search_regexp)
sc_prohibit-skip:
@prohibit='\|\| skip ' \
halt='Use skip_ not skip' \
$(_sc_search_regexp)
sc_sun_os_names:
@grep -nEi \
'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
@@ -402,7 +408,7 @@ check-programs-vs-x:
# Ensure we can check out on case insensitive file systems
sc_case_insensitive_file_names: src/uniq
@git ls-files | sort -f | src/uniq -Di | grep . && \
@git -C $(srcdir) ls-files | sort -f | src/uniq -Di | grep . && \
{ echo "$(ME): the above file(s) conflict on case insensitive" \
" file systems" 1>&2; exit 1; } || :
@@ -440,20 +446,22 @@ sc_prohibit_stat_macro_address:
# Ensure that date's --help output stays in sync with the info
# documentation for GNU strftime. The only exception is %N and %q,
# which date accepts but GNU strftime does not.
#
# "info foo" fails with error, but not "info foo >/dev/null".
extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
sc_strftime_check:
@if test -f $(srcdir)/src/date.c; then \
grep '^ %. ' $(srcdir)/src/date.c | sort \
| $(extract_char) > $@-src; \
{ echo N; echo q; \
info libc date calendar format 2>/dev/null \
| grep "^ *['\`]%.'$$"| $(extract_char); }| sort >$@-info;\
if test $$(stat --format %s $@-info) != 2; then \
if info libc date calendar format 2>/dev/null | \
grep "^ *['\`]%.'$$" >$@-tmp; then \
{ echo N; echo q; $(extract_char) $@-tmp; }| sort \
>$@-info; \
grep '^ %. ' $(srcdir)/src/date.c | sort \
| $(extract_char) > $@-src; \
diff -u $@-src $@-info || exit 1; \
else \
echo '$(ME): skipping $@: libc info not installed' 1>&2; \
fi; \
rm -f $@-src $@-info; \
rm -f $@-info $@-src $@-tmp; \
fi
# Indent only with spaces.
@@ -511,6 +519,14 @@ sc_prohibit_and_fail_1:
in_vc_files='^tests/' \
$(_sc_search_regexp)
# Ensure that tests don't use `cmd ... || fail` as that's a noop.
sc_prohibit_or_fail:
@prohibit='\|\| fail$$' \
exclude=':#' \
halt='|| fail detected. Please use: || fail=1' \
in_vc_files='^tests/' \
$(_sc_search_regexp)
# Ensure that env vars are not passed through returns_ as
# that was seen to fail on FreeBSD /bin/sh at least
sc_prohibit_env_returns:
@@ -603,7 +619,8 @@ sc_prohibit_expr_unsigned:
# Others, use the EXIT_CANCELED, EXIT_ENOENT, etc. macros defined in system.h.
# In those programs, ensure that EXIT_FAILURE is not used by mistake.
sc_some_programs_must_avoid_exit_failure:
@grep -nw EXIT_FAILURE \
@cd $(srcdir) \
&& grep -nw EXIT_FAILURE \
$$(git grep -El '[^T]_FAILURE|EXIT_CANCELED' $(srcdir)/src) \
| grep -vE '= EXIT_FAILURE|return .* \?' | grep . \
&& { echo '$(ME): do not use EXIT_FAILURE in the above' \
@@ -611,22 +628,22 @@ sc_some_programs_must_avoid_exit_failure:
# Ensure that tests call the get_min_ulimit_v_ function if using ulimit -v
sc_prohibit_test_ulimit_without_require_:
@(git grep -l get_min_ulimit_v_ $(srcdir)/tests; \
git grep -l 'ulimit -v' $(srcdir)/tests) \
@(git -C $(srcdir) grep -l get_min_ulimit_v_ tests; \
git -C $(srcdir) grep -l 'ulimit -v' tests) \
| sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
" should match get_min_ulimit_v_ with ulimit -v" 1>&2; exit 1; } || :
# Ensure that tests call the cleanup_ function if using background processes
sc_prohibit_test_background_without_cleanup_:
@(git grep -El '( &$$|&[^&]*=\$$!)' $(srcdir)/tests; \
git grep -l 'cleanup_()' $(srcdir)/tests | sed p) \
@(git -C $(srcdir) grep -El '( &$$|&[^&]*=\$$!)' tests; \
git -C $(srcdir) grep -l 'cleanup_()' tests | sed p) \
| sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
" should use cleanup_ for background processes" 1>&2; exit 1; } || :
# Ensure that tests call the print_ver_ function for programs which are
# actually used in that test.
sc_prohibit_test_calls_print_ver_with_irrelevant_argument:
@git grep -w print_ver_ $(srcdir)/tests \
@git -C $(srcdir) grep -w print_ver_ tests \
| sed 's#:print_ver_##' \
| { fail=0; \
while read file name; do \
@@ -738,7 +755,7 @@ sc_preprocessor_indentation:
# someone who was initially listed only in THANKS.in later authors a commit,
# this rule detects that their pair may now be removed from THANKS.in.
sc_THANKS_in_duplicates:
@{ git log --pretty=format:%aN | sort -u; \
@{ git -C $(srcdir) log --pretty=format:%aN | sort -u; \
cut -b-36 $(srcdir)/THANKS.in \
| sed '/^$$/,/^$$/!d;/^$$/d;s/ *$$//'; } \
| sort | uniq -d | grep . \
@@ -787,11 +804,13 @@ sc_gitignore_missing:
'entries to .gitignore' >&2; exit 1; } || :
# Flag redundant entries in .gitignore
sc_gitignore_redundant:
@{ grep ^/lib $(srcdir)/.gitignore; \
sed 's|^|/lib|' $(srcdir)/lib/.gitignore; } | \
sort | uniq -d | grep . && { echo '$(ME): Remove above' \
'entries from .gitignore' >&2; exit 1; } || :
# Disabled for now as too aggressive flagging
# entries like /lib/arg-nonnull.h
#sc_gitignore_redundant:
# @{ grep ^/lib $(srcdir)/.gitignore; \
# sed 's|^|/lib|' $(srcdir)/lib/.gitignore; } | \
# sort | uniq -d | grep . && { echo '$(ME): Remove above' \
# 'entries from .gitignore' >&2; exit 1; } || :
sc_prohibit-form-feed:
@prohibit=$$'\f' \
@@ -821,8 +840,9 @@ exclude_file_name_regexp--sc_system_h_headers = \
^src/((die|system|copy)\.h|make-prime-list\.c)$$
_src = (false|lbracket|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
_gl_src = (xdecto.max|cl-strtold)
exclude_file_name_regexp--sc_require_config_h_first = \
(^lib/buffer-lcm\.c|gl/lib/xdecto.max\.c|src/$(_src)\.c)$$
(^lib/buffer-lcm\.c|gl/lib/$(_gl_src)\.c|src/$(_src)\.c)$$
exclude_file_name_regexp--sc_require_config_h = \
$(exclude_file_name_regexp--sc_require_config_h_first)

View File

@@ -1,7 +1,7 @@
# -*- autoconf -*-
# Process this file with autoconf to produce a configure script.
# Copyright (C) 1991-2017 Free Software Foundation, Inc.
# Copyright (C) 1991-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -35,8 +35,7 @@ AC_CONFIG_SRCDIR([src/ls.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
AM_INIT_AUTOMAKE([1.11.2 no-dist-gzip dist-xz color-tests parallel-tests
subdir-objects])
AM_INIT_AUTOMAKE([1.11.2 dist-xz color-tests parallel-tests subdir-objects])
AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
dnl POSIXCHECK is worthwhile for maintainers, but adds several seconds
@@ -60,6 +59,7 @@ AC_PROG_GCC_TRADITIONAL
AC_PROG_RANLIB
AC_PROG_LN_S
gl_EARLY
gl_SET_CRYPTO_CHECK_DEFAULT([auto-gpl-compat])
gl_INIT
coreutils_MACROS
@@ -128,14 +128,11 @@ if test "$gl_gcc_warnings" = yes; then
nw="$nw -Wunreachable-code" # Too many warnings for now
nw="$nw -Wpadded" # Our structs are not padded
nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
nw="$nw -Wlogical-op" # Too many warnings until GCC 4.8.0
nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
nw="$nw -Wvla" # warnings in gettext.h
nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
nw="$nw -Wswitch-enum" # Too many warnings for now
nw="$nw -Wswitch-default" # Too many warnings for now
nw="$nw -Wstack-protector" # not worth working around
nw="$nw -Wtype-limits" # False alarms for portable code
nw="$nw -Wformat-overflow=2" # False alarms due to GCC bug 80776
nw="$nw -Wformat-truncation=2" # False alarm in ls.c, probably related
# things I might fix soon:
@@ -144,6 +141,8 @@ if test "$gl_gcc_warnings" = yes; then
nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
nw="$nw -Wsuggest-attribute=format" # warns about copy.c and factor.c
nw="$nw -Wvector-operation-performance" # warns about randperm.c
# Using -Wstrict-overflow is a pain, but the alternative is worse.
# For an example, see the code that provoked this report:
@@ -156,15 +155,9 @@ if test "$gl_gcc_warnings" = yes; then
gl_WARN_ADD([$w])
done
gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
gl_WARN_ADD([-Wno-type-limits]) # False alarms for portable code
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
gl_WARN_ADD([-Wno-format-nonliteral])
# Enable this warning only with gcc-4.8 and newer. Before that
# bounds checking as done in truncate.c was incorrectly flagged.
# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43772
gl_GCC_VERSION_IFELSE([4], [8], [gl_WARN_ADD([-Wlogical-op])])
# clang is unduly picky about some things.
AC_CACHE_CHECK([whether the compiler is clang], [utils_cv_clang],
[AC_COMPILE_IFELSE(
@@ -208,6 +201,11 @@ if test "$gl_gcc_warnings" = yes; then
# FIXME: it may be easy to remove this, since it affects only one file:
# the snprintf call at ftoastr.c:132.
nw="$nw -Wdouble-promotion"
# FIXME: remove this line when gcc improves
# FP in careadlinkat.c w/gcc 10.0.1 20200205
gl_WARN_ADD([-Wno-return-local-addr])
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
AC_SUBST([GNULIB_WARN_CFLAGS])
@@ -318,6 +316,9 @@ if test $ac_cv_func_getattrat = yes; then
AC_SUBST([LIB_NVPAIR])
fi
# glibc >= 2.28 and linux kernel >= 4.11
AC_CHECK_FUNCS([statx])
# SCO-ODT-3.0 is reported to need -los to link programs using initgroups
AC_CHECK_FUNCS([initgroups])
if test $ac_cv_func_initgroups = no; then
@@ -351,6 +352,15 @@ case $utils_cv_func_setpriority,$ac_cv_func_nice in
gl_ADD_PROG([optional_bin_progs], [nice])
esac
if test "$cross_compiling" = yes || test -c /dev/stdin <.; then
AC_DEFINE([DEV_FD_MIGHT_BE_CHR], [1],
[Define to 1 if /dev/std{in,out,err} and /dev/fd/N, if they exist, might be
character-special devices whose minor device number is the file
descriptor number, such as on Solaris. Leave undefined if they are
definitely the actual files. This determination should be done after any
symbolic links are followed.])
fi
AC_DEFUN([coreutils_DUMMY_1],
[
AC_REQUIRE([gl_READUTMP])
@@ -474,6 +484,8 @@ fi
# Build stdbuf only if supported
ac_save_CFLAGS=$CFLAGS
ac_save_LDFLAGS=$LDFLAGS
cu_save_c_werror_flag=$ac_c_werror_flag
AC_LANG_WERROR
# Detect warnings about ignored "constructor" attributes.
gl_WARN_ADD([-Werror], [CFLAGS])
gl_WARN_ADD([-errwarn], [CFLAGS])
@@ -502,18 +514,7 @@ if test "$stdbuf_supported" = "yes" && test -z "$EXEEXT"; then
fi
CFLAGS=$ac_save_CFLAGS
LDFLAGS=$ac_save_LDFLAGS
# Detect when using xlc to determine whether to use -qinclude=
AC_CACHE_CHECK([whether the system supports xlc include], [utils_cv_xlc],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[
#ifndef __xlc__
#error "not xlc"
#endif
]])],
[utils_cv_xlc=yes],
[utils_cv_xlc=no])])
AM_CONDITIONAL([USE_XLC_INCLUDE], [test "$utils_cv_xlc" = yes])
ac_c_werror_flag=$cu_save_c_werror_flag
############################################################################

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
# Make coreutils documentation. -*-Makefile-*-
# This is included by the top-level Makefile.am.
# Copyright (C) 1995-2017 Free Software Foundation, Inc.
# Copyright (C) 1995-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -22,7 +22,8 @@ doc_coreutils_TEXINFOS = \
doc/perm.texi \
doc/parse-datetime.texi \
doc/constants.texi \
doc/fdl.texi
doc/fdl.texi \
doc/sort-version.texi
# The following is necessary if the package name is 8 characters or longer.
# If the info documentation would be split into 10 or more separate files,

View File

@@ -1,6 +1,6 @@
@c File mode bits
@c Copyright (C) 1994-2017 Free Software Foundation, Inc.
@c Copyright (C) 1994-2020 Free Software Foundation, Inc.
@c Permission is granted to copy, distribute and/or modify this document
@c under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -70,38 +70,36 @@ In addition to the three sets of three permissions listed above, the
file mode bits have three special components, which affect only
executable files (programs) and, on most systems, directories:
@enumerate
@item
@table @asis
@item The @dfn{set-user-ID bit} (@dfn{setuid bit}).
@cindex set-user-ID
@cindex setuid
Set the process's effective user ID to that of the file upon execution
(called the @dfn{set-user-ID bit}, or sometimes the @dfn{setuid bit}).
On execution, set the process's effective user ID to that of the file.
For directories on a few systems, give files created in the directory
the same owner as the directory, no matter who creates them, and set
the set-user-ID bit of newly-created subdirectories.
@item
@item The @dfn{set-group-ID bit} (@dfn{setgid bit}).
@cindex set-group-ID
@cindex setgid
Set the process's effective group ID to that of the file upon execution
(called the @dfn{set-group-ID bit}, or sometimes the @dfn{setgid bit}).
On execution, set the process's effective group ID to that of the file.
For directories on most systems, give files created in the directory
the same group as the directory, no matter what group the user who
creates them is in, and set the set-group-ID bit of newly-created
subdirectories.
@item
@item The @dfn{restricted deletion flag} or @dfn{sticky bit}.
@cindex sticky
@cindex swap space, saving text image in
@cindex text image, saving in swap space
@cindex restricted deletion flag
Prevent unprivileged users from removing or renaming a file in a directory
unless they own the file or the directory; this is called the
@dfn{restricted deletion flag} for the directory, and is commonly
unless they own the file or the directory; this is commonly
found on world-writable directories like @file{/tmp}.
For regular files on some older systems, save the program's text image on the
swap device so it will load more quickly when run; this is called the
@dfn{sticky bit}.
@end enumerate
swap device so it will load more quickly when run, so that the image
is ``sticky''.
@end table
In addition to the file mode bits listed above, there may be file attributes
specific to the file system, e.g., access control lists (ACLs), whether a
@@ -494,10 +492,47 @@ the file to all users.
As an
alternative to giving a symbolic mode, you can give an octal (base 8)
number that represents the mode.
This number is always interpreted in octal; you do not have to add a
leading @samp{0}, as you do in C. Mode @samp{0055} is the same as
mode @samp{55}. (However, modes of five digits or more, such as
@samp{00055}, are sometimes special. @xref{Directory Setuid and Setgid}.)
The permissions granted to the user,
to other users in the file's group,
and to other users not in the file's group each require three
bits: one bit for read, one for write, and one for execute/search permission.
These three bits are represented as one octal digit;
for example, if all three are present, the resulting 111 (in binary)
is represented as the digit 7 (in octal). The three special
mode bits also require one bit each, and they are as a group
represented as another octal digit. Here is how the bits are arranged,
starting with the highest valued bit:
@example
Value in Corresponding
Mode Mode Bit
Special mode bits:
4000 Set user ID
2000 Set group ID
1000 Restricted deletion flag or sticky bit
The file's owner:
400 Read
200 Write
100 Execute/search
Other users in the file's group:
40 Read
20 Write
10 Execute/search
Other users not in the file's group:
4 Read
2 Write
1 Execute/search
@end example
For example, numeric mode @samp{4751} corresponds to symbolic mode
@samp{u=srwx,g=rx,o=x}, and numeric mode @samp{664} corresponds to symbolic mode
@samp{ug=rw,o=r}. Numeric mode @samp{0} corresponds to symbolic mode
@samp{a=}.
A numeric mode is usually shorter than the corresponding symbolic
mode, but it is limited in that normally it cannot take into account the
@@ -507,43 +542,10 @@ to this general limitation. @xref{Directory Setuid and Setgid}.
Also, operator numeric modes can take previous file mode bits into
account. @xref{Operator Numeric Modes}.
The permissions granted to the user,
to other users in the file's group,
and to other users not in the file's group each require three
bits, which are represented as one octal digit. The three special
mode bits also require one bit each, and they are as a group
represented as another octal digit. Here is how the bits are arranged,
starting with the lowest valued bit:
@example
Value in Corresponding
Mode Mode Bit
Other users not in the file's group:
1 Execute/search
2 Write
4 Read
Other users in the file's group:
10 Execute/search
20 Write
40 Read
The file's owner:
100 Execute/search
200 Write
400 Read
Special mode bits:
1000 Restricted deletion flag or sticky bit
2000 Set group ID on execution
4000 Set user ID on execution
@end example
For example, numeric mode @samp{4755} corresponds to symbolic mode
@samp{u=rwxs,go=rx}, and numeric mode @samp{664} corresponds to symbolic mode
@samp{ug=rw,o=r}. Numeric mode @samp{0} corresponds to symbolic mode
@samp{a=}.
Numeric modes are always interpreted in octal; you do not have to add a
leading @samp{0}, as you do in C@. Mode @samp{0055} is the same as
mode @samp{55}. However, modes of five digits or more, such as
@samp{00055}, are sometimes special (@pxref{Directory Setuid and Setgid}).
@node Operator Numeric Modes
@section Operator Numeric Modes

905
doc/sort-version.texi Normal file
View File

@@ -0,0 +1,905 @@
@c GNU Version-sort ordering documentation
@c Copyright (C) 2019-2020 Free Software Foundation, Inc.
@c Permission is granted to copy, distribute and/or modify this document
@c under the terms of the GNU Free Documentation License, Version 1.3 or
@c any later version published by the Free Software Foundation; with no
@c Invariant Sections, no Front-Cover Texts, and no Back-Cover
@c Texts. A copy of the license is included in the ``GNU Free
@c Documentation License'' file as part of this distribution.
@c Written by Assaf Gordon
@node Version sort ordering
@chapter Version sort ordering
@node Version sort overview
@section Version sort overview
@dfn{version sort} ordering (and similarly, @dfn{natural sort}
ordering) is a method to sort items such as file names and lines of
text in an order that feels more natural to people, when the text
contains a mixture of letters and digits.
Standard sorting usually does not produce the order that one expects
because comparisons are made on a character-by-character basis.
Compare the sorting of the following items:
@example
Alphabetical sort: Version Sort:
a1 a1
a120 a2
a13 a13
a2 a120
@end example
version sort functionality in GNU coreutils is available in the @samp{ls -v},
@samp{ls --sort=version}, @samp{sort -V}, @samp{sort --version-sort} commands.
@node Using version sort in GNU coreutils
@subsection Using version sort in GNU coreutils
Two GNU coreutils programs use version sort: @command{ls} and @command{sort}.
To list files in version sort order, use @command{ls}
with @option{-v} or @option{--sort=version} options:
@example
default sort: version sort:
$ ls -1 $ ls -1 -v
a1 a1
a100 a1.4
a1.13 a1.13
a1.4 a1.40
a1.40 a2
a2 a100
@end example
To sort text files in version sort order, use @command{sort} with
the @option{-V} option:
@example
$ cat input
b3
b11
b1
b20
alphabetical order: version sort order:
$ sort input $ sort -V input
b1 b1
b11 b3
b20 b11
b3 b20
@end example
To sort a specific column in a file use @option{-k/--key} with @samp{V}
ordering option:
@example
$ cat input2
1000 b3 apples
2000 b11 oranges
3000 b1 potatoes
4000 b20 bananas
$ sort -k2V,2 input2
3000 b1 potatoes
1000 b3 apples
2000 b11 oranges
4000 b20 bananas
@end example
@node Origin of version sort and differences from natural sort
@subsection Origin of version sort and differences from natural sort
In GNU coreutils, the name @dfn{version sort} was chosen because it is based
on Debian GNU/Linux's algorithm of sorting packages' versions.
Its goal is to answer the question
``which package is newer, @file{firefox-60.7.2} or @file{firefox-60.12.3} ?''
In coreutils this algorithm was slightly modified to work on more
general input such as textual strings and file names
(see @ref{Differences from the official Debian Algorithm}).
In other contexts, such as other programs and other programming
languages, a similar sorting functionality is called
@uref{https://en.wikipedia.org/wiki/Natural_sort_order,natural sort}.
@node Correct/Incorrect ordering and Expected/Unexpected results
@subsection Correct/Incorrect ordering and Expected/Unexpected results
Currently there is no standard for version/natural sort ordering.
That is: there is no one correct way or universally agreed-upon way to
order items. Each program and each programming language can decide its
own ordering algorithm and call it 'natural sort' (or other various
names).
See @ref{Other version/natural sort implementations} for many examples of
differing sorting possibilities, each with its own rules and variations.
If you do suspect a bug in coreutils' implementation of version-sort,
see @ref{Reporting bugs or incorrect results} on how to report them.
@node Implementation Details
@section Implementation Details
GNU coreutils' version sort algorithm is based on
@uref{https://www.debian.org/doc/debian-policy/ch-controlfields.html#version,
Debian's versioning scheme}, specifically on the "upstream version"
part.
This section describes the ordering rules.
The next section (@ref{Differences from the official Debian
Algorithm}) describes some differences between GNU coreutils
implementation and Debian's official algorithm.
@node Version-sort ordering rules
@subsection Version-sort ordering rules
The version sort ordering rules are:
@enumerate
@item
The strings are compared from left to right.
@item
First the initial part of each string consisting entirely of non-digit
characters is determined.
@enumerate
@item
These two parts (one of which may be empty) are compared lexically.
If a difference is found it is returned.
@item
The lexical comparison is a comparison of ASCII values modified so that:
@enumerate
@item
all the letters sort earlier than all the non-letters and
@item
so that a tilde sorts before anything, even the end of a part.
@end enumerate
@end enumerate
@item
Then the initial part of the remainder of each string which consists
entirely of digit characters is determined. The numerical values of
these two parts are compared, and any difference found is returned as
the result of the comparison.
@enumerate
@item
For these purposes an empty string (which can only occur at the end of
one or both version strings being compared) counts as zero.
@end enumerate
@item
These two steps (comparing and removing initial non-digit strings and
initial digit strings) are repeated until a difference is found or
both strings are exhausted.
@end enumerate
Consider the version-sort comparison of two file names:
@file{foo07.7z} and @file{foo7a.7z}. The two strings will be broken
down to the following parts, and the parts compared respectively from
each string:
@example
foo @r{vs} foo @r{(rule 2, non-digits characters)}
07 @r{vs} 7 @r{(rule 3, digits characters)}
. @r{vs} a. @r{(rule 2)}
7 @r{vs} 7 @r{(rule 3)}
z @r{vs} z @r{(rule 2)}
@end example
Comparison flow based on above algorithm:
@enumerate
@item
The first parts (@code{foo}) are identical in both strings.
@item
The second parts (@code{07} and @code{7}) are compared numerically,
and are identical.
@item
The third parts (@samp{@code{.}} vs @samp{@code{a.}}) are compared
lexically by ASCII value (rule 2.2).
@item
The first character of the first string (@samp{@code{.}}) is compared
to the first character of the second string (@samp{@code{a}}).
@item
Rule 2.2.1 dictates that "all letters sorts earlier than all non-letters".
Hence, @samp{@code{a}} comes before @samp{@code{.}}.
@item
The returned result is that @file{foo7a.7z} comes before @file{foo07.7z}.
@end enumerate
Result when using sort:
@example
$ cat input3
foo07.7z
foo7a.7z
$ sort -V input3
foo7a.7z
foo07.7z
@end example
See @ref{Differences from the official Debian Algorithm} for
additional rules that extend the Debian algorithm in coreutils.
@node Version sort is not the same as numeric sort
@subsection Version sort is not the same as numeric sort
Consider the following text file:
@example
$ cat input4
8.10
8.5
8.1
8.01
8.010
8.100
8.49
Numerical Sort: Version Sort:
$ sort -n input4 $ sort -V input4
8.01 8.01
8.010 8.1
8.1 8.5
8.10 8.010
8.100 8.10
8.49 8.49
8.5 8.100
@end example
Numeric sort (@samp{sort -n}) treats the entire string as a single numeric
value, and compares it to other values. For example, @code{8.1}, @code{8.10} and
@code{8.100} are numerically equivalent, and are ordered together. Similarly,
@code{8.49} is numerically smaller than @code{8.5}, and appears before first.
Version sort (@samp{sort -V}) first breaks down the string into digits and
non-digits parts, and only then compares each part (see annotated
example in Version-sort ordering rules).
Comparing the string @code{8.1} to @code{8.01}, first the
@samp{@code{8}} characters are compared (and are identical), then the
dots (@samp{@code{.}}) are compared and are identical, and lastly the
remaining digits are compared numerically (@code{1} and @code{01}) -
which are numerically equivalent. Hence, @code{8.01} and @code{8.1}
are grouped together.
Similarly, comparing @code{8.5} to @code{8.49} - the @samp{@code{8}}
and @samp{@code{.}} parts are identical, then the numeric values @code{5} and
@code{49} are compared. The resulting @code{5} appears before @code{49}.
This sorting order (where @code{8.5} comes before @code{8.49}) is common when
assigning versions to computer programs (while perhaps not intuitive
or 'natural' for people).
@node Punctuation Characters
@subsection Punctuation Characters
Punctuation characters are sorted by ASCII order (rule 2.2).
@example
$ touch 1.0.5_src.tar.gz 1.0_src.tar.gz
$ ls -v -1
1.0.5_src.tar.gz
1.0_src.tar.gz
@end example
Why is @file{1.0.5_src.tar.gz} listed before @file{1.0_src.tar.gz} ?
Based on the @ref{Version-sort ordering rules,algorithm,algorithm}
above, the strings are broken down into the following parts:
@example
1 @r{vs} 1 @r{(rule 3, all digit characters)}
. @r{vs} . @r{(rule 2, all non-digit characters)}
0 @r{vs} 0 @r{(rule 3)}
. @r{vs} _src.tar.gz @r{(rule 2)}
5 @r{vs} empty string @r{(no more character in the file name)}
_src.tar.gz @r{vs} empty string
@end example
The fourth parts (@samp{@code{.}} and @code{_src.tar.gz}) are compared
lexically by ASCII order. The character @samp{@code{.}} (ASCII value 46) is
smaller than @samp{@code{_}} (ASCII value 95) - and should be listed before it.
Hence, @file{1.0.5_src.tar.gz} is listed first.
If a different character appears instead of the underscore (for
example, percent sign @samp{@code{%}} ASCII value 37, which is smaller
than dot's ASCII value of 46), that file will be listed first:
@example
$ touch 1.0.5_src.tar.gz 1.0%zzzzz.gz
1.0%zzzzz.gz
1.0.5_src.tar.gz
@end example
The same reasoning applies to the following example: The character
@samp{@code{.}} has ASCII value 46, and is smaller than slash
character @samp{@code{/}} ASCII value 47:
@example
$ cat input5
3.0/
3.0.5
$ sort -V input5
3.0.5
3.0/
@end example
@node Punctuation Characters vs letters
@subsection Punctuation Characters vs letters
Rule 2.2.1 dictates that letters sorts earlier than all non-letters
(after breaking down a string to digits and non-digits parts).
@example
$ cat input6
a%
az
$ sort -V input6
az
a%
@end example
The input strings consist entirely of non-digits, and based on the
above algorithm have only one part, all non-digit characters
(@samp{@code{a%}} vs @samp{@code{az}}).
Each part is then compared lexically,
character-by-character. @samp{@code{a}} compares identically in both
strings.
Rule 2.2.1 dictates that letters (@samp{@code{z}}) sorts earlier than all
non-letters (@samp{@code{%}}) - hence @samp{@code{az}} appears first (despite
@samp{@code{z}} having ASCII value of 122, much bigger than @samp{@code{%}}
with ASCII value 37).
@node Tilde @samp{~} character
@subsection Tilde @samp{~} character
Rule 2.2.2 dictates that tilde character @samp{@code{~}} (ASCII 126) sorts
before all other non-digit characters, including an empty part.
@example
$ cat input7
1
1%
1.2
1~
~
$ sort -V input7
~
1~
1
1%
1.2
@end example
The sorting algorithm starts by breaking down the string into
non-digits (rule 2) and digits parts (rule 3).
In the above input file, only the last line in the input file starts
with a non-digit (@samp{@code{~}}). This is the first part. All other lines
in the input file start with a digit - their first non-digit part is
empty.
Based on rule 2.2.2, tilde @samp{@code{~}} sorts before all other non-digits
including the empty part - hence it comes before all other strings,
and is listed first in the sorted output.
The remaining lines (@code{1}, @code{1%}, @code{1.2}, @code{1~})
follow similar logic: The digit part is extracted (1 for all strings)
and compares identical. The following extracted parts for the remaining
input lines are: empty part, @code{%}, @code{.}, @code{~}.
Tilde sorts before all others, hence the line @code{1~} appears next.
The remaining lines (@code{1}, @code{1%}, @code{1.2}) are sorted based
on previously explained rules.
@node Version sort ignores locale
@subsection Version sort uses ASCII order, ignores locale, unicode characters
In version sort, unicode characters are compared byte-by-byte according
to their binary representation, ignoring their unicode value or the
current locale.
Most commonly, unicode characters (e.g. Greek Small Letter Alpha
U+03B1 @samp{α}) are encoded as UTF-8 bytes (e.g. @samp{α} is encoded as UTF-8
sequence @code{0xCE 0xB1}). The encoding will be compared byte-by-byte,
e.g. first @code{0xCE} (decimal value 206) then @code{0xB1} (decimal value 177).
@example
$ touch aa az "a%" "aα"
$ ls -1 -v
aa
az
a%
aα
@end example
Ignoring the first letter (@code{a}) which is identical in all
strings, the compared values are:
@samp{@code{a}} and @samp{@code{z}} are letters, and sort earlier than
all other non-digit characters.
Then, percent sign @samp{@code{%}} (ASCII value 37) is compared to the
first byte of the UTF-8 sequence of @samp{@code{α}}, which is 0xCE or 206). The
value 37 is smaller, hence @samp{@code{a%}} is listed before @samp{@code{aα}}.
@node Differences from the official Debian Algorithm
@section Differences from the official Debian Algorithm
The GNU coreutils' version sort algorithm differs slightly from the
official Debian algorithm, in order to accommodate more general usage
and file name listing.
@node Minus/Hyphen and Colon characters
@subsection Minus/Hyphen @samp{-} and Colon @samp{:} characters
In Debian's version string syntax the version consists of three parts:
@example
[epoch:]upstream_version[-debian_revision]
@end example
The @code{epoch} and @code{debian_revision} parts are optional.
Example of such version strings:
@example
60.7.2esr-1~deb9u1
52.9.0esr-1~deb9u1
1:2.3.4-1+b2
327-2
1:1.0.13-3
2:1.19.2-1+deb9u5
@end example
If the @code{debian_revision part} is not present,
hyphen characters @samp{-} are not allowed.
If epoch is not present, colons @samp{:} are not allowed.
If these parts are present, hyphen and/or colons can appear only once
in valid Debian version strings.
In GNU coreutils, such restrictions are not reasonable (a file name can
have many hyphens, a line of text can have many colons).
As a result, in GNU coreutils hyphens and colons are treated exactly
like all other punctuation characters (i.e., they are sorted after
letters. See Punctuation Characters above).
In Debian, these characters are treated differently than in coreutils:
a version string with hyphen will sort before similar strings without
hyphens.
Compare:
@example
$ touch abb ab-cd
$ ls -v -1
abb
ab-cd
@end example
With Debian's @command{dpkg} they will be listed as @code{ab-cd} first and
@code{abb} second.
For further technical details see @uref{https://bugs.gnu.org/35939,bug35939}.
@node Additional hard-coded priorities in GNU coreutils' version sort
@subsection Additional hard-coded priorities in GNU coreutils' version sort
In GNU coreutils' version sort algorithm, the following items have
special priority and sort earlier than all other characters (listed in
order);
@enumerate
@item The empty string
@item The string @samp{@code{.}} (a single dot character, ASCII 46)
@item The string @samp{@code{..}} (two dot characters)
@item Strings start with a dot (@samp{@code{.}}) sort earlier than
strings starting with any other characters.
@end enumerate
Example:
@example
$ printf "%s\n" a "" b "." c ".." ".d20" ".d3" | sort -V
.
..
.d3
.d20
a
b
c
@end example
These priorities make perfect sense for @samp{ls -v}: The special
files dot @samp{@code{.}} and dot-dot @samp{@code{..}} will be listed
first, followed by any hidden files (files starting with a dot),
followed by non-hidden files.
For @samp{sort -V} these priorities might seem arbitrary. However,
because the sorting code is shared between the @command{ls} and @command{sort}
program, the ordering rules are the same.
@node Special handling of file extensions
@subsection Special handling of file extensions
GNU coreutils' version sort algorithm implements specialized handling
of file extensions (or strings that look like file names with
extensions).
This nuanced implementation enables slightly more natural ordering of files.
The additional rules are:
@enumerate
@item
A suffix (i.e., a file extension) is defined as: a dot, followed by a
letter or tilde, followed by one or more letters, digits, or tildes
(possibly repeated more than once), until the end of the string
(technically, matching the regular expression
@code{(\.[A-Za-z~][A-Za-z0-9~]*)*}).
@item
If the strings contains suffixes, the suffixes are temporarily
removed, and the strings are compared without them (using the
@ref{Version-sort ordering rules,algorithm,algorithm} above).
@item
If the suffix-less strings are identical, the suffix is restored and
the entire strings are compared.
@item
If the non-suffixed strings differ, the result is returned and the
suffix is effectively ignored.
@end enumerate
Examples for rule 1:
@itemize
@item
@code{hello-8.txt}: the suffix is @code{.txt}
@item
@code{hello-8.2.txt}: the suffix is @code{.txt}
(@samp{@code{.2}} is not included because the dot is not followed by a letter)
@item
@code{hello-8.0.12.tar.gz}: the suffix is @code{.tar.gz} (@samp{@code{.0.12}}
is not included)
@item
@code{hello-8.2}: no suffix (suffix is an empty string)
@item
@code{hello.foobar65}: the suffix is @code{.foobar65}
@item
@code{gcc-c++-10.8.12-0.7rc2.fc9.tar.bz2}: the suffix is
@code{.fc9.tar.bz2} (@code{.7rc2} is not included as it begins with a digit)
@end itemize
Examples for rule 2:
@itemize
@item
Comparing @code{hello-8.txt} to @code{hello-8.2.12.txt}, the
@code{.txt} suffix is temporarily removed from both strings.
@item
Comparing @code{foo-10.3.tar.gz} to @code{foo-10.tar.xz}, the suffixes
@code{.tar.gz} and @code{.tar.xz} are temporarily removed from the
strings.
@end itemize
Example for rule 3:
@itemize
@item
Comparing @code{hello.foobar65} to @code{hello.foobar4}, the suffixes
(@code{.foobar65} and @code{.foobar4}) are temporarily removed. The
remaining strings are identical (@code{hello}). The suffixes are then
restored, and the entire strings are compared (@code{hello.foobar4} comes
first).
@end itemize
Examples for rule 4:
@itemize
@item
When comparing the strings @code{hello-8.2.txt} and @code{hello-8.10.txt}, the
suffixes (@code{.txt}) are temporarily removed. The remaining strings
(@code{hello-8.2} and @code{hello-8.10}) are compared as previously described
(@code{hello-8.2} comes first).
@slanted{(In this case the suffix removal algorithm
does not have a noticeable effect on the resulting order.)}
@end itemize
@b{How does the suffix-removal algorithm effect ordering results?}
Consider the comparison of hello-8.txt and hello-8.2.txt.
Without the suffix-removal algorithm, the strings will be broken down
to the following parts:
@example
hello- @r{vs} hello- @r{(rule 2, all non-digit characters)}
8 @r{vs} 8 @r{(rule 3, all digit characters)}
.txt @r{vs} . @r{(rule 2)}
empty @r{vs} 2
empty @r{vs} .txt
@end example
The comparison of the third parts (@samp{@code{.}} vs
@samp{@code{.txt}}) will determine that the shorter string comes first -
resulting in @file{hello-8.2.txt} appearing first.
Indeed this is the order in which Debian's @command{dpkg} compares the strings.
A more natural result is that @file{hello-8.txt} should come before
@file{hello-8.2.txt}, and this is where the suffix-removal comes into play:
The suffixes (@code{.txt}) are removed, and the remaining strings are
broken down into the following parts:
@example
hello- @r{vs} hello- @r{(rule 2, all non-digit characters)}
8 @r{vs} 8 @r{(rule 3, all digit characters)}
empty @r{vs} . @r{(rule 2)}
empty @r{vs} 2
@end example
As empty strings sort before non-empty strings, the result is @code{hello-8}
being first.
A real-world example would be listing files such as:
@file{gcc_10.fc9.tar.gz}
and @file{gcc_10.8.12.7rc2.fc9.tar.bz2}: Debian's algorithm would list
@file{gcc_10.8.12.7rc2.fc9.tar.bz2} first, while @samp{ls -v} will list
@file{gcc_10.fc9.tar.gz} first.
These priorities make sense for @samp{ls -v}:
Versioned files will be listed in a more natural order.
For @samp{sort -V} these priorities might seem arbitrary. However,
because the sorting code is shared between the @command{ls} and @command{sort}
program, the ordering rules are the same.
@node Advanced Topics
@section Advanced Topics
@node Comparing two strings using Debian's algorithm
@subsection Comparing two strings using Debian's algorithm
The Debian program @command{dpkg} (available on all Debian and Ubuntu
installations) can compare two strings using the @option{--compare-versions}
option.
To use it, create a helper shell function (simply copy & paste the
following snippet to your shell command-prompt):
@example
compver() @{
dpkg --compare-versions "$1" lt "$2" \
&& printf "%s\n" "$1" "$2" \
|| printf "%s\n" "$2" "$1" ; \
@}
@end example
Then compare two strings by calling compver:
@example
$ compver 8.49 8.5
8.5
8.49
@end example
Note that @command{dpkg} will warn if the strings have invalid syntax:
@example
$ compver "foo07.7z" "foo7a.7z"
dpkg: warning: version 'foo07.7z' has bad syntax:
version number does not start with digit
dpkg: warning: version 'foo7a.7z' has bad syntax:
version number does not start with digit
foo7a.7z
foo07.7z
$ compver "3.0/" "3.0.5"
dpkg: warning: version '3.0/' has bad syntax:
invalid character in version number
3.0.5
3.0/
@end example
To illustrate the different handling of hyphens between Debian and
coreutils' algorithms (see
@ref{Minus/Hyphen and Colon characters}):
@example
$ compver abb ab-cd 2>/dev/null $ printf "abb\nab-cd\n" | sort -V
ab-cd abb
abb ab-cd
@end example
To illustrate the different handling of file extension: (see @ref{Special
handling of file extensions}):
@example
$ compver hello-8.txt hello-8.2.txt 2>/dev/null
hello-8.2.txt
hello-8.txt
$ printf "%s\n" hello-8.txt hello-8.2.txt | sort -V
hello-8.txt
hello-8.2.txt
@end example
@node Reporting bugs or incorrect results
@subsection Reporting bugs or incorrect results
If you suspect a bug in GNU coreutils' version sort (i.e., in the
output of @samp{ls -v} or @samp{sort -V}), please first check the following:
@enumerate
@item
Is the result consistent with Debian's own ordering (using @command{dpkg}, see
@ref{Comparing two strings using Debian's algorithm}) ? If it is, then this
is not a bug - please do not report it.
@item
If the result differs from Debian's, is it explained by one of the
sections in @ref{Differences from the official Debian Algorithm}? If it is,
then this is not a bug - please do not report it.
@item
If you have a question about specific ordering which is not explained
here, please write to @email{coreutils@@gnu.org}, and provide a
concise example that will help us diagnose the issue.
@item
If you still suspect a bug which is not explained by the above, please
write to @email{bug-coreutils@@gnu.org} with a concrete example of the
suspected incorrect output, with details on why you think it is
incorrect.
@end enumerate
@node Other version/natural sort implementations
@subsection Other version/natural sort implementations
As previously mentioned, there are multiple variations on
version/natural sort, each with its own rules. Some examples are:
@itemize
@item
Natural Sorting variants in
@uref{https://rosettacode.org/wiki/Natural_sorting,Rosetta Code}.
@item
Python's @uref{https://pypi.org/project/natsort/,natsort package}
(includes detailed description of their sorting rules:
@uref{https://natsort.readthedocs.io/en/master/howitworks.html,
natsort - how it works}).
@item
Ruby's @uref{https://github.com/github/version_sorter,version_sorter}.
@item
Perl has multiple packages for natual and version sorts
(each likely with its own rules and nuances):
@uref{https://metacpan.org/pod/Sort::Naturally,Sort::Naturally},
@uref{https://metacpan.org/pod/Sort::Versions,Sort::Versions},
@uref{https://metacpan.org/pod/CPAN::Version,CPAN::Version}.
@item
PHP has a built-in function
@uref{https://www.php.net/manual/en/function.natsort.php,natsort}.
@item
NodeJS's @uref{https://www.npmjs.com/package/natural-sort,natural-sort package}.
@item
In zsh, the
@uref{http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers,
glob modifier} @code{*(n)} will expand to files in natural sort order.
@item
When writing @code{C} programs, the GNU libc library (@code{glibc})
provides the
@uref{http://man7.org/linux/man-pages/man3/strverscmp.3.html,
strvercmp(3)} function to compare two strings, and
@uref{http://man7.org/linux/man-pages/man3/versionsort.3.html,versionsort(3)}
function to compare two directory entries (despite the names, they are
not identical to GNU coreutils' version sort ordering).
@item
Using Debian's sorting algorithm in:
@itemize
@item
python: @uref{https://stackoverflow.com/a/4957741,
Stack Overflow Example #4957741}.
@item
NodeJS: @uref{https://www.npmjs.com/package/deb-version-compare,
deb-version-compare}.
@end itemize
@end itemize
@node Related Source code
@subsection Related Source code
@itemize
@item
Debian's code which splits a version string into
@code{epoch/upstream_version/debian_revision} parts:
@uref{https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/parsehelp.c#n191,
parsehelp.c:parseversion()}.
@item
Debian's code which performs the @code{upstream_version} comparison:
@uref{https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/lib/dpkg/version.c#n140,
version.c}.
@item
GNULIB code (used by GNU coreutils) which performs the version comparison:
@uref{https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/filevercmp.c,
filevercmp.c}.
@end itemize

View File

@@ -1,6 +1,6 @@
/* buffer-lcm.c - compute a good buffer size for dealing with two files
Copyright (C) 2002-2017 Free Software Foundation, Inc.
Copyright (C) 2002-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

76
gl/lib/cl-strtod.c Normal file
View File

@@ -0,0 +1,76 @@
/* Convert string to double in the current locale, falling back on the C locale.
Copyright 2019-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
#include <config.h>
#include "cl-strtod.h"
#include <c-strtod.h>
#include <errno.h>
#include <stdlib.h>
#if LONG
# define CL_STRTOD cl_strtold
# define DOUBLE long double
# define C_STRTOD c_strtold
# define STRTOD strtold
#else
# define CL_STRTOD cl_strtod
# define DOUBLE double
# define C_STRTOD c_strtod
# define STRTOD strtod
#endif
/* This function acts like strtod or strtold, except that it falls
back on the C locale if the initial prefix is not parsable in
the current locale. If the prefix is parsable in both locales,
it uses the longer parse, breaking ties in favor of the current locale.
Parse the initial prefix of NPTR as a floating-point number in the
current locale or in the C locale (preferring the locale that
yields the longer parse, or the current locale if there is a tie).
If ENDPTR is not NULL, set *ENDPTR to the first unused byte, or to
NPTR if the prefix cannot be parsed.
If successful, return a number without changing errno.
If the prefix cannot be parsed, return 0 and possibly set errno to EINVAL.
If the number overflows, return an extreme value and set errno to ERANGE.
If the number underflows, return a value close to 0 and set errno to ERANGE.
If there is some other error, return 0 and set errno. */
DOUBLE
CL_STRTOD (char const *nptr, char **restrict endptr)
{
char *end;
DOUBLE d = STRTOD (nptr, &end);
if (*end)
{
int strtod_errno = errno;
char *c_end;
DOUBLE c = C_STRTOD (nptr, &c_end);
if (end < c_end)
d = c, end = c_end;
else
errno = strtod_errno;
}
if (endptr)
*endptr = end;
return d;
}

2
gl/lib/cl-strtod.h Normal file
View File

@@ -0,0 +1,2 @@
double cl_strtod (char const *, char **restrict);
long double cl_strtold (char const *, char **restrict);

2
gl/lib/cl-strtold.c Normal file
View File

@@ -0,0 +1,2 @@
#define LONG 1
#include "cl-strtod.c"

View File

@@ -1,5 +1,5 @@
/* Declare an access pattern hint for files.
Copyright (C) 2010-2017 Free Software Foundation, Inc.
Copyright (C) 2010-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/* Declare an access pattern hint for files.
Copyright (C) 2010-2017 Free Software Foundation, Inc.
Copyright (C) 2010-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Invoke open, but return either a desired file descriptor or -1.
Copyright (C) 2005-2017 Free Software Foundation, Inc.
Copyright (C) 2005-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Invoke open, but return either a desired file descriptor or -1.
Copyright (C) 2005-2017 Free Software Foundation, Inc.
Copyright (C) 2005-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Barebones heap implementation supporting only insert and pop.
Copyright (C) 2010-2017 Free Software Foundation, Inc.
Copyright (C) 2010-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Barebones heap implementation supporting only insert and pop.
Copyright (C) 2010-2017 Free Software Foundation, Inc.
Copyright (C) 2010-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/* Align/Truncate a string in a given screen width
Copyright (C) 2009-2017 Free Software Foundation, Inc.
Copyright (C) 2009-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/* Align/Truncate a string in a given screen width
Copyright (C) 2009-2017 Free Software Foundation, Inc.
Copyright (C) 2009-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
Copyright (C) 1999-2017 Free Software Foundation, Inc.
Copyright (C) 1999-2020 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999 Colin Plumb.
This program is free software: you can redistribute it and/or modify

View File

@@ -1,6 +1,6 @@
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
Copyright (C) 1999-2017 Free Software Foundation, Inc.
Copyright (C) 1999-2020 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999 Colin Plumb.
This program is free software: you can redistribute it and/or modify

View File

@@ -1,6 +1,6 @@
/* Generate random integers.
Copyright (C) 2006-2017 Free Software Foundation, Inc.
Copyright (C) 2006-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Generate random integers.
Copyright (C) 2006-2017 Free Software Foundation, Inc.
Copyright (C) 2006-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Generate random permutations.
Copyright (C) 2006-2017 Free Software Foundation, Inc.
Copyright (C) 2006-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,24 +19,29 @@
#include <config.h>
#include "hash.h"
#include "randperm.h"
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include "count-leading-zeros.h"
#include "hash.h"
#include "verify.h"
#include "xalloc.h"
/* Return the ceiling of the log base 2 of N. If N is zero, return
an unspecified value. */
/* Return the floor of the log base 2 of N. If N is zero, return -1. */
static size_t _GL_ATTRIBUTE_CONST
ceil_lg (size_t n)
static int _GL_ATTRIBUTE_CONST
floor_lg (size_t n)
{
size_t b = 0;
for (n--; n != 0; n /= 2)
b++;
return b;
verify (SIZE_WIDTH <= ULLONG_WIDTH);
return (n == 0 ? -1
: SIZE_WIDTH <= UINT_WIDTH
? UINT_WIDTH - 1 - count_leading_zeros (n)
: SIZE_WIDTH <= ULONG_WIDTH
? ULONG_WIDTH - 1 - count_leading_zeros_l (n)
: ULLONG_WIDTH - 1 - count_leading_zeros_ll (n));
}
/* Return an upper bound on the number of random bytes needed to
@@ -48,10 +53,10 @@ randperm_bound (size_t h, size_t n)
{
/* Upper bound on number of bits needed to generate the first number
of the permutation. */
size_t lg_n = ceil_lg (n);
uintmax_t lg_n = floor_lg (n) + 1;
/* Upper bound on number of bits needed to generated the first H elements. */
size_t ar = lg_n * h;
uintmax_t ar = lg_n * h;
/* Convert the bit count to a byte count. */
size_t bound = (ar + CHAR_BIT - 1) / CHAR_BIT;

View File

@@ -1,6 +1,6 @@
/* Generate buffers of random data.
Copyright (C) 2006-2017 Free Software Foundation, Inc.
Copyright (C) 2006-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Generate buffers of random data.
Copyright (C) 2006-2017 Free Software Foundation, Inc.
Copyright (C) 2006-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/* root-dev-ino.c -- get the device and inode numbers for '/'.
Copyright (C) 2003-2017 Free Software Foundation, Inc.
Copyright (C) 2003-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Root device and inode number checking.
Copyright (C) 2003-2017 Free Software Foundation, Inc.
Copyright (C) 2003-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/* Include and determine availability of smack routines
Copyright (C) 2013-2017 Free Software Foundation, Inc.
Copyright (C) 2013-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Compare integer strings.
Copyright (C) 2005-2017 Free Software Foundation, Inc.
Copyright (C) 2005-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Compare numeric strings. This is an internal include file.
Copyright (C) 1988-2017 Free Software Foundation, Inc.
Copyright (C) 1988-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Compare numeric strings.
Copyright (C) 2005-2017 Free Software Foundation, Inc.
Copyright (C) 2005-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Convert decimal strings with bounds checking and exit on error.
Copyright (C) 2014-2017 Free Software Foundation, Inc.
Copyright (C) 2014-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Convert decimal strings with bounds checking and exit on error.
Copyright (C) 2014-2017 Free Software Foundation, Inc.
Copyright (C) 2014-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* xfts.c -- a wrapper for fts_open
Copyright (C) 2003-2017 Free Software Foundation, Inc.
Copyright (C) 2003-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

24
gl/modules/cl-strtod Normal file
View File

@@ -0,0 +1,24 @@
Description:
Convert string to double in current or C locale.
Files:
lib/cl-strtod.c
lib/cl-strtod.h
Depends-on:
c-strtod
configure.ac:
AC_REQUIRE([AC_C_RESTRICT])
Makefile.am:
lib_SOURCES += cl-strtod.c
Include:
"cl-strtod.h"
License:
GPL
Maintainer:
all

25
gl/modules/cl-strtold Normal file
View File

@@ -0,0 +1,25 @@
Description:
Convert string to long double in current or C locale.
Files:
lib/cl-strtod.c
lib/cl-strtod.h
lib/cl-strtold.c
Depends-on:
c-strtold
configure.ac:
AC_REQUIRE([AC_C_RESTRICT])
Makefile.am:
lib_SOURCES += cl-strtold.c
Include:
"cl-strtod.h"
License:
GPL
Maintainer:
all

View File

@@ -6,7 +6,9 @@ lib/randperm.c
lib/randperm.h
Depends-on:
count-leading-zeros
randint
stdint
xalloc
hash

View File

@@ -2,10 +2,10 @@ diff --git a/modules/tempname b/modules/tempname
index 570ea54..f1be8ff 100644
--- a/modules/tempname
+++ b/modules/tempname
@@ -12,6 +12,8 @@
fcntl-h
@@ -13,6 +13,8 @@
gettimeofday
lstat
mkdir
+randint
+stdbool
stdint

View File

@@ -1,5 +1,5 @@
/* Test that fadvise works as advertised.
Copyright (C) 2010-2017 Free Software Foundation, Inc.
Copyright (C) 2010-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/* Test that mbsalign works as advertised.
Copyright (C) 2010-2017 Free Software Foundation, Inc.
Copyright (C) 2010-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* Test the ISAAC or ISAAC64 pseudorandom number generator.
Copyright (C) 2010-2017 Free Software Foundation, Inc.
Copyright (C) 2010-2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

2
gnulib

Submodule gnulib updated: 21d224dc9e...d279bc6d9f

View File

@@ -1,6 +1,6 @@
# This file is sourced by init.sh, *before* its initialization.
# Copyright (C) 2010-2017 Free Software Foundation, Inc.
# Copyright (C) 2010-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -492,7 +492,7 @@ require_membership_in_two_groups_()
*' '*) ;;
*) skip_ 'requires membership in two groups
this test requires that you be a member of more than one group,
but running 'id -G'\'' either failed or found just one. If you really
but running '\''id -G'\'' either failed or found just one. If you really
are a member of at least two groups, then rerun this test with
COREUTILS_GROUPS set in your environment to the space-separated list
of group names or numbers. E.g.,
@@ -576,6 +576,9 @@ require_sparse_support_()
fi
}
# Libraries needed when we compile a shared library.
gcc_shared_libs_=
# Compile a shared lib using the GCC options for doing so.
# Pass input and output file as parameters respectively.
# Any other optional parmeters are passed to $CC.
@@ -585,7 +588,7 @@ gcc_shared_()
local out=$2
shift 2 || return 1
$CC -Wall -shared --std=gnu99 -fPIC -O2 $* "$in" -o "$out" -ldl
$CC -Wall -shared --std=gnu99 -fPIC -O2 $* "$in" -o "$out" $gcc_shared_libs_
}
# There are a myriad of ways to build shared libs,
@@ -593,8 +596,18 @@ gcc_shared_()
# on platforms that support building them as follows.
require_gcc_shared_()
{
gcc_shared_ '-' 'd.so' -xc < /dev/null 2>&1 \
|| skip_ '$CC -shared ... failed to build a shared lib'
# Try two different values for gcc_shared_libs_.
gcc_shared_libs_='-ldl'
if gcc_shared_ '-' 'd.so' -xc < /dev/null 2>&1; then
:
else
gcc_shared_libs_=
if gcc_shared_ '-' 'd.so' -xc < /dev/null 2>&1; then
:
else
skip_ '$CC -shared ... failed to build a shared lib'
fi
fi
rm -f d.so
}
@@ -610,6 +623,21 @@ mkfifo_or_skip_()
fi
}
trap_sigpipe_or_skip_()
{
(trap '' PIPE && yes | :) 2>&1 | grep -qF 'Broken pipe' ||
skip_ 'trapping SIGPIPE is not supported'
}
require_bash_as_SHELL_()
{
if bash --version >/dev/null 2>&1; then
SHELL='bash'
else
skip_ 'bash is required'
fi
}
# Disable the current test if the working directory seems to have
# the setgid bit set.
skip_if_setgid_()

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise chdir-long's sample main program.
# Copyright (C) 2005-2017 Free Software Foundation, Inc.
# Copyright (C) 2005-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
# boottime.m4 serial 4
# Determine whether this system has infrastructure for obtaining the boot time.
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
# Copyright (C) 1996-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
#serial 26
# Check declarations for this package.
dnl Copyright (C) 1997-2017 Free Software Foundation, Inc.
dnl Copyright (C) 1997-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,

View File

@@ -1,6 +1,6 @@
# Tests for GNU GMP (or any compatible replacement).
dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
dnl Copyright (C) 2008-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,

View File

@@ -1,5 +1,5 @@
#serial 2
dnl Copyright (C) 2007-2017 Free Software Foundation, Inc.
dnl Copyright (C) 2007-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

View File

@@ -2,7 +2,7 @@
dnl Misc type-related macros for coreutils.
# Copyright (C) 1998-2017 Free Software Foundation, Inc.
# Copyright (C) 1998-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -41,6 +41,10 @@ AC_DEFUN([coreutils_MACROS],
AC_DEFINE([ARGMATCH_DIE_DECL], [void usage (int _e)],
[Define to the declaration of the xargmatch failure function.])
# Ensure VLAs are not used.
# Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC
AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
# used by shred
AC_CHECK_FUNCS_ONCE([directio])

View File

@@ -7,7 +7,7 @@ m4_pattern_forbid([^gl_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
# directory of the coreutils package.
# Copyright (C) 1998-2017 Free Software Foundation, Inc.
# Copyright (C) 1998-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
# stat-prog.m4 serial 7
# Record the prerequisites of src/stat.c from the coreutils package.
# Copyright (C) 2002-2017 Free Software Foundation, Inc.
# Copyright (C) 2002-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
# xattr.m4 - check for Extended Attributes (Linux)
# serial 3
# Copyright (C) 2003-2017 Free Software Foundation, Inc.
# Copyright (C) 2003-2020 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

1
man/.gitignore vendored
View File

@@ -3,6 +3,7 @@ Makefile.in
b2sum.1
base32.1
base64.1
basenc.1
basename.1
cat.1
chgrp.1

38
man/basenc.x Normal file
View File

@@ -0,0 +1,38 @@
'\" Copyright (C) 2018-2020 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
'\" There is NO WARRANTY, to the extent permitted by law.
[NAME]
basenc \- Encode/decode data and print to standard output
[DESCRIPTION]
.\" Add any additional description here
[ENCODINGS EXAMPLES]
.PP
.nf
.RS
$ printf '\\376\\117\\202' | basenc \-\-base64
/k+C
$ printf '\\376\\117\\202' | basenc \-\-base64url
_k-C
$ printf '\\376\\117\\202' | basenc \-\-base32
7ZHYE===
$ printf '\\376\\117\\202' | basenc \-\-base32hex
VP7O4===
$ printf '\\376\\117\\202' | basenc \-\-base16
FE4F82
$ printf '\\376\\117\\202' | basenc \-\-base2lsbf
011111111111001001000001
$ printf '\\376\\117\\202' | basenc \-\-base2msbf
111111100100111110000010
$ printf '\\376\\117\\202\\000' | basenc \-\-z85
@.FaC
.RE
.fi

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2017 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2020 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2017 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2020 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2017 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2020 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2017 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2020 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
@@ -9,20 +9,20 @@ du \- estimate file space usage
.\" Add any additional description here
[PATTERNS]
PATTERN is a shell pattern (not a regular expression). The pattern
.BR ?
.B ?\&
matches any one character, whereas
.BR *
.B *
matches any string (composed of zero, one or multiple characters). For
example,
.BR *.o
.B *.o
will match any files whose names end in
.BR .o .
Therefore, the command
.IP
.B du --exclude=\(aq*.o\(aq
.B du \-\-exclude=\(aq*.o\(aq
.PP
will skip all files and subdirectories ending in
.BR .o
.B .o
(including the file
.BR .o
.B .o
itself).

View File

@@ -1,4 +1,67 @@
'\" Copyright (C) 1998-2020 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
'\" There is NO WARRANTY, to the extent permitted by law.
[NAME]
env \- run a program in a modified environment
[DESCRIPTION]
.\" Add any additional description here
[OPTIONS]
.SS "\-S/\-\-split\-string usage in scripts"
The
.B \-S
option allows specifying multiple parameters in a script.
Running a script named
.B 1.pl
containing the following first line:
.PP
.RS
.nf
#!/usr/bin/env \-S perl \-w \-T
\&...
.fi
.RE
.PP
Will execute
.B "perl \-w \-T 1.pl".
.PP
Without the
.B '\-S'
parameter the script will likely fail with:
.PP
.RS
.nf
/usr/bin/env: 'perl \-w \-T': No such file or directory
.fi
.RE
.PP
See the full documentation for more details.
.PP
.SS "\-\-default-signal[=SIG]" usage
This option allows setting a signal handler to its default
action, which is not possible using the traditional shell
trap command. The following example ensures that seq
will be terminated by SIGPIPE no matter how this signal
is being handled in the process invoking the command.
.PP
.RS
.nf
sh \-c 'env \-\-default-signal=PIPE seq inf | head \-n1'
.fi
.RE
.PP
[NOTES]
POSIX's exec(2) pages says:
.RS
"many existing applications wrongly assume that they start with certain
signals set to the default action and/or unblocked.... Therefore, it is best
not to block or ignore signals across execs without explicit reason to do so,
and especially not to block signals across execs of arbitrary (not closely
cooperating) programs."
.RE
[SEE ALSO]
sigaction(2), sigprocmask(2), signal(7)

View File

@@ -1,7 +1,7 @@
# Make coreutils man pages. -*-Makefile-*-
# This is included by the top-level Makefile.am.
# Copyright (C) 2002-2017 Free Software Foundation, Inc.
# Copyright (C) 2002-2020 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -69,6 +69,7 @@ man/b2sum.1: src/b2sum$(EXEEXT)
man/base32.1: src/base32$(EXEEXT)
man/base64.1: src/base64$(EXEEXT)
man/basename.1: src/basename$(EXEEXT)
man/basenc.1: src/basenc$(EXEEXT)
man/cat.1: src/cat$(EXEEXT)
man/chcon.1: src/chcon$(EXEEXT)
man/chgrp.1: src/chgrp$(EXEEXT)

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 1998-2017 Free Software Foundation, Inc.
'\" Copyright (C) 1998-2020 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.
@@ -13,7 +13,7 @@ documents the GNU version of
removes each specified file. By default, it does not remove
directories.
.P
If the \fI\-I\fR or \fI\-\-interactive\=once\fR option is given,
If the \fI\-I\fR or \fI\-\-interactive=once\fR option is given,
and there are more than three files or the \fI\-r\fR, \fI\-R\fR,
or \fI\-\-recursive\fR are given, then
.B rm
@@ -22,7 +22,7 @@ the response is not affirmative, the entire command is aborted.
.P
Otherwise, if a file is unwritable, standard input is a terminal, and
the \fI\-f\fR or \fI\-\-force\fR option is not given, or the
\fI\-i\fR or \fI\-\-interactive\=always\fR option is given,
\fI\-i\fR or \fI\-\-interactive=always\fR option is given,
.B rm
prompts the user for whether to remove the file. If the response is
not affirmative, the file is skipped.

View File

@@ -3,4 +3,4 @@ stat \- display file or file system status
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
stat(2), statfs(2)
stat(2), statfs(2), statx(2)

View File

@@ -1,4 +1,4 @@
'\" Copyright (C) 2009-2017 Free Software Foundation, Inc.
'\" Copyright (C) 2009-2020 Free Software Foundation, Inc.
'\"
'\" This is free software. You may redistribute copies of it under the terms
'\" of the GNU General Public License <https://www.gnu.org/licenses/gpl.html>.

View File

@@ -1,4 +1,19 @@
[NAME]
test \- check file types and compare values
[SYNOPSIS]
.B test
.I EXPRESSION
.br
.B test
.br
.\" \& tells doclifter the brackets are literal (Bug#31803).
.B [\&
.I EXPRESSION
.B ]\&
.br
.B "[\& ]\&"
.br
.B [\&
.I OPTION
[DESCRIPTION]
.\" Add any additional description here

View File

@@ -1,8 +1,9 @@
# List of files which contain translatable strings.
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
# Copyright (C) 1996-2020 Free Software Foundation, Inc.
# These are nominally temporary...
lib/argmatch.c
lib/argmatch.h
lib/closein.c
lib/closeout.c
lib/copy-acl.c
@@ -33,8 +34,8 @@ lib/xstrtol-error.c
# Package source files
src/base64.c
src/basename.c
src/basenc.c
src/cat.c
src/chcon.c
src/chgrp.c

View File

@@ -0,0 +1 @@
build/

View File

@@ -0,0 +1,174 @@
Building older GNU coreutils versions on newer systems
======================================================
Overview
--------
Some older GNU coreutils fail to build on newer GNU/Linux systems.
This happens with Coreutils version 8.29 and earlier, on systems
using GlibC version 2.28 or newer, Such as Debian 10, CentOS 8, Fedora 29.
A typical error is:
$ wget https://ftp.gnu.org/gnu/coreutils/coreutils-7.6.tar.xz
$ tar -xf coreutils-7.6.tar.xz
$ cd coreutils-7.6
$ ./configure
$ make
[...]
freadahead.c: In function 'freadahead':
freadahead.c:83:3: error: #error "Please port gnulib freadahead.c to
your platform! Look at the definition of fflush,
fread, ungetc on your system, then report this
to bug-gnulib."
[...]
make[4]: *** [Makefile:1700: freadahead.o] Error 1
Other similar errors mention 'freadptr', 'freadseek','fseterr'.
Older version (pre 7.2) mention 'tee','eaccess','futimens'.
Details
-------
GLibC version 2.28 removed non-standed headre file (libio.h) and some
internal symbols which were used by gnulib (a core component of GNU coreutils).
These were announced as 'deprecated' in vesion 2.27 [1], and removed in
version 2.28. Gnulib code was adjusted shortly after [2],
but the code changes obviously can't be retroactively made to
previously-released coreutils versions.
[1] https://sourceware.org/ml/libc-announce/2018/msg00000.html
[2] https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html
Older coreutils versions defined functions that were later picked-up
by glibc ('tee','eaccess','futimens') resulting in conflicts.
See the patches for the exact code changes.
Supplied patches
----------------
The patch files in this directory change the source code of older
coreutils versions, enabling successful build on newer systems.
Some versions require different patches.
Coreutils Versions Patch file
5.0 coreutils-5.0-on-glibc-2.28.diff
5.97 to 6.9 coreutils-5.97-on-glibc-2.28.diff
6.10 coreutils-6.10-on-glibc-2.28.diff
6.11 coreutils-6.11-on-glibc-2.28.diff
6.12 coreutils-6.12-on-glibc-2.28.diff
7.2 to 8.3 coreutils-7.2-on-glibc-2.28.diff
8.4 to 8.12 coreutils-8.4-on-glibc-2.28.diff
8.13 to 8.16 coreutils-8.13-on-glibc-2.28.diff
8.17 coreutils-8.17-on-glibc-2.28.diff
8.18 to 8.23 coreutils-8.18-on-glibc-2.28.diff
8.24 to 8.29 coreutils-8.24-on-glibc-2.28.diff
8.30 and newer [builds without patching]
Manual build
------------
1. Download the desired version from https://ftp.gnu.org/gnu/coreutils .
2. Patch using the corresponding patch file (see table above).
3. Configure the build, optionally adding the version number
to the executables, to ensure they will not conflict with existing
(newer) executables
4. Build with 'make'
5. Optionally install with 'sudo make install'
Example:
wget https://ftp.gnu.org/gnu/coreutils/coreutils-5.97.tar.gz
tar -xf coreutils-5.97.tar.gz
cd coreutils-5.97
patch -p1 < ../coreutils-5.97-on-glibc-2.28.diff
./configure --program-suffix=-5.97
make
sudo make install
This will install the programs (e.g. 'sort', 'head) in
/usr/local/bin, with "-5.97" added to each program name (e.g. 'sort-5.97',
'head-5.97').
NOTE:
With very old versions (5.X and 6.X), running "./configure" will
hang for a long time at the following step:
"checking for mktime..."
But will eventually continue successfully.
Automated build
---------------
The script 'build-older-versions.sh' automatically performs the manual steps
listed above. The script installs each package in a separate directory:
Programs in `$HOME/old-coreutils/coreutils-{VERSION}/bin`,
manual pages in `$HOME/old-coreutils/coreutils-{VERSION}/share/man`,
PDF manual in `$HOME/old-coreutils/coreutils-{VERSION}/share/doc`,
INFO pages in `$HOME/old-coreutils/coreutils-{VERSION}/share/info`.
It will also create symlinks to all version in a common directory
`$HOME/old-coreutils/bin`.
Example, running the following commands:
./build-older-versions.sh 5.0
./build-older-versions.sh 5.97
./build-older-versions.sh 6.12
./build-older-versions.sh 7.6
Will download, patch, build and install the programs for GNU coreutils
versions 5.0,5.97,6.12,7.6 in `$HOME/old-coreutils/bin` :
$ ls $HOME/old-coreutils/bin
[-5.97 id-5.0 sha224sum-7.6
[-6.12 id-5.97 sha256sum-6.12
[-7.6 id-6.12 sha256sum-7.6
base64-6.12 id-7.6 sha384sum-6.12
base64-7.6 install-5.0 sha384sum-7.6
basename-5.0 install-5.97 sha512sum-6.12
basename-5.97 install-6.12 sha512sum-7.6
basename-6.12 install-7.6 shred-5.0
basename-7.6 join-5.0 shred-5.97
cat-5.0 join-5.97 shred-6.12
cat-5.97 join-6.12 shred-7.6
cat-6.12 join-7.6 shuf-6.12
cat-7.6 kill-5.0 shuf-7.6
chcon-6.12 kill-5.97 sleep-5.0
chcon-7.6 kill-6.12 sleep-5.97
chgrp-5.0 kill-7.6 sleep-6.12
chgrp-5.97 link-5.0 sleep-7.6
chgrp-6.12 link-5.97 sort-5.0
chgrp-7.6 link-6.12 sort-5.97
chmod-5.0 link-7.6 sort-6.12
chmod-5.97 ln-5.0 sort-7.6
chmod-6.12 ln-5.97 split-5.0
chmod-7.6 ln-6.12 split-5.97
chown-5.0 ln-7.6 split-6.12
[... many more files ...]
By adding the directory to your $PATH, older versions can be easily used:
export PATH=$PATH:$HOME/old-coreutils/bin
export MANPATH=$MANPATH:$HOME/old-coreutils/man
========================================================================
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the "GNU Free
Documentation License" file as part of this distribution.

View File

@@ -0,0 +1,200 @@
#!/bin/sh
#
# Copyright (C) 2019-2020 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
#
# Written by Assaf Gordon and Bernhard Voelker.
# To build all versions since 5.0 (if possible):
# git tag \
# | grep '^v[5678]' \
# | sed 's/^v//' \
# | sort -V \
# | while read f; do \
# ./build-older-versions.sh $f 2>&1 \
# | tee build/build.$f.log ; \
# done
PREFIX="${PREFIX:=$HOME/old-coreutils}"
base=$(basename "$0")
die()
{
echo "$base: error: $*" >&2
exit 1
}
warn()
{
echo "$base: warning: $*" >&2
}
get_patch_file()
{
case "$1" in
5.0) echo coreutils-5.0-on-glibc-2.28.diff ;;
5.97|6.[345679]) echo coreutils-5.97-on-glibc-2.28.diff ;;
6.10) echo coreutils-6.10-on-glibc-2.28.diff ;;
6.11) echo coreutils-6.11-on-glibc-2.28.diff ;;
6.12) echo coreutils-6.12-on-glibc-2.28.diff ;;
7.[23456]|8.[123]) echo coreutils-7.2-on-glibc-2.28.diff ;;
8.[456789]|8.1[012]) echo coreutils-8.4-on-glibc-2.28.diff ;;
8.1[3456]) echo coreutils-8.13-on-glibc-2.28.diff ;;
8.17) echo coreutils-8.17-on-glibc-2.28.diff ;;
8.1[89]|8.2[0123]) echo coreutils-8.18-on-glibc-2.28.diff ;;
8.2[456789]) echo coreutils-8.24-on-glibc-2.28.diff ;;
8.[3456789]*) warn "patch not needed for version '$1'" ;;
5.[12]*|5.9*) die "version '$1' does not have a patch (yet) " \
"use versions 5.0 or 5.97" ;;
7.1) die "version '$1' does not have a patch (yet)" \
"use versions 6.12 or 7.2" ;;
5*|6*|7*|8*) die "non-existing version" ;;
*) die "unknown version" ;;
esac
}
get_url()
{
_base_url="https://ftp.gnu.org/gnu/coreutils/coreutils-$1.tar"
case "$1" in
5.*|6.*|7.*) echo "$_base_url.gz" ;;
8.*) echo "$_base_url.xz" ;;
*) die "unknown version" ;;
esac
}
##
## Setup
##
test -n "$1" \
|| die "missing coreutils version to build (e.g. '6.12')"
cd $(dirname "$0")
patch_file=$(get_patch_file "$1") \
|| die "cannot build version '$1'"
# Test for the patch file if the above returned one.
if test "$patch_file"; then
test -e "$patch_file" \
|| die "internal error: patch file '$patch_file' does not exist"
fi
url=$(get_url "$1")
tarball=$(basename "$url")
mkdir -p "build" \
&& cd "build" \
|| die "creating version build dir 'build' failed"
##
## Download tarball (if needed)
##
if ! test -e "$tarball" ; then
wget -O "$tarball.t" "$url" \
&& mv "$tarball.t" "$tarball" \
|| die "failed to download '$url'"
fi
##
## Extract tarball (if needed)
##
srcdir=${tarball%.tar.*}
if ! test -d "$srcdir" ; then
tar -xvf "$tarball" || die "failed to extract '$tarball'"
fi
##
## Patch (if needed)
##
cd "$srcdir" \
|| die "changing directory to '$srcdir' failed"
# Patch will fail if it was already applied (using "--forward" turns
# that into a no-op). So don't check for failure.
# Is there a way to differentiate between 'already applied' and
# 'failed to apply' ?
test "$patch_file" \
&& patch --ignore-whitespace --batch --forward -p1 < "../../$patch_file"
##
## Configure
##
version="${srcdir#coreutils}" # note: this keeps the '-' in '$version'
vprefix="$PREFIX/coreutils$version"
if ! test -e "Makefile" ; then
./configure \
--program-suffix="$version" \
--prefix="$vprefix" \
|| die "failed to run configure in 'build/$srcdir/'"
fi
##
## Build
##
make -j4 \
|| die "build failed in 'build/$srcdir'"
##
## Install
##
make install \
|| die "make-install failed in 'build/$srcdir' (to '$vprefix')"
# Create convenience links for the executables and manpages in common directory.
(
mkdir -p "$PREFIX/bin" "$PREFIX/man/man1" \
|| die "creating common bin or man directory failed"
cd $vprefix/bin \
|| die "changing directory to just-installed 'bin' directory failed"
for f in *; do
ln -snvf "../coreutils$version/bin/$f" "$PREFIX/bin/$f" \
|| die "creating symlink of executable '$f' failed"
done
share= # older versions do not have 'share'.
cd "$vprefix/share/man/man1" 2>/dev/null \
&& share='/share' \
|| cd "$vprefix/man/man1" \
|| die "changing directory to just-installed 'man/man1' directory failed"
for f in *; do
ln -snfv "../../coreutils$version$share/man/man1/$f" "$PREFIX/man/man1/$f" \
|| die "creating symlink of man page '$f' failed"
done
) || exit 1
# Build and install PDF (if possible).
if make SUBDIRS=. pdf; then
make SUBDIRS=. install-pdf \
|| die "make-install-pdf failed in 'build/$srcdir' (to '$vprefix')"
else
echo "$0: no PDF available"
fi
# Print summary
cat<<EOF
=================================================================
GNU Coreutils$version successfully installed.
Source code in $PWD/build/$srcdir
Installed in $vprefix
symlinks for all programs (all versions) in $PREFIX/bin
manual pages for all programs in $PREFIX/share/man/man1
Run the following command to add all programs to your \$PATH:
export PATH=\$PATH:\$HOME/old-coreutils/bin
export MANPATH=\$MANPATH:\$HOME/old-coreutils/man
EOF

View File

@@ -0,0 +1,75 @@
diff -r -U3 coreutils-5.0/src/Makefile.in coreutils-5.0-patched/src/Makefile.in
--- coreutils-5.0/src/Makefile.in 2003-04-02 07:46:19.000000000 -0700
+++ coreutils-5.0-patched/src/Makefile.in 2019-08-01 19:38:07.440997426 -0600
@@ -209,7 +209,7 @@
printf_LDADD = $(LDADD) @POW_LIB@ @LIBICONV@
# If necessary, add -lm to resolve use of floor, rint, modf.
-seq_LDADD = $(LDADD) @SEQ_LIBM@
+seq_LDADD = $(LDADD) @SEQ_LIBM@ -lm
# If necessary, add -lm to resolve the `pow' reference in lib/strtod.c
# or for the fesetround reference in programs using nanosec.c.
diff -r -U3 coreutils-5.0/src/tee.c coreutils-5.0-patched/src/tee.c
--- coreutils-5.0/src/tee.c 2002-12-15 07:21:45.000000000 -0700
+++ coreutils-5.0-patched/src/tee.c 2019-08-01 19:34:32.374301325 -0600
@@ -32,7 +32,7 @@
#define AUTHORS N_ ("Mike Parker, Richard M. Stallman, and David MacKenzie")
-static int tee (int nfiles, const char **files);
+static int tee_FOO (int nfiles, const char **files);
/* If nonzero, append to output files rather than truncating them. */
static int append;
@@ -146,7 +146,7 @@
/* Do *not* warn if tee is given no file arguments.
POSIX requires that it work when given no arguments. */
- errs = tee (argc - optind, (const char **) &argv[optind]);
+ errs = tee_FOO (argc - optind, (const char **) &argv[optind]);
if (close (STDIN_FILENO) != 0)
error (EXIT_FAILURE, errno, _("standard input"));
@@ -158,7 +158,7 @@
Return 0 if successful, 1 if any errors occur. */
static int
-tee (int nfiles, const char **files)
+tee_FOO (int nfiles, const char **files)
{
FILE **descriptors;
char buffer[BUFSIZ];
diff -r -U3 coreutils-5.0/src/test.c coreutils-5.0-patched/src/test.c
--- coreutils-5.0/src/test.c 2003-02-10 02:19:09.000000000 -0700
+++ coreutils-5.0-patched/src/test.c 2019-08-01 19:35:52.871307966 -0600
@@ -139,7 +139,7 @@
/* Do the same thing access(2) does, but use the effective uid and gid. */
static int
-eaccess (char const *file, int mode)
+eaccess_FOO (char const *file, int mode)
{
static int have_ids;
static uid_t uid, euid;
@@ -635,17 +635,17 @@
case 'r': /* file is readable? */
unary_advance ();
- value = -1 != eaccess (argv[pos - 1], R_OK);
+ value = -1 != eaccess_FOO (argv[pos - 1], R_OK);
return (TRUE == value);
case 'w': /* File is writable? */
unary_advance ();
- value = -1 != eaccess (argv[pos - 1], W_OK);
+ value = -1 != eaccess_FOO (argv[pos - 1], W_OK);
return (TRUE == value);
case 'x': /* File is executable? */
unary_advance ();
- value = -1 != eaccess (argv[pos - 1], X_OK);
+ value = -1 != eaccess_FOO (argv[pos - 1], X_OK);
return (TRUE == value);
case 'O': /* File is owned by you? */

View File

@@ -0,0 +1,51 @@
diff -r -U3 coreutils-6.4/lib/utimens.c coreutils-6.4-patched/lib/utimens.c
--- coreutils-6.4/lib/utimens.c 2006-09-14 03:53:59.000000000 -0600
+++ coreutils-6.4-patched/lib/utimens.c 2019-08-01 19:09:08.228883163 -0600
@@ -73,7 +73,7 @@
Return 0 on success, -1 (setting errno) on failure. */
int
-futimens (int fd ATTRIBUTE_UNUSED,
+futimens_FOO (int fd ATTRIBUTE_UNUSED,
char const *file, struct timespec const timespec[2])
{
/* There's currently no interface to set file timestamps with
@@ -166,5 +166,5 @@
int
utimens (char const *file, struct timespec const timespec[2])
{
- return futimens (-1, file, timespec);
+ return futimens_FOO (-1, file, timespec);
}
diff -r -U3 coreutils-6.4/lib/utimens.h coreutils-6.4-patched/lib/utimens.h
--- coreutils-6.4/lib/utimens.h 2004-11-23 14:39:48.000000000 -0700
+++ coreutils-6.4-patched/lib/utimens.h 2019-08-01 19:08:25.656313704 -0600
@@ -1,3 +1,3 @@
#include "timespec.h"
-int futimens (int, char const *, struct timespec const [2]);
+int futimens_FOO (int, char const *, struct timespec const [2]);
int utimens (char const *, struct timespec const [2]);
diff -r -U3 coreutils-6.4/src/copy.c coreutils-6.4-patched/src/copy.c
--- coreutils-6.4/src/copy.c 2006-10-22 10:54:15.000000000 -0600
+++ coreutils-6.4-patched/src/copy.c 2019-08-01 19:09:42.421340384 -0600
@@ -487,7 +487,7 @@
timespec[0] = get_stat_atime (src_sb);
timespec[1] = get_stat_mtime (src_sb);
- if (futimens (dest_desc, dst_name, timespec) != 0)
+ if (futimens_FOO (dest_desc, dst_name, timespec) != 0)
{
error (0, errno, _("preserving times for %s"), quote (dst_name));
if (x->require_preserve)
diff -r -U3 coreutils-6.4/src/touch.c coreutils-6.4-patched/src/touch.c
--- coreutils-6.4/src/touch.c 2006-10-22 10:54:15.000000000 -0600
+++ coreutils-6.4-patched/src/touch.c 2019-08-01 19:09:34.685236947 -0600
@@ -182,7 +182,7 @@
t = timespec;
}
- ok = (futimens (fd, (fd == STDOUT_FILENO ? NULL : file), t) == 0);
+ ok = (futimens_FOO (fd, (fd == STDOUT_FILENO ? NULL : file), t) == 0);
if (fd == STDIN_FILENO)
{

View File

@@ -0,0 +1,24 @@
diff -r -U3 coreutils-6.10/lib/freadahead.c coreutils-6.10-patched/lib/freadahead.c
--- coreutils-6.10/lib/freadahead.c 2007-11-08 00:32:20.000000000 -0700
+++ coreutils-6.10-patched/lib/freadahead.c 2019-08-01 20:09:03.731243826 -0600
@@ -22,7 +22,7 @@
size_t
freadahead (FILE *fp)
{
-#if defined _IO_ferror_unlocked /* GNU libc, BeOS */
+#if defined _IO_EOF_SEEN || defined _IO_ferror_unlocked /* GNU libc, BeOS */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return 0;
return fp->_IO_read_end - fp->_IO_read_ptr;
diff -r -U3 coreutils-6.10/lib/fseterr.c coreutils-6.10-patched/lib/fseterr.c
--- coreutils-6.10/lib/fseterr.c 2007-11-08 00:32:20.000000000 -0700
+++ coreutils-6.10-patched/lib/fseterr.c 2019-08-01 20:09:16.407416594 -0600
@@ -27,7 +27,7 @@
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. */
-#if defined _IO_ferror_unlocked /* GNU libc, BeOS */
+#if defined _IO_EOF_SEEN || defined _IO_ferror_unlocked /* GNU libc, BeOS */
fp->_flags |= _IO_ERR_SEEN;
#elif defined __sferror /* FreeBSD, NetBSD, OpenBSD, MacOS X, Cygwin */
fp->_flags |= __SERR;

View File

@@ -0,0 +1,34 @@
diff -r -U3 coreutils-6.11/lib/freadahead.c coreutils-6.11-patched/lib/freadahead.c
--- coreutils-6.11/lib/freadahead.c 2008-04-17 03:59:17.000000000 -0600
+++ coreutils-6.11-patched/lib/freadahead.c 2019-08-01 20:20:12.712193242 -0600
@@ -19,10 +19,17 @@
/* Specification. */
#include "freadahead.h"
+/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this
+ * problem by defining it ourselves. FIXME: Do not rely on glibc
+ * internals. */
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
+# define _IO_IN_BACKUP 0x100
+#endif
+
size_t
freadahead (FILE *fp)
{
-#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return 0;
return (fp->_IO_read_end - fp->_IO_read_ptr)
diff -r -U3 coreutils-6.11/lib/fseterr.c coreutils-6.11-patched/lib/fseterr.c
--- coreutils-6.11/lib/fseterr.c 2008-04-17 03:59:17.000000000 -0600
+++ coreutils-6.11-patched/lib/fseterr.c 2019-08-01 20:20:37.868480486 -0600
@@ -27,7 +27,7 @@
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. */
-#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */
fp->_flags |= _IO_ERR_SEEN;
#elif defined __sferror /* FreeBSD, NetBSD, OpenBSD, MacOS X, Cygwin */
fp->_flags |= __SERR;

View File

@@ -0,0 +1,63 @@
diff -r -U3 coreutils-6.12/lib/freadahead.c coreutils-6.12-patched/lib/freadahead.c
--- coreutils-6.12/lib/freadahead.c 2008-05-14 06:53:25.000000000 -0600
+++ coreutils-6.12-patched/lib/freadahead.c 2019-08-01 17:50:52.731658318 -0600
@@ -24,7 +24,7 @@
size_t
freadahead (FILE *fp)
{
-#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return 0;
return (fp->_IO_read_end - fp->_IO_read_ptr)
diff -r -U3 coreutils-6.12/lib/freadptr.c coreutils-6.12-patched/lib/freadptr.c
--- coreutils-6.12/lib/freadptr.c 2008-05-14 06:53:25.000000000 -0600
+++ coreutils-6.12-patched/lib/freadptr.c 2019-08-01 17:51:06.867856472 -0600
@@ -29,7 +29,7 @@
size_t size;
/* Keep this code in sync with freadahead! */
-#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return NULL;
size = fp->_IO_read_end - fp->_IO_read_ptr;
diff -r -U3 coreutils-6.12/lib/freadseek.c coreutils-6.12-patched/lib/freadseek.c
--- coreutils-6.12/lib/freadseek.c 2008-05-14 06:53:25.000000000 -0600
+++ coreutils-6.12-patched/lib/freadseek.c 2019-08-01 17:51:21.264058094 -0600
@@ -34,7 +34,7 @@
freadptrinc (FILE *fp, size_t increment)
{
/* Keep this code in sync with freadptr! */
-#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */
fp->_IO_read_ptr += increment;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
fp_->_p += increment;
diff -r -U3 coreutils-6.12/lib/fseterr.c coreutils-6.12-patched/lib/fseterr.c
--- coreutils-6.12/lib/fseterr.c 2008-05-14 06:53:25.000000000 -0600
+++ coreutils-6.12-patched/lib/fseterr.c 2019-08-01 17:51:36.668273645 -0600
@@ -29,7 +29,7 @@
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. */
-#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */
fp->_flags |= _IO_ERR_SEEN;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
fp_->_flags |= __SERR;
diff -r -U3 coreutils-6.12/lib/stdio-impl.h coreutils-6.12-patched/lib/stdio-impl.h
--- coreutils-6.12/lib/stdio-impl.h 2008-05-14 06:53:25.000000000 -0600
+++ coreutils-6.12-patched/lib/stdio-impl.h 2019-08-01 17:49:51.518798189 -0600
@@ -18,6 +18,12 @@
the same implementation of stdio extension API, except that some fields
have different naming conventions, or their access requires some casts. */
+/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this
+ * problem by defining it ourselves. FIXME: Do not rely on glibc
+ * internals. */
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
+# define _IO_IN_BACKUP 0x100
+#endif
/* BSD stdio derived implementations. */

View File

@@ -0,0 +1,75 @@
diff -r -U3 coreutils-7.6/lib/freadahead.c coreutils-7.6-patched/lib/freadahead.c
--- coreutils-7.6/lib/freadahead.c 2009-05-03 23:46:33.000000000 -0600
+++ coreutils-7.6-patched/lib/freadahead.c 2019-08-01 17:30:54.589238442 -0600
@@ -25,7 +25,7 @@
size_t
freadahead (FILE *fp)
{
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return 0;
return (fp->_IO_read_end - fp->_IO_read_ptr)
diff -r -U3 coreutils-7.6/lib/freadptr.c coreutils-7.6-patched/lib/freadptr.c
--- coreutils-7.6/lib/freadptr.c 2009-05-03 23:46:33.000000000 -0600
+++ coreutils-7.6-patched/lib/freadptr.c 2019-08-01 17:34:10.692659598 -0600
@@ -29,7 +29,7 @@
size_t size;
/* Keep this code in sync with freadahead! */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return NULL;
size = fp->_IO_read_end - fp->_IO_read_ptr;
diff -r -U3 coreutils-7.6/lib/freadseek.c coreutils-7.6-patched/lib/freadseek.c
--- coreutils-7.6/lib/freadseek.c 2009-05-03 23:46:33.000000000 -0600
+++ coreutils-7.6-patched/lib/freadseek.c 2019-08-01 17:34:41.013164702 -0600
@@ -34,7 +34,7 @@
freadptrinc (FILE *fp, size_t increment)
{
/* Keep this code in sync with freadptr! */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_IO_read_ptr += increment;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
fp_->_p += increment;
diff -r -U3 coreutils-7.6/lib/fseeko.c coreutils-7.6-patched/lib/fseeko.c
--- coreutils-7.6/lib/fseeko.c 2009-08-09 10:16:11.000000000 -0600
+++ coreutils-7.6-patched/lib/fseeko.c 2019-08-01 17:36:11.030633785 -0600
@@ -44,7 +44,7 @@
#endif
/* These tests are based on fpurge.c. */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_read_end == fp->_IO_read_ptr
&& fp->_IO_write_ptr == fp->_IO_write_base
&& fp->_IO_save_base == NULL)
diff -r -U3 coreutils-7.6/lib/fseterr.c coreutils-7.6-patched/lib/fseterr.c
--- coreutils-7.6/lib/fseterr.c 2009-05-03 23:46:33.000000000 -0600
+++ coreutils-7.6-patched/lib/fseterr.c 2019-08-01 17:34:57.285433551 -0600
@@ -29,7 +29,7 @@
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_flags |= _IO_ERR_SEEN;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
fp_->_flags |= __SERR;
diff -r -U3 coreutils-7.6/lib/stdio-impl.h coreutils-7.6-patched/lib/stdio-impl.h
--- coreutils-7.6/lib/stdio-impl.h 2009-05-03 23:46:34.000000000 -0600
+++ coreutils-7.6-patched/lib/stdio-impl.h 2019-08-01 17:32:36.431051254 -0600
@@ -18,6 +18,12 @@
the same implementation of stdio extension API, except that some fields
have different naming conventions, or their access requires some casts. */
+/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this
+ * problem by defining it ourselves. FIXME: Do not rely on glibc
+ * internals. */
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
+# define _IO_IN_BACKUP 0x100
+#endif
/* BSD stdio derived implementations. */

View File

@@ -0,0 +1,86 @@
diff -r -U3 coreutils-8.13/lib/freadahead.c coreutils-8.13-patched/lib/freadahead.c
--- coreutils-8.13/lib/freadahead.c 2011-08-19 10:09:37.000000000 -0600
+++ coreutils-8.13-patched/lib/freadahead.c 2019-08-01 19:02:30.847557265 -0600
@@ -25,7 +25,7 @@
size_t
freadahead (FILE *fp)
{
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return 0;
return (fp->_IO_read_end - fp->_IO_read_ptr)
diff -r -U3 coreutils-8.13/lib/freadptr.c coreutils-8.13-patched/lib/freadptr.c
--- coreutils-8.13/lib/freadptr.c 2011-08-19 10:09:37.000000000 -0600
+++ coreutils-8.13-patched/lib/freadptr.c 2019-08-01 19:02:30.851557318 -0600
@@ -29,7 +29,7 @@
size_t size;
/* Keep this code in sync with freadahead! */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return NULL;
size = fp->_IO_read_end - fp->_IO_read_ptr;
diff -r -U3 coreutils-8.13/lib/freadseek.c coreutils-8.13-patched/lib/freadseek.c
--- coreutils-8.13/lib/freadseek.c 2011-08-19 10:09:37.000000000 -0600
+++ coreutils-8.13-patched/lib/freadseek.c 2019-08-01 19:02:30.851557318 -0600
@@ -34,7 +34,7 @@
freadptrinc (FILE *fp, size_t increment)
{
/* Keep this code in sync with freadptr! */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_IO_read_ptr += increment;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
fp_->_p += increment;
diff -r -U3 coreutils-8.13/lib/fseeko.c coreutils-8.13-patched/lib/fseeko.c
--- coreutils-8.13/lib/fseeko.c 2011-08-12 02:05:46.000000000 -0600
+++ coreutils-8.13-patched/lib/fseeko.c 2019-08-01 19:02:30.851557318 -0600
@@ -42,7 +42,7 @@
#endif
/* These tests are based on fpurge.c. */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_read_end == fp->_IO_read_ptr
&& fp->_IO_write_ptr == fp->_IO_write_base
&& fp->_IO_save_base == NULL)
diff -r -U3 coreutils-8.13/lib/fseterr.c coreutils-8.13-patched/lib/fseterr.c
--- coreutils-8.13/lib/fseterr.c 2011-08-19 10:09:37.000000000 -0600
+++ coreutils-8.13-patched/lib/fseterr.c 2019-08-01 19:02:30.851557318 -0600
@@ -29,7 +29,7 @@
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_flags |= _IO_ERR_SEEN;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
fp_->_flags |= __SERR;
diff -r -U3 coreutils-8.13/lib/stdio-impl.h coreutils-8.13-patched/lib/stdio-impl.h
--- coreutils-8.13/lib/stdio-impl.h 2011-04-24 11:21:45.000000000 -0600
+++ coreutils-8.13-patched/lib/stdio-impl.h 2019-08-01 19:02:30.851557318 -0600
@@ -18,6 +18,12 @@
the same implementation of stdio extension API, except that some fields
have different naming conventions, or their access requires some casts. */
+/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this
+ * problem by defining it ourselves. FIXME: Do not rely on glibc
+ * internals. */
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
+# define _IO_IN_BACKUP 0x100
+#endif
/* BSD stdio derived implementations. */
diff -r -U3 coreutils-8.13/lib/stdio.in.h coreutils-8.13-patched/lib/stdio.in.h
--- coreutils-8.13/lib/stdio.in.h 2011-06-17 02:06:20.000000000 -0600
+++ coreutils-8.13-patched/lib/stdio.in.h 2019-08-01 19:03:47.484586570 -0600
@@ -697,7 +697,7 @@
/* It is very rare that the developer ever has full control of stdin,
so any use of gets warrants an unconditional warning. Assume it is
always declared, since it is required by C89. */
-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+/* _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); */
#endif

View File

@@ -0,0 +1,86 @@
diff -r -U3 coreutils-8.17/lib/freadahead.c coreutils-8.17-patched/lib/freadahead.c
--- coreutils-8.17/lib/freadahead.c 2012-02-11 02:43:22.000000000 -0700
+++ coreutils-8.17-patched/lib/freadahead.c 2019-08-01 19:19:11.975280339 -0600
@@ -25,7 +25,7 @@
size_t
freadahead (FILE *fp)
{
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return 0;
return (fp->_IO_read_end - fp->_IO_read_ptr)
diff -r -U3 coreutils-8.17/lib/freadptr.c coreutils-8.17-patched/lib/freadptr.c
--- coreutils-8.17/lib/freadptr.c 2012-02-11 02:43:22.000000000 -0700
+++ coreutils-8.17-patched/lib/freadptr.c 2019-08-01 19:19:11.975280339 -0600
@@ -29,7 +29,7 @@
size_t size;
/* Keep this code in sync with freadahead! */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return NULL;
size = fp->_IO_read_end - fp->_IO_read_ptr;
diff -r -U3 coreutils-8.17/lib/freadseek.c coreutils-8.17-patched/lib/freadseek.c
--- coreutils-8.17/lib/freadseek.c 2012-02-11 02:43:22.000000000 -0700
+++ coreutils-8.17-patched/lib/freadseek.c 2019-08-01 19:19:11.975280339 -0600
@@ -34,7 +34,7 @@
freadptrinc (FILE *fp, size_t increment)
{
/* Keep this code in sync with freadptr! */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_IO_read_ptr += increment;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
fp_->_p += increment;
diff -r -U3 coreutils-8.17/lib/fseeko.c coreutils-8.17-patched/lib/fseeko.c
--- coreutils-8.17/lib/fseeko.c 2012-05-04 03:04:45.000000000 -0600
+++ coreutils-8.17-patched/lib/fseeko.c 2019-08-01 19:19:11.975280339 -0600
@@ -47,7 +47,7 @@
#endif
/* These tests are based on fpurge.c. */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_read_end == fp->_IO_read_ptr
&& fp->_IO_write_ptr == fp->_IO_write_base
&& fp->_IO_save_base == NULL)
diff -r -U3 coreutils-8.17/lib/fseterr.c coreutils-8.17-patched/lib/fseterr.c
--- coreutils-8.17/lib/fseterr.c 2012-02-11 02:43:22.000000000 -0700
+++ coreutils-8.17-patched/lib/fseterr.c 2019-08-01 19:19:11.975280339 -0600
@@ -29,7 +29,7 @@
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_flags |= _IO_ERR_SEEN;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
fp_->_flags |= __SERR;
diff -r -U3 coreutils-8.17/lib/stdio-impl.h coreutils-8.17-patched/lib/stdio-impl.h
--- coreutils-8.17/lib/stdio-impl.h 2012-02-11 02:43:22.000000000 -0700
+++ coreutils-8.17-patched/lib/stdio-impl.h 2019-08-01 19:19:11.975280339 -0600
@@ -18,6 +18,12 @@
the same implementation of stdio extension API, except that some fields
have different naming conventions, or their access requires some casts. */
+/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this
+ * problem by defining it ourselves. FIXME: Do not rely on glibc
+ * internals. */
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
+# define _IO_IN_BACKUP 0x100
+#endif
/* BSD stdio derived implementations. */
diff -r -U3 coreutils-8.17/lib/stdio.in.h coreutils-8.17-patched/lib/stdio.in.h
--- coreutils-8.17/lib/stdio.in.h 2012-05-04 03:04:48.000000000 -0600
+++ coreutils-8.17-patched/lib/stdio.in.h 2019-08-01 19:19:37.183560130 -0600
@@ -704,7 +704,7 @@
removed it. */
#undef gets
#if HAVE_RAW_DECL_GETS
-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+/*_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");*/
#endif

View File

@@ -0,0 +1,86 @@
diff -r -U3 coreutils-8.18/lib/freadahead.c coreutils-8.18-patched/lib/freadahead.c
--- coreutils-8.18/lib/freadahead.c 2012-07-15 06:26:12.000000000 -0600
+++ coreutils-8.18-patched/lib/freadahead.c 2019-08-01 19:22:13.169332844 -0600
@@ -25,7 +25,7 @@
size_t
freadahead (FILE *fp)
{
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return 0;
return (fp->_IO_read_end - fp->_IO_read_ptr)
diff -r -U3 coreutils-8.18/lib/freadptr.c coreutils-8.18-patched/lib/freadptr.c
--- coreutils-8.18/lib/freadptr.c 2012-07-15 06:26:12.000000000 -0600
+++ coreutils-8.18-patched/lib/freadptr.c 2019-08-01 19:22:13.169332844 -0600
@@ -29,7 +29,7 @@
size_t size;
/* Keep this code in sync with freadahead! */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return NULL;
size = fp->_IO_read_end - fp->_IO_read_ptr;
diff -r -U3 coreutils-8.18/lib/freadseek.c coreutils-8.18-patched/lib/freadseek.c
--- coreutils-8.18/lib/freadseek.c 2012-07-15 06:26:12.000000000 -0600
+++ coreutils-8.18-patched/lib/freadseek.c 2019-08-01 19:23:20.070111747 -0600
@@ -36,7 +36,7 @@
/* Keep this code in sync with freadptr! */
#if HAVE___FREADPTRINC /* musl libc */
__freadptrinc (fp, increment);
-#elif defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#elif defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_IO_read_ptr += increment;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
fp_->_p += increment;
diff -r -U3 coreutils-8.18/lib/fseeko.c coreutils-8.18-patched/lib/fseeko.c
--- coreutils-8.18/lib/fseeko.c 2012-07-13 08:18:33.000000000 -0600
+++ coreutils-8.18-patched/lib/fseeko.c 2019-08-01 19:22:13.169332844 -0600
@@ -47,7 +47,7 @@
#endif
/* These tests are based on fpurge.c. */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_read_end == fp->_IO_read_ptr
&& fp->_IO_write_ptr == fp->_IO_write_base
&& fp->_IO_save_base == NULL)
diff -r -U3 coreutils-8.18/lib/fseterr.c coreutils-8.18-patched/lib/fseterr.c
--- coreutils-8.18/lib/fseterr.c 2012-07-15 06:26:12.000000000 -0600
+++ coreutils-8.18-patched/lib/fseterr.c 2019-08-01 19:22:13.169332844 -0600
@@ -29,7 +29,7 @@
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_flags |= _IO_ERR_SEEN;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
fp_->_flags |= __SERR;
diff -r -U3 coreutils-8.18/lib/stdio-impl.h coreutils-8.18-patched/lib/stdio-impl.h
--- coreutils-8.18/lib/stdio-impl.h 2012-07-15 06:26:12.000000000 -0600
+++ coreutils-8.18-patched/lib/stdio-impl.h 2019-08-01 19:22:13.169332844 -0600
@@ -18,6 +18,12 @@
the same implementation of stdio extension API, except that some fields
have different naming conventions, or their access requires some casts. */
+/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this
+ * problem by defining it ourselves. FIXME: Do not rely on glibc
+ * internals. */
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
+# define _IO_IN_BACKUP 0x100
+#endif
/* BSD stdio derived implementations. */
diff -r -U3 coreutils-8.18/lib/stdio.in.h coreutils-8.18-patched/lib/stdio.in.h
--- coreutils-8.18/lib/stdio.in.h 2012-06-12 14:43:46.000000000 -0600
+++ coreutils-8.18-patched/lib/stdio.in.h 2019-08-01 19:22:13.169332844 -0600
@@ -704,7 +704,7 @@
removed it. */
#undef gets
#if HAVE_RAW_DECL_GETS
-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+/*_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");*/
#endif

View File

@@ -0,0 +1,86 @@
diff -r -U3 coreutils-8.24/lib/freadahead.c coreutils-8.24-patched/lib/freadahead.c
--- coreutils-8.24/lib/freadahead.c 2015-06-15 23:00:37.000000000 -0600
+++ coreutils-8.24-patched/lib/freadahead.c 2019-08-01 19:47:31.412646436 -0600
@@ -25,7 +25,7 @@
size_t
freadahead (FILE *fp)
{
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return 0;
return (fp->_IO_read_end - fp->_IO_read_ptr)
diff -r -U3 coreutils-8.24/lib/freadptr.c coreutils-8.24-patched/lib/freadptr.c
--- coreutils-8.24/lib/freadptr.c 2015-06-15 23:00:37.000000000 -0600
+++ coreutils-8.24-patched/lib/freadptr.c 2019-08-01 19:47:31.416646500 -0600
@@ -29,7 +29,7 @@
size_t size;
/* Keep this code in sync with freadahead! */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return NULL;
size = fp->_IO_read_end - fp->_IO_read_ptr;
diff -r -U3 coreutils-8.24/lib/freadseek.c coreutils-8.24-patched/lib/freadseek.c
--- coreutils-8.24/lib/freadseek.c 2015-06-15 23:00:37.000000000 -0600
+++ coreutils-8.24-patched/lib/freadseek.c 2019-08-01 19:47:31.416646500 -0600
@@ -36,7 +36,7 @@
/* Keep this code in sync with freadptr! */
#if HAVE___FREADPTRINC /* musl libc */
__freadptrinc (fp, increment);
-#elif defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#elif defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_IO_read_ptr += increment;
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
diff -r -U3 coreutils-8.24/lib/fseeko.c coreutils-8.24-patched/lib/fseeko.c
--- coreutils-8.24/lib/fseeko.c 2015-06-15 23:04:31.000000000 -0600
+++ coreutils-8.24-patched/lib/fseeko.c 2019-08-01 19:47:31.416646500 -0600
@@ -47,7 +47,7 @@
#endif
/* These tests are based on fpurge.c. */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_read_end == fp->_IO_read_ptr
&& fp->_IO_write_ptr == fp->_IO_write_base
&& fp->_IO_save_base == NULL)
diff -r -U3 coreutils-8.24/lib/fseterr.c coreutils-8.24-patched/lib/fseterr.c
--- coreutils-8.24/lib/fseterr.c 2015-06-15 23:00:37.000000000 -0600
+++ coreutils-8.24-patched/lib/fseterr.c 2019-08-01 19:47:31.416646500 -0600
@@ -29,7 +29,7 @@
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_flags |= _IO_ERR_SEEN;
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
diff -r -U3 coreutils-8.24/lib/mountlist.c coreutils-8.24-patched/lib/mountlist.c
--- coreutils-8.24/lib/mountlist.c 2015-07-01 09:08:30.000000000 -0600
+++ coreutils-8.24-patched/lib/mountlist.c 2019-08-01 19:49:22.354401380 -0600
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
+#include <sys/sysmacros.h>
#include "xalloc.h"
diff -r -U3 coreutils-8.24/lib/stdio-impl.h coreutils-8.24-patched/lib/stdio-impl.h
--- coreutils-8.24/lib/stdio-impl.h 2015-06-15 23:00:37.000000000 -0600
+++ coreutils-8.24-patched/lib/stdio-impl.h 2019-08-01 19:47:31.416646500 -0600
@@ -18,6 +18,12 @@
the same implementation of stdio extension API, except that some fields
have different naming conventions, or their access requires some casts. */
+/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this
+ * problem by defining it ourselves. FIXME: Do not rely on glibc
+ * internals. */
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
+# define _IO_IN_BACKUP 0x100
+#endif
/* BSD stdio derived implementations. */

View File

@@ -0,0 +1,88 @@
diff -r -U3 coreutils-8.5/lib/freadahead.c coreutils-8.5-patched/lib/freadahead.c
--- coreutils-8.5/lib/freadahead.c 2010-04-23 07:44:00.000000000 -0600
+++ coreutils-8.5-patched/lib/freadahead.c 2019-08-01 18:35:31.580843463 -0600
@@ -25,7 +25,7 @@
size_t
freadahead (FILE *fp)
{
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return 0;
return (fp->_IO_read_end - fp->_IO_read_ptr)
diff -r -U3 coreutils-8.5/lib/freadptr.c coreutils-8.5-patched/lib/freadptr.c
--- coreutils-8.5/lib/freadptr.c 2010-04-23 07:44:00.000000000 -0600
+++ coreutils-8.5-patched/lib/freadptr.c 2019-08-01 18:35:31.580843463 -0600
@@ -29,7 +29,7 @@
size_t size;
/* Keep this code in sync with freadahead! */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_write_ptr > fp->_IO_write_base)
return NULL;
size = fp->_IO_read_end - fp->_IO_read_ptr;
diff -r -U3 coreutils-8.5/lib/freadseek.c coreutils-8.5-patched/lib/freadseek.c
--- coreutils-8.5/lib/freadseek.c 2010-04-23 07:44:00.000000000 -0600
+++ coreutils-8.5-patched/lib/freadseek.c 2019-08-01 18:35:31.580843463 -0600
@@ -34,7 +34,7 @@
freadptrinc (FILE *fp, size_t increment)
{
/* Keep this code in sync with freadptr! */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_IO_read_ptr += increment;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
fp_->_p += increment;
diff -r -U3 coreutils-8.5/lib/fseeko.c coreutils-8.5-patched/lib/fseeko.c
--- coreutils-8.5/lib/fseeko.c 2010-04-21 12:11:48.000000000 -0600
+++ coreutils-8.5-patched/lib/fseeko.c 2019-08-01 18:35:31.580843463 -0600
@@ -42,7 +42,7 @@
#endif
/* These tests are based on fpurge.c. */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_read_end == fp->_IO_read_ptr
&& fp->_IO_write_ptr == fp->_IO_write_base
&& fp->_IO_save_base == NULL)
diff -r -U3 coreutils-8.5/lib/fseterr.c coreutils-8.5-patched/lib/fseterr.c
--- coreutils-8.5/lib/fseterr.c 2010-04-23 07:44:00.000000000 -0600
+++ coreutils-8.5-patched/lib/fseterr.c 2019-08-01 18:35:31.584843515 -0600
@@ -29,7 +29,7 @@
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_flags |= _IO_ERR_SEEN;
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
fp_->_flags |= __SERR;
diff -r -U3 coreutils-8.5/lib/stdio-impl.h coreutils-8.5-patched/lib/stdio-impl.h
--- coreutils-8.5/lib/stdio-impl.h 2010-04-23 07:44:01.000000000 -0600
+++ coreutils-8.5-patched/lib/stdio-impl.h 2019-08-01 18:35:31.584843515 -0600
@@ -18,6 +18,12 @@
the same implementation of stdio extension API, except that some fields
have different naming conventions, or their access requires some casts. */
+/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this
+ * problem by defining it ourselves. FIXME: Do not rely on glibc
+ * internals. */
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
+# define _IO_IN_BACKUP 0x100
+#endif
/* BSD stdio derived implementations. */
diff -r -U3 coreutils-8.5/lib/stdio.in.h coreutils-8.5-patched/lib/stdio.in.h
--- coreutils-8.5/lib/stdio.in.h 2010-04-21 12:11:57.000000000 -0600
+++ coreutils-8.5-patched/lib/stdio.in.h 2019-08-01 18:26:34.113941755 -0600
@@ -139,7 +139,7 @@
so any use of gets warrants an unconditional warning. Assume it is
always declared, since it is required by C89. */
#undef gets
-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+/*_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");*/
#if @GNULIB_FOPEN@
# if @REPLACE_FOPEN@

View File

@@ -14,10 +14,10 @@ $editor = "vi" if $? != 0 or $editor =~ /^\s*\z/;
# Keywords allowed before the colon on the first line of a commit message:
# program names and a few general category names.
my @valid = qw(
arch b2sum base32 base64 basename cat chcon chgrp chmod chown chroot cksum
comm cp csplit cut date dd df dir dircolors dirname du echo env expand
expr factor false fmt fold groups head hostid hostname id install
join kill link ln logname ls md5sum mkdir mkfifo mknod mktemp
arch b2sum base32 base64 basenc nbasename cat chcon chgrp chmod chown
chroot cksum comm cp csplit cut date dd df dir dircolors dirname du echo
env expand expr factor false fmt fold groups head hostid hostname id
install join kill link ln logname ls md5sum mkdir mkfifo mknod mktemp
mv nice nl nohup nproc numfmt od paste pathchk pinky pr printenv printf
ptx pwd readlink realpath rm rmdir runcon seq sha1sum sha224sum sha256sum
sha384sum sha512sum shred shuf sleep sort split stat stdbuf stty

1
src/.gitignore vendored
View File

@@ -5,6 +5,7 @@ arch
b2sum
base32
base64
basenc
basename
cat
chcon

View File

@@ -1,350 +0,0 @@
/* Base64 encode/decode strings or files.
Copyright (C) 2004-2017 Free Software Foundation, Inc.
This file is part of Base64.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Simon Josefsson <simon@josefsson.org>. */
#include <config.h>
#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
#include "die.h"
#include "error.h"
#include "fadvise.h"
#include "quote.h"
#include "xstrtol.h"
#include "xdectoint.h"
#include "xbinary-io.h"
#define AUTHORS proper_name ("Simon Josefsson")
#if BASE_TYPE == 32
# include "base32.h"
# define PROGRAM_NAME "base32"
#else
# include "base64.h"
# define PROGRAM_NAME "base64"
#endif
static struct option const long_options[] =
{
{"decode", no_argument, 0, 'd'},
{"wrap", required_argument, 0, 'w'},
{"ignore-garbage", no_argument, 0, 'i'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0}
};
void
usage (int status)
{
if (status != EXIT_SUCCESS)
emit_try_help ();
else
{
printf (_("\
Usage: %s [OPTION]... [FILE]\n\
Base%d encode or decode FILE, or standard input, to standard output.\n\
"), program_name, BASE_TYPE);
emit_stdin_note ();
emit_mandatory_arg_note ();
fputs (_("\
-d, --decode decode data\n\
-i, --ignore-garbage when decoding, ignore non-alphabet characters\n\
-w, --wrap=COLS wrap encoded lines after COLS character (default 76).\n\
Use 0 to disable line wrapping\n\
\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
printf (_("\
\n\
The data are encoded as described for the %s alphabet in RFC 4648.\n\
When decoding, the input may contain newlines in addition to the bytes of\n\
the formal %s alphabet. Use --ignore-garbage to attempt to recover\n\
from any other non-alphabet bytes in the encoded stream.\n"),
PROGRAM_NAME, PROGRAM_NAME);
emit_ancillary_info (PROGRAM_NAME);
}
exit (status);
}
#define ENC_BLOCKSIZE (1024*3*10)
#if BASE_TYPE == 32
# define BASE_LENGTH BASE32_LENGTH
/* Note that increasing this may decrease performance if --ignore-garbage
is used, because of the memmove operation below. */
# define DEC_BLOCKSIZE (1024*5)
/* Ensure that BLOCKSIZE is a multiple of 5 and 8. */
verify (ENC_BLOCKSIZE % 40 == 0); /* So padding chars only on last block. */
verify (DEC_BLOCKSIZE % 40 == 0); /* So complete encoded blocks are used. */
# define base_encode base32_encode
# define base_decode_context base32_decode_context
# define base_decode_ctx_init base32_decode_ctx_init
# define base_decode_ctx base32_decode_ctx
# define isbase isbase32
#else
# define BASE_LENGTH BASE64_LENGTH
/* Note that increasing this may decrease performance if --ignore-garbage
is used, because of the memmove operation below. */
# define DEC_BLOCKSIZE (1024*3)
/* Ensure that BLOCKSIZE is a multiple of 3 and 4. */
verify (ENC_BLOCKSIZE % 12 == 0); /* So padding chars only on last block. */
verify (DEC_BLOCKSIZE % 12 == 0); /* So complete encoded blocks are used. */
# define base_encode base64_encode
# define base_decode_context base64_decode_context
# define base_decode_ctx_init base64_decode_ctx_init
# define base_decode_ctx base64_decode_ctx
# define isbase isbase64
#endif
static void
wrap_write (const char *buffer, size_t len,
uintmax_t wrap_column, size_t *current_column, FILE *out)
{
size_t written;
if (wrap_column == 0)
{
/* Simple write. */
if (fwrite (buffer, 1, len, stdout) < len)
die (EXIT_FAILURE, errno, _("write error"));
}
else
for (written = 0; written < len;)
{
uintmax_t cols_remaining = wrap_column - *current_column;
size_t to_write = MIN (cols_remaining, SIZE_MAX);
to_write = MIN (to_write, len - written);
if (to_write == 0)
{
if (fputc ('\n', out) == EOF)
die (EXIT_FAILURE, errno, _("write error"));
*current_column = 0;
}
else
{
if (fwrite (buffer + written, 1, to_write, stdout) < to_write)
die (EXIT_FAILURE, errno, _("write error"));
*current_column += to_write;
written += to_write;
}
}
}
static void
do_encode (FILE *in, FILE *out, uintmax_t wrap_column)
{
size_t current_column = 0;
char inbuf[ENC_BLOCKSIZE];
char outbuf[BASE_LENGTH (ENC_BLOCKSIZE)];
size_t sum;
do
{
size_t n;
sum = 0;
do
{
n = fread (inbuf + sum, 1, ENC_BLOCKSIZE - sum, in);
sum += n;
}
while (!feof (in) && !ferror (in) && sum < ENC_BLOCKSIZE);
if (sum > 0)
{
/* Process input one block at a time. Note that ENC_BLOCKSIZE
is sized so that no pad chars will appear in output. */
base_encode (inbuf, sum, outbuf, BASE_LENGTH (sum));
wrap_write (outbuf, BASE_LENGTH (sum), wrap_column,
&current_column, out);
}
}
while (!feof (in) && !ferror (in) && sum == ENC_BLOCKSIZE);
/* When wrapping, terminate last line. */
if (wrap_column && current_column > 0 && fputc ('\n', out) == EOF)
die (EXIT_FAILURE, errno, _("write error"));
if (ferror (in))
die (EXIT_FAILURE, errno, _("read error"));
}
static void
do_decode (FILE *in, FILE *out, bool ignore_garbage)
{
char inbuf[BASE_LENGTH (DEC_BLOCKSIZE)];
char outbuf[DEC_BLOCKSIZE];
size_t sum;
struct base_decode_context ctx;
base_decode_ctx_init (&ctx);
do
{
bool ok;
size_t n;
unsigned int k;
sum = 0;
do
{
n = fread (inbuf + sum, 1, BASE_LENGTH (DEC_BLOCKSIZE) - sum, in);
if (ignore_garbage)
{
for (size_t i = 0; n > 0 && i < n;)
{
if (isbase (inbuf[sum + i]) || inbuf[sum + i] == '=')
i++;
else
memmove (inbuf + sum + i, inbuf + sum + i + 1, --n - i);
}
}
sum += n;
if (ferror (in))
die (EXIT_FAILURE, errno, _("read error"));
}
while (sum < BASE_LENGTH (DEC_BLOCKSIZE) && !feof (in));
/* The following "loop" is usually iterated just once.
However, when it processes the final input buffer, we want
to iterate it one additional time, but with an indicator
telling it to flush what is in CTX. */
for (k = 0; k < 1 + !!feof (in); k++)
{
if (k == 1 && ctx.i == 0)
break;
n = DEC_BLOCKSIZE;
ok = base_decode_ctx (&ctx, inbuf, (k == 0 ? sum : 0), outbuf, &n);
if (fwrite (outbuf, 1, n, out) < n)
die (EXIT_FAILURE, errno, _("write error"));
if (!ok)
die (EXIT_FAILURE, 0, _("invalid input"));
}
}
while (!feof (in));
}
int
main (int argc, char **argv)
{
int opt;
FILE *input_fh;
const char *infile;
/* True if --decode has been given and we should decode data. */
bool decode = false;
/* True if we should ignore non-base-alphabetic characters. */
bool ignore_garbage = false;
/* Wrap encoded data around the 76:th column, by default. */
uintmax_t wrap_column = 76;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
atexit (close_stdout);
while ((opt = getopt_long (argc, argv, "diw:", long_options, NULL)) != -1)
switch (opt)
{
case 'd':
decode = true;
break;
case 'w':
wrap_column = xdectoumax (optarg, 0, UINTMAX_MAX, "",
_("invalid wrap size"), 0);
break;
case 'i':
ignore_garbage = true;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
usage (EXIT_FAILURE);
break;
}
if (argc - optind > 1)
{
error (0, 0, _("extra operand %s"), quote (argv[optind]));
usage (EXIT_FAILURE);
}
if (optind < argc)
infile = argv[optind];
else
infile = "-";
if (STREQ (infile, "-"))
{
xset_binary_mode (STDIN_FILENO, O_BINARY);
input_fh = stdin;
}
else
{
input_fh = fopen (infile, "rb");
if (input_fh == NULL)
die (EXIT_FAILURE, errno, "%s", quotef (infile));
}
fadvise (input_fh, FADVISE_SEQUENTIAL);
if (decode)
do_decode (input_fh, stdout, ignore_garbage);
else
do_encode (input_fh, stdout, wrap_column);
if (fclose (input_fh) == EOF)
{
if (STREQ (infile, "-"))
die (EXIT_FAILURE, errno, _("closing standard input"));
else
die (EXIT_FAILURE, errno, "%s", quotef (infile));
}
return EXIT_SUCCESS;
}

Some files were not shown because too many files have changed in this diff Show More