diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 00:03:55 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 01:16:28 -0300 |
| commit | a92951b11ab3aa2cdf759b3b743f8af006c21b95 (patch) | |
| tree | b63d45772ea2053f0feb796e5893b81f88a1bf0c /src/ninep/addr.zig | |
| parent | bbb4362a46de8e8d10a6a937e61ccc8f3a0ba4b3 (diff) | |
| download | pardes-a92951b11ab3aa2cdf759b3b743f8af006c21b95.tar.gz pardes-a92951b11ab3aa2cdf759b3b743f8af006c21b95.zip | |
regexp, sam_edit, ninep/addr: a pattern's compile error is told by Regex.message(err), which replaces the five e_ constants and the two switches that mapped errors onto them
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/ninep/addr.zig')
| -rw-r--r-- | src/ninep/addr.zig | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/ninep/addr.zig b/src/ninep/addr.zig index 710dca38..72a2d815 100644 --- a/src/ninep/addr.zig +++ b/src/ninep/addr.zig @@ -285,14 +285,7 @@ pub const Addr = struct { return null; } var rx = regexp_.Regex.compile(pat) catch |err| { - a.err = switch (err) { - error.Anchor => regexp_.Regex.e_anchor, - error.TooLong => regexp_.Regex.e_long, - error.WideRange => regexp_.Regex.e_wide, - error.NegatedRunes => regexp_.Regex.e_negated, - error.Mixed => regexp_.Regex.e_mixed, - error.Bad => e_regexp, - }; + a.err = if (err == error.Bad) e_regexp else regexp_.Regex.message(err); return null; }; // sam's nextmatch (editors/sam/address.c:97-119): an empty match @@ -392,7 +385,7 @@ test "an alternation anchoring some branches and not others is refused with why, for ([_][]const u8{ "/^def|x/", "/foo$|^zèbre/" }) |pat| { const r = th.wr(p, node, pat); try testing.expectEqual(E.INVAL, r.errno()); - try testing.expectEqualStrings(regexp_.Regex.e_mixed, r.reply.ename); + try testing.expectEqualStrings(regexp_.Regex.message(error.Mixed), r.reply.ename); } try testing.expectEqual(Status.ok, th.wr(p, node, "/foo$|def/").reply.status); } @@ -402,7 +395,7 @@ test "a pattern with a newline and an anchor mvzr would misread is refused EINVA defer p.deinit(); const r = th.wr(p, Node.of(th.serialOf(p), .addr), "/(^|\\n)foo/"); try testing.expectEqual(E.INVAL, r.errno()); - try testing.expectEqualStrings(regexp_.Regex.e_anchor, r.reply.ename); + try testing.expectEqualStrings(regexp_.Regex.message(error.Anchor), r.reply.ename); const e = th.wr(p, Node.of(th.serialOf(p), .ctl), "Edit ,x/(^|\\n)foo/d\n"); try testing.expectEqual(E.INVAL, e.errno()); } |
