diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 6509f9eac..1a5066350 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -846,63 +846,6 @@ double stodLocale(const generic_string& str, [[maybe_unused]] _locale_t loc, siz return ans; } -// Source: https://blogs.msdn.microsoft.com/greggm/2005/09/21/comparing-file-names-in-native-code/ -// Modified to use TCHAR's instead of assuming Unicode and reformatted to conform with Notepad++ code style -static TCHAR ToUpperInvariant(TCHAR input) -{ - TCHAR result; - LONG lres = LCMapString(LOCALE_INVARIANT, LCMAP_UPPERCASE, &input, 1, &result, 1); - if (lres == 0) - { - assert(false and "LCMapString failed to convert a character to upper case"); - result = input; - } - return result; -} - -// Source: https://blogs.msdn.microsoft.com/greggm/2005/09/21/comparing-file-names-in-native-code/ -// Modified to use TCHAR's instead of assuming Unicode and reformatted to conform with Notepad++ code style -int OrdinalIgnoreCaseCompareStrings(LPCTSTR sz1, LPCTSTR sz2) -{ - if (sz1 == sz2) - { - return 0; - } - - if (sz1 == nullptr) sz1 = _T(""); - if (sz2 == nullptr) sz2 = _T(""); - - for (;; sz1++, sz2++) - { - const TCHAR c1 = *sz1; - const TCHAR c2 = *sz2; - - // check for binary equality first - if (c1 == c2) - { - if (c1 == 0) - { - return 0; // We have reached the end of both strings. No difference found. - } - } - else - { - if (c1 == 0 || c2 == 0) - { - return (c1-c2); // We have reached the end of one string - } - - // IMPORTANT: this needs to be upper case to match the behavior of the operating system. - // See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/StringsinNET20.asp - const TCHAR u1 = ToUpperInvariant(c1); - const TCHAR u2 = ToUpperInvariant(c2); - if (u1 != u2) - { - return (u1-u2); // strings are different - } - } - } -} bool str2Clipboard(const generic_string &str2cpy, HWND hwnd) { diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index d89a58cbe..6ba4229b3 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -163,8 +163,6 @@ void stringJoin(const std::vector& strings, const generic_string generic_string stringTakeWhileAdmissable(const generic_string& input, const generic_string& admissable); double stodLocale(const generic_string& str, _locale_t loc, size_t* idx = NULL); -int OrdinalIgnoreCaseCompareStrings(LPCTSTR sz1, LPCTSTR sz2); - bool str2Clipboard(const generic_string &str2cpy, HWND hwnd); class Buffer; bool buf2Clipboard(const std::vector& buffers, bool isFullPath, HWND hwnd); diff --git a/PowerEditor/src/MISC/Common/Sorters.h b/PowerEditor/src/MISC/Common/Sorters.h index c8b5acb5e..be823aad0 100644 --- a/PowerEditor/src/MISC/Common/Sorters.h +++ b/PowerEditor/src/MISC/Common/Sorters.h @@ -128,11 +128,11 @@ public: { if (isDescending()) { - return OrdinalIgnoreCaseCompareStrings(getSortKey(a).c_str(), getSortKey(b).c_str()) > 0; + return wcsicmp(getSortKey(a).c_str(), getSortKey(b).c_str()) > 0; } else { - return OrdinalIgnoreCaseCompareStrings(getSortKey(a).c_str(), getSortKey(b).c_str()) < 0; + return wcsicmp(getSortKey(a).c_str(), getSortKey(b).c_str()) < 0; } }); } @@ -142,11 +142,11 @@ public: { if (isDescending()) { - return OrdinalIgnoreCaseCompareStrings(a.c_str(), b.c_str()) > 0; + return wcsicmp(a.c_str(), b.c_str()) > 0; } else { - return OrdinalIgnoreCaseCompareStrings(a.c_str(), b.c_str()) < 0; + return wcsicmp(a.c_str(), b.c_str()) < 0; } }); } diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index ccd1f21be..a0429f657 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -1832,8 +1832,8 @@ void Notepad_plus::getMatchedFileNames(const TCHAR *dir, size_t level, const vec } else if (isRecursive) { - if ((OrdinalIgnoreCaseCompareStrings(foundData.cFileName, TEXT(".")) != 0) && - (OrdinalIgnoreCaseCompareStrings(foundData.cFileName, TEXT("..")) != 0) && + if ((wcscmp(foundData.cFileName, TEXT(".")) != 0) && + (wcscmp(foundData.cFileName, TEXT("..")) != 0) && !matchInExcludeDirList(foundData.cFileName, patterns, level)) { generic_string pathDir(dir); diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 4b9027e6a..e3d1cdcac 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -84,7 +84,7 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params) if (pos == 2) fn.replace(pos, 2, TEXT("\\")); - if (OrdinalIgnoreCaseCompareStrings(fullFileName, fn.c_str()) == 0) + if (wcscmp(fullFileName, fn.c_str()) == 0) { if (dwAction == FILE_ACTION_MODIFIED) { diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index 680302034..94df96ba1 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -215,17 +215,17 @@ void Buffer::setFileName(const TCHAR *fn) } } - if (determinatedLang == L_TEXT) //language can probably be refined + if (determinatedLang == L_TEXT) // language can probably be refined { - if ((OrdinalIgnoreCaseCompareStrings(_fileName, TEXT("makefile")) == 0) || (OrdinalIgnoreCaseCompareStrings(_fileName, TEXT("GNUmakefile")) == 0)) + if ((wcsicmp(_fileName, TEXT("makefile")) == 0) || (wcsicmp(_fileName, TEXT("GNUmakefile")) == 0)) determinatedLang = L_MAKEFILE; - else if (OrdinalIgnoreCaseCompareStrings(_fileName, TEXT("CmakeLists.txt")) == 0) + else if (wcsicmp(_fileName, TEXT("CmakeLists.txt")) == 0) determinatedLang = L_CMAKE; - else if ((OrdinalIgnoreCaseCompareStrings(_fileName, TEXT("SConstruct")) == 0) || (OrdinalIgnoreCaseCompareStrings(_fileName, TEXT("SConscript")) == 0) || (OrdinalIgnoreCaseCompareStrings(_fileName, TEXT("wscript")) == 0)) + else if ((wcsicmp(_fileName, TEXT("SConstruct")) == 0) || (wcsicmp(_fileName, TEXT("SConscript")) == 0) || (wcsicmp(_fileName, TEXT("wscript")) == 0)) determinatedLang = L_PYTHON; - else if ((OrdinalIgnoreCaseCompareStrings(_fileName, TEXT("Rakefile")) == 0) || (OrdinalIgnoreCaseCompareStrings(_fileName, TEXT("Vagrantfile")) == 0)) + else if ((wcsicmp(_fileName, TEXT("Rakefile")) == 0) || (wcsicmp(_fileName, TEXT("Vagrantfile")) == 0)) determinatedLang = L_RUBY; - else if ((OrdinalIgnoreCaseCompareStrings(_fileName, TEXT("crontab")) == 0) || (OrdinalIgnoreCaseCompareStrings(_fileName, TEXT("PKGBUILD")) == 0) || (OrdinalIgnoreCaseCompareStrings(_fileName, TEXT("APKBUILD")) == 0)) + else if ((wcsicmp(_fileName, TEXT("crontab")) == 0) || (wcsicmp(_fileName, TEXT("PKGBUILD")) == 0) || (wcsicmp(_fileName, TEXT("APKBUILD")) == 0)) determinatedLang = L_BASH; } diff --git a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp index b5ef89692..bb0d01a1f 100644 --- a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp +++ b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp @@ -897,8 +897,8 @@ void FileBrowser::getDirectoryStructure(const TCHAR *dir, const std::vector