From f4f7119a2f6e101831d89f758fb008c3ad3607e1 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Mon, 12 Dec 2016 21:56:50 +0100 Subject: [PATCH] Use nullptr instead of NULL Signed-off-by: Sven Strickroth --- src/TortoiseMerge/AboutDlg.cpp | 6 +- src/TortoiseMerge/AboutDlg.h | 2 +- src/TortoiseMerge/BaseView.cpp | 154 +++++++++++++++--------------- src/TortoiseMerge/BaseView.h | 2 +- src/TortoiseMerge/CustomMFCRibbonButton.h | 2 +- src/TortoiseMerge/DiffData.cpp | 16 ++-- src/TortoiseMerge/EncodingDlg.h | 4 +- src/TortoiseMerge/FilePatchesDlg.cpp | 24 ++--- src/TortoiseMerge/FilePatchesDlg.h | 2 +- src/TortoiseMerge/FileTextLines.cpp | 24 ++--- src/TortoiseMerge/FileTextLines.h | 2 +- src/TortoiseMerge/FindDlg.cpp | 4 +- src/TortoiseMerge/FindDlg.h | 2 +- src/TortoiseMerge/GotoLineDlg.cpp | 2 +- src/TortoiseMerge/GotoLineDlg.h | 2 +- src/TortoiseMerge/LineDiffBar.cpp | 16 ++-- src/TortoiseMerge/LocatorBar.cpp | 14 +-- src/TortoiseMerge/MainFrm.cpp | 78 ++++++++------- src/TortoiseMerge/MovedBlocks.cpp | 28 +++--- src/TortoiseMerge/OpenDlg.cpp | 10 +- src/TortoiseMerge/OpenDlg.h | 2 +- src/TortoiseMerge/RegexFilterDlg.cpp | 2 +- src/TortoiseMerge/RegexFilterDlg.h | 2 +- src/TortoiseMerge/RegexFiltersDlg.cpp | 4 +- src/TortoiseMerge/RegexFiltersDlg.h | 2 +- src/TortoiseMerge/SetMainPage.cpp | 2 +- src/TortoiseMerge/Settings.cpp | 12 +-- src/TortoiseMerge/Settings.h | 4 +- src/TortoiseMerge/TempFile.cpp | 6 +- src/TortoiseMerge/TortoiseMerge.cpp | 38 ++++---- src/TortoiseMerge/Undo.cpp | 4 +- src/TortoiseMerge/XSplitter.cpp | 28 +++--- 32 files changed, 245 insertions(+), 255 deletions(-) diff --git a/src/TortoiseMerge/AboutDlg.cpp b/src/TortoiseMerge/AboutDlg.cpp index c6a3bdd81..6504bed15 100644 --- a/src/TortoiseMerge/AboutDlg.cpp +++ b/src/TortoiseMerge/AboutDlg.cpp @@ -28,7 +28,7 @@ // CAboutDlg dialog IMPLEMENT_DYNAMIC(CAboutDlg, CStandAloneDialog) -CAboutDlg::CAboutDlg(CWnd* pParent /*=NULL*/) +CAboutDlg::CAboutDlg(CWnd* pParent /*=nullptr*/) : CStandAloneDialog(CAboutDlg::IDD, pParent) { } @@ -74,8 +74,8 @@ BOOL CAboutDlg::OnInitDialog() m_renderDest.Create32BitFromPicture(&tmpPic,468,64); m_waterEffect.Create(468,64); - SetTimer(ID_EFFECTTIMER, 40, NULL); - SetTimer(ID_DROPTIMER, 300, NULL); + SetTimer(ID_EFFECTTIMER, 40, nullptr); + SetTimer(ID_DROPTIMER, 300, nullptr); m_cWebLink.SetURL(L"https://tortoisegit.org/"); m_cSupportLink.SetURL(L"http://tortoisesvn.tigris.org/contributors.html"); diff --git a/src/TortoiseMerge/AboutDlg.h b/src/TortoiseMerge/AboutDlg.h index d6b9b085b..f42f7930f 100644 --- a/src/TortoiseMerge/AboutDlg.h +++ b/src/TortoiseMerge/AboutDlg.h @@ -37,7 +37,7 @@ class CAboutDlg : public CStandAloneDialog DECLARE_DYNAMIC(CAboutDlg) public: - CAboutDlg(CWnd* pParent = NULL); // standard constructor + CAboutDlg(CWnd* pParent = nullptr); // standard constructor virtual ~CAboutDlg(); // Dialog Data diff --git a/src/TortoiseMerge/BaseView.cpp b/src/TortoiseMerge/BaseView.cpp index f60616555..1a95dac53 100644 --- a/src/TortoiseMerge/BaseView.cpp +++ b/src/TortoiseMerge/BaseView.cpp @@ -51,14 +51,14 @@ #define IDT_SCROLLTIMER 101 -CBaseView * CBaseView::m_pwndLeft = NULL; -CBaseView * CBaseView::m_pwndRight = NULL; -CBaseView * CBaseView::m_pwndBottom = NULL; -CLocatorBar * CBaseView::m_pwndLocator = NULL; -CLineDiffBar * CBaseView::m_pwndLineDiffBar = NULL; -CMFCStatusBar * CBaseView::m_pwndStatusBar = NULL; -CMFCRibbonStatusBar * CBaseView::m_pwndRibbonStatusBar = NULL; -CMainFrame * CBaseView::m_pMainFrame = NULL; +CBaseView* CBaseView::m_pwndLeft = nullptr; +CBaseView* CBaseView::m_pwndRight = nullptr; +CBaseView* CBaseView::m_pwndBottom = nullptr; +CLocatorBar* CBaseView::m_pwndLocator = nullptr; +CLineDiffBar* CBaseView::m_pwndLineDiffBar = nullptr; +CMFCStatusBar* CBaseView::m_pwndStatusBar = nullptr; +CMFCRibbonStatusBar* CBaseView::m_pwndRibbonStatusBar = nullptr; +CMainFrame* CBaseView::m_pMainFrame = nullptr; CBaseView::Screen2View CBaseView::m_Screen2View; const UINT CBaseView::m_FindDialogMessage = RegisterWindowMessage(FINDMSGSTRING); @@ -67,10 +67,10 @@ allviewstate CBaseView::m_AllState; IMPLEMENT_DYNCREATE(CBaseView, CView) CBaseView::CBaseView() - : m_pCacheBitmap(NULL) - , m_pViewData(NULL) - , m_pOtherViewData(NULL) - , m_pOtherView(NULL) + : m_pCacheBitmap(nullptr) + , m_pViewData(nullptr) + , m_pOtherViewData(nullptr) + , m_pOtherView(nullptr) , m_nLineHeight(-1) , m_nCharWidth(-1) , m_nScreenChars(-1) @@ -97,14 +97,14 @@ CBaseView::CBaseView() , m_bOtherDiffChecked(false) , m_bInlineWordDiff(true) , m_bWhitespaceInlineDiffs(false) - , m_pState(NULL) - , m_pFindDialog(NULL) + , m_pState(nullptr) + , m_pFindDialog(nullptr) , m_nStatusBarID(0) , m_bMatchCase(false) , m_bLimitToDiff(true) , m_bWholeWord(false) - , m_pDC(NULL) - , m_pWorkingFile(NULL) + , m_pDC(nullptr) + , m_pWorkingFile(nullptr) , m_bInsertMode(true) , m_bEditorConfigEnabled(false) , m_bEditorConfigLoaded(2) // 2 = not evaluated @@ -127,7 +127,7 @@ CBaseView::CBaseView() m_nTabSize = (int)(DWORD)CRegDWORD(L"Software\\TortoiseGitMerge\\TabSize", 4); m_nTabMode = (int)(DWORD)CRegDWORD(L"Software\\TortoiseGitMerge\\TabMode", TABMODE_NONE); m_bEditorConfigEnabled = !!(DWORD)CRegDWORD(L"Software\\TortoiseGitMerge\\EnableEditorConfig", FALSE); - std::fill_n(m_apFonts, fontsCount, (CFont*)NULL); + std::fill_n(m_apFonts, fontsCount, (CFont*)nullptr); m_hConflictedIcon = LoadIcon(IDI_CONFLICTEDLINE); m_hConflictedIgnoredIcon = LoadIcon(IDI_CONFLICTEDIGNOREDLINE); m_hRemovedIcon = LoadIcon(IDI_REMOVEDLINE); @@ -468,10 +468,10 @@ BOOL CBaseView::PreCreateWindow(CREATESTRUCT& cs) cs.dwExStyle |= WS_EX_CLIENTEDGE; cs.style &= ~WS_BORDER; cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, - ::LoadCursor(NULL, IDC_ARROW), reinterpret_cast(COLOR_WINDOW+1), NULL); + ::LoadCursor(nullptr, IDC_ARROW), reinterpret_cast(COLOR_WINDOW + 1), nullptr); CWnd *pParentWnd = CWnd::FromHandlePermanent(cs.hwndParent); - if (pParentWnd == NULL || ! pParentWnd->IsKindOf(RUNTIME_CLASS(CSplitterWnd))) + if (!pParentWnd || !pParentWnd->IsKindOf(RUNTIME_CLASS(CSplitterWnd))) { // View must always create its own scrollbars, // if only it's not used within splitter @@ -488,7 +488,7 @@ CFont* CBaseView::GetFont(BOOL bItalic /*= FALSE*/, BOOL bBold /*= FALSE*/) nIndex |= 1; if (bItalic) nIndex |= 2; - if (m_apFonts[nIndex] == NULL) + if (!m_apFonts[nIndex]) { m_apFonts[nIndex] = new CFont; m_lfBaseFont.lfCharSet = DEFAULT_CHARSET; @@ -504,7 +504,7 @@ CFont* CBaseView::GetFont(BOOL bItalic /*= FALSE*/, BOOL bBold /*= FALSE*/) if (!m_apFonts[nIndex]->CreateFontIndirect(&m_lfBaseFont)) { delete m_apFonts[nIndex]; - m_apFonts[nIndex] = NULL; + m_apFonts[nIndex] = nullptr; return CView::GetFont(); } } @@ -514,7 +514,7 @@ CFont* CBaseView::GetFont(BOOL bItalic /*= FALSE*/, BOOL bBold /*= FALSE*/) void CBaseView::CalcLineCharDim() { CDC *pDC = GetDC(); - if (pDC == nullptr) + if (!pDC) return; CFont *pOldFont = pDC->SelectObject(GetFont()); const CSize szCharExt = pDC->GetTextExtent(L"X"); @@ -604,7 +604,7 @@ int CBaseView::GetMaxLineLength() int CBaseView::GetLineLengthWithTabsConverted(int index) { - if (m_pViewData == NULL) + if (!m_pViewData) return 0; if (m_pViewData->GetCount() == 0) return 0; @@ -635,7 +635,7 @@ int CBaseView::GetLineLengthWithTabsConverted(int index) int CBaseView::GetLineLength(int index) { - if (m_pViewData == NULL) + if (!m_pViewData) return 0; if (m_pViewData->GetCount() == 0) return 0; @@ -655,7 +655,7 @@ int CBaseView::GetLineLength(int index) int CBaseView::GetViewLineLength(int nViewLine) const { - if (m_pViewData == NULL) + if (!m_pViewData) return 0; if (m_pViewData->GetCount() <= nViewLine) return 0; @@ -666,7 +666,7 @@ int CBaseView::GetViewLineLength(int nViewLine) const int CBaseView::GetLineCount() const { - if (m_pViewData == NULL) + if (!m_pViewData) return 1; int nLineCount = (int)m_Screen2View.size(); ASSERT(nLineCount >= 0); @@ -680,7 +680,7 @@ int CBaseView::GetSubLineOffset(int index) CString CBaseView::GetViewLineChars(int nViewLine) const { - if (m_pViewData == NULL) + if (!m_pViewData) return 0; if (m_pViewData->GetCount() <= nViewLine) return 0; @@ -689,7 +689,7 @@ CString CBaseView::GetViewLineChars(int nViewLine) const CString CBaseView::GetLineChars(int index) { - if (m_pViewData == NULL) + if (!m_pViewData) return 0; if (m_pViewData->GetCount() == 0) return 0; @@ -716,8 +716,8 @@ void CBaseView::CheckOtherView() if (m_bOtherDiffChecked) return; // find out what the 'other' file is - m_pOtherViewData = NULL; - m_pOtherView = NULL; + m_pOtherViewData = nullptr; + m_pOtherView = nullptr; if (this == m_pwndLeft && IsRightViewGood()) { m_pOtherViewData = m_pwndRight->m_pViewData; @@ -790,7 +790,7 @@ CString CBaseView::GetWhitespaceString(CViewData *viewData, int nStartBlock, int bool CBaseView::IsBlockWhitespaceOnly(int nLineIndex, bool& bIdentical, int& blockstart, int& blockend) { - if (m_pViewData == NULL) + if (!m_pViewData) return false; bIdentical = false; CheckOtherView(); @@ -851,7 +851,7 @@ bool CBaseView::IsViewLineHidden(CViewData * pViewData, int nViewLine) int CBaseView::GetLineNumber(int index) const { - if (m_pViewData == NULL) + if (!m_pViewData) return -1; int viewLine = GetViewLineForScreen(index); if (m_pViewData->GetLineNumber(viewLine)==DIFF_EMPTYLINENUMBER) @@ -1246,7 +1246,7 @@ void CBaseView::DrawMargin(CDC *pdc, const CRect &rect, int nLineIndex) if ((nLineIndex >= 0)&&(m_pViewData)&&(m_pViewData->GetCount())) { int nViewLine = GetViewLineForScreen(nLineIndex); - HICON icon = NULL; + HICON icon = nullptr; ASSERT(nViewLine<(int)m_ScreenedViewLine.size()); TScreenedViewLine::EIcon eIcon = m_ScreenedViewLine[nViewLine].eIcon; if (eIcon==TScreenedViewLine::ICN_UNKNOWN) @@ -1338,9 +1338,7 @@ void CBaseView::DrawMargin(CDC *pdc, const CRect &rect, int nLineIndex) if (icon) - { - ::DrawIconEx(pdc->m_hDC, rect.left + 2, rect.top + (rect.Height()-16)/2, icon, 16, 16, NULL, NULL, DI_NORMAL); - } + ::DrawIconEx(pdc->m_hDC, rect.left + 2, rect.top + (rect.Height() - 16) / 2, icon, 16, 16, 0, nullptr, DI_NORMAL); if ((m_bViewLinenumbers)&&(m_nDigits)) { int nSubLine = GetSubLineOffset(nLineIndex); @@ -1373,7 +1371,7 @@ void CBaseView::DrawMargin(CDC *pdc, const CRect &rect, int nLineIndex) pdc->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT)); pdc->SelectObject(GetFont()); - pdc->ExtTextOut(rect.left + 18, rect.top, ETO_CLIPPED, &rect, sLinenumber, NULL); + pdc->ExtTextOut(rect.left + 18, rect.top, ETO_CLIPPED, &rect, sLinenumber, nullptr); } } } @@ -1439,7 +1437,7 @@ void CBaseView::DrawHeader(CDC *pdc, const CRect &rect) sViewTitle = m_sWindowName.Mid(offset); } pdc->ExtTextOut(std::max(rect.left + (rect.Width()-nStringLength)/2, 1), - rect.top+(HEADERHEIGHT/2), ETO_CLIPPED, textrect, sViewTitle, NULL); + rect.top + (HEADERHEIGHT / 2), ETO_CLIPPED, textrect, sViewTitle, nullptr); if (this->GetFocus() == this) pdc->DrawEdge(textrect, EDGE_BUMP, BF_RECT); else @@ -1456,7 +1454,7 @@ void CBaseView::OnDraw(CDC * pDC) CDC cacheDC; VERIFY(cacheDC.CreateCompatibleDC(pDC)); - if (m_pCacheBitmap == NULL) + if (!m_pCacheBitmap) { m_pCacheBitmap = new CBitmap; VERIFY(m_pCacheBitmap->CreateCompatibleBitmap(pDC, rcClient.Width(), nLineHeight)); @@ -1610,7 +1608,7 @@ void CBaseView::DrawLineEnding(CDC *pDC, const CRect &rc, int nLineIndex, const EOL ending = m_pViewData->GetLineEnding(viewLine); if (m_bIconLFs) { - HICON hEndingIcon = NULL; + HICON hEndingIcon = nullptr; switch (ending) { case EOL_CR: hEndingIcon = m_hLineEndingCR; break; @@ -1630,7 +1628,7 @@ void CBaseView::DrawLineEnding(CDC *pDC, const CRect &rc, int nLineIndex, const pDC->FillSolidRect(origin.x, origin.y, rc.Height(), rc.Height(), InlineDiffColor(nLineIndex)); } - DrawIconEx(pDC->GetSafeHdc(), origin.x, origin.y, hEndingIcon, rc.Height(), rc.Height(), NULL, NULL, DI_NORMAL); + DrawIconEx(pDC->GetSafeHdc(), origin.x, origin.y, hEndingIcon, rc.Height(), rc.Height(), 0, nullptr, DI_NORMAL); } else { @@ -1938,7 +1936,7 @@ void CBaseView::DrawTextLine( leftcoord += lower > 0 ? posBuffer.get()[lower - 1] : 0; } - pDC->ExtTextOut(leftcoord, coords.y, ETO_CLIPPED, &rc, p_zBlockText+offset, min(nTextLength, 4094), NULL); + pDC->ExtTextOut(leftcoord, coords.y, ETO_CLIPPED, &rc, p_zBlockText + offset, min(nTextLength, 4094), nullptr); if ((second.shot != second.background) && (itStart->first == nStart + nTextOffset)) pDC->FillSolidRect(nLeft - 1, rc.top, 1, rc.Height(), second.shot); } @@ -2350,7 +2348,7 @@ BOOL CBaseView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if (m_pViewData->GetHideState(viewLine) == HIDESTATE_MARKER) { - ::SetCursor(::LoadCursor(NULL, IDC_HAND)); + ::SetCursor(::LoadCursor(nullptr, IDC_HAND)); return TRUE; } } @@ -2364,11 +2362,11 @@ BOOL CBaseView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) } if (m_nMouseLine >= 0) { - ::SetCursor(::LoadCursor(NULL, IDC_IBEAM)); // Set To Edit Cursor + ::SetCursor(::LoadCursor(nullptr, IDC_IBEAM)); // Set To Edit Cursor return TRUE; } - ::SetCursor(::LoadCursor(NULL, IDC_ARROW)); // Set To Arrow Cursor + ::SetCursor(::LoadCursor(nullptr, IDC_ARROW)); // Set To Arrow Cursor return TRUE; } return CView::OnSetCursor(pWnd, nHitTest, message); @@ -2948,10 +2946,8 @@ INT_PTR CBaseView::OnToolHitTest(CPoint point, TOOLINFO* pTI) const // we want multi line tooltips CToolTipCtrl* pToolTip = AfxGetModuleThreadState()->m_pToolTip; - if (pToolTip->GetSafeHwnd() != NULL) - { + if (pToolTip->GetSafeHwnd()) pToolTip->SetMaxTipWidth(INT_MAX); - } return (textrect.PtInRect(point) ? 1 : 2); } @@ -3415,22 +3411,22 @@ void CBaseView::OnMouseMove(UINT nFlags, CPoint point) if (nMouseLine < m_nTopLine) { ScrollAllToLine(m_nTopLine-1, TRUE); - SetTimer(IDT_SCROLLTIMER, 20, NULL); + SetTimer(IDT_SCROLLTIMER, 20, nullptr); } if (nMouseLine >= m_nTopLine + GetScreenLines() - 2) { ScrollAllToLine(m_nTopLine+1, TRUE); - SetTimer(IDT_SCROLLTIMER, 20, NULL); + SetTimer(IDT_SCROLLTIMER, 20, nullptr); } if (!m_pMainFrame->m_bWrapLines && ((m_nOffsetChar + (point.x - GetMarginWidth()) / GetCharWidth()) <= m_nOffsetChar)) { ScrollAllSide(-1); - SetTimer(IDT_SCROLLTIMER, 20, NULL); + SetTimer(IDT_SCROLLTIMER, 20, nullptr); } if (!m_pMainFrame->m_bWrapLines && (charIndex >= (GetScreenChars()+m_nOffsetChar-4))) { ScrollAllSide(1); - SetTimer(IDT_SCROLLTIMER, 20, NULL); + SetTimer(IDT_SCROLLTIMER, 20, nullptr); } SetCapture(); } @@ -3468,22 +3464,22 @@ void CBaseView::OnTimer(UINT_PTR nIDEvent) if (nMouseLine < m_nTopLine) { ScrollAllToLine(m_nTopLine-1, TRUE); - SetTimer(IDT_SCROLLTIMER, 20, NULL); + SetTimer(IDT_SCROLLTIMER, 20, nullptr); } if (nMouseLine >= m_nTopLine + GetScreenLines() - 2) { ScrollAllToLine(m_nTopLine+1, TRUE); - SetTimer(IDT_SCROLLTIMER, 20, NULL); + SetTimer(IDT_SCROLLTIMER, 20, nullptr); } if (!m_pMainFrame->m_bWrapLines && ((m_nOffsetChar + (point.x - GetMarginWidth()) / GetCharWidth()) <= m_nOffsetChar)) { ScrollAllSide(-1); - SetTimer(IDT_SCROLLTIMER, 20, NULL); + SetTimer(IDT_SCROLLTIMER, 20, nullptr); } if (!m_pMainFrame->m_bWrapLines && (charIndex >= (GetScreenChars()+m_nOffsetChar-4))) { ScrollAllSide(1); - SetTimer(IDT_SCROLLTIMER, 20, NULL); + SetTimer(IDT_SCROLLTIMER, 20, nullptr); } } @@ -3699,7 +3695,7 @@ int CBaseView::CalcColFromPoint(int xpos, int lineIndex) { int xpos2; CDC *pDC = GetDC(); - if (pDC != nullptr) + if (pDC) { CString text = ExpandChars(GetLineChars(lineIndex), 0); int fit = text.GetLength(); @@ -3979,7 +3975,7 @@ void CBaseView::AddUndoViewLine(int nViewLine, bool bAddEmptyLine) void CBaseView::AddEmptyViewLine(int nViewLineIndex) { - if (m_pViewData == NULL) + if (!m_pViewData) return; int viewLine = nViewLineIndex; EOL ending = m_pViewData->GetLineEnding(viewLine); @@ -4002,7 +3998,7 @@ void CBaseView::AddEmptyViewLine(int nViewLineIndex) void CBaseView::RemoveSelectedText() { - if (m_pViewData == NULL) + if (!m_pViewData) return; if (!HasTextSelection()) return; @@ -4370,11 +4366,11 @@ void CBaseView::DeleteFonts() { for (int i=0; iDeleteObject(); delete m_apFonts[i]; - m_apFonts[i] = NULL; + m_apFonts[i] = nullptr; } } } @@ -4437,11 +4433,11 @@ HICON CBaseView::LoadIcon(WORD iconId) void CBaseView::ReleaseBitmap() { - if (m_pCacheBitmap != NULL) + if (m_pCacheBitmap) { m_pCacheBitmap->DeleteObject(); delete m_pCacheBitmap; - m_pCacheBitmap = NULL; + m_pCacheBitmap = nullptr; } } @@ -4565,10 +4561,10 @@ bool CBaseView::GetInlineDiffPositions(int nViewLine, std::vector { if (!m_bShowInlineDiff) return false; - if ((m_pwndBottom != NULL) && !(m_pwndBottom->IsHidden())) + if (m_pwndBottom && !(m_pwndBottom->IsHidden())) return false; - if (m_pViewData == nullptr || m_pViewData->GetCount() <= nViewLine) + if (!m_pViewData || m_pViewData->GetCount() <= nViewLine) return false; const CString &sLine = m_pViewData->GetLine(nViewLine); if (sLine.IsEmpty()) @@ -4582,7 +4578,7 @@ bool CBaseView::GetInlineDiffPositions(int nViewLine, std::vector if (sDiffLine.IsEmpty()) return false; - svn_diff_t * diff = NULL; + svn_diff_t* diff = nullptr; auto pLine1 = (this == m_pwndLeft) ? &sLine : &sDiffLine; auto pLine2 = (this == m_pwndLeft) ? &sDiffLine : &sLine; m_svnlinediff.Diff(&diff, *pLine1, pLine1->GetLength(), *pLine2, pLine2->GetLength(), m_bInlineWordDiff); @@ -4718,7 +4714,7 @@ CBaseView * CBaseView::GetFirstGoodView() return m_pwndRight; if (IsViewGood(m_pwndBottom)) return m_pwndBottom; - return NULL; + return nullptr; } void CBaseView::BuildAllScreen2ViewVector() @@ -4873,7 +4869,7 @@ LineColors & CBaseView::GetLineColors(int nViewLine) if (sDiffLine.IsEmpty()) break; - svn_diff_t * diff = NULL; + svn_diff_t* diff = nullptr; if (sLine.GetLength() > (int)m_nInlineDiffMaxLineLength) break; auto pLine1 = (this == m_pwndLeft) ? &sLine : &sDiffLine; @@ -4948,7 +4944,7 @@ LineColors & CBaseView::GetLineColors(int nViewLine) void CBaseView::OnEditSelectall() { - if (m_pViewData == nullptr) + if (!m_pViewData) return; int nLastViewLine = m_pViewData->GetCount()-1; if (nLastViewLine < 0) @@ -5167,7 +5163,7 @@ void CBaseView::Screen2View::RebuildIfNecessary() } m_Screen2View.push_back(oLineInfo); } - m_pViewData = NULL; + m_pViewData = nullptr; if (IsLeftViewGood()) m_pwndLeft->BuildMarkedWordArray(); @@ -5317,12 +5313,12 @@ void CBaseView::OnEditFind() LRESULT CBaseView::OnFindDialogMessage(WPARAM wParam, LPARAM /*lParam*/) { - ASSERT(m_pFindDialog != NULL); + ASSERT(m_pFindDialog != nullptr); if (m_pFindDialog->IsTerminating()) { // invalidate the handle identifying the dialog box. - m_pFindDialog = NULL; + m_pFindDialog = nullptr; return 0; } @@ -5409,7 +5405,7 @@ LRESULT CBaseView::OnFindDialogMessage(WPARAM wParam, LPARAM /*lParam*/) void CBaseView::OnEditFindnextStart() { - if (m_pViewData == nullptr) + if (!m_pViewData) return; if (HasTextSelection()) { @@ -5431,7 +5427,7 @@ void CBaseView::OnEditFindnextStart() void CBaseView::OnEditFindprevStart() { - if (m_pViewData == nullptr) + if (!m_pViewData) return; if (HasTextSelection()) { @@ -5646,7 +5642,7 @@ CString CBaseView::GetSelectedText() const end.y = m_nSelViewBlockEnd; end.x = GetViewLineLength(m_nSelViewBlockEnd); } - if (m_pViewData == nullptr) + if (!m_pViewData) return sSelectedText; // first store the selected lines in one CString for (int nViewLine=start.y; nViewLine<=end.y; nViewLine++) @@ -5729,7 +5725,7 @@ void CBaseView::CheckModifications(bool& hasMods, bool& hasConflicts, bool& hasW void CBaseView::OnEditGotoline() { - if (m_pViewData == NULL) + if (!m_pViewData) return; // find the last and first line number int nViewLineCount = m_pViewData->GetCount(); @@ -5779,7 +5775,7 @@ void CBaseView::OnToggleReadonly() int CBaseView::SaveFile(int nFlags) { Invalidate(); - if (m_pViewData!=NULL && m_pWorkingFile!=NULL) + if (m_pViewData && m_pWorkingFile) { CFileTextLines file; m_SaveParams.m_LineEndings = m_lineendings; @@ -5835,7 +5831,7 @@ int CBaseView::SaveFile(int nFlags) } CString filename = m_pWorkingFile->GetFilename(); if (m_pWorkingFile->IsReadonly()) - if (!CCommonAppUtils::FileOpenSave(filename, NULL, IDS_SAVEASTITLE, IDS_COMMONFILEFILTER, false, m_hWnd)) + if (!CCommonAppUtils::FileOpenSave(filename, nullptr, IDS_SAVEASTITLE, IDS_COMMONFILEFILTER, false, m_hWnd)) return -1; if (!file.Save(filename)) { @@ -6005,7 +6001,7 @@ void CBaseView::UseViewBlock(CBaseView * pwndView, int nFirstViewLine, int nLast // the text we copy from the other view can actually be saved in ASCII encoding. // if not, we have to change this views encoding to the same encoding as the other view BOOL useDefault = FALSE; - WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, line.sLine, -1, NULL, 0, 0, &useDefault); + WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, line.sLine, -1, nullptr, 0, 0, &useDefault); if (useDefault) // a default char is required, so the char can not be saved as ASCII SetTextType(pwndView->GetTextType()); } diff --git a/src/TortoiseMerge/BaseView.h b/src/TortoiseMerge/BaseView.h index c08f86c3d..fe2ab4f99 100644 --- a/src/TortoiseMerge/BaseView.h +++ b/src/TortoiseMerge/BaseView.h @@ -651,7 +651,7 @@ protected: // variables { public: Screen2View() - : m_pViewData(NULL) + : m_pViewData(nullptr) {m_bFull=false; } int GetViewLineForScreen(int screenLine); diff --git a/src/TortoiseMerge/CustomMFCRibbonButton.h b/src/TortoiseMerge/CustomMFCRibbonButton.h index 0669c72bf..0ab468d89 100644 --- a/src/TortoiseMerge/CustomMFCRibbonButton.h +++ b/src/TortoiseMerge/CustomMFCRibbonButton.h @@ -29,7 +29,7 @@ public: CCustomMFCRibbonButton() : CMFCRibbonButton() {} CCustomMFCRibbonButton(UINT nID, LPCTSTR lpszText, int nSmallImageIndex = -1, int nLargeImageIndex = -1, BOOL bAlwaysShowDescription = FALSE) : CMFCRibbonButton(nID, lpszText, nSmallImageIndex, nLargeImageIndex, bAlwaysShowDescription) {} - CCustomMFCRibbonButton(UINT nID, LPCTSTR lpszText, HICON hIcon, BOOL bAlwaysShowDescription = FALSE, HICON hIconSmall = NULL, BOOL bAutoDestroyIcon = FALSE, BOOL bAlphaBlendIcon = FALSE) + CCustomMFCRibbonButton(UINT nID, LPCTSTR lpszText, HICON hIcon, BOOL bAlwaysShowDescription = FALSE, HICON hIconSmall = nullptr, BOOL bAutoDestroyIcon = FALSE, BOOL bAlphaBlendIcon = FALSE) : CMFCRibbonButton(nID, lpszText, hIcon, bAlwaysShowDescription, hIconSmall, bAutoDestroyIcon, bAlphaBlendIcon) {} protected: diff --git a/src/TortoiseMerge/DiffData.cpp b/src/TortoiseMerge/DiffData.cpp index bb14ce483..c865238a6 100644 --- a/src/TortoiseMerge/DiffData.cpp +++ b/src/TortoiseMerge/DiffData.cpp @@ -323,8 +323,8 @@ BOOL CDiffData::Load() return FALSE; } - apr_pool_t * pool = NULL; - apr_pool_create_ex (&pool, NULL, abort_on_pool_failure, NULL); + apr_pool_t* pool = nullptr; + apr_pool_create_ex(&pool, nullptr, abort_on_pool_failure, nullptr); // Is this a two-way diff? if (IsBaseFileInUse() && IsYourFileInUse() && !IsTheirFileInUse()) @@ -371,13 +371,13 @@ CDiffData::DoTwoWayDiff(const CString& sBaseFilename, const CString& sYourFilena CStringA sBaseFilenameUtf8 = CUnicodeUtils::GetUTF8(sBaseFilename); CStringA sYourFilenameUtf8 = CUnicodeUtils::GetUTF8(sYourFilename); - svn_diff_t * diffYourBase = NULL; + svn_diff_t* diffYourBase = nullptr; svn_error_t * svnerr = svn_diff_file_diff_2(&diffYourBase, sBaseFilenameUtf8, sYourFilenameUtf8, options, pool); if (svnerr) return HandleSvnError(svnerr); - tsvn_svn_diff_t_extension * movedBlocks = NULL; + tsvn_svn_diff_t_extension* movedBlocks = nullptr; if(m_bViewMovedBlocks) movedBlocks = MovedBlocksDetect(diffYourBase, dwIgnoreWS, pool); // Side effect is that diffs are now splitted @@ -452,7 +452,7 @@ CDiffData::DoTwoWayDiff(const CString& sBaseFilename, const CString& sYourFilena tempdiff = tempdiff->next; } - HideUnchangedSections(&m_YourBaseBoth, NULL, NULL); + HideUnchangedSections(&m_YourBaseBoth, nullptr, nullptr); tempdiff = diffYourBase; baseline = 0; @@ -669,7 +669,7 @@ CDiffData::DoTwoWayDiff(const CString& sBaseFilename, const CString& sYourFilena TRACE(L"done with 2-way diff\n"); - HideUnchangedSections(&m_YourBaseLeft, &m_YourBaseRight, NULL); + HideUnchangedSections(&m_YourBaseLeft, &m_YourBaseRight, nullptr); return true; } @@ -697,7 +697,7 @@ CDiffData::DoThreeWayDiff(const CString& sBaseFilename, const CString& sYourFile CStringA sYourFilenameUtf8 = CUnicodeUtils::GetUTF8(sYourFilename); CStringA sTheirFilenameUtf8 = CUnicodeUtils::GetUTF8(sTheirFilename); - svn_diff_t * diffTheirYourBase = NULL; + svn_diff_t* diffTheirYourBase = nullptr; svn_error_t * svnerr = svn_diff_file_diff3_2(&diffTheirYourBase, sBaseFilenameUtf8, sTheirFilenameUtf8, sYourFilenameUtf8, options, pool); if (svnerr) return HandleSvnError(svnerr); @@ -1024,7 +1024,7 @@ CDiffData::DoThreeWayDiff(const CString& sBaseFilename, const CString& sYourFile void CDiffData::HideUnchangedSections(CViewData * data1, CViewData * data2, CViewData * data3) const { - if (data1 == NULL) + if (!data1) return; CRegDWORD contextLines = CRegDWORD(L"Software\\TortoiseGitMerge\\ContextLines", 1); diff --git a/src/TortoiseMerge/EncodingDlg.h b/src/TortoiseMerge/EncodingDlg.h index 961280872..4ae83bcef 100644 --- a/src/TortoiseMerge/EncodingDlg.h +++ b/src/TortoiseMerge/EncodingDlg.h @@ -34,9 +34,9 @@ class CEncodingDlg : public CDialog DECLARE_DYNAMIC(CEncodingDlg) public: - CEncodingDlg(CWnd* pParent = NULL); // standard constructor + CEncodingDlg(CWnd* pParent = nullptr); // standard constructor virtual ~CEncodingDlg(); - void Create(CWnd * pParent = NULL) {CDialog::Create(IDD, pParent);ShowWindow(SW_SHOW);UpdateWindow();} + void Create(CWnd* pParent = nullptr) { CDialog::Create(IDD, pParent); ShowWindow(SW_SHOW); UpdateWindow(); } // Dialog Data enum { IDD = IDD_ENCODING }; diff --git a/src/TortoiseMerge/FilePatchesDlg.cpp b/src/TortoiseMerge/FilePatchesDlg.cpp index cd753a27d..89cdb2843 100644 --- a/src/TortoiseMerge/FilePatchesDlg.cpp +++ b/src/TortoiseMerge/FilePatchesDlg.cpp @@ -27,15 +27,15 @@ #include "SysImageList.h" IMPLEMENT_DYNAMIC(CFilePatchesDlg, CResizableStandAloneDialog) -CFilePatchesDlg::CFilePatchesDlg(CWnd* pParent /*=NULL*/) +CFilePatchesDlg::CFilePatchesDlg(CWnd* pParent /*=nullptr*/) : CResizableStandAloneDialog(CFilePatchesDlg::IDD, pParent) , m_ShownIndex(-1) , m_bMinimized(FALSE) - , m_pPatch(NULL) - , m_pCallBack(NULL) + , m_pPatch(nullptr) + , m_pCallBack(nullptr) , m_nWindowHeight(-1) - , m_pMainFrame(NULL) - , m_boldFont(NULL) + , m_pMainFrame(nullptr) + , m_boldFont(nullptr) { } @@ -100,7 +100,7 @@ BOOL CFilePatchesDlg::OnInitDialog() BOOL CFilePatchesDlg::Init(GitPatch * pPatch, CPatchFilesDlgCallBack * pCallBack, CString sPath, CWnd * pParent) { - if ((pCallBack==NULL)||(pPatch==NULL)) + if (!pCallBack || !pPatch) { m_cFileList.DeleteAllItems(); return FALSE; @@ -123,7 +123,7 @@ BOOL CFilePatchesDlg::Init(GitPatch * pPatch, CPatchFilesDlgCallBack * pCallBack m_sPath += L'\\'; } - SetWindowTheme(m_cFileList.GetSafeHwnd(), L"Explorer", NULL); + SetWindowTheme(m_cFileList.GetSafeHwnd(), L"Explorer", nullptr); m_cFileList.SetExtendedStyle(LVS_EX_INFOTIP | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER); m_cFileList.DeleteAllItems(); int c = ((CHeaderCtrl*)(m_cFileList.GetDlgItem(0)))->GetItemCount()-1; @@ -234,12 +234,12 @@ void CFilePatchesDlg::OnNMDblclkFilelist(NMHDR *pNMHDR, LRESULT *pResult) *pResult = 0; if ((pNMLV->iItem < 0) || (pNMLV->iItem >= m_arFileStates.GetCount())) return; - if (m_pCallBack==NULL) + if (!m_pCallBack) return; if (m_arFileStates.GetAt(pNMLV->iItem) == FPDLG_FILESTATE_ERROR) { - MessageBox(m_pPatch->GetPatchRejects(pNMLV->iItem), NULL, MB_ICONERROR); + MessageBox(m_pPatch->GetPatchRejects(pNMLV->iItem), nullptr, MB_ICONERROR); return; } @@ -357,7 +357,7 @@ void CFilePatchesDlg::OnNMRclickFilelist(NMHDR * /*pNMHDR*/, LRESULT *pResult) int nIndex = m_cFileList.GetSelectionMark(); if (m_arFileStates.GetAt(nIndex) == FPDLG_FILESTATE_ERROR) { - MessageBox(m_pPatch->GetPatchRejects(nIndex), NULL, MB_ICONERROR); + MessageBox(m_pPatch->GetPatchRejects(nIndex), nullptr, MB_ICONERROR); } else if ( m_arFileStates.GetAt(nIndex)!=FPDLG_FILESTATE_PATCHED) { @@ -458,7 +458,7 @@ void CFilePatchesDlg::PatchAll() for (int i=0; iGetPatchRejects(i), NULL, MB_ICONERROR); + MessageBox(m_pPatch->GetPatchRejects(i), nullptr, MB_ICONERROR); else if (m_arFileStates.GetAt(i) != FPDLG_FILESTATE_PATCHED) { progDlg.SetLine(2, GetFullPath(i), true); @@ -491,7 +491,7 @@ void CFilePatchesDlg::PatchSelected() while (((index = m_cFileList.GetNextSelectedItem(pos)) >= 0) && (!progDlg.HasUserCancelled())) { if (m_arFileStates.GetAt(index) == FPDLG_FILESTATE_ERROR) - MessageBox(m_pPatch->GetPatchRejects(index), NULL, MB_ICONERROR); + MessageBox(m_pPatch->GetPatchRejects(index), nullptr, MB_ICONERROR); else if (m_arFileStates.GetAt(index) != FPDLG_FILESTATE_PATCHED) { progDlg.SetLine(2, GetFullPath(index), true); diff --git a/src/TortoiseMerge/FilePatchesDlg.h b/src/TortoiseMerge/FilePatchesDlg.h index 64b24b3b3..3c00e2ead 100644 --- a/src/TortoiseMerge/FilePatchesDlg.h +++ b/src/TortoiseMerge/FilePatchesDlg.h @@ -73,7 +73,7 @@ class CFilePatchesDlg : public CResizableStandAloneDialog DECLARE_DYNAMIC(CFilePatchesDlg) public: - CFilePatchesDlg(CWnd* pParent = NULL); // standard constructor + CFilePatchesDlg(CWnd* pParent = nullptr); // standard constructor virtual ~CFilePatchesDlg(); /** diff --git a/src/TortoiseMerge/FileTextLines.cpp b/src/TortoiseMerge/FileTextLines.cpp index 290ed09f7..501956700 100644 --- a/src/TortoiseMerge/FileTextLines.cpp +++ b/src/TortoiseMerge/FileTextLines.cpp @@ -266,7 +266,7 @@ BOOL CFileTextLines::Load(const CString& sFilePath, int lengthHint /* = 0*/) // load file DWORD dwReadBytes = 0; - if (!ReadFile(hFile, (void *)oFile, fsize.LowPart, &dwReadBytes, NULL)) + if (!ReadFile(hFile, (void*)oFile, fsize.LowPart, &dwReadBytes, nullptr)) { SetErrorString(); return FALSE; @@ -284,7 +284,7 @@ BOOL CFileTextLines::Load(const CString& sFilePath, int lengthHint /* = 0*/) // we may have to convert the file content - CString is UTF16LE try { - CBaseFilter * pFilter = NULL; + CBaseFilter* pFilter = nullptr; switch (m_SaveParams.m_UnicodeType) { case BINARY: @@ -292,25 +292,25 @@ BOOL CFileTextLines::Load(const CString& sFilePath, int lengthHint /* = 0*/) return FALSE; case UTF8: case UTF8BOM: - pFilter = new CUtf8Filter(NULL); + pFilter = new CUtf8Filter(nullptr); break; default: case ASCII: - pFilter = new CAsciiFilter(NULL); + pFilter = new CAsciiFilter(nullptr); break; case UTF16_BE: case UTF16_BEBOM: - pFilter = new CUtf16beFilter(NULL); + pFilter = new CUtf16beFilter(nullptr); break; case UTF16_LE: case UTF16_LEBOM: - pFilter = new CUtf16leFilter(NULL); + pFilter = new CUtf16leFilter(nullptr); break; case UTF32_BE: - pFilter = new CUtf32beFilter(NULL); + pFilter = new CUtf32beFilter(nullptr); break; case UTF32_LE: - pFilter = new CUtf32leFilter(NULL); + pFilter = new CUtf32leFilter(nullptr); break; } pFilter->Decode(oFile); @@ -482,7 +482,7 @@ BOOL CFileTextLines::Save( const CString& sFilePath { if (!PathIsDirectory(destPath.Left(destPath.Find('\\', ind)))) { - if (!CreateDirectory(destPath.Left(destPath.Find('\\', ind)), NULL)) + if (!CreateDirectory(destPath.Left(destPath.Find('\\', ind)), nullptr)) return FALSE; } ind = destPath.Find('\\', ind)+1; @@ -495,7 +495,7 @@ BOOL CFileTextLines::Save( const CString& sFilePath return FALSE; } - CBaseFilter * pFilter = NULL; + CBaseFilter* pFilter = nullptr; bool bSaveBom = true; CFileTextLines::UnicodeType eUnicodeType = bSaveAsUTF8 ? CFileTextLines::UTF8 : m_SaveParams.m_UnicodeType; switch (eUnicodeType) @@ -759,7 +759,7 @@ bool CBaseFilter::Decode(/*in out*/ CBuffer & data) { int nFlags = (m_nCodePage==CP_ACP) ? MB_PRECOMPOSED : 0; // dry decode is around 8 times faster then real one, alternatively we can set buffer to max length - int nReadChars = MultiByteToWideChar(m_nCodePage, nFlags, (LPCSTR)data, data.GetLength(), NULL, 0); + int nReadChars = MultiByteToWideChar(m_nCodePage, nFlags, (LPCSTR)data, data.GetLength(), nullptr, 0); m_oBuffer.SetLength(nReadChars*sizeof(wchar_t)); int ret2 = MultiByteToWideChar(m_nCodePage, nFlags, (LPCSTR)data, data.GetLength(), (LPWSTR)(void *)m_oBuffer, nReadChars); if (ret2 != nReadChars) @@ -773,7 +773,7 @@ bool CBaseFilter::Decode(/*in out*/ CBuffer & data) const CBuffer& CBaseFilter::Encode(const CString& s) { m_oBuffer.SetLength(s.GetLength()*3+1); // set buffer to guessed max size - int nConvertedLen = WideCharToMultiByte(m_nCodePage, 0, (LPCTSTR)s, s.GetLength(), (LPSTR)m_oBuffer, m_oBuffer.GetLength(), NULL, NULL); + int nConvertedLen = WideCharToMultiByte(m_nCodePage, 0, (LPCTSTR)s, s.GetLength(), (LPSTR)m_oBuffer, m_oBuffer.GetLength(), nullptr, nullptr); m_oBuffer.SetLength(nConvertedLen); // set buffer to used size return m_oBuffer; } diff --git a/src/TortoiseMerge/FileTextLines.h b/src/TortoiseMerge/FileTextLines.h index aa1c3b003..53cb47c51 100644 --- a/src/TortoiseMerge/FileTextLines.h +++ b/src/TortoiseMerge/FileTextLines.h @@ -211,7 +211,7 @@ public: private: void Copy(const CBuffer & Src); void Free() { delete [] m_pBuffer; } - void Init() { m_pBuffer=NULL; m_nUsed=0; m_nAllocated=0; } + void Init() { m_pBuffer = nullptr; m_nUsed = 0; m_nAllocated = 0; } BYTE * m_pBuffer; int m_nUsed; diff --git a/src/TortoiseMerge/FindDlg.cpp b/src/TortoiseMerge/FindDlg.cpp index bf8780bb3..56e7e5b5b 100644 --- a/src/TortoiseMerge/FindDlg.cpp +++ b/src/TortoiseMerge/FindDlg.cpp @@ -25,7 +25,7 @@ IMPLEMENT_DYNAMIC(CFindDlg, CDialog) -CFindDlg::CFindDlg(CWnd* pParent /*=NULL*/) +CFindDlg::CFindDlg(CWnd* pParent /*=nullptr*/) : CDialog(CFindDlg::IDD, pParent) , m_pParent(pParent) , m_bTerminating(false) @@ -62,7 +62,7 @@ void CFindDlg::Create(CWnd* pParent, int id /* = 0 */) pt.y = (int)(DWORD)CRegDWORD(sRegPath, 0); pParent->ClientToScreen(&pt); if (MonitorFromPoint(pt, MONITOR_DEFAULTTONULL)) - SetWindowPos(NULL, pt.x, pt.y, 0, 0, SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOSIZE); + SetWindowPos(nullptr, pt.x, pt.y, 0, 0, SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOSIZE); } ShowWindow(SW_SHOW); UpdateWindow(); diff --git a/src/TortoiseMerge/FindDlg.h b/src/TortoiseMerge/FindDlg.h index 81d864d25..0f1c9d870 100644 --- a/src/TortoiseMerge/FindDlg.h +++ b/src/TortoiseMerge/FindDlg.h @@ -33,7 +33,7 @@ class CFindDlg : public CDialog DECLARE_DYNAMIC(CFindDlg) public: - CFindDlg(CWnd* pParent = NULL); // standard constructor + CFindDlg(CWnd* pParent = nullptr); // standard constructor virtual ~CFindDlg(); void Create(CWnd* pParent = nullptr, int id = 0); bool IsTerminating() {return m_bTerminating;} diff --git a/src/TortoiseMerge/GotoLineDlg.cpp b/src/TortoiseMerge/GotoLineDlg.cpp index d7c446604..c37f4651c 100644 --- a/src/TortoiseMerge/GotoLineDlg.cpp +++ b/src/TortoiseMerge/GotoLineDlg.cpp @@ -26,7 +26,7 @@ IMPLEMENT_DYNAMIC(CGotoLineDlg, CDialogEx) -CGotoLineDlg::CGotoLineDlg(CWnd* pParent /*=NULL*/) +CGotoLineDlg::CGotoLineDlg(CWnd* pParent /*=nullptr*/) : CDialogEx(CGotoLineDlg::IDD, pParent) , m_nLine(0) , m_nLow(-1) diff --git a/src/TortoiseMerge/GotoLineDlg.h b/src/TortoiseMerge/GotoLineDlg.h index 6c07680b8..5f8efbe2c 100644 --- a/src/TortoiseMerge/GotoLineDlg.h +++ b/src/TortoiseMerge/GotoLineDlg.h @@ -27,7 +27,7 @@ class CGotoLineDlg : public CDialogEx DECLARE_DYNAMIC(CGotoLineDlg) public: - CGotoLineDlg(CWnd* pParent = NULL); // standard constructor + CGotoLineDlg(CWnd* pParent = nullptr); // standard constructor virtual ~CGotoLineDlg(); int GetLineNumber() const {return m_nLine;} diff --git a/src/TortoiseMerge/LineDiffBar.cpp b/src/TortoiseMerge/LineDiffBar.cpp index 4880305ec..4747fe980 100644 --- a/src/TortoiseMerge/LineDiffBar.cpp +++ b/src/TortoiseMerge/LineDiffBar.cpp @@ -27,8 +27,8 @@ IMPLEMENT_DYNAMIC(CLineDiffBar, CPaneDialog) CLineDiffBar::CLineDiffBar() : CPaneDialog() { - m_pMainFrm = NULL; - m_pCacheBitmap = NULL; + m_pMainFrm = nullptr; + m_pCacheBitmap = nullptr; m_nLineIndex = -1; m_nLineHeight = 0; m_bExclusiveRow = TRUE; @@ -40,7 +40,7 @@ CLineDiffBar::~CLineDiffBar() { m_pCacheBitmap->DeleteObject(); delete m_pCacheBitmap; - m_pCacheBitmap = NULL; + m_pCacheBitmap = nullptr; } } @@ -62,7 +62,7 @@ void CLineDiffBar::DocumentUpdated() CSize size = rect.Size(); size.cy = 2 * m_nLineHeight; SetMinSize(size); - SetWindowPos(NULL, 0, 0, size.cx, 2*m_nLineHeight, SWP_NOMOVE); + SetWindowPos(nullptr, 0, 0, size.cx, 2 * m_nLineHeight, SWP_NOMOVE); RecalcLayout(); if (m_pMainFrm) m_pMainFrm->RecalcLayout(); @@ -85,7 +85,7 @@ void CLineDiffBar::OnPaint() CDC cacheDC; VERIFY(cacheDC.CreateCompatibleDC(&dc)); cacheDC.FillSolidRect(&rect, ::GetSysColor(COLOR_WINDOW)); - if (m_pCacheBitmap == NULL) + if (!m_pCacheBitmap) { m_pCacheBitmap = new CBitmap; VERIFY(m_pCacheBitmap->CreateCompatibleBitmap(&dc, width, height)); @@ -138,13 +138,13 @@ void CLineDiffBar::OnSize(UINT nType, int cx, int cy) { CPaneDialog::OnSize(nType, cx, cy); - if (m_pCacheBitmap != NULL) + if (m_pCacheBitmap) { m_pCacheBitmap->DeleteObject(); delete m_pCacheBitmap; - m_pCacheBitmap = NULL; + m_pCacheBitmap = nullptr; } - SetWindowPos(NULL, 0, 0, cx, 2*m_nLineHeight, SWP_NOMOVE); + SetWindowPos(nullptr, 0, 0, cx, 2 * m_nLineHeight, SWP_NOMOVE); Invalidate(); } diff --git a/src/TortoiseMerge/LocatorBar.cpp b/src/TortoiseMerge/LocatorBar.cpp index e67b5fd8b..716e83ce8 100644 --- a/src/TortoiseMerge/LocatorBar.cpp +++ b/src/TortoiseMerge/LocatorBar.cpp @@ -29,8 +29,8 @@ IMPLEMENT_DYNAMIC(CLocatorBar, CPaneDialog) CLocatorBar::CLocatorBar() : CPaneDialog() - , m_pMainFrm(NULL) - , m_pCacheBitmap(NULL) + , m_pMainFrm(nullptr) + , m_pCacheBitmap(nullptr) , m_regUseFishEye(L"Software\\TortoiseGitMerge\\UseFishEye", TRUE) , m_nLines(-1) , m_minWidth(0) @@ -43,7 +43,7 @@ CLocatorBar::~CLocatorBar() { m_pCacheBitmap->DeleteObject(); delete m_pCacheBitmap; - m_pCacheBitmap = NULL; + m_pCacheBitmap = nullptr; } } @@ -60,7 +60,7 @@ END_MESSAGE_MAP() void CLocatorBar::DocumentUpdated() { m_pMainFrm = (CMainFrame *)this->GetParentFrame(); - if (m_pMainFrm == NULL) + if (!m_pMainFrm) return; m_nLines = 0; @@ -139,7 +139,7 @@ void CLocatorBar::OnPaint() CDC cacheDC; VERIFY(cacheDC.CreateCompatibleDC(&dc)); - if (m_pCacheBitmap == NULL) + if (!m_pCacheBitmap) { m_pCacheBitmap = new CBitmap; VERIFY(m_pCacheBitmap->CreateCompatibleBitmap(&dc, width, height)); @@ -194,11 +194,11 @@ void CLocatorBar::OnSize(UINT nType, int cx, int cy) { CPaneDialog::OnSize(nType, cx, cy); - if (m_pCacheBitmap != NULL) + if (m_pCacheBitmap) { m_pCacheBitmap->DeleteObject(); delete m_pCacheBitmap; - m_pCacheBitmap = NULL; + m_pCacheBitmap = nullptr; } Invalidate(); } diff --git a/src/TortoiseMerge/MainFrm.cpp b/src/TortoiseMerge/MainFrm.cpp index c34ca115a..2addc4e75 100644 --- a/src/TortoiseMerge/MainFrm.cpp +++ b/src/TortoiseMerge/MainFrm.cpp @@ -197,9 +197,9 @@ CMainFrame::CMainFrame() , m_bLineDiff(true) , m_bLocatorBar(true) , m_nMoveMovesToIgnore(0) - , m_pwndLeftView(NULL) - , m_pwndRightView(NULL) - , m_pwndBottomView(NULL) + , m_pwndLeftView(nullptr) + , m_pwndRightView(nullptr) + , m_pwndBottomView(nullptr) , m_bReadOnly(false) , m_bBlame(false) , m_bCheckReload(false) @@ -463,7 +463,7 @@ void CMainFrame::OnApplicationLook(UINT id) m_wndRibbonBar.SetWindows7Look(FALSE); } - RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); + RedrawWindow(nullptr, nullptr, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); theApp.WriteInt(L"ApplicationLook", theApp.m_nAppLook); } @@ -590,7 +590,7 @@ BOOL CMainFrame::PatchFile(CString sFilePath, bool /*bContentMods*/, bool bPropM CString sRejectedFile, sBasePath; if (m_Patch.GetPatchResult(sFilePath, sTempFile, sRejectedFile, sBasePath) < 0) { - MessageBox(m_Patch.GetErrorMessage(), NULL, MB_ICONERROR); + MessageBox(m_Patch.GetErrorMessage(), nullptr, MB_ICONERROR); return FALSE; } sFilePath = m_Patch.GetTargetPath() + L'\\' + sFilePath; @@ -698,7 +698,7 @@ BOOL CMainFrame::DiffFiles(CString sURL1, CString sRev1, CString sURL2, CString progDlg.Stop(); CString sErrMsg; sErrMsg.Format(IDS_ERR_MAINFRAME_FILEVERSIONNOTFOUND, (LPCTSTR)sRev1, (LPCTSTR)sURL1); - MessageBox(sErrMsg, NULL, MB_ICONERROR); + MessageBox(sErrMsg, nullptr, MB_ICONERROR); return FALSE; } sTemp.Format(IDS_GETVERSIONOFFILE, (LPCTSTR)sRev2); @@ -710,7 +710,7 @@ BOOL CMainFrame::DiffFiles(CString sURL1, CString sRev1, CString sURL2, CString progDlg.Stop(); CString sErrMsg; sErrMsg.Format(IDS_ERR_MAINFRAME_FILEVERSIONNOTFOUND, (LPCTSTR)sRev2, (LPCTSTR)sURL2); - MessageBox(sErrMsg, NULL, MB_ICONERROR); + MessageBox(sErrMsg, nullptr, MB_ICONERROR); return FALSE; } progDlg.SetProgress(100,100); @@ -745,7 +745,7 @@ void CMainFrame::OnFileOpen(bool fillyours) return; } m_dlgFilePatches.ShowWindow(SW_HIDE); - m_dlgFilePatches.Init(NULL, NULL, CString(), NULL); + m_dlgFilePatches.Init(nullptr, nullptr, CString(), nullptr); TRACE(L"got the files:\n %s\n %s\n %s\n %s\n %s\n", (LPCTSTR)dlg.m_sBaseFile, (LPCTSTR)dlg.m_sTheirFile, (LPCTSTR)dlg.m_sYourFile, (LPCTSTR)dlg.m_sUnifiedDiffFile, (LPCTSTR)dlg.m_sPatchDirectory); m_Data.m_baseFile.SetFileName(dlg.m_sBaseFile); @@ -754,10 +754,10 @@ void CMainFrame::OnFileOpen(bool fillyours) m_Data.m_sDiffFile = dlg.m_sUnifiedDiffFile; m_Data.m_sPatchPath = dlg.m_sPatchDirectory; m_Data.m_mergedFile.SetOutOfUse(); - CCrashReport::Instance().AddFile2(dlg.m_sBaseFile, NULL, L"Basefile", CR_AF_MAKE_FILE_COPY); - CCrashReport::Instance().AddFile2(dlg.m_sTheirFile, NULL, L"Theirfile", CR_AF_MAKE_FILE_COPY); - CCrashReport::Instance().AddFile2(dlg.m_sYourFile, NULL, L"Yourfile", CR_AF_MAKE_FILE_COPY); - CCrashReport::Instance().AddFile2(dlg.m_sUnifiedDiffFile, NULL, L"Difffile", CR_AF_MAKE_FILE_COPY); + CCrashReport::Instance().AddFile2(dlg.m_sBaseFile, nullptr, L"Basefile", CR_AF_MAKE_FILE_COPY); + CCrashReport::Instance().AddFile2(dlg.m_sTheirFile, nullptr, L"Theirfile", CR_AF_MAKE_FILE_COPY); + CCrashReport::Instance().AddFile2(dlg.m_sYourFile, nullptr, L"Yourfile", CR_AF_MAKE_FILE_COPY); + CCrashReport::Instance().AddFile2(dlg.m_sUnifiedDiffFile, nullptr, L"Difffile", CR_AF_MAKE_FILE_COPY); if (!m_Data.IsBaseFileInUse() && m_Data.IsTheirFileInUse() && m_Data.IsYourFileInUse()) { @@ -862,7 +862,7 @@ bool CMainFrame::LoadViews(int line) { progDlg.Stop(); ClearViewNamesAndPaths(); - MessageBox(m_Patch.GetErrorMessage(), NULL, MB_ICONERROR); + MessageBox(m_Patch.GetErrorMessage(), nullptr, MB_ICONERROR); m_bSaveRequired = false; return false; } @@ -933,17 +933,17 @@ bool CMainFrame::LoadViews(int line) m_pwndLeftView->SetTarget(); m_pwndLeftView->SetWritableIsChangable(true); - m_pwndRightView->m_pViewData = NULL; - m_pwndRightView->m_pWorkingFile = NULL; - m_pwndBottomView->m_pViewData = NULL; - m_pwndBottomView->m_pWorkingFile = NULL; + m_pwndRightView->m_pViewData = nullptr; + m_pwndRightView->m_pWorkingFile = nullptr; + m_pwndBottomView->m_pViewData = nullptr; + m_pwndBottomView->m_pWorkingFile = nullptr; if (!m_wndSplitter.IsRowHidden(1)) m_wndSplitter.HideRow(1); m_pwndLeftView->SetHidden(FALSE); m_pwndRightView->SetHidden(TRUE); m_pwndBottomView->SetHidden(TRUE); - ::SetWindowPos(m_pwndLeftView->m_hWnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); + ::SetWindowPos(m_pwndLeftView->m_hWnd, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); } else { @@ -972,8 +972,8 @@ bool CMainFrame::LoadViews(int line) m_pwndRightView->SetWritable(); m_pwndRightView->SetTarget(); - m_pwndBottomView->m_pViewData = NULL; - m_pwndBottomView->m_pWorkingFile = NULL; + m_pwndBottomView->m_pViewData = nullptr; + m_pwndBottomView->m_pWorkingFile = nullptr; if (!m_wndSplitter.IsRowHidden(1)) m_wndSplitter.HideRow(1); @@ -1323,8 +1323,8 @@ int CMainFrame::CheckResolved() int CMainFrame::SaveFile(const CString& sFilePath) { - CBaseView * pView = NULL; - CViewData * pViewData = NULL; + CBaseView* pView = nullptr; + CViewData* pViewData = nullptr; CFileTextLines * pOriginFile = &m_Data.m_arBaseFile; if (IsViewGood(m_pwndBottomView)) { @@ -1875,7 +1875,7 @@ void CMainFrame::OnActivate(UINT nValue, CWnd* /*pwnd*/, BOOL /*bActivated?*/) // clicked the close button and that brought the window // to the front - in that case checking for reload wouldn't // do any good. - SetTimer(IDT_RELOADCHECKTIMER, 300, NULL); + SetTimer(IDT_RELOADCHECKTIMER, 300, nullptr); } } } @@ -2097,7 +2097,7 @@ void CMainFrame::WriteWindowPlacement(WINDOWPLACEMENT * pwp) void CMainFrame::OnUpdateMergeMarkasresolved(CCmdUI *pCmdUI) { - if (pCmdUI == NULL) + if (!pCmdUI) return; BOOL bEnable = FALSE; if ((!m_bReadOnly)&&(m_Data.m_mergedFile.InUse())) @@ -2266,7 +2266,7 @@ void CMainFrame::OnMoving(UINT fwSide, LPRECT pRect) GetWindowRect(&thisrect); if (patchrect.right == thisrect.left) { - m_dlgFilePatches.SetWindowPos(NULL, patchrect.left - (thisrect.left - pRect->left), patchrect.top - (thisrect.top - pRect->top), + m_dlgFilePatches.SetWindowPos(nullptr, patchrect.left - (thisrect.left - pRect->left), patchrect.top - (thisrect.top - pRect->top), 0, 0, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER); } } @@ -2900,7 +2900,7 @@ bool CMainFrame::HasConflictsWontKeep() const int nConflictLine = CheckResolved(); if (nConflictLine < 0) return false; - if (m_pwndBottomView == nullptr) + if (!m_pwndBottomView) return false; CString sTemp; @@ -2924,7 +2924,7 @@ bool CMainFrame::HasConflictsWontKeep() bool CMainFrame::TryGetFileName(CString& result) { - return CCommonAppUtils::FileOpenSave(result, NULL, IDS_SAVEASTITLE, IDS_COMMONFILEFILTER, false, m_hWnd); + return CCommonAppUtils::FileOpenSave(result, nullptr, IDS_SAVEASTITLE, IDS_COMMONFILEFILTER, false, m_hWnd); } CBaseView* CMainFrame::GetActiveBaseView() const @@ -2996,21 +2996,21 @@ void CMainFrame::LoadIgnoreCommentData() if (!PathFileExists(sPath)) { // ignore comments file does not exist (yet), so create a default one - HRSRC hRes = FindResource(NULL, MAKEINTRESOURCE(IDR_IGNORECOMMENTSTXT), L"config"); + HRSRC hRes = FindResource(nullptr, MAKEINTRESOURCE(IDR_IGNORECOMMENTSTXT), L"config"); if (hRes) { - HGLOBAL hResourceLoaded = LoadResource(NULL, hRes); + HGLOBAL hResourceLoaded = LoadResource(nullptr, hRes); if (hResourceLoaded) { char * lpResLock = (char *) LockResource(hResourceLoaded); - DWORD dwSizeRes = SizeofResource(NULL, hRes); + DWORD dwSizeRes = SizeofResource(nullptr, hRes); if (lpResLock) { HANDLE hFile = CreateFile(sPath, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile != INVALID_HANDLE_VALUE) { DWORD dwWritten = 0; - WriteFile(hFile, lpResLock, dwSizeRes, &dwWritten, NULL); + WriteFile(hFile, lpResLock, dwSizeRes, &dwWritten, nullptr); CloseHandle(hFile); } } @@ -3104,7 +3104,7 @@ void CMainFrame::OnRegexfilter(UINT cmd) dlg.SetIniFile(&m_regexIni); if (dlg.DoModal() == IDOK) { - FILE * pFile = NULL; + FILE* pFile = nullptr; _wfopen_s(&pFile, CPathUtils::GetAppDataDirectory() + L"regexfilters.ini", L"wb"); m_regexIni.SaveFile(pFile); fclose(pFile); @@ -3164,21 +3164,21 @@ void CMainFrame::BuildRegexSubitems(CMFCPopupMenu* pMenuPopup) if (!PathFileExists(sIniPath)) { // ini file does not exist (yet), so create a default one - HRSRC hRes = FindResource(NULL, MAKEINTRESOURCE(IDR_REGEXFILTERINI), L"config"); + HRSRC hRes = FindResource(nullptr, MAKEINTRESOURCE(IDR_REGEXFILTERINI), L"config"); if (hRes) { - HGLOBAL hResourceLoaded = LoadResource(NULL, hRes); + HGLOBAL hResourceLoaded = LoadResource(nullptr, hRes); if (hResourceLoaded) { char * lpResLock = (char *)LockResource(hResourceLoaded); - DWORD dwSizeRes = SizeofResource(NULL, hRes); + DWORD dwSizeRes = SizeofResource(nullptr, hRes); if (lpResLock) { HANDLE hFile = CreateFile(sIniPath, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile != INVALID_HANDLE_VALUE) { DWORD dwWritten = 0; - WriteFile(hFile, lpResLock, dwSizeRes, &dwWritten, NULL); + WriteFile(hFile, lpResLock, dwSizeRes, &dwWritten, nullptr); CloseHandle(hFile); } } @@ -3224,7 +3224,7 @@ void CMainFrame::BuildRegexSubitems(CMFCPopupMenu* pMenuPopup) int cmdIndex = 2; for (const auto& section : sections) { - pMenuPopup->InsertItem(CMFCToolBarMenuButton(ID_REGEXFILTER + cmdIndex, NULL, -1, (LPCWSTR)section.pItem), iIndex + cmdIndex); + pMenuPopup->InsertItem(CMFCToolBarMenuButton(ID_REGEXFILTER + cmdIndex, nullptr, -1, (LPCWSTR)section.pItem), iIndex + cmdIndex); cmdIndex++; } } @@ -3557,10 +3557,8 @@ BOOL CMainFrame::OnShowPopupMenu(CMFCPopupMenu* pMenuPopup) { __super::OnShowPopupMenu(pMenuPopup); - if (pMenuPopup == NULL) - { + if (!pMenuPopup) return TRUE; - } int iIndex = -1; if (!CMFCToolBar::IsCustomizeMode() && diff --git a/src/TortoiseMerge/MovedBlocks.cpp b/src/TortoiseMerge/MovedBlocks.cpp index 85886c154..9ca983c0d 100644 --- a/src/TortoiseMerge/MovedBlocks.cpp +++ b/src/TortoiseMerge/MovedBlocks.cpp @@ -90,7 +90,7 @@ bool EquivalencyGroup::IsPerfectMatch() const void LineToGroupMap::Add(int lineno, const CString &line, int nside) { - EquivalencyGroup *pGroup = NULL; + EquivalencyGroup* pGroup = nullptr; auto it = __super::find(line); if ( it == cend() ) { @@ -111,7 +111,7 @@ void LineToGroupMap::Add(int lineno, const CString &line, int nside) EquivalencyGroup *LineToGroupMap::find(const CString &line) const { - EquivalencyGroup *pGroup = NULL; + EquivalencyGroup* pGroup = nullptr; auto it = __super::find(line); if ( it != cend() ) pGroup = it->second; @@ -129,7 +129,7 @@ LineToGroupMap::~LineToGroupMap() tsvn_svn_diff_t_extension * CreateDiffExtension(svn_diff_t * base, apr_pool_t * pool) { auto ext = static_cast(apr_palloc(pool, sizeof(tsvn_svn_diff_t_extension))); - ext->next = NULL; + ext->next = nullptr; ext->moved_to = -1; ext->moved_from = -1; ext->base = base; @@ -173,8 +173,8 @@ EquivalencyGroup * ExtractGroup(const LineToGroupMap & map, const CString & line tsvn_svn_diff_t_extension * CDiffData::MovedBlocksDetect(svn_diff_t * diffYourBase, DWORD dwIgnoreWS, apr_pool_t * pool) { LineToGroupMap map; - tsvn_svn_diff_t_extension * head = NULL; - tsvn_svn_diff_t_extension * tail = NULL; + tsvn_svn_diff_t_extension* head = nullptr; + tsvn_svn_diff_t_extension* tail = nullptr; svn_diff_t * tempdiff = diffYourBase; LONG baseLine = 0; LONG yourLine = 0; @@ -185,7 +185,7 @@ tsvn_svn_diff_t_extension * CDiffData::MovedBlocksDetect(svn_diff_t * diffYourBa baseLine = (LONG)tempdiff->original_start; if (m_arBaseFile.GetCount() <= (baseLine+tempdiff->original_length)) - return NULL; + return nullptr; for(int i = 0; i < tempdiff->original_length; ++i, ++baseLine) { const CString &sCurrentBaseLine = m_arBaseFile.GetAt(baseLine); @@ -196,7 +196,7 @@ tsvn_svn_diff_t_extension * CDiffData::MovedBlocksDetect(svn_diff_t * diffYourBa } yourLine = (LONG)tempdiff->modified_start; if (m_arYourFile.GetCount() <= (yourLine+tempdiff->modified_length)) - return NULL; + return nullptr; for(int i = 0; i < tempdiff->modified_length; ++i, ++yourLine) { const CString &sCurrentYourLine = m_arYourFile.GetAt(yourLine); @@ -214,7 +214,7 @@ tsvn_svn_diff_t_extension * CDiffData::MovedBlocksDetect(svn_diff_t * diffYourBa if(tempdiff->type != svn_diff__type_diff_modified) continue; - EquivalencyGroup * pGroup = NULL; + EquivalencyGroup* pGroup = nullptr; int i; for(i = (int)tempdiff->original_start; (i - tempdiff->original_start)< tempdiff->original_length; ++i) @@ -267,7 +267,7 @@ tsvn_svn_diff_t_extension * CDiffData::MovedBlocksDetect(svn_diff_t * diffYourBa --j2; // Ok, now our moved block is (i1..i2,j1..j2) tsvn_svn_diff_t_extension * newTail = CreateDiffExtension(tempdiff, pool); - if(head == NULL) + if (!head) { head = newTail; tail = head; @@ -333,14 +333,14 @@ tsvn_svn_diff_t_extension * CDiffData::MovedBlocksDetect(svn_diff_t * diffYourBa // and splitting them out // That is, we actually fragment diff blocks as we find moved sections tsvn_svn_diff_t_extension * existing = head; - tail = NULL; + tail = nullptr; for(tempdiff = diffYourBase; tempdiff; tempdiff = tempdiff->next) { // scan down block for a match if(tempdiff->type != svn_diff__type_diff_modified) continue; - EquivalencyGroup * pGroup = NULL; + EquivalencyGroup* pGroup = nullptr; int j = 0; for(j = (int)tempdiff->modified_start; (j - tempdiff->modified_start) < tempdiff->modified_length; ++j) { @@ -398,7 +398,7 @@ tsvn_svn_diff_t_extension * CDiffData::MovedBlocksDetect(svn_diff_t * diffYourBa --i2; --j2; // Ok, now our moved block is (i1..i2,j1..j2) - tsvn_svn_diff_t_extension * newTail = NULL; + tsvn_svn_diff_t_extension* newTail = nullptr; if(existing && existing->base == tempdiff) { newTail = existing; @@ -406,10 +406,8 @@ tsvn_svn_diff_t_extension * CDiffData::MovedBlocksDetect(svn_diff_t * diffYourBa else { newTail = CreateDiffExtension(tempdiff, pool); - if(head == NULL) - { + if (!head) head = newTail; - } else if(tail) { newTail->next = tail->next; diff --git a/src/TortoiseMerge/OpenDlg.cpp b/src/TortoiseMerge/OpenDlg.cpp index af033d92c..f41e852f6 100644 --- a/src/TortoiseMerge/OpenDlg.cpp +++ b/src/TortoiseMerge/OpenDlg.cpp @@ -27,11 +27,11 @@ // COpenDlg dialog IMPLEMENT_DYNAMIC(COpenDlg, CStandAloneDialog) -COpenDlg::COpenDlg(CWnd* pParent /*=NULL*/) +COpenDlg::COpenDlg(CWnd* pParent /*=nullptr*/) : CStandAloneDialog(COpenDlg::IDD, pParent) , m_bFromClipboard(FALSE) , m_cFormat(0) - , m_nextViewer(NULL) + , m_nextViewer(nullptr) { } @@ -119,7 +119,7 @@ void COpenDlg::OnBnClickedHelp() void COpenDlg::OnBrowseForFile(CString& filepath, UINT nFileFilter) { UpdateData(); - CCommonAppUtils::FileOpenSave(filepath, NULL, IDS_SELECTFILE, nFileFilter, true, m_hWnd); + CCommonAppUtils::FileOpenSave(filepath, nullptr, IDS_SELECTFILE, nFileFilter, true, m_hWnd); UpdateData(FALSE); } @@ -225,7 +225,7 @@ void COpenDlg::OnOK() HGLOBAL hglb = GetClipboardData(m_cFormat); LPCSTR lpstr = (LPCSTR)GlobalLock(hglb); - DWORD len = GetTempPath(0, NULL); + DWORD len = GetTempPath(0, nullptr); auto path = std::make_unique(len + 1); auto tempF = std::make_unique(len + 100); GetTempPath (len+1, path.get()); @@ -258,7 +258,7 @@ void COpenDlg::OnOK() { CString sErr; sErr.Format(IDS_ERR_PATCH_INVALIDPATCHFILE, (LPCTSTR)sFile); - MessageBox(sErr, NULL, MB_ICONERROR); + MessageBox(sErr, nullptr, MB_ICONERROR); return; } CRegDWORD lastRadioButton(L"Software\\TortoiseGitMerge\\OpenRadio", IDC_MERGERADIO); diff --git a/src/TortoiseMerge/OpenDlg.h b/src/TortoiseMerge/OpenDlg.h index 8193b022c..ff009f34c 100644 --- a/src/TortoiseMerge/OpenDlg.h +++ b/src/TortoiseMerge/OpenDlg.h @@ -27,7 +27,7 @@ class COpenDlg : public CStandAloneDialog DECLARE_DYNAMIC(COpenDlg) public: - COpenDlg(CWnd* pParent = NULL); // standard constructor + COpenDlg(CWnd* pParent = nullptr); // standard constructor virtual ~COpenDlg(); // Dialog Data diff --git a/src/TortoiseMerge/RegexFilterDlg.cpp b/src/TortoiseMerge/RegexFilterDlg.cpp index 1a4f57498..3a2af36d8 100644 --- a/src/TortoiseMerge/RegexFilterDlg.cpp +++ b/src/TortoiseMerge/RegexFilterDlg.cpp @@ -27,7 +27,7 @@ IMPLEMENT_DYNAMIC(CRegexFilterDlg, CDialogEx) -CRegexFilterDlg::CRegexFilterDlg(CWnd* pParent /*=NULL*/) +CRegexFilterDlg::CRegexFilterDlg(CWnd* pParent /*=nullptr*/) : CDialogEx(CRegexFilterDlg::IDD, pParent) { } diff --git a/src/TortoiseMerge/RegexFilterDlg.h b/src/TortoiseMerge/RegexFilterDlg.h index 157d42a50..1655730e8 100644 --- a/src/TortoiseMerge/RegexFilterDlg.h +++ b/src/TortoiseMerge/RegexFilterDlg.h @@ -26,7 +26,7 @@ class CRegexFilterDlg : public CDialogEx DECLARE_DYNAMIC(CRegexFilterDlg) public: - CRegexFilterDlg(CWnd* pParent = NULL); // standard constructor + CRegexFilterDlg(CWnd* pParent = nullptr); // standard constructor virtual ~CRegexFilterDlg(); // Dialog Data diff --git a/src/TortoiseMerge/RegexFiltersDlg.cpp b/src/TortoiseMerge/RegexFiltersDlg.cpp index bbd8fff75..d73ab224b 100644 --- a/src/TortoiseMerge/RegexFiltersDlg.cpp +++ b/src/TortoiseMerge/RegexFiltersDlg.cpp @@ -27,7 +27,7 @@ IMPLEMENT_DYNAMIC(CRegexFiltersDlg, CDialogEx) -CRegexFiltersDlg::CRegexFiltersDlg(CWnd* pParent /*=NULL*/) +CRegexFiltersDlg::CRegexFiltersDlg(CWnd* pParent /*=nullptr*/) : CDialogEx(CRegexFiltersDlg::IDD, pParent) , m_pIni(nullptr) { @@ -117,7 +117,7 @@ BOOL CRegexFiltersDlg::OnInitDialog() { CDialogEx::OnInitDialog(); - SetWindowTheme(m_RegexList.GetSafeHwnd(), L"Explorer", NULL); + SetWindowTheme(m_RegexList.GetSafeHwnd(), L"Explorer", nullptr); SetupListControl(); diff --git a/src/TortoiseMerge/RegexFiltersDlg.h b/src/TortoiseMerge/RegexFiltersDlg.h index c9ee98ca3..3b4667b63 100644 --- a/src/TortoiseMerge/RegexFiltersDlg.h +++ b/src/TortoiseMerge/RegexFiltersDlg.h @@ -27,7 +27,7 @@ class CRegexFiltersDlg : public CDialogEx DECLARE_DYNAMIC(CRegexFiltersDlg) public: - CRegexFiltersDlg(CWnd* pParent = NULL); // standard constructor + CRegexFiltersDlg(CWnd* pParent = nullptr); // standard constructor virtual ~CRegexFiltersDlg(); // Dialog Data diff --git a/src/TortoiseMerge/SetMainPage.cpp b/src/TortoiseMerge/SetMainPage.cpp index 95023b261..e0af273aa 100644 --- a/src/TortoiseMerge/SetMainPage.cpp +++ b/src/TortoiseMerge/SetMainPage.cpp @@ -256,7 +256,7 @@ void CSetMainPage::OnBnClickedWhitespace() BOOL CSetMainPage::DialogEnableWindow(UINT nID, BOOL bEnable) { CWnd * pwndDlgItem = GetDlgItem(nID); - if (pwndDlgItem == NULL) + if (!pwndDlgItem) return FALSE; if (bEnable) return pwndDlgItem->EnableWindow(bEnable); diff --git a/src/TortoiseMerge/Settings.cpp b/src/TortoiseMerge/Settings.cpp index 536bc32e0..aabf47339 100644 --- a/src/TortoiseMerge/Settings.cpp +++ b/src/TortoiseMerge/Settings.cpp @@ -24,15 +24,15 @@ IMPLEMENT_DYNAMIC(CSettings, CPropertySheet) CSettings::CSettings(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage) : CPropertySheet(nIDCaption, pParentWnd, iSelectPage) - , m_pMainPage(NULL) - , m_pColorPage(NULL) + , m_pMainPage(nullptr) + , m_pColorPage(nullptr) { } CSettings::CSettings(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) : CPropertySheet(pszCaption, pParentWnd, iSelectPage) - , m_pMainPage(NULL) - , m_pColorPage(NULL) + , m_pMainPage(nullptr) + , m_pColorPage(nullptr) { AddPropPages(); } @@ -54,9 +54,9 @@ void CSettings::AddPropPages() void CSettings::RemovePropPages() { delete m_pMainPage; - m_pMainPage = NULL; + m_pMainPage = nullptr; delete m_pColorPage; - m_pColorPage = NULL; + m_pColorPage = nullptr; } void CSettings::SaveData() diff --git a/src/TortoiseMerge/Settings.h b/src/TortoiseMerge/Settings.h index aab47580a..1670e3c6c 100644 --- a/src/TortoiseMerge/Settings.h +++ b/src/TortoiseMerge/Settings.h @@ -49,8 +49,8 @@ private: CSetColorPage * m_pColorPage; public: - CSettings(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); - CSettings(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); + CSettings(UINT nIDCaption, CWnd* pParentWnd = nullptr, UINT iSelectPage = 0); + CSettings(LPCTSTR pszCaption, CWnd* pParentWnd = nullptr, UINT iSelectPage = 0); virtual ~CSettings(); /** diff --git a/src/TortoiseMerge/TempFile.cpp b/src/TortoiseMerge/TempFile.cpp index a7e6a18bb..70e144521 100644 --- a/src/TortoiseMerge/TempFile.cpp +++ b/src/TortoiseMerge/TempFile.cpp @@ -39,7 +39,7 @@ CTempFiles& CTempFiles::Instance() CTGitPath CTempFiles::ConstructTempPath(const CTGitPath& path) { - DWORD len = ::GetTempPath(0, NULL); + DWORD len = ::GetTempPath(0, nullptr); auto temppath = std::make_unique(len + 1); auto tempF = std::make_unique(len + 50); ::GetTempPath (len+1, temppath.get()); @@ -97,7 +97,7 @@ CTGitPath CTempFiles::CreateTempPath (bool bRemoveAtEnd, const CTGitPath& path, if (directory) { DeleteFile(tempfile.GetWinPath()); - if (CreateDirectory (tempfile.GetWinPath(), NULL) == FALSE) + if (CreateDirectory(tempfile.GetWinPath(), nullptr) == FALSE) { if (GetLastError() != ERROR_ALREADY_EXISTS) return CTGitPath(); @@ -152,7 +152,7 @@ CTGitPath CTempFiles::GetTempDirPath(bool bRemoveAtEnd, const CTGitPath& path /* void CTempFiles::DeleteOldTempFiles(LPCTSTR wildCard) { - DWORD len = ::GetTempPath(0, NULL); + DWORD len = ::GetTempPath(0, nullptr); auto path = std::make_unique(len + 100); len = ::GetTempPath (len+100, path.get()); if (len == 0) diff --git a/src/TortoiseMerge/TortoiseMerge.cpp b/src/TortoiseMerge/TortoiseMerge.cpp index 1b3ed67a6..ea492be51 100644 --- a/src/TortoiseMerge/TortoiseMerge.cpp +++ b/src/TortoiseMerge/TortoiseMerge.cpp @@ -96,7 +96,7 @@ BOOL CTortoiseMergeApp::InitInstance() CCrashReport::Instance().AddUserInfoToReport(L"CommandLine", GetCommandLine()); { - DWORD len = GetCurrentDirectory(0, NULL); + DWORD len = GetCurrentDirectory(0, nullptr); if (len) { auto originalCurrentDirectory = std::make_unique(len); @@ -112,7 +112,7 @@ BOOL CTortoiseMergeApp::InitInstance() CRegDWORD loc = CRegDWORD(L"Software\\TortoiseGit\\LanguageID", 1033); long langId = loc; CString langDll; - HINSTANCE hInst = NULL; + HINSTANCE hInst = nullptr; do { langDll.Format(L"%sLanguages\\TortoiseMerge%ld.dll", (LPCTSTR)CPathUtils::GetAppParentDirectory(), langId); @@ -123,9 +123,9 @@ BOOL CTortoiseMergeApp::InitInstance() if (sFileVer.Compare(sVer)!=0) { FreeLibrary(hInst); - hInst = NULL; + hInst = nullptr; } - if (hInst != NULL) + if (hInst) AfxSetResourceHandle(hInst); else { @@ -138,7 +138,7 @@ BOOL CTortoiseMergeApp::InitInstance() else langId = 0; } - } while ((hInst == NULL) && (langId != 0)); + } while ((!hInst) && (langId != 0)); { CString langStr; langStr.Format(L"%ld", langId); @@ -245,12 +245,12 @@ BOOL CTortoiseMergeApp::InitInstance() // To create the main window, this code creates a new frame window // object and then sets it as the application's main window object CMainFrame* pFrame = new CMainFrame; - if (pFrame == NULL) + if (!pFrame) return FALSE; m_pMainWnd = pFrame; // create and load the frame with its resources - if (!pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL)) + if (!pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, nullptr, nullptr)) return FALSE; // Fill in the command line options @@ -302,7 +302,7 @@ BOOL CTortoiseMergeApp::InitInstance() { CBrowseFolder fbrowser; fbrowser.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; - if (fbrowser.Show(NULL, pFrame->m_Data.m_sPatchPath)==CBrowseFolder::CANCEL) + if (fbrowser.Show(nullptr, pFrame->m_Data.m_sPatchPath) == CBrowseFolder::CANCEL) return FALSE; } } @@ -315,8 +315,8 @@ BOOL CTortoiseMergeApp::InitInstance() HRESULT hr; // Create a new common save file dialog - CComPtr pfd = NULL; - hr = pfd.CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER); + CComPtr pfd; + hr = pfd.CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC_SERVER); if (SUCCEEDED(hr)) { // Set the dialog options @@ -348,7 +348,7 @@ BOOL CTortoiseMergeApp::InitInstance() // check if there's a unified diff on the clipboard and // add a button to the fileopen dialog if there is. UINT cFormat = RegisterClipboardFormat(L"TGIT_UNIFIEDDIFF"); - if ((cFormat)&&(OpenClipboard(NULL))) + if ((cFormat) && (OpenClipboard(nullptr))) { HGLOBAL hglb = GetClipboardData(cFormat); if (hglb) @@ -366,13 +366,13 @@ BOOL CTortoiseMergeApp::InitInstance() if (SUCCEEDED(hr) && SUCCEEDED(hr = pfd->Show(pFrame->m_hWnd))) { // Get the selection from the user - CComPtr psiResult = NULL; + CComPtr psiResult; hr = pfd->GetResult(&psiResult); if (bAdvised) pfd->Unadvise(dwCookie); if (SUCCEEDED(hr)) { - PWSTR pszPath = NULL; + PWSTR pszPath = nullptr; hr = psiResult->GetDisplayName(SIGDN_FILESYSPATH, &pszPath); if (SUCCEEDED(hr)) { @@ -401,10 +401,8 @@ BOOL CTortoiseMergeApp::InitInstance() { int nArgs; LPWSTR *szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); - if( NULL == szArglist ) - { + if (!szArglist) TRACE("CommandLineToArgvW failed\n"); - } else { if ( nArgs==3 || nArgs==4 ) @@ -462,7 +460,7 @@ BOOL CTortoiseMergeApp::InitInstance() CString outfile = parser.GetVal(L"outfile"); if (outfile.IsEmpty()) { - CCommonAppUtils::FileOpenSave(outfile, NULL, IDS_SAVEASTITLE, IDS_COMMONFILEFILTER, false); + CCommonAppUtils::FileOpenSave(outfile, nullptr, IDS_SAVEASTITLE, IDS_COMMONFILEFILTER, false); } if (!outfile.IsEmpty()) { @@ -522,7 +520,7 @@ bool CTortoiseMergeApp::HasClipboardPatch() if (cFormat == 0) return false; - if (OpenClipboard(NULL) == 0) + if (OpenClipboard(nullptr) == 0) return false; bool containsPatch = false; @@ -546,13 +544,13 @@ bool CTortoiseMergeApp::TrySavePatchFromClipboard(std::wstring& resultFile) UINT cFormat = RegisterClipboardFormat(L"TGIT_UNIFIEDDIFF"); if (cFormat == 0) return false; - if (OpenClipboard(NULL) == 0) + if (OpenClipboard(nullptr) == 0) return false; HGLOBAL hglb = GetClipboardData(cFormat); LPCSTR lpstr = (LPCSTR)GlobalLock(hglb); - DWORD len = GetTempPath(0, NULL); + DWORD len = GetTempPath(0, nullptr); auto path = std::make_unique(len + 1); auto tempF = std::make_unique(len + 100); GetTempPath (len+1, path.get()); diff --git a/src/TortoiseMerge/Undo.cpp b/src/TortoiseMerge/Undo.cpp index 61d7f480a..065e8e893 100644 --- a/src/TortoiseMerge/Undo.cpp +++ b/src/TortoiseMerge/Undo.cpp @@ -129,7 +129,7 @@ bool CUndo::Undo(CBaseView * pLeft, CBaseView * pRight, CBaseView * pBottom) else UndoOne(pLeft, pRight, pBottom); - CBaseView * pActiveView = NULL; + CBaseView* pActiveView = nullptr; if (pBottom && pBottom->IsTarget()) { @@ -268,7 +268,7 @@ bool CUndo::Redo(CBaseView * pLeft, CBaseView * pRight, CBaseView * pBottom) else RedoOne(pLeft, pRight, pBottom); - CBaseView * pActiveView = NULL; + CBaseView* pActiveView = nullptr; if (pBottom && pBottom->IsTarget()) { diff --git a/src/TortoiseMerge/XSplitter.cpp b/src/TortoiseMerge/XSplitter.cpp index da1b15cf9..3e3008ed8 100644 --- a/src/TortoiseMerge/XSplitter.cpp +++ b/src/TortoiseMerge/XSplitter.cpp @@ -85,7 +85,7 @@ BOOL CXSplitter::ReplaceView(int row, int col,CRuntimeClass * pViewClass,SIZE si // process of the new view CDocument * pDoc= ((CView *)GetPane(row,col))->GetDocument(); CView * pActiveView=GetParentFrame()->GetActiveView(); - if (pActiveView==NULL || pActiveView==GetPane(row,col)) + if (!pActiveView || pActiveView == GetPane(row, col)) bSetActive=TRUE; else bSetActive=FALSE; @@ -100,9 +100,9 @@ BOOL CXSplitter::ReplaceView(int row, int col,CRuntimeClass * pViewClass,SIZE si // Create new view context.m_pNewViewClass=pViewClass; context.m_pCurrentDoc=pDoc; - context.m_pNewDocTemplate=NULL; - context.m_pLastView=NULL; - context.m_pCurrentFrame=NULL; + context.m_pNewDocTemplate = nullptr; + context.m_pLastView = nullptr; + context.m_pCurrentFrame = nullptr; CreateView(row,col,pViewClass,size, &context); @@ -128,7 +128,7 @@ void CXSplitter::HideRow(int nRowHide) int nActiveRow, nActiveCol; // if the nRow has an active window -- change it - if( GetActivePane( &nActiveRow, &nActiveCol ) != NULL ) + if (GetActivePane(&nActiveRow, &nActiveCol) != nullptr) { if( nActiveRow == nRowHide ) { @@ -142,7 +142,7 @@ void CXSplitter::HideRow(int nRowHide) for( int nCol = 0; nCol < m_nCols; ++nCol ) { CWnd* pPaneHide = GetPane( nRowHide, nCol ); - ASSERT( pPaneHide != NULL ); + ASSERT(pPaneHide != nullptr); pPaneHide->ShowWindow( SW_HIDE ); pPaneHide->SetDlgCtrlID( AFX_IDW_PANE_FIRST+nCol * 16+m_nRows ); @@ -150,7 +150,7 @@ void CXSplitter::HideRow(int nRowHide) for( int nRow = nRowHide+1; nRow < m_nRows; ++nRow ) { CWnd* pPane = GetPane( nRow, nCol ); - ASSERT( pPane != NULL ); + ASSERT(pPane != nullptr); pPane->SetDlgCtrlID( IdFromRowCol( nRow-1, nCol )); } @@ -181,13 +181,13 @@ void CXSplitter::ShowRow() for( int nCol = 0; nCol < m_nCols; ++nCol ) { CWnd* pPaneShow = GetDlgItem( AFX_IDW_PANE_FIRST+nCol * 16+m_nRows ); - ASSERT( pPaneShow != NULL ); + ASSERT(pPaneShow != nullptr); pPaneShow->ShowWindow( SW_SHOWNA ); for( nRow = m_nRows - 2; nRow >= nShowRow; --nRow ) { CWnd* pPane = GetPane( nRow, nCol ); - ASSERT( pPane != NULL ); + ASSERT(pPane != nullptr); pPane->SetDlgCtrlID( IdFromRowCol( nRow + 1, nCol )); } @@ -212,7 +212,7 @@ void CXSplitter::HideColumn(int nColHide) // if the column has an active window -- change it int nActiveRow, nActiveCol; - if( GetActivePane( &nActiveRow, &nActiveCol ) != NULL ) + if (GetActivePane(&nActiveRow, &nActiveCol) != nullptr) { if( nActiveCol == nColHide ) { @@ -226,7 +226,7 @@ void CXSplitter::HideColumn(int nColHide) for( int nRow = 0; nRow < m_nRows; nRow++) { CWnd* pPaneHide = GetPane(nRow, nColHide); - ASSERT( pPaneHide != NULL ); + ASSERT(pPaneHide != nullptr); pPaneHide->ShowWindow(SW_HIDE); pPaneHide->SetDlgCtrlID( AFX_IDW_PANE_FIRST+nRow * 16+m_nCols ); @@ -234,7 +234,7 @@ void CXSplitter::HideColumn(int nColHide) for( int nCol = nColHide + 1; nCol < m_nCols; nCol++ ) { CWnd* pPane = GetPane( nRow, nCol ); - ASSERT( pPane != NULL ); + ASSERT(pPane != nullptr); pPane->SetDlgCtrlID( IdFromRowCol( nRow, nCol - 1 )); } @@ -265,13 +265,13 @@ void CXSplitter::ShowColumn() for( int nRow = 0; nRow < m_nRows; ++nRow ) { CWnd* pPaneShow = GetDlgItem( AFX_IDW_PANE_FIRST+nRow * 16+m_nCols ); - ASSERT( pPaneShow != NULL ); + ASSERT(pPaneShow != nullptr); pPaneShow->ShowWindow( SW_SHOWNA ); for( nCol = m_nCols - 2; nCol >= nShowCol; --nCol ) { CWnd* pPane = GetPane( nRow, nCol ); - ASSERT( pPane != NULL ); + ASSERT(pPane != nullptr); pPane->SetDlgCtrlID( IdFromRowCol( nRow, nCol + 1 )); } -- 2.11.4.GIT