Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update fmtlib to 10.1.1+ds1-2 #6

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.vscode/
.vs/

*.iml
.idea/
.externalNativeBuild/
.gradle/
gradle/
gradlew*
local.properties
build/
support/.cxx

bin/
/_CPack_Packages
/CMakeScripts
/doc/doxyxml
/doc/html
/doc/node_modules
virtualenv
/Testing
/install_manifest.txt
*~
*.a
*.so*
*.xcodeproj
*.zip
cmake_install.cmake
CPack*.cmake
fmt-*.cmake
CTestTestfile.cmake
CMakeCache.txt
CMakeFiles
FMT.build
Makefile
run-msbuild.bat
fmt.pc
50 changes: 50 additions & 0 deletions ChangeLog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
10.1.1 - 2023-08-26
-------------------

* Added formatters for ``std::atomic`` and ``atomic_flag``
(`#3574 <https://github.com/fmtlib/fmt/pull/3574>`_,
`#3594 <https://github.com/fmtlib/fmt/pull/3594>`_).
Thanks `@wangzw (Zhanwei Wang) <https://github.com/wangzw>`_ and
`@AlexGuteniev (Alex Guteniev) <https://github.com/AlexGuteniev>`_.

* Fixed an error about partial specialization of ``formatter<string>``
after instantiation when compiled with gcc and C++20
(`#3584 <https://github.com/fmtlib/fmt/issues/3584>`_).

* Fixed compilation as a C++20 module with gcc and clang
(`#3587 <https://github.com/fmtlib/fmt/issues/3587>`_,
`#3597 <https://github.com/fmtlib/fmt/pull/3597>`_,
`#3605 <https://github.com/fmtlib/fmt/pull/3605>`_). Thanks
`@MathewBensonCode (Mathew Benson) <https://github.com/MathewBensonCode>`_.

* Made ``fmt::to_string`` work with types that have ``format_as`` overloads
(`#3575 <https://github.com/fmtlib/fmt/pull/3575>`_).
Thanks `@phprus (Vladislav Shchapov) <https://github.com/phprus>`_.

* Made ``formatted_size`` work with integral format specifiers at compile time
(`#3591 <https://github.com/fmtlib/fmt/pull/3591>`_).
Thanks `@elbeno (Ben Deane) <https://github.com/elbeno>`_.

* Fixed a warning about the ``no_unique_address`` attribute on clang-cl
(`#3599 <https://github.com/fmtlib/fmt/pull/3599>`_).
Thanks `@lukester1975 <https://github.com/lukester1975>`_.

* Improved compatibility with the legacy GBK encoding
(`#3598 <https://github.com/fmtlib/fmt/issues/3598>`_,
`#3599 <https://github.com/fmtlib/fmt/pull/3599>`_).
Thanks `@YuHuanTin <https://github.com/YuHuanTin>`_.

* Added OpenSSF Scorecard analysis
(`#3530 <https://github.com/fmtlib/fmt/issues/3530>`_,
`#3571 <https://github.com/fmtlib/fmt/pull/3571>`_).
Thanks `@joycebrum (Joyce) <https://github.com/joycebrum>`_.

* Updated CI dependencies
(`#3591 <https://github.com/fmtlib/fmt/pull/3591>`_,
`#3592 <https://github.com/fmtlib/fmt/pull/3592>`_,
`#3593 <https://github.com/fmtlib/fmt/pull/3593>`_,
`#3602 <https://github.com/fmtlib/fmt/pull/3602>`_).

10.1.0 - 2023-08-12
-------------------

Expand Down Expand Up @@ -103,6 +150,9 @@
Thanks `@gix (Nico Rieck) <https://github.com/gix>`_,
`@hmbj (Hans-Martin B. Jensen) <https://github.com/hmbj>`_.

* Added support for the ``?`` format specifier to ``std::filesystem::path`` and
made the default unescaped for consistency with strings.

* Deprecated the wide stream overload of ``printf``.

* Removed unused ``basic_printf_parse_context``.
Expand Down
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
:alt: Ask questions at StackOverflow with the tag fmt
:target: https://stackoverflow.com/questions/tagged/fmt

.. image:: https://api.securityscorecards.dev/projects/github.com/fmtlib/fmt/badge
:target: https://securityscorecards.dev/viewer/?uri=github.com/fmtlib/fmt

**{fmt}** is an open-source formatting library providing a fast and safe
alternative to C stdio and C++ iostreams.

Expand Down
12 changes: 12 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
fmtlib (10.1.1+ds1-2) experimental; urgency=medium

* Fix build with Sphinx 7 (Closes: #1042588)

-- Shengjing Zhu <[email protected]> Wed, 22 Nov 2023 04:18:37 +0800

fmtlib (10.1.1+ds1-1) experimental; urgency=medium

* New upstream version 10.1.1+ds1

-- Shengjing Zhu <[email protected]> Fri, 08 Sep 2023 14:47:55 +0800

fmtlib (10.1.0+ds1-1) experimental; urgency=medium

* New upstream version 10.1.0+ds1
Expand Down
11 changes: 7 additions & 4 deletions debian/patches/0002-Privacy-README.rst.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ Subject: Privacy: README.rst

Forwarded: not-needed
---
README.rst | 24 ------------------------
1 file changed, 24 deletions(-)
README.rst | 27 ---------------------------
1 file changed, 27 deletions(-)

diff --git a/README.rst b/README.rst
index 6a639b6..e89f81f 100644
index 44bb686..3f04146 100644
--- a/README.rst
+++ b/README.rst
@@ -1,27 +1,3 @@
@@ -1,30 +1,3 @@
-.. image:: https://user-images.githubusercontent.com/
- 576385/156254208-f5b743a9-88cf-439d-b0c0-923d53e8d551.png
- :width: 25%
Expand All @@ -35,6 +35,9 @@ index 6a639b6..e89f81f 100644
-.. image:: https://img.shields.io/badge/stackoverflow-fmt-blue.svg
- :alt: Ask questions at StackOverflow with the tag fmt
- :target: https://stackoverflow.com/questions/tagged/fmt
-
-.. image:: https://api.securityscorecards.dev/projects/github.com/fmtlib/fmt/badge
- :target: https://securityscorecards.dev/viewer/?uri=github.com/fmtlib/fmt
-
**{fmt}** is an open-source formatting library providing a fast and safe
alternative to C stdio and C++ iostreams.
Expand Down
29 changes: 29 additions & 0 deletions debian/patches/0006-Doc-build-with-Sphinx-7.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From: Shengjing Zhu <[email protected]>
Date: Wed, 22 Nov 2023 04:17:40 +0800
Subject: Doc: build with Sphinx 7

---
doc/basic-bootstrap/layout.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/basic-bootstrap/layout.html b/doc/basic-bootstrap/layout.html
index 5519c4b..a6e7914 100644
--- a/doc/basic-bootstrap/layout.html
+++ b/doc/basic-bootstrap/layout.html
@@ -102,14 +102,14 @@
{%- endmacro %}

{%- macro css() %}
- <link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
+ <link rel="stylesheet" href="{{ pathto('_static/' + styles[-1], 1) }}" type="text/css" />
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
{%- for cssfile in css_files %}
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
{%- endfor %}
{%- endmacro %}

-<html lang="en">
+<html lang="en" data-content_root="{{ content_root }}">
<head>
<meta charset="{{ encoding }}">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
0003-Privacy-GA-in-doc-layout.html.patch
0004-Doc-unwanted-download-links-in-doc-layout.html.patch
0005-Doc-unwanted-GitHub-iframe.patch
0006-Doc-build-with-Sphinx-7.patch
2 changes: 1 addition & 1 deletion doc/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import errno, os, re, sys
from subprocess import check_call, CalledProcessError, Popen, PIPE, STDOUT

versions = ['1.0.0', '1.1.0', '2.0.0', '3.0.2', '4.0.0', '4.1.0', '5.0.0', '5.1.0', '5.2.0', '5.2.1', '5.3.0', '6.0.0', '6.1.0', '6.1.1', '6.1.2', '6.2.0', '6.2.1', '7.0.0', '7.0.1', '7.0.2', '7.0.3', '7.1.0', '7.1.1', '7.1.2', '7.1.3', '8.0.0', '8.0.1', '8.1.0', '8.1.1', '9.0.0', '9.1.0', '10.0.0', '10.1.0']
versions = ['1.0.0', '1.1.0', '2.0.0', '3.0.2', '4.0.0', '4.1.0', '5.0.0', '5.1.0', '5.2.0', '5.2.1', '5.3.0', '6.0.0', '6.1.0', '6.1.1', '6.1.2', '6.2.0', '6.2.1', '7.0.0', '7.0.1', '7.0.2', '7.0.3', '7.1.0', '7.1.1', '7.1.2', '7.1.3', '8.0.0', '8.0.1', '8.1.0', '8.1.1', '9.0.0', '9.1.0', '10.0.0', '10.1.0', '10.1.1']

class Pip:
def __init__(self, venv_dir):
Expand Down
6 changes: 2 additions & 4 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1420,9 +1420,8 @@ template <typename Context> struct arg_mapper {
FMT_ENABLE_IF(
std::is_pointer<T>::value || std::is_member_pointer<T>::value ||
std::is_function<typename std::remove_pointer<T>::type>::value ||
(std::is_convertible<const T&, const void*>::value &&
!std::is_convertible<const T&, const char_type*>::value &&
!has_formatter<T, Context>::value))>
(std::is_array<T>::value &&
!std::is_convertible<T, const char_type*>::value))>
FMT_CONSTEXPR auto map(const T&) -> unformattable_pointer {
return {};
}
Expand Down Expand Up @@ -1662,7 +1661,6 @@ template <typename Context> class basic_format_arg {
\endrst
*/
// DEPRECATED!
FMT_EXPORT
template <typename Visitor, typename Context>
FMT_CONSTEXPR FMT_INLINE auto visit_format_arg(
Visitor&& vis, const basic_format_arg<Context>& arg) -> decltype(vis(0)) {
Expand Down
31 changes: 21 additions & 10 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
# if FMT_CPLUSPLUS >= 202002L
# if FMT_HAS_CPP_ATTRIBUTE(no_unique_address)
# define FMT_NO_UNIQUE_ADDRESS [[no_unique_address]]
# elif FMT_MSC_VERSION >= 1929 // VS2019 v16.10 and later
// VS2019 v16.10 and later except clang-cl (https://reviews.llvm.org/D110485)
# elif (FMT_MSC_VERSION >= 1929) && !FMT_CLANG_VERSION
# define FMT_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
# endif
# endif
Expand Down Expand Up @@ -368,8 +369,6 @@ class uint128_fallback {
private:
uint64_t lo_, hi_;

friend uint128_fallback umul128(uint64_t x, uint64_t y) noexcept;

public:
constexpr uint128_fallback(uint64_t hi, uint64_t lo) : lo_(lo), hi_(hi) {}
constexpr uint128_fallback(uint64_t value = 0) : lo_(value), hi_(0) {}
Expand Down Expand Up @@ -1038,6 +1037,7 @@ namespace detail {
FMT_API bool write_console(std::FILE* f, string_view text);
FMT_API void print(std::FILE*, string_view);
} // namespace detail

FMT_BEGIN_EXPORT

// Suppress a misleading warning in older versions of clang.
Expand Down Expand Up @@ -1387,8 +1387,8 @@ FMT_CONSTEXPR auto format_uint(Char* buffer, UInt value, int num_digits,
}

template <unsigned BASE_BITS, typename Char, typename It, typename UInt>
inline auto format_uint(It out, UInt value, int num_digits, bool upper = false)
-> It {
FMT_CONSTEXPR inline auto format_uint(It out, UInt value, int num_digits,
bool upper = false) -> It {
if (auto ptr = to_pointer<Char>(out, to_unsigned(num_digits))) {
format_uint<BASE_BITS>(ptr, value, num_digits, upper);
return out;
Expand Down Expand Up @@ -1453,7 +1453,7 @@ template <typename WChar, typename Buffer = memory_buffer> class to_utf8 {
++p;
if (p == s.end() || (c & 0xfc00) != 0xd800 || (*p & 0xfc00) != 0xdc00) {
if (policy == to_utf8_error_policy::abort) return false;
buf.append(string_view(""));
buf.append(string_view("\xEF\xBF\xBD"));
--p;
} else {
c = (c << 10) + static_cast<uint32_t>(*p) - 0x35fdc00;
Expand Down Expand Up @@ -1486,9 +1486,9 @@ inline uint128_fallback umul128(uint64_t x, uint64_t y) noexcept {
auto p = static_cast<uint128_opt>(x) * static_cast<uint128_opt>(y);
return {static_cast<uint64_t>(p >> 64), static_cast<uint64_t>(p)};
#elif defined(_MSC_VER) && defined(_M_X64)
auto result = uint128_fallback();
result.lo_ = _umul128(x, y, &result.hi_);
return result;
auto hi = uint64_t();
auto lo = _umul128(x, y, &hi);
return {hi, lo};
#else
const uint64_t mask = static_cast<uint64_t>(max_value<uint32_t>());

Expand Down Expand Up @@ -4287,7 +4287,8 @@ auto join(Range&& range, string_view sep)
std::string answer = fmt::to_string(42);
\endrst
*/
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value &&
!detail::has_format_as<T>::value)>
inline auto to_string(const T& value) -> std::string {
auto buffer = memory_buffer();
detail::write<char>(appender(buffer), value);
Expand All @@ -4312,6 +4313,14 @@ FMT_NODISCARD auto to_string(const basic_memory_buffer<Char, SIZE>& buf)
return std::basic_string<Char>(buf.data(), size);
}

template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value &&
detail::has_format_as<T>::value)>
inline auto to_string(const T& value) -> std::string {
return to_string(format_as(value));
}

FMT_END_EXPORT

namespace detail {

template <typename Char>
Expand Down Expand Up @@ -4383,6 +4392,8 @@ void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,
detail::parse_format_string<false>(fmt, format_handler(out, fmt, args, loc));
}

FMT_BEGIN_EXPORT

#ifndef FMT_HEADER_ONLY
extern template FMT_API void vformat_to(buffer<char>&, string_view,
typename vformat_args<>::type,
Expand Down
27 changes: 26 additions & 1 deletion include/fmt/std.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#ifndef FMT_STD_H_
#define FMT_STD_H_

#include <atomic>
#include <bitset>
#include <cstdlib>
#include <exception>
Expand Down Expand Up @@ -435,6 +436,30 @@ struct formatter<BitRef, Char,
}
};

FMT_END_NAMESPACE
FMT_EXPORT
template <typename T, typename Char>
struct formatter<std::atomic<T>, Char,
enable_if_t<is_formattable<T, Char>::value>>
: formatter<T, Char> {
template <typename FormatContext>
auto format(const std::atomic<T>& v, FormatContext& ctx) const
-> decltype(ctx.out()) {
return formatter<T, Char>::format(v.load(), ctx);
}
};

#ifdef __cpp_lib_atomic_flag_test
FMT_EXPORT
template <typename Char>
struct formatter<std::atomic_flag, Char>
: formatter<bool, Char> {
template <typename FormatContext>
auto format(const std::atomic_flag& v, FormatContext& ctx) const
-> decltype(ctx.out()) {
return formatter<bool, Char>::format(v.test(), ctx);
}
};
#endif // __cpp_lib_atomic_flag_test

FMT_END_NAMESPACE
#endif // FMT_STD_H_
15 changes: 15 additions & 0 deletions test/compile-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,21 @@ TEST(compile_test, format_to_n) {
TEST(compile_test, constexpr_formatted_size) {
FMT_CONSTEXPR20 size_t size = fmt::formatted_size(FMT_COMPILE("{}"), 42);
EXPECT_EQ(size, 2);
FMT_CONSTEXPR20 size_t hex_size =
fmt::formatted_size(FMT_COMPILE("{:x}"), 15);
EXPECT_EQ(hex_size, 1);
FMT_CONSTEXPR20 size_t binary_size =
fmt::formatted_size(FMT_COMPILE("{:b}"), 15);
EXPECT_EQ(binary_size, 4);
FMT_CONSTEXPR20 size_t padded_size =
fmt::formatted_size(FMT_COMPILE("{:*^6}"), 42);
EXPECT_EQ(padded_size, 6);
FMT_CONSTEXPR20 size_t float_size =
fmt::formatted_size(FMT_COMPILE("{:.3}"), 12.345);
EXPECT_EQ(float_size, 4);
FMT_CONSTEXPR20 size_t str_size =
fmt::formatted_size(FMT_COMPILE("{:s}"), "abc");
EXPECT_EQ(str_size, 3);
}
# endif

Expand Down
7 changes: 7 additions & 0 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,13 @@ TEST(format_test, format_as) {
EXPECT_EQ(fmt::format("{}", test::struct_as_int()), "42");
}

TEST(format_test, format_as_to_string) {
EXPECT_EQ(fmt::to_string(test::scoped_enum_as_int()), "42");
EXPECT_EQ(fmt::to_string(test::scoped_enum_as_string_view()), "foo");
EXPECT_EQ(fmt::to_string(test::scoped_enum_as_string()), "foo");
EXPECT_EQ(fmt::to_string(test::struct_as_int()), "42");
}

template <typename Char, typename T> bool check_enabled_formatter() {
static_assert(std::is_default_constructible<fmt::formatter<T, Char>>::value,
"");
Expand Down
Loading
Loading