mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 08:46:49 +08:00
fix #276: parse_infnan handles FASTFLOAT_ALLOWS_LEADING_PLUS correctly
This commit is contained in:
parent
72b2a7382a
commit
23787fc71a
@ -8,3 +8,4 @@ Lénárd Szolnoki
|
||||
Jan Pharago
|
||||
Maya Warrier
|
||||
Taha Khokhar
|
||||
Anders Dalvander
|
||||
|
||||
@ -25,18 +25,15 @@ from_chars_result_t<UC> FASTFLOAT_CONSTEXPR14 parse_infnan(UC const *first,
|
||||
from_chars_result_t<UC> answer{};
|
||||
answer.ptr = first;
|
||||
answer.ec = std::errc(); // be optimistic
|
||||
bool minusSign = false;
|
||||
if (*first ==
|
||||
UC('-')) { // assume first < last, so dereference without checks;
|
||||
// C++17 20.19.3.(7.1) explicitly forbids '+' here
|
||||
minusSign = true;
|
||||
++first;
|
||||
}
|
||||
bool const minusSign = (*first == UC('-')); // assume first < last, so dereference without checks;
|
||||
#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default
|
||||
if (*first == UC('+')) {
|
||||
if ((*first == UC('-')) || (*first == UC('+'))) {
|
||||
#else
|
||||
// C++17 20.19.3.(7.1) explicitly forbids '+' sign here
|
||||
if (*first == UC('-')) {
|
||||
#endif
|
||||
++first;
|
||||
}
|
||||
#endif
|
||||
if (last - first >= 3) {
|
||||
if (fastfloat_strncasecmp(first, str_const_nan<UC>(), 3)) {
|
||||
answer.ptr = (first += 3);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user