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
src/unicode.zigmodified+95-58
Changes to src/unicode.zig
@@ -261,62 +261,99 @@ test "UTF-8 encoding" {
261261/// Unicode property names for \p{Property} matching
262262pub const UnicodeProperty = enum {
263263 // General categories (short & long forms)
264 Letter, L,
265 Lowercase_Letter, Ll,
266 Uppercase_Letter, Lu,
267 Titlecase_Letter, Lt,
268 Modifier_Letter, Lm,
269 Other_Letter, Lo,
270
271 Mark, M,
272 Nonspacing_Mark, Mn,
273 Spacing_Mark, Mc,
274 Enclosing_Mark, Me,
275
276 Number, N,
277 Decimal_Number, Nd,
278 Letter_Number, Nl,
279 Other_Number, No,
280
281 Punctuation, P,
282 Connector_Punctuation, Pc,
283 Dash_Punctuation, Pd,
284 Open_Punctuation, Ps,
285 Close_Punctuation, Pe,
286 Initial_Punctuation, Pi,
287 Final_Punctuation, Pf,
288 Other_Punctuation, Po,
289
290 Symbol, S,
291 Math_Symbol, Sm,
292 Currency_Symbol, Sc,
293 Modifier_Symbol, Sk,
294 Other_Symbol, So,
295
296 Separator, Z,
297 Space_Separator, Zs,
298 Line_Separator, Zl,
299 Paragraph_Separator, Zp,
300
301 Other, C,
302 Control, Cc,
303 Format, Cf,
304 Surrogate, Cs,
305 Private_Use, Co,
306 Not_Assigned, Cn,
264 Letter,
265 L,
266 Lowercase_Letter,
267 Ll,
268 Uppercase_Letter,
269 Lu,
270 Titlecase_Letter,
271 Lt,
272 Modifier_Letter,
273 Lm,
274 Other_Letter,
275 Lo,
276
277 Mark,
278 M,
279 Nonspacing_Mark,
280 Mn,
281 Spacing_Mark,
282 Mc,
283 Enclosing_Mark,
284 Me,
285
286 Number,
287 N,
288 Decimal_Number,
289 Nd,
290 Letter_Number,
291 Nl,
292 Other_Number,
293 No,
294
295 Punctuation,
296 P,
297 Connector_Punctuation,
298 Pc,
299 Dash_Punctuation,
300 Pd,
301 Open_Punctuation,
302 Ps,
303 Close_Punctuation,
304 Pe,
305 Initial_Punctuation,
306 Pi,
307 Final_Punctuation,
308 Pf,
309 Other_Punctuation,
310 Po,
311
312 Symbol,
313 S,
314 Math_Symbol,
315 Sm,
316 Currency_Symbol,
317 Sc,
318 Modifier_Symbol,
319 Sk,
320 Other_Symbol,
321 So,
322
323 Separator,
324 Z,
325 Space_Separator,
326 Zs,
327 Line_Separator,
328 Zl,
329 Paragraph_Separator,
330 Zp,
331
332 Other,
333 C,
334 Control,
335 Cc,
336 Format,
337 Cf,
338 Surrogate,
339 Cs,
340 Private_Use,
341 Co,
342 Not_Assigned,
343 Cn,
307344
308345 pub fn fromString(s: []const u8) ?UnicodeProperty {
309346 const map = std.StaticStringMap(UnicodeProperty).initComptime(.{
310 .{ "Letter", .Letter }, .{ "L", .L },
347 .{ "Letter", .Letter }, .{ "L", .L },
311348 .{ "Lowercase_Letter", .Lowercase_Letter }, .{ "Ll", .Ll },
312349 .{ "Uppercase_Letter", .Uppercase_Letter }, .{ "Lu", .Lu },
313 .{ "Number", .Number }, .{ "N", .N },
314 .{ "Decimal_Number", .Decimal_Number }, .{ "Nd", .Nd },
315 .{ "Punctuation", .Punctuation }, .{ "P", .P },
316 .{ "Symbol", .Symbol }, .{ "S", .S },
317 .{ "Separator", .Separator }, .{ "Z", .Z },
318 .{ "Space_Separator", .Space_Separator }, .{ "Zs", .Zs },
319 .{ "Control", .Control }, .{ "Cc", .Cc },
350 .{ "Number", .Number }, .{ "N", .N },
351 .{ "Decimal_Number", .Decimal_Number }, .{ "Nd", .Nd },
352 .{ "Punctuation", .Punctuation }, .{ "P", .P },
353 .{ "Symbol", .Symbol }, .{ "S", .S },
354 .{ "Separator", .Separator }, .{ "Z", .Z },
355 .{ "Space_Separator", .Space_Separator }, .{ "Zs", .Zs },
356 .{ "Control", .Control }, .{ "Cc", .Cc },
320357 });
321358 return map.get(s);
322359 }
formatting only · 8 hidden lines
Changes to src/unicode.zig
@@ -368,7 +405,7 @@ test "Unicode property matching" { formatting only
368405// Edge case tests
369406test "unicode: invalid UTF-8 sequences" {
370407 // Truncated multi-byte sequence
371 const truncated = [_]u8{ 0xC3 }; // Should be 2 bytes but only 1
408 const truncated = [_]u8{0xC3}; // Should be 2 bytes but only 1
372409 try std.testing.expectError(error.InvalidUtf8, decodeUtf8(&truncated));
373410
374411 // Invalid continuation byte
formatting only · 18 hidden lines
Changes to src/unicode.zig
@@ -432,12 +469,12 @@ test "unicode: round-trip encoding/decoding" { formatting only
432469
433470 // Test various codepoints can be encoded and decoded back
434471 const test_codepoints = [_]Codepoint{
435 0x0000, 0x007F, // ASCII boundaries
436 0x0080, 0x07FF, // 2-byte boundaries
437 0x0800, 0xFFFF, // 3-byte boundaries
438 0x10000, 0x10FFFF, // 4-byte boundaries
439 'a', 'Z', '0', '9', // Common ASCII
440 0x00E9, 0x20AC, // Common non-ASCII
472 0x0000, 0x007F, // ASCII boundaries
473 0x0080, 0x07FF, // 2-byte boundaries
474 0x0800, 0xFFFF, // 3-byte boundaries
475 0x10000, 0x10FFFF, // 4-byte boundaries
476 'a', 'Z', '0', '9', // Common ASCII
477 0x00E9, 0x20AC, // Common non-ASCII
441478 };
442479
443480 for (test_codepoints) |cp| {