From 13640620ce64aa09736cd75cb43a10934f916886 Mon Sep 17 00:00:00 2001 From: James Duran Date: Wed, 15 Jan 2025 15:56:40 -0800 Subject: [PATCH] Fix captures not begin zeroed when haystack length is 0 --- core/text/match/strlib.odin | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/text/match/strlib.odin b/core/text/match/strlib.odin index 2068fffdd..819f464c5 100644 --- a/core/text/match/strlib.odin +++ b/core/text/match/strlib.odin @@ -698,11 +698,11 @@ gmatch :: proc( first := length > 1 ? 1 : 0 cap := captures[first] res = haystack[cap.byte_start:cap.byte_end] - } else { - captures^ = {} } } - + if !ok { + captures^ = {} + } return } @@ -813,11 +813,11 @@ gfind :: proc( ok = true cap := captures[0] res = haystack[cap.byte_start:cap.byte_end] - } else { - captures^ = {} } } - + if !ok { + captures^ = {} + } return }