1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-21 03:12:48 +02:00

tail: support counts > 2**64

* src/tail.c (tail_lines): If skipping all input, use lseek if
possible.
(parse_options): Allow counts to exceed 2**64.
(main): Don’t subtract 1 from UINTMAX_MAX, since it stands
for infinity in this context.
(main): Also don’t read anything when given infinite elisions.
* tests/tail/tail.pl: Adjust to match new behavior.  Rename err-5
test to big-c and expect the invocation to succeed, since ‘tail
-c99999999999999999999’ now succeeds instead of (unnecessarily)
failing.
This commit is contained in:
Paul Eggert
2024-08-10 19:02:44 -07:00
parent 0f9e2719e0
commit cb11d2ab5e
3 changed files with 27 additions and 25 deletions

View File

@@ -68,15 +68,11 @@ my @tv = (
['err-4', '-2cX', '', '', 1,
"$prog: option used in invalid context -- 2\n"],
# Since the number is larger than 2^64, this should provoke
# the diagnostic: 'tail: 99999999999999999999: invalid number of bytes'
# on all systems... probably, for now, maybe.
['err-5', '-c99999999999999999999', '', '', 1,
"$prog: invalid number of bytes: '99999999999999999999'\n",
$normalize_strerror],
['err-6', '-c --', '', '', 1,
"$prog: invalid number of bytes: '-'\n", $normalize_strerror],
['big-c', '-c99999999999999999999', '', '', 0],
# Same as -n 10
['minus-1', '-', '', '', 0],
['minus-2', '-', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0],