diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2013-05-22 14:53:23 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2013-05-22 14:53:23 +0200 |
commit | 12011c9168471b2dd8012165c9d127a46b7c6bcb (patch) | |
tree | 5c0735ba9b1b3ce365114e09fd4ffaafb50b51f7 | |
parent | c48065c75252d06678ca2663576f401ad08fca8d (diff) | |
download | mupdf-12011c9168471b2dd8012165c9d127a46b7c6bcb.tar.xz |
Fix end-of-line handling in text search.
-rw-r--r-- | fitz/text_search.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/fitz/text_search.c b/fitz/text_search.c index 34f39eb3..6631535b 100644 --- a/fitz/text_search.c +++ b/fitz/text_search.c @@ -8,6 +8,11 @@ static inline int fz_tolower(int c) return c; } +static inline int iswhite(int c) +{ + return c == ' ' || c == '\r' || c == '\n' || c == '\t'; +} + fz_char_and_box *fz_text_char_at(fz_char_and_box *cab, fz_text_page *page, int idx) { int block_num; @@ -38,7 +43,7 @@ fz_char_and_box *fz_text_char_at(fz_char_and_box *cab, fz_text_page *page, int i if (idx == ofs) { cab->bbox = fz_empty_rect; - cab->c = 0; + cab->c = ' '; return cab; } ofs++; @@ -96,10 +101,11 @@ static int match(fz_text_page *page, const char *s, int n) while (*s) { s += fz_chartorune(&c, (char *)s); - if (c == ' ' && charat(page, n) == ' ') + if (iswhite(c) && iswhite(charat(page, n))) { - while (charat(page, n) == ' ') + do n++; + while (iswhite(charat(page, n))); } else { |