forked from fmtlib/fmt
Fix warnings
This commit is contained in:
@ -385,9 +385,9 @@ inline bool isnan(T value) {
|
|||||||
return std::isnan(value);
|
return std::isnan(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> inline int to_int(T value) {
|
// Convers value to int and checks that it's in the range [0, upper).
|
||||||
FMT_ASSERT(isnan(value) || (value >= (std::numeric_limits<int>::min)() &&
|
template <typename T> inline int to_int(T value, int upper) {
|
||||||
value <= (std::numeric_limits<int>::max)()),
|
FMT_ASSERT(isnan(value) || (value >= 0 && value <= upper),
|
||||||
"invalid value");
|
"invalid value");
|
||||||
return static_cast<int>(value);
|
return static_cast<int>(value);
|
||||||
}
|
}
|
||||||
@ -483,9 +483,9 @@ struct chrono_formatter {
|
|||||||
|
|
||||||
std::tm time() const {
|
std::tm time() const {
|
||||||
auto time = std::tm();
|
auto time = std::tm();
|
||||||
time.tm_hour = to_int(hour());
|
time.tm_hour = to_int(hour(), 24);
|
||||||
time.tm_min = to_int(minute());
|
time.tm_min = to_int(minute(), 60);
|
||||||
time.tm_sec = to_int(second());
|
time.tm_sec = to_int(second(), 60);
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ struct chrono_formatter {
|
|||||||
write_sign();
|
write_sign();
|
||||||
if (isnan(value)) return write_nan();
|
if (isnan(value)) return write_nan();
|
||||||
typedef typename int_traits<int>::main_type main_type;
|
typedef typename int_traits<int>::main_type main_type;
|
||||||
main_type n = to_unsigned(to_int(value));
|
main_type n = to_unsigned(to_int(value, (std::numeric_limits<int>::max)()));
|
||||||
int num_digits = internal::count_digits(n);
|
int num_digits = internal::count_digits(n);
|
||||||
if (width > num_digits) out = std::fill_n(out, width - num_digits, '0');
|
if (width > num_digits) out = std::fill_n(out, width - num_digits, '0');
|
||||||
out = format_decimal<char_type>(out, n, num_digits);
|
out = format_decimal<char_type>(out, n, num_digits);
|
||||||
@ -541,21 +541,21 @@ struct chrono_formatter {
|
|||||||
void on_24_hour(numeric_system ns) {
|
void on_24_hour(numeric_system ns) {
|
||||||
if (ns == numeric_system::standard) return write(hour(), 2);
|
if (ns == numeric_system::standard) return write(hour(), 2);
|
||||||
auto time = tm();
|
auto time = tm();
|
||||||
time.tm_hour = to_int(hour());
|
time.tm_hour = to_int(hour(), 24);
|
||||||
format_localized(time, "%OH");
|
format_localized(time, "%OH");
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_12_hour(numeric_system ns) {
|
void on_12_hour(numeric_system ns) {
|
||||||
if (ns == numeric_system::standard) return write(hour12(), 2);
|
if (ns == numeric_system::standard) return write(hour12(), 2);
|
||||||
auto time = tm();
|
auto time = tm();
|
||||||
time.tm_hour = to_int(hour12());
|
time.tm_hour = to_int(hour12(), 12);
|
||||||
format_localized(time, "%OI");
|
format_localized(time, "%OI");
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_minute(numeric_system ns) {
|
void on_minute(numeric_system ns) {
|
||||||
if (ns == numeric_system::standard) return write(minute(), 2);
|
if (ns == numeric_system::standard) return write(minute(), 2);
|
||||||
auto time = tm();
|
auto time = tm();
|
||||||
time.tm_min = to_int(minute());
|
time.tm_min = to_int(minute(), 60);
|
||||||
format_localized(time, "%OM");
|
format_localized(time, "%OM");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,7 +570,7 @@ struct chrono_formatter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto time = tm();
|
auto time = tm();
|
||||||
time.tm_sec = to_int(second());
|
time.tm_sec = to_int(second(), 60);
|
||||||
format_localized(time, "%OS");
|
format_localized(time, "%OS");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <iterator>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@ -94,10 +95,6 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if FMT_SECURE_SCL
|
|
||||||
# include <iterator>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __has_builtin
|
#ifdef __has_builtin
|
||||||
# define FMT_HAS_BUILTIN(x) __has_builtin(x)
|
# define FMT_HAS_BUILTIN(x) __has_builtin(x)
|
||||||
#else
|
#else
|
||||||
|
Reference in New Issue
Block a user