mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
Fix 'change texture pack' sort order being wrong, make string compare case insensitive
This commit is contained in:
parent
217065e21c
commit
42373d64d7
@ -388,12 +388,12 @@ void ListScreen_QuickSort(Int32 left, Int32 right) {
|
||||
UInt32* keys = buffer->FlagsBuffer; UInt32 key;
|
||||
while (left < right) {
|
||||
Int32 i = left, j = right;
|
||||
Int32 pivot = (i + j) / 2;
|
||||
String strI, strJ, pivot = StringsBuffer_UNSAFE_Get(buffer, (i + j) / 2);
|
||||
|
||||
/* partition the list */
|
||||
while (i <= j) {
|
||||
while (StringsBuffer_Compare(buffer, pivot, i) > 0) i++;
|
||||
while (StringsBuffer_Compare(buffer, pivot, j) < 0) j--;
|
||||
while ((strI = StringsBuffer_UNSAFE_Get(buffer, i), String_Compare(&pivot, &strI)) > 0) i++;
|
||||
while ((strJ = StringsBuffer_UNSAFE_Get(buffer, j), String_Compare(&pivot, &strJ)) < 0) j--;
|
||||
QuickSort_Swap_Maybe();
|
||||
}
|
||||
/* recurse into the smaller subset */
|
||||
|
@ -411,13 +411,15 @@ Int32 String_Compare(STRING_PURE String* a, STRING_PURE String* b) {
|
||||
Int32 i;
|
||||
|
||||
for (i = 0; i < minLen; i++) {
|
||||
if (a->buffer[i] == b->buffer[i]) continue;
|
||||
return a->buffer[i] > b->buffer[i] ? 1 : -1;
|
||||
UInt8 aCur = a->buffer[i]; Char_MakeLower(aCur);
|
||||
UInt8 bCur = b->buffer[i]; Char_MakeLower(bCur);
|
||||
|
||||
if (aCur == bCur) continue;
|
||||
return (Int32)aCur - (Int32)bCur;
|
||||
}
|
||||
|
||||
/* all chars are equal here - same string, or a substring */
|
||||
if (a->length == b->length) return 0;
|
||||
return a->length > b->length ? 1 : -1;
|
||||
return a->length - b->length;
|
||||
}
|
||||
|
||||
void String_Format1(STRING_TRANSIENT String* str, const UInt8* format, const void* a1) {
|
||||
@ -781,12 +783,6 @@ void StringsBuffer_Remove(StringsBuffer* buffer, UInt32 index) {
|
||||
buffer->UsedElems -= len;
|
||||
}
|
||||
|
||||
Int32 StringsBuffer_Compare(StringsBuffer* buffer, UInt32 idxA, UInt32 idxB) {
|
||||
String strA = StringsBuffer_UNSAFE_Get(buffer, idxA);
|
||||
String strB = StringsBuffer_UNSAFE_Get(buffer, idxB);
|
||||
return String_Compare(&strA, &strB);
|
||||
}
|
||||
|
||||
|
||||
bool WordWrap_IsWrapper(UInt8 c) {
|
||||
return c == NULL || c == ' ' || c == '-' || c == '>' || c == '<' || c == '/' || c == '\\';
|
||||
|
Loading…
x
Reference in New Issue
Block a user