diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-30 13:59:25 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:17 -0300 |
| commit | 9ca008a27c4ab83a29c1798f4eb081eef372624c (patch) | |
| tree | 53723e46dd928d566ffa6b625911f755d53d83c0 /src/ninep/ctl.zig | |
| parent | e8fc2964acdf7156ab0c9961b7bf83d74f152192 (diff) | |
| download | pardes-9ca008a27c4ab83a29c1798f4eb081eef372624c.tar.gz pardes-9ca008a27c4ab83a29c1798f4eb081eef372624c.zip | |
A look at file:3:0 is refused as addr 3:0 is: a column counts from 1
addr refuses a column 0 with EINVAL, "address out of range: a column
counts from 1". A look took `file:3:0` as line 3 with no column, since
the parser holds no column as 0, and succeeded. Now a look whose column,
or end column, is written as 0 is refused with addr's words and errno.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/ctl.zig')
| -rw-r--r-- | src/ninep/ctl.zig | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index cf0b241c..4312653c 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -289,7 +289,8 @@ fn failureErrno(failure: []const u8) u16 { if (std.mem.indexOf(u8, failure, "no such") != null or std.mem.indexOf(u8, failure, "not found") != null) return E.NOENT; // A pattern refused (Edit's too) is malformed input, as 9ns reads it; // so is a word this build has not (`invalid: acme's Put ...`). - if (std.mem.indexOf(u8, failure, "bad regular expression") != null or std.mem.startsWith(u8, failure, "invalid")) return E.INVAL; + if (std.mem.indexOf(u8, failure, "bad regular expression") != null or std.mem.startsWith(u8, failure, "invalid") or + std.mem.startsWith(u8, failure, "address out of range")) return E.INVAL; return E.IO; } @@ -2504,6 +2505,18 @@ test "with no pane at all, the root look opens its file and the root exec runs i try testing.expectEqualStrings(session, made.cwdSlice()); } +test "a look at file:3:0 is refused as addr 3:0 is, a column counting from 1" { + const p = try withFile(testing.allocator, "one\ntwo\nthree\n"); + defer p.deinit(); + const serial = serialOf(p); + const by_addr = wr(p, Node.of(serial, .addr), "3:0"); + const by_look = wr(p, Node.of(serial, .look), "/test.txt:3:0\n"); + try testing.expectEqual(E.INVAL, by_addr.errno()); + try testing.expectEqual(E.INVAL, by_look.errno()); + try testing.expectEqualStrings(by_addr.reply.ename, by_look.reply.ename); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .look), "/test.txt:3:1\n").reply.status); +} + test "a line starting with # runs as nothing at an exec or a ctl, silently" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); |
