diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-07-11 16:25:21 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-07-12 00:14:08 -0700 |
| commit | fd4d366009e92c79137ee681334f216bbfc9b5f5 (patch) | |
| tree | 1a7c0c600fda53da7de622cca807f61626e7f330 /lib/std/Build/Cache/Path.zig | |
| parent | 818f9cb5a07bec1273d3fc1ecb54e7189a9e6106 (diff) | |
| download | zig-fd4d366009e92c79137ee681334f216bbfc9b5f5.tar.gz zig-fd4d366009e92c79137ee681334f216bbfc9b5f5.zip | |
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.
Diffstat (limited to 'lib/std/Build/Cache/Path.zig')
| -rw-r--r-- | lib/std/Build/Cache/Path.zig | 9 |
1 files 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 { |
