Skip to content

Commit

Permalink
apply some fmt upstream patches
Browse files Browse the repository at this point in the history
Summary: Add PRs [#1808](fmtlib/fmt#1808), [#1812](fmtlib/fmt#1812), [#1816](fmtlib/fmt#1816), [#1818](fmtlib/fmt#1818) to improve cross-platform compatibility.

Reviewed By: stepancheg

Differential Revision: D23154350

fbshipit-source-id: 42f3781f70d376e1da2bcf34cb89a56f431371e4
  • Loading branch information
h-friederich authored and facebook-github-bot committed Aug 18, 2020
1 parent 3fa37a1 commit c7a0657
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions deps/fmt/fmt-7.0.3/include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ FMT_END_NAMESPACE
# if FMT_USE_USER_DEFINED_LITERALS && \
(!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 501) && \
((FMT_GCC_VERSION >= 604 && __cplusplus >= 201402L) || \
FMT_CLANG_VERSION >= 304)
FMT_CLANG_VERSION >= 304) && \
!defined(__PGI) && !defined(__NVCC__)
# define FMT_USE_UDL_TEMPLATE 1
# else
# define FMT_USE_UDL_TEMPLATE 0
Expand Down Expand Up @@ -1578,7 +1579,8 @@ template <typename OutputIt, typename Char, typename UInt> struct int_writer {
format_decimal(digits, abs_value, num_digits);
basic_memory_buffer<Char> buffer;
size += prefix_size;
buffer.resize(size);
const auto usize = to_unsigned(size);
buffer.resize(usize);
basic_string_view<Char> s(&sep, sep_size);
// Index of a decimal digit with the least significant digit having index 0.
int digit_index = 0;
Expand All @@ -1598,9 +1600,8 @@ template <typename OutputIt, typename Char, typename UInt> struct int_writer {
make_checked(p, s.size()));
}
if (prefix_size != 0) p[-1] = static_cast<Char>('-');
using iterator = remove_reference_t<decltype(reserve(out, 0))>;
auto data = buffer.data();
out = write_padded<align::right>(out, specs, size, size, [=](iterator it) {
out = write_padded<align::right>(out, specs, usize, usize, [=](iterator it) {
return copy_str<Char>(data, data + size, it);
});
}
Expand Down Expand Up @@ -2662,17 +2663,17 @@ FMT_CONSTEXPR_DECL FMT_INLINE void parse_format_string(
return;
}
struct writer {
FMT_CONSTEXPR void operator()(const Char* begin, const Char* end) {
if (begin == end) return;
FMT_CONSTEXPR void operator()(const Char* pbegin, const Char* pend) {
if (pbegin == pend) return;
for (;;) {
const Char* p = nullptr;
if (!find<IS_CONSTEXPR>(begin, end, '}', p))
return handler_.on_text(begin, end);
if (!find<IS_CONSTEXPR>(pbegin, pend, '}', p))
return handler_.on_text(pbegin, pend);
++p;
if (p == end || *p != '}')
if (p == pend || *p != '}')
return handler_.on_error("unmatched '}' in format string");
handler_.on_text(begin, p);
begin = p + 1;
handler_.on_text(pbegin, p);
pbegin = p + 1;
}
}
Handler& handler_;
Expand Down

0 comments on commit c7a0657

Please sign in to comment.