Link formatting workaround to issue

This commit is contained in:
Marc Tiehuis 2019-06-21 20:23:53 +12:00
parent 11526b6e9d
commit 948dc7b304

View File

@ -404,9 +404,11 @@ fn formatValue(
output: fn (@typeOf(context), []const u8) Errors!void,
) Errors!void {
if (comptime std.mem.eql(u8, fmt, "B")) {
// TODO https://github.com/ziglang/zig/issues/2725
if (options.width) |w| return formatBytes(value, w, 1000, context, Errors, output);
return formatBytes(value, null, 1000, context, Errors, output);
} else if (comptime std.mem.eql(u8, fmt, "Bi")) {
// TODO https://github.com/ziglang/zig/issues/2725
if (options.width) |w| return formatBytes(value, w, 1024, context, Errors, output);
return formatBytes(value, null, 1024, context, Errors, output);
}
@ -458,6 +460,7 @@ pub fn formatIntValue(
@compileError("Unknown format string: '" ++ fmt ++ "'");
}
// TODO https://github.com/ziglang/zig/issues/2725
if (options.width) |w| return formatInt(int_value, radix, uppercase, w, context, Errors, output);
return formatInt(int_value, radix, uppercase, 0, context, Errors, output);
}
@ -471,11 +474,13 @@ fn formatFloatValue(
output: fn (@typeOf(context), []const u8) Errors!void,
) Errors!void {
if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "e")) {
// TODO https://github.com/ziglang/zig/issues/2725
if (options.precision) |p| return formatFloatScientific(value, p, context, Errors, output);
return formatFloatScientific(value, null, context, Errors, output);
} else if (comptime std.mem.eql(u8, fmt, "d")) {
// TODO https://github.com/ziglang/zig/issues/2725
if (options.precision) |p| return formatFloatDecimal(value, p, context, Errors, output);
return formatFloatDecimal(value, options.precision, context, Errors, output);
return formatFloatDecimal(value, null, context, Errors, output);
} else {
@compileError("Unknown format string: '" ++ fmt ++ "'");
}