From 5356f648c21a1bc6fc96dcb9078bddce9dadcc37 Mon Sep 17 00:00:00 2001 From: Don HO Date: Wed, 13 Mar 2019 02:02:35 +0100 Subject: [PATCH] Remove some ugly coding styles --- PowerEditor/src/MISC/Common/Common.h | 2 +- PowerEditor/src/Notepad_plus_Window.cpp | 2 +- PowerEditor/src/NppBigSwitch.cpp | 2 +- PowerEditor/src/NppCommands.cpp | 10 +++--- PowerEditor/src/NppIO.cpp | 10 +++--- PowerEditor/src/Parameters.cpp | 10 +++--- .../src/ScitillaComponent/AutoCompletion.cpp | 34 +++++++++---------- PowerEditor/src/ScitillaComponent/Buffer.cpp | 6 ++-- .../src/ScitillaComponent/FindReplaceDlg.cpp | 14 ++++---- .../src/ScitillaComponent/FunctionCallTip.cpp | 2 +- .../ScitillaComponent/ScintillaEditView.cpp | 10 +++--- .../src/ScitillaComponent/ScintillaEditView.h | 2 +- .../xmlMatchedTagsHighlighter.cpp | 6 ++-- .../src/TinyXml/tinyXmlA/tinyxmlparserA.cpp | 2 +- PowerEditor/src/TinyXml/tinyxmlparser.cpp | 2 +- PowerEditor/src/Utf8_16.cpp | 4 +-- .../src/WinControls/AboutDlg/URLCtrl.cpp | 20 +++++------ .../DockingWnd/DockingSplitter.cpp | 2 +- .../OpenSaveFileDialog/FileDialog.cpp | 2 +- .../WinControls/Preference/preferenceDlg.cpp | 2 +- .../src/WinControls/ProjectPanel/TreeView.cpp | 2 +- .../ReadDirectoryChangesPrivate.cpp | 2 +- .../StaticDialog/RunDlg/RunDlg.cpp | 2 +- PowerEditor/src/WinControls/TabBar/TabBar.cpp | 2 +- .../src/WinControls/ToolBar/ToolBar.cpp | 7 ++-- .../src/WinControls/WindowsDlg/WindowsDlg.cpp | 6 ++-- .../src/WinControls/shortcut/shortcut.cpp | 4 +-- .../src/WinControls/shortcut/shortcut.h | 2 +- PowerEditor/src/uchardet/nsLatin1Prober.cpp | 2 +- .../src/uchardet/nsUniversalDetector.cpp | 2 +- 30 files changed, 88 insertions(+), 87 deletions(-) diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index c56a7ff8c..97de03bfb 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -126,7 +126,7 @@ protected: class StringBuffer final { public: - ~StringBuffer() { if(_allocLen) delete[] _str; } + ~StringBuffer() { if (_allocLen) delete[] _str; } void sizeTo(size_t size) { diff --git a/PowerEditor/src/Notepad_plus_Window.cpp b/PowerEditor/src/Notepad_plus_Window.cpp index b01d4bbe7..79493e0f6 100644 --- a/PowerEditor/src/Notepad_plus_Window.cpp +++ b/PowerEditor/src/Notepad_plus_Window.cpp @@ -130,7 +130,7 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin WINDOWPLACEMENT posInfo; posInfo.length = sizeof(WINDOWPLACEMENT); posInfo.flags = 0; - if(_isPrelaunch) + if (_isPrelaunch) posInfo.showCmd = SW_HIDE; else posInfo.showCmd = nppGUI._isMaximized ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL; diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 913d26d71..1c3c5a5a2 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1855,7 +1855,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case WM_ENDSESSION: { - if(wParam == TRUE) + if (wParam == TRUE) ::DestroyWindow(hwnd); return 0; } diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 57ff50811..3abe99f45 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -783,11 +783,11 @@ void Notepad_plus::command(int id) const int index = id - IDM_VIEW_TAB1; BufferID buf = _pDocTab->getBufferByIndex(index); _isFolding = true; - if(buf == BUFFER_INVALID) + if (buf == BUFFER_INVALID) { // No buffer at chosen index, select the very last buffer instead. const int last_index = _pDocTab->getItemCount() - 1; - if(last_index > 0) + if (last_index > 0) switchToFile(_pDocTab->getBufferByIndex(last_index)); } else @@ -803,7 +803,7 @@ void Notepad_plus::command(int id) const int current_index = _pDocTab->getCurrentTabIndex(); const int last_index = _pDocTab->getItemCount() - 1; _isFolding = true; - if(current_index < last_index) + if (current_index < last_index) switchToFile(_pDocTab->getBufferByIndex(current_index + 1)); else { @@ -817,7 +817,7 @@ void Notepad_plus::command(int id) { const int current_index = _pDocTab->getCurrentTabIndex(); _isFolding = true; - if(current_index > 0) + if (current_index > 0) switchToFile(_pDocTab->getBufferByIndex(current_index - 1)); else { @@ -1280,7 +1280,7 @@ void Notepad_plus::command(int id) if (braceOpposite != -1) { - if(id == IDM_SEARCH_GOTOMATCHINGBRACE) + if (id == IDM_SEARCH_GOTOMATCHINGBRACE) _pEditView->execute(SCI_GOTOPOS, braceOpposite); else _pEditView->execute(SCI_SETSEL, min(braceAtCaret, braceOpposite), max(braceAtCaret, braceOpposite) + 1); // + 1 so we always include the ending brace in the selection. diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index e516f8808..ff1d8e303 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -908,7 +908,7 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode) { // warning user and save it if user want it. activateBuffer(id, MAIN_VIEW); - if(!activateBuffer(id, SUB_VIEW)) + if (!activateBuffer(id, SUB_VIEW)) switchEditViewTo(MAIN_VIEW); int res = _nativeLangSpeaker.messageBox("NoBackupDoSaveFile", @@ -934,7 +934,7 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode) else { activateBuffer(id, MAIN_VIEW); - if(!activateBuffer(id, SUB_VIEW)) + if (!activateBuffer(id, SUB_VIEW)) switchEditViewTo(MAIN_VIEW); int res = doSaveOrNot(buf->getFullPathName()); @@ -1042,10 +1042,10 @@ bool Notepad_plus::fileCloseAllGiven(const std::vector &krvecBufferIndexes) } else if (buf->isDirty()) { - if(_activeView == MAIN_VIEW) + if (_activeView == MAIN_VIEW) { activateBuffer(id, MAIN_VIEW); - if(!activateBuffer(id, SUB_VIEW)) + if (!activateBuffer(id, SUB_VIEW)) switchEditViewTo(MAIN_VIEW); } else @@ -1120,7 +1120,7 @@ bool Notepad_plus::fileCloseAllButCurrent() else if (buf->isDirty()) { activateBuffer(id, MAIN_VIEW); - if(!activateBuffer(id, SUB_VIEW)) + if (!activateBuffer(id, SUB_VIEW)) switchEditViewTo(MAIN_VIEW); int res = doSaveOrNot(buf->getFullPathName()); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 9ce6bd284..b21c1f9f0 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -736,7 +736,7 @@ winVer NppParameters::getWindowsVersion() } pGNSI = (PGNSI) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo"); - if(pGNSI != NULL) + if (pGNSI != NULL) pGNSI(&si); else GetSystemInfo(&si); @@ -5029,16 +5029,16 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) { int leftmost = 0; element->Attribute(TEXT("leftmostDelimiter"), &leftmost); - if(leftmost > 0 && leftmost < 256) + if (leftmost > 0 && leftmost < 256) _nppGUI._leftmostDelimiter = static_cast(leftmost); int rightmost = 0; element->Attribute(TEXT("rightmostDelimiter"), &rightmost); - if(rightmost > 0 && rightmost < 256) + if (rightmost > 0 && rightmost < 256) _nppGUI._rightmostDelimiter = static_cast(rightmost); const TCHAR *delimiterSelectionOnEntireDocument = element->Attribute(TEXT("delimiterSelectionOnEntireDocument")); - if(delimiterSelectionOnEntireDocument != NULL && !lstrcmp(delimiterSelectionOnEntireDocument, TEXT("yes"))) + if (delimiterSelectionOnEntireDocument != NULL && !lstrcmp(delimiterSelectionOnEntireDocument, TEXT("yes"))) _nppGUI._delimiterSelectionOnEntireDocument = true; else _nppGUI._delimiterSelectionOnEntireDocument = false; @@ -6301,7 +6301,7 @@ int NppParameters::langTypeToCommandID(LangType lt) const default : - if(lt >= L_EXTERNAL && lt < L_END) + if (lt >= L_EXTERNAL && lt < L_END) id = lt - L_EXTERNAL + IDM_LANG_EXTERNAL; else id = IDM_LANG_TEXT; diff --git a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp index cdfe3dd8d..405dabde3 100644 --- a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp +++ b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp @@ -164,7 +164,7 @@ void AutoCompletion::getWordArray(vector & wordArray, TCHAR *beg static generic_string addTrailingSlash(generic_string path) { - if(path.length() >=1 && path[path.length() - 1] == '\\') + if (path.length() >=1 && path[path.length() - 1] == '\\') return path; else return path + L"\\"; @@ -172,7 +172,7 @@ static generic_string addTrailingSlash(generic_string path) static generic_string removeTrailingSlash(generic_string path) { - if(path.length() >= 1 && path[path.length() - 1] == '\\') + if (path.length() >= 1 && path[path.length() - 1] == '\\') return path.substr(0, path.length() - 1); else return path; @@ -204,13 +204,13 @@ static bool getRawPath(generic_string input, generic_string &rawPath_out) // a quotation mark. locale loc; size_t lastOccurrence = input.rfind(L":"); - if(lastOccurrence == std::string::npos) // No match. + if (lastOccurrence == std::string::npos) // No match. return false; - else if(lastOccurrence == 0) + else if (lastOccurrence == 0) return false; - else if(!std::isalpha(input[lastOccurrence - 1], loc)) + else if (!std::isalpha(input[lastOccurrence - 1], loc)) return false; - else if(lastOccurrence >= 2 && !isAllowedBeforeDriveLetter(input[lastOccurrence - 2])) + else if (lastOccurrence >= 2 && !isAllowedBeforeDriveLetter(input[lastOccurrence - 2])) return false; rawPath_out = input.substr(lastOccurrence - 1); @@ -220,15 +220,15 @@ static bool getRawPath(generic_string input, generic_string &rawPath_out) static bool getPathsForPathCompletion(generic_string input, generic_string &rawPath_out, generic_string &pathToMatch_out) { generic_string rawPath; - if(! getRawPath(input, rawPath)) + if (! getRawPath(input, rawPath)) { return false; } - else if(isFile(rawPath) || isFile(removeTrailingSlash(rawPath))) + else if (isFile(rawPath) || isFile(removeTrailingSlash(rawPath))) { return false; } - else if(isDirectory(rawPath)) + else if (isDirectory(rawPath)) { rawPath_out = rawPath; pathToMatch_out = rawPath; @@ -237,7 +237,7 @@ static bool getPathsForPathCompletion(generic_string input, generic_string &rawP else { size_t last_occurrence = rawPath.rfind(L"\\"); - if(last_occurrence == std::string::npos) // No match. + if (last_occurrence == std::string::npos) // No match. return false; else { @@ -270,7 +270,7 @@ void AutoCompletion::showPathCompletion() exists, this means we should list all files and directories in C:. */ generic_string rawPath, pathToMatch; - if(! getPathsForPathCompletion(currentLine, rawPath, pathToMatch)) + if (! getPathsForPathCompletion(currentLine, rawPath, pathToMatch)) return; // Get all files and directories in the path. @@ -281,7 +281,7 @@ void AutoCompletion::showPathCompletion() generic_string pathToMatchPlusSlash = addTrailingSlash(pathToMatch); generic_string searchString = pathToMatchPlusSlash + TEXT("*.*"); hFind = ::FindFirstFile(searchString.c_str(), &data); - if(hFind != INVALID_HANDLE_VALUE) + if (hFind != INVALID_HANDLE_VALUE) { // Maximum number of entries to show. Without this it appears to the user like N++ hangs when autocompleting // some really large directories (c:\windows\winxsys on my system for instance). @@ -289,18 +289,18 @@ void AutoCompletion::showPathCompletion() unsigned int counter = 0; do { - if(++counter > maxEntries) + if (++counter > maxEntries) break; - if(generic_string(data.cFileName) == TEXT(".") || generic_string(data.cFileName) == TEXT("..")) + if (generic_string(data.cFileName) == TEXT(".") || generic_string(data.cFileName) == TEXT("..")) continue; - if(! autoCompleteEntries.empty()) + if (! autoCompleteEntries.empty()) autoCompleteEntries += TEXT("\n"); autoCompleteEntries += pathToMatchPlusSlash; autoCompleteEntries += data.cFileName; - if(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // If directory, add trailing slash. + if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // If directory, add trailing slash. autoCompleteEntries += TEXT("\\"); } while(::FindNextFile(hFind, &data)); @@ -796,7 +796,7 @@ bool AutoCompletion::setLanguage(LangType language) { _funcCompletionActive = true; } - if(_funcCompletionActive) //try setting up environment + if (_funcCompletionActive) //try setting up environment { //setup defaults _ignoreCase = true; diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 83b17df53..fa077b9a6 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -884,7 +884,7 @@ bool FileManager::backupCurrentBuffer() UnicodeConvertor.fclose(); // Note that fwrite() doesn't return the number of bytes written, but rather the number of ITEMS. - if(items_written == 1) // backup file has been saved + if (items_written == 1) // backup file has been saved { buffer->setModifiedStatus(false); result = true; //all done @@ -1014,9 +1014,9 @@ bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy, g // Error, we didn't write the entire document to disk. // Note that fwrite() doesn't return the number of bytes written, but rather the number of ITEMS. - if(items_written != 1) + if (items_written != 1) { - if(error_msg != NULL) + if (error_msg != NULL) *error_msg = TEXT("Failed to save file.\nNot enough space on disk to save file?"); return false; diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index d3c4e3178..ff26e2a8e 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -2243,7 +2243,7 @@ void FindReplaceDlg::findAllIn(InWhat op) if (::SendMessage(_hParent, cmdid, 0, 0)) { - if(_findAllResult == 1) + if (_findAllResult == 1) wsprintf(_findAllResultStr, TEXT("1 hit")); else wsprintf(_findAllResultStr, TEXT("%s hits"), commafyInt(_findAllResult).c_str()); @@ -2982,7 +2982,7 @@ void Finder::addFileNameTitle(const TCHAR * fileName) void Finder::addFileHitCount(int count) { TCHAR text[20]; - if(count == 1) + if (count == 1) wsprintf(text, TEXT(" (1 hit)")); else wsprintf(text, TEXT(" (%i hits)"), count); @@ -2996,13 +2996,13 @@ void Finder::addSearchHitCount(int count, bool isMatchLines) { const TCHAR *moreInfo = isMatchLines ? TEXT(" - Line Filter Mode: only display the filtered results") :TEXT(""); TCHAR text[100]; - if(count == 1 && _nbFoundFiles == 1) + if (count == 1 && _nbFoundFiles == 1) wsprintf(text, TEXT(" (1 hit in 1 file%s)"), moreInfo); - else if(count == 1 && _nbFoundFiles != 1) + else if (count == 1 && _nbFoundFiles != 1) wsprintf(text, TEXT(" (1 hit in %i files%s)"), _nbFoundFiles, moreInfo); - else if(count != 1 && _nbFoundFiles == 1) + else if (count != 1 && _nbFoundFiles == 1) wsprintf(text, TEXT(" (%i hits in 1 file%s)"), count, moreInfo); - else if(count != 1 && _nbFoundFiles != 1) + else if (count != 1 && _nbFoundFiles != 1) wsprintf(text, TEXT(" (%i hits in %i files%s)"), count, _nbFoundFiles, moreInfo); setFinderReadOnly(false); _scintView.insertGenericTextFrom(_lastSearchHeaderPos, text); @@ -3558,7 +3558,7 @@ void FindIncrementDlg::setFindStatus(FindStatus iStatus, int nbCounted) void FindIncrementDlg::addToRebar(ReBar * rebar) { - if(_pRebar) + if (_pRebar) return; _pRebar = rebar; diff --git a/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp b/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp index e301de36f..7977c350e 100644 --- a/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp +++ b/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp @@ -268,7 +268,7 @@ bool FunctionCallTip::getCursorFunction() bool same = false; if (_funcName) { - if(_ignoreCase) + if (_ignoreCase) same = testNameNoCase(_funcName, funcToken.token, lstrlen(_funcName)) == 0; else same = generic_strncmp(_funcName, funcToken.token, lstrlen(_funcName)) == 0; diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 2b44729f3..e5c13d27c 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -552,7 +552,7 @@ void ScintillaEditView::setSpecialStyle(const Style & styleToSet) void ScintillaEditView::setHotspotStyle(Style& styleToSet) { StyleMap* styleMap; - if( _hotspotStyles.find(_currentBuffer) == _hotspotStyles.end() ) + if ( _hotspotStyles.find(_currentBuffer) == _hotspotStyles.end() ) { _hotspotStyles[_currentBuffer] = new StyleMap; } @@ -2283,9 +2283,9 @@ void ScintillaEditView::beginOrEndSelect() void ScintillaEditView::updateBeginEndSelectPosition(const bool is_insert, const int position, const int length) { - if(_beginSelectPosition != -1 && position < _beginSelectPosition - 1) + if (_beginSelectPosition != -1 && position < _beginSelectPosition - 1) { - if(is_insert) + if (is_insert) _beginSelectPosition += length; else _beginSelectPosition -= length; @@ -3332,7 +3332,7 @@ void ScintillaEditView::insertNewLineAboveCurrentLine() { generic_string newline = getEOLString(); const auto current_line = getCurrentLineNumber(); - if(current_line == 0) + if (current_line == 0) { // Special handling if caret is at first line. insertGenericTextFrom(0, newline.c_str()); @@ -3352,7 +3352,7 @@ void ScintillaEditView::insertNewLineBelowCurrentLine() generic_string newline = getEOLString(); const auto line_count = static_cast(execute(SCI_GETLINECOUNT)); const auto current_line = getCurrentLineNumber(); - if(current_line == line_count - 1) + if (current_line == line_count - 1) { // Special handling if caret is at last line. appandGenericText(newline.c_str()); diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index 8a0bd09a8..dc0d93497 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -485,7 +485,7 @@ public: long length = 0; while(*c != '\0') { - if( (*c & 0xC0) != 0x80) + if ( (*c & 0xC0) != 0x80) ++length; ++c; } diff --git a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp index d0a3877cf..264970bd1 100644 --- a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp +++ b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp @@ -600,11 +600,11 @@ void XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr) const FindResult startFound = findText(codeBeginTag.c_str(), caret, 0, 0); // This searches backwards from "caret". const FindResult endFound= findText(codeEndTag.c_str(), caret, 0, 0); // This searches backwards from "caret". - if(startFound.success) + if (startFound.success) { - if(! endFound.success) + if (! endFound.success) return; - else if(endFound.success && endFound.start <= startFound.end) + else if (endFound.success && endFound.start <= startFound.end) return; } } diff --git a/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp b/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp index 4d1117666..82bd056a7 100644 --- a/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp +++ b/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp @@ -522,7 +522,7 @@ TiXmlNodeA* TiXmlNodeA::Identify( const char* p ) TiXmlNodeA* returnNode = 0; p = SkipWhiteSpace( p ); - if( !p || !*p || *p != '<' ) + if ( !p || !*p || *p != '<' ) { return 0; } diff --git a/PowerEditor/src/TinyXml/tinyxmlparser.cpp b/PowerEditor/src/TinyXml/tinyxmlparser.cpp index bf2c26477..fdd0c4f7d 100644 --- a/PowerEditor/src/TinyXml/tinyxmlparser.cpp +++ b/PowerEditor/src/TinyXml/tinyxmlparser.cpp @@ -504,7 +504,7 @@ TiXmlNode* TiXmlNode::Identify( const TCHAR* p ) TiXmlNode* returnNode = 0; p = SkipWhiteSpace( p ); - if( !p || !*p || *p != '<' ) + if ( !p || !*p || *p != '<' ) { return 0; } diff --git a/PowerEditor/src/Utf8_16.cpp b/PowerEditor/src/Utf8_16.cpp index 75bc25cb1..fcc61ddc9 100644 --- a/PowerEditor/src/Utf8_16.cpp +++ b/PowerEditor/src/Utf8_16.cpp @@ -349,8 +349,8 @@ size_t Utf8_16_Write::fwrite(const void* p, size_t _size) buf[bufIndex++] = iter8.get(); } ++iter8; - if(bufIndex == bufSize || !iter8) { - if(!::fwrite(buf, bufIndex*sizeof(utf16), 1, m_pFile)) return 0; + if (bufIndex == bufSize || !iter8) { + if (!::fwrite(buf, bufIndex*sizeof(utf16), 1, m_pFile)) return 0; bufIndex = 0; } } diff --git a/PowerEditor/src/WinControls/AboutDlg/URLCtrl.cpp b/PowerEditor/src/WinControls/AboutDlg/URLCtrl.cpp index 819dd6794..6088f45ef 100644 --- a/PowerEditor/src/WinControls/AboutDlg/URLCtrl.cpp +++ b/PowerEditor/src/WinControls/AboutDlg/URLCtrl.cpp @@ -151,9 +151,9 @@ void URLCtrl::create(HWND itemHandle, int cmd, HWND msgDest) void URLCtrl::destroy() { - if(_hfUnderlined) + if (_hfUnderlined) ::DeleteObject(_hfUnderlined); - if(_hCursor) + if (_hCursor) ::DestroyCursor(_hCursor); } @@ -171,7 +171,7 @@ void URLCtrl::action() ::UpdateWindow(_hSelf); // Open a browser - if(_URL != TEXT("")) + if (_URL != TEXT("")) { ::ShellExecute(NULL, TEXT("open"), _URL.c_str(), NULL, NULL, SW_SHOWNORMAL); } @@ -201,9 +201,9 @@ LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) DWORD dwDTStyle = DT_SINGLELINE; //Test if centered horizontally or vertically - if(dwStyle & SS_CENTER) dwDTStyle |= DT_CENTER; - if(dwStyle & SS_RIGHT) dwDTStyle |= DT_RIGHT; - if(dwStyle & SS_CENTERIMAGE) dwDTStyle |= DT_VCENTER; + if (dwStyle & SS_CENTER) dwDTStyle |= DT_CENTER; + if (dwStyle & SS_RIGHT) dwDTStyle |= DT_RIGHT; + if (dwStyle & SS_CENTERIMAGE) dwDTStyle |= DT_VCENTER; RECT rect; ::GetClientRect(hwnd, &rect); @@ -216,7 +216,7 @@ LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) ::SetBkColor(hdc, getCtrlBgColor(GetParent(hwnd))); ///*::GetSysColor(COLOR_3DFACE)*/); // Create an underline font - if(_hfUnderlined == 0) + if (_hfUnderlined == 0) { // Get the default GUI font LOGFONT lf; @@ -266,7 +266,7 @@ LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) break; case WM_LBUTTONUP: - if(_clicking) + if (_clicking) { _clicking = false; @@ -277,12 +277,12 @@ LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) //Support using space to activate this object case WM_KEYDOWN: - if(wParam == VK_SPACE) + if (wParam == VK_SPACE) _clicking = true; break; case WM_KEYUP: - if(wParam == VK_SPACE && _clicking) + if (wParam == VK_SPACE && _clicking) { _clicking = false; diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp index 0d52f987d..a2f381b27 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp @@ -44,7 +44,7 @@ static HHOOK hookMouse = NULL; static LRESULT CALLBACK hookProcMouse(int nCode, WPARAM wParam, LPARAM lParam) { - if(nCode >= 0) + if (nCode >= 0) { switch (wParam) { diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp index 99df367d0..f81db4970 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp @@ -510,7 +510,7 @@ void goToCenter(HWND hwnd) ::GetClientRect(hParent, &rc); //If window coordinates are all zero(ie,window is minimised),then assign desktop as the parent window. - if(rc.left == 0 && rc.right == 0 && rc.top == 0 && rc.bottom == 0) + if (rc.left == 0 && rc.right == 0 && rc.top == 0 && rc.bottom == 0) { //hParent = ::GetDesktopWindow(); ::ShowWindow(hParent, SW_SHOWNORMAL); diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index ba03e15fd..11c1810f0 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -2106,7 +2106,7 @@ void trim(generic_string & str) { str.erase(pos + 1); pos = str.find_first_not_of(' '); - if(pos != generic_string::npos) str.erase(0, pos); + if (pos != generic_string::npos) str.erase(0, pos); } else str.erase(str.begin(), str.end()); }; diff --git a/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp b/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp index a760b93aa..f130f86e3 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp +++ b/PowerEditor/src/WinControls/ProjectPanel/TreeView.cpp @@ -317,7 +317,7 @@ void TreeView::dragItem(HWND parentHandle, int x, int y) hitTestInfo.pt.x = point.x; hitTestInfo.pt.y = point.y; HTREEITEM targetItem = reinterpret_cast(::SendMessage(_hSelf, TVM_HITTEST, 0, reinterpret_cast(&hitTestInfo))); - if(targetItem) + if (targetItem) { ::SendMessage(_hSelf, TVM_SELECTITEM, TVGN_DROPHILITE, reinterpret_cast(targetItem)); } diff --git a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp index 5f9cd4e54..05d82dfce 100644 --- a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp +++ b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp @@ -126,7 +126,7 @@ VOID CALLBACK CReadChangesRequest::NotificationCompletion( _ASSERTE(dwNumberOfBytesTransfered >= offsetof(FILE_NOTIFY_INFORMATION, FileName) + sizeof(WCHAR)); // This might mean overflow? Not sure. - if(!dwNumberOfBytesTransfered) + if (!dwNumberOfBytesTransfered) return; pBlock->BackupBuffer(dwNumberOfBytesTransfered); diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp index 0a8c21741..25c0d5873 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp @@ -325,7 +325,7 @@ INT_PTR CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) if (const TCHAR *fn = fd.doOpenSingleFileDlg()) { - if(wcschr(fn, ' ') != NULL) + if (wcschr(fn, ' ') != NULL) { generic_string fn_quotes(fn); fn_quotes = TEXT("\"") + fn_quotes + TEXT("\""); diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index 9e9f28dd2..93230ff0c 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -777,7 +777,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara int currentTabOn = getTabIndexAt(xPos, yPos); if (_isDragging) { - if(::GetCapture() == _hSelf) + if (::GetCapture() == _hSelf) ::ReleaseCapture(); notify(_isDraggingInside?TCN_TABDROPPED:TCN_TABDROPPEDOUTSIDE, currentTabOn); diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp index 9e02c5abe..ac9f170c0 100644 --- a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp +++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp @@ -246,7 +246,8 @@ void ToolBar::setToUglyIcons() void ToolBar::reset(bool create) { - if(create && _hSelf) { + if (create && _hSelf) + { //Store current button state information TBBUTTON tempBtn; for(size_t i = 0; i < _nbCurrentButtons; ++i) @@ -258,7 +259,7 @@ void ToolBar::reset(bool create) _hSelf = NULL; } - if(!_hSelf) + if (!_hSelf) { _hSelf = ::CreateWindowEx( WS_EX_PALETTEWINDOW, @@ -362,7 +363,7 @@ void ToolBar::doPopop(POINT chevPoint) while(start < _nbCurrentButtons) { ::SendMessage(_hSelf, TB_GETITEMRECT, start, reinterpret_cast(&btnRect)); - if(btnRect.right > width) + if (btnRect.right > width) break; ++start; } diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp index 956ca558c..e7e4ff949 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp @@ -62,7 +62,7 @@ inline static DWORD GetExStyle(HWND hWnd) { inline static BOOL ModifyStyle(HWND hWnd, DWORD dwRemove, DWORD dwAdd) { DWORD dwStyle = (DWORD)::GetWindowLongPtr(hWnd, GWL_STYLE); DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd; - if(dwStyle == dwNewStyle) + if (dwStyle == dwNewStyle) return FALSE; ::SetWindowLongPtr(hWnd, GWL_STYLE, dwNewStyle); return TRUE; @@ -71,7 +71,7 @@ inline static BOOL ModifyStyle(HWND hWnd, DWORD dwRemove, DWORD dwAdd) { inline static BOOL ModifyStyleEx(HWND hWnd, DWORD dwRemove, DWORD dwAdd) { DWORD dwStyle = (DWORD)::GetWindowLongPtr(hWnd, GWL_EXSTYLE); DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd; - if(dwStyle == dwNewStyle) + if (dwStyle == dwNewStyle) return FALSE; ::SetWindowLongPtr(hWnd, GWL_EXSTYLE, dwNewStyle); return TRUE; @@ -306,7 +306,7 @@ INT_PTR CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa { NMLVDISPINFO *pLvdi = (NMLVDISPINFO *)pNMHDR; - if(pLvdi->item.mask & LVIF_TEXT) + if (pLvdi->item.mask & LVIF_TEXT) { pLvdi->item.pszText[0] = 0; size_t index = pLvdi->item.iItem; diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index dfc77ce04..d495caa6e 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -223,7 +223,7 @@ KeyCombo ScintillaKeyMap::getKeyComboByIndex(size_t index) const { void ScintillaKeyMap::setKeyComboByIndex(int index, KeyCombo combo) { - if(combo._key == 0 && (_size > 1)) + if (combo._key == 0 && (_size > 1)) { //remove the item if possible _keyCombos.erase(_keyCombos.begin() + index); } @@ -837,7 +837,7 @@ void recordedMacroStep::PlayBack(Window* pNotepad, ScintillaEditView *pEditView) scnN.nmhdr.code = SCN_CHARADDED; scnN.nmhdr.hwndFrom = pEditView->getHSelf(); scnN.nmhdr.idFrom = 0; - if(_sParameter.empty()) + if (_sParameter.empty()) scnN.ch = 0; else scnN.ch = _sParameter.at(0); diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.h b/PowerEditor/src/WinControls/shortcut/shortcut.h index 065b84e03..3719e164a 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.h +++ b/PowerEditor/src/WinControls/shortcut/shortcut.h @@ -154,7 +154,7 @@ public: virtual generic_string toString() const; //the hotkey part generic_string toMenuItemString() const { //generic_string suitable for menu generic_string str = _menuName; - if(isEnabled()) + if (isEnabled()) { str += TEXT("\t"); str += toString(); diff --git a/PowerEditor/src/uchardet/nsLatin1Prober.cpp b/PowerEditor/src/uchardet/nsLatin1Prober.cpp index 7694ef765..7ef2a1e74 100644 --- a/PowerEditor/src/uchardet/nsLatin1Prober.cpp +++ b/PowerEditor/src/uchardet/nsLatin1Prober.cpp @@ -154,7 +154,7 @@ float nsLatin1Prober::GetConfidence(void) for (PRInt32 i = 0; i < FREQ_CAT_NUM; i++) total += mFreqCounter[i]; - if(!total) + if (!total) confidence = 0.0f; else { diff --git a/PowerEditor/src/uchardet/nsUniversalDetector.cpp b/PowerEditor/src/uchardet/nsUniversalDetector.cpp index ff06b9d65..8bcd8c589 100644 --- a/PowerEditor/src/uchardet/nsUniversalDetector.cpp +++ b/PowerEditor/src/uchardet/nsUniversalDetector.cpp @@ -102,7 +102,7 @@ nsUniversalDetector::Reset() nsresult nsUniversalDetector::HandleData(const char* aBuf, PRUint32 aLen) { - if(mDone) + if (mDone) return NS_OK; if (aLen > 0)