summaryrefslogtreecommitdiff
path: root/src/base/cprintf.cc
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2008-12-03 04:57:54 -0800
committerNathan Binkert <nate@binkert.org>2008-12-03 04:57:54 -0800
commit74f10be5266039fc9d2c1be14c551d1bcefed99c (patch)
tree99bfdb9d3ff33d397f7dc935a97dd5b5968cc06b /src/base/cprintf.cc
parent47e2b0889359877cb9a86c02c4bdf862fbd87338 (diff)
downloadgem5-74f10be5266039fc9d2c1be14c551d1bcefed99c.tar.xz
cprintf: support a configurable width and precision ("*" in printf)
Diffstat (limited to 'src/base/cprintf.cc')
-rw-r--r--src/base/cprintf.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/base/cprintf.cc b/src/base/cprintf.cc
index d4ba9ca21..5c11e501c 100644
--- a/src/base/cprintf.cc
+++ b/src/base/cprintf.cc
@@ -40,7 +40,7 @@ using namespace std;
namespace cp {
Print::Print(std::ostream &stream, const std::string &format)
- : stream(stream), format(format.c_str()), ptr(format.c_str())
+ : stream(stream), format(format.c_str()), ptr(format.c_str()), cont(false)
{
saved_flags = stream.flags();
saved_fill = stream.fill();
@@ -48,7 +48,7 @@ Print::Print(std::ostream &stream, const std::string &format)
}
Print::Print(std::ostream &stream, const char *format)
- : stream(stream), format(format), ptr(format)
+ : stream(stream), format(format), ptr(format), cont(false)
{
saved_flags = stream.flags();
saved_fill = stream.fill();
@@ -60,8 +60,10 @@ Print::~Print()
}
void
-Print::process(Format &fmt)
+Print::process()
{
+ fmt.clear();
+
size_t len;
while (*ptr) {
@@ -221,8 +223,15 @@ Print::process(Format &fmt)
number = number * 10 + (*ptr - '0');
break;
+ case '*':
+ if (have_precision)
+ fmt.get_precision = true;
+ else
+ fmt.get_width = true;
+ break;
+
case '%':
- assert("we shouldn't get here");
+ assert(false && "we shouldn't get here");
break;
default: