commit 67dc32af3a3d1016a54143894844dc6c2de75c46
parent dd83b0b3c30701d35366065239d2508afff9bbcb
Author: Sebastian <sebastian@sebsite.pw>
Date: Fri, 6 May 2022 22:50:29 -0400
regex: pass by pointer
Fixes: https://todo.sr.ht/~sircmpwn/hare/627
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/regex/+test.ha b/regex/+test.ha
@@ -30,7 +30,7 @@ fn run_find_case(
return;
};
- match (find(re, string)) {
+ match (find(&re, string)) {
case void =>
if (expected == matchres::MATCH) {
fmt::fatalf("Expected expression /{}/ to match string \"{}\", but it did not",
@@ -93,7 +93,7 @@ fn run_findall_case(
return;
};
- match (findall(re, string)) {
+ match (findall(&re, string)) {
case void =>
if (expected == matchres::MATCH) {
fmt::fatalf("Expected expression /{}/ to match string \"{}\", but it did not",
diff --git a/regex/regex.ha b/regex/regex.ha
@@ -504,7 +504,7 @@ fn add_thread(threads: *[]thread, parent_idx: size, new_pc: size) void = {
fn run_thread(
i: size,
- re: regex,
+ re: *regex,
string: str,
threads: *[]thread,
r_or_end: (rune | void),
@@ -648,7 +648,7 @@ fn run_thread(
// Attempts to match a regular expression against a string and returns the
// either the longest leftmost match or all matches.
fn search(
- re: regex,
+ re: *regex,
string: str,
str_iter: *strings::iterator,
str_idx: *int
@@ -771,7 +771,7 @@ fn search(
// Attempts to match a regular expression against a string and returns the
// longest leftmost match, or void if there is no match.
-export fn find(re: regex, string: str) (void | []matchgroup | error) = {
+export fn find(re: *regex, string: str) (void | []matchgroup | error) = {
let str_idx = -1;
let str_iter = strings::iter(string);
return search(re, string, &str_iter, &str_idx);
@@ -779,7 +779,7 @@ export fn find(re: regex, string: str) (void | []matchgroup | error) = {
// Attempts to match a regular expression against a string and returns all
// non-overlapping matches, or void if there are no matches.
-export fn findall(re: regex, string: str) (void | [][]matchgroup | error) = {
+export fn findall(re: *regex, string: str) (void | [][]matchgroup | error) = {
let res: [][]matchgroup = [];
let str_idx = -1;
let str_iter = strings::iter(string);