Diff for /qemu/path.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2018/04/24 18:23:57 version 1.1.1.3, 2018/04/24 18:56:08
Line 38  static int strneq(const char *s1, unsign Line 38  static int strneq(const char *s1, unsign
     return s2[i] == 0;      return s2[i] == 0;
 }  }
   
 static struct pathelem *add_entry(struct pathelem *root, const char *name);  static struct pathelem *add_entry(struct pathelem *root, const char *name,
                                     unsigned char type);
   
 static struct pathelem *new_entry(const char *root,  static struct pathelem *new_entry(const char *root,
                                   struct pathelem *parent,                                    struct pathelem *parent,
Line 56  static struct pathelem *new_entry(const  Line 57  static struct pathelem *new_entry(const 
   
 #define streq(a,b) (strcmp((a), (b)) == 0)  #define streq(a,b) (strcmp((a), (b)) == 0)
   
   /* Not all systems provide this feature */
   #if defined(DT_DIR) && defined(DT_UNKNOWN)
   # define dirent_type(dirent) ((dirent)->d_type)
   # define is_dir_maybe(type)  ((type) == DT_DIR || (type) == DT_UNKNOWN)
   #else
   # define dirent_type(dirent) (1)
   # define is_dir_maybe(type)  (type)
   #endif
   
 static struct pathelem *add_dir_maybe(struct pathelem *path)  static struct pathelem *add_dir_maybe(struct pathelem *path)
 {  {
     DIR *dir;      DIR *dir;
Line 65  static struct pathelem *add_dir_maybe(st Line 75  static struct pathelem *add_dir_maybe(st
   
         while ((dirent = readdir(dir)) != NULL) {          while ((dirent = readdir(dir)) != NULL) {
             if (!streq(dirent->d_name,".") && !streq(dirent->d_name,"..")){              if (!streq(dirent->d_name,".") && !streq(dirent->d_name,"..")){
                 path = add_entry(path, dirent->d_name);                  path = add_entry(path, dirent->d_name, dirent_type(dirent));
             }              }
         }          }
         closedir(dir);          closedir(dir);
Line 73  static struct pathelem *add_dir_maybe(st Line 83  static struct pathelem *add_dir_maybe(st
     return path;      return path;
 }  }
   
 static struct pathelem *add_entry(struct pathelem *root, const char *name)  static struct pathelem *add_entry(struct pathelem *root, const char *name,
                                     unsigned char type)
 {  {
       struct pathelem **e;
   
     root->num_entries++;      root->num_entries++;
   
     root = realloc(root, sizeof(*root)      root = realloc(root, sizeof(*root)
                    + sizeof(root->entries[0])*root->num_entries);                     + sizeof(root->entries[0])*root->num_entries);
       e = &root->entries[root->num_entries-1];
   
       *e = new_entry(root->pathname, root, name);
       if (is_dir_maybe(type)) {
           *e = add_dir_maybe(*e);
       }
   
     root->entries[root->num_entries-1] = new_entry(root->pathname, root, name);  
     root->entries[root->num_entries-1]  
         = add_dir_maybe(root->entries[root->num_entries-1]);  
     return root;      return root;
 }  }
   

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3


unix.superglobalmegacorp.com