diff options
author | Adrian Lees <adrian@aemulor.com> | 2005-04-17 04:13:13 +0000 |
---|---|---|
committer | Adrian Lees <adrian@aemulor.com> | 2005-04-17 04:13:13 +0000 |
commit | 9cff88ddd5cf5bde060b0af0979ddf1b320379fc (patch) | |
tree | 54683fa8969f1ddc5a92fa4d084d83f24da474aa /riscos | |
parent | 452a27e74c159096f588e6d27dfabb3b6915ccaa (diff) | |
download | netsurf-9cff88ddd5cf5bde060b0af0979ddf1b320379fc.tar.gz netsurf-9cff88ddd5cf5bde060b0af0979ddf1b320379fc.tar.bz2 |
[project @ 2005-04-17 04:13:13 by adrianl]
Multiple matches per box
svn path=/import/netsurf/; revision=1658
Diffstat (limited to 'riscos')
-rw-r--r-- | riscos/search.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/riscos/search.c b/riscos/search.c index 34005d690..c309aba69 100644 --- a/riscos/search.c +++ b/riscos/search.c @@ -491,20 +491,27 @@ bool find_occurrences(const char *pattern, int p_len, struct box *cur, /* ignore this box, if there's no visible text */ if (!cur->object && cur->text) { - unsigned match_length; - const char *pos = find_pattern(cur->text, cur->length, - pattern, p_len, case_sens, &match_length); - if (pos) { - /* found string in box => add to list */ + const char *text = cur->text; + unsigned length = cur->length; + + while (length > 0) { + unsigned match_length; unsigned match_offset; - struct list_entry *entry = calloc(1, sizeof(*entry)); + const char *new_text; + struct list_entry *entry; + const char *pos = find_pattern(text, length, + pattern, p_len, case_sens, &match_length); + if (!pos) break; + + /* found string in box => add to list */ + entry = calloc(1, sizeof(*entry)); if (!entry) { warn_user("NoMemory", 0); return false; } - + match_offset = pos - cur->text; - + entry->start_box = cur; entry->start_idx = match_offset; entry->end_box = cur; @@ -516,6 +523,10 @@ bool find_occurrences(const char *pattern, int p_len, struct box *cur, else search_found->prev->next = entry; search_found->prev = entry; + + new_text = pos + match_length; + length -= (new_text - text); + text = new_text; } } |