diff options
author | Jakob Kaivo <jkk@ung.org> | 2022-04-19 21:12:30 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2022-04-19 21:12:30 -0400 |
commit | 312c003e12d24cd1c3834978bc2f29534e384b91 (patch) | |
tree | 257543be6d71913eca59a20c6bc454805ca0c0a7 | |
parent | bd9f014a7108d0a0293ee4c44332ec5659c64313 (diff) |
fix repeating last line on piped input
-rw-r--r-- | more.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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; } |