fix: [imp] fmt issue

This commit is contained in:
mutouyun 2023-05-27 16:40:43 +08:00
parent 1014baf821
commit 19cb391624
2 changed files with 6 additions and 10 deletions

View File

@ -131,12 +131,6 @@ public:
} }
}; };
/// \brief Custom defined fmt_to method for imp::fmt
template <typename... T>
bool tag_invoke(decltype(::LIBIMP::fmt_to), fmt_context &f_ctx, context<T...> const &l_ctx) noexcept {
return ::LIBIMP::log::context_to_string(f_ctx, l_ctx);
}
} // namespace detail } // namespace detail
class printer { class printer {

View File

@ -197,12 +197,14 @@ void fmt_context::expend(std::size_t sz) noexcept {
} }
bool fmt_context::append(span<char const> const &str) noexcept { bool fmt_context::append(span<char const> const &str) noexcept {
auto sbuf = buffer(str.size()); auto sz = str.size();
if (sbuf.size() < str.size()) { if (str.back() == '\0') --sz;
auto sbuf = buffer(sz);
if (sbuf.size() < sz) {
return false; return false;
} }
std::memcpy(sbuf.data(), str.data(), str.size()); std::memcpy(sbuf.data(), str.data(), sz);
offset_ += str.size(); offset_ += sz;
return true; return true;
} }