From 312c003e12d24cd1c3834978bc2f29534e384b91 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 19 Apr 2022 21:12:30 -0400 Subject: fix repeating last line on piped input --- more.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/more.c b/more.c index b3bbfb6..5c0de59 100644 --- a/more.c +++ b/more.c @@ -52,6 +52,7 @@ struct more_file { char *buf; size_t nbuf; char *path; + int eof; }; static int more_clear = 0; @@ -82,6 +83,8 @@ static ssize_t more_getline(struct more_file *mf, size_t lineno) fgetpos(mf->f, &(mf->tlines[mf->nlines - 1])); if (getline(&(mf->buf), &(mf->nbuf), mf->f) == -1) { + mf->nlines--; + mf->eof = 1; return -1; } -- cgit v1.2.1