From 8bbe76af3a5427597185ad6207ee6e588d2eb0fd Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 2 Dec 2019 11:36:33 -0800 Subject: Add a missing decimal point in exponent notation with trailing zeros --- include/fmt/format.h | 7 ++++--- test/format-test.cc | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 398c2a77..600b0eba 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1145,10 +1145,11 @@ template class float_writer { if (specs_.format == float_format::exp) { // Insert a decimal point after the first digit and add an exponent. *it++ = static_cast(*digits_); - if (num_digits_ > 1) *it++ = decimal_point_; - it = copy_str(digits_ + 1, digits_ + num_digits_, it); int num_zeros = specs_.precision - num_digits_; - if (num_zeros > 0 && specs_.trailing_zeros) + bool trailing_zeros = num_zeros > 0 && specs_.trailing_zeros; + if (num_digits_ > 1 || trailing_zeros) *it++ = decimal_point_; + it = copy_str(digits_ + 1, digits_ + num_digits_, it); + if (trailing_zeros) it = std::fill_n(it, num_zeros, static_cast('0')); *it++ = static_cast(specs_.upper ? 'E' : 'e'); return write_exponent(full_exp - 1, it); diff --git a/test/format-test.cc b/test/format-test.cc index 84c9d8a0..f52e1275 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1204,6 +1204,7 @@ TEST(FormatterTest, Precision) { EXPECT_EQ("1.2", format("{0:.2}", 1.2345l)); EXPECT_EQ("1.2e+56", format("{:.2}", 1.234e56)); EXPECT_EQ("1e+00", format("{:.0e}", 1.0L)); + EXPECT_EQ(" 0.0e+00", format("{:9.1e}", 0.0)); EXPECT_EQ( "4.9406564584124654417656879286822137236505980261432476442558568250067550" "727020875186529983636163599237979656469544571773092665671035593979639877" -- cgit v1.2.3 From 5981588565191fe7c8934021f711286f8ea61d93 Mon Sep 17 00:00:00 2001 From: Beat Bolli Date: Mon, 2 Dec 2019 20:40:59 +0100 Subject: Fix compilation with MinGW Commit 3bc28fcc6b2a ("Squelch MSVC warning exporting subclasses of runtime_error", 2019-11-29) silenced a MSVC warning under. The MinGW compiler also defines _WIN32, but does not support the "warning" pragma. Introduce a helper macro to squelch the MSVC warning only when using the Microsoft compiler. Signed-off-by: Beat Bolli --- include/fmt/core.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 6a0846fc..d49f36e6 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -166,10 +166,15 @@ #endif #if !defined(FMT_HEADER_ONLY) && defined(_WIN32) +# if FMT_MSC_VER +# define FMT_NO_W4275 __pragma(warning(suppress : 4275)) +# else +# define FMT_NO_W4275 +# endif # ifdef FMT_EXPORT -# define FMT_API __pragma(warning(suppress : 4275)) __declspec(dllexport) +# define FMT_API FMT_NO_W4275 __declspec(dllexport) # elif defined(FMT_SHARED) -# define FMT_API __pragma(warning(suppress : 4275)) __declspec(dllimport) +# define FMT_API FMT_NO_W4275 __declspec(dllimport) # define FMT_EXTERN_TEMPLATE_API FMT_API # endif #endif -- cgit v1.2.3 From b160123e39cf9ceed8b18a2d8bacdef22033e11b Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 2 Dec 2019 16:18:06 -0800 Subject: Update ChangeLog.rst --- ChangeLog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.rst b/ChangeLog.rst index 25d1b200..cdec766f 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -92,7 +92,7 @@ Thanks `@jeremyong (Jeremy Ong) `_. -* Changed formatting of octal zero with prefix from "0o0" to "0": +* Changed formatting of octal zero with prefix from "00" to "0": .. code:: c++ -- cgit v1.2.3 From 1a599117d8ef331e68eb0d808d1fa04a48b1fcf2 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Tue, 3 Dec 2019 04:14:16 +0300 Subject: Export assert_fail with FMT_API. This fixes dll build. --- include/fmt/core.h | 2 +- include/fmt/format-inl.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index d49f36e6..80e87e21 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -229,7 +229,7 @@ namespace internal { // A workaround for gcc 4.8 to make void_t work in a SFINAE context. template struct void_t_impl { using type = void; }; -void assert_fail(const char* file, int line, const char* message); +FMT_API void assert_fail(const char* file, int line, const char* message); #ifndef FMT_ASSERT # ifdef NDEBUG diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 72b30466..21caeec9 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -55,7 +55,7 @@ inline fmt::internal::null<> strerror_s(char*, std::size_t, ...) { return {}; } FMT_BEGIN_NAMESPACE namespace internal { -FMT_FUNC void assert_fail(const char* file, int line, const char* message) { +FMT_API FMT_FUNC void assert_fail(const char* file, int line, const char* message) { print(stderr, "{}:{}: assertion failed: {}", file, line, message); std::abort(); } -- cgit v1.2.3 From a64f60c8499dcca96868e9beda4c76915baae29a Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Tue, 3 Dec 2019 04:26:27 +0300 Subject: Remove unneeded FMT_API. --- include/fmt/format-inl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 21caeec9..72b30466 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -55,7 +55,7 @@ inline fmt::internal::null<> strerror_s(char*, std::size_t, ...) { return {}; } FMT_BEGIN_NAMESPACE namespace internal { -FMT_API FMT_FUNC void assert_fail(const char* file, int line, const char* message) { +FMT_FUNC void assert_fail(const char* file, int line, const char* message) { print(stderr, "{}:{}: assertion failed: {}", file, line, message); std::abort(); } -- cgit v1.2.3 From 168460f02c0f720ea4a1bfef82116632ce7f2d9e Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 3 Dec 2019 06:45:00 -0800 Subject: Remove TYPES --- include/fmt/core.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 80e87e21..d37486d0 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1211,7 +1211,6 @@ template class format_arg_store { static constexpr unsigned long long types = is_packed ? internal::encode_types() : internal::is_unpacked_bit | num_args; - FMT_DEPRECATED static constexpr unsigned long long TYPES = types; format_arg_store(const Args&... args) : data_{internal::make_arg(args)...} {} -- cgit v1.2.3 From 123e7f7fc33381a07a9d4d28ea2006f5132c503d Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 3 Dec 2019 09:24:15 -0800 Subject: Revert #1433 because of build failures (#1450) --- include/fmt/core.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index d37486d0..e766b3a9 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -166,15 +166,10 @@ #endif #if !defined(FMT_HEADER_ONLY) && defined(_WIN32) -# if FMT_MSC_VER -# define FMT_NO_W4275 __pragma(warning(suppress : 4275)) -# else -# define FMT_NO_W4275 -# endif # ifdef FMT_EXPORT -# define FMT_API FMT_NO_W4275 __declspec(dllexport) +# define FMT_API __declspec(dllexport) # elif defined(FMT_SHARED) -# define FMT_API FMT_NO_W4275 __declspec(dllimport) +# define FMT_API __declspec(dllimport) # define FMT_EXTERN_TEMPLATE_API FMT_API # endif #endif -- cgit v1.2.3 From 02af5beb8a025cbac94e93da060789556c785316 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 4 Dec 2019 10:22:07 -0800 Subject: Bump version and update changelog --- ChangeLog.rst | 9 +++++++++ include/fmt/core.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog.rst b/ChangeLog.rst index cdec766f..aa811439 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -1,3 +1,12 @@ +6.1.1 - TBD +----------- + +* Fixed shared library build on Windows. + +* Added a missing decimal point in exponent notation with trailing zeros. + +* Removed deprecated ``format_arg_store::TYPES``. + 6.1.0 - 2019-12-01 ------------------ diff --git a/include/fmt/core.h b/include/fmt/core.h index e766b3a9..13d74ba8 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -15,7 +15,7 @@ #include // The fmt library version in the form major * 10000 + minor * 100 + patch. -#define FMT_VERSION 60100 +#define FMT_VERSION 60101 #ifdef __has_feature # define FMT_HAS_FEATURE(x) __has_feature(x) -- cgit v1.2.3 From 983806b0c1ca83a7d2f239d2af2ebcf642a08fa5 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 4 Dec 2019 12:03:44 -0800 Subject: Update changelog --- ChangeLog.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog.rst b/ChangeLog.rst index aa811439..9186cd4b 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -1,7 +1,13 @@ 6.1.1 - TBD ----------- -* Fixed shared library build on Windows. +* Fixed shared library build on Windows + (`#1443 `_, + `#1445 `_, + `#1446 `_, + `#1450 `_,). + Thanks `@egorpugin (Egor Pugin) `_, + `@bbolli (Beat Bolli) `_. * Added a missing decimal point in exponent notation with trailing zeros. -- cgit v1.2.3 From d22e4ad85b477b4f2b4ffb034d1212cc9afcfe49 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 4 Dec 2019 12:20:52 -0800 Subject: Remove trailing comma --- ChangeLog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.rst b/ChangeLog.rst index 9186cd4b..670fdf95 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -5,7 +5,7 @@ (`#1443 `_, `#1445 `_, `#1446 `_, - `#1450 `_,). + `#1450 `_). Thanks `@egorpugin (Egor Pugin) `_, `@bbolli (Beat Bolli) `_. -- cgit v1.2.3 From 071794ec654a7c503b6214de4032c8ec8a07440b Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 4 Dec 2019 12:21:48 -0800 Subject: 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 670fdf95..dd712418 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -1,5 +1,5 @@ -6.1.1 - TBD ------------ +6.1.1 - 2019-12-04 +------------------ * Fixed shared library build on Windows (`#1443 `_, diff --git a/doc/build.py b/doc/build.py index e8f5f396..2f0c8b80 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'] +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'] def pip_install(package, commit=None, **kwargs): "Install package using pip." -- cgit v1.2.3