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

Diff for /src/usr.bin/mg/fileio.c between version 1.67 and 1.68

version 1.67, 2005/12/20 05:04:28 version 1.68, 2005/12/20 06:17:36
Line 396 
Line 396 
         return (TRUE);          return (TRUE);
 }  }
   
 struct filelist {  
         struct list     fl_l;  
         char    fl_name[NFILEN + 2];  
 };  
   
 /*  /*
  * return list of file names that match the name in buf.   * return list of file names that match the name in buf.
  */   */
Line 411 
Line 406 
         int              len, preflen, ret;          int              len, preflen, ret;
         DIR             *dirp;          DIR             *dirp;
         struct dirent   *dent;          struct dirent   *dent;
         struct list             *last;          struct list     *last, *current;
         struct filelist *current;          char             fl_name[NFILEN + 2];
         char             prefixx[NFILEN + 1];          char             prefixx[NFILEN + 1];
   
         /*          /*
Line 514 
Line 509 
                                 isdir = 1;                                  isdir = 1;
                 }                  }
   
                 current = malloc(sizeof(struct filelist));                  if ((current = malloc(sizeof(struct list))) == NULL) {
                 if (current == NULL)                          free_file_list(last);
                         break;                          return (NULL);
                   }
                 ret = snprintf(current->fl_name, sizeof(current->fl_name),                  ret = snprintf(fl_name, sizeof(fl_name),
                     "%s%s%s", prefixx, dent->d_name, isdir ? "/" : "");                      "%s%s%s", prefixx, dent->d_name, isdir ? "/" : "");
                 if (ret < 0 || ret >= sizeof(current->fl_name)) {                  if (ret < 0 || ret >= sizeof(fl_name)) {
                         free(current);                          free(current);
                         continue;                          continue;
                 }                  }
                 current->fl_l.l_next = last;                  current->l_next = last;
                 current->fl_l.l_name = current->fl_name;                  current->l_name = strdup(fl_name);
                 last = (struct list *) current;                  last = current;
         }          }
         closedir(dirp);          closedir(dirp);
   

Legend:
Removed from v.1.67  
changed lines
  Added in v.1.68