Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Attila Mark 2020-02-06 22:43:21 -08:00
commit 57763d0fe2
6 changed files with 33 additions and 19 deletions

View File

@ -176,17 +176,17 @@ target_include_directories(fmt PUBLIC
set(FMT_DEBUG_POSTFIX d)
set(FMT_DEBUG_POSTFIX d)
set_target_properties(fmt PROPERTIES
OUTPUT_NAME fmt
VERSION ${FMT_VERSION}
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}
VERSION ${FMT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}
DEBUG_POSTFIX ${FMT_DEBUG_POSTFIX})
# Configure pkg-config fmt.pc properly
# Set FMT_LIB_NAME for pkg-config fmt.pc.
get_target_property(FMT_LIB_NAME fmt OUTPUT_NAME)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(FMT_LIB_NAME ${FMT_LIB_NAME}${FMT_DEBUG_POSTFIX})
endif()
endif ()
if (BUILD_SHARED_LIBS)
if (UNIX AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS")

View File

@ -33,7 +33,7 @@ Features
* Safe `printf implementation
<https://fmt.dev/latest/api.html#printf-formatting>`_ including
the POSIX extension for positional arguments.
* Implementation of `C++20 std::format <https://fmt.dev/Text%20Formatting.html>`__.
* Implementation of `C++20 std::format <https://en.cppreference.com/w/cpp/utility/format>`__.
* Support for user-defined types.
* High performance: faster than common standard library implementations of
`printf <https://en.cppreference.com/w/cpp/io/c/fprintf>`_ and

View File

@ -495,12 +495,12 @@ FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin,
handler.on_text(ptr - 1, ptr);
break;
case 'n': {
const Char newline[]{'\n', 0};
const Char newline[] = {'\n'};
handler.on_text(newline, newline + 1);
break;
}
case 't': {
const Char tab[]{'\t', 0};
const Char tab[] = {'\t'};
handler.on_text(tab, tab + 1);
break;
}
@ -761,10 +761,10 @@ inline std::chrono::duration<Rep, std::milli> get_milliseconds(
template <typename Char, typename Rep, typename OutputIt>
OutputIt format_duration_value(OutputIt out, Rep val, int precision) {
const Char pr_f[]{'{', ':', '.', '{', '}', 'f', '}', 0};
const Char pr_f[] = {'{', ':', '.', '{', '}', 'f', '}', 0};
if (precision >= 0) return format_to(out, pr_f, val, precision);
const Char fp_f[]{'{', ':', 'g', '}', 0};
const Char format[]{'{', '}', 0};
const Char fp_f[] = {'{', ':', 'g', '}', 0};
const Char format[] = {'{', '}', 0};
return format_to(out, std::is_floating_point<Rep>::value ? fp_f : format,
val);
}
@ -779,9 +779,9 @@ OutputIt format_duration_unit(OutputIt out) {
}
return std::copy(s.begin(), s.end(), out);
}
const Char num_f[]{'[', '{', '}', ']', 's', 0};
const Char num_f[] = {'[', '{', '}', ']', 's', 0};
if (Period::den == 1) return format_to(out, num_f, Period::num);
const Char num_def_f[]{'[', '{', '}', '/', '{', '}', ']', 's', 0};
const Char num_def_f[] = {'[', '{', '}', '/', '{', '}', ']', 's', 0};
return format_to(out, num_def_f, Period::num, Period::den);
}

View File

@ -185,11 +185,20 @@
# define FMT_CLASS_API
#endif
#ifndef FMT_API
# define FMT_API
# if FMT_GCC_VERSION || FMT_CLANG_VERSION
# define FMT_API __attribute__((visibility("default")))
# define FMT_EXTERN_TEMPLATE_API FMT_API
# define FMT_INSTANTIATION_DEF_API
# else
# define FMT_API
# endif
#endif
#ifndef FMT_EXTERN_TEMPLATE_API
# define FMT_EXTERN_TEMPLATE_API
#endif
#ifndef FMT_INSTANTIATION_DEF_API
# define FMT_INSTANTIATION_DEF_API FMT_API
#endif
#ifndef FMT_HEADER_ONLY
# define FMT_EXTERN extern
@ -304,7 +313,8 @@ template <typename Char> class basic_string_view {
size_t size_;
public:
using char_type = Char;
using char_type FMT_DEPRECATED_ALIAS = Char;
using value_type = Char;
using iterator = const Char*;
FMT_CONSTEXPR basic_string_view() FMT_NOEXCEPT : data_(nullptr), size_(0) {}
@ -462,7 +472,7 @@ struct is_string : std::is_class<decltype(to_string_view(std::declval<S>()))> {
template <typename S, typename = void> struct char_t_impl {};
template <typename S> struct char_t_impl<S, enable_if_t<is_string<S>::value>> {
using result = decltype(to_string_view(std::declval<S>()));
using type = typename result::char_type;
using type = typename result::value_type;
};
struct error_handler {

View File

@ -121,7 +121,7 @@ template FMT_API char* internal::sprintf_format(long double,
internal::buffer<char>&,
sprintf_specs);
template struct FMT_API internal::basic_data<void>;
template struct FMT_INSTANTIATION_DEF_API internal::basic_data<void>;
// Workaround a bug in MSVC2013 that prevents instantiation of format_float.
int (*instantiate_format_float)(double, int, internal::float_specs,

View File

@ -402,8 +402,12 @@ TEST(ArgTest, VisitInvalidArg) {
fmt::visit_format_arg(visitor, arg);
}
TEST(StringViewTest, ValueType) {
static_assert(std::is_same<string_view::value_type, char>::value, "");
}
TEST(StringViewTest, Length) {
// Test that StringRef::size() returns string length, not buffer size.
// Test that string_view::size() returns string length, not buffer size.
char str[100] = "some string";
EXPECT_EQ(std::strlen(str), string_view(str).size());
EXPECT_LT(std::strlen(str), sizeof(str));