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

Diff for /src/usr.bin/tail/forward.c between version 1.28 and 1.29

version 1.28, 2015/11/20 01:15:22 version 1.29, 2015/11/21 13:58:56
Line 47 
Line 47 
 #include "extern.h"  #include "extern.h"
   
 static int rlines(struct tailfile *, off_t);  static int rlines(struct tailfile *, off_t);
   static inline void tfprint(FILE *fp);
 static int tfqueue(struct tailfile *tf);  static int tfqueue(struct tailfile *tf);
 static const struct timespec *tfreopen(struct tailfile *tf);  static const struct timespec *tfreopen(struct tailfile *tf);
   
 static int kq = -1;  static int kq = -1;
   
 static void  
 printtail(FILE *fp)  
 {  
         int ch;  
   
         while (!feof(fp) && (ch = getc(fp)) != EOF)  
                 if (putchar(ch) == EOF)  
                         oerr();  
 }  
   
 /*  /*
  * forward -- display the file, from an offset, forward.   * forward -- display the file, from an offset, forward.
  *   *
Line 97 
Line 88 
         if (nfiles < 1)          if (nfiles < 1)
                 return;                  return;
   
         if ((kq = kqueue()) < 0)          if (fflag && (kq = kqueue()) < 0)
                 warn("kqueue");                  warn("kqueue");
   
         for (i = 0; i < nfiles; i++) {          for (i = 0; i < nfiles; i++) {
Line 136 
Line 127 
                                         }                                          }
                                         break;                                          break;
                                 }                                  }
                                 if (ch == '\n' && !--off) {                                  if (ch == '\n' && !--off)
                                         if (!fflag)  
                                                 printtail(tf[i].fp);  
                                         break;                                          break;
                                 }  
                         }                          }
                         break;                          break;
                 case RBYTES:                  case RBYTES:
Line 188 
Line 176 
                         err(1, "Unsupported style");                          err(1, "Unsupported style");
                 }                  }
   
                 if (tfqueue(&(tf[i])) == -1)                  tfprint(tf[i].fp);
                   if (fflag && tfqueue(&(tf[i])) == -1)
                         warn("Unable to follow %s", tf[i].fname);                          warn("Unable to follow %s", tf[i].fname);
   
         }          }
Line 214 
Line 203 
                                         ltf = ctf;                                          ltf = ctf;
                                 }                                  }
                                 clearerr(ctf->fp);                                  clearerr(ctf->fp);
                                 while (!feof(ctf->fp) &&                                  tfprint(ctf->fp);
                                     (ch = getc(ctf->fp)) != EOF) {  
                                         if (putchar(ch) == EOF)  
                                                 oerr();  
                                 }  
                                 if (ferror(ctf->fp)) {                                  if (ferror(ctf->fp)) {
                                         ierr(ctf->fname);                                          ierr(ctf->fname);
                                         fclose(ctf->fp);                                          fclose(ctf->fp);
Line 299 
Line 284 
         }          }
   
         return (0);          return (0);
   }
   
   static inline void
   tfprint(FILE *fp)
   {
           int ch;
   
           while (!feof(fp) && (ch = getc(fp)) != EOF)
                   if (putchar(ch) == EOF)
                           oerr();
 }  }
   
 static int  static int

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29