Răsfoiți Sursa

Files with the same name except for a letter case are sorted deterministically (2nd)

(cherry picked from commit 555831790b9162898a1ea806de53f86f7a29656a)

Source commit: f09481ac9078fc33bf0f8fe2b1549934c64ac3a5
Martin Prikryl 5 ani în urmă
părinte
comite
e0c9ce31eb
2 a modificat fișierele cu 13 adăugiri și 2 ștergeri
  1. 11 2
      source/core/Common.cpp
  2. 2 0
      source/packages/filemng/CustomDirView.pas

+ 11 - 2
source/core/Common.cpp

@@ -904,14 +904,23 @@ bool __fastcall SamePaths(const UnicodeString & Path1, const UnicodeString & Pat
 int __fastcall CompareLogicalText(
   const UnicodeString & S1, const UnicodeString & S2, bool NaturalOrderNumericalSorting)
 {
+  // Keep in sync with CompareLogicalTextPas
+
+  int Result;
   if (NaturalOrderNumericalSorting)
   {
-    return StrCmpLogicalW(S1.c_str(), S2.c_str());
+    Result = StrCmpLogicalW(S1.c_str(), S2.c_str());
   }
   else
   {
-    return lstrcmpi(S1.c_str(), S2.c_str());
+    Result = lstrcmpi(S1.c_str(), S2.c_str());
   }
+  // For deterministics results
+  if (Result == 0)
+  {
+    Result = lstrcmp(S1.c_str(), S2.c_str());
+  }
+  return Result;
 }
 //---------------------------------------------------------------------------
 int __fastcall CompareNumber(__int64 Value1, __int64 Value2)

+ 2 - 0
source/packages/filemng/CustomDirView.pas

@@ -671,6 +671,8 @@ function StrCmpLogicalW(const sz1, sz2: UnicodeString): Integer; stdcall; extern
 
 function CompareLogicalTextPas(const S1, S2: string; NaturalOrderNumericalSorting: Boolean): Integer;
 begin
+  // Keep in sync with CompareLogicalText
+
   if NaturalOrderNumericalSorting then
     Result := StrCmpLogicalW(PChar(S1), PChar(S2))
   else