diff options
Diffstat (limited to 'src/Core.zig')
| -rw-r--r-- | src/Core.zig | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/Core.zig b/src/Core.zig index 413de233..775d1e9a 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -531,7 +531,7 @@ fn initSession(gpa: std.mem.Allocator, opts: Options) !*Pardes { if (opts.file_line > 0) { var said: pardes.Kind.Buf(160) = .{}; var place: [20]u8 = undefined; - _ = pardes.Kind.address(p, 0, std.fmt.bufPrint(&place, "{d}", .{opts.file_line}) catch unreachable, &said); // a usize + _ = pardes.Kind.address(p, 0, std.fmt.bufPrint(&place, "{d}", .{opts.file_line}) catch unreachable, &said); // a usize fits 20 } } else |_| {} break :initial_doc made; @@ -1296,10 +1296,10 @@ fn sayShellFailure(p: *Pardes, id: u8, err: anyerror) void { p.reportFailure(id, "shell: directory missing (no such directory)"); } else if (err == error.InterpreterNotFound) { // The script is there; the program its `#!` names is not. - var said: [320]u8 = undefined; + var said: pardes.Kind.Buf(320) = .{}; var interp: [256]u8 = undefined; const name = tape.value(.interpreter, missingInterpreter, .{ pane.shell orelse p.shellBin(), &interp }); - p.reportFailure(id, if (name) |n| std.fmt.bufPrint(&said, "shell: interpreter {s} not found", .{n}) catch unreachable else "shell: interpreter not found"); + p.reportFailure(id, if (name) |n| said.print("shell: interpreter {s} not found", .{n}) else "shell: interpreter not found"); } else { p.reportError(id, "shell", err); } @@ -1338,13 +1338,12 @@ pub fn saveFailed(p: *Pardes, id: u8, path: []const u8, err: anyerror) void { // A write into a directory that is not there: said so, in the words // a mount reads as ENOENT; EACCES when one above refuses. const parent = parentTrouble(path, err); - const shown = path[0..@min(path.len, limits.host_path_cap)]; // what fits `what` if (parent.denied) - p.reportFailure(id, std.fmt.bufPrint(&what, "Save {s}: permission denied", .{shown}) catch unreachable) + p.reportFailure(id, std.fmt.bufPrint(&what, "Save {s}: permission denied", .{path[0..@min(path.len, limits.host_path_cap)]}) catch unreachable) // cap + 24 fits cap + 32 else if (parent.missing) - p.reportFailure(id, std.fmt.bufPrint(&what, "Save {s}: no such directory", .{shown}) catch unreachable) + p.reportFailure(id, std.fmt.bufPrint(&what, "Save {s}: no such directory", .{path[0..@min(path.len, limits.host_path_cap)]}) catch unreachable) // cap + 24 fits cap + 32 else - p.reportError(id, std.fmt.bufPrint(&what, "Save {s}", .{shown}) catch unreachable, err); + p.reportError(id, std.fmt.bufPrint(&what, "Save {s}", .{path[0..@min(path.len, limits.host_path_cap)]}) catch unreachable, err); // cap + 5 fits cap + 32 p.noteLateFailure(id); } @@ -1356,17 +1355,17 @@ pub fn dumpFailed(p: *Pardes, path: []const u8, err: anyerror) void { const taped = tape.enter(p, .{ .dump_failed = .{ .path = path, .err = err } }); defer tape.leave(p, taped); var what: [limits.host_path_cap + 8]u8 = undefined; - const operation = std.fmt.bufPrint(&what, "Dump {s}", .{path[0..@min(path.len, limits.host_path_cap)]}) catch unreachable; + const operation = std.fmt.bufPrint(&what, "Dump {s}", .{path[0..@min(path.len, limits.host_path_cap)]}) catch unreachable; // cap + 5 fits cap + 8 // Into a DumpDir that is not there: said so, ENOENT, as a Save is; // one that is there but no directory (`/dev/null`) says that. const parent = parentTrouble(path, err); - var said: [limits.host_path_cap + 48]u8 = undefined; + var said: pardes.Kind.Buf(limits.host_path_cap + 48) = .{}; if (parent.denied and parent.kind == null) - p.reportFailure(v.active, std.fmt.bufPrint(&said, "{s}: permission denied", .{operation}) catch unreachable) // `what` and 19 bytes + p.reportFailure(v.active, said.print("{s}: permission denied", .{operation})) else if (parent.kind != null and parent.kind != .directory) - p.reportFailure(v.active, std.fmt.bufPrint(&said, "{s}: {s} is not a directory", .{ operation, parent.dir }) catch "Dump: not a directory") + p.reportFailure(v.active, said.print("{s}: {s} is not a directory", .{ operation, parent.dir })) else if (parent.missing) - p.reportFailure(v.active, std.fmt.bufPrint(&said, "{s}: no such directory", .{operation}) catch unreachable) + p.reportFailure(v.active, said.print("{s}: no such directory", .{operation})) else p.reportError(v.active, operation, err); // In the words the message row has, so the write's err is the one @@ -1734,8 +1733,8 @@ pub fn windowOpacityDone(p: *Pardes, applied: u8, failure: ?[]const u8) void { // Do not claim a value the compositor refused; an explicit retry of // the same command will arm a new request. p.settings.window_opacity = applied; - var buf: [256]u8 = undefined; - p.setMessage(p.view().active, std.fmt.bufPrint(&buf, "WindowOpacity: {s}", .{reason[0..@min(reason.len, 240)]}) catch unreachable); // 255 bytes + var buf: [240 + 16]u8 = undefined; + p.setMessage(p.view().active, std.fmt.bufPrint(&buf, "WindowOpacity: {s}", .{reason[0..@min(reason.len, 240)]}) catch unreachable); // 240 + 15 fits 240 + 16 } /// Recompute geometry, push grid-size changes to each emulator and pty, |
