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.
This commit is contained in:
Paul Eggert committed 2025-08-03 19:48:05 -07:00
1 parent 3918655d4b
commit 10aa908ebd
1 file changed
+1 -1
+1 -1
View File
@@ -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
{