Skip to content

Commit 7ff885d

Browse files
committed
fix for is_space for wchar_t and larger char types
1 parent 3e26cf4 commit 7ff885d

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

include/fast_float/float_common.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,9 @@ template <typename T> constexpr bool space_lut<T>::value[];
699699

700700
#endif
701701

702-
inline constexpr bool is_space(uint8_t c) { return space_lut<>::value[c]; }
702+
template <typename UC> constexpr bool is_space(UC c) {
703+
return c < 256 && space_lut<>::value[uint8_t(c)];
704+
}
703705

704706
template <typename UC> static constexpr uint64_t int_cmp_zeros() {
705707
static_assert((sizeof(UC) == 1) || (sizeof(UC) == 2) || (sizeof(UC) == 4),

include/fast_float/parse_number.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value,
294294

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

347347
from_chars_result_t<UC> answer;
348348
if (uint64_t(fmt & chars_format::skip_white_space)) {
349-
while ((first != last) && fast_float::is_space(uint8_t(*first))) {
349+
while ((first != last) && fast_float::is_space(*first)) {
350350
first++;
351351
}
352352
}

tests/rcppfastfloat_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ bool eddelbuettel() {
7575
// check that there is no content left
7676
for (const char *leftover = answer.ptr;
7777
leftover != input.data() + input.size(); leftover++) {
78-
if (!fast_float::is_space(uint8_t(*leftover))) {
78+
if (!fast_float::is_space(*leftover)) {
7979
non_space_trailing_content = true;
8080
break;
8181
}

0 commit comments

Comments
 (0)