From 44524cbf51a14d6eed0b81f97b2b267783038e72 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sat, 26 Sep 2026 18:56:42 -0400 Subject: [PATCH] std.Io.Reader: revert interface change This function was broken before and is still broken after, so avoiding the change for now. --- lib/std/Io/Reader.zig | 15 ++++++++++++++- test/src/Runner.zig | 6 ++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/std/Io/Reader.zig b/lib/std/Io/Reader.zig index 06b5b523a8fefcc0427b3900fad4af0bd34ac891..c8797f26c68bdc41778f6360d75e591c78e10396 100644 --- a/lib/std/Io/Reader.zig +++ b/lib/std/Io/Reader.zig @@ -849,14 +849,27 @@ pub fn peekDelimiterInclusive(r: *Reader, delimiter: u8) DelimiterError![]u8 { } while (true) { const content_len = r.end - r.seek; + if (r.buffer.len - content_len == 0) break; try fillMore(r); - if (r.buffer.len - content_len == 0) return error.StreamTooLong; const seek = r.seek; const contents = r.buffer[0..r.end]; if (std.mem.findScalarPos(u8, contents, seek + content_len, delimiter)) |end| { return contents[seek .. end + 1]; } } + // It might or might not be end of stream. There is no more buffer space + // left to disambiguate. If `StreamTooLong` was added to `RebaseError` then + // this logic could be replaced by removing the exit condition from the + // above while loop. That error code would represent when `buffer` capacity + // is too small for an operation, replacing the current use of asserts. + var failing_writer = Writer.failing; + while (r.vtable.stream(r, &failing_writer, .limited(1))) |n| { + assert(n == 0); + } else |err| switch (err) { + error.WriteFailed => return error.StreamTooLong, + error.ReadFailed => |e| return e, + error.EndOfStream => |e| return e, + } } /// Returns a slice of the next bytes of buffered data from the stream until diff --git a/test/src/Runner.zig b/test/src/Runner.zig index d993f75e657c428b141e58f03a3ebccca12bf5a8..a73aaf05907e1232bcee34df1659113f0bbd426e 100644 --- a/test/src/Runner.zig +++ b/test/src/Runner.zig @@ -574,6 +574,12 @@ fn testOne(runner: *Runner, test_index: u32) TestError!void { update.src_dir.close(runner.io); update.prog_node.end(); } + + // hack around `std.Io.Reader` interface bugs by ensuring the + // buffer is larger than the longest supported manifest line + try update.manifest_sr.line_aw.ensureTotalCapacityPrecise(512); + update.manifest_sr.updateBuffer(); + var skip_delimiter = false; while (update.manifest_sr.interface.takeSentinel('\n')) |line| { var line_it = std.mem.tokenizeScalar(u8, line, ' '); -- 2.54.0