=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/csplit/csplit.c,v retrieving revision 1.3 retrieving revision 1.4 diff -c -r1.3 -r1.4 *** src/usr.bin/csplit/csplit.c 2006/07/17 22:28:11 1.3 --- src/usr.bin/csplit/csplit.c 2012/03/04 04:05:15 1.4 *************** *** 1,4 **** ! /* $OpenBSD: csplit.c,v 1.3 2006/07/17 22:28:11 deraadt Exp $ */ /* $FreeBSD: src/usr.bin/csplit/csplit.c,v 1.9 2004/03/22 11:15:03 tjr Exp $ */ /*- --- 1,4 ---- ! /* $OpenBSD: csplit.c,v 1.4 2012/03/04 04:05:15 fgsch Exp $ */ /* $FreeBSD: src/usr.bin/csplit/csplit.c,v 1.9 2004/03/22 11:15:03 tjr Exp $ */ /*- *************** *** 63,69 **** void cleanup(void); void do_lineno(const char *); void do_rexp(const char *); ! char *getline(void); void handlesig(int); FILE *newfile(void); void toomuch(FILE *, long); --- 63,69 ---- void cleanup(void); void do_lineno(const char *); void do_rexp(const char *); ! char *get_line(void); void handlesig(int); FILE *newfile(void); void toomuch(FILE *, long); *************** *** 195,201 **** /* Copy the rest into a new file. */ if (!feof(infile)) { ofp = newfile(); ! while ((p = getline()) != NULL && fputs(p, ofp) == 0) ; if (!sflag) printf("%jd\n", (intmax_t)ftello(ofp)); --- 195,201 ---- /* Copy the rest into a new file. */ if (!feof(infile)) { ofp = newfile(); ! while ((p = get_line()) != NULL && fputs(p, ofp) == 0) ; if (!sflag) printf("%jd\n", (intmax_t)ftello(ofp)); *************** *** 270,276 **** /* Read a line from the input into a static buffer. */ char * ! getline(void) { static char lbuf[LINE_MAX]; FILE *src; --- 270,276 ---- /* Read a line from the input into a static buffer. */ char * ! get_line(void) { static char lbuf[LINE_MAX]; FILE *src; *************** *** 291,297 **** return (lbuf); } ! /* Conceptually rewind the input (as obtained by getline()) back `n' lines. */ void toomuch(FILE *ofp, long n) { --- 291,297 ---- return (lbuf); } ! /* Conceptually rewind the input (as obtained by get_line()) back `n' lines. */ void toomuch(FILE *ofp, long n) { *************** *** 343,349 **** err(1, "%s", currfile); /* ! * getline() will read from here. Next call will truncate to * truncofs in this file. */ overfile = ofp; --- 343,349 ---- err(1, "%s", currfile); /* ! * get_line() will read from here. Next call will truncate to * truncofs in this file. */ overfile = ofp; *************** *** 391,397 **** /* Read and output lines until we get a match. */ first = 1; ! while ((p = getline()) != NULL) { if (fputs(p, ofp) != 0) break; if (!first && regexec(&cre, p, 0, NULL, 0) == 0) --- 391,397 ---- /* Read and output lines until we get a match. */ first = 1; ! while ((p = get_line()) != NULL) { if (fputs(p, ofp) != 0) break; if (!first && regexec(&cre, p, 0, NULL, 0) == 0) *************** *** 417,423 **** * Positive offset: copy the requested number of lines * after the match. */ ! while (--ofs > 0 && (p = getline()) != NULL) fputs(p, ofp); toomuch(NULL, 0); nwritten = (intmax_t)ftello(ofp); --- 417,423 ---- * Positive offset: copy the requested number of lines * after the match. */ ! while (--ofs > 0 && (p = get_line()) != NULL) fputs(p, ofp); toomuch(NULL, 0); nwritten = (intmax_t)ftello(ofp); *************** *** 451,457 **** while (nfiles < maxfiles - 1) { ofp = newfile(); while (lineno + 1 != lastline) { ! if ((p = getline()) == NULL) errx(1, "%ld: out of range", lastline); if (fputs(p, ofp) != 0) break; --- 451,457 ---- while (nfiles < maxfiles - 1) { ofp = newfile(); while (lineno + 1 != lastline) { ! if ((p = get_line()) == NULL) errx(1, "%ld: out of range", lastline); if (fputs(p, ofp) != 0) break;