base: Handle zero fill in cprintf when printing floats.
authorGabe Black <gabeblack@google.com>
Tue, 5 Dec 2017 03:42:41 +0000 (19:42 -0800)
committerGabe Black <gabeblack@google.com>
Wed, 6 Dec 2017 01:14:31 +0000 (01:14 +0000)
The fill_zero flag was being followed for ints, but not for floats.
This makes the cprintf unit test pass.

Change-Id: I4d17a3c9327aea05e0a3c81be1886c0c9256f03c
Reviewed-on: https://gem5-review.googlesource.com/6322
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>

src/base/cprintf_formats.hh

index 5b3b344325c0be60f03199f764a091463c3a2aa3..253fe59cfca6198d35c16a88ad532ce11af309cc 100644 (file)
@@ -151,6 +151,9 @@ _format_float(std::ostream &out, const T &data, Format &fmt)
 
     ios::fmtflags flags(out.flags());
 
+    if (fmt.fill_zero)
+        out.fill('0');
+
     switch (fmt.float_format) {
       case Format::scientific:
         if (fmt.precision != -1) {