Changeset 5066

Show
Ignore:
Timestamp:
12/04/07 14:32:49 (7 months ago)
Author:
morris
Message:

Pick out substring to search from index correctly, even when decomposing

Files:

Legend:

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

    r5065 r5066  
    637637                name = wi_string_with_cstring(p->fts_name); 
    638638                 
    639                 if(wd_files_name_matches_query(name, query, wi_make_range(0, wi_string_length(name)))) { 
     639                if(wd_files_name_matches_query(name, query, false)) { 
    640640                        /* matched, get size */ 
    641641                        switch(type) { 
     
    727727                        break; 
    728728                 
    729                 index = wi_string_index_of_char(string, WD_FIELD_SEPARATOR, 0); 
    730                  
    731                 if(index != WI_NOT_FOUND) { 
    732                         range.length = index; 
     729                if(wd_files_name_matches_query(string, query, true)) { 
     730                        index = wi_string_index_of_char(string, WD_FIELD_SEPARATOR, 0); 
    733731                         
    734                         if(wd_files_name_matches_query(string, query, range)) { 
    735                                 if(account->files) { 
    736                                         pathrange.location = index + 1; 
    737                                         pathrange.length = wi_string_length(string) - pathrange.location; 
    738                                          
    739                                         if(wi_string_index_of_string_in_range(string, account->files, WI_STRING_CASE_INSENSITIVE, pathrange) == pathrange.location) { 
    740                                                 wi_string_delete_characters_to_index(string, index + pathlength + 1); 
    741                                                  
    742                                                 wd_reply(420, WI_STR("%@"), string); 
    743                                         } 
    744                                 } else { 
    745                                         wi_string_delete_characters_to_index(string, index + 1); 
     732                        if(account->files) { 
     733                                pathrange.location = index + 1; 
     734                                pathrange.length = wi_string_length(string) - pathrange.location; 
     735                                 
     736                                if(wi_string_index_of_string_in_range(string, account->files, WI_STRING_CASE_INSENSITIVE, pathrange) == pathrange.location) { 
     737                                        wi_string_delete_characters_to_index(string, index + pathlength + 1); 
    746738                                         
    747739                                        wd_reply(420, WI_STR("%@"), string); 
    748740                                } 
     741                        } else { 
     742                                wi_string_delete_characters_to_index(string, index + 1); 
     743                                 
     744                                wd_reply(420, WI_STR("%@"), string); 
    749745                        } 
    750746                } 
     
    13241320 
    13251321 
    1326 wi_boolean_t wd_files_name_matches_query(wi_string_t *name, wi_string_t *query, wi_range_t range) { 
     1322wi_boolean_t wd_files_name_matches_query(wi_string_t *name, wi_string_t *query, wi_boolean_t index) { 
    13271323#ifdef HAVE_CORESERVICES_CORESERVICES_H 
    13281324        CFMutableStringRef              nameString; 
    13291325        CFStringRef                             queryString; 
     1326        CFRange                                 range; 
    13301327        wi_boolean_t                    matches; 
    13311328         
     
    13361333        queryString = CFStringCreateWithCString(NULL, wi_string_cstring(query), kCFStringEncodingUTF8); 
    13371334         
    1338         matches = CFStringFindWithOptions(nameString, queryString, CFRangeMake(range.location, range.length),  kCFCompareCaseInsensitive, NULL); 
     1335        if(index) 
     1336                range = CFRangeMake(0, CFStringFind(nameString, CFSTR(WD_FIELD_SEPARATOR_STR), 0).location); 
     1337        else 
     1338                range = CFRangeMake(0, CFStringGetLength(nameString)); 
     1339         
     1340        if(range.length == kCFNotFound) 
     1341                matches = false; 
     1342        else 
     1343                matches = CFStringFindWithOptions(nameString, queryString, range, kCFCompareCaseInsensitive, NULL); 
    13391344 
    13401345        CFRelease(nameString); 
     
    13431348        return matches; 
    13441349#else 
    1345         return (wi_string_index_of_string_in_range(name, query, WI_STRING_CASE_INSENSITIVE, range) != WI_NOT_FOUND); 
     1350        wi_range_t                              range; 
     1351         
     1352        if(index) 
     1353                range = wi_make_range(0, wi_string_index_of_char(name, WD_FIELD_SEPARATOR, 0)); 
     1354        else 
     1355                range = wi_make_range(0, wi_string_length(name)); 
     1356         
     1357        if(range.length == WI_NOT_FOUND) 
     1358                return false; 
     1359        else 
     1360                return (wi_string_index_of_string_in_range(name, query, WI_STRING_CASE_INSENSITIVE, range) != WI_NOT_FOUND); 
    13461361#endif 
    13471362} 
  • wired/trunk/wired/files.h

    r5065 r5066  
    7373wi_boolean_t                                                    wd_files_path_is_dropbox(wi_string_t *); 
    7474wi_string_t *                                                   wd_files_real_path(wi_string_t *); 
    75 wi_boolean_t                                                    wd_files_name_matches_query(wi_string_t *, wi_string_t *, wi_range_t); 
     75wi_boolean_t                                                    wd_files_name_matches_query(wi_string_t *, wi_string_t *, wi_boolean_t); 
    7676 
    7777 
  • wired/trunk/wired/server.h

    r4842 r5066  
    4141#define WD_MESSAGE_SEPARATOR_STR        "\4" 
    4242#define WD_FIELD_SEPARATOR                      '\34' 
     43#define WD_FIELD_SEPARATOR_STR          "\34" 
    4344#define WD_GROUP_SEPARATOR                      '\35' 
    4445#define WD_RECORD_SEPARATOR                     '\36'