From bb6305d1c40b8d75e1d58bc57811479d1d2986c9 Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Sun, 24 Mar 2024 17:54:20 +0100 Subject: [Core] Fix incorrect file sort method --- core/string/ustring.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'core/string') diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 93a08fd8b5..bdef1b9bbe 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -1043,12 +1043,11 @@ signed char String::naturalnocasecmp_to(const String &p_str) const { static _FORCE_INLINE_ signed char file_cmp_common(const char32_t *&r_this_str, const char32_t *&r_that_str) { // Compare leading `_` sequences. - while (*r_this_str && *r_that_str) { + while ((*r_this_str == '_' && *r_that_str) || (*r_this_str && *r_that_str == '_')) { // Sort `_` lower than everything except `.` - if (*r_this_str != '_' && *r_that_str == '_') { + if (*r_this_str != '_') { return *r_this_str == '.' ? -1 : 1; - } - if (*r_this_str == '_' && *r_that_str != '_') { + } else if (*r_that_str != '_') { return *r_that_str == '.' ? 1 : -1; } r_this_str++; -- cgit v1.2.3