summaryrefslogtreecommitdiff
path: root/src/ninep/events.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 09:16:54 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commitc2cc0d9f212fdb285a11cbceaa16a30ad3236743 (patch)
treefe339b453de19d1d7aad0f3f862c99772212c1d9 /src/ninep/events.zig
parent49d5bf5ebfe4a84070b7eac1e9d8ac52e1cc45fd (diff)
downloadpardes-c2cc0d9f212fdb285a11cbceaa16a30ad3236743.tar.gz
pardes-c2cc0d9f212fdb285a11cbceaa16a30ad3236743.zip
An err record's reason that names its file already is not prefixed twice
A refused look logged `err N look: look: no space for a pane...`: the reason began with the file's name, and the record put it before it again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/events.zig')
-rw-r--r--src/ninep/events.zig7
1 files changed, 5 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.* = ' ';
};