Merge pull request #10399 from JJenkx/windows/libc-strcoll-byte-difference

fix(libc): return the byte difference from strcoll as titles' libc.prx does
This commit is contained in:
Dean authored and GitHub committed 2026-10-26 13:31:16 +13:00
commit 9c435c2812
2 files changed
+7 -1

No files matched your search

+5 -1
View File
@@ -487,7 +487,11 @@ size_t APS5_VABI strspn_nid_postfix(const char* s, const char* accept) {
}
int APS5_VABI strcoll_nid_postfix(const char* s1, const char* s2) {
return std::strcmp(s1, s2);
for (;; ++s1, ++s2) {
const int a = static_cast<unsigned char>(*s1);
const int b = static_cast<unsigned char>(*s2);
if (a != b || a == 0) return a - b;
}
}
int APS5_VABI strncpy_s_nid_postfix(char* dest, size_t destsz, const char* src, size_t count) {
+2
View File
@@ -176,6 +176,8 @@ static void CheckSecureStringSizeLimits() {
}
static void CheckCaseInsensitiveComparison() {
Require(strcoll_nid_postfix("a", "z") == -25 && strcoll_nid_postfix("z", "a") == 25 && strcoll_nid_postfix("ab", "abc") == -99);
Require(strcoll_nid_postfix("A", "a") == -32 && strcoll_nid_postfix("same", "same") == 0 && strcoll_nid_postfix("\xff", "\x01") == 254);
Require(strcasecmp_nid_postfix("", "") == 0 && strcasecmp_nid_postfix("AbC", "aBc") == 0);
Require(strcasecmp_nid_postfix("A", "b") == -1 && strcasecmp_nid_postfix("b", "A") == 1);
Require(strcasecmp_nid_postfix("ab", "A") == 1 && strcasecmp_nid_postfix("AB", "a") == 1);