Ticket #3589: regex.patch
File regex.patch, 3.7 KB (added by phelum, 8 years ago) |
---|
-
regex.c
old new 124 124 mc_search__cond_struct_new_regex_hex_add (const char *charset, GString * str_to, 125 125 const char *one_char, gsize str_len) 126 126 { 127 //GString *upp, *low;127 GString *upp, *low; 128 128 gsize loop; 129 129 130 //upp = mc_search__toupper_case_str (charset, one_char, str_len);131 //low = mc_search__tolower_case_str (charset, one_char, str_len);130 upp = mc_search__toupper_case_str (charset, one_char, str_len); 131 low = mc_search__tolower_case_str (charset, one_char, str_len); 132 132 133 // for (loop = 0; loop < upp->len; loop++) 134 for (loop = 0; loop < str_len; loop++) 133 for (loop = 0; loop < upp->len; loop++) 135 134 { 136 135 gchar tmp_str[10 + 1]; /* longest content is "[\\x%02X\\x%02X]" */ 137 136 gint tmp_len; 138 137 139 // if (loop >= low->len || upp->str[loop] == low->str[loop]) 140 // tmp_len = 141 // g_snprintf (tmp_str, sizeof (tmp_str), "\\x%02X", (unsigned char) upp->str[loop]); 142 // else 143 // tmp_len = 144 // g_snprintf (tmp_str, sizeof (tmp_str), "[\\x%02X\\x%02X]", 145 // (unsigned char) upp->str[loop], (unsigned char) low->str[loop]); 138 if (loop >= low->len || upp->str[loop] == low->str[loop]) 146 139 tmp_len = 147 g_snprintf (tmp_str, sizeof (tmp_str), "\\x%02X", one_char [loop]); 140 g_snprintf (tmp_str, sizeof (tmp_str), "\\x%02X", (unsigned char) upp->str[loop]); 141 else 142 tmp_len = 143 g_snprintf (tmp_str, sizeof (tmp_str), "[\\x%02X\\x%02X]", 144 (unsigned char) upp->str[loop], (unsigned char) low->str[loop]); 148 145 149 146 g_string_append_len (str_to, tmp_str, tmp_len); 150 147 } 151 148 152 //g_string_free (upp, TRUE);153 //g_string_free (low, TRUE);149 g_string_free (upp, TRUE); 150 g_string_free (low, TRUE); 154 151 } 155 152 156 153 /* --------------------------------------------------------------------------------------------- */ … … 209 206 spec_char = g_string_sized_new (64); 210 207 loop = 0; 211 208 212 // while (loop <= astr->len) 213 while (loop < astr->len) 209 while (loop <= astr->len) 214 210 { 215 211 if (mc_search__regex_str_append_if_special (spec_char, astr, &loop)) 216 212 { … … 269 265 char *string_safe, *p, *end; 270 266 gboolean ret; 271 267 272 // The processing below causes problems when 0x00 in hex arguments. 273 // So we always just call the match function with the input argument. 274 275 // if ((g_regex_get_compile_flags (regex) & G_REGEX_RAW) 276 // || g_utf8_validate (string, string_len, NULL)) 268 if ((g_regex_get_compile_flags (regex) & G_REGEX_RAW) 269 || g_utf8_validate (string, string_len, NULL)) 277 270 { 278 271 return g_regex_match_full (regex, string, string_len, start_position, match_options, 279 272 match_info, error); … … 820 813 #ifdef SEARCH_TYPE_GLIB 821 814 GError *mcerror = NULL; 822 815 823 GRegexCompileFlags CompileFlags;824 825 CompileFlags = mc_search__regex_get_compile_flags (charset, lc_mc_search->is_case_sensitive);826 if (lc_mc_search->search_type == MC_SEARCH_T_HEX) // if hex mode search,827 CompileFlags |= G_REGEX_RAW; // use raw mode here828 829 816 mc_search_cond->regex_handle = 830 817 g_regex_new (mc_search_cond->str->str, 831 CompileFlags,832 0,818 mc_search__regex_get_compile_flags (charset, 819 lc_mc_search->is_case_sensitive), 0, 833 820 &mcerror); 834 821 835 822 if (mcerror != NULL)