authorgravatar for hahv@msn.comKNnut <hahv@msn.com> 2025-08-04 23:07:49+08:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-05 06:08:42+02:00
logfcb088cb6abf8a0a20de2650491c2d9a4b1ba399
tree6e16dab5b8ba16d4ac4ae64fe6ff85122f61faf7
parent96be6f6566b19c242220f0f8571dc81ecadf6a79

std.Target.Query: fix `WindowsVersion` format in `zigTriple()`


1 files changed, 18 insertions(+), 2 deletions(-)

lib/std/Target/Query.zig+18-2
...@@ -423,7 +423,7 @@ pub fn zigTriple(self: Query, gpa: Allocator) Allocator.Error![]u8 {...@@ -423,7 +423,7 @@ pub fn zigTriple(self: Query, gpa: Allocator) Allocator.Error![]u8 {
423 try formatVersion(v, gpa, &result);423 try formatVersion(v, gpa, &result);
424 },424 },
425 .windows => |v| {425 .windows => |v| {
426 try result.print(gpa, "{d}", .{v});426 try result.print(gpa, "{f}", .{v});
427 },427 },
428 }428 }
429 }429 }
...@@ -437,7 +437,7 @@ pub fn zigTriple(self: Query, gpa: Allocator) Allocator.Error![]u8 {...@@ -437,7 +437,7 @@ pub fn zigTriple(self: Query, gpa: Allocator) Allocator.Error![]u8 {
437 .windows => |v| {437 .windows => |v| {
438 // This is counting on a custom format() function defined on `WindowsVersion`438 // This is counting on a custom format() function defined on `WindowsVersion`
439 // to add a prefix '.' and make there be a total of three dots.439 // to add a prefix '.' and make there be a total of three dots.
440 try result.print(gpa, "..{d}", .{v});440 try result.print(gpa, "..{f}", .{v});
441 },441 },
442 }442 }
443 }443 }
...@@ -729,4 +729,20 @@ test parse {...@@ -729,4 +729,20 @@ test parse {
729 defer std.testing.allocator.free(text);729 defer std.testing.allocator.free(text);
730 try std.testing.expectEqualSlices(u8, "aarch64-linux.3.10...4.4.1-android.30", text);730 try std.testing.expectEqualSlices(u8, "aarch64-linux.3.10...4.4.1-android.30", text);
731 }731 }
732 {
733 const query = try Query.parse(.{
734 .arch_os_abi = "x86-windows.xp...win8-msvc",
735 });
736 const target = try std.zig.system.resolveTargetQuery(query);
737
738 try std.testing.expect(target.cpu.arch == .x86);
739 try std.testing.expect(target.os.tag == .windows);
740 try std.testing.expect(target.os.version_range.windows.min == .xp);
741 try std.testing.expect(target.os.version_range.windows.max == .win8);
742 try std.testing.expect(target.abi == .msvc);
743
744 const text = try query.zigTriple(std.testing.allocator);
745 defer std.testing.allocator.free(text);
746 try std.testing.expectEqualSlices(u8, "x86-windows.xp...win8-msvc", text);
747 }
732}748}