mirror of
https://github.com/fmtlib/fmt.git
synced 2025-12-27 09:18:15 +01:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bdf0628b1 | ||
|
|
fc1355114d | ||
|
|
926233bde8 | ||
|
|
0683fa7d1d | ||
|
|
6ce207b9a5 | ||
|
|
07b1c1a15f | ||
|
|
58992761cf | ||
|
|
b8957f50c3 | ||
|
|
df66516ed3 | ||
|
|
a57baa69a5 | ||
|
|
85534a1397 | ||
|
|
a2fa5d6288 | ||
|
|
cd3003683d | ||
|
|
d1ef29d679 | ||
|
|
cc09f1a679 | ||
|
|
e4eb242ce8 | ||
|
|
ce98e0c6a0 |
44
.github/workflows/windows.yml
vendored
Normal file
44
.github/workflows/windows.yml
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
name: windows
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{matrix.os}}
|
||||
strategy:
|
||||
matrix:
|
||||
# windows-2016 and windows-2019 have MSVC 2017 and 2019 installed
|
||||
# respectively: https://github.com/actions/virtual-environments.
|
||||
os: [windows-2016, windows-2019]
|
||||
platform: [Win32, x64]
|
||||
build_type: [Debug, Release]
|
||||
include:
|
||||
- os: windows-2016
|
||||
platform: Win32
|
||||
build_type: Debug
|
||||
shared: -DBUILD_SHARED_LIBS=ON
|
||||
exclude:
|
||||
- os: windows-2016
|
||||
platform: Win32
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Create Build Environment
|
||||
run: cmake -E make_directory ${{runner.workspace}}/build
|
||||
|
||||
- name: Configure
|
||||
# Use a bash shell for $GITHUB_WORKSPACE.
|
||||
shell: bash
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
run: |
|
||||
cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ${{matrix.shared}} \
|
||||
-A ${{matrix.platform}} $GITHUB_WORKSPACE
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
run: cmake --build . --config ${{matrix.build_type}}
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{runner.workspace}}/build
|
||||
run: ctest -C ${{matrix.build_type}}
|
||||
@@ -1,3 +1,25 @@
|
||||
7.1.3 - 2020-11-24
|
||||
------------------
|
||||
|
||||
* Fixed handling of buffer boundaries in ``format_to_n``
|
||||
(`#1996 <https://github.com/fmtlib/fmt/issues/1996>`_,
|
||||
`#2029 <https://github.com/fmtlib/fmt/issues/2029>`_).
|
||||
|
||||
* Fixed linkage errors when linking with a shared library
|
||||
(`#2011 <https://github.com/fmtlib/fmt/issues/2011>`_).
|
||||
|
||||
* Reintroduced ostream support to range formatters
|
||||
(`#2014 <https://github.com/fmtlib/fmt/issues/2014>`_).
|
||||
|
||||
* Worked around an issue with mixing std versions in gcc
|
||||
(`#2017 <https://github.com/fmtlib/fmt/issues/2017>`_).
|
||||
|
||||
7.1.2 - 2020-11-04
|
||||
------------------
|
||||
|
||||
* Fixed floating point formatting with large precision
|
||||
(`#1976 <https://github.com/fmtlib/fmt/issues/1976>`_).
|
||||
|
||||
7.1.1 - 2020-11-01
|
||||
------------------
|
||||
|
||||
|
||||
@@ -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', '7.0.2', '7.0.3', '7.1.0', '7.1.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']
|
||||
|
||||
def pip_install(package, commit=None, **kwargs):
|
||||
"Install package using pip."
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <vector>
|
||||
|
||||
// The fmt library version in the form major * 10000 + minor * 100 + patch.
|
||||
#define FMT_VERSION 70101
|
||||
#define FMT_VERSION 70103
|
||||
|
||||
#ifdef __clang__
|
||||
# define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
|
||||
@@ -761,7 +761,7 @@ class fixed_buffer_traits {
|
||||
explicit fixed_buffer_traits(size_t limit) : limit_(limit) {}
|
||||
size_t count() const { return count_; }
|
||||
size_t limit(size_t size) {
|
||||
size_t n = limit_ - count_;
|
||||
size_t n = limit_ > count_ ? limit_ - count_ : 0;
|
||||
count_ += size;
|
||||
return size < n ? size : n;
|
||||
}
|
||||
@@ -784,7 +784,7 @@ class iterator_buffer final : public Traits, public buffer<T> {
|
||||
public:
|
||||
explicit iterator_buffer(OutputIt out, size_t n = buffer_size)
|
||||
: Traits(n),
|
||||
buffer<T>(data_, 0, n < size_t(buffer_size) ? n : size_t(buffer_size)),
|
||||
buffer<T>(data_, 0, buffer_size),
|
||||
out_(out) {}
|
||||
~iterator_buffer() { flush(); }
|
||||
|
||||
|
||||
@@ -2337,7 +2337,7 @@ void fallback_format(Double d, int num_digits, bool binary32, buffer<char>& buf,
|
||||
upper = &upper_store;
|
||||
}
|
||||
denominator.assign_pow10(exp10);
|
||||
denominator <<= 1;
|
||||
denominator <<= shift;
|
||||
} else if (exp10 < 0) {
|
||||
numerator.assign_pow10(-exp10);
|
||||
lower.assign(numerator);
|
||||
|
||||
@@ -1145,8 +1145,8 @@ template <typename T = void> struct null {};
|
||||
template <typename Char> struct fill_t {
|
||||
private:
|
||||
enum { max_size = 4 };
|
||||
Char data_[max_size];
|
||||
unsigned char size_;
|
||||
Char data_[max_size] = {Char(' '), Char(0), Char(0), Char(0)};
|
||||
unsigned char size_ = 1;
|
||||
|
||||
public:
|
||||
FMT_CONSTEXPR void operator=(basic_string_view<Char> s) {
|
||||
@@ -1166,13 +1166,6 @@ template <typename Char> struct fill_t {
|
||||
FMT_CONSTEXPR const Char& operator[](size_t index) const {
|
||||
return data_[index];
|
||||
}
|
||||
|
||||
static FMT_CONSTEXPR fill_t<Char> make() {
|
||||
auto fill = fill_t<Char>();
|
||||
fill[0] = Char(' ');
|
||||
fill.size_ = 1;
|
||||
return fill;
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
@@ -1204,8 +1197,7 @@ template <typename Char> struct basic_format_specs {
|
||||
type(0),
|
||||
align(align::none),
|
||||
sign(sign::none),
|
||||
alt(false),
|
||||
fill(detail::fill_t<Char>::make()) {}
|
||||
alt(false) {}
|
||||
};
|
||||
|
||||
using format_specs = basic_format_specs<char>;
|
||||
@@ -1274,7 +1266,7 @@ template <typename T> struct decimal_fp {
|
||||
int exponent;
|
||||
};
|
||||
|
||||
template <typename T> decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT;
|
||||
template <typename T> FMT_API decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT;
|
||||
} // namespace dragonbox
|
||||
|
||||
template <typename T>
|
||||
|
||||
@@ -388,7 +388,7 @@ class ostream final : private detail::buffer<char> {
|
||||
clear();
|
||||
}
|
||||
|
||||
void grow(size_t) final;
|
||||
FMT_API void grow(size_t) override final;
|
||||
|
||||
ostream(cstring_view path, const detail::ostream_params& params)
|
||||
: file_(path, params.oflag) {
|
||||
|
||||
@@ -254,7 +254,10 @@ struct formatter<
|
||||
enable_if_t<fmt::is_range<T, Char>::value
|
||||
// Workaround a bug in MSVC 2017 and earlier.
|
||||
#if !FMT_MSC_VER || FMT_MSC_VER >= 1927
|
||||
&& has_formatter<detail::value_type<T>, format_context>::value
|
||||
&&
|
||||
(has_formatter<detail::value_type<T>, format_context>::value ||
|
||||
detail::has_fallback_formatter<detail::value_type<T>,
|
||||
format_context>::value)
|
||||
#endif
|
||||
>> {
|
||||
formatting_range<Char> formatting;
|
||||
|
||||
@@ -24,9 +24,9 @@ int format_float(char* buf, std::size_t size, const char* format, int precision,
|
||||
: snprintf_ptr(buf, size, format, precision, value);
|
||||
}
|
||||
|
||||
template dragonbox::decimal_fp<float> dragonbox::to_decimal(float x)
|
||||
template FMT_API dragonbox::decimal_fp<float> dragonbox::to_decimal(float x)
|
||||
FMT_NOEXCEPT;
|
||||
template dragonbox::decimal_fp<double> dragonbox::to_decimal(double x)
|
||||
template FMT_API dragonbox::decimal_fp<double> dragonbox::to_decimal(double x)
|
||||
FMT_NOEXCEPT;
|
||||
|
||||
// DEPRECATED! This function exists for ABI compatibility.
|
||||
|
||||
@@ -315,7 +315,7 @@ long getpagesize() {
|
||||
# endif
|
||||
}
|
||||
|
||||
void ostream::grow(size_t) {
|
||||
FMT_API void ostream::grow(size_t) {
|
||||
if (this->size() == this->capacity()) flush();
|
||||
}
|
||||
#endif // FMT_USE_FCNTL
|
||||
|
||||
@@ -1270,6 +1270,8 @@ TEST(FormatterTest, FormatDouble) {
|
||||
EXPECT_EQ(buffer, format("{:a}", -42.0));
|
||||
safe_sprintf(buffer, "%A", -42.0);
|
||||
EXPECT_EQ(buffer, format("{:A}", -42.0));
|
||||
EXPECT_EQ("9223372036854775808.000000",
|
||||
format("{:f}", 9223372036854775807.0));
|
||||
}
|
||||
|
||||
TEST(FormatterTest, PrecisionRounding) {
|
||||
@@ -1943,10 +1945,12 @@ TEST(FormatTest, FormatToN) {
|
||||
EXPECT_EQ(5u, result.size);
|
||||
EXPECT_EQ(buffer + 3, result.out);
|
||||
EXPECT_EQ("123x", fmt::string_view(buffer, 4));
|
||||
|
||||
result = fmt::format_to_n(buffer, 3, "{:s}", "foobar");
|
||||
EXPECT_EQ(6u, result.size);
|
||||
EXPECT_EQ(buffer + 3, result.out);
|
||||
EXPECT_EQ("foox", fmt::string_view(buffer, 4));
|
||||
|
||||
buffer[0] = 'x';
|
||||
buffer[1] = 'x';
|
||||
buffer[2] = 'x';
|
||||
@@ -1954,10 +1958,20 @@ TEST(FormatTest, FormatToN) {
|
||||
EXPECT_EQ(1u, result.size);
|
||||
EXPECT_EQ(buffer + 1, result.out);
|
||||
EXPECT_EQ("Axxx", fmt::string_view(buffer, 4));
|
||||
|
||||
result = fmt::format_to_n(buffer, 3, "{}{} ", 'B', 'C');
|
||||
EXPECT_EQ(3u, result.size);
|
||||
EXPECT_EQ(buffer + 3, result.out);
|
||||
EXPECT_EQ("BC x", fmt::string_view(buffer, 4));
|
||||
|
||||
result = fmt::format_to_n(buffer, 4, "{}", "ABCDE");
|
||||
EXPECT_EQ(5u, result.size);
|
||||
EXPECT_EQ("ABCD", fmt::string_view(buffer, 4));
|
||||
|
||||
buffer[3] = 'x';
|
||||
result = fmt::format_to_n(buffer, 3, "{}", std::string(1000, '*'));
|
||||
EXPECT_EQ(1000u, result.size);
|
||||
EXPECT_EQ("***x", fmt::string_view(buffer, 4));
|
||||
}
|
||||
|
||||
TEST(FormatTest, WideFormatToN) {
|
||||
@@ -2414,11 +2428,13 @@ TEST(FormatTest, CharTraitsIsNotAmbiguous) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if __cplusplus > 201103L
|
||||
struct custom_char {
|
||||
int value;
|
||||
custom_char() = default;
|
||||
|
||||
template <typename T> custom_char(T val) : value(static_cast<int>(val)) {}
|
||||
template <typename T>
|
||||
constexpr custom_char(T val) : value(static_cast<int>(val)) {}
|
||||
|
||||
operator int() const { return value; }
|
||||
};
|
||||
@@ -2435,6 +2451,7 @@ TEST(FormatTest, FormatCustomChar) {
|
||||
EXPECT_EQ(result.size(), 1);
|
||||
EXPECT_EQ(result[0], custom_char('x'));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Convert a char8_t string to std::string. Otherwise GTest will insist on
|
||||
// inserting `char8_t` NTBS into a `char` stream which is disabled by P1423.
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
//
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#define FMT_STRING_ALIAS 1
|
||||
#include "fmt/format.h"
|
||||
|
||||
struct test {};
|
||||
@@ -24,6 +23,7 @@ template <> struct formatter<test> : formatter<int> {
|
||||
#include <sstream>
|
||||
|
||||
#include "fmt/ostream.h"
|
||||
#include "fmt/ranges.h"
|
||||
#include "gmock.h"
|
||||
#include "gtest-extra.h"
|
||||
#include "util.h"
|
||||
@@ -323,3 +323,8 @@ TEST(OStreamTest, CompileTimeString) {
|
||||
TEST(OStreamTest, ToString) {
|
||||
EXPECT_EQ("ABC", fmt::to_string(fmt_test::ABC()));
|
||||
}
|
||||
|
||||
TEST(OStreamTest, Range) {
|
||||
auto strs = std::vector<TestString>{TestString("foo"), TestString("bar")};
|
||||
EXPECT_EQ("{foo, bar}", format("{}", strs));
|
||||
}
|
||||
Reference in New Issue
Block a user