summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed/main.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-06-16 08:44:39 +0000
committertjr <tjr@FreeBSD.org>2002-06-16 08:44:39 +0000
commit0588706f27a1201b7e7757a728f12011e932e740 (patch)
tree847a3ce62fb5e4383023c4e8d0d20950d93f5bf0 /usr.bin/sed/main.c
parent2f995a06656a4a1504e1e0037450c56e313d846b (diff)
downloadFreeBSD-src-0588706f27a1201b7e7757a728f12011e932e740.zip
FreeBSD-src-0588706f27a1201b7e7757a728f12011e932e740.tar.gz
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.
Diffstat (limited to 'usr.bin/sed/main.c')
-rw-r--r--usr.bin/sed/main.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c
index c369654..853003f 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);
}
OpenPOWER on IntegriCloud