diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-12-21 05:38:34 -0800 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-12-21 05:42:03 -0800 |
commit | 119d7478d1a7d59a0fa5a02690b2555ac2c3ed89 (patch) | |
tree | 4dd701c67a7ed48d5c00f61249084d06e5e58b37 /libcody | |
parent | 31705b068fa5d6cbd04aa4ac5f5275bad37d2222 (diff) | |
download | gcc-119d7478d1a7d59a0fa5a02690b2555ac2c3ed89.tar.gz |
libcody: to_string is not always available [PR 98412]
to_string is not always available, so don't use it.
libcody/
* buffer.cc (MessageBuffer::AppendInteger): Workaround
to_string's non-ubiquity.
Diffstat (limited to 'libcody')
-rw-r--r-- | libcody/buffer.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libcody/buffer.cc b/libcody/buffer.cc index 3256c37399b..85c066fef71 100644 --- a/libcody/buffer.cc +++ b/libcody/buffer.cc @@ -146,7 +146,13 @@ void MessageBuffer::Append (char c) void MessageBuffer::AppendInteger (unsigned u) { - std::string v (std::to_string (u)); + // Sigh, even though std::to_string is C++11, we support building on + // gcc 4.8, which is a C++11 compiler lacking std::to_string. so + // have something horrible. + std::string v (20, 0); + size_t len = snprintf (const_cast<char *> (v.data ()), v.size (), "%u", u); + v.erase (len); + AppendWord (v); } |