parent
f3e03ce777
commit
ce9f48e9d1
@ -1,68 +0,0 @@
|
|||||||
From 214cf13f17c7177912cc8f9b6c070c4b3a282c36 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Vladislav Shchapov <phprus@gmail.com>
|
|
||||||
Date: Wed, 5 Jan 2022 03:23:42 +0500
|
|
||||||
Subject: [PATCH] Fix endianness bug in write_digit2_separated (#2699)
|
|
||||||
|
|
||||||
* Fix endianness bug in write_digit2_separated
|
|
||||||
|
|
||||||
* Move endianness check to compile time if it possible
|
|
||||||
|
|
||||||
* Turn 8 into a constant
|
|
||||||
---
|
|
||||||
include/fmt/chrono.h | 10 +++++++++-
|
|
||||||
include/fmt/format.h | 10 +++++++++-
|
|
||||||
2 files changed, 18 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h
|
|
||||||
index 908999ab5f..682efd8d21 100644
|
|
||||||
--- a/include/fmt/chrono.h
|
|
||||||
+++ b/include/fmt/chrono.h
|
|
||||||
@@ -558,7 +558,15 @@ inline void write_digit2_separated(char* buf, unsigned a, unsigned b,
|
|
||||||
auto usep = static_cast<unsigned long long>(sep);
|
|
||||||
// Add ASCII '0' to each digit byte and insert separators.
|
|
||||||
digits |= 0x3030003030003030 | (usep << 16) | (usep << 40);
|
|
||||||
- memcpy(buf, &digits, 8);
|
|
||||||
+
|
|
||||||
+ constexpr const size_t len = 8;
|
|
||||||
+ if (const_check(is_big_endian())) {
|
|
||||||
+ char tmp[len];
|
|
||||||
+ memcpy(tmp, &digits, len);
|
|
||||||
+ std::reverse_copy(tmp, tmp + len, buf);
|
|
||||||
+ } else {
|
|
||||||
+ memcpy(buf, &digits, len);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Period> FMT_CONSTEXPR inline const char* get_units() {
|
|
||||||
diff --git a/include/fmt/format.h b/include/fmt/format.h
|
|
||||||
index a6f1fdc89e..8b789574ec 100644
|
|
||||||
--- a/include/fmt/format.h
|
|
||||||
+++ b/include/fmt/format.h
|
|
||||||
@@ -296,10 +296,18 @@ FMT_CONSTEXPR20 auto bit_cast(const From& from) -> To {
|
|
||||||
}
|
|
||||||
|
|
||||||
inline auto is_big_endian() -> bool {
|
|
||||||
+#ifdef _WIN32
|
|
||||||
+ return false;
|
|
||||||
+#elif defined(__BIG_ENDIAN__)
|
|
||||||
+ return true;
|
|
||||||
+#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
|
|
||||||
+ return __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__;
|
|
||||||
+#else
|
|
||||||
struct bytes {
|
|
||||||
char data[sizeof(int)];
|
|
||||||
};
|
|
||||||
return bit_cast<bytes>(1).data[0] == 0;
|
|
||||||
+#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// A fallback implementation of uintptr_t for systems that lack it.
|
|
||||||
@@ -309,7 +317,7 @@ struct fallback_uintptr {
|
|
||||||
fallback_uintptr() = default;
|
|
||||||
explicit fallback_uintptr(const void* p) {
|
|
||||||
*this = bit_cast<fallback_uintptr>(p);
|
|
||||||
- if (is_big_endian()) {
|
|
||||||
+ if (const_check(is_big_endian())) {
|
|
||||||
for (size_t i = 0, j = sizeof(void*) - 1; i < j; ++i, --j)
|
|
||||||
std::swap(value[i], value[j]);
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
From 17a5c808dad4bcf3a412c005314cad43609ae6ef Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Julian=20R=C3=BCth?= <julian.rueth@fsfe.org>
|
|
||||||
Date: Tue, 4 Jan 2022 12:53:44 -0600
|
|
||||||
Subject: [PATCH] Restore FMT_API on error_handler::on_error() (#2696)
|
|
||||||
|
|
||||||
this fixes a breaking ABI change that was introduce in the upgrade from
|
|
||||||
8.0.1 to 8.1.0.
|
|
||||||
|
|
||||||
Fixes #2695.
|
|
||||||
---
|
|
||||||
include/fmt/core.h | 3 ++-
|
|
||||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/include/fmt/core.h b/include/fmt/core.h
|
|
||||||
index 4efa21f11f..28b8ff648f 100644
|
|
||||||
--- a/include/fmt/core.h
|
|
||||||
+++ b/include/fmt/core.h
|
|
||||||
@@ -615,7 +615,8 @@ struct error_handler {
|
|
||||||
constexpr error_handler(const error_handler&) = default;
|
|
||||||
|
|
||||||
// This function is intentionally not constexpr to give a compile-time error.
|
|
||||||
- void on_error(const char* message) { throw_format_error(message); }
|
|
||||||
+ // This function is marked as FMT_API for backwards compatibility, see #2695.
|
|
||||||
+ FMT_NORETURN FMT_API void on_error(const char* message) { throw_format_error(message); }
|
|
||||||
};
|
|
||||||
FMT_END_DETAIL_NAMESPACE
|
|
||||||
|
|
@ -1 +1 @@
|
|||||||
SHA512 (8.1.0.tar.gz) = 63d052c6ba7ca53978ca42b8a72d8548eabae04064832bb79010f44f0276b31d0a2fc02d99b09a350ce514931afc387d5fe13c121344cad6d87fe4d504810d9f
|
SHA512 (8.1.1.tar.gz) = 794a47d7cb352a2a9f2c050a60a46b002e4157e5ad23e15a5afc668e852b1e1847aeee3cda79e266c789ff79310d792060c94976ceef6352e322d60b94e23189
|
||||||
|
Loading…
Reference in new issue