aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2025-07-29 09:37:44 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2025-08-03 19:48:05 -0700
commit10aa908ebd8d487f0dbbc77abb317a94d33f460d (patch)
tree5d6964c363261a1793b7045f523be38b699bd982
parenttail: refactor SEEK_END and lines (diff)
downloadcoreutils-10aa908ebd8d487f0dbbc77abb317a94d33f460d.tar.gz
coreutils-10aa908ebd8d487f0dbbc77abb317a94d33f460d.zip
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.
-rw-r--r--src/tail.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/tail.c b/src/tail.c
index 4715bd1d8..db6aea4a0 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
{