Skip to content

Commit

Permalink
version based on 8.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
moiwi committed Feb 6, 2024
1 parent 65e9dd0 commit 5ca8660
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 70 deletions.
23 changes: 21 additions & 2 deletions ChangeLog.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
8.1.0 - TBD
-----------
8.1.1 - 2022-01-06
------------------

* Restored ABI compatibility with version 8.0.x
(`#2695 <https://github.com/fmtlib/fmt/issues/2695>`_,
`#2696 <https://github.com/fmtlib/fmt/pull/2696>`_).
Thanks `@saraedum (Julian Rüth) <https://github.com/saraedum>`_.

* Fixed chorno formatting on big endian systems
(`#2698 <https://github.com/fmtlib/fmt/issues/2698>`_,
`#2699 <https://github.com/fmtlib/fmt/pull/2699>`_).
Thanks `@phprus (Vladislav Shchapov) <https://github.com/phprus>`_ and
`@xvitaly (Vitaly Zaitsev) <https://github.com/xvitaly>`_.

* Fixed a linkage error with mingw
(`#2691 <https://github.com/fmtlib/fmt/issues/2691>`_,
`#2692 <https://github.com/fmtlib/fmt/pull/2692>`_).
Thanks `@rbberger (Richard Berger) <https://github.com/rbberger>`_.

8.1.0 - 2022-01-02
------------------

* Optimized chrono formatting
(`#2500 <https://github.com/fmtlib/fmt/pull/2500>`_,
Expand Down
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']
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']

class Pip:
def __init__(self, venv_dir):
Expand Down
12 changes: 10 additions & 2 deletions include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -1082,7 +1090,7 @@ template <typename OutputIt, typename Char> class tm_writer {
}
template <typename T, FMT_ENABLE_IF(!has_member_data_tm_gmtoff<T>::value)>
void format_utc_offset_impl(const T& tm) {
#if defined(_WIN32)
#if defined(_WIN32) && defined(_UCRT)
# if FMT_USE_TZSET
tzset_once();
# endif
Expand Down
33 changes: 23 additions & 10 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define FMT_EXCEPTIONS 0

// The fmt library version in the form major * 10000 + minor * 100 + patch.
#define FMT_VERSION 80100
#define FMT_VERSION 80101

#if defined(__clang__) && !defined(__ibmxl__)
# define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
Expand Down Expand Up @@ -222,6 +222,20 @@
# endif
#endif

#ifndef FMT_DEPRECATED
# if FMT_HAS_CPP14_ATTRIBUTE(deprecated) || FMT_MSC_VER >= 1900
# define FMT_DEPRECATED [[deprecated]]
# else
# if (defined(__GNUC__) && !defined(__LCC__)) || defined(__clang__)
# define FMT_DEPRECATED __attribute__((deprecated))
# elif FMT_MSC_VER
# define FMT_DEPRECATED __declspec(deprecated)
# else
# define FMT_DEPRECATED /* deprecated */
# endif
# endif
#endif

#ifndef FMT_BEGIN_NAMESPACE
# define FMT_BEGIN_NAMESPACE \
namespace fmt { \
Expand Down Expand Up @@ -604,7 +618,7 @@ 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); }
FMT_NORETURN FMT_API void on_error(const char* message);
};
FMT_END_DETAIL_NAMESPACE

Expand Down Expand Up @@ -1376,21 +1390,20 @@ template <typename Context> struct arg_mapper {
using cstring_result = conditional_t<std::is_same<char_type, char>::value,
const char*, unformattable_pointer>;

// DEPRECATED!
FMT_CONSTEXPR FMT_INLINE auto map(const signed char* val) -> cstring_result {
FMT_DEPRECATED FMT_CONSTEXPR FMT_INLINE auto map(const signed char* val)
-> cstring_result {
return map(reinterpret_cast<const char*>(val));
}
// DEPRECATED!
FMT_CONSTEXPR FMT_INLINE auto map(const unsigned char* val)
FMT_DEPRECATED FMT_CONSTEXPR FMT_INLINE auto map(const unsigned char* val)
-> cstring_result {
return map(reinterpret_cast<const char*>(val));
}
// DEPRECATED!
FMT_CONSTEXPR FMT_INLINE auto map(signed char* val) -> cstring_result {
FMT_DEPRECATED FMT_CONSTEXPR FMT_INLINE auto map(signed char* val)
-> cstring_result {
return map(reinterpret_cast<const char*>(val));
}
// DEPRECATED!
FMT_CONSTEXPR FMT_INLINE auto map(unsigned char* val) -> cstring_result {
FMT_DEPRECATED FMT_CONSTEXPR FMT_INLINE auto map(unsigned char* val)
-> cstring_result {
return map(reinterpret_cast<const char*>(val));
}

Expand Down
6 changes: 6 additions & 0 deletions include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2572,6 +2572,12 @@ FMT_FUNC void report_system_error(int error_code,
report_error(format_system_error, error_code, message);
}

// DEPRECATED!
// This function is defined here and not inline for ABI compatiblity.
FMT_FUNC void detail::error_handler::on_error(const char* message) {
throw_format_error(message);
}

FMT_FUNC std::string vformat(string_view fmt, format_args args) {
// Don't optimize the "{}" case to keep the binary size small and because it
// can be better optimized in fmt::format anyway.
Expand Down
36 changes: 12 additions & 24 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,6 @@ FMT_END_NAMESPACE
# define FMT_CATCH(x) if (false)
#endif

#ifndef FMT_DEPRECATED
# if FMT_HAS_CPP14_ATTRIBUTE(deprecated) || FMT_MSC_VER >= 1900
# define FMT_DEPRECATED [[deprecated]]
# else
# if (defined(__GNUC__) && !defined(__LCC__)) || defined(__clang__)
# define FMT_DEPRECATED __attribute__((deprecated))
# elif FMT_MSC_VER
# define FMT_DEPRECATED __declspec(deprecated)
# else
# define FMT_DEPRECATED /* deprecated */
# endif
# endif
#endif

#ifndef FMT_MAYBE_UNUSED
# if FMT_HAS_CPP17_ATTRIBUTE(maybe_unused)
# define FMT_MAYBE_UNUSED [[maybe_unused]]
Expand Down Expand Up @@ -318,10 +304,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.
Expand All @@ -331,7 +325,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]);
}
Expand Down Expand Up @@ -534,7 +528,7 @@ FMT_CONSTEXPR inline auto utf8_decode(const char* s, uint32_t* c, int* e)
return next;
}

enum { invalid_code_point = ~uint32_t() };
constexpr uint32_t invalid_code_point = ~uint32_t();

// Invokes f(cp, sv) for every code point cp in s with sv being the string view
// corresponding to the code point. cp is invalid_code_point on error.
Expand Down Expand Up @@ -3079,14 +3073,8 @@ constexpr auto operator"" _a(const char* s, size_t) -> detail::udl_arg<char> {
}
# endif

/**
DEPRECATED! User-defined literal equivalent of fmt::format.
**Example**::
using namespace fmt::literals;
std::string message = "The answer is {}"_format(42);
*/
// DEPRECATED!
// User-defined literal equivalent of fmt::format.
FMT_DEPRECATED constexpr auto operator"" _format(const char* s, size_t n)
-> detail::udl_formatter<char> {
return {{s, n}};
Expand Down
8 changes: 4 additions & 4 deletions support/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ def release(args):

# Create a release on GitHub.
fmt_repo.push('origin', 'release')
params = {'access_token': os.getenv('FMT_TOKEN')}
auth_headers = {'Authorization': 'token ' + os.getenv('FMT_TOKEN')}
r = requests.post('https://api.github.com/repos/fmtlib/fmt/releases',
params=params,
headers=auth_headers,
data=json.dumps({'tag_name': version,
'target_commitish': 'release',
'body': changes, 'draft': True}))
Expand All @@ -283,8 +283,8 @@ def release(args):
package = 'fmt-{}.zip'.format(version)
r = requests.post(
'{}/{}/assets?name={}'.format(uploads_url, id, package),
headers={'Content-Type': 'application/zip'},
params=params, data=open('build/fmt/' + package, 'rb'))
headers={'Content-Type': 'application/zip'} | auth_headers,
data=open('build/fmt/' + package, 'rb'))
if r.status_code != 201:
raise Exception('Failed to upload an asset ' + str(r))

Expand Down
8 changes: 3 additions & 5 deletions test/core-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,13 @@ struct convertible_to_pointer {
enum class test_scoped_enum {};

TEST(core_test, is_formattable) {
#if 0
// This should be enabled once corresponding map overloads are gone.
static_assert(fmt::is_formattable<signed char*>::value, "");
static_assert(fmt::is_formattable<unsigned char*>::value, "");
static_assert(fmt::is_formattable<const signed char*>::value, "");
static_assert(fmt::is_formattable<const unsigned char*>::value, "");
#endif
static_assert(!fmt::is_formattable<wchar_t>::value, "");
#ifdef __cpp_char8_t
static_assert(!fmt::is_formattable<char8_t>::value, "");
Expand All @@ -768,11 +771,6 @@ TEST(core_test, is_formattable) {

static_assert(!fmt::is_formattable<convertible_to_pointer>::value, "");

static_assert(!fmt::is_formattable<signed char*, wchar_t>::value, "");
static_assert(!fmt::is_formattable<unsigned char*, wchar_t>::value, "");
static_assert(!fmt::is_formattable<const signed char*, wchar_t>::value, "");
static_assert(!fmt::is_formattable<const unsigned char*, wchar_t>::value, "");

static_assert(!fmt::is_formattable<void (*)()>::value, "");

struct s;
Expand Down
16 changes: 0 additions & 16 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1386,22 +1386,6 @@ TEST(format_test, format_cstring) {
format_error, "string pointer is null");
}

TEST(format_test, format_schar_string) {
signed char str[] = "test";
EXPECT_EQ("test", fmt::format("{0:s}", str));
const signed char* const_str = str;
EXPECT_EQ("test", fmt::format("{0:s}", const_str));
}

TEST(format_test, format_uchar_string) {
unsigned char str[] = "test";
EXPECT_EQ("test", fmt::format("{0:s}", str));
const unsigned char* const_str = str;
EXPECT_EQ("test", fmt::format("{0:s}", const_str));
unsigned char* ptr = str;
EXPECT_EQ("test", fmt::format("{0:s}", ptr));
}

void function_pointer_test(int, double, std::string) {}

TEST(format_test, format_pointer) {
Expand Down
6 changes: 0 additions & 6 deletions test/printf-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,6 @@ TEST(printf_test, string) {
EXPECT_PRINTF(L" (null)", L"%10s", null_wstr);
}

TEST(printf_test, uchar_string) {
unsigned char str[] = "test";
unsigned char* pstr = str;
EXPECT_EQ("test", fmt::sprintf("%s", pstr));
}

TEST(printf_test, pointer) {
int n;
void* p = &n;
Expand Down

0 comments on commit 5ca8660

Please sign in to comment.