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
examples/error_handling.zigmodified+11-11
Changes to examples/error_handling.zig
@@ -4,7 +4,7 @@ const ErrorContext = .ErrorContext;
44const ErrorHelper = .ErrorHelper;
55const RegexError = .RegexError;
66
7pub fn main() !void {
7pub fn main(init: std.process.Init) !void {
88 var gpa = std.heap.GeneralPurposeAllocator(.{}){};
99 defer _ = gpa.deinit();
1010 const allocator = gpa.allocator();
formatting only · 16 hidden lines
Changes to examples/error_handling.zig
@@ -13,11 +13,11 @@ pub fn main() !void { formatting only
1313
1414 // Example 1: Invalid patterns with helpful error messages
1515 const invalid_patterns = [_][]const u8{
16 "abc(def", // Unmatched parenthesis
17 "abc[def", // Unmatched bracket
18 "abc+(", // Invalid quantifier usage
19 "abc\\q", // Invalid escape sequence
20 "[z-a]", // Invalid character range
16 "abc(def", // Unmatched parenthesis
17 "abc[def", // Unmatched bracket
18 "abc+(", // Invalid quantifier usage
19 "abc\\q", // Invalid escape sequence
20 "[z-a]", // Invalid character range
2121 "(a(b(c(d(e(f(g(h(i(j(k(l(m(n(o(p(q", // Too many nested groups
2222 };
2323
Changes to examples/error_handling.zig
@@ -26,7 +26,7 @@ pub fn main() !void {
2626 std.debug.print("Testing pattern: \"{s}\"\n", .{pattern});
2727 std.debug.print("───────────────────────────────────────────────\n", .{});
2828
29 if (Regex.compile(allocator, pattern)) |regex_value| {
29 if (Regex.compile(allocator, init.io, pattern)) |regex_value| {
3030 var regex = regex_value;
3131 defer regex.deinit();
3232 std.debug.print("✓ Pattern compiled successfully (unexpected)\n\n", .{});
@@ -53,7 +53,7 @@ pub fn main() !void {
5353 const user_pattern = "hello|world";
5454 std.debug.print("User provided pattern: \"{s}\"\n", .{user_pattern});
5555
56 if (Regex.compile(allocator, user_pattern)) |regex_value| {
56 if (Regex.compile(allocator, init.io, user_pattern)) |regex_value| {
5757 var regex = regex_value;
5858 defer regex.deinit();
5959 std.debug.print("✓ Pattern compiled successfully\n", .{});
@@ -84,7 +84,7 @@ pub fn main() !void {
8484 const problematic_pattern = "abc[def";
8585 std.debug.print("Problematic pattern: \"{s}\"\n", .{problematic_pattern});
8686
87 if (Regex.compile(allocator, problematic_pattern)) |regex_value| {
87 if (Regex.compile(allocator, init.io, problematic_pattern)) |regex_value| {
8888 var regex = regex_value;
8989 regex.deinit();
9090 } else |err| {
@@ -95,7 +95,7 @@ pub fn main() !void {
9595 const fixed_pattern = "abc[def]";
9696 std.debug.print("Fixed pattern: \"{s}\"\n", .{fixed_pattern});
9797
98 if (Regex.compile(allocator, fixed_pattern)) |regex_value| {
98 if (Regex.compile(allocator, init.io, fixed_pattern)) |regex_value| {
9999 var regex = regex_value;
100100 defer regex.deinit();
101101 std.debug.print("✓ Fixed pattern compiles successfully!\n", .{});
@@ -119,7 +119,7 @@ pub fn main() !void {
119119
120120 for (patterns_to_validate) |pattern| {
121121 std.debug.print("Validating: \"{s}\" ... ", .{pattern});
122 if (Regex.compile(allocator, pattern)) |regex_value| {
122 if (Regex.compile(allocator, init.io, pattern)) |regex_value| {
123123 var regex = regex_value;
124124 regex.deinit();
125125 std.debug.print("✓ Valid\n", .{});