瀏覽代碼

{.Glboal} implicit in regex allocator.

Jeroen van Rijn 5 月之前
父節點
當前提交
66077add33
共有 2 個文件被更改,包括 3 次插入1 次删除
  1. 2 0
      core/text/regex/regex.odin
  2. 1 1
      tests/core/text/regex/test_core_text_regex.odin

+ 2 - 0
core/text/regex/regex.odin

@@ -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

+ 1 - 1
tests/core/text/regex/test_core_text_regex.odin

@@ -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"}},