"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/interface/filelistctrl.h" between
FileZilla_3.45.0_src.tar.bz2 and FileZilla_3.45.1_src.tar.bz2

About: FileZilla is a fast and feature-rich cross-platform FTP, FTPS and SFTP client with an intuitive graphical user interface.

filelistctrl.h  (FileZilla_3.45.0_src.tar.bz2):filelistctrl.h  (FileZilla_3.45.1_src.tar.bz2)
skipping to change at line 70 skipping to change at line 70
#define CMP_LESS(f, data1, data2) \ #define CMP_LESS(f, data1, data2) \
{\ {\
int res = this->f(data1, data2);\ int res = this->f(data1, data2);\
if (res < 0)\ if (res < 0)\
return true;\ return true;\
else\ else\
return false;\ return false;\
} }
static int CmpCase(std::wstring const& str1, std::wstring const& str2) static int CmpCase(std::wstring_view const& str1, std::wstring_view const & str2)
{ {
return str1.compare(str2); return str1.compare(str2);
} }
static int CmpCase(wxString const& str1, wxString const& str2) static int CmpNoCase(std::wstring_view const& str1, std::wstring_view con
{ st& str2)
return str1.Cmp(str2);
}
static int CmpNoCase(std::wstring const& str1, std::wstring const& str2)
{ {
int cmp = fz::stricmp(str1, str2); int cmp = fz::stricmp(str1, str2);
if (cmp) { if (cmp) {
return cmp; return cmp;
} }
return str1.compare(str2); return str1.compare(str2);
} }
static int CmpNoCase(wxString const& str1, wxString const& str2) static int CmpNatural(std::wstring_view const& str1, std::wstring_view co nst& str2)
{ {
int cmp = str1.CmpNoCase(str2); wchar_t const* p1 = str1.data();
if (cmp) { wchar_t const* p2 = str2.data();
return cmp;
}
return str1.Cmp(str2);
}
static int CmpNatural(wxString const& str1, wxString const& str2) wchar_t const* const end1 = p1 + str1.size();
{ wchar_t const* const end2 = p2 + str2.size();
return CmpNatural(static_cast<wxChar const*>(str1.c_str()), stati
c_cast<wxChar const*>(str2.c_str()));
}
static int CmpNatural(std::wstring const& str1, std::wstring const& str2)
{
return CmpNatural(str1.c_str(), str2.c_str());
}
static int CmpNatural(wchar_t const* p1, wchar_t const* p2)
{
int res = 0; int res = 0;
int zeroCount = 0; int zeroCount = 0;
bool isNumber = false; bool isNumber = false;
for (; *p1 && *p2; ++p1, ++p2) { for (; p1 != end1 && p2 != end2; ++p1, ++p2) {
int diff = static_cast<int>(wxTolower(*p1)) - static_cast <int>(wxTolower(*p2)); int diff = static_cast<int>(wxTolower(*p1)) - static_cast <int>(wxTolower(*p2));
if (isNumber) { if (isNumber) {
if (res == 0) { if (res == 0) {
res = diff; res = diff;
} }
int nbDigits = (wxIsdigit(*p1) ? 1 : 0) + (wxIsdi git(*p2) ? 1 : 0); int nbDigits = (wxIsdigit(*p1) ? 1 : 0) + (wxIsdi git(*p2) ? 1 : 0);
if (nbDigits == 0 && res == 0) { if (nbDigits == 0 && res == 0) {
if (zeroCount) { if (zeroCount) {
break; break;
} }
isNumber = false; isNumber = false;
} }
else if (nbDigits != 2) { else if (nbDigits != 2) {
break; break;
} }
} }
else if (wxIsdigit(*p1) && wxIsdigit(*p2)) { else if (wxIsdigit(*p1) && wxIsdigit(*p2)) {
zeroCount = 0; zeroCount = 0;
for (; *p1 == '0' && *(p1 + 1) && wxIsdigit(*(p1 + 1)); ++p1) { for (; *p1 == '0' && (p1 + 1) != end1 && wxIsdigi t(*(p1 + 1)); ++p1) {
zeroCount++; zeroCount++;
} }
for (; *p2 == '0' && *(p2 + 1) && wxIsdigit(*(p2 + 1)); ++p2) { for (; *p2 == '0' && (p2 + 1) != end2 && wxIsdigi t(*(p2 + 1)); ++p2) {
zeroCount--; zeroCount--;
} }
res = *p1 - *p2; res = *p1 - *p2;
isNumber = true; isNumber = true;
} }
else if (diff) { else if (diff) {
return diff; return diff;
} }
} }
if (res == 0 && isNumber) { if (res == 0 && isNumber) {
res = zeroCount; res = zeroCount;
} }
if (!*p1 && !*p2) { if (p1 == end1 && p2 == end2) {
return res; return res;
} }
if (!isNumber || res == 0) { if (!isNumber || res == 0) {
return !*p1 ? -1 : 1; return (p1 == end1) ? -1 : 1;
} }
if (*p1 && wxIsdigit(*p1)) { if (p1 != end1 && wxIsdigit(*p1)) {
return 1; //more digits return 1; //more digits
} }
if (*p2 && wxIsdigit(*p2)) { if (p2 != end2 && wxIsdigit(*p2)) {
return -1; //fewer digits return -1; //fewer digits
} }
return res; //same length, compare first different digit in the sequence return res; //same length, compare first different digit in the sequence*/
} }
typedef int (* CompareFunction)(std::wstring const&, std::wstring const&) ; typedef int (* CompareFunction)(std::wstring_view const&, std::wstring_vi ew const&);
static CompareFunction GetCmpFunction(NameSortMode mode) static CompareFunction GetCmpFunction(NameSortMode mode)
{ {
switch (mode) switch (mode)
{ {
default: default:
case CFileListCtrlSortBase::namesort_caseinsensitive: case CFileListCtrlSortBase::namesort_caseinsensitive:
return &CFileListCtrlSortBase::CmpNoCase; return &CFileListCtrlSortBase::CmpNoCase;
case CFileListCtrlSortBase::namesort_casesensitive: case CFileListCtrlSortBase::namesort_casesensitive:
return &CFileListCtrlSortBase::CmpCase; return &CFileListCtrlSortBase::CmpCase;
case CFileListCtrlSortBase::namesort_natural: case CFileListCtrlSortBase::namesort_natural:
 End of changes. 15 change blocks. 
35 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)