Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/csplit Compare return value of fputs(3) with EOF ins...
details: https://anonhg.NetBSD.org/src/rev/ae0ae31dcca8
branches: trunk
changeset: 355490:ae0ae31dcca8
user: cheusov <cheusov%NetBSD.org@localhost>
date: Sun Jul 30 23:02:53 2017 +0000
description:
Compare return value of fputs(3) with EOF instead of 0.
This is POSIX-ly correct and fixes csplit(1) on non-NetBSD systems.
diffstat:
usr.bin/csplit/csplit.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diffs (54 lines):
diff -r d03c2af2da54 -r ae0ae31dcca8 usr.bin/csplit/csplit.c
--- a/usr.bin/csplit/csplit.c Sun Jul 30 22:53:56 2017 +0000
+++ b/usr.bin/csplit/csplit.c Sun Jul 30 23:02:53 2017 +0000
@@ -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 @@
/* 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 @@
/* 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 @@
* 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 @@
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)
Home |
Main Index |
Thread Index |
Old Index