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/multiline_dotall.zigmodified+12-12
Changes to tests/multiline_dotall.zig
@@ -6,11 +6,11 @@ test "multiline flag: ^ matches after newlines" {
66 const allocator = std.testing.allocator;
77
88 // Without multiline flag
9 var regex_single = try Regex.compileWithFlags(allocator, "^test", .{ .multiline = false });
9 var regex_single = try Regex.compileWithFlags(allocator, std.testing.io, "^test", .{ .multiline = false });
1010 defer regex_single.deinit();
1111
1212 // With multiline flag
13 var regex_multi = try Regex.compileWithFlags(allocator, "^test", .{ .multiline = true });
13 var regex_multi = try Regex.compileWithFlags(allocator, std.testing.io, "^test", .{ .multiline = true });
1414 defer regex_multi.deinit();
1515
1616 const input = "line1\ntest";
@@ -26,11 +26,11 @@ test "multiline flag: $ matches before newlines" {
2626 const allocator = std.testing.allocator;
2727
2828 // Without multiline flag
29 var regex_single = try Regex.compileWithFlags(allocator, "test$", .{ .multiline = false });
29 var regex_single = try Regex.compileWithFlags(allocator, std.testing.io, "test$", .{ .multiline = false });
3030 defer regex_single.deinit();
3131
3232 // With multiline flag
33 var regex_multi = try Regex.compileWithFlags(allocator, "test$", .{ .multiline = true });
33 var regex_multi = try Regex.compileWithFlags(allocator, std.testing.io, "test$", .{ .multiline = true });
3434 defer regex_multi.deinit();
3535
3636 const input = "test\nline2";
@@ -45,7 +45,7 @@ test "multiline flag: $ matches before newlines" {
4545test "multiline flag: complex pattern" {
4646 const allocator = std.testing.allocator;
4747
48 var regex = try Regex.compileWithFlags(allocator, "^\\w+$", .{ .multiline = true });
48 var regex = try Regex.compileWithFlags(allocator, std.testing.io, "^\\w+$", .{ .multiline = true });
4949 defer regex.deinit();
5050
5151 // Should match each line
@@ -57,11 +57,11 @@ test "dot-all flag: . matches newlines" {
5757 const allocator = std.testing.allocator;
5858
5959 // Without dot-all flag
60 var regex_normal = try Regex.compileWithFlags(allocator, "a.b", .{ .dot_all = false });
60 var regex_normal = try Regex.compileWithFlags(allocator, std.testing.io, "a.b", .{ .dot_all = false });
6161 defer regex_normal.deinit();
6262
6363 // With dot-all flag
64 var regex_dotall = try Regex.compileWithFlags(allocator, "a.b", .{ .dot_all = true });
64 var regex_dotall = try Regex.compileWithFlags(allocator, std.testing.io, "a.b", .{ .dot_all = true });
6565 defer regex_dotall.deinit();
6666
6767 const input_with_newline = "a\nb";
@@ -80,11 +80,11 @@ test "dot-all flag: .* matches across lines" {
8080 const allocator = std.testing.allocator;
8181
8282 // Without dot-all flag
83 var regex_normal = try Regex.compileWithFlags(allocator, "start.*end", .{ .dot_all = false });
83 var regex_normal = try Regex.compileWithFlags(allocator, std.testing.io, "start.*end", .{ .dot_all = false });
8484 defer regex_normal.deinit();
8585
8686 // With dot-all flag
87 var regex_dotall = try Regex.compileWithFlags(allocator, "start.*end", .{ .dot_all = true });
87 var regex_dotall = try Regex.compileWithFlags(allocator, std.testing.io, "start.*end", .{ .dot_all = true });
8888 defer regex_dotall.deinit();
8989
9090 const input = "start\nmiddle\nend";
@@ -99,7 +99,7 @@ test "dot-all flag: .* matches across lines" {
9999test "combined multiline and dot-all flags" {
100100 const allocator = std.testing.allocator;
101101
102 var regex = try Regex.compileWithFlags(allocator, "^.*$", .{
102 var regex = try Regex.compileWithFlags(allocator, std.testing.io, "^.*$", .{
103103 .multiline = true,
104104 .dot_all = true,
105105 });
@@ -112,7 +112,7 @@ test "combined multiline and dot-all flags" {
112112test "multiline flag: multiple matches with findAll" {
113113 const allocator = std.testing.allocator;
114114
115 var regex = try Regex.compileWithFlags(allocator, "^\\d+", .{ .multiline = true });
115 var regex = try Regex.compileWithFlags(allocator, std.testing.io, "^\\d+", .{ .multiline = true });
116116 defer regex.deinit();
117117
118118 const matches = try regex.findAll(allocator, "123\n456\n789");
@@ -135,7 +135,7 @@ test "default flags: multiline and dot-all are false" {
135135 const allocator = std.testing.allocator;
136136
137137 // Default compile should have multiline=false and dot_all=false
138 var regex = try Regex.compile(allocator, "^test$");
138 var regex = try Regex.compile(allocator, std.testing.io, "^test$");
139139 defer regex.deinit();
140140
141141 // Should not match with newlines