diff options
Diffstat (limited to 'src/ninep')
| -rw-r--r-- | src/ninep/events.zig | 7 | ||||
| -rw-r--r-- | src/ninep/tree.zig | 3 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/ninep/events.zig b/src/ninep/events.zig index 45569b22..3da6f723 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -216,9 +216,12 @@ pub fn noteError(p: *Pardes, req: Req, reply: Reply) void { }; } var buf: [256]u8 = undefined; + // A reason that names its file already (`look: no space...` from a + // look) is not prefixed twice: `err 3 look: no space...`. + const reason = if (why.len > file.len + 2 and std.ascii.startsWithIgnoreCase(why, file) and std.mem.startsWith(u8, why[file.len..], ": ")) why[file.len + 2 ..] else why; // A long reason is cut between words, with an ellipsis, never mid-word. - const kept = pardes.Messages.clip(why, 200); - const record = std.fmt.bufPrint(&buf, "err {s} {s}: {s}{s}\n", .{ serial, file, kept, if (kept.len < why.len) "…" else "" }) catch return; + const kept = pardes.Messages.clip(reason, 200); + const record = std.fmt.bufPrint(&buf, "err {s} {s}: {s}{s}\n", .{ serial, file, kept, if (kept.len < reason.len) "…" else "" }) catch return; for (record[0 .. record.len - 1]) |*c| if (c.* < ' ') { c.* = ' '; }; diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index c089c31d..9d2027bf 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -1470,6 +1470,9 @@ test "at the pane cap, pane/new, look and New each say so, and look reads back e const looked = th.wr(p, look_node, try std.fmt.bufPrint(&line, "{s}/f.txt\n", .{dir})); try testing.expect(looked.errno() != 0); try testing.expect(std.mem.indexOf(u8, looked.reply.ename, said) != null); + // Its err record names the file once: `look: no space...`. + try testing.expect(th.logHas(p, "look: no space")); + try testing.expect(!th.logHas(p, "look: look:")); try testing.expectEqualStrings("", th.rd(p, look_node, 0, 64).bytes); // New from a pane's ctl fails as well. const ctl_node = Node.of(p.panes[0].?.serial, .ctl); |
