Skip to content

Commit

Permalink
Merge bitcoin#11573: [Util] Update tinyformat.h
Browse files Browse the repository at this point in the history
60b98f8 [Util] Update tinyformat.h (fanquake)

Pull request description:

  Updates `tinyformat.h` to commit c42f/tinyformat@689695c upstream. Including:
  c42f/tinyformat@8a2812d
  c42f/tinyformat@5d9e05a
  c42f/tinyformat@48e2e48

  @achow101 mentioned that since upgrading to Ubuntu 17.10 (GCC 7), tinyformat had been throwing lots of -Wimplicit-fallthrough warnings. However fallthrough warnings should have been silenced by bitcoin#10489. cc @theuni.

  The upstream commit to fix fallthrough warnings is in this PR c42f/tinyformat#39.

  The last time tinyformat.h was updated in this repo was in bitcoin#8274.

Tree-SHA512: a51bd30544693550e08148daf5d244e3a3a410caff7897351eb9cd28f661dc85e193e045bb86068ee4006b2f89a7233b7573b8c50d93d2a9a15a11386fdcc605
  • Loading branch information
laanwj authored and PastaPastaPasta committed Jan 12, 2020
1 parent fea865b commit 50c6dc4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/tinyformat.h
Expand Up @@ -495,7 +495,11 @@ namespace detail {
class FormatArg
{
public:
FormatArg() {}
FormatArg()
: m_value(nullptr),
m_formatImpl(nullptr),
m_toIntImpl(nullptr)
{ }

template<typename T>
explicit FormatArg(const T& value)
Expand All @@ -507,11 +511,15 @@ class FormatArg
void format(std::ostream& out, const char* fmtBegin,
const char* fmtEnd, int ntrunc) const
{
assert(m_value);
assert(m_formatImpl);
m_formatImpl(out, fmtBegin, fmtEnd, ntrunc, m_value);
}

int toInt() const
{
assert(m_value);
assert(m_toIntImpl);
return m_toIntImpl(m_value);
}

Expand Down Expand Up @@ -712,23 +720,27 @@ inline const char* streamStateFromFormat(std::ostream& out, bool& spacePadPositi
break;
case 'X':
out.setf(std::ios::uppercase);
// Falls through
case 'x': case 'p':
out.setf(std::ios::hex, std::ios::basefield);
intConversion = true;
break;
case 'E':
out.setf(std::ios::uppercase);
// Falls through
case 'e':
out.setf(std::ios::scientific, std::ios::floatfield);
out.setf(std::ios::dec, std::ios::basefield);
break;
case 'F':
out.setf(std::ios::uppercase);
// Falls through
case 'f':
out.setf(std::ios::fixed, std::ios::floatfield);
break;
case 'G':
out.setf(std::ios::uppercase);
// Falls through
case 'g':
out.setf(std::ios::dec, std::ios::basefield);
// As in boost::format, let stream decide float format.
Expand Down

0 comments on commit 50c6dc4

Please sign in to comment.