This commit is contained in:
IRainman 2025-03-12 21:13:20 +03:00
parent 1ab438cf7a
commit 929e98182e
2 changed files with 11 additions and 13 deletions

View File

@ -23,10 +23,11 @@ namespace detail {
template <typename T, typename UC>
from_chars_result_t<UC>
FASTFLOAT_CONSTEXPR14 parse_infnan(UC const *first, UC const *last,
T &value, const chars_format fmt) noexcept {
T &value,
const chars_format fmt) noexcept {
from_chars_result_t<UC> answer{};
answer.ptr = first;
answer.ec = std::errc(); // be optimistic
answer.ec = std::errc(); // be optimistic
FASTFLOAT_ASSUME(first < last); // so dereference without checks
bool const minusSign = (*first == UC('-'));
@ -254,9 +255,9 @@ from_chars_advanced(parsed_number_string_t<UC> const &pns, T &value) noexcept {
if (pns.mantissa == 0) {
value =
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
pns.negative ? T(-0.) :
pns.negative ? T(-0.) :
#endif
T(0.);
T(0.);
return answer;
}
#endif
@ -286,9 +287,9 @@ from_chars_advanced(parsed_number_string_t<UC> const &pns, T &value) noexcept {
}
to_float(
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
pns.negative,
pns.negative,
#endif
am, value);
am, value);
// Test for over/underflow.
if ((pns.mantissa != 0 && am.mantissa == 0 && am.power2 == 0) ||
am.power2 == binary_format<T>::infinite_power()) {
@ -329,7 +330,7 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value,
? parse_number_string<true, UC>(first, last, options)
:
#endif
parse_number_string<false, UC>(first, last, options);
parse_number_string<false, UC>(first, last, options);
if (!pns.valid) {
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
if (uint64_t(options.format & chars_format::no_infnan)) {

View File

@ -656,8 +656,7 @@ TEST_CASE("decimal_point_parsing") {
answer = fast_float::from_chars_advanced(
input.data(), input.data() + input.size(), result,
fast_float::parse_options(fast_float::chars_format::general, ',', 10)
);
fast_float::parse_options(fast_float::chars_format::general, ',', 10));
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
CHECK_MESSAGE(answer.ptr == input.data() + input.size(),
"Parsing should have stopped at end");
@ -667,8 +666,7 @@ TEST_CASE("decimal_point_parsing") {
std::string const input = "1.25";
auto answer = fast_float::from_chars_advanced(
input.data(), input.data() + input.size(), result,
fast_float::parse_options(fast_float::chars_format::general, ',', 10)
);
fast_float::parse_options(fast_float::chars_format::general, ',', 10));
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
CHECK_MESSAGE(answer.ptr == input.data() + 1,
"Parsing should have stopped at dot");
@ -676,8 +674,7 @@ TEST_CASE("decimal_point_parsing") {
answer = fast_float::from_chars_advanced(
input.data(), input.data() + input.size(), result,
fast_float::parse_options{}
);
fast_float::parse_options{});
CHECK_MESSAGE(answer.ec == std::errc(), "expected parse success");
CHECK_MESSAGE(answer.ptr == input.data() + input.size(),
"Parsing should have stopped at end");