Ticket #414: 8.patch

File 8.patch, 1.2 KB (added by vda, 15 years ago)

Updated fix

  • src/search/glob.c

    diff -d -urpN mc.7/src/search/glob.c mc.8/src/search/glob.c
    old new mc_search__run_glob (mc_search_t * mc_se 
    141142} 
    142143 
    143144/* --------------------------------------------------------------------------------------------- */ 
     145static GString * 
     146mc_search__translate_replace_glob_to_regex (gchar *str) 
     147{ 
     148    GString *buff = g_string_new (""); 
     149    int cnt = '0'; 
     150 
     151    while (*str) { 
     152        char c = *str++; 
     153        switch (c) { 
     154        case '*': 
     155        case '?': 
     156            g_string_append_c (buff, '\\'); 
     157            c = ++cnt; 
     158            break; 
     159        /* breaks copying: mc uses "\0" internally, it must not be changed */ 
     160        /*case '\\':*/ 
     161        case '&': 
     162            g_string_append_c (buff, '\\'); 
     163            break; 
     164        } 
     165        g_string_append_c (buff, c); 
     166    } 
     167    return buff; 
     168} 
     169 
    144170GString * 
    145171mc_search_glob_prepare_replace_str (mc_search_t * mc_search, GString * replace_str) 
    146172{ 
    147     return mc_search_regex_prepare_replace_str (mc_search, replace_str); 
     173    GString *repl = mc_search__translate_replace_glob_to_regex(replace_str->str); 
     174    GString *res = mc_search_regex_prepare_replace_str (mc_search, repl); 
     175    g_string_free (repl, TRUE); 
     176    return res; 
    148177}