CVS commit: src/usr.bin/csplit
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 #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 @@ -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(, 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)
CVS commit: src/usr.bin/csplit
Module Name:src Committed By: wiz Date: Tue Feb 4 19:48:48 UTC 2014 Modified Files: src/usr.bin/csplit: csplit.1 Log Message: Correct number of output files in example. From Jason McIntyre jmc@OpenBSD. While here, also explain about the extra file in the example and put .Ex into its own section in the correct place. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/csplit/csplit.1 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.1 diff -u src/usr.bin/csplit/csplit.1:1.4 src/usr.bin/csplit/csplit.1:1.5 --- src/usr.bin/csplit/csplit.1:1.4 Thu Mar 12 12:35:51 2009 +++ src/usr.bin/csplit/csplit.1 Tue Feb 4 19:48:48 2014 @@ -1,4 +1,4 @@ -.\ $NetBSD: csplit.1,v 1.4 2009/03/12 12:35:51 joerg Exp $ +.\ $NetBSD: csplit.1,v 1.5 2014/02/04 19:48:48 wiz Exp $ .\ .\ Copyright (c) 2002 Tim J. Robbins. .\ All rights reserved. @@ -26,7 +26,7 @@ .\ .\ $FreeBSD: src/usr.bin/csplit/csplit.1,v 1.11 2005/01/25 22:29:51 tjr Exp $ .\ -.Dd January 4, 2009 +.Dd February 4, 2014 .Dt CSPLIT 1 .Os .Sh NAME @@ -121,8 +121,6 @@ After all the patterns have been process .Pp Requesting to split at a line before the current line number or past the end of the file will result in an error. -.Pp -.Ex -std .Sh ENVIRONMENT The .Ev LANG , LC_ALL , LC_COLLATE , @@ -132,12 +130,14 @@ environment variables affect the executi .Nm as described in .Xr environ 7 . +.Sh EXIT STATUS +.Ex -std .Sh EXAMPLES Split the .Xr mdoc 7 file .Pa foo.1 -into one file for each section (up to 20): +into one file for each section (up to 21 plus one for the rest, if any): .Pp .Dl $ csplit -k foo.1 '%^\e.Sh%' '/^\e.Sh/' '{20}' .Pp
CVS commit: src/usr.bin/csplit
Module Name:src Committed By: joerg Date: Wed Aug 31 13:35:47 UTC 2011 Modified Files: src/usr.bin/csplit: csplit.c Log Message: static + __dead To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 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.5 src/usr.bin/csplit/csplit.c:1.6 --- src/usr.bin/csplit/csplit.c:1.5 Mon Jul 13 19:05:40 2009 +++ src/usr.bin/csplit/csplit.c Wed Aug 31 13:35:46 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: csplit.c,v 1.5 2009/07/13 19:05:40 roy Exp $ */ +/* $NetBSD: csplit.c,v 1.6 2011/08/31 13:35:46 joerg 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.5 2009/07/13 19:05:40 roy Exp $); +__RCSID($NetBSD: csplit.c,v 1.6 2011/08/31 13:35:46 joerg Exp $); #endif #include sys/types.h @@ -78,24 +78,24 @@ /* * Command line options */ -const char *prefix; /* File name prefix */ -long sufflen; /* Number of decimal digits for suffix */ -int sflag; /* Suppress output of file names */ -int kflag; /* Keep output if error occurs */ +static const char *prefix; /* File name prefix */ +static long sufflen; /* Number of decimal digits for suffix */ +static int sflag; /* Suppress output of file names */ +static int kflag; /* Keep output if error occurs */ /* * Other miscellaneous globals (XXX too many) */ -long lineno; /* Current line number in input file */ -long reps; /* Number of repetitions for this pattern */ -long nfiles; /* Number of files output so far */ -long maxfiles; /* Maximum number of files we can create */ -char currfile[PATH_MAX]; /* Current output file */ -const char *infn; /* Name of the input file */ -FILE *infile; /* Input file handle */ -FILE *overfile; /* Overflow file for toomuch() */ -off_t truncofs; /* Offset this file should be truncated at */ -int doclean; /* Should cleanup() remove output? */ +static long lineno; /* Current line number in input file */ +static long reps; /* Number of repetitions for this pattern */ +static long nfiles; /* Number of files output so far */ +static long maxfiles; /* Maximum number of files we can create */ +static char currfile[PATH_MAX]; /* Current output file */ +static const char *infn; /* Name of the input file */ +static FILE *infile; /* Input file handle */ +static FILE *overfile; /* Overflow file for toomuch() */ +static off_t truncofs; /* Offset this file should be truncated at */ +static int doclean; /* Should cleanup() remove output? */ int main(int argc, char *argv[]) @@ -224,7 +224,7 @@ exit(1); } -static void +__dead static void handlesig(int sig) { char msg[BUFSIZ];