From 023555b706ce870769a6e2c924e95480ea5f19d1 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 24 Oct 2016 18:43:01 +0200 Subject: Don't return overlapping search results. --- source/fitz/stext-search.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/fitz/stext-search.c b/source/fitz/stext-search.c index 46c9166b..bba2c3f5 100644 --- a/source/fitz/stext-search.c +++ b/source/fitz/stext-search.c @@ -135,7 +135,8 @@ fz_search_stext_page(fz_context *ctx, fz_stext_page *text, const char *needle, f hit_count = 0; len = textlen_stext(ctx, text); - for (pos = 0; pos < len; pos++) + pos = 0; + while (pos < len) { n = match_stext(ctx, text, needle, pos); if (n) @@ -161,6 +162,11 @@ fz_search_stext_page(fz_context *ctx, fz_stext_page *text, const char *needle, f } if (!fz_is_empty_rect(&linebox) && hit_count < hit_max) hit_bbox[hit_count++] = linebox; + pos += n; + } + else + { + pos += 1; } } -- cgit v1.2.3