string: fix char16_t/char16_t strncmp
Some checks failed
Doxygen Action / build (push) Has been cancelled

Signed-off-by: Simon Rozman <simon.rozman@amebis.si>
This commit is contained in:
2025-12-12 18:44:11 +01:00
parent 655bee3692
commit 9e9209c55b

View File

@@ -993,8 +993,6 @@ namespace stdex
utf32_t a, b;
for (i = 0, j = 0; i < count1 && j < count2; ++i, j = j_next) {
a = str1[i];
if (!a)
break;
if (j + 1 >= count2 || !is_surrogate_pair(&str2[j])) {
b = static_cast<utf32_t>(str2[j]);
j_next = j + 1;
@@ -1003,8 +1001,7 @@ namespace stdex
b = surrogate_pair_to_ucs4(&str2[j]);
j_next = j + 2;
}
if (!b)
break;
if (!a && !b) return 0;
if (a > b) return +1;
if (a < b) return -1;
}
@@ -1082,32 +1079,32 @@ namespace stdex
{
stdex_assert(str1 || !count1);
stdex_assert(str2 || !count2);
for (size_t i = 0, j = 0; ;) {
if (i >= count1 && j >= count2) return 0;
if (i >= count1 && j < count2) return -1;
if (i < count1 && j >= count2) return +1;
utf32_t a;
size_t i, i_next, j, j_next;
utf32_t a, b;
for (i = 0, j = 0; i < count1 && j < count2; i = i_next, j = j_next) {
if (i + 1 >= count1 || !is_surrogate_pair(&str1[i])) {
a = static_cast<utf16_t>(str1[i]);
i++;
a = static_cast<utf32_t>(str1[i]);
i_next = i + 1;
}
else {
a = surrogate_pair_to_ucs4(&str1[i]);
i += 2;
i_next = i + 2;
}
utf32_t b;
if (j + 1 >= count2 || !is_surrogate_pair(&str2[j])) {
b = static_cast<utf16_t>(str2[j]);
j++;
b = static_cast<utf32_t>(str2[j]);
j_next = j + 1;
}
else {
b = surrogate_pair_to_ucs4(&str2[j]);
j += 2;
j_next = j + 2;
}
if (a < b) return -1;
if (!a && !b) return 0;
if (a > b) return +1;
if (a < b) return -1;
}
if (i < count1 && str1[i]) return +1;
if (j < count2 && str2[j]) return -1;
return 0;
}
///