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 |
141 | 142 | } |
142 | 143 | |
143 | 144 | /* --------------------------------------------------------------------------------------------- */ |
| 145 | static GString * |
| 146 | mc_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 | |
144 | 170 | GString * |
145 | 171 | mc_search_glob_prepare_replace_str (mc_search_t * mc_search, GString * replace_str) |
146 | 172 | { |
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; |
148 | 177 | } |