diff options
Diffstat (limited to 'src/dump.zig')
| -rw-r--r-- | src/dump.zig | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/dump.zig b/src/dump.zig index 37ba83c0..f8740cdb 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -1,5 +1,6 @@ const std = @import("std"); const builtin = @import("builtin"); +const limits = @import("limits.zig"); // scoped, not bare std.log: main.zig's logFn drops the unscoped .default scope // wholesale (ghostty and uucode log there too), and a corrupt dump's parse @@ -40,22 +41,11 @@ pub const magic = "pardes-dump"; pub const version: u32 = 1; pub const max_panes: usize = 16; pub const max_cols: usize = 6; -/// Bounds the only user-editable, schema-owned tag fragment. Keep this beside -/// the dump limits so readers can reject data before copying it into a pane. -/// It IS the storage bound: `Pane.tag_tail` is `[max_tag_tail]u8`, and every -/// writer (appendTag, tagInsert, restoreDumpTail, the acmefs `tag` file) -/// refuses input that does not fit rather than truncating it, so the schema -/// limit and the buffer can never disagree. -/// -/// 512 on the P4 firmware. A tag is ONE line — a pane's path plus its command -/// words — and 4 KiB of it is 4 KiB per pane out of a 384 KiB heap. A serial -/// console is 80 columns; 512 is six of those. -pub const max_tag_tail: usize = - if (@import("pardes_config").platform == .p4) 512 else 4096; /// Output arguments are typed in the same bounded one-line tag storage. Keep /// the schema limit named independently so a dump reader can validate it -/// without importing the output-pane implementation. -pub const max_origin_arg: usize = max_tag_tail; +/// without importing the output-pane implementation. The bound itself is +/// `limits.max_tag_tail` — the one place a board-shaped capacity is chosen. +pub const max_origin_arg: usize = limits.max_tag_tail; pub const Size = struct { cols: u16, @@ -157,7 +147,7 @@ pub fn validate(state: State) !void { if (!std.math.isFinite(pane.vweight) or pane.vweight <= 0) return error.BadDumpPaneWeight; if (pane.scroll > std.math.maxInt(i32)) return error.BadDumpPaneScroll; - if (pane.tag_tail) |tail| if (tail.len > max_tag_tail) + if (pane.tag_tail) |tail| if (tail.len > limits.max_tag_tail) return error.BadDumpTagTail; if (pane.file) |file| if (file.origin_arg.len > max_origin_arg) return error.BadDumpOriginArg; @@ -412,9 +402,9 @@ test "validation bounds pane restore state" { try std.testing.expectError(error.BadDumpPaneScroll, validate(state)); panes[0].scroll = 0; - var oversized_tail: [max_tag_tail + 1]u8 = @splat('x'); + var oversized_tail: [limits.max_tag_tail + 1]u8 = @splat('x'); panes[0].tag_tail = &oversized_tail; try std.testing.expectError(error.BadDumpTagTail, validate(state)); - panes[0].tag_tail = oversized_tail[0..max_tag_tail]; + panes[0].tag_tail = oversized_tail[0..limits.max_tag_tail]; try validate(state); } |
