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

Diff for /src/usr.bin/grep/grep.c between version 1.32 and 1.33

version 1.32, 2005/04/03 19:12:40 version 1.33, 2005/04/03 19:18:33
Line 29 
Line 29 
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/limits.h>  #include <sys/limits.h>
 #include <sys/stat.h>  #include <sys/stat.h>
   #include <sys/queue.h>
   
 #include <ctype.h>  #include <ctype.h>
 #include <err.h>  #include <err.h>
Line 98 
Line 99 
 int      tail;          /* lines left to print */  int      tail;          /* lines left to print */
 int      lead;          /* number of lines in leading context queue */  int      lead;          /* number of lines in leading context queue */
   
   struct patfile {
           const char              *pf_file;
           SLIST_ENTRY(patfile)     pf_next;
   };
   SLIST_HEAD(, patfile)            patfilelh;
   
 extern char *__progname;  extern char *__progname;
   
 static void  static void
Line 199 
Line 206 
 }  }
   
 static void  static void
 read_patterns(char *fn)  read_patterns(const char *fn)
 {  {
         FILE *f;          FILE *f;
         char *line;          char *line;
Line 230 
Line 237 
 main(int argc, char *argv[])  main(int argc, char *argv[])
 {  {
         int c, lastc, prevoptind, newarg, i;          int c, lastc, prevoptind, newarg, i;
           struct patfile *patfile, *pf_next;
         long l;          long l;
         char *ep;          char *ep;
   
           SLIST_INIT(&patfilelh);
         switch (__progname[0]) {          switch (__progname[0]) {
         case 'e':          case 'e':
                 Eflag++;                  Eflag++;
Line 355 
Line 364 
                         add_pattern(optarg, strlen(optarg));                          add_pattern(optarg, strlen(optarg));
                         break;                          break;
                 case 'f':                  case 'f':
                         read_patterns(optarg);                          patfile = grep_malloc(sizeof(*patfile));
                           patfile->pf_file = optarg;
                           SLIST_INSERT_HEAD(&patfilelh, patfile, pf_next);
                         break;                          break;
                 case 'h':                  case 'h':
                         oflag = 0;                          oflag = 0;
Line 419 
Line 430 
         }          }
         argc -= optind;          argc -= optind;
         argv += optind;          argv += optind;
   
           for (patfile = SLIST_FIRST(&patfilelh); patfile != NULL;
               patfile = pf_next) {
                   pf_next = SLIST_NEXT(patfile, pf_next);
                   read_patterns(patfile->pf_file);
                   free(patfile);
           }
   
         if (argc == 0 && patterns == 0)          if (argc == 0 && patterns == 0)
                 usage();                  usage();

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33