| author | |
| committer | |
| log | 832caefc2a1b20deb513d43306d6723670ba9c8f |
| tree | 30401a79076971ead109ea05748e97049adcb71b |
| parent | 4cd50865bffab670040f20b69da13d2f3e89f86f |
16 files changed, 56 insertions(+), 55 deletions(-)
doc/docgen.zig+2-2| ... | @@ -40,11 +40,11 @@ pub fn main() !void { | ... | @@ -40,11 +40,11 @@ pub fn main() !void { |
| 40 | var out_file = try os.File.openWrite(out_file_name); | 40 | var out_file = try os.File.openWrite(out_file_name); |
| 41 | defer out_file.close(); | 41 | defer out_file.close(); |
| 42 | 42 | ||
| 43 | var file_in_stream = io.FileInStream.init(&in_file); | 43 | var file_in_stream = io.FileInStream.init(in_file); |
| 44 | 44 | ||
| 45 | const input_file_bytes = try file_in_stream.stream.readAllAlloc(allocator, max_doc_file_size); | 45 | const input_file_bytes = try file_in_stream.stream.readAllAlloc(allocator, max_doc_file_size); |
| 46 | 46 | ||
| 47 | var file_out_stream = io.FileOutStream.init(&out_file); | 47 | var file_out_stream = io.FileOutStream.init(out_file); |
| 48 | var buffered_out_stream = io.BufferedOutStream(io.FileOutStream.Error).init(&file_out_stream.stream); | 48 | var buffered_out_stream = io.BufferedOutStream(io.FileOutStream.Error).init(&file_out_stream.stream); |
| 49 | 49 | ||
| 50 | var tokenizer = Tokenizer.init(in_file_name, input_file_bytes); | 50 | var tokenizer = Tokenizer.init(in_file_name, input_file_bytes); |
example/guess_number/main.zig+1-1| ... | @@ -6,7 +6,7 @@ const os = std.os; | ... | @@ -6,7 +6,7 @@ const os = std.os; |
| 6 | 6 | ||
| 7 | pub fn main() !void { | 7 | pub fn main() !void { |
| 8 | var stdout_file = try io.getStdOut(); | 8 | var stdout_file = try io.getStdOut(); |
| 9 | var stdout_file_stream = io.FileOutStream.init(&stdout_file); | 9 | var stdout_file_stream = io.FileOutStream.init(stdout_file); |
| 10 | const stdout = &stdout_file_stream.stream; | 10 | const stdout = &stdout_file_stream.stream; |
| 11 | 11 | ||
| 12 | try stdout.print("Welcome to the Guess Number Game in Zig.\n"); | 12 | try stdout.print("Welcome to the Guess Number Game in Zig.\n"); |
src-self-hosted/errmsg.zig+1-1| ... | @@ -272,7 +272,7 @@ pub const Msg = struct { | ... | @@ -272,7 +272,7 @@ pub const Msg = struct { |
| 272 | try stream.write("\n"); | 272 | try stream.write("\n"); |
| 273 | } | 273 | } |
| 274 | 274 | ||
| 275 | pub fn printToFile(msg: *const Msg, file: *os.File, color: Color) !void { | 275 | pub fn printToFile(msg: *const Msg, file: os.File, color: Color) !void { |
| 276 | const color_on = switch (color) { | 276 | const color_on = switch (color) { |
| 277 | Color.Auto => file.isTty(), | 277 | Color.Auto => file.isTty(), |
| 278 | Color.On => true, | 278 | Color.On => true, |
src-self-hosted/main.zig+6-6| ... | @@ -55,11 +55,11 @@ pub fn main() !void { | ... | @@ -55,11 +55,11 @@ pub fn main() !void { |
| 55 | const allocator = std.heap.c_allocator; | 55 | const allocator = std.heap.c_allocator; |
| 56 | 56 | ||
| 57 | var stdout_file = try std.io.getStdOut(); | 57 | var stdout_file = try std.io.getStdOut(); |
| 58 | var stdout_out_stream = std.io.FileOutStream.init(&stdout_file); | 58 | var stdout_out_stream = std.io.FileOutStream.init(stdout_file); |
| 59 | stdout = &stdout_out_stream.stream; | 59 | stdout = &stdout_out_stream.stream; |
| 60 | 60 | ||
| 61 | stderr_file = try std.io.getStdErr(); | 61 | stderr_file = try std.io.getStdErr(); |
| 62 | var stderr_out_stream = std.io.FileOutStream.init(&stderr_file); | 62 | var stderr_out_stream = std.io.FileOutStream.init(stderr_file); |
| 63 | stderr = &stderr_out_stream.stream; | 63 | stderr = &stderr_out_stream.stream; |
| 64 | 64 | ||
| 65 | const args = try os.argsAlloc(allocator); | 65 | const args = try os.argsAlloc(allocator); |
| ... | @@ -491,7 +491,7 @@ async fn processBuildEvents(comp: *Compilation, color: errmsg.Color) void { | ... | @@ -491,7 +491,7 @@ async fn processBuildEvents(comp: *Compilation, color: errmsg.Color) void { |
| 491 | stderr.print("Build {} compile errors:\n", count) catch os.exit(1); | 491 | stderr.print("Build {} compile errors:\n", count) catch os.exit(1); |
| 492 | for (msgs) |msg| { | 492 | for (msgs) |msg| { |
| 493 | defer msg.destroy(); | 493 | defer msg.destroy(); |
| 494 | msg.printToFile(&stderr_file, color) catch os.exit(1); | 494 | msg.printToFile(stderr_file, color) catch os.exit(1); |
| 495 | } | 495 | } |
| 496 | }, | 496 | }, |
| 497 | } | 497 | } |
| ... | @@ -619,7 +619,7 @@ fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void { | ... | @@ -619,7 +619,7 @@ fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void { |
| 619 | } | 619 | } |
| 620 | 620 | ||
| 621 | var stdin_file = try io.getStdIn(); | 621 | var stdin_file = try io.getStdIn(); |
| 622 | var stdin = io.FileInStream.init(&stdin_file); | 622 | var stdin = io.FileInStream.init(stdin_file); |
| 623 | 623 | ||
| 624 | const source_code = try stdin.stream.readAllAlloc(allocator, max_src_size); | 624 | const source_code = try stdin.stream.readAllAlloc(allocator, max_src_size); |
| 625 | defer allocator.free(source_code); | 625 | defer allocator.free(source_code); |
| ... | @@ -635,7 +635,7 @@ fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void { | ... | @@ -635,7 +635,7 @@ fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void { |
| 635 | const msg = try errmsg.Msg.createFromParseError(allocator, parse_error, &tree, "<stdin>"); | 635 | const msg = try errmsg.Msg.createFromParseError(allocator, parse_error, &tree, "<stdin>"); |
| 636 | defer msg.destroy(); | 636 | defer msg.destroy(); |
| 637 | 637 | ||
| 638 | try msg.printToFile(&stderr_file, color); | 638 | try msg.printToFile(stderr_file, color); |
| 639 | } | 639 | } |
| 640 | if (tree.errors.len != 0) { | 640 | if (tree.errors.len != 0) { |
| 641 | os.exit(1); | 641 | os.exit(1); |
| ... | @@ -772,7 +772,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8) FmtError!void { | ... | @@ -772,7 +772,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8) FmtError!void { |
| 772 | const msg = try errmsg.Msg.createFromParseError(fmt.loop.allocator, parse_error, &tree, file_path); | 772 | const msg = try errmsg.Msg.createFromParseError(fmt.loop.allocator, parse_error, &tree, file_path); |
| 773 | defer fmt.loop.allocator.destroy(msg); | 773 | defer fmt.loop.allocator.destroy(msg); |
| 774 | 774 | ||
| 775 | try msg.printToFile(&stderr_file, fmt.color); | 775 | try msg.printToFile(stderr_file, fmt.color); |
| 776 | } | 776 | } |
| 777 | if (tree.errors.len != 0) { | 777 | if (tree.errors.len != 0) { |
| 778 | fmt.any_error = true; | 778 | fmt.any_error = true; |
src-self-hosted/test.zig+2-2| ... | @@ -185,7 +185,7 @@ pub const TestContext = struct { | ... | @@ -185,7 +185,7 @@ pub const TestContext = struct { |
| 185 | try stderr.write("build incorrectly failed:\n"); | 185 | try stderr.write("build incorrectly failed:\n"); |
| 186 | for (msgs) |msg| { | 186 | for (msgs) |msg| { |
| 187 | defer msg.destroy(); | 187 | defer msg.destroy(); |
| 188 | try msg.printToFile(&stderr, errmsg.Color.Auto); | 188 | try msg.printToFile(stderr, errmsg.Color.Auto); |
| 189 | } | 189 | } |
| 190 | }, | 190 | }, |
| 191 | } | 191 | } |
| ... | @@ -234,7 +234,7 @@ pub const TestContext = struct { | ... | @@ -234,7 +234,7 @@ pub const TestContext = struct { |
| 234 | var stderr = try std.io.getStdErr(); | 234 | var stderr = try std.io.getStdErr(); |
| 235 | for (msgs) |msg| { | 235 | for (msgs) |msg| { |
| 236 | defer msg.destroy(); | 236 | defer msg.destroy(); |
| 237 | try msg.printToFile(&stderr, errmsg.Color.Auto); | 237 | try msg.printToFile(stderr, errmsg.Color.Auto); |
| 238 | } | 238 | } |
| 239 | std.debug.warn("============\n"); | 239 | std.debug.warn("============\n"); |
| 240 | return error.TestFailed; | 240 | return error.TestFailed; |
std/debug/index.zig+7-7| ... | @@ -862,7 +862,7 @@ fn openSelfDebugInfoLinux(allocator: *mem.Allocator) !DebugInfo { | ... | @@ -862,7 +862,7 @@ fn openSelfDebugInfoLinux(allocator: *mem.Allocator) !DebugInfo { |
| 862 | di.self_exe_file = try os.openSelfExe(); | 862 | di.self_exe_file = try os.openSelfExe(); |
| 863 | errdefer di.self_exe_file.close(); | 863 | errdefer di.self_exe_file.close(); |
| 864 | 864 | ||
| 865 | try di.elf.openFile(allocator, &di.self_exe_file); | 865 | try di.elf.openFile(allocator, di.self_exe_file); |
| 866 | errdefer di.elf.close(); | 866 | errdefer di.elf.close(); |
| 867 | 867 | ||
| 868 | di.debug_info = (try di.elf.findSection(".debug_info")) orelse return error.MissingDebugInfo; | 868 | di.debug_info = (try di.elf.findSection(".debug_info")) orelse return error.MissingDebugInfo; |
| ... | @@ -1067,7 +1067,7 @@ pub const DebugInfo = switch (builtin.os) { | ... | @@ -1067,7 +1067,7 @@ pub const DebugInfo = switch (builtin.os) { |
| 1067 | } | 1067 | } |
| 1068 | 1068 | ||
| 1069 | pub fn readString(self: *DebugInfo) ![]u8 { | 1069 | pub fn readString(self: *DebugInfo) ![]u8 { |
| 1070 | var in_file_stream = io.FileInStream.init(&self.self_exe_file); | 1070 | var in_file_stream = io.FileInStream.init(self.self_exe_file); |
| 1071 | const in_stream = &in_file_stream.stream; | 1071 | const in_stream = &in_file_stream.stream; |
| 1072 | return readStringRaw(self.allocator(), in_stream); | 1072 | return readStringRaw(self.allocator(), in_stream); |
| 1073 | } | 1073 | } |
| ... | @@ -1403,7 +1403,7 @@ fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64 | ... | @@ -1403,7 +1403,7 @@ fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64 |
| 1403 | } | 1403 | } |
| 1404 | 1404 | ||
| 1405 | fn parseAbbrevTable(st: *DebugInfo) !AbbrevTable { | 1405 | fn parseAbbrevTable(st: *DebugInfo) !AbbrevTable { |
| 1406 | const in_file = &st.self_exe_file; | 1406 | const in_file = st.self_exe_file; |
| 1407 | var in_file_stream = io.FileInStream.init(in_file); | 1407 | var in_file_stream = io.FileInStream.init(in_file); |
| 1408 | const in_stream = &in_file_stream.stream; | 1408 | const in_stream = &in_file_stream.stream; |
| 1409 | var result = AbbrevTable.init(st.allocator()); | 1409 | var result = AbbrevTable.init(st.allocator()); |
| ... | @@ -1454,7 +1454,7 @@ fn getAbbrevTableEntry(abbrev_table: *const AbbrevTable, abbrev_code: u64) ?*con | ... | @@ -1454,7 +1454,7 @@ fn getAbbrevTableEntry(abbrev_table: *const AbbrevTable, abbrev_code: u64) ?*con |
| 1454 | } | 1454 | } |
| 1455 | 1455 | ||
| 1456 | fn parseDie(st: *DebugInfo, abbrev_table: *const AbbrevTable, is_64: bool) !Die { | 1456 | fn parseDie(st: *DebugInfo, abbrev_table: *const AbbrevTable, is_64: bool) !Die { |
| 1457 | const in_file = &st.self_exe_file; | 1457 | const in_file = st.self_exe_file; |
| 1458 | var in_file_stream = io.FileInStream.init(in_file); | 1458 | var in_file_stream = io.FileInStream.init(in_file); |
| 1459 | const in_stream = &in_file_stream.stream; | 1459 | const in_stream = &in_file_stream.stream; |
| 1460 | const abbrev_code = try readULeb128(in_stream); | 1460 | const abbrev_code = try readULeb128(in_stream); |
| ... | @@ -1676,7 +1676,7 @@ fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, target_address: u | ... | @@ -1676,7 +1676,7 @@ fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, target_address: u |
| 1676 | fn getLineNumberInfoLinux(di: *DebugInfo, compile_unit: *const CompileUnit, target_address: usize) !LineInfo { | 1676 | fn getLineNumberInfoLinux(di: *DebugInfo, compile_unit: *const CompileUnit, target_address: usize) !LineInfo { |
| 1677 | const compile_unit_cwd = try compile_unit.die.getAttrString(di, DW.AT_comp_dir); | 1677 | const compile_unit_cwd = try compile_unit.die.getAttrString(di, DW.AT_comp_dir); |
| 1678 | 1678 | ||
| 1679 | const in_file = &di.self_exe_file; | 1679 | const in_file = di.self_exe_file; |
| 1680 | const debug_line_end = di.debug_line.offset + di.debug_line.size; | 1680 | const debug_line_end = di.debug_line.offset + di.debug_line.size; |
| 1681 | var this_offset = di.debug_line.offset; | 1681 | var this_offset = di.debug_line.offset; |
| 1682 | var this_index: usize = 0; | 1682 | var this_index: usize = 0; |
| ... | @@ -1856,7 +1856,7 @@ fn scanAllCompileUnits(st: *DebugInfo) !void { | ... | @@ -1856,7 +1856,7 @@ fn scanAllCompileUnits(st: *DebugInfo) !void { |
| 1856 | var this_unit_offset = st.debug_info.offset; | 1856 | var this_unit_offset = st.debug_info.offset; |
| 1857 | var cu_index: usize = 0; | 1857 | var cu_index: usize = 0; |
| 1858 | 1858 | ||
| 1859 | var in_file_stream = io.FileInStream.init(&st.self_exe_file); | 1859 | var in_file_stream = io.FileInStream.init(st.self_exe_file); |
| 1860 | const in_stream = &in_file_stream.stream; | 1860 | const in_stream = &in_file_stream.stream; |
| 1861 | 1861 | ||
| 1862 | while (this_unit_offset < debug_info_end) { | 1862 | while (this_unit_offset < debug_info_end) { |
| ... | @@ -1922,7 +1922,7 @@ fn scanAllCompileUnits(st: *DebugInfo) !void { | ... | @@ -1922,7 +1922,7 @@ fn scanAllCompileUnits(st: *DebugInfo) !void { |
| 1922 | } | 1922 | } |
| 1923 | 1923 | ||
| 1924 | fn findCompileUnit(st: *DebugInfo, target_address: u64) !*const CompileUnit { | 1924 | fn findCompileUnit(st: *DebugInfo, target_address: u64) !*const CompileUnit { |
| 1925 | var in_file_stream = io.FileInStream.init(&st.self_exe_file); | 1925 | var in_file_stream = io.FileInStream.init(st.self_exe_file); |
| 1926 | const in_stream = &in_file_stream.stream; | 1926 | const in_stream = &in_file_stream.stream; |
| 1927 | for (st.compile_unit_list.toSlice()) |*compile_unit| { | 1927 | for (st.compile_unit_list.toSlice()) |*compile_unit| { |
| 1928 | if (compile_unit.pc_range) |range| { | 1928 | if (compile_unit.pc_range) |range| { |
std/elf.zig+2-2| ... | @@ -353,7 +353,7 @@ pub const SectionHeader = struct { | ... | @@ -353,7 +353,7 @@ pub const SectionHeader = struct { |
| 353 | }; | 353 | }; |
| 354 | 354 | ||
| 355 | pub const Elf = struct { | 355 | pub const Elf = struct { |
| 356 | in_file: *os.File, | 356 | in_file: os.File, |
| 357 | auto_close_stream: bool, | 357 | auto_close_stream: bool, |
| 358 | is_64: bool, | 358 | is_64: bool, |
| 359 | endian: builtin.Endian, | 359 | endian: builtin.Endian, |
| ... | @@ -376,7 +376,7 @@ pub const Elf = struct { | ... | @@ -376,7 +376,7 @@ pub const Elf = struct { |
| 376 | } | 376 | } |
| 377 | 377 | ||
| 378 | /// Call close when done. | 378 | /// Call close when done. |
| 379 | pub fn openFile(elf: *Elf, allocator: *mem.Allocator, file: *os.File) !void { | 379 | pub fn openFile(elf: *Elf, allocator: *mem.Allocator, file: os.File) !void { |
| 380 | elf.allocator = allocator; | 380 | elf.allocator = allocator; |
| 381 | elf.in_file = file; | 381 | elf.in_file = file; |
| 382 | elf.auto_close_stream = false; | 382 | elf.auto_close_stream = false; |
std/event/tcp.zig+3-3| ... | @@ -145,11 +145,11 @@ test "listen on a port, send bytes, receive bytes" { | ... | @@ -145,11 +145,11 @@ test "listen on a port, send bytes, receive bytes" { |
| 145 | cancel @handle(); | 145 | cancel @handle(); |
| 146 | } | 146 | } |
| 147 | } | 147 | } |
| 148 | async fn errorableHandler(self: *Self, _addr: *const std.net.Address, _socket: *const std.os.File) !void { | 148 | async fn errorableHandler(self: *Self, _addr: *const std.net.Address, _socket: std.os.File) !void { |
| 149 | const addr = _addr.*; // TODO https://github.com/ziglang/zig/issues/733 | 149 | const addr = _addr.*; // TODO https://github.com/ziglang/zig/issues/733 |
| 150 | var socket = _socket.*; // TODO https://github.com/ziglang/zig/issues/733 | 150 | var socket = _socket; // TODO https://github.com/ziglang/zig/issues/733 |
| 151 | 151 | ||
| 152 | var adapter = std.io.FileOutStream.init(&socket); | 152 | var adapter = std.io.FileOutStream.init(socket); |
| 153 | var stream = &adapter.stream; | 153 | var stream = &adapter.stream; |
| 154 | try stream.print("hello from server\n"); | 154 | try stream.print("hello from server\n"); |
| 155 | } | 155 | } |
std/io.zig+3-3| ... | @@ -280,7 +280,7 @@ pub fn readFileAllocAligned(allocator: *mem.Allocator, path: []const u8, comptim | ... | @@ -280,7 +280,7 @@ pub fn readFileAllocAligned(allocator: *mem.Allocator, path: []const u8, comptim |
| 280 | const buf = try allocator.alignedAlloc(u8, A, size); | 280 | const buf = try allocator.alignedAlloc(u8, A, size); |
| 281 | errdefer allocator.free(buf); | 281 | errdefer allocator.free(buf); |
| 282 | 282 | ||
| 283 | var adapter = FileInStream.init(&file); | 283 | var adapter = FileInStream.init(file); |
| 284 | try adapter.stream.readNoEof(buf[0..size]); | 284 | try adapter.stream.readNoEof(buf[0..size]); |
| 285 | return buf; | 285 | return buf; |
| 286 | } | 286 | } |
| ... | @@ -592,7 +592,7 @@ pub const BufferedAtomicFile = struct { | ... | @@ -592,7 +592,7 @@ pub const BufferedAtomicFile = struct { |
| 592 | self.atomic_file = try os.AtomicFile.init(allocator, dest_path, os.File.default_mode); | 592 | self.atomic_file = try os.AtomicFile.init(allocator, dest_path, os.File.default_mode); |
| 593 | errdefer self.atomic_file.deinit(); | 593 | errdefer self.atomic_file.deinit(); |
| 594 | 594 | ||
| 595 | self.file_stream = FileOutStream.init(&self.atomic_file.file); | 595 | self.file_stream = FileOutStream.init(self.atomic_file.file); |
| 596 | self.buffered_stream = BufferedOutStream(FileOutStream.Error).init(&self.file_stream.stream); | 596 | self.buffered_stream = BufferedOutStream(FileOutStream.Error).init(&self.file_stream.stream); |
| 597 | return self; | 597 | return self; |
| 598 | } | 598 | } |
| ... | @@ -622,7 +622,7 @@ test "import io tests" { | ... | @@ -622,7 +622,7 @@ test "import io tests" { |
| 622 | 622 | ||
| 623 | pub fn readLine(buf: []u8) !usize { | 623 | pub fn readLine(buf: []u8) !usize { |
| 624 | var stdin = getStdIn() catch return error.StdInUnavailable; | 624 | var stdin = getStdIn() catch return error.StdInUnavailable; |
| 625 | var adapter = FileInStream.init(&stdin); | 625 | var adapter = FileInStream.init(stdin); |
| 626 | var stream = &adapter.stream; | 626 | var stream = &adapter.stream; |
| 627 | var index: usize = 0; | 627 | var index: usize = 0; |
| 628 | while (true) { | 628 | while (true) { |
std/io_test.zig+2-2| ... | @@ -19,7 +19,7 @@ test "write a file, read it, then delete it" { | ... | @@ -19,7 +19,7 @@ test "write a file, read it, then delete it" { |
| 19 | var file = try os.File.openWrite(tmp_file_name); | 19 | var file = try os.File.openWrite(tmp_file_name); |
| 20 | defer file.close(); | 20 | defer file.close(); |
| 21 | 21 | ||
| 22 | var file_out_stream = io.FileOutStream.init(&file); | 22 | var file_out_stream = io.FileOutStream.init(file); |
| 23 | var buf_stream = io.BufferedOutStream(io.FileOutStream.Error).init(&file_out_stream.stream); | 23 | var buf_stream = io.BufferedOutStream(io.FileOutStream.Error).init(&file_out_stream.stream); |
| 24 | const st = &buf_stream.stream; | 24 | const st = &buf_stream.stream; |
| 25 | try st.print("begin"); | 25 | try st.print("begin"); |
| ... | @@ -35,7 +35,7 @@ test "write a file, read it, then delete it" { | ... | @@ -35,7 +35,7 @@ test "write a file, read it, then delete it" { |
| 35 | const expected_file_size = "begin".len + data.len + "end".len; | 35 | const expected_file_size = "begin".len + data.len + "end".len; |
| 36 | assert(file_size == expected_file_size); | 36 | assert(file_size == expected_file_size); |
| 37 | 37 | ||
| 38 | var file_in_stream = io.FileInStream.init(&file); | 38 | var file_in_stream = io.FileInStream.init(file); |
| 39 | var buf_stream = io.BufferedInStream(io.FileInStream.Error).init(&file_in_stream.stream); | 39 | var buf_stream = io.BufferedInStream(io.FileInStream.Error).init(&file_in_stream.stream); |
| 40 | const st = &buf_stream.stream; | 40 | const st = &buf_stream.stream; |
| 41 | const contents = try st.readAllAlloc(allocator, 2 * 1024); | 41 | const contents = try st.readAllAlloc(allocator, 2 * 1024); |
std/os/child_process.zig+2-2| ... | @@ -209,8 +209,8 @@ pub const ChildProcess = struct { | ... | @@ -209,8 +209,8 @@ pub const ChildProcess = struct { |
| 209 | defer Buffer.deinit(&stdout); | 209 | defer Buffer.deinit(&stdout); |
| 210 | defer Buffer.deinit(&stderr); | 210 | defer Buffer.deinit(&stderr); |
| 211 | 211 | ||
| 212 | var stdout_file_in_stream = io.FileInStream.init(&child.stdout.?); | 212 | var stdout_file_in_stream = io.FileInStream.init(child.stdout.?); |
| 213 | var stderr_file_in_stream = io.FileInStream.init(&child.stderr.?); | 213 | var stderr_file_in_stream = io.FileInStream.init(child.stderr.?); |
| 214 | 214 | ||
| 215 | try stdout_file_in_stream.stream.readAllBuffer(&stdout, max_output_size); | 215 | try stdout_file_in_stream.stream.readAllBuffer(&stdout, max_output_size); |
| 216 | try stderr_file_in_stream.stream.readAllBuffer(&stderr, max_output_size); | 216 | try stderr_file_in_stream.stream.readAllBuffer(&stderr, max_output_size); |
std/os/index.zig+1| ... | @@ -2149,6 +2149,7 @@ pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) ![]u8 { | ... | @@ -2149,6 +2149,7 @@ pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) ![]u8 { |
| 2149 | switch (builtin.os) { | 2149 | switch (builtin.os) { |
| 2150 | Os.linux => return readLink(out_buffer, "/proc/self/exe"), | 2150 | Os.linux => return readLink(out_buffer, "/proc/self/exe"), |
| 2151 | Os.windows => { | 2151 | Os.windows => { |
| 2152 | var utf16le_buf: [windows_util.PATH_MAX_WIDE]u16 = undefined; | ||
| 2152 | const utf16le_slice = try selfExePathW(&utf16le_buf); | 2153 | const utf16le_slice = try selfExePathW(&utf16le_buf); |
| 2153 | // Trust that Windows gives us valid UTF-16LE. | 2154 | // Trust that Windows gives us valid UTF-16LE. |
| 2154 | const end_index = std.unicode.utf16leToUtf8(out_buffer, utf16le_slice) catch unreachable; | 2155 | const end_index = std.unicode.utf16leToUtf8(out_buffer, utf16le_slice) catch unreachable; |
std/special/build_runner.zig+2-2| ... | @@ -49,14 +49,14 @@ pub fn main() !void { | ... | @@ -49,14 +49,14 @@ pub fn main() !void { |
| 49 | 49 | ||
| 50 | var stderr_file = io.getStdErr(); | 50 | var stderr_file = io.getStdErr(); |
| 51 | var stderr_file_stream: io.FileOutStream = undefined; | 51 | var stderr_file_stream: io.FileOutStream = undefined; |
| 52 | var stderr_stream = if (stderr_file) |*f| x: { | 52 | var stderr_stream = if (stderr_file) |f| x: { |
| 53 | stderr_file_stream = io.FileOutStream.init(f); | 53 | stderr_file_stream = io.FileOutStream.init(f); |
| 54 | break :x &stderr_file_stream.stream; | 54 | break :x &stderr_file_stream.stream; |
| 55 | } else |err| err; | 55 | } else |err| err; |
| 56 | 56 | ||
| 57 | var stdout_file = io.getStdOut(); | 57 | var stdout_file = io.getStdOut(); |
| 58 | var stdout_file_stream: io.FileOutStream = undefined; | 58 | var stdout_file_stream: io.FileOutStream = undefined; |
| 59 | var stdout_stream = if (stdout_file) |*f| x: { | 59 | var stdout_stream = if (stdout_file) |f| x: { |
| 60 | stdout_file_stream = io.FileOutStream.init(f); | 60 | stdout_file_stream = io.FileOutStream.init(f); |
| 61 | break :x &stdout_file_stream.stream; | 61 | break :x &stdout_file_stream.stream; |
| 62 | } else |err| err; | 62 | } else |err| err; |
std/zig/parser_test.zig+1-1| ... | @@ -1865,7 +1865,7 @@ var fixed_buffer_mem: [100 * 1024]u8 = undefined; | ... | @@ -1865,7 +1865,7 @@ var fixed_buffer_mem: [100 * 1024]u8 = undefined; |
| 1865 | 1865 | ||
| 1866 | fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *bool) ![]u8 { | 1866 | fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *bool) ![]u8 { |
| 1867 | var stderr_file = try io.getStdErr(); | 1867 | var stderr_file = try io.getStdErr(); |
| 1868 | var stderr = &io.FileOutStream.init(&stderr_file).stream; | 1868 | var stderr = &io.FileOutStream.init(stderr_file).stream; |
| 1869 | 1869 | ||
| 1870 | var tree = try std.zig.parse(allocator, source); | 1870 | var tree = try std.zig.parse(allocator, source); |
| 1871 | defer tree.deinit(); | 1871 | defer tree.deinit(); |
test/compare_output.zig+15-15| ... | @@ -19,7 +19,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -19,7 +19,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 19 | \\ | 19 | \\ |
| 20 | \\pub fn main() void { | 20 | \\pub fn main() void { |
| 21 | \\ privateFunction(); | 21 | \\ privateFunction(); |
| 22 | \\ const stdout = &(FileOutStream.init(&(getStdOut() catch unreachable)).stream); | 22 | \\ const stdout = &FileOutStream.init(getStdOut() catch unreachable).stream; |
| 23 | \\ stdout.print("OK 2\n") catch unreachable; | 23 | \\ stdout.print("OK 2\n") catch unreachable; |
| 24 | \\} | 24 | \\} |
| 25 | \\ | 25 | \\ |
| ... | @@ -34,7 +34,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -34,7 +34,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 34 | \\// purposefully conflicting function with main.zig | 34 | \\// purposefully conflicting function with main.zig |
| 35 | \\// but it's private so it should be OK | 35 | \\// but it's private so it should be OK |
| 36 | \\fn privateFunction() void { | 36 | \\fn privateFunction() void { |
| 37 | \\ const stdout = &(FileOutStream.init(&(getStdOut() catch unreachable)).stream); | 37 | \\ const stdout = &FileOutStream.init(getStdOut() catch unreachable).stream; |
| 38 | \\ stdout.print("OK 1\n") catch unreachable; | 38 | \\ stdout.print("OK 1\n") catch unreachable; |
| 39 | \\} | 39 | \\} |
| 40 | \\ | 40 | \\ |
| ... | @@ -60,7 +60,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -60,7 +60,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 60 | tc.addSourceFile("foo.zig", | 60 | tc.addSourceFile("foo.zig", |
| 61 | \\use @import("std").io; | 61 | \\use @import("std").io; |
| 62 | \\pub fn foo_function() void { | 62 | \\pub fn foo_function() void { |
| 63 | \\ const stdout = &(FileOutStream.init(&(getStdOut() catch unreachable)).stream); | 63 | \\ const stdout = &FileOutStream.init(getStdOut() catch unreachable).stream; |
| 64 | \\ stdout.print("OK\n") catch unreachable; | 64 | \\ stdout.print("OK\n") catch unreachable; |
| 65 | \\} | 65 | \\} |
| 66 | ); | 66 | ); |
| ... | @@ -71,7 +71,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -71,7 +71,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 71 | \\ | 71 | \\ |
| 72 | \\pub fn bar_function() void { | 72 | \\pub fn bar_function() void { |
| 73 | \\ if (foo_function()) { | 73 | \\ if (foo_function()) { |
| 74 | \\ const stdout = &(FileOutStream.init(&(getStdOut() catch unreachable)).stream); | 74 | \\ const stdout = &FileOutStream.init(getStdOut() catch unreachable).stream; |
| 75 | \\ stdout.print("OK\n") catch unreachable; | 75 | \\ stdout.print("OK\n") catch unreachable; |
| 76 | \\ } | 76 | \\ } |
| 77 | \\} | 77 | \\} |
| ... | @@ -103,7 +103,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -103,7 +103,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 103 | \\pub const a_text = "OK\n"; | 103 | \\pub const a_text = "OK\n"; |
| 104 | \\ | 104 | \\ |
| 105 | \\pub fn ok() void { | 105 | \\pub fn ok() void { |
| 106 | \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); | 106 | \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; |
| 107 | \\ stdout.print(b_text) catch unreachable; | 107 | \\ stdout.print(b_text) catch unreachable; |
| 108 | \\} | 108 | \\} |
| 109 | ); | 109 | ); |
| ... | @@ -121,7 +121,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -121,7 +121,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 121 | \\const io = @import("std").io; | 121 | \\const io = @import("std").io; |
| 122 | \\ | 122 | \\ |
| 123 | \\pub fn main() void { | 123 | \\pub fn main() void { |
| 124 | \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); | 124 | \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; |
| 125 | \\ stdout.print("Hello, world!\n{d4} {x3} {c}\n", u32(12), u16(0x12), u8('a')) catch unreachable; | 125 | \\ stdout.print("Hello, world!\n{d4} {x3} {c}\n", u32(12), u16(0x12), u8('a')) catch unreachable; |
| 126 | \\} | 126 | \\} |
| 127 | , "Hello, world!\n0012 012 a\n"); | 127 | , "Hello, world!\n0012 012 a\n"); |
| ... | @@ -274,7 +274,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -274,7 +274,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 274 | \\ var x_local : i32 = print_ok(x); | 274 | \\ var x_local : i32 = print_ok(x); |
| 275 | \\} | 275 | \\} |
| 276 | \\fn print_ok(val: @typeOf(x)) @typeOf(foo) { | 276 | \\fn print_ok(val: @typeOf(x)) @typeOf(foo) { |
| 277 | \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); | 277 | \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; |
| 278 | \\ stdout.print("OK\n") catch unreachable; | 278 | \\ stdout.print("OK\n") catch unreachable; |
| 279 | \\ return 0; | 279 | \\ return 0; |
| 280 | \\} | 280 | \\} |
| ... | @@ -356,7 +356,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -356,7 +356,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 356 | \\pub fn main() void { | 356 | \\pub fn main() void { |
| 357 | \\ const bar = Bar {.field2 = 13,}; | 357 | \\ const bar = Bar {.field2 = 13,}; |
| 358 | \\ const foo = Foo {.field1 = bar,}; | 358 | \\ const foo = Foo {.field1 = bar,}; |
| 359 | \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); | 359 | \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; |
| 360 | \\ if (!foo.method()) { | 360 | \\ if (!foo.method()) { |
| 361 | \\ stdout.print("BAD\n") catch unreachable; | 361 | \\ stdout.print("BAD\n") catch unreachable; |
| 362 | \\ } | 362 | \\ } |
| ... | @@ -370,7 +370,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -370,7 +370,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 370 | cases.add("defer with only fallthrough", | 370 | cases.add("defer with only fallthrough", |
| 371 | \\const io = @import("std").io; | 371 | \\const io = @import("std").io; |
| 372 | \\pub fn main() void { | 372 | \\pub fn main() void { |
| 373 | \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); | 373 | \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; |
| 374 | \\ stdout.print("before\n") catch unreachable; | 374 | \\ stdout.print("before\n") catch unreachable; |
| 375 | \\ defer stdout.print("defer1\n") catch unreachable; | 375 | \\ defer stdout.print("defer1\n") catch unreachable; |
| 376 | \\ defer stdout.print("defer2\n") catch unreachable; | 376 | \\ defer stdout.print("defer2\n") catch unreachable; |
| ... | @@ -383,7 +383,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -383,7 +383,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 383 | \\const io = @import("std").io; | 383 | \\const io = @import("std").io; |
| 384 | \\const os = @import("std").os; | 384 | \\const os = @import("std").os; |
| 385 | \\pub fn main() void { | 385 | \\pub fn main() void { |
| 386 | \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); | 386 | \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; |
| 387 | \\ stdout.print("before\n") catch unreachable; | 387 | \\ stdout.print("before\n") catch unreachable; |
| 388 | \\ defer stdout.print("defer1\n") catch unreachable; | 388 | \\ defer stdout.print("defer1\n") catch unreachable; |
| 389 | \\ defer stdout.print("defer2\n") catch unreachable; | 389 | \\ defer stdout.print("defer2\n") catch unreachable; |
| ... | @@ -400,7 +400,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -400,7 +400,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 400 | \\ do_test() catch return; | 400 | \\ do_test() catch return; |
| 401 | \\} | 401 | \\} |
| 402 | \\fn do_test() !void { | 402 | \\fn do_test() !void { |
| 403 | \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); | 403 | \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; |
| 404 | \\ stdout.print("before\n") catch unreachable; | 404 | \\ stdout.print("before\n") catch unreachable; |
| 405 | \\ defer stdout.print("defer1\n") catch unreachable; | 405 | \\ defer stdout.print("defer1\n") catch unreachable; |
| 406 | \\ errdefer stdout.print("deferErr\n") catch unreachable; | 406 | \\ errdefer stdout.print("deferErr\n") catch unreachable; |
| ... | @@ -419,7 +419,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -419,7 +419,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 419 | \\ do_test() catch return; | 419 | \\ do_test() catch return; |
| 420 | \\} | 420 | \\} |
| 421 | \\fn do_test() !void { | 421 | \\fn do_test() !void { |
| 422 | \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); | 422 | \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; |
| 423 | \\ stdout.print("before\n") catch unreachable; | 423 | \\ stdout.print("before\n") catch unreachable; |
| 424 | \\ defer stdout.print("defer1\n") catch unreachable; | 424 | \\ defer stdout.print("defer1\n") catch unreachable; |
| 425 | \\ errdefer stdout.print("deferErr\n") catch unreachable; | 425 | \\ errdefer stdout.print("deferErr\n") catch unreachable; |
| ... | @@ -436,7 +436,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -436,7 +436,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 436 | \\const io = @import("std").io; | 436 | \\const io = @import("std").io; |
| 437 | \\ | 437 | \\ |
| 438 | \\pub fn main() void { | 438 | \\pub fn main() void { |
| 439 | \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); | 439 | \\ const stdout = &io.FileOutStream.init(io.getStdOut() catch unreachable).stream; |
| 440 | \\ stdout.print(foo_txt) catch unreachable; | 440 | \\ stdout.print(foo_txt) catch unreachable; |
| 441 | \\} | 441 | \\} |
| 442 | , "1234\nabcd\n"); | 442 | , "1234\nabcd\n"); |
| ... | @@ -456,7 +456,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -456,7 +456,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 456 | \\pub fn main() !void { | 456 | \\pub fn main() !void { |
| 457 | \\ var args_it = os.args(); | 457 | \\ var args_it = os.args(); |
| 458 | \\ var stdout_file = try io.getStdOut(); | 458 | \\ var stdout_file = try io.getStdOut(); |
| 459 | \\ var stdout_adapter = io.FileOutStream.init(&stdout_file); | 459 | \\ var stdout_adapter = io.FileOutStream.init(stdout_file); |
| 460 | \\ const stdout = &stdout_adapter.stream; | 460 | \\ const stdout = &stdout_adapter.stream; |
| 461 | \\ var index: usize = 0; | 461 | \\ var index: usize = 0; |
| 462 | \\ _ = args_it.skip(); | 462 | \\ _ = args_it.skip(); |
| ... | @@ -497,7 +497,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -497,7 +497,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 497 | \\pub fn main() !void { | 497 | \\pub fn main() !void { |
| 498 | \\ var args_it = os.args(); | 498 | \\ var args_it = os.args(); |
| 499 | \\ var stdout_file = try io.getStdOut(); | 499 | \\ var stdout_file = try io.getStdOut(); |
| 500 | \\ var stdout_adapter = io.FileOutStream.init(&stdout_file); | 500 | \\ var stdout_adapter = io.FileOutStream.init(stdout_file); |
| 501 | \\ const stdout = &stdout_adapter.stream; | 501 | \\ const stdout = &stdout_adapter.stream; |
| 502 | \\ var index: usize = 0; | 502 | \\ var index: usize = 0; |
| 503 | \\ _ = args_it.skip(); | 503 | \\ _ = args_it.skip(); |
test/tests.zig+6-6| ... | @@ -263,8 +263,8 @@ pub const CompareOutputContext = struct { | ... | @@ -263,8 +263,8 @@ pub const CompareOutputContext = struct { |
| 263 | var stdout = Buffer.initNull(b.allocator); | 263 | var stdout = Buffer.initNull(b.allocator); |
| 264 | var stderr = Buffer.initNull(b.allocator); | 264 | var stderr = Buffer.initNull(b.allocator); |
| 265 | 265 | ||
| 266 | var stdout_file_in_stream = io.FileInStream.init(&child.stdout.?); | 266 | var stdout_file_in_stream = io.FileInStream.init(child.stdout.?); |
| 267 | var stderr_file_in_stream = io.FileInStream.init(&child.stderr.?); | 267 | var stderr_file_in_stream = io.FileInStream.init(child.stderr.?); |
| 268 | 268 | ||
| 269 | stdout_file_in_stream.stream.readAllBuffer(&stdout, max_stdout_size) catch unreachable; | 269 | stdout_file_in_stream.stream.readAllBuffer(&stdout, max_stdout_size) catch unreachable; |
| 270 | stderr_file_in_stream.stream.readAllBuffer(&stderr, max_stdout_size) catch unreachable; | 270 | stderr_file_in_stream.stream.readAllBuffer(&stderr, max_stdout_size) catch unreachable; |
| ... | @@ -578,8 +578,8 @@ pub const CompileErrorContext = struct { | ... | @@ -578,8 +578,8 @@ pub const CompileErrorContext = struct { |
| 578 | var stdout_buf = Buffer.initNull(b.allocator); | 578 | var stdout_buf = Buffer.initNull(b.allocator); |
| 579 | var stderr_buf = Buffer.initNull(b.allocator); | 579 | var stderr_buf = Buffer.initNull(b.allocator); |
| 580 | 580 | ||
| 581 | var stdout_file_in_stream = io.FileInStream.init(&child.stdout.?); | 581 | var stdout_file_in_stream = io.FileInStream.init(child.stdout.?); |
| 582 | var stderr_file_in_stream = io.FileInStream.init(&child.stderr.?); | 582 | var stderr_file_in_stream = io.FileInStream.init(child.stderr.?); |
| 583 | 583 | ||
| 584 | stdout_file_in_stream.stream.readAllBuffer(&stdout_buf, max_stdout_size) catch unreachable; | 584 | stdout_file_in_stream.stream.readAllBuffer(&stdout_buf, max_stdout_size) catch unreachable; |
| 585 | stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable; | 585 | stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable; |
| ... | @@ -842,8 +842,8 @@ pub const TranslateCContext = struct { | ... | @@ -842,8 +842,8 @@ pub const TranslateCContext = struct { |
| 842 | var stdout_buf = Buffer.initNull(b.allocator); | 842 | var stdout_buf = Buffer.initNull(b.allocator); |
| 843 | var stderr_buf = Buffer.initNull(b.allocator); | 843 | var stderr_buf = Buffer.initNull(b.allocator); |
| 844 | 844 | ||
| 845 | var stdout_file_in_stream = io.FileInStream.init(&child.stdout.?); | 845 | var stdout_file_in_stream = io.FileInStream.init(child.stdout.?); |
| 846 | var stderr_file_in_stream = io.FileInStream.init(&child.stderr.?); | 846 | var stderr_file_in_stream = io.FileInStream.init(child.stderr.?); |
| 847 | 847 | ||
| 848 | stdout_file_in_stream.stream.readAllBuffer(&stdout_buf, max_stdout_size) catch unreachable; | 848 | stdout_file_in_stream.stream.readAllBuffer(&stdout_buf, max_stdout_size) catch unreachable; |
| 849 | stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable; | 849 | stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable; |