ReviewOS

also looking at this

zig-utils/zig-regex

Port to latest zig-master

#2
Closed armagidon-exception wants to merge main into main
53 files +1149 -1017
tests/fuzz.zigmodified+14-14
formatting only · 8 hidden lines
Changes to tests/fuzz.zig
@@ -21,7 +21,7 @@ test "fuzz: random valid patterns" { formatting only
2121 const char_choice = random.intRangeAtMost(u8, 0, 4);
2222 pattern_buf[j] = switch (char_choice) {
2323 0 => 'a' + random.intRangeAtMost(u8, 0, 25), // a-z
24 1 => '0' + random.intRangeAtMost(u8, 0, 9), // 0-9
24 1 => '0' + random.intRangeAtMost(u8, 0, 9), // 0-9
2525 2 => '.', // wildcard
2626 3 => '*', // quantifier
2727 else => '+', // quantifier
formatting only · 30 hidden lines
Changes to tests/fuzz.zig
@@ -129,18 +129,18 @@ test "fuzz: malformed patterns should return errors" { formatting only
129129 const allocator = std.testing.allocator;
130130
131131 const bad_patterns = [_][]const u8{
132 "(abc", // Unmatched paren
133 "abc)", // Unmatched paren
134 "[abc", // Unmatched bracket
135 "abc]", // Unmatched bracket
136 "*", // Quantifier without target
137 "+abc", // Quantifier without target
138 "?abc", // Quantifier without target
139 "{2,3}", // Quantifier without target
140 "\\", // Incomplete escape
141 "[z-a]", // Invalid range
142 "{-1,5}", // Invalid repetition
143 "{5,2}", // Invalid repetition (min > max)
132 "(abc", // Unmatched paren
133 "abc)", // Unmatched paren
134 "[abc", // Unmatched bracket
135 "abc]", // Unmatched bracket
136 "*", // Quantifier without target
137 "+abc", // Quantifier without target
138 "?abc", // Quantifier without target
139 "{2,3}", // Quantifier without target
140 "\\", // Incomplete escape
141 "[z-a]", // Invalid range
142 "{-1,5}", // Invalid repetition
143 "{5,2}", // Invalid repetition (min > max)
144144 };
145145
146146 for (bad_patterns) |pattern| {
Changes to tests/fuzz.zig
@@ -180,7 +180,7 @@ test "fuzz: edge cases with empty strings" {
180180test "fuzz: long input strings" {
181181 const allocator = std.testing.allocator;
182182
183 var regex = try Regex.compile(allocator, "a*b+c?");
183 var regex = try Regex.compile(allocator, std.testing.io, "a*b+c?");
184184 defer regex.deinit();
185185
186186 // Create progressively longer inputs