diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-07-22 17:06:25 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-07-22 17:06:25 -0700 |
| commit | ec5cdb2fe394b6a8ca3d30b7652049f39c1aecdb (patch) | |
| tree | ae21be4e1c84b14872e4b80666459dd4082a5c0a /lib/std/Io.zig | |
| parent | 91640f5f819de5bb6211d6bfa3c778737fa822aa (diff) | |
| download | zig-ec5cdb2fe394b6a8ca3d30b7652049f39c1aecdb.tar.gz zig-ec5cdb2fe394b6a8ca3d30b7652049f39c1aecdb.zip | |
std: fix deprecated writer not handling the buffer
Diffstat (limited to 'lib/std/Io.zig')
| -rw-r--r-- | lib/std/Io.zig | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/std/Io.zig b/lib/std/Io.zig index b27217ece0..3f98ec3043 100644 --- a/lib/std/Io.zig +++ b/lib/std/Io.zig @@ -419,9 +419,14 @@ pub fn GenericWriter( new_interface: Writer, err: ?Error = null, - fn drain(w: *Writer, data: []const []const u8, splat: usize) Writer.Error!usize { + fn drain(w: *std.io.Writer, data: []const []const u8, splat: usize) std.io.Writer.Error!usize { _ = splat; const a: *@This() = @alignCast(@fieldParentPtr("new_interface", w)); + const buffered = w.buffered(); + if (buffered.len != 0) return w.consume(a.derp_writer.write(buffered) catch |err| { + a.err = err; + return error.WriteFailed; + }); return a.derp_writer.write(data[0]) catch |err| { a.err = err; return error.WriteFailed; |
