| author | |
| committer | |
| log | b5ed0ae2cecb96adca7b259f7054519c92a3283f |
| tree | ef5e9ef53e900fd3b4ffd0e7db8a79b06bb2e2b4 |
| parent | fb255db0adc7fb39f4d33738fcf3c5831a1a7649 |
3 files changed, 18 insertions(+), 15 deletions(-)
lib/compiler/Maker.zig+11-8| ... | ... | @@ -4677,12 +4677,13 @@ test sanitizeExampleName { |
| 4677 | 4677 | const Templates = struct { |
| 4678 | 4678 | zig_lib_directory: Cache.Directory, |
| 4679 | 4679 | dir: Io.Dir, |
| 4680 | buffer: std.array_list.Managed(u8), | |
| 4680 | buffer: std.ArrayList(u8), | |
| 4681 | gpa: Allocator, | |
| 4681 | 4682 | |
| 4682 | 4683 | fn deinit(templates: *Templates, io: Io) void { |
| 4683 | 4684 | templates.zig_lib_directory.handle.close(io); |
| 4684 | 4685 | templates.dir.close(io); |
| 4685 | templates.buffer.deinit(); | |
| 4686 | templates.buffer.deinit(templates.gpa); | |
| 4686 | 4687 | templates.* = undefined; |
| 4687 | 4688 | } |
| 4688 | 4689 | |
| ... | ... | @@ -4705,29 +4706,30 @@ const Templates = struct { |
| 4705 | 4706 | const contents = templates.dir.readFileAlloc(io, template_path, arena, .limited(max_bytes)) catch |err| { |
| 4706 | 4707 | fatal("unable to read template file {q}: {t}", .{ template_path, err }); |
| 4707 | 4708 | }; |
| 4709 | const gpa = templates.gpa; | |
| 4708 | 4710 | templates.buffer.clearRetainingCapacity(); |
| 4709 | try templates.buffer.ensureUnusedCapacity(contents.len); | |
| 4711 | try templates.buffer.ensureUnusedCapacity(gpa, contents.len); | |
| 4710 | 4712 | var i: usize = 0; |
| 4711 | 4713 | while (i < contents.len) { |
| 4712 | 4714 | if (contents[i] == '_' or contents[i] == '.') { |
| 4713 | 4715 | // Both '_' and '.' are allowed because depending on the context |
| 4714 | 4716 | // one prefix will be valid, while the other might not. |
| 4715 | 4717 | if (std.mem.startsWith(u8, contents[i + 1 ..], "NAME")) { |
| 4716 | try templates.buffer.appendSlice(root_name); | |
| 4718 | try templates.buffer.appendSlice(gpa, root_name); | |
| 4717 | 4719 | i += "_NAME".len; |
| 4718 | 4720 | continue; |
| 4719 | 4721 | } else if (std.mem.startsWith(u8, contents[i + 1 ..], "FINGERPRINT")) { |
| 4720 | try templates.buffer.print("0x{x}", .{fingerprint.int()}); | |
| 4722 | try templates.buffer.print(gpa, "0x{x}", .{fingerprint.int()}); | |
| 4721 | 4723 | i += "_FINGERPRINT".len; |
| 4722 | 4724 | continue; |
| 4723 | 4725 | } else if (std.mem.startsWith(u8, contents[i + 1 ..], "ZIGVER")) { |
| 4724 | try templates.buffer.appendSlice(builtin.zig_version_string); | |
| 4726 | try templates.buffer.appendSlice(gpa, builtin.zig_version_string); | |
| 4725 | 4727 | i += "_ZIGVER".len; |
| 4726 | 4728 | continue; |
| 4727 | 4729 | } |
| 4728 | 4730 | } |
| 4729 | 4731 | |
| 4730 | try templates.buffer.append(contents[i]); | |
| 4732 | try templates.buffer.append(gpa, contents[i]); | |
| 4731 | 4733 | i += 1; |
| 4732 | 4734 | } |
| 4733 | 4735 | |
| ... | ... | @@ -4748,7 +4750,8 @@ const Templates = struct { |
| 4748 | 4750 | return .{ |
| 4749 | 4751 | .zig_lib_directory = zig_lib_directory, |
| 4750 | 4752 | .dir = template_dir, |
| 4751 | .buffer = std.array_list.Managed(u8).init(gpa), | |
| 4753 | .buffer = .empty, | |
| 4754 | .gpa = gpa, | |
| 4752 | 4755 | }; |
| 4753 | 4756 | } |
| 4754 | 4757 |
lib/compiler/Maker/Fetch.zig+6-6| ... | ... | @@ -1756,11 +1756,11 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash |
| 1756 | 1756 | const root_dir = pkg_path.root_dir.handle; |
| 1757 | 1757 | |
| 1758 | 1758 | // Collect all files, recursively, then sort. |
| 1759 | var all_files = std.array_list.Managed(*HashedFile).init(gpa); | |
| 1760 | defer all_files.deinit(); | |
| 1759 | var all_files: std.ArrayList(*HashedFile) = .empty; | |
| 1760 | defer all_files.deinit(gpa); | |
| 1761 | 1761 | |
| 1762 | var deleted_files = std.array_list.Managed(*DeletedFile).init(gpa); | |
| 1763 | defer deleted_files.deinit(); | |
| 1762 | var deleted_files: std.ArrayList(*DeletedFile) = .empty; | |
| 1763 | defer deleted_files.deinit(gpa); | |
| 1764 | 1764 | |
| 1765 | 1765 | // Track directories which had any files deleted from them so that empty directories |
| 1766 | 1766 | // can be deleted. |
| ... | ... | @@ -1803,7 +1803,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash |
| 1803 | 1803 | .failure = undefined, // to be populated by the worker |
| 1804 | 1804 | }; |
| 1805 | 1805 | group.async(io, workerDeleteFile, .{ io, root_dir, deleted_file }); |
| 1806 | try deleted_files.append(deleted_file); | |
| 1806 | try deleted_files.append(gpa, deleted_file); | |
| 1807 | 1807 | continue; |
| 1808 | 1808 | } |
| 1809 | 1809 | |
| ... | ... | @@ -1831,7 +1831,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash |
| 1831 | 1831 | .size = undefined, // to be populated by the worker |
| 1832 | 1832 | }; |
| 1833 | 1833 | group.async(io, workerHashFile, .{ io, root_dir, hashed_file }); |
| 1834 | try all_files.append(hashed_file); | |
| 1834 | try all_files.append(gpa, hashed_file); | |
| 1835 | 1835 | } |
| 1836 | 1836 | |
| 1837 | 1837 | try group.await(io); |
lib/compiler/Maker/Step/Compile.zig+1-1| ... | ... | @@ -867,7 +867,7 @@ fn lowerZigArgs( |
| 867 | 867 | return step.fail(maker, "failed creating directory {f}: {t}", .{ args_path, err }); |
| 868 | 868 | |
| 869 | 869 | const args_to_escape = zig_args.items[2..]; |
| 870 | var escaped_args = try std.array_list.Managed([]const u8).initCapacity(arena, args_to_escape.len); | |
| 870 | var escaped_args: std.ArrayList([]const u8) = try .initCapacity(arena, args_to_escape.len); | |
| 871 | 871 | arg_blk: for (args_to_escape) |arg| { |
| 872 | 872 | for (arg, 0..) |c, arg_idx| { |
| 873 | 873 | if (c == '\\' or c == '"') { |