]> git.ipfire.org Git - thirdparty/coreutils.git/commit
tail: speed up -c N for huge N
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 29 Jul 2025 06:39:30 +0000 (23:39 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 Aug 2025 02:48:05 +0000 (19:48 -0700)
commitd58aa27d067aec2044d3ddd69e35bdefc859b0d9
tree314fa9fb753fe154853b81533b637fb52c438232
parent6439858056d9bc9dd7411df583e60854ace41d17
tail: speed up -c N for huge N

When the user specifies -c N where 2**63 <= N, don’t give
up and use the slow method (which will exhaust memory if
the file is large).  Instead, treat it as N = 2**63 - 1,
since that has equivalent effect.
* src/tail.c (tail_bytes): With -c N and large N, adjust
the code so that lseeks can still be used without
affecting correctness.  Formerly the code gave up and
did a sequential pass through the whole input, which
could easily exhaust memory.
src/tail.c