Skip to content
Prev Previous commit
Next Next commit
fix for is_space for wchar_t and larger char types
  • Loading branch information
dalle committed Nov 20, 2024
commit 7ff885d45ca93ce16d7d665094707b1a5df60652
4 changes: 3 additions & 1 deletion include/fast_float/float_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions include/fast_float/parse_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
Expand Down Expand Up @@ -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++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/rcppfastfloat_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down