This commit is contained in:
@@ -588,7 +588,7 @@ __evstring_findFirst_impl(
|
||||
.offset = ~0ull
|
||||
};
|
||||
|
||||
if(query.len == 0)
|
||||
if(query.len == 0 || query.len > text.len)
|
||||
return result;
|
||||
|
||||
for(u64 l = text.offset; l <= text.offset + text.len - query.len; l++)
|
||||
@@ -731,18 +731,25 @@ evstring_findAll(
|
||||
if(text_len == 0 || query_len == 0 || query_len > text_len) {
|
||||
return 0;
|
||||
}
|
||||
bool check_run = (results == NULL);
|
||||
|
||||
evstring_view query_view = evstring_slice(query, 0, -1);
|
||||
|
||||
u64 count = 0;
|
||||
for(evstring_view v = evstring_findFirst(text, query);
|
||||
v.len != 0;
|
||||
v = __evstring_findFirst_impl(
|
||||
evstring_slice(text, v.offset + v.len, -1),
|
||||
evstring_slice(query, 0, -1))) {
|
||||
if(!check_run) {
|
||||
results[count] = v;
|
||||
|
||||
for(u64 l = 0; l <= text_len - query_len; l++)
|
||||
{
|
||||
evstring_view curr_view = {
|
||||
.data = text,
|
||||
.len = query_len,
|
||||
.offset = l
|
||||
};
|
||||
if(EV_EQUAL(evstring_view)(&curr_view, &query_view))
|
||||
{
|
||||
if(results) results[count] = curr_view;
|
||||
count++;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user