mirror of
https://anongit.gentoo.org/git/repo/gentoo.git
synced 2025-12-13 21:47:44 +00:00
35 lines
1.4 KiB
Diff
35 lines
1.4 KiB
Diff
https://cgit.git.savannah.gnu.org/cgit/coreutils.git/commit/?id=914972e80dbf82aac9ffe3ff1f67f1028e1a788b
|
|
(Dropped the test to avoid autoreconf.)
|
|
|
|
From 914972e80dbf82aac9ffe3ff1f67f1028e1a788b Mon Sep 17 00:00:00 2001
|
|
From: Hannes Braun <hannes@hannesbraun.net>
|
|
Date: Wed, 24 Sep 2025 21:20:49 +0200
|
|
Subject: tail: fix tailing larger number of lines in regular files
|
|
|
|
* src/tail.c (file_lines): Seek to the previous block instead of the
|
|
beginning (or a little before) of the block that was just scanned.
|
|
Otherwise, the same block is read and scanned (at least partially)
|
|
again. This bug was introduced by commit v9.7-219-g976f8abc1.
|
|
* tests/tail/basic-seek.sh: Add a new test.
|
|
* tests/local.mk: Reference the new test.
|
|
* NEWS: mention the bug fix.
|
|
---
|
|
src/tail.c | 2 +-
|
|
tests/local.mk | 1 +
|
|
tests/tail/basic-seek.sh | 28 ++++++++++++++++++++++++++++
|
|
4 files changed, 34 insertions(+), 1 deletion(-)
|
|
create mode 100755 tests/tail/basic-seek.sh
|
|
|
|
diff --git a/src/tail.c b/src/tail.c
|
|
index b8bef1d91..c7779c77d 100644
|
|
--- a/src/tail.c
|
|
+++ b/src/tail.c
|
|
@@ -596,7 +596,7 @@ file_lines (char const *prettyname, int fd, struct stat const *sb,
|
|
goto free_buffer;
|
|
}
|
|
|
|
- pos = xlseek (fd, -bufsize, SEEK_CUR, prettyname);
|
|
+ pos = xlseek (fd, -(bufsize + bytes_read), SEEK_CUR, prettyname);
|
|
bytes_read = read (fd, buffer, bufsize);
|
|
if (bytes_read < 0)
|
|
{
|