mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
fix some std.Io compilation failures
This commit is contained in:
parent
032152409b
commit
873bcb5aa6
2 changed files with 10 additions and 3 deletions
|
|
@ -29,7 +29,6 @@ pub fn main() !void {
|
|||
}
|
||||
|
||||
fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
|
||||
_ = gpa;
|
||||
var i: usize = 0;
|
||||
var opt_out_fmt: ?std.Target.ObjectFormat = null;
|
||||
var opt_input: ?[]const u8 = null;
|
||||
|
|
@ -148,12 +147,16 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
|
|||
const input = opt_input orelse fatal("expected input parameter", .{});
|
||||
const output = opt_output orelse fatal("expected output parameter", .{});
|
||||
|
||||
var threaded: std.Io.Threaded = .init(gpa);
|
||||
defer threaded.deinit();
|
||||
const io = threaded.io();
|
||||
|
||||
const input_file = fs.cwd().openFile(input, .{}) catch |err| fatal("failed to open {s}: {t}", .{ input, err });
|
||||
defer input_file.close();
|
||||
|
||||
const stat = input_file.stat() catch |err| fatal("failed to stat {s}: {t}", .{ input, err });
|
||||
|
||||
var in: File.Reader = .initSize(input_file, &input_buffer, stat.size);
|
||||
var in: File.Reader = .initSize(input_file, io, &input_buffer, stat.size);
|
||||
|
||||
const elf_hdr = std.elf.Header.read(&in.interface) catch |err| switch (err) {
|
||||
error.ReadFailed => fatal("unable to read {s}: {t}", .{ input, in.err.? }),
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ pub fn main() !void {
|
|||
};
|
||||
defer if (needs_free) gpa.free(child_path);
|
||||
|
||||
var threaded: std.Io.Threaded = .init(gpa);
|
||||
defer threaded.deinit();
|
||||
const io = threaded.io();
|
||||
|
||||
var child = std.process.Child.init(&.{ child_path, "hello arg" }, gpa);
|
||||
child.stdin_behavior = .Pipe;
|
||||
child.stdout_behavior = .Pipe;
|
||||
|
|
@ -32,7 +36,7 @@ pub fn main() !void {
|
|||
|
||||
const hello_stdout = "hello from stdout";
|
||||
var buf: [hello_stdout.len]u8 = undefined;
|
||||
var stdout_reader = child.stdout.?.readerStreaming(&.{});
|
||||
var stdout_reader = child.stdout.?.readerStreaming(io, &.{});
|
||||
const n = try stdout_reader.interface.readSliceShort(&buf);
|
||||
if (!std.mem.eql(u8, buf[0..n], hello_stdout)) {
|
||||
testError("child stdout: '{s}'; want '{s}'", .{ buf[0..n], hello_stdout });
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue