spdlog-1.8.5-fmt8.patch 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. diff --git a/include/spdlog/common-inl.h b/include/spdlog/common-inl.h
  2. index 378efe60..3632ec94 100644
  3. --- a/include/spdlog/common-inl.h
  4. +++ b/include/spdlog/common-inl.h
  5. @@ -60,7 +60,7 @@ SPDLOG_INLINE spdlog_ex::spdlog_ex(std::string msg)
  6. SPDLOG_INLINE spdlog_ex::spdlog_ex(const std::string &msg, int last_errno)
  7. {
  8. memory_buf_t outbuf;
  9. - fmt::format_system_error(outbuf, last_errno, msg);
  10. + fmt::format_system_error(outbuf, last_errno, msg.c_str());
  11. msg_ = fmt::to_string(outbuf);
  12. }
  13. diff --git a/src/fmt.cpp b/src/fmt.cpp
  14. index 9e91beb1..edd52dd5 100644
  15. --- a/src/fmt.cpp
  16. +++ b/src/fmt.cpp
  17. @@ -10,94 +10,58 @@
  18. #include <spdlog/fmt/bundled/format-inl.h>
  19. +
  20. FMT_BEGIN_NAMESPACE
  21. namespace detail {
  22. -template <typename T>
  23. -int format_float(char* buf, std::size_t size, const char* format, int precision,
  24. - T value) {
  25. -#ifdef FMT_FUZZ
  26. - if (precision > 100000)
  27. - throw std::runtime_error(
  28. - "fuzz mode - avoid large allocation inside snprintf");
  29. -#endif
  30. - // Suppress the warning about nonliteral format string.
  31. - int (*snprintf_ptr)(char*, size_t, const char*, ...) = FMT_SNPRINTF;
  32. - return precision < 0 ? snprintf_ptr(buf, size, format, value)
  33. - : snprintf_ptr(buf, size, format, precision, value);
  34. +template<typename T>
  35. +int format_float(char *buf, std::size_t size, const char *format, int precision, T value)
  36. +{
  37. +# ifdef FMT_FUZZ
  38. + if (precision > 100000)
  39. + throw std::runtime_error("fuzz mode - avoid large allocation inside snprintf");
  40. +# endif
  41. + // Suppress the warning about nonliteral format string.
  42. + int (*snprintf_ptr)(char *, size_t, const char *, ...) = FMT_SNPRINTF;
  43. + return precision < 0 ? snprintf_ptr(buf, size, format, value) : snprintf_ptr(buf, size, format, precision, value);
  44. }
  45. -template FMT_API dragonbox::decimal_fp<float> dragonbox::to_decimal(float x)
  46. - FMT_NOEXCEPT;
  47. -template FMT_API dragonbox::decimal_fp<double> dragonbox::to_decimal(double x)
  48. - FMT_NOEXCEPT;
  49. -
  50. -// DEPRECATED! This function exists for ABI compatibility.
  51. -template <typename Char>
  52. -typename basic_format_context<std::back_insert_iterator<buffer<Char>>,
  53. - Char>::iterator
  54. -vformat_to(buffer<Char>& buf, basic_string_view<Char> format_str,
  55. - basic_format_args<basic_format_context<
  56. - std::back_insert_iterator<buffer<type_identity_t<Char>>>,
  57. - type_identity_t<Char>>>
  58. - args) {
  59. - using iterator = std::back_insert_iterator<buffer<char>>;
  60. - using context = basic_format_context<
  61. - std::back_insert_iterator<buffer<type_identity_t<Char>>>,
  62. - type_identity_t<Char>>;
  63. - auto out = iterator(buf);
  64. - format_handler<iterator, Char, context> h(out, format_str, args, {});
  65. - parse_format_string<false>(format_str, h);
  66. - return out;
  67. -}
  68. -template basic_format_context<std::back_insert_iterator<buffer<char>>,
  69. - char>::iterator
  70. -vformat_to(buffer<char>&, string_view,
  71. - basic_format_args<basic_format_context<
  72. - std::back_insert_iterator<buffer<type_identity_t<char>>>,
  73. - type_identity_t<char>>>);
  74. -} // namespace detail
  75. -
  76. -template struct FMT_INSTANTIATION_DEF_API detail::basic_data<void>;
  77. +template FMT_API dragonbox::decimal_fp<float> dragonbox::to_decimal(float x) FMT_NOEXCEPT;
  78. +template FMT_API dragonbox::decimal_fp<double> dragonbox::to_decimal(double x) FMT_NOEXCEPT;
  79. +} // namespace detail
  80. // Workaround a bug in MSVC2013 that prevents instantiation of format_float.
  81. -int (*instantiate_format_float)(double, int, detail::float_specs,
  82. - detail::buffer<char>&) = detail::format_float;
  83. +int (*instantiate_format_float)(double, int, detail::float_specs, detail::buffer<char> &) = detail::format_float;
  84. -#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
  85. -template FMT_API detail::locale_ref::locale_ref(const std::locale& loc);
  86. +# ifndef FMT_STATIC_THOUSANDS_SEPARATOR
  87. +template FMT_API detail::locale_ref::locale_ref(const std::locale &loc);
  88. template FMT_API std::locale detail::locale_ref::get<std::locale>() const;
  89. -#endif
  90. +# endif
  91. // Explicit instantiations for char.
  92. -template FMT_API std::string detail::grouping_impl<char>(locale_ref);
  93. -template FMT_API char detail::thousands_sep_impl(locale_ref);
  94. +template FMT_API auto detail::thousands_sep_impl(locale_ref) -> thousands_sep_result<char>;
  95. template FMT_API char detail::decimal_point_impl(locale_ref);
  96. -template FMT_API void detail::buffer<char>::append(const char*, const char*);
  97. +template FMT_API void detail::buffer<char>::append(const char *, const char *);
  98. template FMT_API void detail::vformat_to(
  99. - detail::buffer<char>&, string_view,
  100. - basic_format_args<FMT_BUFFER_CONTEXT(char)>, detail::locale_ref);
  101. -
  102. -template FMT_API int detail::snprintf_float(double, int, detail::float_specs,
  103. - detail::buffer<char>&);
  104. -template FMT_API int detail::snprintf_float(long double, int,
  105. - detail::float_specs,
  106. - detail::buffer<char>&);
  107. -template FMT_API int detail::format_float(double, int, detail::float_specs,
  108. - detail::buffer<char>&);
  109. -template FMT_API int detail::format_float(long double, int, detail::float_specs,
  110. - detail::buffer<char>&);
  111. + detail::buffer<char> &, string_view, basic_format_args<FMT_BUFFER_CONTEXT(char)>, detail::locale_ref);
  112. +
  113. +template FMT_API int detail::snprintf_float(double, int, detail::float_specs, detail::buffer<char> &);
  114. +template FMT_API int detail::snprintf_float(long double, int, detail::float_specs, detail::buffer<char> &);
  115. +template FMT_API int detail::format_float(double, int, detail::float_specs, detail::buffer<char> &);
  116. +template FMT_API int detail::format_float(long double, int, detail::float_specs, detail::buffer<char> &);
  117. // Explicit instantiations for wchar_t.
  118. -template FMT_API std::string detail::grouping_impl<wchar_t>(locale_ref);
  119. -template FMT_API wchar_t detail::thousands_sep_impl(locale_ref);
  120. +template FMT_API auto detail::thousands_sep_impl(locale_ref) -> thousands_sep_result<wchar_t>;
  121. template FMT_API wchar_t detail::decimal_point_impl(locale_ref);
  122. -template FMT_API void detail::buffer<wchar_t>::append(const wchar_t*,
  123. - const wchar_t*);
  124. +template FMT_API void detail::buffer<wchar_t>::append(const wchar_t *, const wchar_t *);
  125. +
  126. +template struct detail::basic_data<void>;
  127. +
  128. FMT_END_NAMESPACE
  129. +
  130. #endif // !SPDLOG_FMT_EXTERNAL