Merge de5b4812b2 into 58a300c82a
This commit is contained in:
commit
ad938add8a
@ -66,8 +66,10 @@ using fmt::internal::Arg;
|
||||
#ifndef FMT_THROW
|
||||
# if FMT_EXCEPTIONS
|
||||
# define FMT_THROW(x) throw x
|
||||
# define FMT_RETURNAFTERTHROW(x)
|
||||
# else
|
||||
# define FMT_THROW(x) assert(false)
|
||||
# define FMT_RETURNAFTERTHROW(x) return x
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -251,7 +253,7 @@ class WidthHandler : public fmt::internal::ArgVisitor<WidthHandler, unsigned> {
|
||||
|
||||
unsigned visit_unhandled_arg() {
|
||||
FMT_THROW(fmt::FormatError("width is not integer"));
|
||||
return 0;
|
||||
FMT_RETURNAFTERTHROW(0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -273,7 +275,7 @@ class PrecisionHandler :
|
||||
public:
|
||||
unsigned visit_unhandled_arg() {
|
||||
FMT_THROW(fmt::FormatError("precision is not integer"));
|
||||
return 0;
|
||||
FMT_RETURNAFTERTHROW(0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -625,7 +627,7 @@ void fmt::BasicWriter<Char>::write_str(
|
||||
if (*str_value)
|
||||
str_size = std::char_traits<StrChar>::length(str_value);
|
||||
}
|
||||
if (spec.precision_ >= 0 && spec.precision_ < str_size)
|
||||
if (spec.precision_ >= 0 && static_cast<std::size_t>(spec.precision_) < str_size)
|
||||
str_size = spec.precision_;
|
||||
write_str(str_value, str_size, spec);
|
||||
}
|
||||
|
||||
17
format.h
17
format.h
@ -60,6 +60,16 @@
|
||||
# define FMT_GCC_EXTENSION
|
||||
#endif
|
||||
|
||||
#define FMT_CLANGFALLTHROUGH
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
|
||||
#ifdef NDEBUG
|
||||
#undef FMT_CLANGFALLTHROUGH
|
||||
#define FMT_CLANGFALLTHROUGH [[clang::fallthrough]];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC_LIBSTD__
|
||||
# define FMT_GNUC_LIBSTD_VERSION (__GNUC_LIBSTD__ * 100 + __GNUC_LIBSTD_MINOR__)
|
||||
#endif
|
||||
@ -865,7 +875,8 @@ class ArgVisitor {
|
||||
default:
|
||||
assert(false);
|
||||
// Fall through.
|
||||
case Arg::INT:
|
||||
FMT_CLANGFALLTHROUGH
|
||||
case Arg::INT:
|
||||
return FMT_DISPATCH(visit_int(arg.int_value));
|
||||
case Arg::UINT:
|
||||
return FMT_DISPATCH(visit_uint(arg.uint_value));
|
||||
@ -2442,6 +2453,10 @@ FMT_VARIADIC(int, fprintf, std::FILE *, StringRef)
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#ifdef FMT_HEADER_ONLY
|
||||
# include "format.cc"
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user