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

Diff for /src/usr.bin/file/file.c between version 1.30 and 1.31

version 1.30, 2015/04/24 16:47:32 version 1.31, 2015/04/24 17:10:50
Line 57 
Line 57 
   
 __dead void      usage(void);  __dead void      usage(void);
   
 static void      open_file(struct input_file *, const char *, int *);  static void      prepare_file(struct input_file *, const char *, int *);
   static void      open_file(struct input_file *);
 static void      read_link(struct input_file *);  static void      read_link(struct input_file *);
 static void      test_file(struct magic *, struct input_file *, int);  static void      test_file(struct magic *, struct input_file *, int);
   
Line 91 
Line 92 
 int  int
 main(int argc, char **argv)  main(int argc, char **argv)
 {  {
         struct input_file        inf;          struct input_file       *files = NULL;
         int                      opt, i, width = 0;          int                      opt, i, width = 0;
         FILE                    *f;          FILE                    *f;
         struct magic            *m;          struct magic            *m;
Line 166 
Line 167 
                 exit(0);                  exit(0);
         }          }
   
           files = xcalloc(argc, sizeof *files);
           for (i = 0; i < argc; i++)
                   prepare_file(&files[i], argv[i], &width);
         for (i = 0; i < argc; i++) {          for (i = 0; i < argc; i++) {
                 memset(&inf, 0, sizeof inf);                  open_file(&files[i]);
                 open_file(&inf, argv[i], &width);                  test_file(m, &files[i], width);
                 test_file(m, &inf, width);  
         }          }
         exit(0);          exit(0);
 }  }
   
 static void  static void
 open_file(struct input_file *inf, const char *path, int *width)  prepare_file(struct input_file *inf, const char *path, int *width)
 {  {
         char    *label;          char    *label;
         int      n, retval;          int      n;
   
         inf->path = xstrdup(path);          inf->path = xstrdup(path);
   
Line 186 
Line 189 
         if (n > *width)          if (n > *width)
                 *width = n;                  *width = n;
         inf->label = label;          inf->label = label;
   }
   
   static void
   open_file(struct input_file *inf)
   {
           int      retval;
   
         retval = lstat(inf->path, &inf->sb);          retval = lstat(inf->path, &inf->sb);
         if (retval == -1) {          if (retval == -1) {

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31