Ticket #3524: mc-3524-regex-lookaround.patch

File mc-3524-regex-lookaround.patch, 2.0 KB (added by egmont, 9 years ago)

Fix'n'cleanup

  • lib/search/normal.c

    diff --git a/lib/search/normal.c b/lib/search/normal.c
    index 4287e21..49e4567 100644
    a b mc_search__cond_struct_new_init_normal (const char *charset, mc_search_t * lc_mc 
    9494    if (lc_mc_search->whole_words) 
    9595    { 
    9696        /* NOTE: \b as word boundary doesn't allow search 
    97          * whole words with non-ASCII symbols */ 
    98         g_string_prepend (tmp, "(^|[^\\p{L}\\p{N}_])("); 
    99         g_string_append (tmp, ")([^\\p{L}\\p{N}_]|$)"); 
     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}_])"); 
    100101    } 
    101102 
    102103    mc_search_cond->str = tmp; 
  • lib/search/regex.c

    diff --git a/lib/search/regex.c b/lib/search/regex.c
    index 1711af4..ba8b4df 100644
    a b mc_search__run_regex (mc_search_t * lc_mc_search, const void *user_data, 
    906906        { 
    907907        case COND__FOUND_OK: 
    908908#ifdef SEARCH_TYPE_GLIB 
    909             if (lc_mc_search->whole_words) 
    910                 g_match_info_fetch_pos (lc_mc_search->regex_match_info, 2, &start_pos, &end_pos); 
    911             else 
    912                 g_match_info_fetch_pos (lc_mc_search->regex_match_info, 0, &start_pos, &end_pos); 
     909            g_match_info_fetch_pos (lc_mc_search->regex_match_info, 0, &start_pos, &end_pos); 
    913910#else /* SEARCH_TYPE_GLIB */ 
    914             if (lc_mc_search->whole_words) 
    915             { 
    916                 start_pos = lc_mc_search->iovector[4]; 
    917                 end_pos = lc_mc_search->iovector[5]; 
    918             } 
    919             else 
    920             { 
    921                 start_pos = lc_mc_search->iovector[0]; 
    922                 end_pos = lc_mc_search->iovector[1]; 
    923             } 
     911            start_pos = lc_mc_search->iovector[0]; 
     912            end_pos = lc_mc_search->iovector[1]; 
    924913#endif /* SEARCH_TYPE_GLIB */ 
    925914            if (found_len != NULL) 
    926915                *found_len = end_pos - start_pos;