diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index dcab2699..5c373259 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -956,12 +956,12 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const if (posFound != -1 && posFound != -2) { const char *encodingBlockRegExpr = "encoding[ \\t]*=[ \\t]*\"[^\".]+\""; - posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingBlockRegExpr), (LPARAM)encodingBlockRegExpr); + _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingBlockRegExpr), (LPARAM)encodingBlockRegExpr); const char *encodingRegExpr = "\".+\""; - posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingRegExpr), (LPARAM)encodingRegExpr); + _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingRegExpr), (LPARAM)encodingRegExpr); - posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingAliasRegExpr), (LPARAM)encodingAliasRegExpr); + _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingAliasRegExpr), (LPARAM)encodingAliasRegExpr); startPos = int(_invisibleEditView.execute(SCI_GETTARGETSTART)); endPos = int(_invisibleEditView.execute(SCI_GETTARGETEND)); @@ -998,9 +998,9 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const if (posFound == -1 || posFound == -2) return -1; } - posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(charsetBlock), (LPARAM)charsetBlock); - posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(intermediaire), (LPARAM)intermediaire); - posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingStrRE), (LPARAM)encodingStrRE); + _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(charsetBlock), (LPARAM)charsetBlock); + _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(intermediaire), (LPARAM)intermediaire); + _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingStrRE), (LPARAM)encodingStrRE); startPos = int(_invisibleEditView.execute(SCI_GETTARGETSTART)); endPos = int(_invisibleEditView.execute(SCI_GETTARGETEND)); @@ -6074,7 +6074,8 @@ void Notepad_plus::showQuote(const char *quote, const char *quoter, bool doTroll void Notepad_plus::launchDocumentBackupTask() { HANDLE hThread = ::CreateThread(NULL, 0, backupDocument, NULL, 0, NULL); - ::CloseHandle(hThread); + if (hThread) + ::CloseHandle(hThread); } DWORD WINAPI Notepad_plus::backupDocument(void * /*param*/) @@ -6150,7 +6151,6 @@ bool Notepad_plus::undoStreamComment() generic_string white_space(TEXT(" ")); int start_comment_length = start_comment.length(); int end_comment_length = end_comment.length(); - int startCommentLength, endCommentLength; do { // do as long as stream-comments are within selection @@ -6166,7 +6166,7 @@ bool Notepad_plus::undoStreamComment() //-- First, search all start_comment and end_comment before and after the selectionStart and selectionEnd position. const int iSelStart=0, iSelEnd=1; - #define N_CMNT 2 + const size_t N_CMNT = 2 int posStartCommentBefore[N_CMNT], posEndCommentBefore[N_CMNT], posStartCommentAfter[N_CMNT], posEndCommentAfter[N_CMNT]; bool blnStartCommentBefore[N_CMNT], blnEndCommentBefore[N_CMNT], blnStartCommentAfter[N_CMNT], blnEndCommentAfter[N_CMNT]; int posStartComment, posEndComment; @@ -6238,8 +6238,8 @@ bool Notepad_plus::undoStreamComment() //-- Ok, there are valid start-comment and valid end-comment around the caret-position. // Now, un-comment stream-comment: retVal = true; - startCommentLength = start_comment_length; - endCommentLength = end_comment_length; + int startCommentLength = start_comment_length; + int endCommentLength = end_comment_length; //-- First delete end-comment, so that posStartCommentBefore does not change! //-- Get character before end-comment to decide, if there is a white character before the end-comment, which will be removed too! _pEditView->getGenericText(charbuf, charbufLen, posEndComment-1, posEndComment); diff --git a/PowerEditor/src/ScitillaComponent/Printer.h b/PowerEditor/src/ScitillaComponent/Printer.h index b9fae444..91e2fb86 100644 --- a/PowerEditor/src/ScitillaComponent/Printer.h +++ b/PowerEditor/src/ScitillaComponent/Printer.h @@ -47,7 +47,7 @@ class Printer public : Printer(){}; void init(HINSTANCE hInst, HWND hwnd, ScintillaEditView *pSEView, bool showDialog, int startPos, int endPos); - size_t Printer::doPrint() { + size_t doPrint() { if (!::PrintDlg(&_pdlg)) return 0; diff --git a/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.h b/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.h index 0d45bfb2..f9659d39 100644 --- a/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.h +++ b/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.h @@ -72,7 +72,7 @@ public: }; protected: - virtual BOOL CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); + virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); private: ScintillaEditView **_ppEditView; diff --git a/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.h b/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.h index 39d7b2bc..b261f498 100644 --- a/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.h +++ b/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.h @@ -99,7 +99,7 @@ public: void drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); protected: - virtual BOOL CALLBACK ClipboardHistoryPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); + virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); private: ScintillaEditView **_ppEditView; diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp index b56a14ac..63a70ae1 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp @@ -678,10 +678,9 @@ void DockingManager::setActiveTab(int iCont, int iItem) void DockingManager::showDockableDlg(HWND hDlg, BOOL view) { - tTbData *pTbData = NULL; for (size_t i = 0, len = _vContainer.size(); i < len; ++i) { - pTbData = _vContainer[i]->findToolbarByWnd(hDlg); + tTbData *pTbData = _vContainer[i]->findToolbarByWnd(hDlg); if (pTbData != NULL) { _vContainer[i]->showToolbar(pTbData, view); diff --git a/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp b/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp index 22bc6281..f7065889 100644 --- a/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp @@ -457,7 +457,7 @@ void Gripper::doTabReordering(POINT pt) _iItem = iItem; } - else if ((hTab != _hTab) || (_iItem == -1)) + else if (_hTab && ((hTab != _hTab) || (_iItem == -1))) { /* test if cusor points after last tab */ int iLastItem = ::SendMessage(hTab, TCM_GETITEMCOUNT, 0, 0) - 1; @@ -501,7 +501,7 @@ void Gripper::doTabReordering(POINT pt) } /* insert new entry when mouse doesn't point to current hovered tab */ - if ((_hTab != hTabOld) || (_iItem != iItemOld)) + if (_hTab && ((_hTab != hTabOld) || (_iItem != iItemOld))) { _tcItem.mask = TCIF_PARAM | (_hTab == _hTabSource ? TCIF_TEXT : 0); ::SendMessage(_hTab, TCM_INSERTITEM, _iItem, (LPARAM)&_tcItem); diff --git a/PowerEditor/src/WinControls/FunctionList/functionParser.h b/PowerEditor/src/WinControls/FunctionList/functionParser.h index 525a74d1..31233d7b 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionParser.h +++ b/PowerEditor/src/WinControls/FunctionList/functionParser.h @@ -37,7 +37,7 @@ struct foundInfo { generic_string _data2; int _pos; int _pos2; - //foundInfo(): /*_data(TEXT("")), _data2(TEXT("")), _pos(-1) _pos2(-1) */{}; + foundInfo(): _data(TEXT("")), _data2(TEXT("")), _pos(-1), _pos2(-1) {}; }; class FunctionParser { diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 150703e5..a2849c29 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -257,7 +257,7 @@ bool PreferenceDlg::renameDialogTitle(const TCHAR *internalName, const TCHAR *ne return false; const size_t lenMax = 256; - TCHAR oldName[lenMax]; + TCHAR oldName[lenMax] = {0}; size_t txtLen = ::SendDlgItemMessage(_hSelf, IDC_LIST_DLGTITLE, LB_GETTEXTLEN, i, 0); if (txtLen >= lenMax) return false; diff --git a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h index 97dcecbc..495dc7fb 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h +++ b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h @@ -134,7 +134,7 @@ protected: void setWorkSpaceDirty(bool isDirty); void popupMenuCmd(int cmdID); POINT getMenuDisplyPoint(int iButton); - virtual BOOL CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); + virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); bool buildTreeFrom(TiXmlNode *projectRoot, HTREEITEM hParentItem); void notified(LPNMHDR notification); void showContextMenu(int x, int y); diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp index 8683c65c..b665e2d0 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp @@ -49,7 +49,8 @@ void StaticDialog::display(bool toShow) const if (toShow) { // If the user has switched from a dual monitor to a single monitor since we last // displayed the dialog, then ensure that it's still visible on the single monitor. - RECT workAreaRect, rc; + RECT workAreaRect = {0}; + RECT rc = {0}; ::SystemParametersInfo(SPI_GETWORKAREA, 0, &workAreaRect, 0); ::GetWindowRect(_hSelf, &rc); int newLeft = rc.left; @@ -77,9 +78,17 @@ HGLOBAL StaticDialog::makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplat { // Get Dlg Template resource HRSRC hDialogRC = ::FindResource(_hInst, MAKEINTRESOURCE(dialogID), RT_DIALOG); + if (!hDialogRC) + return NULL; + HGLOBAL hDlgTemplate = ::LoadResource(_hInst, hDialogRC); + if (!hDlgTemplate) + return NULL; + DLGTEMPLATE *pDlgTemplate = (DLGTEMPLATE *)::LockResource(hDlgTemplate); - + if (!pDlgTemplate) + return NULL; + // Duplicate Dlg Template resource unsigned long sizeDlg = ::SizeofResource(_hInst, hDialogRC); HGLOBAL hMyDlgTemplate = ::GlobalAlloc(GPTR, sizeDlg); diff --git a/PowerEditor/src/WinControls/TabBar/ControlsTab.h b/PowerEditor/src/WinControls/TabBar/ControlsTab.h index ff6d9d01..925f84a7 100644 --- a/PowerEditor/src/WinControls/TabBar/ControlsTab.h +++ b/PowerEditor/src/WinControls/TabBar/ControlsTab.h @@ -53,7 +53,7 @@ public : _isVertical = isVertical; TabBar::init(hInst, hwnd, false, isTraditional, isMultiLine); }; - void ControlsTab::createTabs(WindowVector & winVector); + void createTabs(WindowVector & winVector); void destroy() { TabBar::destroy(); diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.h b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.h index e8cbe3e3..5fb08eb4 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.h +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.h @@ -104,7 +104,7 @@ public: }; protected: - virtual BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); + virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); private: VerticalFileSwitcherListView _fileListView; diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index ba53815b..4c0a52c3 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -546,7 +546,7 @@ void Accelerator::updateShortcuts() tmpAccelArray[i] = IFAcc[i]; } _hIncFindAccTab = ::CreateAcceleratorTable(tmpAccelArray, nb); - delete tmpAccelArray; + delete [] tmpAccelArray; return; } diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.h b/PowerEditor/src/WinControls/shortcut/shortcut.h index 6bc2a120..a67940bf 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.h +++ b/PowerEditor/src/WinControls/shortcut/shortcut.h @@ -215,7 +215,7 @@ public: }; KeyCombo getKeyComboByIndex(int index) const; - void ScintillaKeyMap::setKeyComboByIndex(int index, KeyCombo combo); + void setKeyComboByIndex(int index, KeyCombo combo); void removeKeyComboByIndex(int index); void clearDups() { if (size > 1) diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index ed02bb0d..7ad85802 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -495,7 +495,7 @@ DEVOMER*/ } catch (const Win32Exception & ex) { TCHAR message[1024]; //TODO: sane number wsprintf(message, TEXT("An exception occured. Notepad++ cannot recover and must be shut down.\r\nThe exception details are as follows:\r\n") - TEXT("Code:\t0x%08X\r\nType:\t%S\r\nException address: 0x%08X"), ex.code(), ex.what(), ex.where()); + TEXT("Code:\t0x%08X\r\nType:\t%S\r\nException address: 0x%08X"), ex.code(), ex.what(), (long)ex.where()); ::MessageBox(Notepad_plus_Window::gNppHWND, message, TEXT("Win32Exception"), MB_OK | MB_ICONERROR); mdump.writeDump(ex.info()); doException(notepad_plus_plus);