diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ninep/ctl.zig | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 9092a307..5d08a77f 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -661,10 +661,12 @@ pub fn writeRoot(p: *Pardes, req: Req) Reply { continue; } if (std.mem.startsWith(u8, line, "size ") or std.mem.eql(u8, line, "size")) { - const size = sizeOf(line) orelse return refuse(p, req, e_size, line); + // The offending word is the value: `size 5 5` quotes "5 5". + const value = std.mem.trim(u8, line["size".len..], " \t"); + const size = sizeOf(line) orelse return refuseQuoting(p, req, e_size, value); // A frontend's window is the size; only a session none is // attached to (--detach, unattended) takes one written. - if (!p.unattended) return refuse(p, req, "size: a frontend is attached and owns the size", line); + if (!p.unattended) return refuseQuoting(p, req, "size: a frontend is attached and owns the size", value); if (apply) { const was: [2]u16 = .{ p.screen_w, p.screen_h }; const before = p.rects; @@ -677,7 +679,7 @@ pub fn writeRoot(p: *Pardes, req: Req) Reply { if (!pardes.layout.minimaFit(p)) { p.update(.{ .resize = .{ .cols = was[0], .rows = was[1] } }); p.sync(); - return refuse(p, req, "size: too small for the panes, each its tag and 2 rows", line); + return refuseQuoting(p, req, "size: too small for the panes, each its tag and 2 rows", value); } pardes.layout.restoreMinima(p, &before); p.sync(); @@ -2392,6 +2394,8 @@ test "size sets the screen of a session no frontend is attached to, and only of try testing.expectEqual(E.INVAL, wr(p, root_ctl, "size 120\n").errno()); try testing.expectEqual(E.INVAL, wr(p, root_ctl, "size\n").errno()); try testing.expect(std.mem.indexOf(u8, wr(p, root_ctl, "size 5 2\n").reply.ename, "at least 20x6, at most 4096x4096") != null); + // The bad value quoted, never the word size. + try testing.expect(std.mem.endsWith(u8, wr(p, root_ctl, "size 5 2\n").reply.ename, "\"5 2\"")); // Too small for the panes it has, each its tag and two rows: refused, // the size as it was. for (0..4) |_| p.newScratchBelow(p.active); |
