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/posix_classes.zigmodified+18-18
Changes to tests/posix_classes.zig
@@ -5,7 +5,7 @@ const Regex = @import("regex").Regex;
55
66test "posix: [:alpha:] matches letters" {
77 const allocator = std.testing.allocator;
8 var regex = try Regex.compile(allocator, "[[:alpha:]]+");
8 var regex = try Regex.compile(allocator, std.testing.io, "[[:alpha:]]+");
99 defer regex.deinit();
1010
1111 try std.testing.expect(try regex.isMatch("hello"));
@@ -17,7 +17,7 @@ test "posix: [:alpha:] matches letters" {
1717
1818test "posix: [:digit:] matches digits" {
1919 const allocator = std.testing.allocator;
20 var regex = try Regex.compile(allocator, "[[:digit:]]+");
20 var regex = try Regex.compile(allocator, std.testing.io, "[[:digit:]]+");
2121 defer regex.deinit();
2222
2323 try std.testing.expect(try regex.isMatch("123"));
@@ -29,7 +29,7 @@ test "posix: [:digit:] matches digits" {
2929
3030test "posix: [:alnum:] matches alphanumeric" {
3131 const allocator = std.testing.allocator;
32 var regex = try Regex.compile(allocator, "[[:alnum:]]+");
32 var regex = try Regex.compile(allocator, std.testing.io, "[[:alnum:]]+");
3333 defer regex.deinit();
3434
3535 try std.testing.expect(try regex.isMatch("hello123"));
@@ -41,7 +41,7 @@ test "posix: [:alnum:] matches alphanumeric" {
4141
4242test "posix: [:space:] matches whitespace" {
4343 const allocator = std.testing.allocator;
44 var regex = try Regex.compile(allocator, "[[:space:]]+");
44 var regex = try Regex.compile(allocator, std.testing.io, "[[:space:]]+");
4545 defer regex.deinit();
4646
4747 try std.testing.expect(try regex.isMatch(" "));
@@ -53,7 +53,7 @@ test "posix: [:space:] matches whitespace" {
5353
5454test "posix: [:upper:] matches uppercase" {
5555 const allocator = std.testing.allocator;
56 var regex = try Regex.compile(allocator, "[[:upper:]]+");
56 var regex = try Regex.compile(allocator, std.testing.io, "[[:upper:]]+");
5757 defer regex.deinit();
5858
5959 try std.testing.expect(try regex.isMatch("HELLO"));
@@ -65,7 +65,7 @@ test "posix: [:upper:] matches uppercase" {
6565
6666test "posix: [:lower:] matches lowercase" {
6767 const allocator = std.testing.allocator;
68 var regex = try Regex.compile(allocator, "[[:lower:]]+");
68 var regex = try Regex.compile(allocator, std.testing.io, "[[:lower:]]+");
6969 defer regex.deinit();
7070
7171 try std.testing.expect(try regex.isMatch("hello"));
@@ -77,7 +77,7 @@ test "posix: [:lower:] matches lowercase" {
7777
7878test "posix: [:xdigit:] matches hex digits" {
7979 const allocator = std.testing.allocator;
80 var regex = try Regex.compile(allocator, "[[:xdigit:]]+");
80 var regex = try Regex.compile(allocator, std.testing.io, "[[:xdigit:]]+");
8181 defer regex.deinit();
8282
8383 try std.testing.expect(try regex.isMatch("0123456789"));
@@ -90,7 +90,7 @@ test "posix: [:xdigit:] matches hex digits" {
9090
9191test "posix: [:punct:] matches punctuation" {
9292 const allocator = std.testing.allocator;
93 var regex = try Regex.compile(allocator, "[[:punct:]]+");
93 var regex = try Regex.compile(allocator, std.testing.io, "[[:punct:]]+");
9494 defer regex.deinit();
9595
9696 try std.testing.expect(try regex.isMatch("!@#$%"));
@@ -102,7 +102,7 @@ test "posix: [:punct:] matches punctuation" {
102102
103103test "posix: [:blank:] matches space and tab" {
104104 const allocator = std.testing.allocator;
105 var regex = try Regex.compile(allocator, "[[:blank:]]+");
105 var regex = try Regex.compile(allocator, std.testing.io, "[[:blank:]]+");
106106 defer regex.deinit();
107107
108108 try std.testing.expect(try regex.isMatch(" "));
@@ -114,7 +114,7 @@ test "posix: [:blank:] matches space and tab" {
114114
115115test "posix: [:print:] matches printable characters" {
116116 const allocator = std.testing.allocator;
117 var regex = try Regex.compile(allocator, "[[:print:]]+");
117 var regex = try Regex.compile(allocator, std.testing.io, "[[:print:]]+");
118118 defer regex.deinit();
119119
120120 try std.testing.expect(try regex.isMatch("Hello World!"));
@@ -124,7 +124,7 @@ test "posix: [:print:] matches printable characters" {
124124
125125test "posix: [:graph:] matches visible characters" {
126126 const allocator = std.testing.allocator;
127 var regex = try Regex.compile(allocator, "[[:graph:]]+");
127 var regex = try Regex.compile(allocator, std.testing.io, "[[:graph:]]+");
128128 defer regex.deinit();
129129
130130 try std.testing.expect(try regex.isMatch("Hello"));
@@ -136,7 +136,7 @@ test "posix: [:graph:] matches visible characters" {
136136
137137test "posix: [:cntrl:] matches control characters" {
138138 const allocator = std.testing.allocator;
139 var regex = try Regex.compile(allocator, "[[:cntrl:]]");
139 var regex = try Regex.compile(allocator, std.testing.io, "[[:cntrl:]]");
140140 defer regex.deinit();
141141
142142 try std.testing.expect(try regex.isMatch("\x00"));
@@ -149,7 +149,7 @@ test "posix: [:cntrl:] matches control characters" {
149149
150150test "posix: combined with regular characters" {
151151 const allocator = std.testing.allocator;
152 var regex = try Regex.compile(allocator, "[[:alpha:]0-9_]+");
152 var regex = try Regex.compile(allocator, std.testing.io, "[[:alpha:]0-9_]+");
153153 defer regex.deinit();
154154
155155 try std.testing.expect(try regex.isMatch("hello123"));
@@ -159,7 +159,7 @@ test "posix: combined with regular characters" {
159159
160160test "posix: multiple POSIX classes in one bracket" {
161161 const allocator = std.testing.allocator;
162 var regex = try Regex.compile(allocator, "[[:alpha:][:digit:]]+");
162 var regex = try Regex.compile(allocator, std.testing.io, "[[:alpha:][:digit:]]+");
163163 defer regex.deinit();
164164
165165 try std.testing.expect(try regex.isMatch("abc123"));
@@ -169,7 +169,7 @@ test "posix: multiple POSIX classes in one bracket" {
169169
170170test "posix: extract words with [:alpha:]" {
171171 const allocator = std.testing.allocator;
172 var regex = try Regex.compile(allocator, "[[:alpha:]]+");
172 var regex = try Regex.compile(allocator, std.testing.io, "[[:alpha:]]+");
173173 defer regex.deinit();
174174
175175 const text = "Hello World 123";
@@ -189,7 +189,7 @@ test "posix: extract words with [:alpha:]" {
189189
190190test "posix: extract hex numbers with [:xdigit:]" {
191191 const allocator = std.testing.allocator;
192 var regex = try Regex.compile(allocator, "0x[[:xdigit:]]+");
192 var regex = try Regex.compile(allocator, std.testing.io, "0x[[:xdigit:]]+");
193193 defer regex.deinit();
194194
195195 const text = "Colors: 0xFF5733 and 0xABCDEF";
@@ -209,7 +209,7 @@ test "posix: extract hex numbers with [:xdigit:]" {
209209
210210test "posix: validate identifier with [:alnum:]" {
211211 const allocator = std.testing.allocator;
212 var regex = try Regex.compile(allocator, "^[[:alpha:]_][[:alnum:]_]*$");
212 var regex = try Regex.compile(allocator, std.testing.io, "^[[:alpha:]_][[:alnum:]_]*$");
213213 defer regex.deinit();
214214
215215 try std.testing.expect(try regex.isMatch("valid_identifier"));
@@ -221,7 +221,7 @@ test "posix: validate identifier with [:alnum:]" {
221221
222222test "posix: split on whitespace with [:space:]" {
223223 const allocator = std.testing.allocator;
224 var regex = try Regex.compile(allocator, "[[:space:]]+");
224 var regex = try Regex.compile(allocator, std.testing.io, "[[:space:]]+");
225225 defer regex.deinit();
226226
227227 const text = "one\ttwo\nthree four";