diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/search.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/search.c b/src/search.c index 92be012..90975c2 100644 --- a/src/search.c +++ b/src/search.c @@ -751,7 +751,12 @@ teco_do_search_backwards(GRegex *re, gsize from, gsize to, gint *count, GError * return FALSE; } - if (g_match_info_is_partial_match(info)) { + if (g_match_info_matches(info)) { + g_free(matched->matches[i].ranges); + matched->matches[i].ranges = teco_get_ranges(info, from+from_block, + &matched->matches[i].num_ranges); + i = ++matched_total % matched_num; + } else if (G_UNLIKELY(g_match_info_is_partial_match(info))) { /* * Match may fall on the block boundary, * so retry matching the rest of the document. @@ -769,32 +774,27 @@ teco_do_search_backwards(GRegex *re, gsize from, gsize to, gint *count, GError * rc = g_match_info_fetch_pos(info, 0, &partial_start, &partial_end); //g_assert(rc == TRUE); if (!rc) + /* make sure that test case fails */ abort(); + g_assert(partial_end == to_block-from_block); - if (partial_end == to_block-from_block) { - g_autoptr(GMatchInfo) partial_info = NULL; + g_autoptr(GMatchInfo) partial_info = NULL; - g_regex_match_full(re, buffer+partial_start, to-from-partial_start, 0, - G_REGEX_MATCH_ANCHORED, &partial_info, &tmp_error); - if (tmp_error) { - g_propagate_error(error, tmp_error); - return FALSE; - } - - if (g_match_info_matches(partial_info)) { - g_free(matched->matches[i].ranges); - matched->matches[i].ranges = teco_get_ranges(partial_info, from+partial_start, - &matched->matches[i].num_ranges); - i = ++matched_total % matched_num; - } + g_regex_match_full(re, buffer+partial_start, to-from-partial_start, 0, + G_REGEX_MATCH_ANCHORED, &partial_info, &tmp_error); + if (tmp_error) { + g_propagate_error(error, tmp_error); + return FALSE; + } + + if (g_match_info_matches(partial_info)) { + g_free(matched->matches[i].ranges); + matched->matches[i].ranges = teco_get_ranges(partial_info, from+partial_start, + &matched->matches[i].num_ranges); + i = ++matched_total % matched_num; } /* there might still be other matches within the current block */ - } else if (g_match_info_matches(info)) { - g_free(matched->matches[i].ranges); - matched->matches[i].ranges = teco_get_ranges(info, from+from_block, - &matched->matches[i].num_ranges); - i = ++matched_total % matched_num; } else { break; } |
