summaryrefslogtreecommitdiff
path: root/src/regexp.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 01:18:56 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commite6e81a6bc544c5ab5a47c21d85e6868020031abb (patch)
treea2a9947d01ba0e6b1d36ccf4020816d2e0c6ca61 /src/regexp.zig
parent65612a1cc13dd2a7e866f88176dbf6db5dd83467 (diff)
downloadpardes-e6e81a6bc544c5ab5a47c21d85e6868020031abb.tar.gz
pardes-e6e81a6bc544c5ab5a47c21d85e6868020031abb.zip
regexp: a class's range may end at \xff: mvzr counted `c1..c2 + 1` in a u8, which overflowed at 0xff (a panic in a safe build, a loop past its bounds in a fast one), so `[\x80-\xff]` in any search, an address, s or S, a plumbing rule, took the editor down; build.zig's patch of mvzr widens the count to usize, beside its other patches (one occurrence, checked); found writing the plumber's rules, whose classes for UTF-8 names the design record wrote as \x80-\xff; test: a class of a-z and the high bytes finds café, [\xff-\xff] compiles; the changelog says so
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/regexp.zig')
-rw-r--r--src/regexp.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/regexp.zig b/src/regexp.zig
index 7bcbceff..87fc51d6 100644
--- a/src/regexp.zig
+++ b/src/regexp.zig
@@ -595,6 +595,14 @@ test "a \\x without two hex digits is refused, not handed to mvzr to panic on" {
try std.testing.expectEqual(@as(usize, 1), (try rx.find("xA", 0, 1, 2)).?.start);
}
+test "a class's range may end at \\xff: UTF-8's high bytes as one class" {
+ var rx = try Regex.compile("[a-z\\x80-\\xff]+");
+ const text = "-- café --";
+ const m = (try rx.find(text, 0, text.len, text.len)).?;
+ try std.testing.expectEqualStrings("café", text[m.start..m.end]);
+ _ = try Regex.compile("[\\xff-\\xff]");
+}
+
test "a repeat inside a group gives back to what follows the group" {
const Case = struct { pat: []const u8, text: []const u8, start: usize, end: usize };
for ([_]Case{