diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-23 15:56:20 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-23 16:28:34 -0300 |
| commit | 4640cef5f7237422b178122eea403858fcd560ea (patch) | |
| tree | fb887acdeab131a812bfe73129096811677ca691 /core | |
| parent | 18933ab34ea07f2cf755aa4e8d9bdb4dc25a67a6 (diff) | |
| download | pardes-4640cef5f7237422b178122eea403858fcd560ea.tar.gz pardes-4640cef5f7237422b178122eea403858fcd560ea.zip | |
rows: a style is one the syntax has, or the write is refused: a pane rows line took a style number as any u4 (core/locations.zig parseRows, 1..15) where the render casts the style syntax bits into `Syn` (four kinds): `m 1 1 0 0 0 0 0 3:0+3=7 a.txt` written to a +Search pane rows, then any frame, panicked (`invalid enum value`, core/File.zig:2079 recolorSyntax) the session and every client that draws; now the decoder yields a `Syn`, by name or by a number `std.enums.fromInt` takes, `.none` refused: a 9P write refused in words (EINVAL, the rows text error), never drawn; a user could hit it with a script writing rows; the test (the change before) passes
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core')
| -rw-r--r-- | core/locations.zig | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/core/locations.zig b/core/locations.zig index 10704912..041e9692 100644 --- a/core/locations.zig +++ b/core/locations.zig @@ -224,9 +224,12 @@ pub fn parseRows(arena: std.mem.Allocator, text: []const u8) error{ OutOfMemory, continue :names; }; if (style & syntax.syn_bits != 0) return error.BadRows; - const syn: u8 = if (std.meta.stringToEnum(syntax.Syn, name)) |known| @backingInt(known) else std.fmt.parseInt(u4, name, 10) catch return error.BadRows; - if (syn == 0) return error.BadRows; - style |= syn; + // A kind by its name or its number, one Syn has: the + // render takes the style's syntax bits as a Syn. + const syn = std.meta.stringToEnum(syntax.Syn, name) orelse + std.enums.fromInt(syntax.Syn, std.fmt.parseInt(u8, name, 10) catch return error.BadRows) orelse return error.BadRows; + if (syn == .none) return error.BadRows; + style |= @backingInt(syn); } @memset(row.colors[start..][0..n], style); } |
