authorgravatar for 14938807+xackus@users.noreply.github.comxackus <14938807+xackus@users.noreply.github.com> 2020-04-02 00:00:42+02:00
committergravatar for 14938807+xackus@users.noreply.github.comxackus <14938807+xackus@users.noreply.github.com> 2020-04-02 16:12:08+02:00
log7a28c644aa8eb3d27dee113338af8278f8f6334f
treede1a483b9d9fa9224a50c94522da6bb3308b016c
parentd3ab0eb28de5a5a94fd4ef988dd4c4b0e3ddf927

new ArrayList API: fix everything else


18 files changed, 58 insertions(+), 59 deletions(-)

lib/std/build.zig+2-2
...@@ -1779,7 +1779,7 @@ pub const LibExeObjStep = struct {...@@ -1779,7 +1779,7 @@ pub const LibExeObjStep = struct {
1779 const self = @fieldParentPtr(LibExeObjStep, "step", step);1779 const self = @fieldParentPtr(LibExeObjStep, "step", step);
1780 const builder = self.builder;1780 const builder = self.builder;
17811781
1782 if (self.root_src == null and self.link_objects.len == 0) {1782 if (self.root_src == null and self.link_objects.items.len == 0) {
1783 warn("{}: linker needs 1 or more objects to link\n", .{self.step.name});1783 warn("{}: linker needs 1 or more objects to link\n", .{self.step.name});
1784 return error.NeedAnObject;1784 return error.NeedAnObject;
1785 }1785 }
...@@ -1847,7 +1847,7 @@ pub const LibExeObjStep = struct {...@@ -1847,7 +1847,7 @@ pub const LibExeObjStep = struct {
1847 }1847 }
1848 }1848 }
18491849
1850 if (self.build_options_contents.len > 0) {1850 if (self.build_options_contents.items.len > 0) {
1851 const build_options_file = try fs.path.join(1851 const build_options_file = try fs.path.join(
1852 builder.allocator,1852 builder.allocator,
1853 &[_][]const u8{ builder.cache_root, builder.fmt("{}_build_options.zig", .{self.name}) },1853 &[_][]const u8{ builder.cache_root, builder.fmt("{}_build_options.zig", .{self.name}) },
lib/std/build/emit_raw.zig+1-1
...@@ -94,7 +94,7 @@ const BinaryElfOutput = struct {...@@ -94,7 +94,7 @@ const BinaryElfOutput = struct {
9494
95 sort.sort(*BinaryElfSegment, self.segments.span(), segmentSortCompare);95 sort.sort(*BinaryElfSegment, self.segments.span(), segmentSortCompare);
9696
97 if (self.segments.len > 0) {97 if (self.segments.items.len > 0) {
98 const firstSegment = self.segments.at(0);98 const firstSegment = self.segments.at(0);
99 if (firstSegment.firstSection) |firstSection| {99 if (firstSegment.firstSection) |firstSection| {
100 const diff = firstSection.elfOffset - firstSegment.elfOffset;100 const diff = firstSection.elfOffset - firstSegment.elfOffset;
lib/std/coff.zig+1-1
...@@ -181,7 +181,7 @@ pub const Coff = struct {...@@ -181,7 +181,7 @@ pub const Coff = struct {
181 }181 }
182182
183 pub fn loadSections(self: *Coff) !void {183 pub fn loadSections(self: *Coff) !void {
184 if (self.sections.len == self.coff_header.number_of_sections)184 if (self.sections.items.len == self.coff_header.number_of_sections)
185 return;185 return;
186186
187 try self.sections.ensureCapacity(self.coff_header.number_of_sections);187 try self.sections.ensureCapacity(self.coff_header.number_of_sections);
lib/std/debug.zig+1-1
...@@ -1478,7 +1478,7 @@ pub const ModuleDebugInfo = switch (builtin.os.tag) {...@@ -1478,7 +1478,7 @@ pub const ModuleDebugInfo = switch (builtin.os.tag) {
14781478
1479 var coff_section: *coff.Section = undefined;1479 var coff_section: *coff.Section = undefined;
1480 const mod_index = for (self.sect_contribs) |sect_contrib| {1480 const mod_index = for (self.sect_contribs) |sect_contrib| {
1481 if (sect_contrib.Section > self.coff.sections.len) continue;1481 if (sect_contrib.Section > self.coff.sections.items.len) continue;
1482 // Remember that SectionContribEntry.Section is 1-based.1482 // Remember that SectionContribEntry.Section is 1-based.
1483 coff_section = &self.coff.sections.span()[sect_contrib.Section - 1];1483 coff_section = &self.coff.sections.span()[sect_contrib.Section - 1];
14841484
lib/std/fs.zig+3-3
...@@ -1440,9 +1440,9 @@ pub const Walker = struct {...@@ -1440,9 +1440,9 @@ pub const Walker = struct {
1440 /// a reference to the path.1440 /// a reference to the path.
1441 pub fn next(self: *Walker) !?Entry {1441 pub fn next(self: *Walker) !?Entry {
1442 while (true) {1442 while (true) {
1443 if (self.stack.len == 0) return null;1443 if (self.stack.items.len == 0) return null;
1444 // `top` becomes invalid after appending to `self.stack`.1444 // `top` becomes invalid after appending to `self.stack`.
1445 const top = &self.stack.span()[self.stack.len - 1];1445 const top = &self.stack.span()[self.stack.items.len - 1];
1446 const dirname_len = top.dirname_len;1446 const dirname_len = top.dirname_len;
1447 if (try top.dir_it.next()) |base| {1447 if (try top.dir_it.next()) |base| {
1448 self.name_buffer.shrink(dirname_len);1448 self.name_buffer.shrink(dirname_len);
...@@ -1457,7 +1457,7 @@ pub const Walker = struct {...@@ -1457,7 +1457,7 @@ pub const Walker = struct {
1457 errdefer new_dir.close();1457 errdefer new_dir.close();
1458 try self.stack.append(StackItem{1458 try self.stack.append(StackItem{
1459 .dir_it = new_dir.iterate(),1459 .dir_it = new_dir.iterate(),
1460 .dirname_len = self.name_buffer.len,1460 .dirname_len = self.name_buffer.items.len,
1461 });1461 });
1462 }1462 }
1463 }1463 }
lib/std/http/headers.zig+12-12
...@@ -139,7 +139,7 @@ pub const Headers = struct {...@@ -139,7 +139,7 @@ pub const Headers = struct {
139 pub fn clone(self: Self, allocator: *Allocator) !Self {139 pub fn clone(self: Self, allocator: *Allocator) !Self {
140 var other = Headers.init(allocator);140 var other = Headers.init(allocator);
141 errdefer other.deinit();141 errdefer other.deinit();
142 try other.data.ensureCapacity(self.data.len);142 try other.data.ensureCapacity(self.data.items.len);
143 try other.index.initCapacity(self.index.entries.len);143 try other.index.initCapacity(self.index.entries.len);
144 for (self.data.span()) |entry| {144 for (self.data.span()) |entry| {
145 try other.append(entry.name, entry.value, entry.never_index);145 try other.append(entry.name, entry.value, entry.never_index);
...@@ -152,7 +152,7 @@ pub const Headers = struct {...@@ -152,7 +152,7 @@ pub const Headers = struct {
152 }152 }
153153
154 pub fn append(self: *Self, name: []const u8, value: []const u8, never_index: ?bool) !void {154 pub fn append(self: *Self, name: []const u8, value: []const u8, never_index: ?bool) !void {
155 const n = self.data.len + 1;155 const n = self.data.items.len + 1;
156 try self.data.ensureCapacity(n);156 try self.data.ensureCapacity(n);
157 var entry: HeaderEntry = undefined;157 var entry: HeaderEntry = undefined;
158 if (self.index.get(name)) |kv| {158 if (self.index.get(name)) |kv| {
...@@ -197,7 +197,7 @@ pub const Headers = struct {...@@ -197,7 +197,7 @@ pub const Headers = struct {
197 if (self.index.remove(name)) |kv| {197 if (self.index.remove(name)) |kv| {
198 var dex = &kv.value;198 var dex = &kv.value;
199 // iterate backwards199 // iterate backwards
200 var i = dex.len;200 var i = dex.items.len;
201 while (i > 0) {201 while (i > 0) {
202 i -= 1;202 i -= 1;
203 const data_index = dex.at(i);203 const data_index = dex.at(i);
...@@ -220,18 +220,18 @@ pub const Headers = struct {...@@ -220,18 +220,18 @@ pub const Headers = struct {
220 const removed = self.data.orderedRemove(i);220 const removed = self.data.orderedRemove(i);
221 const kv = self.index.get(removed.name).?;221 const kv = self.index.get(removed.name).?;
222 var dex = &kv.value;222 var dex = &kv.value;
223 if (dex.len == 1) {223 if (dex.items.len == 1) {
224 // was last item; delete the index224 // was last item; delete the index
225 _ = self.index.remove(kv.key);225 _ = self.index.remove(kv.key);
226 dex.deinit();226 dex.deinit();
227 removed.deinit();227 removed.deinit();
228 self.allocator.free(kv.key);228 self.allocator.free(kv.key);
229 } else {229 } else {
230 dex.shrink(dex.len - 1);230 dex.shrink(dex.items.len - 1);
231 removed.deinit();231 removed.deinit();
232 }232 }
233 // if it was the last item; no need to rebuild index233 // if it was the last item; no need to rebuild index
234 if (i != self.data.len) {234 if (i != self.data.items.len) {
235 self.rebuild_index();235 self.rebuild_index();
236 }236 }
237 }237 }
...@@ -242,18 +242,18 @@ pub const Headers = struct {...@@ -242,18 +242,18 @@ pub const Headers = struct {
242 const removed = self.data.swapRemove(i);242 const removed = self.data.swapRemove(i);
243 const kv = self.index.get(removed.name).?;243 const kv = self.index.get(removed.name).?;
244 var dex = &kv.value;244 var dex = &kv.value;
245 if (dex.len == 1) {245 if (dex.items.len == 1) {
246 // was last item; delete the index246 // was last item; delete the index
247 _ = self.index.remove(kv.key);247 _ = self.index.remove(kv.key);
248 dex.deinit();248 dex.deinit();
249 removed.deinit();249 removed.deinit();
250 self.allocator.free(kv.key);250 self.allocator.free(kv.key);
251 } else {251 } else {
252 dex.shrink(dex.len - 1);252 dex.shrink(dex.items.len - 1);
253 removed.deinit();253 removed.deinit();
254 }254 }
255 // if it was the last item; no need to rebuild index255 // if it was the last item; no need to rebuild index
256 if (i != self.data.len) {256 if (i != self.data.items.len) {
257 self.rebuild_index();257 self.rebuild_index();
258 }258 }
259 }259 }
...@@ -277,7 +277,7 @@ pub const Headers = struct {...@@ -277,7 +277,7 @@ pub const Headers = struct {
277 pub fn get(self: Self, allocator: *Allocator, name: []const u8) !?[]const HeaderEntry {277 pub fn get(self: Self, allocator: *Allocator, name: []const u8) !?[]const HeaderEntry {
278 const dex = self.getIndices(name) orelse return null;278 const dex = self.getIndices(name) orelse return null;
279279
280 const buf = try allocator.alloc(HeaderEntry, dex.len);280 const buf = try allocator.alloc(HeaderEntry, dex.items.len);
281 var n: usize = 0;281 var n: usize = 0;
282 for (dex.span()) |idx| {282 for (dex.span()) |idx| {
283 buf[n] = self.data.at(idx);283 buf[n] = self.data.at(idx);
...@@ -301,7 +301,7 @@ pub const Headers = struct {...@@ -301,7 +301,7 @@ pub const Headers = struct {
301301
302 // adapted from mem.join302 // adapted from mem.join
303 const total_len = blk: {303 const total_len = blk: {
304 var sum: usize = dex.len - 1; // space for separator(s)304 var sum: usize = dex.items.len - 1; // space for separator(s)
305 for (dex.span()) |idx|305 for (dex.span()) |idx|
306 sum += self.data.at(idx).value.len;306 sum += self.data.at(idx).value.len;
307 break :blk sum;307 break :blk sum;
...@@ -330,7 +330,7 @@ pub const Headers = struct {...@@ -330,7 +330,7 @@ pub const Headers = struct {
330 var it = self.index.iterator();330 var it = self.index.iterator();
331 while (it.next()) |kv| {331 while (it.next()) |kv| {
332 var dex = &kv.value;332 var dex = &kv.value;
333 dex.len = 0; // keeps capacity available333 dex.items.len = 0; // keeps capacity available
334 }334 }
335 }335 }
336 { // fill up indexes again; we know capacity is fine from before336 { // fill up indexes again; we know capacity is fine from before
lib/std/io/in_stream.zig+1-1
...@@ -54,7 +54,7 @@ pub fn InStream(...@@ -54,7 +54,7 @@ pub fn InStream(
54 /// and the `std.ArrayList` has exactly `max_append_size` bytes appended.54 /// and the `std.ArrayList` has exactly `max_append_size` bytes appended.
55 pub fn readAllArrayList(self: Self, array_list: *std.ArrayList(u8), max_append_size: usize) !void {55 pub fn readAllArrayList(self: Self, array_list: *std.ArrayList(u8), max_append_size: usize) !void {
56 try array_list.ensureCapacity(math.min(max_append_size, 4096));56 try array_list.ensureCapacity(math.min(max_append_size, 4096));
57 const original_len = array_list.len;57 const original_len = array_list.items.len;
58 var start_index: usize = original_len;58 var start_index: usize = original_len;
59 while (true) {59 while (true) {
60 array_list.expandToCapacity();60 array_list.expandToCapacity();
lib/std/json.zig+10-10
...@@ -1556,7 +1556,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options:...@@ -1556,7 +1556,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options:
1556 else => {},1556 else => {},
1557 }1557 }
15581558
1559 try arraylist.ensureCapacity(arraylist.len + 1);1559 try arraylist.ensureCapacity(arraylist.items.len + 1);
1560 const v = try parseInternal(ptrInfo.child, tok, tokens, options);1560 const v = try parseInternal(ptrInfo.child, tok, tokens, options);
1561 arraylist.appendAssumeCapacity(v);1561 arraylist.appendAssumeCapacity(v);
1562 }1562 }
...@@ -1874,7 +1874,7 @@ pub const Parser = struct {...@@ -1874,7 +1874,7 @@ pub const Parser = struct {
1874 try p.transition(&arena.allocator, input, s.i - 1, token);1874 try p.transition(&arena.allocator, input, s.i - 1, token);
1875 }1875 }
18761876
1877 debug.assert(p.stack.len == 1);1877 debug.assert(p.stack.items.len == 1);
18781878
1879 return ValueTree{1879 return ValueTree{
1880 .arena = arena,1880 .arena = arena,
...@@ -1888,7 +1888,7 @@ pub const Parser = struct {...@@ -1888,7 +1888,7 @@ pub const Parser = struct {
1888 switch (p.state) {1888 switch (p.state) {
1889 .ObjectKey => switch (token) {1889 .ObjectKey => switch (token) {
1890 .ObjectEnd => {1890 .ObjectEnd => {
1891 if (p.stack.len == 1) {1891 if (p.stack.items.len == 1) {
1892 return;1892 return;
1893 }1893 }
18941894
...@@ -1907,8 +1907,8 @@ pub const Parser = struct {...@@ -1907,8 +1907,8 @@ pub const Parser = struct {
1907 },1907 },
1908 },1908 },
1909 .ObjectValue => {1909 .ObjectValue => {
1910 var object = &p.stack.items[p.stack.len - 2].Object;1910 var object = &p.stack.items[p.stack.items.len - 2].Object;
1911 var key = p.stack.items[p.stack.len - 1].String;1911 var key = p.stack.items[p.stack.items.len - 1].String;
19121912
1913 switch (token) {1913 switch (token) {
1914 .ObjectBegin => {1914 .ObjectBegin => {
...@@ -1950,11 +1950,11 @@ pub const Parser = struct {...@@ -1950,11 +1950,11 @@ pub const Parser = struct {
1950 }1950 }
1951 },1951 },
1952 .ArrayValue => {1952 .ArrayValue => {
1953 var array = &p.stack.items[p.stack.len - 1].Array;1953 var array = &p.stack.items[p.stack.items.len - 1].Array;
19541954
1955 switch (token) {1955 switch (token) {
1956 .ArrayEnd => {1956 .ArrayEnd => {
1957 if (p.stack.len == 1) {1957 if (p.stack.items.len == 1) {
1958 return;1958 return;
1959 }1959 }
19601960
...@@ -2021,12 +2021,12 @@ pub const Parser = struct {...@@ -2021,12 +2021,12 @@ pub const Parser = struct {
2021 }2021 }
20222022
2023 fn pushToParent(p: *Parser, value: *const Value) !void {2023 fn pushToParent(p: *Parser, value: *const Value) !void {
2024 switch (p.stack.span()[p.stack.len - 1]) {2024 switch (p.stack.span()[p.stack.items.len - 1]) {
2025 // Object Parent -> [ ..., object, <key>, value ]2025 // Object Parent -> [ ..., object, <key>, value ]
2026 Value.String => |key| {2026 Value.String => |key| {
2027 _ = p.stack.pop();2027 _ = p.stack.pop();
20282028
2029 var object = &p.stack.items[p.stack.len - 1].Object;2029 var object = &p.stack.items[p.stack.items.len - 1].Object;
2030 _ = try object.put(key, value.*);2030 _ = try object.put(key, value.*);
2031 p.state = .ObjectKey;2031 p.state = .ObjectKey;
2032 },2032 },
...@@ -2165,7 +2165,7 @@ test "json.parser.dynamic" {...@@ -2165,7 +2165,7 @@ test "json.parser.dynamic" {
2165 testing.expect(animated.Bool == false);2165 testing.expect(animated.Bool == false);
21662166
2167 const array_of_object = image.Object.get("ArrayOfObject").?.value;2167 const array_of_object = image.Object.get("ArrayOfObject").?.value;
2168 testing.expect(array_of_object.Array.len == 1);2168 testing.expect(array_of_object.Array.items.len == 1);
21692169
2170 const obj0 = array_of_object.Array.at(0).Object.get("n").?.value;2170 const obj0 = array_of_object.Array.at(0).Object.get("n").?.value;
2171 testing.expect(mem.eql(u8, obj0.String, "m"));2171 testing.expect(mem.eql(u8, obj0.String, "m"));
lib/std/math/big/rational.zig-1
...@@ -4,7 +4,6 @@ const math = std.math;...@@ -4,7 +4,6 @@ const math = std.math;
4const mem = std.mem;4const mem = std.mem;
5const testing = std.testing;5const testing = std.testing;
6const Allocator = mem.Allocator;6const Allocator = mem.Allocator;
7const ArrayList = std.ArrayList;
87
9const bn = @import("int.zig");8const bn = @import("int.zig");
10const Limb = bn.Limb;9const Limb = bn.Limb;
lib/std/net.zig+8-8
...@@ -509,7 +509,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*...@@ -509,7 +509,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
509509
510 try linuxLookupName(&lookup_addrs, &canon, name, family, flags, port);510 try linuxLookupName(&lookup_addrs, &canon, name, family, flags, port);
511511
512 result.addrs = try arena.alloc(Address, lookup_addrs.len);512 result.addrs = try arena.alloc(Address, lookup_addrs.items.len);
513 if (!canon.isNull()) {513 if (!canon.isNull()) {
514 result.canon_name = canon.toOwnedSlice();514 result.canon_name = canon.toOwnedSlice();
515 }515 }
...@@ -554,7 +554,7 @@ fn linuxLookupName(...@@ -554,7 +554,7 @@ fn linuxLookupName(
554 return name_err;554 return name_err;
555 } else {555 } else {
556 try linuxLookupNameFromHosts(addrs, canon, name, family, port);556 try linuxLookupNameFromHosts(addrs, canon, name, family, port);
557 if (addrs.len == 0) {557 if (addrs.items.len == 0) {
558 try linuxLookupNameFromDnsSearch(addrs, canon, name, family, port);558 try linuxLookupNameFromDnsSearch(addrs, canon, name, family, port);
559 }559 }
560 }560 }
...@@ -562,11 +562,11 @@ fn linuxLookupName(...@@ -562,11 +562,11 @@ fn linuxLookupName(
562 try canon.resize(0);562 try canon.resize(0);
563 try linuxLookupNameFromNull(addrs, family, flags, port);563 try linuxLookupNameFromNull(addrs, family, flags, port);
564 }564 }
565 if (addrs.len == 0) return error.UnknownHostName;565 if (addrs.items.len == 0) return error.UnknownHostName;
566566
567 // No further processing is needed if there are fewer than 2567 // No further processing is needed if there are fewer than 2
568 // results or if there are only IPv4 results.568 // results or if there are only IPv4 results.
569 if (addrs.len == 1 or family == os.AF_INET) return;569 if (addrs.items.len == 1 or family == os.AF_INET) return;
570 const all_ip4 = for (addrs.span()) |addr| {570 const all_ip4 = for (addrs.span()) |addr| {
571 if (addr.addr.any.family != os.AF_INET) break false;571 if (addr.addr.any.family != os.AF_INET) break false;
572 } else true;572 } else true;
...@@ -908,7 +908,7 @@ fn linuxLookupNameFromDnsSearch(...@@ -908,7 +908,7 @@ fn linuxLookupNameFromDnsSearch(
908 canon.shrink(canon_name.len + 1);908 canon.shrink(canon_name.len + 1);
909 try canon.appendSlice(tok);909 try canon.appendSlice(tok);
910 try linuxLookupNameFromDns(addrs, canon, canon.span(), family, rc, port);910 try linuxLookupNameFromDns(addrs, canon, canon.span(), family, rc, port);
911 if (addrs.len != 0) return;911 if (addrs.items.len != 0) return;
912 }912 }
913913
914 canon.shrink(canon_name.len);914 canon.shrink(canon_name.len);
...@@ -967,7 +967,7 @@ fn linuxLookupNameFromDns(...@@ -967,7 +967,7 @@ fn linuxLookupNameFromDns(
967 dnsParse(ap[i], ctx, dnsParseCallback) catch {};967 dnsParse(ap[i], ctx, dnsParseCallback) catch {};
968 }968 }
969969
970 if (addrs.len != 0) return;970 if (addrs.items.len != 0) return;
971 if (ap[0].len < 4 or (ap[0][3] & 15) == 2) return error.TemporaryNameServerFailure;971 if (ap[0].len < 4 or (ap[0][3] & 15) == 2) return error.TemporaryNameServerFailure;
972 if ((ap[0][3] & 15) == 0) return error.UnknownHostName;972 if ((ap[0][3] & 15) == 0) return error.UnknownHostName;
973 if ((ap[0][3] & 15) == 3) return;973 if ((ap[0][3] & 15) == 3) return;
...@@ -1049,7 +1049,7 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void {...@@ -1049,7 +1049,7 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void {
1049 }1049 }
1050 }1050 }
10511051
1052 if (rc.ns.len == 0) {1052 if (rc.ns.items.len == 0) {
1053 return linuxLookupNameFromNumericUnspec(&rc.ns, "127.0.0.1", 53);1053 return linuxLookupNameFromNumericUnspec(&rc.ns, "127.0.0.1", 53);
1054 }1054 }
1055}1055}
...@@ -1078,7 +1078,7 @@ fn resMSendRc(...@@ -1078,7 +1078,7 @@ fn resMSendRc(
1078 var ns_list = std.ArrayList(Address).init(rc.ns.allocator);1078 var ns_list = std.ArrayList(Address).init(rc.ns.allocator);
1079 defer ns_list.deinit();1079 defer ns_list.deinit();
10801080
1081 try ns_list.resize(rc.ns.len);1081 try ns_list.resize(rc.ns.items.len);
1082 const ns = ns_list.span();1082 const ns = ns_list.span();
10831083
1084 for (rc.ns.span()) |iplit, i| {1084 for (rc.ns.span()) |iplit, i| {
lib/std/special/build_runner.zig+1-1
...@@ -171,7 +171,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {...@@ -171,7 +171,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
171 \\171 \\
172 );172 );
173173
174 if (builder.available_options_list.len == 0) {174 if (builder.available_options_list.items.len == 0) {
175 try out_stream.print(" (none)\n", .{});175 try out_stream.print(" (none)\n", .{});
176 } else {176 } else {
177 for (builder.available_options_list.span()) |option| {177 for (builder.available_options_list.span()) |option| {
lib/std/unicode.zig+2-2
...@@ -475,7 +475,7 @@ pub fn utf16leToUtf8Alloc(allocator: *mem.Allocator, utf16le: []const u16) ![]u8...@@ -475,7 +475,7 @@ pub fn utf16leToUtf8Alloc(allocator: *mem.Allocator, utf16le: []const u16) ![]u8
475 var it = Utf16LeIterator.init(utf16le);475 var it = Utf16LeIterator.init(utf16le);
476 while (try it.nextCodepoint()) |codepoint| {476 while (try it.nextCodepoint()) |codepoint| {
477 const utf8_len = utf8CodepointSequenceLength(codepoint) catch unreachable;477 const utf8_len = utf8CodepointSequenceLength(codepoint) catch unreachable;
478 try result.resize(result.len + utf8_len);478 try result.resize(result.items.len + utf8_len);
479 assert((utf8Encode(codepoint, result.items[out_index..]) catch unreachable) == utf8_len);479 assert((utf8Encode(codepoint, result.items[out_index..]) catch unreachable) == utf8_len);
480 out_index += utf8_len;480 out_index += utf8_len;
481 }481 }
...@@ -571,7 +571,7 @@ pub fn utf8ToUtf16LeWithNull(allocator: *mem.Allocator, utf8: []const u8) ![:0]u...@@ -571,7 +571,7 @@ pub fn utf8ToUtf16LeWithNull(allocator: *mem.Allocator, utf8: []const u8) ![:0]u
571 }571 }
572 }572 }
573573
574 const len = result.len;574 const len = result.items.len;
575 try result.append(0);575 try result.append(0);
576 return result.toOwnedSlice()[0..len :0];576 return result.toOwnedSlice()[0..len :0];
577}577}
src-self-hosted/libc_installation.zig+3-3
...@@ -268,7 +268,7 @@ pub const LibCInstallation = struct {...@@ -268,7 +268,7 @@ pub const LibCInstallation = struct {
268 try search_paths.append(line);268 try search_paths.append(line);
269 }269 }
270 }270 }
271 if (search_paths.len == 0) {271 if (search_paths.items.len == 0) {
272 return error.CCompilerCannotFindHeaders;272 return error.CCompilerCannotFindHeaders;
273 }273 }
274274
...@@ -276,9 +276,9 @@ pub const LibCInstallation = struct {...@@ -276,9 +276,9 @@ pub const LibCInstallation = struct {
276 const sys_include_dir_example_file = if (is_windows) "sys\\types.h" else "sys/errno.h";276 const sys_include_dir_example_file = if (is_windows) "sys\\types.h" else "sys/errno.h";
277277
278 var path_i: usize = 0;278 var path_i: usize = 0;
279 while (path_i < search_paths.len) : (path_i += 1) {279 while (path_i < search_paths.items.len) : (path_i += 1) {
280 // search in reverse order280 // search in reverse order
281 const search_path_untrimmed = search_paths.at(search_paths.len - path_i - 1);281 const search_path_untrimmed = search_paths.at(search_paths.items.len - path_i - 1);
282 const search_path = std.mem.trimLeft(u8, search_path_untrimmed, " ");282 const search_path = std.mem.trimLeft(u8, search_path_untrimmed, " ");
283 var search_dir = fs.cwd().openDir(search_path, .{}) catch |err| switch (err) {283 var search_dir = fs.cwd().openDir(search_path, .{}) catch |err| switch (err) {
284 error.FileNotFound,284 error.FileNotFound,
src-self-hosted/stage2.zig+2-2
...@@ -239,7 +239,7 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void {...@@ -239,7 +239,7 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void {
239 }239 }
240240
241 if (stdin_flag) {241 if (stdin_flag) {
242 if (input_files.len != 0) {242 if (input_files.items.len != 0) {
243 try stderr.writeAll("cannot use --stdin with positional arguments\n");243 try stderr.writeAll("cannot use --stdin with positional arguments\n");
244 process.exit(1);244 process.exit(1);
245 }245 }
...@@ -273,7 +273,7 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void {...@@ -273,7 +273,7 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void {
273 return;273 return;
274 }274 }
275275
276 if (input_files.len == 0) {276 if (input_files.items.len == 0) {
277 try stderr.writeAll("expected at least one source file argument\n");277 try stderr.writeAll("expected at least one source file argument\n");
278 process.exit(1);278 process.exit(1);
279 }279 }
src-self-hosted/translate_c.zig+3-3
...@@ -4309,7 +4309,7 @@ fn makeRestorePoint(c: *Context) RestorePoint {...@@ -4309,7 +4309,7 @@ fn makeRestorePoint(c: *Context) RestorePoint {
4309 return RestorePoint{4309 return RestorePoint{
4310 .c = c,4310 .c = c,
4311 .token_index = c.tree.tokens.len,4311 .token_index = c.tree.tokens.len,
4312 .src_buf_index = c.source_buffer.len,4312 .src_buf_index = c.source_buffer.items.len,
4313 };4313 };
4314}4314}
43154315
...@@ -4771,11 +4771,11 @@ fn appendToken(c: *Context, token_id: Token.Id, bytes: []const u8) !ast.TokenInd...@@ -4771,11 +4771,11 @@ fn appendToken(c: *Context, token_id: Token.Id, bytes: []const u8) !ast.TokenInd
47714771
4772fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: var) !ast.TokenIndex {4772fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: var) !ast.TokenIndex {
4773 assert(token_id != .Invalid);4773 assert(token_id != .Invalid);
4774 const start_index = c.source_buffer.len;4774 const start_index = c.source_buffer.items.len;
4775 errdefer c.source_buffer.shrink(start_index);4775 errdefer c.source_buffer.shrink(start_index);
47764776
4777 try c.source_buffer.outStream().print(format, args);4777 try c.source_buffer.outStream().print(format, args);
4778 const end_index = c.source_buffer.len;4778 const end_index = c.source_buffer.items.len;
4779 const token_index = c.tree.tokens.len;4779 const token_index = c.tree.tokens.len;
4780 const new_token = try c.tree.tokens.addOne();4780 const new_token = try c.tree.tokens.addOne();
4781 errdefer c.tree.tokens.shrink(token_index);4781 errdefer c.tree.tokens.shrink(token_index);
test/standalone/brace_expansion/main.zig+2-2
...@@ -113,7 +113,7 @@ fn parse(tokens: *const ArrayList(Token), token_index: *usize) ParseError!Node {...@@ -113,7 +113,7 @@ fn parse(tokens: *const ArrayList(Token), token_index: *usize) ParseError!Node {
113113
114fn expandString(input: []const u8, output: *ArrayListSentineled(u8, 0)) !void {114fn expandString(input: []const u8, output: *ArrayListSentineled(u8, 0)) !void {
115 const tokens = try tokenize(input);115 const tokens = try tokenize(input);
116 if (tokens.len == 1) {116 if (tokens.items.len == 1) {
117 return output.resize(0);117 return output.resize(0);
118 }118 }
119119
...@@ -142,7 +142,7 @@ fn expandString(input: []const u8, output: *ArrayListSentineled(u8, 0)) !void {...@@ -142,7 +142,7 @@ fn expandString(input: []const u8, output: *ArrayListSentineled(u8, 0)) !void {
142const ExpandNodeError = error{OutOfMemory};142const ExpandNodeError = error{OutOfMemory};
143143
144fn expandNode(node: Node, output: *ArrayList(ArrayListSentineled(u8, 0))) ExpandNodeError!void {144fn expandNode(node: Node, output: *ArrayList(ArrayListSentineled(u8, 0))) ExpandNodeError!void {
145 assert(output.len == 0);145 assert(output.items.len == 0);
146 switch (node) {146 switch (node) {
147 Node.Scalar => |scalar| {147 Node.Scalar => |scalar| {
148 try output.append(try ArrayListSentineled(u8, 0).init(global_allocator, scalar));148 try output.append(try ArrayListSentineled(u8, 0).init(global_allocator, scalar));
test/tests.zig+2-2
...@@ -864,13 +864,13 @@ pub const CompileErrorContext = struct {...@@ -864,13 +864,13 @@ pub const CompileErrorContext = struct {
864 var err_iter = ErrLineIter.init(stderr);864 var err_iter = ErrLineIter.init(stderr);
865 var i: usize = 0;865 var i: usize = 0;
866 ok = while (err_iter.next()) |line| : (i += 1) {866 ok = while (err_iter.next()) |line| : (i += 1) {
867 if (i >= self.case.expected_errors.len) break false;867 if (i >= self.case.expected_errors.items.len) break false;
868 const expected = self.case.expected_errors.at(i);868 const expected = self.case.expected_errors.at(i);
869 if (mem.indexOf(u8, line, expected) == null) break false;869 if (mem.indexOf(u8, line, expected) == null) break false;
870 continue;870 continue;
871 } else true;871 } else true;
872872
873 ok = ok and i == self.case.expected_errors.len;873 ok = ok and i == self.case.expected_errors.items.len;
874874
875 if (!ok) {875 if (!ok) {
876 warn("\n======== Expected these compile errors: ========\n", .{});876 warn("\n======== Expected these compile errors: ========\n", .{});
tools/merge_anal_dumps.zig+4-4
...@@ -194,7 +194,7 @@ const Dump = struct {...@@ -194,7 +194,7 @@ const Dump = struct {
194 for (other_files) |other_file, i| {194 for (other_files) |other_file, i| {
195 const gop = try self.file_map.getOrPut(other_file.String);195 const gop = try self.file_map.getOrPut(other_file.String);
196 if (!gop.found_existing) {196 if (!gop.found_existing) {
197 gop.kv.value = self.file_list.len;197 gop.kv.value = self.file_list.items.len;
198 try self.file_list.append(other_file.String);198 try self.file_list.append(other_file.String);
199 }199 }
200 try other_file_to_mine.putNoClobber(i, gop.kv.value);200 try other_file_to_mine.putNoClobber(i, gop.kv.value);
...@@ -213,7 +213,7 @@ const Dump = struct {...@@ -213,7 +213,7 @@ const Dump = struct {
213 };213 };
214 const gop = try self.node_map.getOrPut(other_node);214 const gop = try self.node_map.getOrPut(other_node);
215 if (!gop.found_existing) {215 if (!gop.found_existing) {
216 gop.kv.value = self.node_list.len;216 gop.kv.value = self.node_list.items.len;
217 try self.node_list.append(other_node);217 try self.node_list.append(other_node);
218 }218 }
219 try other_ast_node_to_mine.putNoClobber(i, gop.kv.value);219 try other_ast_node_to_mine.putNoClobber(i, gop.kv.value);
...@@ -243,7 +243,7 @@ const Dump = struct {...@@ -243,7 +243,7 @@ const Dump = struct {
243 };243 };
244 const gop = try self.error_map.getOrPut(other_error);244 const gop = try self.error_map.getOrPut(other_error);
245 if (!gop.found_existing) {245 if (!gop.found_existing) {
246 gop.kv.value = self.error_list.len;246 gop.kv.value = self.error_list.items.len;
247 try self.error_list.append(other_error);247 try self.error_list.append(other_error);
248 }248 }
249 try other_error_to_mine.putNoClobber(i, gop.kv.value);249 try other_error_to_mine.putNoClobber(i, gop.kv.value);
...@@ -304,7 +304,7 @@ const Dump = struct {...@@ -304,7 +304,7 @@ const Dump = struct {
304 ) !void {304 ) !void {
305 const gop = try self.type_map.getOrPut(other_type);305 const gop = try self.type_map.getOrPut(other_type);
306 if (!gop.found_existing) {306 if (!gop.found_existing) {
307 gop.kv.value = self.type_list.len;307 gop.kv.value = self.type_list.items.len;
308 try self.type_list.append(other_type);308 try self.type_list.append(other_type);
309 }309 }
310 try other_types_to_mine.putNoClobber(other_type_index, gop.kv.value);310 try other_types_to_mine.putNoClobber(other_type_index, gop.kv.value);