diff --git a/lib/std/io/formatter.c3 b/lib/std/io/formatter.c3 index 31319decb..b737cabe2 100644 --- a/lib/std/io/formatter.c3 +++ b/lib/std/io/formatter.c3 @@ -238,8 +238,7 @@ fn usz! Formatter.out_str(&self, any arg) @private self.width = width; } self.width = 0; - self.out_substr("0x")!; - return self.ntoa_any(arg, 16); + return self.out_substr("0x")! + self.ntoa_any(arg, 16); case ARRAY: // this is SomeType[*] so grab the "SomeType" PrintFlags flags = self.flags; @@ -485,11 +484,14 @@ fn usz! Formatter.vprintf(&self, String format, any[] anys) total_len += self.pad(' ', self.width, len)!; continue; } - OutputFn out_fn = self.out_fn; - self.out_fn = (OutputFn)&out_null_fn; - usz len = self.out_str(current)!; - self.out_fn = out_fn; - total_len += self.pad(' ', self.width, len)!; + if (self.width) + { + OutputFn out_fn = self.out_fn; + self.out_fn = (OutputFn)&out_null_fn; + usz len = self.out_str(current)!; + self.out_fn = out_fn; + total_len += self.pad(' ', self.width, len)!; + } total_len += self.out_str(current)!; continue; case 'p': diff --git a/lib/std/io/formatter_private.c3 b/lib/std/io/formatter_private.c3 index f57c6c29e..7d78ef476 100644 --- a/lib/std/io/formatter_private.c3 +++ b/lib/std/io/formatter_private.c3 @@ -215,7 +215,6 @@ fn usz! Formatter.floatformat(&self, FloatFormatting formatting, double y) @priv if (!self.flags.left) len += self.pad(' ', self.width, 3 + pl)!; String s = self.flags.uppercase ? "INF" : "inf"; if (math::is_nan(y)) s = self.flags.uppercase ? "NAN" : "nan"; - len += s.len; if (pl) len += self.out(is_neg ? '-' : '+')!; len += self.out_chars(s)!; if (self.flags.left) len += self.pad(' ', self.width, 3 + pl)!;