From: Paul Eggert Date: Tue, 29 Jul 2025 16:37:44 +0000 (-0700) Subject: tail: optimize tail -n +2**63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10aa908ebd8d487f0dbbc77abb317a94d33f460d;p=thirdparty%2Fcoreutils.git tail: optimize tail -n +2**63 * src/tail.c (tail_lines): Also optimize ‘tail -n +N’ on a seekable file, where OFF_T_MAX <= N < UINTMAX_MAX. Of course this is very unlikely. --- diff --git a/src/tail.c b/src/tail.c index 4715bd1d85..db6aea4a04 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1955,7 +1955,7 @@ tail_lines (char const *pretty_filename, int fd, struct stat const *st, { /* If skipping all input use lseek if possible, for speed. */ off_t pos; - if (n_lines == UINTMAX_MAX && 0 <= (pos = lseek (fd, 0, SEEK_END))) + if (OFF_T_MAX <= n_lines && 0 <= (pos = lseek (fd, 0, SEEK_END))) *read_pos = pos; else {