From 19cb3916249eba729aace599fe092d7072816572 Mon Sep 17 00:00:00 2001 From: mutouyun Date: Sat, 27 May 2023 16:40:43 +0800 Subject: [PATCH] fix: [imp] fmt issue --- include/libimp/log.h | 6 ------ src/libimp/fmt.cpp | 10 ++++++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/include/libimp/log.h b/include/libimp/log.h index 33c38d2..05fe998 100644 --- a/include/libimp/log.h +++ b/include/libimp/log.h @@ -131,12 +131,6 @@ public: } }; -/// \brief Custom defined fmt_to method for imp::fmt -template -bool tag_invoke(decltype(::LIBIMP::fmt_to), fmt_context &f_ctx, context const &l_ctx) noexcept { - return ::LIBIMP::log::context_to_string(f_ctx, l_ctx); -} - } // namespace detail class printer { diff --git a/src/libimp/fmt.cpp b/src/libimp/fmt.cpp index 2fc2895..94bb284 100644 --- a/src/libimp/fmt.cpp +++ b/src/libimp/fmt.cpp @@ -197,12 +197,14 @@ void fmt_context::expend(std::size_t sz) noexcept { } bool fmt_context::append(span const &str) noexcept { - auto sbuf = buffer(str.size()); - if (sbuf.size() < str.size()) { + auto sz = str.size(); + if (str.back() == '\0') --sz; + auto sbuf = buffer(sz); + if (sbuf.size() < sz) { return false; } - std::memcpy(sbuf.data(), str.data(), str.size()); - offset_ += str.size(); + std::memcpy(sbuf.data(), str.data(), sz); + offset_ += sz; return true; }