diff options
Diffstat (limited to 'src/lib/netlist/plib/pfmtlog.cpp')
-rw-r--r-- | src/lib/netlist/plib/pfmtlog.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/lib/netlist/plib/pfmtlog.cpp b/src/lib/netlist/plib/pfmtlog.cpp index 44801e2d96b..8f6836fee0c 100644 --- a/src/lib/netlist/plib/pfmtlog.cpp +++ b/src/lib/netlist/plib/pfmtlog.cpp @@ -7,8 +7,8 @@ #include "pfmtlog.h" #include "palloc.h" -#include "pstrutil.h" #include "pstonum.h" +#include "pstrutil.h" #include <algorithm> #include <array> @@ -48,6 +48,7 @@ pfmt::rtype pfmt::setfmt(std::stringstream &strm, char32_t cfmt_spec) pstring fmt; pstring search("{"); search += plib::to_string(m_arg); + rtype r; r.sl = search.size(); @@ -93,17 +94,19 @@ pfmt::rtype pfmt::setfmt(std::stringstream &strm, char32_t cfmt_spec) if (r.p != pstring::npos) { // a.b format here ... + char32_t pend(0); + int width(0); if (fmt != "" && pstring("duxofge").find(static_cast<pstring::value_type>(cfmt_spec)) != pstring::npos) { - r.pend = static_cast<char32_t>(fmt.at(fmt.size() - 1)); - if (pstring("duxofge").find(static_cast<pstring::value_type>(r.pend)) == pstring::npos) - r.pend = cfmt_spec; + pend = static_cast<char32_t>(fmt.at(fmt.size() - 1)); + if (pstring("duxofge").find(static_cast<pstring::value_type>(pend)) == pstring::npos) + pend = cfmt_spec; else fmt = plib::left(fmt, fmt.size() - 1); } else // FIXME: Error - r.pend = cfmt_spec; + pend = cfmt_spec; auto pdot(fmt.find('.')); @@ -112,12 +115,18 @@ pfmt::rtype pfmt::setfmt(std::stringstream &strm, char32_t cfmt_spec) else if (pdot != pstring::npos) { strm << std::setprecision(pstonum_ne_def<int>(fmt.substr(pdot + 1), 6)); - r.width = pstonum_ne_def<int>(left(fmt,pdot), 0); + width = pstonum_ne_def<int>(left(fmt,pdot), 0); } else if (fmt != "") - r.width = pstonum_ne_def<int>(fmt, 0); + width = pstonum_ne_def<int>(fmt, 0); + + auto aw(plib::abs(width)); + + strm << std::setw(aw); + if (width < 0) + strm << std::left; - switch (r.pend) + switch (pend) { case 'x': strm << std::hex; |