Date: Fri, 12 May 2017 14:38:09 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r318238 - stable/11/usr.bin/csplit Message-ID: <201705121438.v4CEc9F6069154@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Fri May 12 14:38:09 2017 New Revision: 318238 URL: https://svnweb.freebsd.org/changeset/base/318238 Log: 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 Modified: stable/11/usr.bin/csplit/csplit.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/csplit/csplit.c ============================================================================== --- stable/11/usr.bin/csplit/csplit.c Fri May 12 11:40:58 2017 (r318237) +++ stable/11/usr.bin/csplit/csplit.c Fri May 12 14:38:09 2017 (r318238) @@ -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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705121438.v4CEc9F6069154>