From 89d0c7124bc7330e90712f9b1fa9824a0fa8303a Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 17 Jul 2020 06:39:53 -0700 Subject: [PATCH 1/6] Fix compatibility with CMake 3.4 (#1779) --- CMakeLists.txt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8dd862c..977090f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,15 +24,23 @@ function(join result_var) set(${result_var} "${result}" PARENT_SCOPE) endfunction() +include(CMakeParseArguments) + # Sets a cache variable with a docstring joined from multiple arguments: # set( ... CACHE ...) # This allows splitting a long docstring for readability. function(set_verbose) - cmake_parse_arguments(SET_VERBOSE "" "" "CACHE" ${ARGN}) - list(GET SET_VERBOSE_CACHE 0 type) - list(REMOVE_AT SET_VERBOSE_CACHE 0) - join(doc ${SET_VERBOSE_CACHE}) - set(${SET_VERBOSE_UNPARSED_ARGUMENTS} CACHE ${type} ${doc}) + # cmake_parse_arguments is broken in CMake 3.4 (cannot parse CACHE) so use + # list instead. + list(GET ARGN 0 var) + list(REMOVE_AT ARGN 0) + list(GET ARGN 0 val) + list(REMOVE_AT ARGN 0) + list(REMOVE_AT ARGN 0) + list(GET ARGN 0 type) + list(REMOVE_AT ARGN 0) + join(doc ${ARGN}) + set(${var} ${val} CACHE ${type} ${doc}) endfunction() # Set the default CMAKE_BUILD_TYPE to Release. From 2b7a146fa1f91ee3d7ebc6a782663185543bc373 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 18 Jul 2020 08:31:38 -0700 Subject: [PATCH 2/6] Fix a regression in handling digit separators (#1782) --- include/fmt/format.h | 2 +- test/locale-test.cc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index ddf086f8..7c403bf8 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1559,7 +1559,7 @@ template struct int_writer { int num_digits = count_digits(abs_value); int size = num_digits, n = num_digits; std::string::const_iterator group = groups.cbegin(); - while (group != groups.cend() && num_digits > *group && *group > 0 && + while (group != groups.cend() && n > *group && *group > 0 && *group != max_value()) { size += sep_size; n -= *group; diff --git a/test/locale-test.cc b/test/locale-test.cc index fcce0091..15a40d99 100644 --- a/test/locale-test.cc +++ b/test/locale-test.cc @@ -61,6 +61,7 @@ TEST(LocaleTest, Format) { std::locale special_grouping_loc(std::locale(), new special_grouping()); EXPECT_EQ("1,23,45,678", fmt::format(special_grouping_loc, "{:L}", 12345678)); + EXPECT_EQ("12,345", fmt::format(special_grouping_loc, "{:L}", 12345)); std::locale small_grouping_loc(std::locale(), new small_grouping()); EXPECT_EQ("4,2,9,4,9,6,7,2,9,5", From 229ee9b469c1748dca600edd6abdc8d70f9e44b9 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 20 Jul 2020 08:39:15 -0700 Subject: [PATCH 3/6] Workaround broken numeric_limits (#1725) --- include/fmt/format.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 7c403bf8..b1ba0713 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -283,6 +283,9 @@ template constexpr T max_value() { template constexpr int num_bits() { return std::numeric_limits::digits; } +// std::numeric_limits::digits may return 0 for 128-bit ints. +template <> constexpr int num_bits() { return 128; } +template <> constexpr int num_bits() { return 128; } template <> constexpr int num_bits() { return static_cast(sizeof(void*) * std::numeric_limits::digits); @@ -743,8 +746,8 @@ FMT_CONSTEXPR bool is_supported_floating_point(T) { // represent all values of T. template using uint32_or_64_or_128_t = conditional_t< - std::numeric_limits::digits <= 32, uint32_t, - conditional_t::digits <= 64, uint64_t, uint128_t>>; + num_bits() <= 32, uint32_t, + conditional_t() <= 64, uint64_t, uint128_t>>; // Static data is placed in this class template for the header-only config. template struct FMT_EXTERN_TEMPLATE_API basic_data { From cbf6be9604090409afd2620f611297962ebc738e Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 28 Jul 2020 09:15:02 -0700 Subject: [PATCH 4/6] Update changelog --- ChangeLog.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ChangeLog.rst b/ChangeLog.rst index 3e24c7d9..294b62da 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -1,3 +1,15 @@ +7.0.2 - TBD +----------- + +* Worked around broken ``numeric_limits`` for 128-bit integers + (`#1725 `_). + +* Fixed compatibility with CMake 3.4 + (`#1779 `_). + +* Fixed handling of digit separators in locale-specific formatting + (`#1782 `_). + 7.0.1 - 2020-07-07 ------------------ From 86b63bb71a63d2addcaaa4f0935105a6c7e2f49c Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 28 Jul 2020 09:25:15 -0700 Subject: [PATCH 5/6] Bump version --- include/fmt/core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 761162eb..40c4ddb0 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -18,7 +18,7 @@ #include // The fmt library version in the form major * 10000 + minor * 100 + patch. -#define FMT_VERSION 70001 +#define FMT_VERSION 70002 #ifdef __clang__ # define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) From b9d749095e3397f154e2938f96dd11912f2d9300 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 29 Jul 2020 07:30:55 -0700 Subject: [PATCH 6/6] Update version --- ChangeLog.rst | 4 ++-- doc/build.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog.rst b/ChangeLog.rst index 294b62da..aa1b7fe0 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -1,5 +1,5 @@ -7.0.2 - TBD ------------ +7.0.2 - 2020-07-29 +------------------ * Worked around broken ``numeric_limits`` for 128-bit integers (`#1725 `_). diff --git a/doc/build.py b/doc/build.py index 25d7885a..ba9eea75 100755 --- a/doc/build.py +++ b/doc/build.py @@ -6,7 +6,7 @@ import errno, os, shutil, sys, tempfile from subprocess import check_call, check_output, CalledProcessError, Popen, PIPE from distutils.version import LooseVersion -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'] +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'] def pip_install(package, commit=None, **kwargs): "Install package using pip."