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 only success only for the return value 0. PR: 213510 Submitted by: J.R. Oldroyd MFC after: 1 week Relnotes: yes
This commit is contained in:
parent
002cc1f914
commit
daa379c5af
@ -195,7 +195,7 @@ main(int argc, char *argv[])
|
|||||||
/* Copy the rest into a new file. */
|
/* Copy the rest into a new file. */
|
||||||
if (!feof(infile)) {
|
if (!feof(infile)) {
|
||||||
ofp = newfile();
|
ofp = newfile();
|
||||||
while ((p = get_line()) != NULL && fputs(p, ofp) == 0)
|
while ((p = get_line()) != NULL && fputs(p, ofp) != EOF)
|
||||||
;
|
;
|
||||||
if (!sflag)
|
if (!sflag)
|
||||||
printf("%jd\n", (intmax_t)ftello(ofp));
|
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. */
|
/* Read and output lines until we get a match. */
|
||||||
first = 1;
|
first = 1;
|
||||||
while ((p = get_line()) != NULL) {
|
while ((p = get_line()) != NULL) {
|
||||||
if (fputs(p, ofp) != 0)
|
if (fputs(p, ofp) == EOF)
|
||||||
break;
|
break;
|
||||||
if (!first && regexec(&cre, p, 0, NULL, 0) == 0)
|
if (!first && regexec(&cre, p, 0, NULL, 0) == 0)
|
||||||
break;
|
break;
|
||||||
@ -453,7 +453,7 @@ do_lineno(const char *expr)
|
|||||||
while (lineno + 1 != lastline) {
|
while (lineno + 1 != lastline) {
|
||||||
if ((p = get_line()) == NULL)
|
if ((p = get_line()) == NULL)
|
||||||
errx(1, "%ld: out of range", lastline);
|
errx(1, "%ld: out of range", lastline);
|
||||||
if (fputs(p, ofp) != 0)
|
if (fputs(p, ofp) == EOF)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!sflag)
|
if (!sflag)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user