Skip to content

Fix/writergate#97

Merged
meszmate merged 4 commits intomeszmate:mainfrom
jetzig-framework:fix/writergate
Apr 26, 2026
Merged

Fix/writergate#97
meszmate merged 4 commits intomeszmate:mainfrom
jetzig-framework:fix/writergate

Conversation

@Cohors1316
Copy link
Copy Markdown
Contributor

@Cohors1316 Cohors1316 commented Apr 26, 2026

Replaced all deprecated GenericWriters with std.Io.Writer.

zig build test passes.
zig build run-counter builds and runs.

As big as this is the only two real changes are the Writers in Terminal and wasm, and I would take a good look at those to see if I missed something. Note that I haven't created a way to verify the wasm version yet.

For reference:

var buffer: std.Io.Writer.Allocating = .init(allocator);
const writer = &buffer.writer;

is the closest replacement for

var buffer: std.array_list.Managed(u8) = .init(allocator);
const writer = buffer.writer();

for fixed writer

var buffer: [256]u8 = undefined;
var writer: std.Io.Writer = .fixed(&buffer);
const string = writer.buffered();

@meszmate meszmate self-assigned this Apr 26, 2026
Two small follow-ups while reviewing the writer migration:

1. Both Writer.drain implementations (terminal.zig and wasm.zig) indexed
   data[data.len - 1] without first checking data.len > 0. The std.Io
   contract treats an empty data slice as a pure flush; if the runtime
   ever calls drain with no fragments the old code would panic. Add an
   early-return.

2. Style.render unconditionally initialized a second Writer.Allocating
   for tab expansion even when tab_width was null. Move the buf
   declaration inside the if-block so it's only paid for when actually
   used. (No correctness impact — Allocating starts empty so the deinit
   was a no-op — but it removes a per-render allocation noise.)

Build and full test suite still green; smoke-tested counter, showcase,
form, action_system, rich_log, braille_canvas — no regressions.
@meszmate meszmate merged commit 637a3fe into meszmate:main Apr 26, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants