From fd4d366009e92c79137ee681334f216bbfc9b5f5 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 11 Jul 2024 16:25:21 -0700 Subject: [PATCH] std.Build.Cache.Path: fix the format method This function previously wrote a trailing directory separator, but that's not correct if the path refers to a file. --- lib/std/Build/Cache/Path.zig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/std/Build/Cache/Path.zig b/lib/std/Build/Cache/Path.zig index 0abe79d373..b81786d0a8 100644 --- a/lib/std/Build/Cache/Path.zig +++ b/lib/std/Build/Cache/Path.zig @@ -157,12 +157,17 @@ pub fn format( } if (self.root_dir.path) |p| { try writer.writeAll(p); - try writer.writeAll(fs.path.sep_str); + if (self.sub_path.len > 0) { + try writer.writeAll(fs.path.sep_str); + try writer.writeAll(self.sub_path); + } + return; } if (self.sub_path.len > 0) { try writer.writeAll(self.sub_path); - try writer.writeAll(fs.path.sep_str); + return; } + try writer.writeByte('.'); } pub fn eql(self: Path, other: Path) bool {