From 7525731b50b05008d26a13e4e55e7f3244a13fe1 Mon Sep 17 00:00:00 2001 From: Vitaly Zaitsev Date: Wed, 28 Jun 2023 09:54:31 +0200 Subject: [PATCH] Added fixes for the tests. --- spdlog-fmt10-tests-fixes.patch | 86 ++++++++++++++++++++++++++++++++++ spdlog.spec | 2 + 2 files changed, 88 insertions(+) create mode 100644 spdlog-fmt10-tests-fixes.patch diff --git a/spdlog-fmt10-tests-fixes.patch b/spdlog-fmt10-tests-fixes.patch new file mode 100644 index 0000000..e0e6a75 --- /dev/null +++ b/spdlog-fmt10-tests-fixes.patch @@ -0,0 +1,86 @@ +From af1785b897c9d1098d4aa7213fad232be63c19b4 Mon Sep 17 00:00:00 2001 +From: Bernd Ritter +Date: Fri, 19 May 2023 18:51:02 +0200 +Subject: [PATCH] Removes special format handling for fmt. (#2736) + +* Removes special format handling for fmt. Regains test compatibility with fmt +1.10.0. + +fixes #2735 + +* reverted std::vector back to filename_t and used pointer to array start likewise as fmt's implementation uses + +* calc_filename buffer increase softened, exception is throw if buffer exceeds 4k, filename parameter renamed to match intend. + +* calc_filetime based on std::put_time for simpler implementation +--- + include/spdlog/sinks/daily_file_sink.h | 46 +++++--------------------- + 1 file changed, 9 insertions(+), 37 deletions(-) + +diff --git a/include/spdlog/sinks/daily_file_sink.h b/include/spdlog/sinks/daily_file_sink.h +index f6f1bb1d7..90af96768 100644 +--- a/include/spdlog/sinks/daily_file_sink.h ++++ b/include/spdlog/sinks/daily_file_sink.h +@@ -13,6 +13,9 @@ + #include + #include + ++#include ++#include ++#include + #include + #include + #include +@@ -46,46 +49,15 @@ struct daily_filename_calculator + */ + struct daily_filename_format_calculator + { +- static filename_t calc_filename(const filename_t &filename, const tm &now_tm) ++ static filename_t calc_filename(const filename_t &file_path, const tm &now_tm) + { +-#ifdef SPDLOG_USE_STD_FORMAT +- // adapted from fmtlib: https://github.com/fmtlib/fmt/blob/8.0.1/include/fmt/chrono.h#L522-L546 +- +- filename_t tm_format; +- tm_format.append(filename); +- // By appending an extra space we can distinguish an empty result that +- // indicates insufficient buffer size from a guaranteed non-empty result +- // https://github.com/fmtlib/fmt/issues/2238 +- tm_format.push_back(' '); +- +- const size_t MIN_SIZE = 10; +- filename_t buf; +- buf.resize(MIN_SIZE); +- for (;;) +- { +- size_t count = strftime(buf.data(), buf.size(), tm_format.c_str(), &now_tm); +- if (count != 0) +- { +- // Remove the extra space. +- buf.resize(count - 1); +- break; +- } +- buf.resize(buf.size() * 2); +- } +- +- return buf; ++#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES) ++ std::wstringstream stream; + #else +- // generate fmt datetime format string, e.g. {:%Y-%m-%d}. +- filename_t fmt_filename = fmt::format(SPDLOG_FMT_STRING(SPDLOG_FILENAME_T("{{:{}}}")), filename); +- +- // MSVC doesn't allow fmt::runtime(..) with wchar, with fmtlib versions < 9.1.x +-# if defined(_MSC_VER) && defined(SPDLOG_WCHAR_FILENAMES) && FMT_VERSION < 90101 +- return fmt::format(fmt_filename, now_tm); +-# else +- return fmt::format(SPDLOG_FMT_RUNTIME(fmt_filename), now_tm); +-# endif +- ++ std::stringstream stream; + #endif ++ stream << std::put_time(&now_tm, file_path.c_str()); ++ return stream.str(); + } + + private: diff --git a/spdlog.spec b/spdlog.spec index 12704b7..32b8881 100644 --- a/spdlog.spec +++ b/spdlog.spec @@ -11,6 +11,8 @@ Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz Patch100: spdlog-catchv3-compatibility.patch # https://github.com/gabime/spdlog/pull/2694 Patch101: spdlog-fmt10-compatibility.patch +# https://github.com/gabime/spdlog/pull/2736 +Patch102: spdlog-fmt10-tests-fixes.patch BuildRequires: catch-devel >= 3.0.0 BuildRequires: cmake