summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-22 19:01:54 -0300
committerGabriel Schneider <[email protected]>2026-11-22 19:01:54 -0300
commit79b73e14711e48e61d0f742622671a8fcfd8d054 (patch)
tree16c4e9815c090008f03752739b6d4590d26caa01 /core
parentb3c38ea198e1fe915f029d7e41b469b8a53d2338 (diff)
parent19386feb0074afc1afed6e8ebe8596c426e4bdb0 (diff)
downloadpardes-79b73e14711e48e61d0f742622671a8fcfd8d054.tar.gz
pardes-79b73e14711e48e61d0f742622671a8fcfd8d054.zip
integration: the pair's chain and the regular expressions' three panics on the gathered line: pardes-pair-11 (`kpskrqqt`: pardes-merge57 with the pair's ten changes merged past the four already there, its conflicts resolved by the agent that gated it: a window client's Font, an addon's landing on the tape and a near client loading it by path when its bytes are the session's, a window's facts its client's, the terminal put back when a pair's client dies without a word, a Restore telling its clients, daemon.py's --with-pair and the Restore test) and pardes-regex-3 (`szlonulo` on `qzrzlnox`, on pardes-merge57: mvzr panicked on an empty group with more after it, a repeat right after | or ^, a count ending in neither , nor }: three Edits in build/patches.zig, docs/mvzr-empty-group.md, the test of every short pattern); no conflict; core-test 917/1074 (157 skipped), shell-test 1116/1119; its gate: .scratch/sketch/reorg/merge58, the numbers in PARDES.md (2026-11-22)
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core')
-rw-r--r--core/regexp.zig45
1 files changed, 45 insertions, 0 deletions
diff --git a/core/regexp.zig b/core/regexp.zig
index 2936b491..4a51d0ce 100644
--- a/core/regexp.zig
+++ b/core/regexp.zig
@@ -681,3 +681,48 @@ test "a pattern that stops inside a count or an escape is refused, not read past
}
}
}
+
+test "what mvzr compiles it can walk: an empty group matches the empty string; a repeat of `|` or `^`, and a count without its `}`, are refused" {
+ std.testing.log_level = .err; // mvzr warns of each bad string
+ // An empty group with more after it, searched to a line's end, where
+ // mvzr asks whether the group may match nothing (build/patches.zig).
+ const Case = struct { pat: []const u8, text: []const u8, hit: ?[2]usize };
+ for ([_]Case{
+ .{ .pat = "()a", .text = "b", .hit = null },
+ .{ .pat = "()a", .text = "ba", .hit = .{ 1, 2 } },
+ .{ .pat = "a()b", .text = "a", .hit = null },
+ .{ .pat = "a()b", .text = "xab", .hit = .{ 1, 3 } },
+ }) |c| {
+ var rx = try Regex.compile(c.pat);
+ const m = try rx.find(c.text, 0, c.text.len, c.text.len);
+ try std.testing.expectEqual(c.hit, if (m) |h| [2]usize{ h.start, h.end } else null);
+ }
+ // A repeat right after `|` or `^` took it for what it repeats, and a
+ // count ending in neither `,` nor `}` left a hole in the program: each
+ // walked off an empty slice in the matcher.
+ for ([_][]const u8{ "a|*", "|+", "(|?)", "|??", "^*", "^+?", "a|{2}", "({1))", "a{1b" }) |pat|
+ try std.testing.expectError(error.Bad, Regex.compile(pat));
+ // Every pattern up to five characters over the first alphabet and four
+ // over the second, searched from every offset of a text with an empty
+ // line: refused, or searched to an answer inside the budget.
+ const text = "aa\n\na";
+ var pat: [5]u8 = undefined;
+ for ([_][]const u8{ "()|*+?a", "()|*+?a^{1}" }, [_]usize{ 5, 4 }) |alphabet, longest| {
+ for (1..longest + 1) |len| {
+ var n: usize = 1;
+ for (0..len) |_| n *= alphabet.len;
+ for (0..n) |k| {
+ var rest = k;
+ for (pat[0..len]) |*c| {
+ c.* = alphabet[rest % alphabet.len];
+ rest /= alphabet.len;
+ }
+ var rx = Regex.compile(pat[0..len]) catch continue;
+ for (0..text.len + 1) |from| {
+ const m = try rx.find(text, from, text.len, text.len) orelse continue;
+ try std.testing.expect(from <= m.start and m.start <= m.end and m.end <= text.len);
+ }
+ }
+ }
+ }
+}