fix for is_space for wchar_t and larger char types

This commit is contained in:
Anders Dalvander 2024-11-20 13:40:39 +01:00
parent 3e26cf4cea
commit 7ff885d45c
3 changed files with 6 additions and 4 deletions

View File

@ -699,7 +699,9 @@ template <typename T> constexpr bool space_lut<T>::value[];
#endif
inline constexpr bool is_space(uint8_t c) { return space_lut<>::value[c]; }
template <typename UC> constexpr bool is_space(UC c) {
return c < 256 && space_lut<>::value[uint8_t(c)];
}
template <typename UC> static constexpr uint64_t int_cmp_zeros() {
static_assert((sizeof(UC) == 1) || (sizeof(UC) == 2) || (sizeof(UC) == 4),

View File

@ -294,7 +294,7 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value,
from_chars_result_t<UC> answer;
if (uint64_t(fmt & chars_format::skip_white_space)) {
while ((first != last) && fast_float::is_space(uint8_t(*first))) {
while ((first != last) && fast_float::is_space(*first)) {
first++;
}
}
@ -346,7 +346,7 @@ from_chars_int_advanced(UC const *first, UC const *last, T &value,
from_chars_result_t<UC> answer;
if (uint64_t(fmt & chars_format::skip_white_space)) {
while ((first != last) && fast_float::is_space(uint8_t(*first))) {
while ((first != last) && fast_float::is_space(*first)) {
first++;
}
}

View File

@ -75,7 +75,7 @@ bool eddelbuettel() {
// check that there is no content left
for (const char *leftover = answer.ptr;
leftover != input.data() + input.size(); leftover++) {
if (!fast_float::is_space(uint8_t(*leftover))) {
if (!fast_float::is_space(*leftover)) {
non_space_trailing_content = true;
break;
}