mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 08:43:19 -04:00
Save last displayed file by having the "last" pointer global and save it
during we show the first file's tail. Instead of: tarsier% tail -f 1 2 ==> 1 <== foo bar ==> 2 <== bar foo ==> 2 <== bar2 foo2 Now with this change, we have: tarsier% tail -f 1 2 ==> 1 <== foo bar ==> 2 <== bar foo bar2 foo2 While I'm there, move a comment to where it should belong to. Also, const'ify the "last" static because we will never need to change the contents it points to. MFC After: 1 week
This commit is contained in:
parent
f787023e5a
commit
76628ce773
1 changed files with 8 additions and 6 deletions
|
|
@ -72,6 +72,8 @@ struct kevent *ev;
|
|||
int action = USE_SLEEP;
|
||||
int kq;
|
||||
|
||||
static const file_info_t *last;
|
||||
|
||||
/*
|
||||
* forward -- display the file, from an offset, forward.
|
||||
*
|
||||
|
|
@ -238,16 +240,10 @@ rlines(fp, off, sbp)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* follow -- display the file, from an offset, forward.
|
||||
*
|
||||
*/
|
||||
|
||||
static void
|
||||
show(file_info_t *file)
|
||||
{
|
||||
int ch;
|
||||
static file_info_t *last;
|
||||
|
||||
while ((ch = getc(file->fp)) != EOF) {
|
||||
if (last != file && no_files > 1) {
|
||||
|
|
@ -295,6 +291,10 @@ set_events(file_info_t *files)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* follow -- display the file, from an offset, forward.
|
||||
*
|
||||
*/
|
||||
void
|
||||
follow(file_info_t *files, enum STYLE style, off_t off)
|
||||
{
|
||||
|
|
@ -322,6 +322,8 @@ follow(file_info_t *files, enum STYLE style, off_t off)
|
|||
if (! active)
|
||||
return;
|
||||
|
||||
last = --file;
|
||||
|
||||
kq = kqueue();
|
||||
if (kq < 0)
|
||||
err(1, "kqueue");
|
||||
|
|
|
|||
Loading…
Reference in a new issue