ReviewOS

also looking at this

zig-utils/zig-regex

Migrate to zig 0.16

#5
Closed illya-laifu wants to merge zig-0.16-migrations into main
13 files +222 -239

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

examples/error_handling.zigmodified+11-15
Changes to examples/error_handling.zig
@@ -4,20 +4,16 @@ const ErrorContext = .ErrorContext;
44const ErrorHelper = .ErrorHelper;
55const RegexError = .RegexError;
66
7pub fn main() !void {
8 var gpa = std.heap.GeneralPurposeAllocator(.{}){};
9 defer _ = gpa.deinit();
10 const allocator = gpa.allocator();
11
7pub fn main(init: std.process.Init) !void {
128 std.debug.print("\n=== Regex Error Handling Examples ===\n\n", .{});
139
1410 // Example 1: Invalid patterns with helpful error messages
1511 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
12 "abc(def", // Unmatched parenthesis
13 "abc[def", // Unmatched bracket
14 "abc+(", // Invalid quantifier usage
15 "abc\\q", // Invalid escape sequence
16 "[z-a]", // Invalid character range
2117 "(a(b(c(d(e(f(g(h(i(j(k(l(m(n(o(p(q", // Too many nested groups
2218 };
2319
@@ -26,7 +22,7 @@ pub fn main() !void {
2622 std.debug.print("Testing pattern: \"{s}\"\n", .{pattern});
2723 std.debug.print("───────────────────────────────────────────────\n", .{});
2824
29 if (Regex.compile(allocator, pattern)) |regex_value| {
25 if (Regex.compile(init.gpa, pattern)) |regex_value| {
3026 var regex = regex_value;
3127 defer regex.deinit();
3228 std.debug.print("✓ Pattern compiled successfully (unexpected)\n\n", .{});
@@ -53,7 +49,7 @@ pub fn main() !void {
5349 const user_pattern = "hello|world";
5450 std.debug.print("User provided pattern: \"{s}\"\n", .{user_pattern});
5551
56 if (Regex.compile(allocator, user_pattern)) |regex_value| {
52 if (Regex.compile(init.gpa, user_pattern)) |regex_value| {
5753 var regex = regex_value;
5854 defer regex.deinit();
5955 std.debug.print("✓ Pattern compiled successfully\n", .{});
@@ -84,7 +80,7 @@ pub fn main() !void {
8480 const problematic_pattern = "abc[def";
8581 std.debug.print("Problematic pattern: \"{s}\"\n", .{problematic_pattern});
8682
87 if (Regex.compile(allocator, problematic_pattern)) |regex_value| {
83 if (Regex.compile(init.gpa, problematic_pattern)) |regex_value| {
8884 var regex = regex_value;
8985 regex.deinit();
9086 } else |err| {
@@ -95,7 +91,7 @@ pub fn main() !void {
9591 const fixed_pattern = "abc[def]";
9692 std.debug.print("Fixed pattern: \"{s}\"\n", .{fixed_pattern});
9793
98 if (Regex.compile(allocator, fixed_pattern)) |regex_value| {
94 if (Regex.compile(init.gpa, fixed_pattern)) |regex_value| {
9995 var regex = regex_value;
10096 defer regex.deinit();
10197 std.debug.print("✓ Fixed pattern compiles successfully!\n", .{});
@@ -119,7 +115,7 @@ pub fn main() !void {
119115
120116 for (patterns_to_validate) |pattern| {
121117 std.debug.print("Validating: \"{s}\" ... ", .{pattern});
122 if (Regex.compile(allocator, pattern)) |regex_value| {
118 if (Regex.compile(init.gpa, pattern)) |regex_value| {
123119 var regex = regex_value;
124120 regex.deinit();
125121 std.debug.print("✓ Valid\n", .{});