diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index e8eb25d82..2634a97d2 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -766,7 +766,9 @@ COLORREF getCtrlBgColor(HWND hWnd) generic_string stringToUpper(generic_string strToConvert) { - std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), ::toupper); + std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), + [](TCHAR ch){ return static_cast(_totupper(ch)); } + ); return strToConvert; } diff --git a/PowerEditor/src/TinyXml/tinyxml.h b/PowerEditor/src/TinyXml/tinyxml.h index f5b3c6100..2c8bfe200 100644 --- a/PowerEditor/src/TinyXml/tinyxml.h +++ b/PowerEditor/src/TinyXml/tinyxml.h @@ -58,6 +58,7 @@ distribution. #include +#include #include #include "Common.h" @@ -176,7 +177,7 @@ protected: }; static const TCHAR* SkipWhiteSpace( const TCHAR* ); - inline static bool IsWhiteSpace( int c ) { return ( isspace( c ) || c == '\n' || c == '\r' ); } + inline static bool IsWhiteSpace( int c ) { return ( _istspace( static_cast(c) ) || c == '\n' || c == '\r' ); } virtual void StreamOut (TIXML_OSTREAM *) const = 0; diff --git a/PowerEditor/src/TinyXml/tinyxmlparser.cpp b/PowerEditor/src/TinyXml/tinyxmlparser.cpp index 84c89bb9b..bf2c26477 100644 --- a/PowerEditor/src/TinyXml/tinyxmlparser.cpp +++ b/PowerEditor/src/TinyXml/tinyxmlparser.cpp @@ -24,6 +24,7 @@ distribution. #include +#include #include "tinyxml.h" //#define DEBUG_PARSER @@ -156,7 +157,7 @@ const TCHAR* TiXmlBase::SkipWhiteSpace( const TCHAR* p ) } while ( p && *p ) { - if ( isspace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space. + if ( _istspace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space. ++p; else break; @@ -204,10 +205,10 @@ const TCHAR* TiXmlBase::ReadName( const TCHAR* p, TIXML_STRING * name ) // hyphens, or colons. (Colons are valid ony for namespaces, // but tinyxml can't tell namespaces from names.) if ( p && *p - && ( isalpha( (UCHAR) *p ) || *p == '_' ) ) + && ( _istalpha( *p ) || *p == '_' ) ) { while( p && *p - && ( isalnum( (UCHAR ) *p ) + && ( _istalnum( *p ) || *p == '_' || *p == '-' || *p == '.' @@ -270,7 +271,7 @@ bool TiXmlBase::StringEqual( const TCHAR* p, return false; } - if ( tolower( *p ) == tolower( *tag ) ) + if ( _totlower( *p ) == _totlower( *tag ) ) { const TCHAR* q = p; @@ -289,7 +290,7 @@ bool TiXmlBase::StringEqual( const TCHAR* p, } else { - while ( *q && *tag && tolower( *q ) == tolower( *tag ) ) + while ( *q && *tag && _totlower( *q ) == _totlower( *tag ) ) { ++q; ++tag; @@ -338,7 +339,7 @@ const TCHAR* TiXmlBase::ReadText( const TCHAR* p, whitespace = true; ++p; } - else if ( isspace( *p ) ) + else if ( _istspace( *p ) ) { whitespace = true; ++p; @@ -533,7 +534,7 @@ TiXmlNode* TiXmlNode::Identify( const TCHAR* p ) #endif returnNode = new TiXmlDeclaration(); } - else if ( isalpha( *(p+1) ) + else if ( _istalpha( *(p+1) ) || *(p+1) == '_' ) { #ifdef DEBUG_PARSER @@ -1013,7 +1014,7 @@ const TCHAR* TiXmlAttribute::Parse( const TCHAR* p, TiXmlParsingData* data ) // its best, even without them. value = TEXT(""); while ( p && *p // existence - && !isspace( *p ) && *p != '\n' && *p != '\r' // whitespace + && !_istspace( *p ) && *p != '\n' && *p != '\r' // whitespace && *p != '/' && *p != '>' ) // tag end { value += *p; @@ -1126,7 +1127,7 @@ const TCHAR* TiXmlDeclaration::Parse( const TCHAR* p, TiXmlParsingData* data ) else { // Read over whatever it is. - while( p && *p && *p != '>' && !isspace( *p ) ) + while( p && *p && *p != '>' && !_istspace( *p ) ) ++p; } } @@ -1136,7 +1137,7 @@ const TCHAR* TiXmlDeclaration::Parse( const TCHAR* p, TiXmlParsingData* data ) bool TiXmlText::Blank() const { for (size_t i = 0, len = value.length(); i < len; i++) - if ( !isspace( value[i] ) ) + if ( !_istspace( value[i] ) ) return false; return true; } diff --git a/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.cpp b/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.cpp index 8f7106d7e..22ae23e61 100644 --- a/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.cpp +++ b/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.cpp @@ -129,7 +129,7 @@ void AnsiCharPanel::insertChar(unsigned char char2insert) const bool isUnicode = ((*_ppEditView)->execute(SCI_GETCODEPAGE) == SC_CP_UTF8); if (isUnicode) { - MultiByteToWideChar(0, 0, charStr, -1, wCharStr, sizeof(wCharStr)); + MultiByteToWideChar(0, 0, charStr, -1, wCharStr, _countof(wCharStr)); WideCharToMultiByte(CP_UTF8, 0, wCharStr, -1, multiByteStr, sizeof(multiByteStr), NULL, NULL); } else // ANSI @@ -140,7 +140,7 @@ void AnsiCharPanel::insertChar(unsigned char char2insert) const } else { - MultiByteToWideChar(codepage, 0, charStr, -1, wCharStr, sizeof(wCharStr)); + MultiByteToWideChar(codepage, 0, charStr, -1, wCharStr, _countof(wCharStr)); WideCharToMultiByte(CP_UTF8, 0, wCharStr, -1, multiByteStr, sizeof(multiByteStr), NULL, NULL); } (*_ppEditView)->execute(SCI_REPLACESEL, 0, reinterpret_cast("")); diff --git a/PowerEditor/src/WinControls/AnsiCharPanel/asciiListView.cpp b/PowerEditor/src/WinControls/AnsiCharPanel/asciiListView.cpp index e94cddd7a..76cf6ef8f 100644 --- a/PowerEditor/src/WinControls/AnsiCharPanel/asciiListView.cpp +++ b/PowerEditor/src/WinControls/AnsiCharPanel/asciiListView.cpp @@ -119,7 +119,7 @@ generic_string AsciiListView::getAscii(unsigned char value) char ascii[2]; ascii[0] = value; ascii[1] = '\0'; - MultiByteToWideChar(_codepage, 0, ascii, -1, charStr, sizeof(charStr)); + MultiByteToWideChar(_codepage, 0, ascii, -1, charStr, _countof(charStr)); return charStr; } diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp index 1a502d734..0d52f987d 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp @@ -177,7 +177,7 @@ LRESULT DockingSplitter::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM if (hookMouse) { ::UnhookWindowsHookEx(hookMouse); - ::SetCapture(NULL); + ::ReleaseCapture(); hookMouse = NULL; } _isLeftButtonDown = FALSE; diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp index acf457140..4597427ce 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp @@ -142,7 +142,7 @@ bool findStrNoCase(const generic_string & strHaystack, const generic_string & st auto it = std::search( strHaystack.begin(), strHaystack.end(), strNeedle.begin(), strNeedle.end(), - [](char ch1, char ch2){return std::toupper(ch1) == std::toupper(ch2); } + [](TCHAR ch1, TCHAR ch2){return _totupper(ch1) == _totupper(ch2); } ); return (it != strHaystack.end()); } diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index ee49aad0f..f34287838 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -1359,7 +1359,7 @@ INT_PTR CALLBACK DefaultDirectoryDlg::run_dlgProc(UINT message, WPARAM wParam, L TCHAR inputDir[MAX_PATH]; ::SendDlgItemMessage(_hSelf, IDC_OPENSAVEDIR_ALWAYSON_EDIT, WM_GETTEXT, MAX_PATH, reinterpret_cast(inputDir)); lstrcpy(nppGUI._defaultDir, inputDir); - ::ExpandEnvironmentStrings(nppGUI._defaultDir, nppGUI._defaultDirExp, 500); + ::ExpandEnvironmentStrings(nppGUI._defaultDir, nppGUI._defaultDirExp, _countof(nppGUI._defaultDirExp)); pNppParam->setWorkingDir(nppGUI._defaultDirExp); return TRUE; } diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index fa4946e79..e78cb0053 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -27,6 +27,7 @@ #include +#include #include "shortcut.h" #include "Parameters.h" #include "ScintillaEditView.h" @@ -472,10 +473,7 @@ INT_PTR CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) // return true if one of CommandShortcuts is deleted. Otherwise false. void Accelerator::updateShortcuts() { - vector incrFindAccIds; - incrFindAccIds.push_back(IDM_SEARCH_FINDNEXT); - incrFindAccIds.push_back(IDM_SEARCH_FINDPREV); - incrFindAccIds.push_back(IDM_SEARCH_FINDINCREMENT); + const array incrFindAccIds = { IDM_SEARCH_FINDNEXT, IDM_SEARCH_FINDPREV, IDM_SEARCH_FINDINCREMENT }; NppParameters *pNppParam = NppParameters::getInstance();