Module Name:    src
Committed By:   cheusov
Date:           Sun Jul 30 23:02:53 UTC 2017

Modified Files:
        src/usr.bin/csplit: csplit.c

Log Message:
Compare return value of fputs(3) with EOF instead of 0.
This is POSIX-ly correct and fixes csplit(1) on non-NetBSD systems.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/csplit/csplit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/csplit/csplit.c
diff -u src/usr.bin/csplit/csplit.c:1.6 src/usr.bin/csplit/csplit.c:1.7
--- src/usr.bin/csplit/csplit.c:1.6	Wed Aug 31 13:35:46 2011
+++ src/usr.bin/csplit/csplit.c	Sun Jul 30 23:02:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: csplit.c,v 1.6 2011/08/31 13:35:46 joerg Exp $	*/
+/*	$NetBSD: csplit.c,v 1.7 2017/07/30 23:02:53 cheusov Exp $	*/
 /*	$FreeBSD: src/usr.bin/csplit/csplit.c,v 1.9 2004/03/22 11:15:03 tjr Exp$	*/
 
 /*-
@@ -47,7 +47,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: csplit.c,v 1.6 2011/08/31 13:35:46 joerg Exp $");
+__RCSID("$NetBSD: csplit.c,v 1.7 2017/07/30 23:02:53 cheusov Exp $");
 #endif
 
 #include <sys/types.h>
@@ -201,7 +201,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)
 			(void)printf("%jd\n", (intmax_t)ftello(ofp));
@@ -403,7 +403,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;
@@ -429,7 +429,7 @@ do_rexp(const char *expr)
 		 * after the match.
 		 */
 		while (--ofs > 0 && (p = get_line()) != NULL)
-			if (fputs(p, ofp) != 0)
+			if (fputs(p, ofp) == EOF)
 				break;
 		toomuch(NULL, 0L);
 		nwritten = (intmax_t)ftello(ofp);
@@ -465,7 +465,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)

Reply via email to