Ticket #3525: mc-3525-whole-words.patch

File mc-3525-whole-words.patch, 1.8 KB (added by egmont, 9 years ago)

Fix

  • lib/search/normal.c

    diff --git a/lib/search/normal.c b/lib/search/normal.c
    index 49e4567..2ebe463 100644
    a b mc_search__cond_struct_new_init_normal (const char *charset, mc_search_t * lc_mc 
    9191    tmp = mc_search__normal_translate_to_regex (mc_search_cond->str); 
    9292    g_string_free (mc_search_cond->str, TRUE); 
    9393 
    94     if (lc_mc_search->whole_words) 
    95     { 
    96         /* NOTE: \b as word boundary doesn't allow search 
    97          * whole words with non-ASCII symbols. 
    98          * Update: Is it still true nowadays? Probably not. #2396, #3524 */ 
    99         g_string_prepend (tmp, "(?<![\\p{L}\\p{N}_])"); 
    100         g_string_append (tmp, "(?![\\p{L}\\p{N}_])"); 
    101     } 
    102  
    10394    mc_search_cond->str = tmp; 
    10495    mc_search__cond_struct_new_init_regex (charset, lc_mc_search, mc_search_cond); 
    10596} 
  • lib/search/regex.c

    diff --git a/lib/search/regex.c b/lib/search/regex.c
    index ba8b4df..da41df5 100644
    a b void 
    740740mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * lc_mc_search, 
    741741                                       mc_search_cond_t * mc_search_cond) 
    742742{ 
     743    if (lc_mc_search->whole_words && !lc_mc_search->is_entire_line) 
     744    { 
     745        /* NOTE: \b as word boundary doesn't allow search 
     746         * whole words with non-ASCII symbols. 
     747         * Update: Is it still true nowadays? Probably not. #2396, #3524 */ 
     748        g_string_prepend (mc_search_cond->str, "(?<![\\p{L}\\p{N}_])"); 
     749        g_string_append (mc_search_cond->str, "(?![\\p{L}\\p{N}_])"); 
     750    } 
     751 
     752{ 
    743753#ifdef SEARCH_TYPE_GLIB 
    744754    GError *mcerror = NULL; 
    745755 
    mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * lc_mc_ 
    799809        } 
    800810    } 
    801811#endif /* SEARCH_TYPE_GLIB */ 
     812} 
    802813    lc_mc_search->is_utf8 = str_isutf8 (charset); 
    803814} 
    804815