Changeset 4758

Show
Ignore:
Timestamp:
05/12/07 02:52:20 (1 year ago)
Author:
morris
Message:

Fix a crash when globbing files that contain regexp characters

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wire/trunk/wire/files.c

    r4577 r4758  
    185185wi_array_t * wr_files_full_paths(wi_array_t *paths) { 
    186186        wi_enumerator_t *enumerator, *glob_enumerator; 
    187         wi_array_t              *array
     187        wi_array_t              *array, *globpaths
    188188        wi_string_t             *path, *globpath; 
    189189         
     
    192192         
    193193        while((path = wi_enumerator_next_data(enumerator))) { 
    194                 glob_enumerator = wi_array_data_enumerator(wr_files_glob(path)); 
     194                globpaths = wr_files_glob(path); 
    195195                 
    196                 while((globpath = wi_enumerator_next_data(glob_enumerator))) 
    197                         wi_array_add_data(array, wr_files_full_path(globpath)); 
     196                if(globpaths) { 
     197                        glob_enumerator = wi_array_data_enumerator(wr_files_glob(path)); 
     198                         
     199                        while((globpath = wi_enumerator_next_data(glob_enumerator))) 
     200                                wi_array_add_data(array, wr_files_full_path(globpath)); 
     201                } 
    198202        } 
    199203         
     
    263267        glob_t                  gl; 
    264268        wi_uinteger_t   i; 
     269        int                             status; 
    265270         
    266271        gl.gl_opendir   = wr_files_glob_opendir; 
     
    270275        gl.gl_stat              = wr_files_glob_stat; 
    271276         
    272         if(glob(wi_string_cstring(pattern), GLOB_ALTDIRFUNC, NULL, &gl) != 0) { 
    273                 wr_printf_prefix(WI_STR("glob: %m")); 
     277        status = glob(wi_string_cstring(pattern), GLOB_NOCHECK | GLOB_ALTDIRFUNC , NULL, &gl); 
     278         
     279        if(status != 0) { 
     280                wr_printf_prefix(WI_STR("glob: %s"), strerror(errno)); 
    274281                 
    275282                return NULL;