mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-27 05:05:32 +03:00
tail: Count lines correctly when file ends with two or more newlines
Previously, an extra line would be displayed when a file ended in more than one newline.
This commit is contained in:
parent
daa9812cea
commit
7ad212ff63
Notes:
sideshowbarker
2024-07-16 19:56:59 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/7ad212ff63 Pull-request: https://github.com/SerenityOS/serenity/pull/18932
@ -33,7 +33,7 @@ static ErrorOr<off_t> find_seek_pos(Core::File& file, int wanted_lines)
|
||||
TRY(file.seek(pos - 1, SeekMode::SetPosition));
|
||||
|
||||
auto ch = TRY(file.read_value<u8>());
|
||||
if (ch == '\n' && (end - pos) > 1) {
|
||||
if (ch == '\n' && (end - pos) > 0) {
|
||||
lines++;
|
||||
if (lines == wanted_lines)
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user