summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2017-05-12 14:38:09 +0000
committerjilles <jilles@FreeBSD.org>2017-05-12 14:38:09 +0000
commitc6b8911a067c4ec5dd04017960443d5e5b599deb (patch)
treebcfb524e92afe095c3334bd796c78064d36ecd93 /usr.bin
parent0fcf106f9e305567805ecaf3df0db345d798f2de (diff)
downloadFreeBSD-src-c6b8911a067c4ec5dd04017960443d5e5b599deb.zip
FreeBSD-src-c6b8911a067c4ec5dd04017960443d5e5b599deb.tar.gz
MFC r317709: csplit: Fix check of fputs() return value, making csplit work
again. As of r295638, fputs() returns the number of bytes written (if not more than INT_MAX). This broke csplit completely, since csplit assumed success only for the return value 0. PR: 213510 Relnotes: yes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/csplit/csplit.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/csplit/csplit.c b/usr.bin/csplit/csplit.c
index a5e819f..b23c85d 100644
--- a/usr.bin/csplit/csplit.c
+++ b/usr.bin/csplit/csplit.c
@@ -195,7 +195,7 @@ main(int argc, char *argv[])
/* Copy the rest into a new file. */
if (!feof(infile)) {
ofp = newfile();
- while ((p = get_line()) != NULL && fputs(p, ofp) == 0)
+ while ((p = get_line()) != NULL && fputs(p, ofp) != EOF)
;
if (!sflag)
printf("%jd\n", (intmax_t)ftello(ofp));
@@ -392,7 +392,7 @@ do_rexp(const char *expr)
/* Read and output lines until we get a match. */
first = 1;
while ((p = get_line()) != NULL) {
- if (fputs(p, ofp) != 0)
+ if (fputs(p, ofp) == EOF)
break;
if (!first && regexec(&cre, p, 0, NULL, 0) == 0)
break;
@@ -453,7 +453,7 @@ do_lineno(const char *expr)
while (lineno + 1 != lastline) {
if ((p = get_line()) == NULL)
errx(1, "%ld: out of range", lastline);
- if (fputs(p, ofp) != 0)
+ if (fputs(p, ofp) == EOF)
break;
}
if (!sflag)
OpenPOWER on IntegriCloud