authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-10 20:22:30-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-10 20:22:30-04:00
log2bff0dda795cd84e4da59652736b7cfa7e1c964c
tree4b3bc5f10fefd1c3e4fedccc872ed99d9d87a6e7
parent9abee660dce3b43b9ac3b8260fbf269532d6c7f5
signaturelock-open Commit is signed but in an unrecognized format.

fix regressions found by test suite


11 files changed, 103 insertions(+), 128 deletions(-)

doc/docgen.zig+44-51
......@@ -40,12 +40,9 @@ pub fn main() !void {
4040 var out_file = try fs.cwd().createFile(out_file_name, .{});
4141 defer out_file.close();
4242
43 var file_in_stream = in_file.inStream();
43 const input_file_bytes = try in_file.inStream().readAllAlloc(allocator, max_doc_file_size);
4444
45 const input_file_bytes = try file_in_stream.stream.readAllAlloc(allocator, max_doc_file_size);
46
47 var file_out_stream = out_file.outStream();
48 var buffered_out_stream = io.BufferedOutStream(fs.File.WriteError).init(&file_out_stream.stream);
45 var buffered_out_stream = io.bufferedOutStream(out_file.outStream());
4946
5047 var tokenizer = Tokenizer.init(in_file_name, input_file_bytes);
5148 var toc = try genToc(allocator, &tokenizer);
......@@ -53,7 +50,7 @@ pub fn main() !void {
5350 try fs.cwd().makePath(tmp_dir_name);
5451 defer fs.deleteTree(tmp_dir_name) catch {};
5552
56 try genHtml(allocator, &tokenizer, &toc, &buffered_out_stream.stream, zig_exe);
53 try genHtml(allocator, &tokenizer, &toc, buffered_out_stream.outStream(), zig_exe);
5754 try buffered_out_stream.flush();
5855}
5956
......@@ -327,8 +324,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
327324 var toc_buf = try std.Buffer.initSize(allocator, 0);
328325 defer toc_buf.deinit();
329326
330 var toc_buf_adapter = io.BufferOutStream.init(&toc_buf);
331 var toc = &toc_buf_adapter.stream;
327 var toc = toc_buf.outStream();
332328
333329 var nodes = std.ArrayList(Node).init(allocator);
334330 defer nodes.deinit();
......@@ -342,7 +338,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
342338 if (header_stack_size != 0) {
343339 return parseError(tokenizer, token, "unbalanced headers", .{});
344340 }
345 try toc.write(" </ul>\n");
341 try toc.writeAll(" </ul>\n");
346342 break;
347343 },
348344 Token.Id.Content => {
......@@ -407,7 +403,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
407403 if (last_columns) |n| {
408404 try toc.print("<ul style=\"columns: {}\">\n", .{n});
409405 } else {
410 try toc.write("<ul>\n");
406 try toc.writeAll("<ul>\n");
411407 }
412408 } else {
413409 last_action = Action.Open;
......@@ -424,9 +420,9 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
424420
425421 if (last_action == Action.Close) {
426422 try toc.writeByteNTimes(' ', 8 + header_stack_size * 4);
427 try toc.write("</ul></li>\n");
423 try toc.writeAll("</ul></li>\n");
428424 } else {
429 try toc.write("</li>\n");
425 try toc.writeAll("</li>\n");
430426 last_action = Action.Close;
431427 }
432428 } else if (mem.eql(u8, tag_name, "see_also")) {
......@@ -614,8 +610,7 @@ fn urlize(allocator: *mem.Allocator, input: []const u8) ![]u8 {
614610 var buf = try std.Buffer.initSize(allocator, 0);
615611 defer buf.deinit();
616612
617 var buf_adapter = io.BufferOutStream.init(&buf);
618 var out = &buf_adapter.stream;
613 const out = buf.outStream();
619614 for (input) |c| {
620615 switch (c) {
621616 'a'...'z', 'A'...'Z', '_', '-', '0'...'9' => {
......@@ -634,8 +629,7 @@ fn escapeHtml(allocator: *mem.Allocator, input: []const u8) ![]u8 {
634629 var buf = try std.Buffer.initSize(allocator, 0);
635630 defer buf.deinit();
636631
637 var buf_adapter = io.BufferOutStream.init(&buf);
638 var out = &buf_adapter.stream;
632 const out = buf.outStream();
639633 try writeEscaped(out, input);
640634 return buf.toOwnedSlice();
641635}
......@@ -643,10 +637,10 @@ fn escapeHtml(allocator: *mem.Allocator, input: []const u8) ![]u8 {
643637fn writeEscaped(out: var, input: []const u8) !void {
644638 for (input) |c| {
645639 try switch (c) {
646 '&' => out.write("&amp;"),
647 '<' => out.write("&lt;"),
648 '>' => out.write("&gt;"),
649 '"' => out.write("&quot;"),
640 '&' => out.writeAll("&amp;"),
641 '<' => out.writeAll("&lt;"),
642 '>' => out.writeAll("&gt;"),
643 '"' => out.writeAll("&quot;"),
650644 else => out.writeByte(c),
651645 };
652646 }
......@@ -681,8 +675,7 @@ fn termColor(allocator: *mem.Allocator, input: []const u8) ![]u8 {
681675 var buf = try std.Buffer.initSize(allocator, 0);
682676 defer buf.deinit();
683677
684 var buf_adapter = io.BufferOutStream.init(&buf);
685 var out = &buf_adapter.stream;
678 var out = buf.outStream();
686679 var number_start_index: usize = undefined;
687680 var first_number: usize = undefined;
688681 var second_number: usize = undefined;
......@@ -743,7 +736,7 @@ fn termColor(allocator: *mem.Allocator, input: []const u8) ![]u8 {
743736 'm' => {
744737 state = TermState.Start;
745738 while (open_span_count != 0) : (open_span_count -= 1) {
746 try out.write("</span>");
739 try out.writeAll("</span>");
747740 }
748741 if (first_number != 0 or second_number != 0) {
749742 try out.print("<span class=\"t{}_{}\">", .{ first_number, second_number });
......@@ -774,7 +767,7 @@ fn isType(name: []const u8) bool {
774767
775768fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Token, raw_src: []const u8) !void {
776769 const src = mem.trim(u8, raw_src, " \n");
777 try out.write("<code class=\"zig\">");
770 try out.writeAll("<code class=\"zig\">");
778771 var tokenizer = std.zig.Tokenizer.init(src);
779772 var index: usize = 0;
780773 var next_tok_is_fn = false;
......@@ -835,15 +828,15 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
835828 .Keyword_allowzero,
836829 .Keyword_while,
837830 => {
838 try out.write("<span class=\"tok-kw\">");
831 try out.writeAll("<span class=\"tok-kw\">");
839832 try writeEscaped(out, src[token.start..token.end]);
840 try out.write("</span>");
833 try out.writeAll("</span>");
841834 },
842835
843836 .Keyword_fn => {
844 try out.write("<span class=\"tok-kw\">");
837 try out.writeAll("<span class=\"tok-kw\">");
845838 try writeEscaped(out, src[token.start..token.end]);
846 try out.write("</span>");
839 try out.writeAll("</span>");
847840 next_tok_is_fn = true;
848841 },
849842
......@@ -852,24 +845,24 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
852845 .Keyword_true,
853846 .Keyword_false,
854847 => {
855 try out.write("<span class=\"tok-null\">");
848 try out.writeAll("<span class=\"tok-null\">");
856849 try writeEscaped(out, src[token.start..token.end]);
857 try out.write("</span>");
850 try out.writeAll("</span>");
858851 },
859852
860853 .StringLiteral,
861854 .MultilineStringLiteralLine,
862855 .CharLiteral,
863856 => {
864 try out.write("<span class=\"tok-str\">");
857 try out.writeAll("<span class=\"tok-str\">");
865858 try writeEscaped(out, src[token.start..token.end]);
866 try out.write("</span>");
859 try out.writeAll("</span>");
867860 },
868861
869862 .Builtin => {
870 try out.write("<span class=\"tok-builtin\">");
863 try out.writeAll("<span class=\"tok-builtin\">");
871864 try writeEscaped(out, src[token.start..token.end]);
872 try out.write("</span>");
865 try out.writeAll("</span>");
873866 },
874867
875868 .LineComment,
......@@ -877,16 +870,16 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
877870 .ContainerDocComment,
878871 .ShebangLine,
879872 => {
880 try out.write("<span class=\"tok-comment\">");
873 try out.writeAll("<span class=\"tok-comment\">");
881874 try writeEscaped(out, src[token.start..token.end]);
882 try out.write("</span>");
875 try out.writeAll("</span>");
883876 },
884877
885878 .Identifier => {
886879 if (prev_tok_was_fn) {
887 try out.write("<span class=\"tok-fn\">");
880 try out.writeAll("<span class=\"tok-fn\">");
888881 try writeEscaped(out, src[token.start..token.end]);
889 try out.write("</span>");
882 try out.writeAll("</span>");
890883 } else {
891884 const is_int = blk: {
892885 if (src[token.start] != 'i' and src[token.start] != 'u')
......@@ -901,9 +894,9 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
901894 break :blk true;
902895 };
903896 if (is_int or isType(src[token.start..token.end])) {
904 try out.write("<span class=\"tok-type\">");
897 try out.writeAll("<span class=\"tok-type\">");
905898 try writeEscaped(out, src[token.start..token.end]);
906 try out.write("</span>");
899 try out.writeAll("</span>");
907900 } else {
908901 try writeEscaped(out, src[token.start..token.end]);
909902 }
......@@ -913,9 +906,9 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
913906 .IntegerLiteral,
914907 .FloatLiteral,
915908 => {
916 try out.write("<span class=\"tok-number\">");
909 try out.writeAll("<span class=\"tok-number\">");
917910 try writeEscaped(out, src[token.start..token.end]);
918 try out.write("</span>");
911 try out.writeAll("</span>");
919912 },
920913
921914 .Bang,
......@@ -983,7 +976,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
983976 }
984977 index = token.end;
985978 }
986 try out.write("</code>");
979 try out.writeAll("</code>");
987980}
988981
989982fn tokenizeAndPrint(docgen_tokenizer: *Tokenizer, out: var, source_token: Token) !void {
......@@ -1002,7 +995,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1002995 for (toc.nodes) |node| {
1003996 switch (node) {
1004997 .Content => |data| {
1005 try out.write(data);
998 try out.writeAll(data);
1006999 },
10071000 .Link => |info| {
10081001 if (!toc.urls.contains(info.url)) {
......@@ -1011,12 +1004,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
10111004 try out.print("<a href=\"#{}\">{}</a>", .{ info.url, info.name });
10121005 },
10131006 .Nav => {
1014 try out.write(toc.toc);
1007 try out.writeAll(toc.toc);
10151008 },
10161009 .Builtin => |tok| {
1017 try out.write("<pre>");
1010 try out.writeAll("<pre>");
10181011 try tokenizeAndPrintRaw(tokenizer, out, tok, builtin_code);
1019 try out.write("</pre>");
1012 try out.writeAll("</pre>");
10201013 },
10211014 .HeaderOpen => |info| {
10221015 try out.print(
......@@ -1025,7 +1018,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
10251018 );
10261019 },
10271020 .SeeAlso => |items| {
1028 try out.write("<p>See also:</p><ul>\n");
1021 try out.writeAll("<p>See also:</p><ul>\n");
10291022 for (items) |item| {
10301023 const url = try urlize(allocator, item.name);
10311024 if (!toc.urls.contains(url)) {
......@@ -1033,7 +1026,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
10331026 }
10341027 try out.print("<li><a href=\"#{}\">{}</a></li>\n", .{ url, item.name });
10351028 }
1036 try out.write("</ul>\n");
1029 try out.writeAll("</ul>\n");
10371030 },
10381031 .Syntax => |content_tok| {
10391032 try tokenizeAndPrint(tokenizer, out, content_tok);
......@@ -1047,9 +1040,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
10471040 if (!code.is_inline) {
10481041 try out.print("<p class=\"file\">{}.zig</p>", .{code.name});
10491042 }
1050 try out.write("<pre>");
1043 try out.writeAll("<pre>");
10511044 try tokenizeAndPrint(tokenizer, out, code.source_token);
1052 try out.write("</pre>");
1045 try out.writeAll("</pre>");
10531046 const name_plus_ext = try std.fmt.allocPrint(allocator, "{}.zig", .{code.name});
10541047 const tmp_source_file_name = try fs.path.join(
10551048 allocator,
doc/langref.html.in+1-1
......@@ -230,7 +230,7 @@
230230const std = @import("std");
231231
232232pub fn main() !void {
233 const stdout = &std.io.getStdOut().outStream().stream;
233 const stdout = std.io.getStdOut().outStream();
234234 try stdout.print("Hello, {}!\n", .{"world"});
235235}
236236 {#code_end#}
lib/std/build.zig+1-2
......@@ -926,8 +926,7 @@ pub const Builder = struct {
926926
927927 try child.spawn();
928928
929 var stdout_file_in_stream = child.stdout.?.inStream();
930 const stdout = try stdout_file_in_stream.stream.readAllAlloc(self.allocator, max_output_size);
929 const stdout = try child.stdout.?.inStream().readAllAlloc(self.allocator, max_output_size);
931930 errdefer self.allocator.free(stdout);
932931
933932 const term = try child.wait();
lib/std/build/run.zig+2-4
......@@ -175,8 +175,7 @@ pub const RunStep = struct {
175175
176176 switch (self.stdout_action) {
177177 .expect_exact, .expect_matches => {
178 var stdout_file_in_stream = child.stdout.?.inStream();
179 stdout = stdout_file_in_stream.stream.readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable;
178 stdout = child.stdout.?.inStream().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable;
180179 },
181180 .inherit, .ignore => {},
182181 }
......@@ -186,8 +185,7 @@ pub const RunStep = struct {
186185
187186 switch (self.stderr_action) {
188187 .expect_exact, .expect_matches => {
189 var stderr_file_in_stream = child.stderr.?.inStream();
190 stderr = stderr_file_in_stream.stream.readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable;
188 stderr = child.stderr.?.inStream().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable;
191189 },
192190 .inherit, .ignore => {},
193191 }
lib/std/coff.zig+6-9
......@@ -56,8 +56,7 @@ pub const Coff = struct {
5656 pub fn loadHeader(self: *Coff) !void {
5757 const pe_pointer_offset = 0x3C;
5858
59 var file_stream = self.in_file.inStream();
60 const in = &file_stream.stream;
59 const in = self.in_file.inStream();
6160
6261 var magic: [2]u8 = undefined;
6362 try in.readNoEof(magic[0..]);
......@@ -89,11 +88,11 @@ pub const Coff = struct {
8988 else => return error.InvalidMachine,
9089 }
9190
92 try self.loadOptionalHeader(&file_stream);
91 try self.loadOptionalHeader();
9392 }
9493
95 fn loadOptionalHeader(self: *Coff, file_stream: *File.InStream) !void {
96 const in = &file_stream.stream;
94 fn loadOptionalHeader(self: *Coff) !void {
95 const in = self.in_file.inStream();
9796 self.pe_header.magic = try in.readIntLittle(u16);
9897 // For now we're only interested in finding the reference to the .pdb,
9998 // so we'll skip most of this header, which size is different in 32
......@@ -136,8 +135,7 @@ pub const Coff = struct {
136135 const debug_dir = &self.pe_header.data_directory[DEBUG_DIRECTORY];
137136 const file_offset = debug_dir.virtual_address - header.virtual_address + header.pointer_to_raw_data;
138137
139 var file_stream = self.in_file.inStream();
140 const in = &file_stream.stream;
138 const in = self.in_file.inStream();
141139 try self.in_file.seekTo(file_offset);
142140
143141 // Find the correct DebugDirectoryEntry, and where its data is stored.
......@@ -188,8 +186,7 @@ pub const Coff = struct {
188186
189187 try self.sections.ensureCapacity(self.coff_header.number_of_sections);
190188
191 var file_stream = self.in_file.inStream();
192 const in = &file_stream.stream;
189 const in = self.in_file.inStream();
193190
194191 var name: [8]u8 = undefined;
195192
lib/std/debug.zig+19-19
......@@ -475,15 +475,15 @@ fn populateModule(di: *ModuleDebugInfo, mod: *Module) !void {
475475
476476 const modi = di.pdb.getStreamById(mod.mod_info.ModuleSymStream) orelse return error.MissingDebugInfo;
477477
478 const signature = try modi.stream.readIntLittle(u32);
478 const signature = try modi.inStream().readIntLittle(u32);
479479 if (signature != 4)
480480 return error.InvalidDebugInfo;
481481
482482 mod.symbols = try allocator.alloc(u8, mod.mod_info.SymByteSize - 4);
483 try modi.stream.readNoEof(mod.symbols);
483 try modi.inStream().readNoEof(mod.symbols);
484484
485485 mod.subsect_info = try allocator.alloc(u8, mod.mod_info.C13ByteSize);
486 try modi.stream.readNoEof(mod.subsect_info);
486 try modi.inStream().readNoEof(mod.subsect_info);
487487
488488 var sect_offset: usize = 0;
489489 var skip_len: usize = undefined;
......@@ -656,11 +656,11 @@ fn openCoffDebugInfo(allocator: *mem.Allocator, coff_file_path: [:0]const u16) !
656656 try di.pdb.openFile(di.coff, path);
657657
658658 var pdb_stream = di.pdb.getStream(pdb.StreamType.Pdb) orelse return error.InvalidDebugInfo;
659 const version = try pdb_stream.stream.readIntLittle(u32);
660 const signature = try pdb_stream.stream.readIntLittle(u32);
661 const age = try pdb_stream.stream.readIntLittle(u32);
659 const version = try pdb_stream.inStream().readIntLittle(u32);
660 const signature = try pdb_stream.inStream().readIntLittle(u32);
661 const age = try pdb_stream.inStream().readIntLittle(u32);
662662 var guid: [16]u8 = undefined;
663 try pdb_stream.stream.readNoEof(&guid);
663 try pdb_stream.inStream().readNoEof(&guid);
664664 if (version != 20000404) // VC70, only value observed by LLVM team
665665 return error.UnknownPDBVersion;
666666 if (!mem.eql(u8, &di.coff.guid, &guid) or di.coff.age != age)
......@@ -668,9 +668,9 @@ fn openCoffDebugInfo(allocator: *mem.Allocator, coff_file_path: [:0]const u16) !
668668 // We validated the executable and pdb match.
669669
670670 const string_table_index = str_tab_index: {
671 const name_bytes_len = try pdb_stream.stream.readIntLittle(u32);
671 const name_bytes_len = try pdb_stream.inStream().readIntLittle(u32);
672672 const name_bytes = try allocator.alloc(u8, name_bytes_len);
673 try pdb_stream.stream.readNoEof(name_bytes);
673 try pdb_stream.inStream().readNoEof(name_bytes);
674674
675675 const HashTableHeader = packed struct {
676676 Size: u32,
......@@ -680,17 +680,17 @@ fn openCoffDebugInfo(allocator: *mem.Allocator, coff_file_path: [:0]const u16) !
680680 return cap * 2 / 3 + 1;
681681 }
682682 };
683 const hash_tbl_hdr = try pdb_stream.stream.readStruct(HashTableHeader);
683 const hash_tbl_hdr = try pdb_stream.inStream().readStruct(HashTableHeader);
684684 if (hash_tbl_hdr.Capacity == 0)
685685 return error.InvalidDebugInfo;
686686
687687 if (hash_tbl_hdr.Size > HashTableHeader.maxLoad(hash_tbl_hdr.Capacity))
688688 return error.InvalidDebugInfo;
689689
690 const present = try readSparseBitVector(&pdb_stream.stream, allocator);
690 const present = try readSparseBitVector(&pdb_stream.inStream(), allocator);
691691 if (present.len != hash_tbl_hdr.Size)
692692 return error.InvalidDebugInfo;
693 const deleted = try readSparseBitVector(&pdb_stream.stream, allocator);
693 const deleted = try readSparseBitVector(&pdb_stream.inStream(), allocator);
694694
695695 const Bucket = struct {
696696 first: u32,
......@@ -698,8 +698,8 @@ fn openCoffDebugInfo(allocator: *mem.Allocator, coff_file_path: [:0]const u16) !
698698 };
699699 const bucket_list = try allocator.alloc(Bucket, present.len);
700700 for (present) |_| {
701 const name_offset = try pdb_stream.stream.readIntLittle(u32);
702 const name_index = try pdb_stream.stream.readIntLittle(u32);
701 const name_offset = try pdb_stream.inStream().readIntLittle(u32);
702 const name_index = try pdb_stream.inStream().readIntLittle(u32);
703703 const name = mem.toSlice(u8, @ptrCast([*:0]u8, name_bytes.ptr + name_offset));
704704 if (mem.eql(u8, name, "/names")) {
705705 break :str_tab_index name_index;
......@@ -714,7 +714,7 @@ fn openCoffDebugInfo(allocator: *mem.Allocator, coff_file_path: [:0]const u16) !
714714 const dbi = di.pdb.dbi;
715715
716716 // Dbi Header
717 const dbi_stream_header = try dbi.stream.readStruct(pdb.DbiStreamHeader);
717 const dbi_stream_header = try dbi.inStream().readStruct(pdb.DbiStreamHeader);
718718 if (dbi_stream_header.VersionHeader != 19990903) // V70, only value observed by LLVM team
719719 return error.UnknownPDBVersion;
720720 if (dbi_stream_header.Age != age)
......@@ -728,7 +728,7 @@ fn openCoffDebugInfo(allocator: *mem.Allocator, coff_file_path: [:0]const u16) !
728728 // Module Info Substream
729729 var mod_info_offset: usize = 0;
730730 while (mod_info_offset != mod_info_size) {
731 const mod_info = try dbi.stream.readStruct(pdb.ModInfo);
731 const mod_info = try dbi.inStream().readStruct(pdb.ModInfo);
732732 var this_record_len: usize = @sizeOf(pdb.ModInfo);
733733
734734 const module_name = try dbi.readNullTermString(allocator);
......@@ -766,14 +766,14 @@ fn openCoffDebugInfo(allocator: *mem.Allocator, coff_file_path: [:0]const u16) !
766766 var sect_contribs = ArrayList(pdb.SectionContribEntry).init(allocator);
767767 var sect_cont_offset: usize = 0;
768768 if (section_contrib_size != 0) {
769 const ver = @intToEnum(pdb.SectionContrSubstreamVersion, try dbi.stream.readIntLittle(u32));
769 const ver = @intToEnum(pdb.SectionContrSubstreamVersion, try dbi.inStream().readIntLittle(u32));
770770 if (ver != pdb.SectionContrSubstreamVersion.Ver60)
771771 return error.InvalidDebugInfo;
772772 sect_cont_offset += @sizeOf(u32);
773773 }
774774 while (sect_cont_offset != section_contrib_size) {
775775 const entry = try sect_contribs.addOne();
776 entry.* = try dbi.stream.readStruct(pdb.SectionContribEntry);
776 entry.* = try dbi.inStream().readStruct(pdb.SectionContribEntry);
777777 sect_cont_offset += @sizeOf(pdb.SectionContribEntry);
778778
779779 if (sect_cont_offset > section_contrib_size)
......@@ -827,7 +827,7 @@ pub fn openElfDebugInfo(allocator: *mem.Allocator, elf_file_path: []const u8) !M
827827 const str_section_off = shoff + @as(u64, hdr.e_shentsize) * @as(u64, hdr.e_shstrndx);
828828 const str_shdr = @ptrCast(
829829 *const elf.Shdr,
830 @alignCast(@alignOf(elf.Shdr), &mapped_mem[str_section_off]),
830 @alignCast(@alignOf(elf.Shdr), &mapped_mem[try math.cast(usize, str_section_off)]),
831831 );
832832 const header_strings = mapped_mem[str_shdr.sh_offset .. str_shdr.sh_offset + str_shdr.sh_size];
833833 const shdrs = @ptrCast(
lib/std/pdb.zig+6-8
......@@ -495,8 +495,7 @@ const Msf = struct {
495495 streams: []MsfStream,
496496
497497 fn openFile(self: *Msf, allocator: *mem.Allocator, file: File) !void {
498 var file_stream = file.inStream();
499 const in = &file_stream.stream;
498 const in = file.inStream();
500499
501500 const superblock = try in.readStruct(SuperBlock);
502501
......@@ -529,7 +528,7 @@ const Msf = struct {
529528 );
530529
531530 const begin = self.directory.pos;
532 const stream_count = try self.directory.stream.readIntLittle(u32);
531 const stream_count = try self.directory.inStream().readIntLittle(u32);
533532 const stream_sizes = try allocator.alloc(u32, stream_count);
534533 defer allocator.free(stream_sizes);
535534
......@@ -538,7 +537,7 @@ const Msf = struct {
538537 // and must be taken into account when resolving stream indices.
539538 const Nil = 0xFFFFFFFF;
540539 for (stream_sizes) |*s, i| {
541 const size = try self.directory.stream.readIntLittle(u32);
540 const size = try self.directory.inStream().readIntLittle(u32);
542541 s.* = if (size == Nil) 0 else blockCountFromSize(size, superblock.BlockSize);
543542 }
544543
......@@ -553,7 +552,7 @@ const Msf = struct {
553552 var blocks = try allocator.alloc(u32, size);
554553 var j: u32 = 0;
555554 while (j < size) : (j += 1) {
556 const block_id = try self.directory.stream.readIntLittle(u32);
555 const block_id = try self.directory.inStream().readIntLittle(u32);
557556 const n = (block_id % superblock.BlockSize);
558557 // 0 is for SuperBlock, 1 and 2 for FPMs.
559558 if (block_id == 0 or n == 1 or n == 2 or block_id * superblock.BlockSize > try file.getEndPos())
......@@ -648,7 +647,7 @@ const MsfStream = struct {
648647 fn readNullTermString(self: *MsfStream, allocator: *mem.Allocator) ![]u8 {
649648 var list = ArrayList(u8).init(allocator);
650649 while (true) {
651 const byte = try self.stream.readByte();
650 const byte = try self.inStream().readByte();
652651 if (byte == 0) {
653652 return list.toSlice();
654653 }
......@@ -662,8 +661,7 @@ const MsfStream = struct {
662661 var offset = self.pos % self.block_size;
663662
664663 try self.in_file.seekTo(block * self.block_size + offset);
665 var file_stream = self.in_file.inStream();
666 const in = &file_stream.stream;
664 const in = self.in_file.inStream();
667665
668666 var size: usize = 0;
669667 var rem_buffer = buffer;
lib/std/special/build_runner.zig+4-4
......@@ -42,8 +42,8 @@ pub fn main() !void {
4242
4343 var targets = ArrayList([]const u8).init(allocator);
4444
45 const stderr_stream = &io.getStdErr().outStream().stream;
46 const stdout_stream = &io.getStdOut().outStream().stream;
45 const stderr_stream = io.getStdErr().outStream();
46 const stdout_stream = io.getStdOut().outStream();
4747
4848 while (nextArg(args, &arg_idx)) |arg| {
4949 if (mem.startsWith(u8, arg, "-D")) {
......@@ -159,7 +159,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
159159 try out_stream.print(" {s:22} {}\n", .{ name, top_level_step.description });
160160 }
161161
162 try out_stream.write(
162 try out_stream.writeAll(
163163 \\
164164 \\General Options:
165165 \\ --help Print this help and exit
......@@ -184,7 +184,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
184184 }
185185 }
186186
187 try out_stream.write(
187 try out_stream.writeAll(
188188 \\
189189 \\Advanced Options:
190190 \\ --build-file [file] Override path to build.zig
test/compare_output.zig+15-19
......@@ -22,7 +22,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
2222 \\
2323 \\pub fn main() void {
2424 \\ privateFunction();
25 \\ const stdout = &getStdOut().outStream().stream;
25 \\ const stdout = getStdOut().outStream();
2626 \\ stdout.print("OK 2\n", .{}) catch unreachable;
2727 \\}
2828 \\
......@@ -37,7 +37,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
3737 \\// purposefully conflicting function with main.zig
3838 \\// but it's private so it should be OK
3939 \\fn privateFunction() void {
40 \\ const stdout = &getStdOut().outStream().stream;
40 \\ const stdout = getStdOut().outStream();
4141 \\ stdout.print("OK 1\n", .{}) catch unreachable;
4242 \\}
4343 \\
......@@ -63,7 +63,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
6363 tc.addSourceFile("foo.zig",
6464 \\usingnamespace @import("std").io;
6565 \\pub fn foo_function() void {
66 \\ const stdout = &getStdOut().outStream().stream;
66 \\ const stdout = getStdOut().outStream();
6767 \\ stdout.print("OK\n", .{}) catch unreachable;
6868 \\}
6969 );
......@@ -74,7 +74,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
7474 \\
7575 \\pub fn bar_function() void {
7676 \\ if (foo_function()) {
77 \\ const stdout = &getStdOut().outStream().stream;
77 \\ const stdout = getStdOut().outStream();
7878 \\ stdout.print("OK\n", .{}) catch unreachable;
7979 \\ }
8080 \\}
......@@ -106,7 +106,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
106106 \\pub const a_text = "OK\n";
107107 \\
108108 \\pub fn ok() void {
109 \\ const stdout = &io.getStdOut().outStream().stream;
109 \\ const stdout = io.getStdOut().outStream();
110110 \\ stdout.print(b_text, .{}) catch unreachable;
111111 \\}
112112 );
......@@ -124,7 +124,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
124124 \\const io = @import("std").io;
125125 \\
126126 \\pub fn main() void {
127 \\ const stdout = &io.getStdOut().outStream().stream;
127 \\ const stdout = io.getStdOut().outStream();
128128 \\ stdout.print("Hello, world!\n{d:4} {x:3} {c}\n", .{@as(u32, 12), @as(u16, 0x12), @as(u8, 'a')}) catch unreachable;
129129 \\}
130130 , "Hello, world!\n 12 12 a\n");
......@@ -267,7 +267,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
267267 \\ var x_local : i32 = print_ok(x);
268268 \\}
269269 \\fn print_ok(val: @TypeOf(x)) @TypeOf(foo) {
270 \\ const stdout = &io.getStdOut().outStream().stream;
270 \\ const stdout = io.getStdOut().outStream();
271271 \\ stdout.print("OK\n", .{}) catch unreachable;
272272 \\ return 0;
273273 \\}
......@@ -349,7 +349,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
349349 \\pub fn main() void {
350350 \\ const bar = Bar {.field2 = 13,};
351351 \\ const foo = Foo {.field1 = bar,};
352 \\ const stdout = &io.getStdOut().outStream().stream;
352 \\ const stdout = io.getStdOut().outStream();
353353 \\ if (!foo.method()) {
354354 \\ stdout.print("BAD\n", .{}) catch unreachable;
355355 \\ }
......@@ -363,7 +363,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
363363 cases.add("defer with only fallthrough",
364364 \\const io = @import("std").io;
365365 \\pub fn main() void {
366 \\ const stdout = &io.getStdOut().outStream().stream;
366 \\ const stdout = io.getStdOut().outStream();
367367 \\ stdout.print("before\n", .{}) catch unreachable;
368368 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
369369 \\ defer stdout.print("defer2\n", .{}) catch unreachable;
......@@ -376,7 +376,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
376376 \\const io = @import("std").io;
377377 \\const os = @import("std").os;
378378 \\pub fn main() void {
379 \\ const stdout = &io.getStdOut().outStream().stream;
379 \\ const stdout = io.getStdOut().outStream();
380380 \\ stdout.print("before\n", .{}) catch unreachable;
381381 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
382382 \\ defer stdout.print("defer2\n", .{}) catch unreachable;
......@@ -393,7 +393,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
393393 \\ do_test() catch return;
394394 \\}
395395 \\fn do_test() !void {
396 \\ const stdout = &io.getStdOut().outStream().stream;
396 \\ const stdout = io.getStdOut().outStream();
397397 \\ stdout.print("before\n", .{}) catch unreachable;
398398 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
399399 \\ errdefer stdout.print("deferErr\n", .{}) catch unreachable;
......@@ -412,7 +412,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
412412 \\ do_test() catch return;
413413 \\}
414414 \\fn do_test() !void {
415 \\ const stdout = &io.getStdOut().outStream().stream;
415 \\ const stdout = io.getStdOut().outStream();
416416 \\ stdout.print("before\n", .{}) catch unreachable;
417417 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
418418 \\ errdefer stdout.print("deferErr\n", .{}) catch unreachable;
......@@ -429,7 +429,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
429429 \\const io = @import("std").io;
430430 \\
431431 \\pub fn main() void {
432 \\ const stdout = &io.getStdOut().outStream().stream;
432 \\ const stdout = io.getStdOut().outStream();
433433 \\ stdout.print(foo_txt, .{}) catch unreachable;
434434 \\}
435435 , "1234\nabcd\n");
......@@ -448,9 +448,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
448448 \\
449449 \\pub fn main() !void {
450450 \\ var args_it = std.process.args();
451 \\ var stdout_file = io.getStdOut();
452 \\ var stdout_adapter = stdout_file.outStream();
453 \\ const stdout = &stdout_adapter.stream;
451 \\ const stdout = io.getStdOut().outStream();
454452 \\ var index: usize = 0;
455453 \\ _ = args_it.skip();
456454 \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) {
......@@ -489,9 +487,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
489487 \\
490488 \\pub fn main() !void {
491489 \\ var args_it = std.process.args();
492 \\ var stdout_file = io.getStdOut();
493 \\ var stdout_adapter = stdout_file.outStream();
494 \\ const stdout = &stdout_adapter.stream;
490 \\ const stdout = io.getStdOut().outStream();
495491 \\ var index: usize = 0;
496492 \\ _ = args_it.skip();
497493 \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) {
test/standalone/guess_number/main.zig+1-1
......@@ -4,7 +4,7 @@ const io = std.io;
44const fmt = std.fmt;
55
66pub fn main() !void {
7 const stdout = &io.getStdOut().outStream().stream;
7 const stdout = io.getStdOut().outStream();
88 const stdin = io.getStdIn();
99
1010 try stdout.print("Welcome to the Guess Number Game in Zig.\n", .{});
test/tests.zig+4-10
......@@ -566,12 +566,9 @@ pub const StackTracesContext = struct {
566566 }
567567 child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });
568568
569 var stdout_file_in_stream = child.stdout.?.inStream();
570 var stderr_file_in_stream = child.stderr.?.inStream();
571
572 const stdout = stdout_file_in_stream.stream.readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
569 const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
573570 defer b.allocator.free(stdout);
574 const stderr = stderr_file_in_stream.stream.readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
571 const stderr = child.stderr.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
575572 defer b.allocator.free(stderr);
576573
577574 const term = child.wait() catch |err| {
......@@ -798,11 +795,8 @@ pub const CompileErrorContext = struct {
798795 var stdout_buf = Buffer.initNull(b.allocator);
799796 var stderr_buf = Buffer.initNull(b.allocator);
800797
801 var stdout_file_in_stream = child.stdout.?.inStream();
802 var stderr_file_in_stream = child.stderr.?.inStream();
803
804 stdout_file_in_stream.stream.readAllBuffer(&stdout_buf, max_stdout_size) catch unreachable;
805 stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable;
798 child.stdout.?.inStream().readAllBuffer(&stdout_buf, max_stdout_size) catch unreachable;
799 child.stderr.?.inStream().readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable;
806800
807801 const term = child.wait() catch |err| {
808802 debug.panic("Unable to spawn {}: {}\n", .{ zig_args.items[0], @errorName(err) });