From e8e7ed956f3914a3790e980df0862b26c30bd611 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 14:39:47 -0300 Subject: idioms #20, the bound in the type or the cut handled: of the 166 `catch unreachable` the pass kept, 64 stay where a reader checks the bound without arithmetic (an integer's digits, a declared field's size, and now the daemon's pid lists and the clock's two-digit fields written in their types), 69 texts print through Kind.Buf at their old size, 31 handle the failure once (a print into ename cut at its 320, paneText's line cut where its buffer fills, a log record or mouse report dropped rather than cut short, the question's letters that fit), Newcol's and pane/new's refusals are comptime strings, and dropUnsaved's too-long scratch name is null, not an empty sentinel Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/host_io.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/host_io.zig') diff --git a/src/host_io.zig b/src/host_io.zig index 6ce26e41..9e0292b3 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -231,8 +231,8 @@ pub const Adoptions = struct { /// takes this pty instead of forking a shell (`take`). pub fn adoptShell(a: *Adoptions, core: *pardes.Pardes, pid: libc.pid_t, fd: c_int) void { if (pid == 0) { - var buf: [96]u8 = undefined; - return core.setMessage(core.view().active, if (a.taken == 0) "Adopt: no shell of a session that died is waiting" else std.fmt.bufPrint(&buf, "Adopt: {d} shell{s} taken in; what they showed is gone", .{ a.taken, if (a.taken == 1) "" else "s" }) catch unreachable); // a count fits 96 + var buf: pardes.Kind.Buf(96) = .{}; + return core.setMessage(core.view().active, if (a.taken == 0) "Adopt: no shell of a session that died is waiting" else buf.print("Adopt: {d} shell{s} taken in; what they showed is gone", .{ a.taken, if (a.taken == 1) "" else "s" })); } if (a.len < a.list.len) { a.list[a.len] = .{ .pid = pid, .fd = fd, .pane = null }; @@ -246,8 +246,8 @@ pub const Adoptions = struct { } // No room for it: its master goes, and the shell with this session. _ = libc.close(fd); - var buf: [96]u8 = undefined; - core.setMessage(core.view().active, std.fmt.bufPrint(&buf, "Adopt: no room for shell {d}; it ends with this session", .{pid}) catch unreachable); // a pid fits 96 + var buf: pardes.Kind.Buf(96) = .{}; + core.setMessage(core.view().active, buf.print("Adopt: no room for shell {d}; it ends with this session", .{pid})); } /// The adopted shell pane `pane`'s spawn takes, off the list. -- cgit v1.3