Skip to content

Commit fcb088c

Browse files
KNnutalexrp
authored andcommitted
std.Target.Query: fix WindowsVersion format in zigTriple()
1 parent 96be6f6 commit fcb088c

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/std/Target/Query.zig

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ pub fn zigTriple(self: Query, gpa: Allocator) Allocator.Error![]u8 {
423423
try formatVersion(v, gpa, &result);
424424
},
425425
.windows => |v| {
426-
try result.print(gpa, "{d}", .{v});
426+
try result.print(gpa, "{f}", .{v});
427427
},
428428
}
429429
}
@@ -437,7 +437,7 @@ pub fn zigTriple(self: Query, gpa: Allocator) Allocator.Error![]u8 {
437437
.windows => |v| {
438438
// This is counting on a custom format() function defined on `WindowsVersion`
439439
// 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});
441441
},
442442
}
443443
}
@@ -729,4 +729,20 @@ test parse {
729729
defer std.testing.allocator.free(text);
730730
try std.testing.expectEqualSlices(u8, "aarch64-linux.3.10...4.4.1-android.30", text);
731731
}
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+
}
732748
}

0 commit comments

Comments
 (0)