From 254fac850d1cd86d51edd86ac44ce5b2cfca4902 Mon Sep 17 00:00:00 2001 From: "Tim J. Robbins" Date: Sun, 16 Jun 2002 08:44:39 +0000 Subject: [PATCH] Correct the handling of (for example) the N command by only zeroing the input space in mf_fgets() if we reach the end of all input files. --- usr.bin/sed/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c index c3696544a62..853003f99fd 100644 --- a/usr.bin/sed/main.c +++ b/usr.bin/sed/main.c @@ -315,7 +315,6 @@ mf_fgets(sp, spflag) firstfile = 1; } - sp->len = 0; for (;;) { if (f != NULL && (c = getc(f)) != EOF) { (void)ungetc(c, f); @@ -323,6 +322,7 @@ mf_fgets(sp, spflag) } /* If we are here then either eof or no files are open yet */ if (f == stdin) { + sp->len = 0; lastline = 1; return (0); } @@ -334,6 +334,7 @@ mf_fgets(sp, spflag) } else firstfile = 0; if (files == NULL) { + sp->len = 0; lastline = 1; return (0); }