[BACK]Return to csplit.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / csplit

Diff for /src/usr.bin/csplit/csplit.c between version 1.3 and 1.4

version 1.3, 2006/07/17 22:28:11 version 1.4, 2012/03/04 04:05:15
Line 63 
Line 63 
 void     cleanup(void);  void     cleanup(void);
 void     do_lineno(const char *);  void     do_lineno(const char *);
 void     do_rexp(const char *);  void     do_rexp(const char *);
 char    *getline(void);  char    *get_line(void);
 void     handlesig(int);  void     handlesig(int);
 FILE    *newfile(void);  FILE    *newfile(void);
 void     toomuch(FILE *, long);  void     toomuch(FILE *, long);
Line 195 
Line 195 
         /* 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 = getline()) != NULL && fputs(p, ofp) == 0)                  while ((p = get_line()) != NULL && fputs(p, ofp) == 0)
                         ;                          ;
                 if (!sflag)                  if (!sflag)
                         printf("%jd\n", (intmax_t)ftello(ofp));                          printf("%jd\n", (intmax_t)ftello(ofp));
Line 270 
Line 270 
   
 /* Read a line from the input into a static buffer. */  /* Read a line from the input into a static buffer. */
 char *  char *
 getline(void)  get_line(void)
 {  {
         static char lbuf[LINE_MAX];          static char lbuf[LINE_MAX];
         FILE *src;          FILE *src;
Line 291 
Line 291 
         return (lbuf);          return (lbuf);
 }  }
   
 /* Conceptually rewind the input (as obtained by getline()) back `n' lines. */  /* Conceptually rewind the input (as obtained by get_line()) back `n' lines. */
 void  void
 toomuch(FILE *ofp, long n)  toomuch(FILE *ofp, long n)
 {  {
Line 343 
Line 343 
                 err(1, "%s", currfile);                  err(1, "%s", currfile);
   
         /*          /*
          * getline() will read from here. Next call will truncate to           * get_line() will read from here. Next call will truncate to
          * truncofs in this file.           * truncofs in this file.
          */           */
         overfile = ofp;          overfile = ofp;
Line 391 
Line 391 
   
         /* Read and output lines until we get a match. */          /* Read and output lines until we get a match. */
         first = 1;          first = 1;
         while ((p = getline()) != NULL) {          while ((p = get_line()) != NULL) {
                 if (fputs(p, ofp) != 0)                  if (fputs(p, ofp) != 0)
                         break;                          break;
                 if (!first && regexec(&cre, p, 0, NULL, 0) == 0)                  if (!first && regexec(&cre, p, 0, NULL, 0) == 0)
Line 417 
Line 417 
                  * Positive offset: copy the requested number of lines                   * Positive offset: copy the requested number of lines
                  * after the match.                   * after the match.
                  */                   */
                 while (--ofs > 0 && (p = getline()) != NULL)                  while (--ofs > 0 && (p = get_line()) != NULL)
                         fputs(p, ofp);                          fputs(p, ofp);
                 toomuch(NULL, 0);                  toomuch(NULL, 0);
                 nwritten = (intmax_t)ftello(ofp);                  nwritten = (intmax_t)ftello(ofp);
Line 451 
Line 451 
         while (nfiles < maxfiles - 1) {          while (nfiles < maxfiles - 1) {
                 ofp = newfile();                  ofp = newfile();
                 while (lineno + 1 != lastline) {                  while (lineno + 1 != lastline) {
                         if ((p = getline()) == 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) != 0)
                                 break;                                  break;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4