mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 21:16:50 +03:00
[project @ 2005-04-17 04:13:13 by adrianl]
Multiple matches per box svn path=/import/netsurf/; revision=1658
This commit is contained in:
parent
452a27e74c
commit
9cff88ddd5
@ -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 */
|
/* ignore this box, if there's no visible text */
|
||||||
if (!cur->object && cur->text) {
|
if (!cur->object && cur->text) {
|
||||||
unsigned match_length;
|
const char *text = cur->text;
|
||||||
const char *pos = find_pattern(cur->text, cur->length,
|
unsigned length = cur->length;
|
||||||
pattern, p_len, case_sens, &match_length);
|
|
||||||
if (pos) {
|
while (length > 0) {
|
||||||
/* found string in box => add to list */
|
unsigned match_length;
|
||||||
unsigned match_offset;
|
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) {
|
if (!entry) {
|
||||||
warn_user("NoMemory", 0);
|
warn_user("NoMemory", 0);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
match_offset = pos - cur->text;
|
match_offset = pos - cur->text;
|
||||||
|
|
||||||
entry->start_box = cur;
|
entry->start_box = cur;
|
||||||
entry->start_idx = match_offset;
|
entry->start_idx = match_offset;
|
||||||
entry->end_box = cur;
|
entry->end_box = cur;
|
||||||
@ -516,6 +523,10 @@ bool find_occurrences(const char *pattern, int p_len, struct box *cur,
|
|||||||
else
|
else
|
||||||
search_found->prev->next = entry;
|
search_found->prev->next = entry;
|
||||||
search_found->prev = entry;
|
search_found->prev = entry;
|
||||||
|
|
||||||
|
new_text = pos + match_length;
|
||||||
|
length -= (new_text - text);
|
||||||
|
text = new_text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user