From 10aa908ebd8d487f0dbbc77abb317a94d33f460d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 29 Jul 2025 09:37:44 -0700 Subject: [PATCH] tail: optimize tail -n +2**63 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * 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. --- src/tail.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 { -- 2.47.2