Skip to content

Commit 50ee38a

Browse files
committed
fix for fastfloat_strncasecmp for wchar_t and larger char types
1 parent 7ff885d commit 50ee38a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

include/fast_float/float_common.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,15 @@ fastfloat_really_inline constexpr bool is_supported_char_type() {
222222
// Compares two ASCII strings in a case insensitive manner.
223223
template <typename UC>
224224
inline FASTFLOAT_CONSTEXPR14 bool
225-
fastfloat_strncasecmp(UC const *input1, UC const *input2, size_t length) {
226-
char running_diff{0};
225+
fastfloat_strncasecmp(UC const *actual_mixedcase, UC const *expected_lowercase,
226+
size_t length) {
227227
for (size_t i = 0; i < length; ++i) {
228-
running_diff |= (char(input1[i]) ^ char(input2[i]));
228+
UC const actual = actual_mixedcase[i];
229+
if ((actual < 256 ? actual | 32 : actual) != expected_lowercase[i]) {
230+
return false;
231+
}
229232
}
230-
return (running_diff == 0) || (running_diff == 32);
233+
return true;
231234
}
232235

233236
#ifndef FLT_EVAL_METHOD

0 commit comments

Comments
 (0)