- Add 0001-Fix-large-shift-in-uint128_fallback.patch

0002-Use-FMT_USE_FLOAT128-instead-of-__SIZEOF_FLOAT128__.patch
  0001-Make-sure-the-correct-fmod-overload-is-called.patch

OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/fmt?expand=0&rev=47
This commit is contained in:
Jan Engelhardt 2022-07-13 22:13:51 +00:00 committed by Git OBS Bridge
parent cf0c1df311
commit 422272881a
5 changed files with 117 additions and 0 deletions

View File

@ -0,0 +1,52 @@
From 2a1b3ac629bfec51ce70d3c0ebaf28e706754e19 Mon Sep 17 00:00:00 2001
From: Victor Zverovich <viz@fb.com>
Date: Sun, 10 Jul 2022 08:14:18 -0700
Subject: [PATCH 1/2] Fix large shift in uint128_fallback
---
include/fmt/format.h | 2 ++
test/format-test.cc | 4 +++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/fmt/format.h b/include/fmt/format.h
index 0bd2fdb1..6516975e 100644
--- a/include/fmt/format.h
+++ b/include/fmt/format.h
@@ -366,10 +366,12 @@ class uint128_fallback {
}
FMT_CONSTEXPR auto operator>>(int shift) const -> uint128_fallback {
if (shift == 64) return {0, hi_};
+ if (shift > 64) return uint128_fallback(0, hi_) >> (shift - 64);
return {hi_ >> shift, (hi_ << (64 - shift)) | (lo_ >> shift)};
}
FMT_CONSTEXPR auto operator<<(int shift) const -> uint128_fallback {
if (shift == 64) return {lo_, 0};
+ if (shift > 64) return uint128_fallback(lo_, 0) << (shift - 64);
return {hi_ << shift | (lo_ >> (64 - shift)), (lo_ << shift)};
}
FMT_CONSTEXPR auto operator>>=(int shift) -> uint128_fallback& {
diff --git a/test/format-test.cc b/test/format-test.cc
index 45a92624..8c1c305f 100644
--- a/test/format-test.cc
+++ b/test/format-test.cc
@@ -59,6 +59,8 @@ TEST(uint128_test, shift) {
EXPECT_EQ(static_cast<uint64_t>(n), 0x8000000000000000);
n = n >> 62;
EXPECT_EQ(static_cast<uint64_t>(n), 42);
+ EXPECT_EQ(uint128_fallback(1) << 112, uint128_fallback(0x1000000000000, 0));
+ EXPECT_EQ(uint128_fallback(0x1000000000000, 0) >> 112, uint128_fallback(1));
}
TEST(uint128_test, minus) {
@@ -234,7 +236,7 @@ TEST(util_test, format_system_error) {
throws_on_alloc = true;
}
if (!throws_on_alloc) {
- fmt::print("warning: std::allocator allocates {} chars", max_size);
+ fmt::print("warning: std::allocator allocates {} chars\n", max_size);
return;
}
}
--
2.36.1

View File

@ -0,0 +1,25 @@
From d82e1a108d3b3e3e7b8b019b47df9c4ed127723b Mon Sep 17 00:00:00 2001
From: Victor Zverovich <viz@fb.com>
Date: Wed, 13 Jul 2022 12:33:57 -0700
Subject: [PATCH] Make sure the correct fmod overload is called
---
include/fmt/chrono.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h
index 9b2aa74d..4a2c3a3d 100644
--- a/include/fmt/chrono.h
+++ b/include/fmt/chrono.h
@@ -1777,7 +1777,7 @@ struct chrono_formatter {
format_to(std::back_inserter(buf), runtime("{:.{}f}"),
std::fmod(val * static_cast<rep>(Period::num) /
static_cast<rep>(Period::den),
- 60),
+ static_cast<rep>(60)),
num_fractional_digits);
if (negative) *out++ = '-';
if (buf.size() < 2 || buf[1] == '.') *out++ = '0';
--
2.36.1

View File

@ -0,0 +1,34 @@
From 05be7a0764f8fbfbdf9c9750ec54d49fe3d2419f Mon Sep 17 00:00:00 2001
From: Victor Zverovich <viz@fb.com>
Date: Sun, 10 Jul 2022 08:47:16 -0700
Subject: [PATCH 2/2] Use FMT_USE_FLOAT128 instead of __SIZEOF_FLOAT128__
---
test/format-test.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/format-test.cc b/test/format-test.cc
index 8c1c305f..4ec7c838 100644
--- a/test/format-test.cc
+++ b/test/format-test.cc
@@ -101,7 +101,7 @@ template <typename Float> void check_isfinite() {
TEST(float_test, isfinite) {
check_isfinite<double>();
-#ifdef __SIZEOF_FLOAT128__
+#if FMT_USE_FLOAT128
check_isfinite<fmt::detail::float128>();
#endif
}
@@ -122,7 +122,7 @@ template <typename Float> void check_isnan() {
TEST(float_test, isnan) {
check_isnan<double>();
-#ifdef __SIZEOF_FLOAT128__
+#if FMT_USE_FLOAT128
check_isnan<fmt::detail::float128>();
#endif
}
--
2.36.1

View File

@ -21,6 +21,9 @@ Tue Jul 5 14:16:23 UTC 2022 - Jan Engelhardt <jengelh@inai.de>
* Added experimental std::filesystem::path formatting support.
* Added a std::thread::id formatter to fmt/std.h.
* Added support for nested specifiers to range formatting.
- Add 0001-Fix-large-shift-in-uint128_fallback.patch
0002-Use-FMT_USE_FLOAT128-instead-of-__SIZEOF_FLOAT128__.patch
0001-Make-sure-the-correct-fmod-overload-is-called.patch
-------------------------------------------------------------------
Sat Apr 30 12:01:50 UTC 2022 - Jan Engelhardt <jengelh@inai.de>

View File

@ -25,6 +25,9 @@ License: MIT
URL: http://fmtlib.net/
Source0: https://github.com/fmtlib/fmt/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1: baselibs.conf
Patch1: 0001-Fix-large-shift-in-uint128_fallback.patch
Patch2: 0002-Use-FMT_USE_FLOAT128-instead-of-__SIZEOF_FLOAT128__.patch
Patch3: 0001-Make-sure-the-correct-fmod-overload-is-called.patch
BuildRequires: c++_compiler
BuildRequires: cmake
BuildRequires: pkg-config