{.Glboal} implicit in regex allocator.

This commit is contained in:
Jeroen van Rijn
2025-04-06 21:13:02 +02:00
parent 07a79254e0
commit 66077add33
2 changed files with 3 additions and 1 deletions

View File

@@ -279,6 +279,8 @@ create_iterator :: proc(
permanent_allocator := context.allocator,
temporary_allocator := context.temp_allocator,
) -> (result: Match_Iterator, err: Error) {
flags := flags
flags += {.Global} // We're iterating over a string, so the next match could start anywhere
result.haystack = str
result.regex = create(pattern, flags, permanent_allocator, temporary_allocator) or_return

View File

@@ -1102,7 +1102,7 @@ Iterator_Test :: struct {
iterator_vectors := []Iterator_Test{
{
`xxab32ab52xx`, `(ab\d{1})`, {.Global},
`xxab32ab52xx`, `(ab\d{1})`, {}, // {.Global} implicitly added by the iterator
{
{pos = {{2, 5}, {2, 5}}, groups = {"ab3", "ab3"}},
{pos = {{6, 9}, {6, 9}}, groups = {"ab5", "ab5"}},