summaryrefslogtreecommitdiff
path: root/src/ninep
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 16:26:07 -0300
committerGabriel Schneider <[email protected]>2026-11-05 22:03:21 -0300
commit9b525aca9b1fc177873bc3a581bd2a7887bee63d (patch)
treea902794d5ca75f0269f85db1485ab85ad455c8eb /src/ninep
parentce7273b3de52b3d42fedf21fc8cc96316ccab9ed (diff)
downloadpardes-9b525aca9b1fc177873bc3a581bd2a7887bee63d.tar.gz
pardes-9b525aca9b1fc177873bc3a581bd2a7887bee63d.zip
ninep: a ctl write refused for a control character takes the line it is in with it, as one refused for its length does: the start an earlier write held, which ran at the clunk as a second err record for one failed write (the 9P monkey's seed 2, shrunk to zig build monkey-session -Dplatform=tui -- --seed 2 --steps 763 --only 761,762), and the rest the next write brings, through its newline (src/ninep/tree.zig writeLines, ninep's file, the one place); a T1 test pins it (test/behaviour/rules.zig, 'a write refused for a control character takes its line with it'), failing before on the third write, which ran the held start and the tail as one line; gates on tui: core-test 960/960, behaviour-test 238/238; monkey-session seeds 1 to 10 clean
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/ninep')
-rw-r--r--src/ninep/tree.zig13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig
index 707ce40a..3b8a8581 100644
--- a/src/ninep/tree.zig
+++ b/src/ninep/tree.zig
@@ -1258,8 +1258,17 @@ pub fn holdsPage(p: *Pardes, req: Req) bool {
fn writeLines(p: *Pardes, req: Req, target: Target) Reply {
// A command line holds no control character but a tab: the whole write
- // is refused at once, not held to fail unseen at the close.
- if (resultsFile(target) or ctlFile(target)) for (req.data) |c| if ((c < ' ' and c != '\t' and c != '\n' and c != '\r') or c == 0x7f) return failText(req.tag, E.INVAL, ctl.e_control);
+ // is refused at once, not held to fail unseen at the close, and the
+ // line it is in goes with it, as one refused for its length does: the
+ // start a write before held, and the rest, through its newline, that
+ // the next write brings.
+ if (resultsFile(target) or ctlFile(target)) for (req.data) |c| if ((c < ' ' and c != '\t' and c != '\n' and c != '\r') or c == 0x7f) {
+ if (openOf(p, req)) |o| if (o.what == .lines or o.what == .ctl) {
+ o.pending.clearRetainingCapacity();
+ o.discarding = !std.mem.endsWith(u8, req.data, "\n");
+ };
+ return failText(req.tag, E.INVAL, ctl.e_control);
+ };
// A NUL no name may hold fails its write at once, not the close.
if (target == .pane and target.pane.file == .name and std.mem.indexOfScalar(u8, req.data, 0) != null)
return failText(req.tag, E.INVAL, pane.e_name_char ++ ": a NUL");