Zig Version
0.15.2
Steps to Reproduce and Observed Behavior
Run this Zig program, it failed to read the file as it is previously in 0.15.1.
With file content intest_data:
And program in read_file.zig:
const std = @import("std");
pub fn main() !void {
const f = try std.fs.cwd().openFile("test_data", .{});
defer f.close();
var buf: [1024]u8 = undefined;
var file_reader = f.reader(&buf);
const reader = &file_reader.interface;
while (reader.takeDelimiterExclusive('\n')) |line| {
std.log.debug("1: '{s}'", .{line});
if (line.len == 0) {
// std.log.debug("2: '{s}'", .{reader.buffered()});
break;
}
} else |err| switch (err) {
error.EndOfStream => {
std.log.debug("eof", .{});
},
error.StreamTooLong, error.ReadFailed => return err,
}
}
It simply produces wrong output:
$ rm -rf .zig-cache zig-out && zig version && zig run read_file.zig
0.15.2
debug: 1: '123456'
debug: 1: ''
Expected Behavior
$ rm -rf .zig-cache zig-out && zig version && zig run read_file.zig
0.15.1
debug: 1: '123456'
debug: 1: 'abcd'
debug: 1: 'rer'
debug: eof
Zig Version
0.15.2
Steps to Reproduce and Observed Behavior
Run this Zig program, it failed to read the file as it is previously in 0.15.1.
With file content in
test_data:And program in read_file.zig:
It simply produces wrong output:
Expected Behavior