diff options
author | Bardur Arantsson <bardur@scientician.net> | 2017-01-04 21:27:24 +0100 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2017-01-04 21:34:11 +0100 |
commit | 145a0540715551140f17e4a193b605618c390f8f (patch) | |
tree | 6ef5e1b68ba0d9ee23e9d91ac0d82631fe76be19 | |
parent | ed08d82d76665f84d5fd9ce4ef41e84542b010cc (diff) |
Bump to fmt-3.0.1
l--------- | vendor/fmt | 2 | ||||
-rw-r--r-- | vendor/fmt-3.0.0/fmt/ostream.cc | 61 | ||||
-rw-r--r-- | vendor/fmt-3.0.0/fmt/time.h | 64 | ||||
-rw-r--r-- | vendor/fmt-3.0.1/fmt/CMakeLists.txt (renamed from vendor/fmt-3.0.0/fmt/CMakeLists.txt) | 8 | ||||
-rw-r--r-- | vendor/fmt-3.0.1/fmt/format.cc (renamed from vendor/fmt-3.0.0/fmt/format.cc) | 5 | ||||
-rw-r--r-- | vendor/fmt-3.0.1/fmt/format.h (renamed from vendor/fmt-3.0.0/fmt/format.h) | 141 | ||||
-rw-r--r-- | vendor/fmt-3.0.1/fmt/ostream.cc | 43 | ||||
-rw-r--r-- | vendor/fmt-3.0.1/fmt/ostream.h (renamed from vendor/fmt-3.0.0/fmt/ostream.h) | 20 | ||||
-rw-r--r-- | vendor/fmt-3.0.1/fmt/posix.cc (renamed from vendor/fmt-3.0.0/fmt/posix.cc) | 52 | ||||
-rw-r--r-- | vendor/fmt-3.0.1/fmt/posix.h (renamed from vendor/fmt-3.0.0/fmt/posix.h) | 31 | ||||
-rw-r--r-- | vendor/fmt-3.0.1/fmt/time.h | 53 |
11 files changed, 228 insertions, 252 deletions
@@ -1 +1 @@ -fmt-3.0.0
\ No newline at end of file +fmt-3.0.1
\ No newline at end of file diff --git a/vendor/fmt-3.0.0/fmt/ostream.cc b/vendor/fmt-3.0.0/fmt/ostream.cc deleted file mode 100644 index 0ba30347..00000000 --- a/vendor/fmt-3.0.0/fmt/ostream.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* - Formatting library for C++ - std::ostream support - - Copyright (c) 2012 - 2016, Victor Zverovich - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ostream.h" - -namespace fmt { - -namespace { -// Write the content of w to os. -void write(std::ostream &os, Writer &w) { - const char *data = w.data(); - typedef internal::MakeUnsigned<std::streamsize>::Type UnsignedStreamSize; - UnsignedStreamSize size = w.size(); - UnsignedStreamSize max_size = - internal::to_unsigned((std::numeric_limits<std::streamsize>::max)()); - do { - UnsignedStreamSize n = size <= max_size ? size : max_size; - os.write(data, static_cast<std::streamsize>(n)); - data += n; - size -= n; - } while (size != 0); -} -} - -FMT_FUNC void print(std::ostream &os, CStringRef format_str, ArgList args) { - MemoryWriter w; - w.write(format_str, args); - write(os, w); -} - -FMT_FUNC int fprintf(std::ostream &os, CStringRef format, ArgList args) { - MemoryWriter w; - printf(w, format, args); - write(os, w); - return static_cast<int>(w.size()); -} -} // namespace fmt diff --git a/vendor/fmt-3.0.0/fmt/time.h b/vendor/fmt-3.0.0/fmt/time.h deleted file mode 100644 index 863382c0..00000000 --- a/vendor/fmt-3.0.0/fmt/time.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - Formatting library for C++ - time formatting - - Copyright (c) 2012 - 2016, Victor Zverovich - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef FMT_TIME_H_ -#define FMT_TIME_H_ - -#include "fmt/format.h" -#include <ctime> - -namespace fmt { -template <typename ArgFormatter> -void format(BasicFormatter<char, ArgFormatter> &f, - const char *&format_str, const std::tm &tm) { - if (*format_str == ':') - ++format_str; - const char *end = format_str; - while (*end && *end != '}') - ++end; - if (*end != '}') - FMT_THROW(FormatError("missing '}' in format string")); - internal::MemoryBuffer<char, internal::INLINE_BUFFER_SIZE> format; - format.append(format_str, end + 1); - format[format.size() - 1] = '\0'; - Buffer<char> &buffer = f.writer().buffer(); - std::size_t start = buffer.size(); - for (;;) { - std::size_t size = buffer.capacity() - start; - std::size_t count = std::strftime(&buffer[start], size, &format[0], &tm); - if (count != 0) { - buffer.resize(start + count); - break; - } - const std::size_t MIN_GROWTH = 10; - buffer.reserve(buffer.capacity() + size > MIN_GROWTH ? size : MIN_GROWTH); - } - format_str = end + 1; -} -} - -#endif // FMT_TIME_H_ diff --git a/vendor/fmt-3.0.0/fmt/CMakeLists.txt b/vendor/fmt-3.0.1/fmt/CMakeLists.txt index c0ef02e5..89ef1f35 100644 --- a/vendor/fmt-3.0.0/fmt/CMakeLists.txt +++ b/vendor/fmt-3.0.1/fmt/CMakeLists.txt @@ -20,7 +20,7 @@ if (FMT_PEDANTIC) target_compile_options(fmt PRIVATE ${PEDANTIC_COMPILE_FLAGS}) endif () -target_include_directories(fmt INTERFACE +target_include_directories(fmt PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}> $<INSTALL_INTERFACE:include>) @@ -74,7 +74,8 @@ if (FMT_INSTALL) ${PROJECT_SOURCE_DIR}/support/cmake/fmt-config.cmake.in ${project_config} INSTALL_DESTINATION ${FMT_CMAKE_DIR}) - export(TARGETS ${INSTALL_TARGETS} FILE ${PROJECT_BINARY_DIR}/${targets_export_name}.cmake) + export(TARGETS ${INSTALL_TARGETS} + FILE ${PROJECT_BINARY_DIR}/${targets_export_name}.cmake) # Install version, config and target files. install( @@ -83,7 +84,8 @@ if (FMT_INSTALL) install(EXPORT ${targets_export_name} DESTINATION ${FMT_CMAKE_DIR}) # Install the library and headers. - install(TARGETS ${INSTALL_TARGETS} EXPORT ${targets_export_name} DESTINATION ${FMT_LIB_DIR}) + install(TARGETS ${INSTALL_TARGETS} EXPORT ${targets_export_name} + DESTINATION ${FMT_LIB_DIR}) install(FILES ${FMT_HEADERS} DESTINATION include/fmt) if (FMT_CPPFORMAT) install(TARGETS cppformat DESTINATION ${FMT_LIB_DIR}) diff --git a/vendor/fmt-3.0.0/fmt/format.cc b/vendor/fmt-3.0.1/fmt/format.cc index ae5d1103..2bd774e4 100644 --- a/vendor/fmt-3.0.0/fmt/format.cc +++ b/vendor/fmt-3.0.1/fmt/format.cc @@ -79,6 +79,11 @@ static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) { } namespace fmt { + +FMT_FUNC internal::RuntimeError::~RuntimeError() throw() {} +FMT_FUNC FormatError::~FormatError() throw() {} +FMT_FUNC SystemError::~SystemError() throw() {} + namespace { #ifndef _MSC_VER diff --git a/vendor/fmt-3.0.0/fmt/format.h b/vendor/fmt-3.0.1/fmt/format.h index 5013b810..f8ce147c 100644 --- a/vendor/fmt-3.0.0/fmt/format.h +++ b/vendor/fmt-3.0.1/fmt/format.h @@ -50,7 +50,13 @@ # include <iterator> #endif -#if defined(_MSC_VER) && _MSC_VER <= 1500 +#ifdef _MSC_VER +# define FMT_MSC_VER _MSC_VER +#else +# define FMT_MSC_VER 0 +#endif + +#if FMT_MSC_VER && FMT_MSC_VER <= 1500 typedef unsigned __int32 uint32_t; typedef unsigned __int64 uint64_t; typedef __int64 intmax_t; @@ -99,7 +105,8 @@ typedef __int64 intmax_t; #if defined(__clang__) && !defined(FMT_ICC_VERSION) # pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wdocumentation" +# pragma clang diagnostic ignored "-Wdocumentation-unknown-command" +# pragma clang diagnostic ignored "-Wpadded" #endif #ifdef __GNUC_LIBSTD__ @@ -130,7 +137,7 @@ typedef __int64 intmax_t; // since version 2013. # define FMT_USE_VARIADIC_TEMPLATES \ (FMT_HAS_FEATURE(cxx_variadic_templates) || \ - (FMT_GCC_VERSION >= 404 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1800) + (FMT_GCC_VERSION >= 404 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1800) #endif #ifndef FMT_USE_RVALUE_REFERENCES @@ -141,7 +148,7 @@ typedef __int64 intmax_t; # else # define FMT_USE_RVALUE_REFERENCES \ (FMT_HAS_FEATURE(cxx_rvalue_references) || \ - (FMT_GCC_VERSION >= 403 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1600) + (FMT_GCC_VERSION >= 403 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1600) # endif #endif @@ -153,7 +160,7 @@ typedef __int64 intmax_t; #if defined(__GNUC__) && !defined(__EXCEPTIONS) # define FMT_EXCEPTIONS 0 #endif -#if defined(_MSC_VER) && !_HAS_EXCEPTIONS +#if FMT_MSC_VER && !_HAS_EXCEPTIONS # define FMT_EXCEPTIONS 0 #endif #ifndef FMT_EXCEPTIONS @@ -177,7 +184,7 @@ typedef __int64 intmax_t; # if FMT_EXCEPTIONS # if FMT_USE_NOEXCEPT || FMT_HAS_FEATURE(cxx_noexcept) || \ (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || \ - _MSC_VER >= 1900 + FMT_MSC_VER >= 1900 # define FMT_NOEXCEPT noexcept # else # define FMT_NOEXCEPT throw() @@ -187,6 +194,17 @@ typedef __int64 intmax_t; # endif #endif +#ifndef FMT_OVERRIDE +# if FMT_USE_OVERRIDE || FMT_HAS_FEATURE(cxx_override) || \ + (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || \ + FMT_MSC_VER >= 1900 +# define FMT_OVERRIDE override +# else +# define FMT_OVERRIDE +# endif +#endif + + // A macro to disallow the copy constructor and operator= functions // This should be used in the private: declarations for a class #ifndef FMT_USE_DELETED_FUNCTIONS @@ -194,7 +212,7 @@ typedef __int64 intmax_t; #endif #if FMT_USE_DELETED_FUNCTIONS || FMT_HAS_FEATURE(cxx_deleted_functions) || \ - (FMT_GCC_VERSION >= 404 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1800 + (FMT_GCC_VERSION >= 404 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1800 # define FMT_DELETED_OR_UNDEFINED = delete # define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName&) = delete; \ @@ -214,7 +232,7 @@ typedef __int64 intmax_t; # define FMT_USE_USER_DEFINED_LITERALS \ FMT_USE_VARIADIC_TEMPLATES && FMT_USE_RVALUE_REFERENCES && \ (FMT_HAS_FEATURE(cxx_user_literals) || \ - (FMT_GCC_VERSION >= 407 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1900) && \ + (FMT_GCC_VERSION >= 407 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1900) && \ (!defined(FMT_ICC_VERSION) || FMT_ICC_VERSION >= 1500) #endif @@ -222,7 +240,6 @@ typedef __int64 intmax_t; # define FMT_ASSERT(condition, message) assert((condition) && message) #endif - #if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clz) # define FMT_BUILTIN_CLZ(n) __builtin_clz(n) #endif @@ -231,11 +248,11 @@ typedef __int64 intmax_t; # define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n) #endif -// Some compilers masquerade as both MSVC and GCC-likes or +// Some compilers masquerade as both MSVC and GCC-likes or // otherwise support __builtin_clz and __builtin_clzll, so // only define FMT_BUILTIN_CLZ using the MSVC intrinsics // if the clz and clzll builtins are not available. -#if defined(_MSC_VER) && !defined(FMT_BUILTIN_CLZLL) +#if FMT_MSC_VER && !defined(FMT_BUILTIN_CLZLL) # include <intrin.h> // _BitScanReverse, _BitScanReverse64 namespace fmt { @@ -247,7 +264,7 @@ inline uint32_t clz(uint32_t x) { assert(x != 0); // Static analysis complains about using uninitialized data - // "r", but the only way that can happen is if "x" is 0, + // "r", but the only way that can happen is if "x" is 0, // which the callers guarantee to not happen. # pragma warning(suppress: 6102) return 31 - r; @@ -273,7 +290,7 @@ inline uint32_t clzll(uint64_t x) { assert(x != 0); // Static analysis complains about using uninitialized data - // "r", but the only way that can happen is if "x" is 0, + // "r", but the only way that can happen is if "x" is 0, // which the callers guarantee to not happen. # pragma warning(suppress: 6102) return 63 - r; @@ -303,7 +320,7 @@ inline DummyInt _isnan(...) { return DummyInt(); } // A helper function to suppress bogus "conditional expression is constant" // warnings. template <typename T> -inline T check(T value) { return value; } +inline T const_check(T value) { return value; } } } // namespace fmt @@ -322,8 +339,8 @@ class numeric_limits<fmt::internal::DummyInt> : using namespace fmt::internal; // The resolution "priority" is: // isinf macro > std::isinf > ::isinf > fmt::internal::isinf - if (check(sizeof(isinf(x)) == sizeof(bool) || - sizeof(isinf(x)) == sizeof(int))) { + if (const_check(sizeof(isinf(x)) == sizeof(bool) || + sizeof(isinf(x)) == sizeof(int))) { return isinf(x) != 0; } return !_finite(static_cast<double>(x)); @@ -333,8 +350,8 @@ class numeric_limits<fmt::internal::DummyInt> : template <typename T> static bool isnotanumber(T x) { using namespace fmt::internal; - if (check(sizeof(isnan(x)) == sizeof(bool) || - sizeof(isnan(x)) == sizeof(int))) { + if (const_check(sizeof(isnan(x)) == sizeof(bool) || + sizeof(isnan(x)) == sizeof(int))) { return isnan(x) != 0; } return _isnan(static_cast<double>(x)) != 0; @@ -343,7 +360,7 @@ class numeric_limits<fmt::internal::DummyInt> : // Portable version of signbit. static bool isnegative(double x) { using namespace fmt::internal; - if (check(sizeof(signbit(x)) == sizeof(int))) + if (const_check(sizeof(signbit(x)) == sizeof(int))) return signbit(x) != 0; if (x < 0) return true; if (!isnotanumber(x)) return false; @@ -525,13 +542,12 @@ class BasicCStringRef { typedef BasicCStringRef<char> CStringRef; typedef BasicCStringRef<wchar_t> WCStringRef; -/** - A formatting error such as invalid format string. -*/ +/** A formatting error such as invalid format string. */ class FormatError : public std::runtime_error { public: explicit FormatError(CStringRef message) : std::runtime_error(message.c_str()) {} + ~FormatError() throw(); }; namespace internal { @@ -657,8 +673,8 @@ void Buffer<T>::append(const U *begin, const U *end) { namespace internal { -// A memory buffer for trivially copyable/constructible types with the first SIZE -// elements stored in the object itself. +// A memory buffer for trivially copyable/constructible types with the first +// SIZE elements stored in the object itself. template <typename T, std::size_t SIZE, typename Allocator = std::allocator<T> > class MemoryBuffer : private Allocator, public Buffer<T> { private: @@ -670,7 +686,7 @@ class MemoryBuffer : private Allocator, public Buffer<T> { } protected: - void grow(std::size_t size); + void grow(std::size_t size) FMT_OVERRIDE; public: explicit MemoryBuffer(const Allocator &alloc = Allocator()) @@ -830,6 +846,16 @@ struct FMT_API BasicData { static const char DIGITS[]; }; +#ifndef FMT_USE_EXTERN_TEMPLATES +// Clang doesn't have a feature check for extern templates so we check +// for variadic templates which were introduced in the same version. +# define FMT_USE_EXTERN_TEMPLATES (__clang__ && FMT_USE_VARIADIC_TEMPLATES) +#endif + +#if FMT_USE_EXTERN_TEMPLATES && !defined(FMT_HEADER_ONLY) +extern template struct BasicData<void>; +#endif + typedef BasicData<> Data; #ifdef FMT_BUILTIN_CLZLL @@ -918,6 +944,7 @@ inline void format_decimal(Char *buffer, UInt value, unsigned num_digits, } unsigned index = static_cast<unsigned>(value * 2); *--buffer = Data::DIGITS[index + 1]; + thousands_sep(buffer); *--buffer = Data::DIGITS[index]; } @@ -1105,6 +1132,21 @@ struct Not { enum { value = 0 }; }; template<> struct Not<false> { enum { value = 1 }; }; +template<typename T, T> struct LConvCheck { + LConvCheck(int) {} +}; + +// Returns the thousands separator for the current locale. +// We check if ``lconv`` contains ``thousands_sep`` because on Android +// ``lconv`` is stubbed as an empty struct. +template <typename LConv> +inline StringRef thousands_sep( + LConv *lc, LConvCheck<char *LConv::*, &LConv::thousands_sep> = 0) { + return lc->thousands_sep; +} + +inline fmt::StringRef thousands_sep(...) { return ""; } + // Makes an Arg object from any type. template <typename Formatter> class MakeValue : public Arg { @@ -1126,7 +1168,7 @@ class MakeValue : public Arg { // characters and strings into narrow strings as in // fmt::format("{}", L"test"); // To fix this, use a wide format string: fmt::format(L"{}", L"test"). -#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) +#if !FMT_MSC_VER || defined(_NATIVE_WCHAR_T_DEFINED) MakeValue(typename WCharHelper<wchar_t, Char>::Unsupported); #endif MakeValue(typename WCharHelper<wchar_t *, Char>::Unsupported); @@ -1172,7 +1214,7 @@ class MakeValue : public Arg { MakeValue(long value) { // To minimize the number of types we need to deal with, long is // translated either to int or to long long depending on its size. - if (check(sizeof(long) == sizeof(int))) + if (const_check(sizeof(long) == sizeof(int))) int_value = static_cast<int>(value); else long_long_value = value; @@ -1182,7 +1224,7 @@ class MakeValue : public Arg { } MakeValue(unsigned long value) { - if (check(sizeof(unsigned long) == sizeof(unsigned))) + if (const_check(sizeof(unsigned long) == sizeof(unsigned))) uint_value = static_cast<unsigned>(value); else ulong_long_value = value; @@ -1214,7 +1256,9 @@ class MakeValue : public Arg { FMT_MAKE_VALUE(char *, string.value, CSTRING) FMT_MAKE_VALUE(const char *, string.value, CSTRING) + FMT_MAKE_VALUE(signed char *, sstring.value, CSTRING) FMT_MAKE_VALUE(const signed char *, sstring.value, CSTRING) + FMT_MAKE_VALUE(unsigned char *, ustring.value, CSTRING) FMT_MAKE_VALUE(const unsigned char *, ustring.value, CSTRING) FMT_MAKE_STR_VALUE(const std::string &, STRING) FMT_MAKE_STR_VALUE(StringRef, STRING) @@ -1268,7 +1312,7 @@ public: MakeArg() { type = Arg::NONE; } - + template <typename T> MakeArg(const T &value) : Arg(MakeValue<Formatter>(value)) { @@ -1288,6 +1332,7 @@ struct NamedArg : Arg { class RuntimeError : public std::runtime_error { protected: RuntimeError() : std::runtime_error("") {} + ~RuntimeError() throw(); }; template <typename Char> @@ -1487,9 +1532,10 @@ class ArgVisitor { */ Result visit(const Arg &arg) { switch (arg.type) { - default: + case Arg::NONE: + case Arg::NAMED_ARG: FMT_ASSERT(false, "invalid argument type"); - return Result(); + break; case Arg::INT: return FMT_DISPATCH(visit_int(arg.int_value)); case Arg::UINT: @@ -1517,6 +1563,7 @@ class ArgVisitor { case Arg::CUSTOM: return FMT_DISPATCH(visit_custom(arg.custom)); } + return Result(); } }; @@ -1822,21 +1869,21 @@ class ArgFormatterBase : public ArgVisitor<Impl, void> { typedef typename BasicWriter<Char>::CharPtr CharPtr; Char fill = internal::CharTraits<Char>::cast(spec_.fill()); CharPtr out = CharPtr(); - const unsigned CHAR_WIDTH = 1; - if (spec_.width_ > CHAR_WIDTH) { + const unsigned CHAR_SIZE = 1; + if (spec_.width_ > CHAR_SIZE) { out = writer_.grow_buffer(spec_.width_); if (spec_.align_ == ALIGN_RIGHT) { - std::uninitialized_fill_n(out, spec_.width_ - CHAR_WIDTH, fill); - out += spec_.width_ - CHAR_WIDTH; + std::uninitialized_fill_n(out, spec_.width_ - CHAR_SIZE, fill); + out += spec_.width_ - CHAR_SIZE; } else if (spec_.align_ == ALIGN_CENTER) { out = writer_.fill_padding(out, spec_.width_, - internal::check(CHAR_WIDTH), fill); + internal::const_check(CHAR_SIZE), fill); } else { - std::uninitialized_fill_n(out + CHAR_WIDTH, - spec_.width_ - CHAR_WIDTH, fill); + std::uninitialized_fill_n(out + CHAR_SIZE, + spec_.width_ - CHAR_SIZE, fill); } } else { - out = writer_.grow_buffer(CHAR_WIDTH); + out = writer_.grow_buffer(CHAR_SIZE); } *out = internal::CharTraits<Char>::cast(value); } @@ -2063,7 +2110,7 @@ struct ArgArray; template <unsigned N> struct ArgArray<N, true/*IsPacked*/> { typedef Value Type[N > 0 ? N : 1]; - + template <typename Formatter, typename T> static Value make(const T &value) { #ifdef __clang__ @@ -2258,6 +2305,8 @@ class SystemError : public internal::RuntimeError { } FMT_VARIADIC_CTOR(SystemError, init, int, CStringRef) + ~SystemError() throw(); + int error_code() const { return error_code_; } }; @@ -2588,7 +2637,6 @@ void BasicWriter<Char>::write_str( if (str_size == 0) { if (!str_value) { FMT_THROW(FormatError("string pointer is null")); - return; } } std::size_t precision = static_cast<std::size_t>(spec.precision_); @@ -2753,9 +2801,12 @@ void BasicWriter<Char>::write_int(T value, Spec spec) { } case 'n': { unsigned num_digits = internal::count_digits(abs_value); - fmt::StringRef sep = std::localeconv()->thousands_sep; + fmt::StringRef sep = ""; +#ifndef ANDROID + sep = internal::thousands_sep(std::localeconv()); +#endif unsigned size = static_cast<unsigned>( - num_digits + sep.size() * (num_digits - 1) / 3); + num_digits + sep.size() * ((num_digits - 1) / 3)); CharPtr p = prepare_int_buffer(size, spec, prefix, prefix_size) + 1; internal::format_decimal(get(p), abs_value, 0, internal::ThousandsSep(sep)); break; @@ -2780,7 +2831,7 @@ void BasicWriter<Char>::write_double(T value, const FormatSpec &spec) { case 'e': case 'f': case 'g': case 'a': break; case 'F': -#ifdef _MSC_VER +#if FMT_MSC_VER // MSVC's printf doesn't support 'F'. type = 'f'; #endif @@ -2873,7 +2924,7 @@ void BasicWriter<Char>::write_double(T value, const FormatSpec &spec) { Char *start = 0; for (;;) { std::size_t buffer_size = buffer_.capacity() - offset; -#ifdef _MSC_VER +#if FMT_MSC_VER // MSVC's vsnprintf_s doesn't work with zero size, so reserve // space for at least one extra character to make the size non-zero. // Note that the buffer's capacity will increase by more than 1. diff --git a/vendor/fmt-3.0.1/fmt/ostream.cc b/vendor/fmt-3.0.1/fmt/ostream.cc new file mode 100644 index 00000000..bcb67fe1 --- /dev/null +++ b/vendor/fmt-3.0.1/fmt/ostream.cc @@ -0,0 +1,43 @@ +/* + Formatting library for C++ - std::ostream support + + Copyright (c) 2012 - 2016, Victor Zverovich + All rights reserved. + + For the license information refer to format.h. + */ + +#include "ostream.h" + +namespace fmt { + +namespace { +// Write the content of w to os. +void write(std::ostream &os, Writer &w) { + const char *data = w.data(); + typedef internal::MakeUnsigned<std::streamsize>::Type UnsignedStreamSize; + UnsignedStreamSize size = w.size(); + UnsignedStreamSize max_size = + internal::to_unsigned((std::numeric_limits<std::streamsize>::max)()); + do { + UnsignedStreamSize n = size <= max_size ? size : max_size; + os.write(data, static_cast<std::streamsize>(n)); + data += n; + size -= n; + } while (size != 0); +} +} + +FMT_FUNC void print(std::ostream &os, CStringRef format_str, ArgList args) { + MemoryWriter w; + w.write(format_str, args); + write(os, w); +} + +FMT_FUNC int fprintf(std::ostream &os, CStringRef format, ArgList args) { + MemoryWriter w; + printf(w, format, args); + write(os, w); + return static_cast<int>(w.size()); +} +} // namespace fmt diff --git a/vendor/fmt-3.0.0/fmt/ostream.h b/vendor/fmt-3.0.1/fmt/ostream.h index 458d31de..29483c1b 100644 --- a/vendor/fmt-3.0.0/fmt/ostream.h +++ b/vendor/fmt-3.0.1/fmt/ostream.h @@ -4,25 +4,7 @@ Copyright (c) 2012 - 2016, Victor Zverovich All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + For the license information refer to format.h. */ #ifndef FMT_OSTREAM_H_ diff --git a/vendor/fmt-3.0.0/fmt/posix.cc b/vendor/fmt-3.0.1/fmt/posix.cc index 1ec746a4..76eb7f05 100644 --- a/vendor/fmt-3.0.0/fmt/posix.cc +++ b/vendor/fmt-3.0.1/fmt/posix.cc @@ -1,28 +1,10 @@ /* A C++ interface to POSIX functions. - Copyright (c) 2014 - 2016, Victor Zverovich + Copyright (c) 2012 - 2016, Victor Zverovich All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + For the license information refer to format.h. */ // Disable bogus MSVC warnings. @@ -90,7 +72,7 @@ fmt::BufferedFile::BufferedFile( fmt::CStringRef filename, fmt::CStringRef mode) { FMT_RETRY_VAL(file_, FMT_SYSTEM(fopen(filename.c_str(), mode.c_str())), 0); if (!file_) - throw SystemError(errno, "cannot open file {}", filename); + FMT_THROW(SystemError(errno, "cannot open file {}", filename)); } void fmt::BufferedFile::close() { @@ -99,7 +81,7 @@ void fmt::BufferedFile::close() { int result = FMT_SYSTEM(fclose(file_)); file_ = 0; if (result != 0) - throw SystemError(errno, "cannot close file"); + FMT_THROW(SystemError(errno, "cannot close file")); } // A macro used to prevent expansion of fileno on broken versions of MinGW. @@ -108,7 +90,7 @@ void fmt::BufferedFile::close() { int fmt::BufferedFile::fileno() const { int fd = FMT_POSIX_CALL(fileno FMT_ARGS(file_)); if (fd == -1) - throw SystemError(errno, "cannot get file descriptor"); + FMT_THROW(SystemError(errno, "cannot get file descriptor")); return fd; } @@ -121,7 +103,7 @@ fmt::File::File(fmt::CStringRef path, int oflag) { FMT_RETRY(fd_, FMT_POSIX_CALL(open(path.c_str(), oflag, mode))); #endif if (fd_ == -1) - throw SystemError(errno, "cannot open file {}", path); + FMT_THROW(SystemError(errno, "cannot open file {}", path)); } fmt::File::~File() FMT_NOEXCEPT { @@ -139,7 +121,7 @@ void fmt::File::close() { int result = FMT_POSIX_CALL(close(fd_)); fd_ = -1; if (result != 0) - throw SystemError(errno, "cannot close file"); + FMT_THROW(SystemError(errno, "cannot close file")); } fmt::LongLong fmt::File::size() const { @@ -153,7 +135,7 @@ fmt::LongLong fmt::File::size() const { if (size_lower == INVALID_FILE_SIZE) { DWORD error = GetLastError(); if (error != NO_ERROR) - throw WindowsError(GetLastError(), "cannot get file size"); + FMT_THROW(WindowsError(GetLastError(), "cannot get file size")); } fmt::ULongLong long_size = size_upper; return (long_size << sizeof(DWORD) * CHAR_BIT) | size_lower; @@ -161,7 +143,7 @@ fmt::LongLong fmt::File::size() const { typedef struct stat Stat; Stat file_stat = Stat(); if (FMT_POSIX_CALL(fstat(fd_, &file_stat)) == -1) - throw SystemError(errno, "cannot get file attributes"); + FMT_THROW(SystemError(errno, "cannot get file attributes")); FMT_STATIC_ASSERT(sizeof(fmt::LongLong) >= sizeof(file_stat.st_size), "return type of File::size is not large enough"); return file_stat.st_size; @@ -172,7 +154,7 @@ std::size_t fmt::File::read(void *buffer, std::size_t count) { RWResult result = 0; FMT_RETRY(result, FMT_POSIX_CALL(read(fd_, buffer, convert_rwcount(count)))); if (result < 0) - throw SystemError(errno, "cannot read from file"); + FMT_THROW(SystemError(errno, "cannot read from file")); return internal::to_unsigned(result); } @@ -180,7 +162,7 @@ std::size_t fmt::File::write(const void *buffer, std::size_t count) { RWResult result = 0; FMT_RETRY(result, FMT_POSIX_CALL(write(fd_, buffer, convert_rwcount(count)))); if (result < 0) - throw SystemError(errno, "cannot write to file"); + FMT_THROW(SystemError(errno, "cannot write to file")); return internal::to_unsigned(result); } @@ -189,7 +171,7 @@ fmt::File fmt::File::dup(int fd) { // http://pubs.opengroup.org/onlinepubs/009695399/functions/dup.html int new_fd = FMT_POSIX_CALL(dup(fd)); if (new_fd == -1) - throw SystemError(errno, "cannot duplicate file descriptor {}", fd); + FMT_THROW(SystemError(errno, "cannot duplicate file descriptor {}", fd)); return File(new_fd); } @@ -197,8 +179,8 @@ void fmt::File::dup2(int fd) { int result = 0; FMT_RETRY(result, FMT_POSIX_CALL(dup2(fd_, fd))); if (result == -1) { - throw SystemError(errno, - "cannot duplicate file descriptor {} to {}", fd_, fd); + FMT_THROW(SystemError(errno, + "cannot duplicate file descriptor {} to {}", fd_, fd)); } } @@ -225,7 +207,7 @@ void fmt::File::pipe(File &read_end, File &write_end) { int result = FMT_POSIX_CALL(pipe(fds)); #endif if (result != 0) - throw SystemError(errno, "cannot create pipe"); + FMT_THROW(SystemError(errno, "cannot create pipe")); // The following assignments don't throw because read_fd and write_fd // are closed. read_end = File(fds[0]); @@ -236,7 +218,7 @@ fmt::BufferedFile fmt::File::fdopen(const char *mode) { // Don't retry as fdopen doesn't return EINTR. FILE *f = FMT_POSIX_CALL(fdopen(fd_, mode)); if (!f) - throw SystemError(errno, "cannot associate stream with file descriptor"); + FMT_THROW(SystemError(errno, "cannot associate stream with file descriptor")); BufferedFile file(f); fd_ = -1; return file; @@ -250,7 +232,7 @@ long fmt::getpagesize() { #else long size = FMT_POSIX_CALL(sysconf(_SC_PAGESIZE)); if (size < 0) - throw SystemError(errno, "cannot get memory page size"); + FMT_THROW(SystemError(errno, "cannot get memory page size")); return size; #endif } diff --git a/vendor/fmt-3.0.0/fmt/posix.h b/vendor/fmt-3.0.1/fmt/posix.h index ab6d12e8..be1286c4 100644 --- a/vendor/fmt-3.0.0/fmt/posix.h +++ b/vendor/fmt-3.0.1/fmt/posix.h @@ -1,34 +1,16 @@ /* A C++ interface to POSIX functions. - Copyright (c) 2014 - 2016, Victor Zverovich + Copyright (c) 2012 - 2016, Victor Zverovich All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + For the license information refer to format.h. */ #ifndef FMT_POSIX_H_ #define FMT_POSIX_H_ -#ifdef __MINGW32__ +#if defined(__MINGW32__) || defined(__CYGWIN__) // Workaround MinGW bug https://sourceforge.net/p/mingw/bugs/2024/. # undef __STRICT_ANSI__ #endif @@ -41,7 +23,7 @@ #include <cstddef> -#ifdef __APPLE__ +#if defined __APPLE__ || defined(__FreeBSD__) # include <xlocale.h> // for LC_NUMERIC_MASK on OS X #endif @@ -339,7 +321,8 @@ class File { // Returns the memory page size. long getpagesize(); -#if defined(LC_NUMERIC_MASK) || defined(_MSC_VER) +#if (defined(LC_NUMERIC_MASK) || defined(_MSC_VER)) && \ + !defined(__ANDROID__) && !defined(__CYGWIN__) # define FMT_LOCALE #endif @@ -374,7 +357,7 @@ class Locale { Locale() : locale_(newlocale(LC_NUMERIC_MASK, "C", NULL)) { if (!locale_) - throw fmt::SystemError(errno, "cannot create locale"); + FMT_THROW(fmt::SystemError(errno, "cannot create locale")); } ~Locale() { freelocale(locale_); } diff --git a/vendor/fmt-3.0.1/fmt/time.h b/vendor/fmt-3.0.1/fmt/time.h new file mode 100644 index 00000000..10225c03 --- /dev/null +++ b/vendor/fmt-3.0.1/fmt/time.h @@ -0,0 +1,53 @@ +/* + Formatting library for C++ - time formatting + + Copyright (c) 2012 - 2016, Victor Zverovich + All rights reserved. + + For the license information refer to format.h. + */ + +#ifndef FMT_TIME_H_ +#define FMT_TIME_H_ + +#include "format.h" +#include <ctime> + +namespace fmt { +template <typename ArgFormatter> +void format(BasicFormatter<char, ArgFormatter> &f, + const char *&format_str, const std::tm &tm) { + if (*format_str == ':') + ++format_str; + const char *end = format_str; + while (*end && *end != '}') + ++end; + if (*end != '}') + FMT_THROW(FormatError("missing '}' in format string")); + internal::MemoryBuffer<char, internal::INLINE_BUFFER_SIZE> format; + format.append(format_str, end + 1); + format[format.size() - 1] = '\0'; + Buffer<char> &buffer = f.writer().buffer(); + std::size_t start = buffer.size(); + for (;;) { + std::size_t size = buffer.capacity() - start; + std::size_t count = std::strftime(&buffer[start], size, &format[0], &tm); + if (count != 0) { + buffer.resize(start + count); + break; + } + if (size >= format.size() * 256) { + // If the buffer is 256 times larger than the format string, assume + // that `strftime` gives an empty result. There doesn't seem to be a + // better way to distinguish the two cases: + // https://github.com/fmtlib/fmt/issues/367 + break; + } + const std::size_t MIN_GROWTH = 10; + buffer.reserve(buffer.capacity() + (size > MIN_GROWTH ? size : MIN_GROWTH)); + } + format_str = end + 1; +} +} + +#endif // FMT_TIME_H_ |