summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/patches.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/build/patches.zig b/build/patches.zig
index 7d87b9f1..410d27ab 100644
--- a/build/patches.zig
+++ b/build/patches.zig
@@ -356,6 +356,15 @@ pub fn ghosttyKitty(b: *std.Build, patch: *std.Build.Step.Compile, dep: *std.Bui
/// could compile one typed pattern differently. Unreported upstream as
/// of 3efcfe33 (its trunk on 2026-11-19); docs/mvzr-bounds.md is the
/// report for it.
+/// - Three kinds of pattern the matcher indexed an empty slice on (a panic
+/// in a safe build, at a key typed into `s` or `/`): an empty group with
+/// more after it (`()a`, `a()b`: whether the group may match nothing was
+/// asked of its inside's first operation, which it has not got); a
+/// repeat right after `|` or `^` (`a|*`, `|??`, `^*`: it took the `|` or
+/// the `^` for what it repeats; at the pattern's start it was already
+/// refused); and a count that ends in neither `,` nor `}` (`({1))`: the
+/// character after it was skipped and a hole left in the program, which
+/// ends it there). docs/mvzr-empty-group.md is the report for upstream.
const mvzr_edits = [_]Edit{
.{
.old = "fn matchPattern(patt: []const RegOp, sets: []const CharSet, haystack: []const u8, i_in: usize) ?OpMatch {\n",
@@ -419,6 +428,12 @@ const mvzr_edits = [_]Edit{
.{ .old = "fn valueFor(in: []const u8) ?u8 {\n", .new = "fn valueFor(in: []const u8) ?u8 {\n if (in.len == 0) return null;\n" },
.{ .old = " return parseHex(in[1..4]) catch return null;\n", .new = " return parseHex(in[1..3]) catch return null;\n" },
.{ .old = " if (i == in.len or in[i] != ']') {\n return BadString;\n", .new = " if (i >= in.len or in[i] != ']') {\n return BadString;\n" },
+ // What compiles is a program the matcher can walk: an empty pattern
+ // accepts the empty string; a repeat repeats an operation; a count is
+ // closed.
+ .{ .old = "fn patternAcceptsEmpty(patt: []const RegOp) bool {\n", .new = "fn patternAcceptsEmpty(patt: []const RegOp) bool {\n if (patt.len == 0) return true;\n" },
+ .{ .old = " if (j == 0 or patt[j] == .begin) return BadString;\n", .new = " if (j == 0 or patt[j - 1] == .begin or patt[j - 1] == .alt) return BadString;\n" },
+ .{ .old = " } else if (in[i] == '}') {\n // {M}\n", .new = " } else if (in[i] != '}') {\n bad_string = true;\n break :dispatch;\n } else {\n // {M}\n" },
.{ .old = "for (c1..c2 + 1) |c_range|", .new = "for (c1..@as(usize, c2) + 1) |c_range|" },
.{ .old = "[1]RegOp{.{ .unused = {} }} ** ops", .new = "@splat(.{ .unused = {} })" },
.{ .old = "[1]CharSet{.{ .low = 0, .hi = 0 }} ** char_sets", .new = "@splat(.{ .low = 0, .hi = 0 })" },