diff --git a/PowerEditor/src/DarkMode/DarkMode.cpp b/PowerEditor/src/DarkMode/DarkMode.cpp index a6de389fe..ae39218a8 100644 --- a/PowerEditor/src/DarkMode/DarkMode.cpp +++ b/PowerEditor/src/DarkMode/DarkMode.cpp @@ -125,9 +125,10 @@ bool AllowDarkModeForWindow(HWND hWnd, bool allow) bool IsHighContrast() { - HIGHCONTRASTW highContrast = { sizeof(highContrast) }; - if (SystemParametersInfoW(SPI_GETHIGHCONTRAST, sizeof(highContrast), &highContrast, FALSE)) - return highContrast.dwFlags & HCF_HIGHCONTRASTON; + HIGHCONTRASTW highContrast{}; + highContrast.cbSize = sizeof(HIGHCONTRASTW); + if (SystemParametersInfoW(SPI_GETHIGHCONTRAST, sizeof(HIGHCONTRASTW), &highContrast, FALSE)) + return (highContrast.dwFlags & HCF_HIGHCONTRASTON) == HCF_HIGHCONTRASTON; return false; } diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 219db92d1..a1c42c07c 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -785,7 +785,7 @@ bool str2numberVector(generic_string str2convert, std::vector& numVect) } std::vector v = stringSplit(str2convert, TEXT(" ")); - for (auto i : v) + for (const auto& i : v) { // Don't treat empty string and the number greater than 9999 if (!i.empty() && i.length() < 5) @@ -827,7 +827,7 @@ generic_string stringTakeWhileAdmissable(const generic_string& input, const gene } -double stodLocale(const generic_string& str, _locale_t loc, size_t* idx) +double stodLocale(const generic_string& str, [[maybe_unused]] _locale_t loc, size_t* idx) { // Copied from the std::stod implementation but uses _wcstod_l instead of wcstod. const wchar_t* ptr = str.c_str(); @@ -1690,7 +1690,7 @@ void Version::setVersionFrom(const generic_string& filePath) return; unsigned char* buffer = new unsigned char[bufferSize]; - ::GetFileVersionInfo(filePath.c_str(), uselessArg, bufferSize, buffer); + ::GetFileVersionInfo(filePath.c_str(), 0, bufferSize, buffer); VS_FIXEDFILEINFO* lpFileInfo = nullptr; UINT cbFileInfo = 0; diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 5ae53793b..76b17cddc 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -1803,8 +1803,9 @@ bool NppParameters::isInFontList(const generic_string& fontName2Search) const HFONT NppParameters::getDefaultUIFont() { static HFONT g_defaultMessageFont = []() { - NONCLIENTMETRICS ncm = { sizeof(ncm) }; - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0); + NONCLIENTMETRICS ncm{}; + ncm.cbSize = sizeof(NONCLIENTMETRICS); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0); return CreateFontIndirect(&ncm.lfMessageFont); }(); @@ -3280,7 +3281,7 @@ void NppParameters::writeDefaultUDL() { bool firstCleanDone = false; std::vector deleteState; - for (auto udl : _pXmlUserLangsDoc) + for (const auto& udl : _pXmlUserLangsDoc) { if (!_pXmlUserLangDoc) { @@ -3337,7 +3338,7 @@ void NppParameters::writeDefaultUDL() void NppParameters::writeNonDefaultUDL() { - for (auto udl : _pXmlUserLangsDoc) + for (auto& udl : _pXmlUserLangsDoc) { if (udl._isDirty && udl._udlXmlDoc != nullptr && udl._udlXmlDoc != _pXmlUserLangDoc) { diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index b7c6cbb77..ef1fd7fea 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -1256,7 +1256,8 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA HWND hDirCombo = ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO); // Change handler of edit element in the comboboxes to support Ctrl+Backspace - COMBOBOXINFO cbinfo = { sizeof(COMBOBOXINFO) }; + COMBOBOXINFO cbinfo{}; + cbinfo.cbSize = sizeof(COMBOBOXINFO); GetComboBoxInfo(hFindCombo, &cbinfo); if (!cbinfo.hwndItem) return FALSE; @@ -1689,7 +1690,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA { setStatusbarMessage(TEXT(""), FSNoMessage); const int filterSize = 512; - TCHAR filters[filterSize + 1]; + TCHAR filters[filterSize + 1] = { '\0' }; filters[filterSize] = '\0'; TCHAR directory[MAX_PATH]; ::GetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters, filterSize); @@ -5494,8 +5495,8 @@ int Progress::createProgressWindow() int height = cPBheight + cBTNheight + textHeight + progressBarPadding + morePadding; - POINT center; - RECT callerRect; + POINT center{}; + RECT callerRect{}; ::GetWindowRect(_hCallerWnd, &callerRect); center.x = (callerRect.left + callerRect.right) / 2; center.y = (callerRect.top + callerRect.bottom) / 2; diff --git a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp index 06994f46d..d2a583a82 100644 --- a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp @@ -1017,15 +1017,15 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA _ctrlTab.createTabs(_wVector); _ctrlTab.display(); - RECT arc; + RECT arc{}; ::GetWindowRect(::GetDlgItem(_hSelf, IDC_IMPORT_BUTTON), &arc); - POINT p; + POINT p{}; p.x = arc.left; p.y = arc.bottom; ::ScreenToClient(_hSelf, &p); - RECT rc; + RECT rc{}; getClientRect(rc); rc.top = p.y + 10; rc.bottom -= 20; @@ -1051,14 +1051,14 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA if (!(BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_UD_PERCENTAGE_SLIDER, BM_GETCHECK, 0, 0))) ::EnableWindow(::GetDlgItem(_hSelf, IDC_UD_PERCENTAGE_SLIDER), FALSE); } - SCROLLINFO si; + SCROLLINFO si{}; si.cbSize = sizeof(si); si.fMask = SIF_RANGE; //| SIF_PAGE; si.nMin = 0; si.nMax = 0; ::SetScrollInfo(_hSelf, SB_VERT, &si, TRUE); - TCHAR temp[32]; + TCHAR temp[32] = { '\0' }; generic_string udlVersion = TEXT("User Defined Language v."); udlVersion += _itow(SCE_UDL_VERSION_MAJOR, temp, 10); udlVersion += TEXT("."); @@ -1221,7 +1221,7 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA { auto i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); const size_t langNameLen = 256; - TCHAR langName[langNameLen + 1]; + TCHAR langName[langNameLen + 1] = { '\0' }; auto cbTextLen = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETLBTEXTLEN, i, 0); if (static_cast(cbTextLen) > langNameLen) return TRUE; @@ -1250,7 +1250,7 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA { auto i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); const size_t langNameLen = 256; - TCHAR langName[langNameLen + 1]; + TCHAR langName[langNameLen + 1] = { '\0' }; auto cbTextLen = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETLBTEXTLEN, i, 0); if (static_cast(cbTextLen) > langNameLen) return TRUE; @@ -1454,7 +1454,7 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA int maxPos = originalHight - _currentHight; // Set the vertical scrolling range and page size - SCROLLINFO si; + SCROLLINFO si{}; si.cbSize = sizeof(si); si.fMask = SIF_RANGE | SIF_PAGE; si.nMin = 0; @@ -1618,8 +1618,7 @@ intptr_t CALLBACK StringDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { case IDOK : { - TCHAR tmpName[langNameLenMax]; - tmpName[0] = '\0'; + TCHAR tmpName[langNameLenMax] = { '\0' }; ::GetDlgItemText(_hSelf, IDC_STRING_EDIT, tmpName, langNameLenMax); _textValue = tmpName; ::EndDialog(_hSelf, reinterpret_cast(_textValue.c_str())); @@ -1684,7 +1683,7 @@ LRESULT StringDlg::customEditProc(HWND hEdit, UINT msg, WPARAM wParam, LPARAM lP return CallWindowProc(pSelf->_oldEditProc, hEdit, msg, wParam, lParam); } -bool StringDlg::isAllowed(const generic_string & txt) +bool StringDlg::isAllowed([[maybe_unused]] const generic_string & txt) { #ifndef __MINGW32__ for (auto ch : txt) diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp index ddd05b0b9..8da876006 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp @@ -376,7 +376,7 @@ LRESULT DockingCont::runProcCaption(HWND hwnd, UINT Message, WPARAM wParam, LPAR if ((_bCaptionTT == TRUE) || (_hoverMPos == posClose)) { - TRACKMOUSEEVENT tme; + TRACKMOUSEEVENT tme{}; tme.cbSize = sizeof(tme); tme.hwndTrack = hwnd; tme.dwFlags = TME_LEAVE | TME_HOVER; @@ -717,7 +717,15 @@ LRESULT DockingCont::runProcTab(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l int nSelTab = TabCtrl_GetCurSel(hwnd); for (int i = 0; i < nTabs; ++i) { - DRAWITEMSTRUCT dis = { ODT_TAB, id, (UINT)i, ODA_DRAWENTIRE, ODS_DEFAULT, hwnd, hdc }; + DRAWITEMSTRUCT dis{}; + dis.CtlType = ODT_TAB; + dis.CtlID = id; + dis.itemID = static_cast(i); + dis.itemAction = ODA_DRAWENTIRE; + dis.itemState = ODS_DEFAULT; + dis.hwndItem = hwnd; + dis.hDC = hdc; + TabCtrl_GetItemRect(hwnd, i, &dis.rcItem); if (i == nFocusTab) @@ -857,7 +865,7 @@ LRESULT DockingCont::runProcTab(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l if ((_bTabTTHover == FALSE) && (iItem != iItemSel)) { - TRACKMOUSEEVENT tme; + TRACKMOUSEEVENT tme{}; tme.cbSize = sizeof(tme); tme.hwndTrack = hwnd; tme.dwFlags = TME_LEAVE | TME_HOVER; @@ -1324,7 +1332,7 @@ void DockingCont::onSize() SWP_NOZORDER); // Notify switch in - NMHDR nmhdr; + NMHDR nmhdr{}; nmhdr.code = DMN_FLOATDROPPED; nmhdr.hwndFrom = _hSelf; nmhdr.idFrom = 0; @@ -1543,7 +1551,7 @@ void DockingCont::selectTab(int iTab) ::SetFocus(((tTbData*)tcItem.lParam)->hClient); // Notify switch in - NMHDR nmhdr; + NMHDR nmhdr{}; nmhdr.code = DMN_SWITCHIN; nmhdr.hwndFrom = _hSelf; nmhdr.idFrom = 0; @@ -1559,7 +1567,7 @@ void DockingCont::selectTab(int iTab) ::ShowWindow(((tTbData*)tcItem.lParam)->hClient, SW_HIDE); // Notify switch off - NMHDR nmhdr; + NMHDR nmhdr{}; nmhdr.code = DMN_SWITCHOFF; nmhdr.hwndFrom = _hSelf; nmhdr.idFrom = 0; diff --git a/PowerEditor/src/WinControls/FunctionList/functionParser.cpp b/PowerEditor/src/WinControls/FunctionList/functionParser.cpp index 078ddeb4d..806a2dd36 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionParser.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionParser.cpp @@ -564,7 +564,7 @@ size_t FunctionZoneParser::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSy return targetEnd; } -void FunctionZoneParser::classParse(vector & foundInfos, vector< pair > &scannedZones, const std::vector< std::pair > & commentZones, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName) +void FunctionZoneParser::classParse(vector & foundInfos, vector< pair > &scannedZones, const std::vector< std::pair > & commentZones, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string /*classStructName*/) { if (begin >= end) return; @@ -582,7 +582,7 @@ void FunctionZoneParser::classParse(vector & foundInfos, vector< pair // Get class name intptr_t foundPos = 0; - generic_string classStructName = parseSubLevel(targetStart, targetEnd, _classNameExprArray, foundPos, ppEditView); + generic_string subLevelClassStructName = parseSubLevel(targetStart, targetEnd, _classNameExprArray, foundPos, ppEditView); if (!_openSymbole.empty() && !_closeSymbole.empty()) @@ -603,7 +603,7 @@ void FunctionZoneParser::classParse(vector & foundInfos, vector< pair //vector< generic_string > emptyArray; if (!isInZones(targetStart, commentZones)) { - funcParse(foundInfos, targetStart, targetEnd, ppEditView, classStructName, &commentZones); + funcParse(foundInfos, targetStart, targetEnd, ppEditView, subLevelClassStructName, &commentZones); } begin = targetStart + (targetEnd - targetStart); targetStart = (*ppEditView)->searchInTarget(_rangeExpr.c_str(), _rangeExpr.length(), begin, end); diff --git a/PowerEditor/src/uchardet/CharDistribution.cpp b/PowerEditor/src/uchardet/CharDistribution.cpp index 2ccda334a..c04eba8ee 100644 --- a/PowerEditor/src/uchardet/CharDistribution.cpp +++ b/PowerEditor/src/uchardet/CharDistribution.cpp @@ -57,7 +57,7 @@ float CharDistributionAnalysis::GetConfidence(void) if (mTotalChars != mFreqChars) { - float r = mFreqChars / ((mTotalChars - mFreqChars) * mTypicalDistributionRatio); + float r = static_cast(mFreqChars) / (static_cast(mTotalChars - mFreqChars) * mTypicalDistributionRatio); if (r < SURE_YES) return r; diff --git a/PowerEditor/src/uchardet/JpCntx.cpp b/PowerEditor/src/uchardet/JpCntx.cpp index d6a437381..a0c98edc2 100644 --- a/PowerEditor/src/uchardet/JpCntx.cpp +++ b/PowerEditor/src/uchardet/JpCntx.cpp @@ -186,7 +186,7 @@ float JapaneseContextAnalysis::GetConfidence(void) { //This is just one way to calculate confidence. It works well for me. if (mTotalRel > mDataThreshold) - return ((float)(mTotalRel - mRelSample[0]))/mTotalRel; + return static_cast(mTotalRel - mRelSample[0]) / static_cast(mTotalRel); else return (float)DONT_KNOW; } diff --git a/PowerEditor/src/uchardet/nsLatin1Prober.cpp b/PowerEditor/src/uchardet/nsLatin1Prober.cpp index 7ef2a1e74..642b18e49 100644 --- a/PowerEditor/src/uchardet/nsLatin1Prober.cpp +++ b/PowerEditor/src/uchardet/nsLatin1Prober.cpp @@ -158,8 +158,9 @@ float nsLatin1Prober::GetConfidence(void) confidence = 0.0f; else { - confidence = mFreqCounter[3]*1.0f / total; - confidence -= mFreqCounter[1]*20.0f/total; + const float floatTotal = static_cast(total); + confidence = static_cast(mFreqCounter[3]) / floatTotal; + confidence -= static_cast(mFreqCounter[1]) * 20.0f / floatTotal; } if (confidence < 0.0f) diff --git a/PowerEditor/src/uchardet/nsPkgInt.h b/PowerEditor/src/uchardet/nsPkgInt.h index b1e66785e..72bcaa564 100644 --- a/PowerEditor/src/uchardet/nsPkgInt.h +++ b/PowerEditor/src/uchardet/nsPkgInt.h @@ -72,6 +72,7 @@ struct nsPkgInt { nsPkgInt(nsIdxSft a,nsSftMsk b, nsBitSft c,nsUnitMsk d,const PRUint32* const e) :idxsft(a), sftmsk(b), bitsft(c), unitmsk(d), data(e){} nsPkgInt(); + nsPkgInt(const nsPkgInt&) = default; nsPkgInt operator= (const nsPkgInt&); }; diff --git a/PowerEditor/src/uchardet/nsSBCharSetProber.cpp b/PowerEditor/src/uchardet/nsSBCharSetProber.cpp index 3a88fdf31..8e17a0bcb 100644 --- a/PowerEditor/src/uchardet/nsSBCharSetProber.cpp +++ b/PowerEditor/src/uchardet/nsSBCharSetProber.cpp @@ -102,8 +102,8 @@ float nsSingleByteCharSetProber::GetConfidence(void) float r; if (mTotalSeqs > 0) { - r = ((float)1.0) * mSeqCounters[POSITIVE_CAT] / mTotalSeqs / mModel->mTypicalPositiveRatio; - r = r*mFreqChar/mTotalChar; + r = static_cast(mSeqCounters[POSITIVE_CAT]) / static_cast(mTotalSeqs) / mModel->mTypicalPositiveRatio; + r = r * static_cast(mFreqChar) / static_cast(mTotalChar); if (r >= (float)1.00) r = (float)0.99; return r;