From eae27ea60b72e2201adfac9132d26f1d9974efad Mon Sep 17 00:00:00 2001 From: GreyMerlin Date: Tue, 23 Oct 2018 14:27:28 -0700 Subject: [PATCH] Various refactorings involving NULL, ASSERT, TRUE and FALSE (2) * `assert(0)` -> `assert(false)` * Some `return 0;` -> `return nullptr;` * Also `ptr(0)` initializations -> `ptr(nullptr)` --- Externals/crystaledit/editlib/LineInfo.cpp | 2 +- Externals/crystaledit/editlib/UndoRecord.h | 8 +-- Externals/crystaledit/editlib/cregexp_poco.cpp | 4 +- Src/ChildFrm.cpp | 4 +- Src/Common/BCMenu.cpp | 73 +++++++++++++++----------- Src/Common/ExConverter.cpp | 4 +- Src/Common/LanguageSelect.cpp | 4 +- Src/Common/MDITabBar.h | 2 +- Src/Common/Picture.cpp | 2 +- Src/Common/PropertyPageHost.cpp | 2 +- Src/Common/RegKey.cpp | 40 +++++++------- Src/Common/ShellContextMenu.cpp | 14 ++--- Src/Common/ShellFileOperations.cpp | 2 +- Src/Common/SuperComboBox.cpp | 4 +- Src/Common/UniFile.cpp | 24 ++++----- Src/Common/VersionInfo.cpp | 2 +- Src/Common/multiformatText.h | 2 +- Src/Common/scbarcf.cpp | 2 +- Src/CompareStats.h | 2 +- Src/ConfigLog.cpp | 8 +-- Src/DiffContext.cpp | 2 +- Src/DiffFileData.cpp | 2 +- Src/DiffItem.h | 2 +- Src/DiffItemList.cpp | 10 ++-- Src/DiffList.cpp | 2 +- Src/DiffThread.cpp | 2 +- Src/DiffThread.h | 6 +-- Src/DiffViewBar.cpp | 2 +- Src/DiffWrapper.cpp | 14 ++--- Src/DirActions.cpp | 2 +- Src/DirCmpReport.cpp | 10 ++-- Src/DirCompProgressBar.cpp | 4 +- Src/DirDoc.cpp | 4 +- Src/DirFrame.cpp | 4 +- Src/DirViewColItems.cpp | 20 +++---- Src/FileActionScript.cpp | 2 +- Src/FileTransform.h | 2 +- Src/FilterList.cpp | 2 +- Src/GhostTextView.cpp | 2 +- Src/HexMergeDoc.cpp | 6 +-- Src/HexMergeFrm.cpp | 4 +- Src/HexMergeView.cpp | 2 +- Src/IListCtrlImpl.h | 2 +- Src/ImgMergeFrm.cpp | 12 ++--- Src/LineFiltersDlg.cpp | 2 +- Src/LineFiltersList.cpp | 6 +-- Src/LocationBar.cpp | 2 +- Src/MainFrm.cpp | 2 +- Src/Merge.cpp | 12 ++--- Src/Merge7zFormatMergePluginImpl.h | 2 +- Src/MergeDoc.cpp | 2 +- Src/MergeEditView.cpp | 2 +- Src/OptionsFont.cpp | 6 +-- Src/PathContext.h | 2 +- Src/Plugins.cpp | 6 +-- Src/PropRegistry.cpp | 2 +- Src/markdown.cpp | 4 +- 57 files changed, 192 insertions(+), 183 deletions(-) diff --git a/Externals/crystaledit/editlib/LineInfo.cpp b/Externals/crystaledit/editlib/LineInfo.cpp index 607c2f718..1d7e119a0 100644 --- a/Externals/crystaledit/editlib/LineInfo.cpp +++ b/Externals/crystaledit/editlib/LineInfo.cpp @@ -17,7 +17,7 @@ @brief Constructor. */ LineInfo::LineInfo() -: m_pcLine(NULL) +: m_pcLine(nullptr) , m_nLength(0) , m_nMax(0) , m_nEolChars(0) diff --git a/Externals/crystaledit/editlib/UndoRecord.h b/Externals/crystaledit/editlib/UndoRecord.h index fe2c60851..e85e1891b 100644 --- a/Externals/crystaledit/editlib/UndoRecord.h +++ b/Externals/crystaledit/editlib/UndoRecord.h @@ -42,16 +42,16 @@ private: UndoRecord () // default constructor : m_dwFlags(0) , m_nAction(0) - , m_paSavedRevisionNumbers(NULL) - , m_pszText(NULL) + , m_paSavedRevisionNumbers(nullptr) + , m_pszText(nullptr) { } UndoRecord (const UndoRecord & src) // copy constructor : m_dwFlags(0) , m_nAction(0) - , m_paSavedRevisionNumbers(NULL) - , m_pszText(NULL) + , m_paSavedRevisionNumbers(nullptr) + , m_pszText(nullptr) { Clone(src); } diff --git a/Externals/crystaledit/editlib/cregexp_poco.cpp b/Externals/crystaledit/editlib/cregexp_poco.cpp index 44f503bf5..ec0a574ee 100644 --- a/Externals/crystaledit/editlib/cregexp_poco.cpp +++ b/Externals/crystaledit/editlib/cregexp_poco.cpp @@ -131,11 +131,11 @@ static int add(size_t *len, LPTSTR *s, LPCTSTR a, size_t alen, int &flag) { if (!p) return 0; *s = p; - assert(*s); + assert(*s != 0); memcpy(*s + *len, a, alen * sizeof(TCHAR)); } else { *s = (LPTSTR) malloc(NewLen * sizeof(TCHAR)); - assert(*s); + assert(*s != 0); memcpy(*s, a, alen * sizeof(TCHAR)); *len = 0; } diff --git a/Src/ChildFrm.cpp b/Src/ChildFrm.cpp index f15ca4f49..c4a318082 100644 --- a/Src/ChildFrm.cpp +++ b/Src/ChildFrm.cpp @@ -75,8 +75,8 @@ END_MESSAGE_MAP() * @brief Constructor. */ CChildFrame::CChildFrame() -: m_hIdentical(NULL) -, m_hDifferent(NULL) +: m_hIdentical(nullptr) +, m_hDifferent(nullptr) { m_bActivated = false; std::fill_n(m_nLastSplitPos, 2, 0); diff --git a/Src/Common/BCMenu.cpp b/Src/Common/BCMenu.cpp index 55d602938..b488d25e8 100644 --- a/Src/Common/BCMenu.cpp +++ b/Src/Common/BCMenu.cpp @@ -1218,7 +1218,8 @@ BCMenu *BCMenu::FindAnotherMenuOption(int nId,UINT& nLoc,CArray #endif if(psubmenu){ pgoodmenu=psubmenu->FindAnotherMenuOption(nId,nLoc,bcsubs,bclocs); - if(pgoodmenu)return(pgoodmenu); + if(pgoodmenu != nullptr) + return pgoodmenu; } else if(nId==(int)GetMenuItemID(i)){ INT_PTR numsubs=bcsubs.GetSize(); @@ -1231,12 +1232,12 @@ BCMenu *BCMenu::FindAnotherMenuOption(int nId,UINT& nLoc,CArray } if(foundflag){ nLoc=static_cast(i); - return(this); + return this; } } } nLoc = static_cast(-1); - return(NULL); + return nullptr; } BCMenu *BCMenu::FindMenuOption(int nId,UINT& nLoc) @@ -1251,15 +1252,16 @@ BCMenu *BCMenu::FindMenuOption(int nId,UINT& nLoc) #endif if(psubmenu){ pgoodmenu=psubmenu->FindMenuOption(nId,nLoc); - if(pgoodmenu)return(pgoodmenu); + if(pgoodmenu != nullptr) + return pgoodmenu; } else if(nId==(int)GetMenuItemID(i)){ nLoc=i; - return(this); + return this; } } nLoc = static_cast(-1); - return(NULL); + return nullptr; } BCMenuData *BCMenu::FindMenuOption(wchar_t *lpstrText) @@ -1274,20 +1276,21 @@ BCMenuData *BCMenu::FindMenuOption(wchar_t *lpstrText) #else psubmenu=static_cast(GetSubMenu(i)); #endif - if(psubmenu){ + if(psubmenu != nullptr){ pmenulist=psubmenu->FindMenuOption(lpstrText); - if(pmenulist)return(pmenulist); + if(pmenulist != nullptr) + return pmenulist; } else{ for(j=0;j<=m_MenuList.GetUpperBound();++j){ const wchar_t *szWide;//SK: we use const to prevent misuse of this Ptr szWide = m_MenuList[j]->GetWideString (); if(szWide && !wcscmp(lpstrText,szWide))//SK: modified for dynamic allocation - return(m_MenuList[j]); + return m_MenuList[j]; } } } - return(NULL); + return nullptr; } @@ -1299,27 +1302,30 @@ BOOL BCMenu::LoadMenu(int nResource) BOOL BCMenu::LoadMenu(LPCTSTR lpszResourceName) { ASSERT_VALID(this); - ASSERT(lpszResourceName != NULL); + ASSERT(lpszResourceName != nullptr); // Find the Menu Resource: HINSTANCE hInst = AfxFindResourceHandle(lpszResourceName,RT_MENU); HRSRC hRsrc = ::FindResource(hInst,lpszResourceName,RT_MENU); - if (hRsrc == NULL){ - hInst = NULL; + if (hRsrc == nullptr){ + hInst = nullptr; hRsrc = ::FindResource(hInst,lpszResourceName,RT_MENU); } - if(hRsrc == NULL)return FALSE; + if(hRsrc == nullptr) + return FALSE; // Load the Menu Resource: HGLOBAL hGlobal = LoadResource(hInst, hRsrc); - if(hGlobal == NULL)return FALSE; + if(hGlobal == nullptr) + return FALSE; // first destroy the menu if we're trying to loadmenu again DestroyMenu(); // Attempt to create us as a menu... - if(!CMenu::CreateMenu())return FALSE; + if(!CMenu::CreateMenu()) + return FALSE; // Get Item template Header, and calculate offset of MENUITEMTEMPLATES @@ -1524,10 +1530,10 @@ BCMenuData *BCMenu::FindMenuList(UINT_PTR nID) for(int i=0;i<=m_MenuList.GetUpperBound();++i){ if(m_MenuList[i]->nID==nID && !m_MenuList[i]->syncflag){ m_MenuList[i]->syncflag=1; - return(m_MenuList[i]); + return m_MenuList[i]; } } - return(NULL); + return nullptr; } void BCMenu::InitializeMenuList(int value) @@ -1643,13 +1649,13 @@ void BCMenu::GetTransparentBitmap(CBitmap &bmp) BITMAP BitMap; bmp.GetBitmap(&BitMap); - ddc.CreateCompatibleDC(NULL); + ddc.CreateCompatibleDC(nullptr); CBitmap * pddcOldBmp = ddc.SelectObject(&bmp); // use this to get the background color, takes into account color shifting CDC ddc2; CBitmap bmp2; - ddc2.CreateCompatibleDC(NULL); + ddc2.CreateCompatibleDC(nullptr); bmp2.CreateCompatibleBitmap(&ddc,BitMap.bmWidth,BitMap.bmHeight); col=RGB(255,0,255); // Original was RGB(192,192,192) CBitmap * pddcOldBmp2 = ddc2.SelectObject(&bmp2); @@ -1685,13 +1691,13 @@ void BCMenu::GetDisabledBitmap(CBitmap &bmp,COLORREF background) BITMAP BitMap; bmp.GetBitmap(&BitMap); - ddc.CreateCompatibleDC(NULL); + ddc.CreateCompatibleDC(nullptr); CBitmap * pddcOldBmp = ddc.SelectObject(&bmp); // use this to get the background color, takes into account color shifting CDC ddc2; CBitmap bmp2; - ddc2.CreateCompatibleDC(NULL); + ddc2.CreateCompatibleDC(nullptr); bmp2.CreateCompatibleBitmap(&ddc,BitMap.bmWidth,BitMap.bmHeight); CBitmap * pddcOldBmp2 = ddc2.SelectObject(&bmp2); CRect rect(0,0,BitMap.bmWidth,BitMap.bmHeight); @@ -1795,13 +1801,13 @@ void BCMenu::DitherBlt2(CDC *drawdc, int nXDest, int nYDest, int nWidth, { // create a monochrome memory DC CDC ddc; - ddc.CreateCompatibleDC(0); + ddc.CreateCompatibleDC(nullptr); CBitmap bwbmp; bwbmp.CreateCompatibleBitmap(&ddc, nWidth, nHeight); CBitmap * pddcOldBmp = ddc.SelectObject(&bwbmp); CDC dc; - dc.CreateCompatibleDC(0); + dc.CreateCompatibleDC(nullptr); CBitmap * pdcOldBmp = dc.SelectObject(&bmp); // build a mask @@ -1837,7 +1843,7 @@ void BCMenu::DitherBlt3(CDC *drawdc, int nXDest, int nYDest, int nWidth, { GetDisabledBitmap(bmp,bgcolor); CDC dc; - dc.CreateCompatibleDC(NULL); + dc.CreateCompatibleDC(nullptr); CBitmap * pdcOldBmp = dc.SelectObject(&bmp); drawdc->BitBlt(nXDest,nYDest,nWidth, nHeight, &dc,0,0,SRCCOPY); // reset DCs @@ -1876,22 +1882,25 @@ HBITMAP BCMenu::LoadSysColorBitmap(int nResourceId) AfxFindResourceHandle(MAKEINTRESOURCE(nResourceId),RT_BITMAP); HRSRC hRsrc = ::FindResource(hInst,MAKEINTRESOURCE(nResourceId),RT_BITMAP); - if (hRsrc == NULL){ - hInst = NULL; + if (hRsrc == nullptr){ + hInst = nullptr; hRsrc = ::FindResource(hInst,MAKEINTRESOURCE(nResourceId),RT_BITMAP); } - if (hRsrc == NULL)return NULL; + if (hRsrc == nullptr) + return nullptr; // determine how many colors in the bitmap HGLOBAL hglb; - if ((hglb = LoadResource(hInst, hRsrc)) == NULL) - return NULL; + if ((hglb = LoadResource(hInst, hRsrc)) == nullptr) + return nullptr; LPBITMAPINFOHEADER lpBitmap = (LPBITMAPINFOHEADER)LockResource(hglb); - if (lpBitmap == NULL)return NULL; + if (lpBitmap == nullptr) + return nullptr; WORD numcol = NumBitmapColors(lpBitmap); ::FreeResource(hglb); - if(numcol!=16)return(NULL); + if(numcol!=16) + return nullptr; return AfxLoadSysColorBitmap(hInst, hRsrc, FALSE); } diff --git a/Src/Common/ExConverter.cpp b/Src/Common/ExConverter.cpp index 0ac484696..69c922884 100644 --- a/Src/Common/ExConverter.cpp +++ b/Src/Common/ExConverter.cpp @@ -37,8 +37,8 @@ private: public: CExconverterMLang() - : m_pmlang(NULL) - , m_hLibMLang(NULL) + : m_pmlang(nullptr) + , m_hLibMLang(nullptr) , m_mlangcookie(0) { } diff --git a/Src/Common/LanguageSelect.cpp b/Src/Common/LanguageSelect.cpp index e5c897905..f108392a3 100644 --- a/Src/Common/LanguageSelect.cpp +++ b/Src/Common/LanguageSelect.cpp @@ -484,7 +484,7 @@ static HANDLE NTAPI FindFile(HANDLE h, LPCTSTR path, WIN32_FIND_DATA *fd) const WORD wSourceLangId = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); CLanguageSelect::CLanguageSelect() -: m_hCurrentDll(0) +: m_hCurrentDll(nullptr) , m_wCurLanguage(wSourceLangId) , m_codepage(0) { @@ -894,7 +894,7 @@ bool CLanguageSelect::TranslateString(const std::string& str, String &translated void CLanguageSelect::SetIndicators(CStatusBar &sb, const UINT *rgid, int n) const { HGDIOBJ hf = (HGDIOBJ)sb.SendMessage(WM_GETFONT); - CClientDC dc(0); + CClientDC dc(nullptr); if (hf) hf = dc.SelectObject(hf); if (n) diff --git a/Src/Common/MDITabBar.h b/Src/Common/MDITabBar.h index b2101d85a..2335f2d98 100644 --- a/Src/Common/MDITabBar.h +++ b/Src/Common/MDITabBar.h @@ -26,7 +26,7 @@ private: CFont m_font; public: - CMDITabBar() : m_bInSelchange(false), m_pMainFrame(NULL), m_bMouseTracking(false), m_bCloseButtonDown(false), m_bAutoMaxWidth(true), m_nDraggingTabItemIndex(-1) {} + CMDITabBar() : m_bInSelchange(false), m_pMainFrame(nullptr), m_bMouseTracking(false), m_bCloseButtonDown(false), m_bAutoMaxWidth(true), m_nDraggingTabItemIndex(-1) {} virtual ~CMDITabBar() {} BOOL Create(CMDIFrameWnd* pParentWnd); void UpdateTabs(); diff --git a/Src/Common/Picture.cpp b/Src/Common/Picture.cpp index c6dcfb1d7..7ce38ae8f 100644 --- a/Src/Common/Picture.cpp +++ b/Src/Common/Picture.cpp @@ -131,7 +131,7 @@ CSize CPicture::GetImageSize(CDC* pDC) const return CSize(0, 0); CSize sz(hmWidth,hmHeight); if (pDC==NULL) { - CWindowDC dc(NULL); + CWindowDC dc(nullptr); dc.HIMETRICtoDP(&sz); // convert to pixels } else { pDC->HIMETRICtoDP(&sz); diff --git a/Src/Common/PropertyPageHost.cpp b/Src/Common/PropertyPageHost.cpp index a45d35f07..82bdf2c76 100644 --- a/Src/Common/PropertyPageHost.cpp +++ b/Src/Common/PropertyPageHost.cpp @@ -169,7 +169,7 @@ bool CPropertyPageHost::SetActivePage(int nIndex, bool bAndFocus /*= true*/) // move the focus to the first dlg ctrl if (bAndFocus) { - CWnd* pCtrl = pPage->GetNextDlgTabItem(NULL); + CWnd* pCtrl = pPage->GetNextDlgTabItem(nullptr); if (pCtrl) pCtrl->SetFocus(); diff --git a/Src/Common/RegKey.cpp b/Src/Common/RegKey.cpp index 9e654b187..bfd8191a8 100644 --- a/Src/Common/RegKey.cpp +++ b/Src/Common/RegKey.cpp @@ -15,7 +15,7 @@ * @brief Default constructor. */ CRegKeyEx::CRegKeyEx() -: m_hKey(NULL) +: m_hKey(nullptr) { } @@ -113,8 +113,8 @@ bool CRegKeyEx::QueryRegUser(LPCTSTR key) */ LONG CRegKeyEx::WriteDword(LPCTSTR pszKey, DWORD dwVal) { - assert(m_hKey); - assert(pszKey); + assert(m_hKey != nullptr); + assert(pszKey != nullptr); return RegSetValueEx(m_hKey, pszKey, 0L, REG_DWORD, (const LPBYTE) &dwVal, sizeof(DWORD)); } @@ -127,8 +127,8 @@ LONG CRegKeyEx::WriteDword(LPCTSTR pszKey, DWORD dwVal) */ LONG CRegKeyEx::WriteBool(LPCTSTR pszKey, bool bVal) { - assert(m_hKey); - assert(pszKey); + assert(m_hKey != nullptr); + assert(pszKey != nullptr); DWORD dwVal = (DWORD)bVal; return RegSetValueEx(m_hKey, pszKey, 0L, REG_DWORD, (const LPBYTE) &dwVal, sizeof(DWORD)); @@ -142,8 +142,8 @@ LONG CRegKeyEx::WriteBool(LPCTSTR pszKey, bool bVal) */ LONG CRegKeyEx::WriteFloat(LPCTSTR pszKey, float fVal) { - assert(m_hKey); - assert(pszKey); + assert(m_hKey != nullptr); + assert(pszKey != nullptr); String s = strutils::to_str(fVal); return RegSetValueEx(m_hKey, pszKey, 0L, REG_SZ, (const LPBYTE) s.c_str(), static_cast((s.length() + 1))*sizeof(TCHAR) ); @@ -157,9 +157,9 @@ LONG CRegKeyEx::WriteFloat(LPCTSTR pszKey, float fVal) */ LONG CRegKeyEx::WriteString(LPCTSTR pszKey, LPCTSTR pszData) { - assert(m_hKey); - assert(pszKey); - assert(pszData); + assert(m_hKey != nullptr); + assert(pszKey != nullptr); + assert(pszData != nullptr); return RegSetValueEx(m_hKey, pszKey, 0L, REG_SZ, (const LPBYTE) pszData, static_cast(_tcslen(pszData)+ 1)*sizeof(TCHAR)); @@ -173,8 +173,8 @@ LONG CRegKeyEx::WriteString(LPCTSTR pszKey, LPCTSTR pszData) */ DWORD CRegKeyEx::ReadDword(LPCTSTR pszKey, DWORD defval) { - assert(m_hKey); - assert(pszKey); + assert(m_hKey != nullptr); + assert(pszKey != nullptr); DWORD dwType; DWORD dwSize = sizeof (DWORD); @@ -252,8 +252,8 @@ BYTE CRegKeyEx::ReadByte(LPCTSTR pszKey, BYTE defval) */ float CRegKeyEx::ReadFloat(LPCTSTR pszKey, float defval) { - assert(m_hKey); - assert(pszKey); + assert(m_hKey != nullptr); + assert(pszKey != nullptr); DWORD dwType; DWORD dwSize = 100; @@ -276,8 +276,8 @@ float CRegKeyEx::ReadFloat(LPCTSTR pszKey, float defval) */ bool CRegKeyEx::ReadBool(LPCTSTR pszKey, bool defval) { - assert(m_hKey); - assert(pszKey); + assert(m_hKey != nullptr); + assert(pszKey != nullptr); DWORD dwType; DWORD dwSize = sizeof(DWORD); @@ -300,8 +300,8 @@ bool CRegKeyEx::ReadBool(LPCTSTR pszKey, bool defval) */ String CRegKeyEx::ReadString (LPCTSTR pszKey, LPCTSTR defval) { - assert(m_hKey); - assert(pszKey); + assert(m_hKey != nullptr); + assert(pszKey != nullptr); DWORD dwType; DWORD dwSize = 0; @@ -333,8 +333,8 @@ String CRegKeyEx::ReadString (LPCTSTR pszKey, LPCTSTR defval) */ void CRegKeyEx::ReadChars (LPCTSTR pszKey, LPTSTR pData, DWORD dwLen, LPCTSTR defval) { - assert(m_hKey); - assert(pszKey); + assert(m_hKey != nullptr); + assert(pszKey != nullptr); DWORD dwType; DWORD len = dwLen; diff --git a/Src/Common/ShellContextMenu.cpp b/Src/Common/ShellContextMenu.cpp index b31ffb959..7e852d62b 100644 --- a/Src/Common/ShellContextMenu.cpp +++ b/Src/Common/ShellContextMenu.cpp @@ -33,10 +33,10 @@ #endif CShellContextMenu::CShellContextMenu(UINT cmdFirst, UINT cmdLast) -: m_pPreferredMenu(NULL) -, m_pShellContextMenu2(NULL) -, m_pShellContextMenu3(NULL) -, m_hShellContextMenu(NULL) +: m_pPreferredMenu(nullptr) +, m_pShellContextMenu2(nullptr) +, m_pShellContextMenu3(nullptr) +, m_hShellContextMenu(nullptr) , m_cmdFirst(cmdFirst) , m_cmdLast(cmdLast) { @@ -94,7 +94,7 @@ bool CShellContextMenu::HandleMenuMessage(UINT message, WPARAM wParam, LPARAM lP // (HMENU)hMenu = (HMENU)lpDrawItem->hwndItem; // TRACE(_T(" hMenu == 0x%p\n"), hMenu); //} - //assert(0); + //assert(false); } } else if (m_pShellContextMenu2) @@ -102,7 +102,7 @@ bool CShellContextMenu::HandleMenuMessage(UINT message, WPARAM wParam, LPARAM lP if (FAILED(/*hr = */m_pShellContextMenu2->HandleMenuMsg(message, wParam, lParam))) { //TRACE(_T("HandleMenuMsg(%x) failed with error: %lx\n"), message, hr); - //assert(0); + //assert(false); } } // indicate that we've processed the message @@ -115,7 +115,7 @@ bool CShellContextMenu::HandleMenuMessage(UINT message, WPARAM wParam, LPARAM lP if (FAILED(/*hr = */m_pShellContextMenu3->HandleMenuMsg2(message, wParam, lParam, &retval))) { //TRACE(_T("HandleMenuMsg2(%x) failed with error: %lx\n"), message, hr); - //assert(0); + //assert(false); } return true; } diff --git a/Src/Common/ShellFileOperations.cpp b/Src/Common/ShellFileOperations.cpp index c2fa87ef7..75a916f3e 100644 --- a/Src/Common/ShellFileOperations.cpp +++ b/Src/Common/ShellFileOperations.cpp @@ -36,7 +36,7 @@ ShellFileOperations::ShellFileOperations() : m_bOneToOneMapping(false) , m_function(0) , m_flags(0) - , m_parentWindow(NULL) + , m_parentWindow(nullptr) , m_isCanceled(false) { } diff --git a/Src/Common/SuperComboBox.cpp b/Src/Common/SuperComboBox.cpp index 3503873f3..daa15bc01 100644 --- a/Src/Common/SuperComboBox.cpp +++ b/Src/Common/SuperComboBox.cpp @@ -19,7 +19,7 @@ HIMAGELIST CSuperComboBox::m_himlSystem = NULL; CSuperComboBox::CSuperComboBox() - : m_pDropHandler(NULL) + : m_pDropHandler(nullptr) { m_bEditChanged = false; m_bDoComplete = false; @@ -38,7 +38,7 @@ CSuperComboBox::CSuperComboBox() _AFX_THREAD_STATE* pState = AfxGetThreadState(); if (!pState->m_bNeedTerm) { - SCODE sc = ::OleInitialize(NULL); + SCODE sc = ::OleInitialize(nullptr); if (FAILED(sc)) AfxMessageBox(_T("OLE initialization failed. Make sure that the OLE libraries are the correct version")); else diff --git a/Src/Common/UniFile.cpp b/Src/Common/UniFile.cpp index c9bb52b8d..bea088116 100644 --- a/Src/Common/UniFile.cpp +++ b/Src/Common/UniFile.cpp @@ -178,10 +178,10 @@ void UniLocalFile::LastErrorCustom(const String& desc) ///////////// UniMemFile::UniMemFile() - : m_hMapping(NULL) - , m_base(NULL) - , m_data(NULL) - , m_current(NULL) + : m_hMapping(nullptr) + , m_base(nullptr) + , m_data(nullptr) + , m_current(nullptr) { } @@ -192,12 +192,12 @@ void UniMemFile::Close() { m_base = 0; } - m_data = NULL; - m_current = NULL; - if (m_hMapping != NULL) + m_data = nullptr; + m_current = nullptr; + if (m_hMapping != nullptr) { delete m_hMapping; - m_hMapping = NULL; + m_hMapping = nullptr; } } @@ -692,7 +692,7 @@ bool UniMemFile::ReadString(String & line, String & eol, bool * lossy) */ bool UniMemFile::WriteString(const String & line) { - assert(0); // unimplemented -- currently cannot write to a UniMemFile! + assert(false); // unimplemented -- currently cannot write to a UniMemFile! return false; } @@ -701,7 +701,7 @@ bool UniMemFile::WriteString(const String & line) ///////////// UniStdioFile::UniStdioFile() - : m_fp(0) + : m_fp(nullptr) , m_data(0) , m_ucrbuff(128) { @@ -884,13 +884,13 @@ void UniStdioFile::SetBom(bool bom) bool UniStdioFile::ReadString(String & line, bool * lossy) { - assert(0); // unimplemented -- currently cannot read from a UniStdioFile! + assert(false); // unimplemented -- currently cannot read from a UniStdioFile! return false; } bool UniStdioFile::ReadString(String & line, String & eol, bool * lossy) { - assert(0); // unimplemented -- currently cannot read from a UniStdioFile! + assert(false); // unimplemented -- currently cannot read from a UniStdioFile! return false; } diff --git a/Src/Common/VersionInfo.cpp b/Src/Common/VersionInfo.cpp index 350f23166..c840dffb3 100644 --- a/Src/Common/VersionInfo.cpp +++ b/Src/Common/VersionInfo.cpp @@ -382,7 +382,7 @@ void CVersionInfo::QueryStrings() */ void CVersionInfo::QueryValue(LPCTSTR szId, String& s) { - assert(m_pVffInfo != NULL); + assert(m_pVffInfo != nullptr); LPTSTR lpVersion; // String pointer to 'version' text UINT uVersionLen; bool bRetCode; diff --git a/Src/Common/multiformatText.h b/Src/Common/multiformatText.h index 38a8e4e7e..bb1725f8a 100644 --- a/Src/Common/multiformatText.h +++ b/Src/Common/multiformatText.h @@ -26,7 +26,7 @@ class storageForPlugins { public: storageForPlugins() - : m_bstr(NULL) + : m_bstr(nullptr) , m_bOriginalIsUnicode(false) , m_bCurrentIsUnicode(false) , m_bCurrentIsFile(false) diff --git a/Src/Common/scbarcf.cpp b/Src/Common/scbarcf.cpp index 1057b4e33..e7df95f81 100644 --- a/Src/Common/scbarcf.cpp +++ b/Src/Common/scbarcf.cpp @@ -52,7 +52,7 @@ CSizingControlBarCF::CSizingControlBarCF() m_bActive = false; CDC dc; - dc.CreateCompatibleDC(NULL); + dc.CreateCompatibleDC(nullptr); m_sFontFace = (::EnumFontFamilies(dc.m_hDC, _T("Tahoma"), (FONTENUMPROC) EnumFontFamProc, 0) == 0) ? diff --git a/Src/CompareStats.h b/Src/CompareStats.h index 89f2b62db..85747da98 100644 --- a/Src/CompareStats.h +++ b/Src/CompareStats.h @@ -104,7 +104,7 @@ private: int m_nDirs; /**< number of directories to compare */ struct ThreadState { - ThreadState() : m_nHitCount(0), m_pDiffItem(NULL) {} + ThreadState() : m_nHitCount(0), m_pDiffItem(nullptr) {} Poco::AtomicCounter m_nHitCount; const DIFFITEM *m_pDiffItem; }; diff --git a/Src/ConfigLog.cpp b/Src/ConfigLog.cpp index 80b8ecfb3..b7c3d2619 100644 --- a/Src/ConfigLog.cpp +++ b/Src/ConfigLog.cpp @@ -341,17 +341,17 @@ bool CConfigLog::DoFile(String &sError) FileWriteString(GetCompilerVersion()); LPCTSTR szCmdLine = ::GetCommandLine(); - assert(szCmdLine != NULL); + assert(szCmdLine != nullptr); // Skip the quoted executable file name. - if (szCmdLine != NULL) + if (szCmdLine != nullptr) { szCmdLine = _tcschr(szCmdLine, '"'); - if (szCmdLine != NULL) + if (szCmdLine != nullptr) { szCmdLine += 1; // skip the opening quote. szCmdLine = _tcschr(szCmdLine, '"'); - if (szCmdLine != NULL) + if (szCmdLine != nullptr) { szCmdLine += 1; // skip the closing quote. } diff --git a/Src/DiffContext.cpp b/Src/DiffContext.cpp index f1954b49d..8fa87831e 100644 --- a/Src/DiffContext.cpp +++ b/Src/DiffContext.cpp @@ -244,7 +244,7 @@ CompareOptions * CDiffContext::GetCompareOptions(int compareMethod) void CDiffContext::FetchPluginInfos(const String& filteredFilenames, PackingInfo ** infoUnpacker, PrediffingInfo ** infoPrediffer) { - assert(m_piPluginInfos); + assert(m_piPluginInfos != nullptr); m_piPluginInfos->FetchPluginInfos(filteredFilenames, infoUnpacker, infoPrediffer); } diff --git a/Src/DiffFileData.cpp b/Src/DiffFileData.cpp index 998f6982a..8a0e50fd5 100644 --- a/Src/DiffFileData.cpp +++ b/Src/DiffFileData.cpp @@ -102,7 +102,7 @@ bool DiffFileData::DoOpenFiles() /** @brief Clear inf structure to pristine */ void DiffFileData::Reset() { - assert(m_inf); + assert(m_inf != nullptr); // If diffutils put data in, have it cleanup if (m_used) { diff --git a/Src/DiffItem.h b/Src/DiffItem.h index 54037f986..e8ebc69bb 100644 --- a/Src/DiffItem.h +++ b/Src/DiffItem.h @@ -189,7 +189,7 @@ struct DIFFITEM : ListEntry static DIFFITEM emptyitem; /**< singleton to represent a diffitem that doesn't have any data */ - DIFFITEM() : parent(NULL), nidiffs(-1), nsdiffs(-1), customFlags1(0) { } + DIFFITEM() : parent(nullptr), nidiffs(-1), nsdiffs(-1), customFlags1(0) { } ~DIFFITEM(); bool isEmpty() const { return this == &emptyitem; } diff --git a/Src/DiffItemList.cpp b/Src/DiffItemList.cpp index c755cb1a4..38b3a1f8e 100644 --- a/Src/DiffItemList.cpp +++ b/Src/DiffItemList.cpp @@ -157,9 +157,9 @@ DIFFITEM &DiffItemList::GetNextSiblingDiffRefPosition(uintptr_t & diffpos) */ void DiffItemList::SetDiffStatusCode(uintptr_t diffpos, unsigned diffcode, unsigned mask) { - assert(diffpos); + assert(diffpos != NULL); DIFFITEM & di = GetDiffRefAt(diffpos); - assert(! ((~mask) & diffcode) ); // make sure they only set flags in their mask + assert( ((~mask) & diffcode) == 0 ); // make sure they only set flags in their mask di.diffcode.diffcode &= (~mask); // remove current data di.diffcode.diffcode |= diffcode; // add new data } @@ -169,7 +169,7 @@ void DiffItemList::SetDiffStatusCode(uintptr_t diffpos, unsigned diffcode, unsig */ void DiffItemList::SetDiffCounts(uintptr_t diffpos, unsigned diffs, unsigned ignored) { - assert(diffpos); + assert(diffpos != NULL); DIFFITEM & di = GetDiffRefAt(diffpos); di.nidiffs = ignored; // see StoreDiffResult() in DirScan.cpp di.nsdiffs = diffs; @@ -182,7 +182,7 @@ void DiffItemList::SetDiffCounts(uintptr_t diffpos, unsigned diffs, unsigned ign */ unsigned DiffItemList::GetCustomFlags1(uintptr_t diffpos) const { - assert(diffpos); + assert(diffpos != NULL); const DIFFITEM & di = GetDiffAt(diffpos); return di.customFlags1; } @@ -194,7 +194,7 @@ unsigned DiffItemList::GetCustomFlags1(uintptr_t diffpos) const */ void DiffItemList::SetCustomFlags1(uintptr_t diffpos, unsigned flag) { - assert(diffpos); + assert(diffpos != NULL); DIFFITEM & di = GetDiffRefAt(diffpos); di.customFlags1 = flag; } diff --git a/Src/DiffList.cpp b/Src/DiffList.cpp index 92c211826..ec86bf552 100644 --- a/Src/DiffList.cpp +++ b/Src/DiffList.cpp @@ -215,7 +215,7 @@ const DIFFRANGE * DiffList::DiffRangeAt(int nDiff) const } else { - assert(0); + assert(false); return NULL; } } diff --git a/Src/DiffThread.cpp b/Src/DiffThread.cpp index 63f587998..da6bc6d13 100644 --- a/Src/DiffThread.cpp +++ b/Src/DiffThread.cpp @@ -57,7 +57,7 @@ public: * @brief Default constructor. */ CDiffThread::CDiffThread() -: m_pDiffContext(NULL) +: m_pDiffContext(nullptr) , m_bAborting(false) , m_bPaused(false) , m_pDiffParm(new DiffFuncStruct) diff --git a/Src/DiffThread.h b/Src/DiffThread.h index 9f81a9dba..388292332 100644 --- a/Src/DiffThread.h +++ b/Src/DiffThread.h @@ -49,11 +49,11 @@ struct DiffFuncStruct Poco::Semaphore *pSemaphore; /**< Semaphore for synchronizing threads. */ DiffFuncStruct() - : context(NULL) + : context(nullptr) , nThreadState(0/*CDiffThread::THREAD_NOTSTARTED*/) - , m_pAbortgate(NULL) + , m_pAbortgate(nullptr) , bOnlyRequested(false) - , pSemaphore(NULL) + , pSemaphore(nullptr) {} }; diff --git a/Src/DiffViewBar.cpp b/Src/DiffViewBar.cpp index 1cfeaba61..857394a0a 100644 --- a/Src/DiffViewBar.cpp +++ b/Src/DiffViewBar.cpp @@ -20,7 +20,7 @@ IMPLEMENT_DYNAMIC(CDiffViewBar, TViewBarBase); ////////////////////////////////////////////////////////////////////// CDiffViewBar::CDiffViewBar() -: m_hwndFrame(NULL) +: m_hwndFrame(nullptr) { } diff --git a/Src/DiffWrapper.cpp b/Src/DiffWrapper.cpp index dd0177548..48e9b8f59 100644 --- a/Src/DiffWrapper.cpp +++ b/Src/DiffWrapper.cpp @@ -159,7 +159,7 @@ void CDiffWrapper::SetCreateDiffList(DiffList *diffList) */ void CDiffWrapper::GetOptions(DIFFOPTIONS *options) const { - assert(options); + assert(options != nullptr); DIFFOPTIONS tmpOptions = {0}; m_options.GetAsDiffOptions(tmpOptions); *options = tmpOptions; @@ -173,7 +173,7 @@ void CDiffWrapper::GetOptions(DIFFOPTIONS *options) const */ void CDiffWrapper::SetOptions(const DIFFOPTIONS *options) { - assert(options); + assert(options != nullptr); m_options.SetFromDiffOptions(*options); } @@ -204,7 +204,7 @@ void CDiffWrapper::GetPrediffer(PrediffingInfo * prediffer) const */ void CDiffWrapper::SetPatchOptions(const PATCHOPTIONS *options) { - assert(options); + assert(options != nullptr); m_options.m_contextLines = options->nContext; switch (options->outputStyle) @@ -1222,7 +1222,7 @@ CDiffWrapper::LoadWinMergeDiffsFromDiffUtilsScript(struct change * script, const { if (thisob->match0>=0) { - assert(thisob->inserted); + assert(thisob->inserted > 0); for (int i=0; iinserted; ++i) { int line0 = i+thisob->match0 + (trans_a0-first0-1); @@ -1232,7 +1232,7 @@ CDiffWrapper::LoadWinMergeDiffsFromDiffUtilsScript(struct change * script, const } if (thisob->match1>=0) { - assert(thisob->deleted); + assert(thisob->deleted > 0); for (int i=0; ideleted; ++i) { int line0 = i+thisob->line0 + (trans_a0-first0-1); @@ -1383,7 +1383,7 @@ CDiffWrapper::LoadWinMergeDiffsFromDiffUtilsScript3( { if (thisob->match0>=0) { - assert(thisob->inserted); + assert(thisob->inserted > 0); for (int i=0; iinserted; ++i) { int line0 = i+thisob->match0 + (trans_a0-first0-1); @@ -1393,7 +1393,7 @@ CDiffWrapper::LoadWinMergeDiffsFromDiffUtilsScript3( } if (thisob->match1>=0) { - assert(thisob->deleted); + assert(thisob->deleted > 0); for (int i=0; ideleted; ++i) { int line0 = i+thisob->line0 + (trans_a0-first0-1); diff --git a/Src/DirActions.cpp b/Src/DirActions.cpp index e80ca6b2d..c704f740c 100644 --- a/Src/DirActions.cpp +++ b/Src/DirActions.cpp @@ -1055,7 +1055,7 @@ void SetDiffStatus(DIFFITEM& di, unsigned diffcode, unsigned mask) // Someone could figure out these pieces and probably simplify this. // Update DIFFITEM code (comparison result) - assert(! ((~mask) & diffcode) ); // make sure they only set flags in their mask + assert( ((~mask) & diffcode) == 0 ); // make sure they only set flags in their mask di.diffcode.diffcode &= (~mask); // remove current data di.diffcode.diffcode |= diffcode; // add new data diff --git a/Src/DirCmpReport.cpp b/Src/DirCmpReport.cpp index 8ecee6444..5e3bfb313 100644 --- a/Src/DirCmpReport.cpp +++ b/Src/DirCmpReport.cpp @@ -61,12 +61,12 @@ static String EndEl(const String& elName) * @brief Constructor. */ DirCmpReport::DirCmpReport(const std::vector & colRegKeys) -: m_pList(NULL) -, m_pFile(NULL) +: m_pList(nullptr) +, m_pFile(nullptr) , m_nColumns(0) , m_colRegKeys(colRegKeys) , m_sSeparator(_T(",")) -, m_pFileCmpReport(NULL) +, m_pFileCmpReport(nullptr) , m_bIncludeFileCmpReport(false) , m_bOutputUTF8(false) { @@ -144,8 +144,8 @@ static HGLOBAL ConvertToUTF16ForClipboard(HGLOBAL hMem, int codepage) */ bool DirCmpReport::GenerateReport(String &errStr) { - assert(m_pList != NULL); - assert(m_pFile == NULL); + assert(m_pList != nullptr); + assert(m_pFile == nullptr); bool bRet = false; DirCmpReportDlg dlg; diff --git a/Src/DirCompProgressBar.cpp b/Src/DirCompProgressBar.cpp index 387fbff99..a5c2ab32b 100644 --- a/Src/DirCompProgressBar.cpp +++ b/Src/DirCompProgressBar.cpp @@ -39,9 +39,9 @@ void DirCompProgressBar::ClearStat() DirCompProgressBar::DirCompProgressBar() : m_bCompareReady(false) , m_prevState(CompareStats::STATE_IDLE) -, m_pCompareStats(NULL) +, m_pCompareStats(nullptr) #ifdef __ITaskbarList3_INTERFACE_DEFINED__ -, m_pTaskbarList(NULL) +, m_pTaskbarList(nullptr) #endif { } diff --git a/Src/DirDoc.cpp b/Src/DirDoc.cpp index 101a6fc2e..f82e266cf 100644 --- a/Src/DirDoc.cpp +++ b/Src/DirDoc.cpp @@ -357,7 +357,7 @@ void CDirDoc::UpdateResources() if (m_pDirView) m_pDirView->UpdateResources(); - SetTitle(NULL); + SetTitle(nullptr); Redisplay(); } @@ -683,7 +683,7 @@ void CDirDoc::Swap(int idx1, int idx2) m_pCompareStats->Swap(idx1, idx2); for (int nIndex = 0; nIndex < m_nDirs; nIndex++) UpdateHeaderPath(nIndex); - SetTitle(NULL); + SetTitle(nullptr); } bool CDirDoc::MoveableToNextDiff() diff --git a/Src/DirFrame.cpp b/Src/DirFrame.cpp index 41467b3cd..3118bdc31 100644 --- a/Src/DirFrame.cpp +++ b/Src/DirFrame.cpp @@ -78,8 +78,8 @@ static UINT RO_PANEL_WIDTH = 30; IMPLEMENT_DYNCREATE(CDirFrame, CMDIChildWnd) CDirFrame::CDirFrame() -: m_hIdentical(NULL) -, m_hDifferent(NULL) +: m_hIdentical(nullptr) +, m_hDifferent(nullptr) { } diff --git a/Src/DirViewColItems.cpp b/Src/DirViewColItems.cpp index 67a082d05..051ea9a31 100644 --- a/Src/DirViewColItems.cpp +++ b/Src/DirViewColItems.cpp @@ -1081,8 +1081,8 @@ DirViewColItems::GetDirColInfo(int col) const { if (col < 0 || col >= countof(f_cols)) { - assert(0); // fix caller, should not ask for nonexistent columns - return 0; + assert(false); // fix caller, should not ask for nonexistent columns + return nullptr; } return &f_cols[col]; } @@ -1090,8 +1090,8 @@ DirViewColItems::GetDirColInfo(int col) const { if (col < 0 || col >= countof(f_cols3)) { - assert(0); // fix caller, should not ask for nonexistent columns - return 0; + assert(false); // fix caller, should not ask for nonexistent columns + return nullptr; } return &f_cols3[col]; } @@ -1108,7 +1108,7 @@ DirViewColItems::IsColById(int col, const char *idname) const { if (col < 0 || col >= countof(f_cols)) { - assert(0); // fix caller, should not ask for nonexistent columns + assert(false); // fix caller, should not ask for nonexistent columns return false; } return f_cols[col].idName == idname; @@ -1117,7 +1117,7 @@ DirViewColItems::IsColById(int col, const char *idname) const { if (col < 0 || col >= sizeof(f_cols3)/sizeof(f_cols3[0])) { - assert(0); // fix caller, should not ask for nonexistent columns + assert(false); // fix caller, should not ask for nonexistent columns return false; } return f_cols3[col].idName == idname; @@ -1182,8 +1182,8 @@ DirViewColItems::IsDefaultSortAscending(int col) const const DirColInfo * pColInfo = GetDirColInfo(col); if (!pColInfo) { - assert(0); // fix caller, should not ask for nonexistent columns - return 0; + assert(false); // fix caller, should not ask for nonexistent columns + return false; } return pColInfo->defSortUp; } @@ -1237,7 +1237,7 @@ DirViewColItems::ColGetTextToDisplay(const CDiffContext *pCtxt, int col, const DirColInfo * pColInfo = GetDirColInfo(col); if (!pColInfo) { - assert(0); // fix caller, should not ask for nonexistent columns + assert(false); // fix caller, should not ask for nonexistent columns return _T("???"); } ColGetFncPtrType fnc = pColInfo->getfnc; @@ -1316,7 +1316,7 @@ DirViewColItems::ColSort(const CDiffContext *pCtxt, int col, const DIFFITEM & ld const DirColInfo * pColInfo = GetDirColInfo(col); if (!pColInfo) { - assert(0); // fix caller, should not ask for nonexistent columns + assert(false); // fix caller, should not ask for nonexistent columns return 0; } size_t offset = pColInfo->offset; diff --git a/Src/FileActionScript.cpp b/Src/FileActionScript.cpp index 3d4827183..bc55839c3 100644 --- a/Src/FileActionScript.cpp +++ b/Src/FileActionScript.cpp @@ -41,7 +41,7 @@ FileActionScript::FileActionScript() , m_bHasMoveOperations(false) , m_bHasRenameOperations(false) , m_bHasDelOperations(false) -, m_hParentWindow(NULL) +, m_hParentWindow(nullptr) , m_pCopyOperations(new ShellFileOperations()) , m_pMoveOperations(new ShellFileOperations()) , m_pRenameOperations(new ShellFileOperations()) diff --git a/Src/FileTransform.h b/Src/FileTransform.h index 186dcdda9..942eb1f2f 100644 --- a/Src/FileTransform.h +++ b/Src/FileTransform.h @@ -101,7 +101,7 @@ public: explicit PackingInfo(PLUGIN_MODE bMode = (PLUGIN_MODE)FileTransform::g_bUnpackerMode) : PluginForFile(bMode) , subcode(0) - , pufile(0) + , pufile(nullptr) , disallowMixedEOL(false) { } diff --git a/Src/FilterList.cpp b/Src/FilterList.cpp index 7e42f0eba..bcd5f325b 100644 --- a/Src/FilterList.cpp +++ b/Src/FilterList.cpp @@ -15,7 +15,7 @@ using Poco::RegularExpression; * @brief Constructor. */ FilterList::FilterList() -: m_lastMatchExpression(NULL) +: m_lastMatchExpression(nullptr) { } diff --git a/Src/GhostTextView.cpp b/Src/GhostTextView.cpp index 58c9a1756..b50983ffa 100644 --- a/Src/GhostTextView.cpp +++ b/Src/GhostTextView.cpp @@ -40,7 +40,7 @@ IMPLEMENT_DYNCREATE (CGhostTextView, CCrystalEditViewEx) * @brief Constructor, initializes members. */ CGhostTextView::CGhostTextView() -: m_pGhostTextBuffer(NULL) +: m_pGhostTextBuffer(nullptr) , m_nTopSubLinePushed(0) { } diff --git a/Src/HexMergeDoc.cpp b/Src/HexMergeDoc.cpp index 12a0b8e16..e9f461c50 100644 --- a/Src/HexMergeDoc.cpp +++ b/Src/HexMergeDoc.cpp @@ -123,11 +123,11 @@ END_MESSAGE_MAP() * @brief Constructor. */ CHexMergeDoc::CHexMergeDoc() -: m_pDirDoc(NULL) +: m_pDirDoc(nullptr) { m_nBuffers = m_nBuffersTemp; m_filePaths.SetSize(m_nBuffers); - std::fill_n(m_pView, m_nBuffers, static_cast(NULL)); + std::fill_n(m_pView, m_nBuffers, static_cast(nullptr)); std::fill_n(m_nBufferType, m_nBuffers, BUFFER_NORMAL); } @@ -574,7 +574,7 @@ void CHexMergeDoc::UpdateHeaderPath(int pane) sText.insert(0, _T("* ")); pf->GetHeaderInterface()->SetText(pane, sText); - SetTitle(NULL); + SetTitle(nullptr); } diff --git a/Src/HexMergeFrm.cpp b/Src/HexMergeFrm.cpp index 5130de9ad..772f5ffa2 100644 --- a/Src/HexMergeFrm.cpp +++ b/Src/HexMergeFrm.cpp @@ -74,8 +74,8 @@ enum // CHexMergeFrame construction/destruction CHexMergeFrame::CHexMergeFrame() -: m_hIdentical(NULL) -, m_hDifferent(NULL) +: m_hIdentical(nullptr) +, m_hDifferent(nullptr) { std::fill_n(m_nLastSplitPos, 2, 0); m_pMergeDoc = 0; diff --git a/Src/HexMergeView.cpp b/Src/HexMergeView.cpp index 82c6a84c1..307821d23 100644 --- a/Src/HexMergeView.cpp +++ b/Src/HexMergeView.cpp @@ -103,7 +103,7 @@ END_MESSAGE_MAP() * @brief Constructor. */ CHexMergeView::CHexMergeView() -: m_pif(0) +: m_pif(nullptr) , m_nThisPane(0) { } diff --git a/Src/IListCtrlImpl.h b/Src/IListCtrlImpl.h index 816e8a36f..4c003ffe3 100644 --- a/Src/IListCtrlImpl.h +++ b/Src/IListCtrlImpl.h @@ -112,7 +112,7 @@ public: std::string ret; if (ImageList_GetImageInfo(hImageList, iconIndex, &imageInfo)) { - HDC hdcMem = CreateCompatibleDC(NULL); + HDC hdcMem = CreateCompatibleDC(nullptr); BITMAPINFO bmpinfo = { 0 }; bmpinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); int w = imageInfo.rcImage.right - imageInfo.rcImage.left; diff --git a/Src/ImgMergeFrm.cpp b/Src/ImgMergeFrm.cpp index 37b382bd8..95ad38953 100644 --- a/Src/ImgMergeFrm.cpp +++ b/Src/ImgMergeFrm.cpp @@ -156,12 +156,12 @@ CMenu CImgMergeFrame::menu; // CImgMergeFrame construction/destruction CImgMergeFrame::CImgMergeFrame() -: m_hIdentical(NULL) -, m_hDifferent(NULL) -, m_pDirDoc(NULL) +: m_hIdentical(nullptr) +, m_hDifferent(nullptr) +, m_pDirDoc(nullptr) , m_bAutoMerged(false) -, m_pImgMergeWindow(NULL) -, m_pImgToolWindow(NULL) +, m_pImgMergeWindow(nullptr) +, m_pImgToolWindow(nullptr) { std::fill_n(m_nLastSplitPos, 2, 0); std::fill_n(m_nBufferType, 3, BUFFER_NORMAL); @@ -209,7 +209,7 @@ bool CImgMergeFrame::OpenDocs(int nFiles, const FileLocation fileloc[], const bo m_strDesc[pane] = strDesc ? strDesc[pane] : _T(""); m_nBufferType[pane] = (!strDesc || strDesc[pane].empty()) ? BUFFER_NORMAL : BUFFER_NORMAL_NAMED; } - SetTitle(NULL); + SetTitle(nullptr); LPCTSTR lpszWndClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW, LoadCursor(NULL, IDC_ARROW), (HBRUSH)(COLOR_WINDOW+1), NULL); diff --git a/Src/LineFiltersDlg.cpp b/Src/LineFiltersDlg.cpp index a4c913cf1..1d2ff8273 100644 --- a/Src/LineFiltersDlg.cpp +++ b/Src/LineFiltersDlg.cpp @@ -26,7 +26,7 @@ IMPLEMENT_DYNAMIC(LineFiltersDlg, CTrPropertyPage) */ LineFiltersDlg::LineFiltersDlg() : CTrPropertyPage(LineFiltersDlg::IDD) -, m_pList(NULL) +, m_pList(nullptr) { //{{AFX_DATA_INIT(LineFiltersDlg) m_bIgnoreRegExp = FALSE; diff --git a/Src/LineFiltersList.cpp b/Src/LineFiltersList.cpp index b0dda5c4e..4354c4074 100644 --- a/Src/LineFiltersList.cpp +++ b/Src/LineFiltersList.cpp @@ -19,7 +19,7 @@ static const TCHAR FiltersRegPath[] =_T("LineFilters"); * @brief Default constructor. */ LineFiltersList::LineFiltersList() -: m_pOptionsMgr(NULL) +: m_pOptionsMgr(nullptr) { } @@ -147,7 +147,7 @@ bool LineFiltersList::Compare(const LineFiltersList *list) const */ void LineFiltersList::Initialize(COptionsMgr *pOptionsMgr) { - assert(pOptionsMgr); + assert(pOptionsMgr != nullptr); String valuename(FiltersRegPath); m_pOptionsMgr = pOptionsMgr; @@ -177,7 +177,7 @@ void LineFiltersList::Initialize(COptionsMgr *pOptionsMgr) */ void LineFiltersList::SaveFilters() { - assert(m_pOptionsMgr); + assert(m_pOptionsMgr != nullptr); String valuename(FiltersRegPath); size_t count = m_items.size(); diff --git a/Src/LocationBar.cpp b/Src/LocationBar.cpp index 1eae2292e..0950e25b5 100644 --- a/Src/LocationBar.cpp +++ b/Src/LocationBar.cpp @@ -19,7 +19,7 @@ IMPLEMENT_DYNAMIC(CLocationBar, TViewBarBase); ////////////////////////////////////////////////////////////////////// CLocationBar::CLocationBar() -: m_hwndFrame(NULL) +: m_hwndFrame(nullptr) { } diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index f9df628ae..31430bcc0 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -269,7 +269,7 @@ static CPtrList &GetDocList(CMultiDocTemplate *pTemplate) */ CMainFrame::CMainFrame() : m_bFirstTime(true) -, m_pDropHandler(NULL) +, m_pDropHandler(nullptr) , m_bShowErrors(false) { } diff --git a/Src/Merge.cpp b/Src/Merge.cpp index 60c5814ae..1631ffcce 100644 --- a/Src/Merge.cpp +++ b/Src/Merge.cpp @@ -106,11 +106,11 @@ END_MESSAGE_MAP() CMergeApp::CMergeApp() : m_bNeedIdleTimer(false) -, m_pOpenTemplate(0) -, m_pDiffTemplate(0) -, m_pHexMergeTemplate(0) -, m_pDirTemplate(0) -, m_mainThreadScripts(NULL) +, m_pOpenTemplate(nullptr) +, m_pDiffTemplate(nullptr) +, m_pHexMergeTemplate(nullptr) +, m_pDirTemplate(nullptr) +, m_mainThreadScripts(nullptr) , m_nLastCompareResult(0) , m_bNonInteractive(false) , m_pOptions(new CRegOptionsMgr()) @@ -715,7 +715,7 @@ void CMergeApp::UpdateDefaultCodepage(int cpDefaultMode, int cpCustomCodepage) break; default: // no other valid option - assert (0); + assert (false); ucr::setDefaultCodepage(GetACP()); } } diff --git a/Src/Merge7zFormatMergePluginImpl.h b/Src/Merge7zFormatMergePluginImpl.h index f7964e24a..1680ca5e8 100644 --- a/Src/Merge7zFormatMergePluginImpl.h +++ b/Src/Merge7zFormatMergePluginImpl.h @@ -21,7 +21,7 @@ class PluginInfo; struct Merge7zFormatMergePluginImpl : public Merge7z::Format { - Merge7zFormatMergePluginImpl() : m_plugin(NULL) {} + Merge7zFormatMergePluginImpl() : m_plugin(nullptr) {} virtual HRESULT DeCompressArchive(HWND, LPCTSTR path, LPCTSTR folder); virtual HRESULT CompressArchive(HWND, LPCTSTR path, Merge7z::DirItemEnumerator *); virtual Inspector *Open(HWND, LPCTSTR); diff --git a/Src/MergeDoc.cpp b/Src/MergeDoc.cpp index b4feb45bf..010e73ee5 100644 --- a/Src/MergeDoc.cpp +++ b/Src/MergeDoc.cpp @@ -129,7 +129,7 @@ END_MESSAGE_MAP() CMergeDoc::CMergeDoc() : m_bEnableRescan(true) , m_nCurDiff(-1) -, m_pDirDoc(NULL) +, m_pDirDoc(nullptr) , m_bMixedEol(false) , m_pInfoUnpacker(new PackingInfo) , m_pEncodingErrorBar(nullptr) diff --git a/Src/MergeEditView.cpp b/Src/MergeEditView.cpp index 6b87a6da7..215427bf2 100644 --- a/Src/MergeEditView.cpp +++ b/Src/MergeEditView.cpp @@ -69,7 +69,7 @@ CMergeEditView::CMergeEditView() , m_nThisPane(0) , m_nThisGroup(0) , m_bDetailView(false) -, m_piMergeEditStatus(0) +, m_piMergeEditStatus(nullptr) , m_bAutomaticRescan(false) , fTimerWaitingForIdle(0) , m_lineBegin(0) diff --git a/Src/OptionsFont.cpp b/Src/OptionsFont.cpp index 8277c643e..ea8a4b402 100644 --- a/Src/OptionsFont.cpp +++ b/Src/OptionsFont.cpp @@ -40,7 +40,7 @@ void InitializeLogFont(LOGFONT &logfont, int lfHeight, int lfCharSet, int lfPitc */ void SetDefaults(COptionsMgr *pOptionsMgr) { - HDC hDC = GetDC(NULL); + HDC hDC = GetDC(nullptr); const int logPixelsY = GetDeviceCaps(hDC, LOGPIXELSY); // ***** @@ -118,7 +118,7 @@ LOGFONT Load(const COptionsMgr *pOptionsMgr, const String& name) // Build a new LOGFONT with values from the 'actual' values of the in-memory Options::Font table. // The Registry is not accessed. LOGFONT lfnew = { 0 }; - HDC hDC = GetDC(NULL); + HDC hDC = GetDC(nullptr); lfnew.lfHeight = -MulDiv(pOptionsMgr->GetInt(name + OPT_FONT_POINTSIZE), GetDeviceCaps(hDC, LOGPIXELSY), 72); if (lfnew.lfHeight == 0) lfnew.lfHeight = pOptionsMgr->GetInt(name + OPT_FONT_HEIGHT); @@ -144,7 +144,7 @@ void Save(COptionsMgr *pOptionsMgr, const String& name, const LOGFONT* lf, bool { // Store LOGFONT values into both the 'actual' value of the in-memory Options::Font table, and // into the appropriate Registry entries. - HDC hDC = GetDC(NULL); + HDC hDC = GetDC(nullptr); pOptionsMgr->SaveOption(name + OPT_FONT_USECUSTOM, bUseCustom); pOptionsMgr->SaveOption(name + OPT_FONT_POINTSIZE, -MulDiv(lf->lfHeight, 72, GetDeviceCaps(hDC, LOGPIXELSY))); pOptionsMgr->SaveOption(name + OPT_FONT_HEIGHT, lf->lfHeight); diff --git a/Src/PathContext.h b/Src/PathContext.h index 4571ebe5f..da4b6e198 100644 --- a/Src/PathContext.h +++ b/Src/PathContext.h @@ -83,7 +83,7 @@ public: m_sel = (pPathContext->GetSize() == 0) ? -1 : 0; } - PathContextIterator() : m_pPathContext(NULL), m_sel(-1) + PathContextIterator() : m_pPathContext(nullptr), m_sel(-1) { } diff --git a/Src/Plugins.cpp b/Src/Plugins.cpp index 49e6ad909..d19c6d0a3 100644 --- a/Src/Plugins.cpp +++ b/Src/Plugins.cpp @@ -888,7 +888,7 @@ CScriptsOfThread * CAllThreadsScripts::GetActiveSet() for (size_t i = 0 ; i < m_aAvailableThreads.size() ; i++) if (m_aAvailableThreads[i] && m_aAvailableThreads[i]->m_nThreadId == nThreadId) return m_aAvailableThreads[i]; - assert(0); + assert(false); return NULL; } CScriptsOfThread * CAllThreadsScripts::GetActiveSetNoAssert() @@ -946,8 +946,8 @@ CAssureScriptsForThread::~CAssureScriptsForThread() static void ShowPluginErrorMessage(IDispatch *piScript, LPTSTR description) { PluginInfo * pInfo = CAllThreadsScripts::GetActiveSet()->GetPluginInfo(piScript); - assert(pInfo != NULL); - assert(description != NULL); + assert(pInfo != nullptr); + assert(description != nullptr); AppErrorMessageBox(strutils::format(_T("%s: %s"), pInfo->m_name.c_str(), description)); } diff --git a/Src/PropRegistry.cpp b/Src/PropRegistry.cpp index 5394193e7..a72ed80a5 100644 --- a/Src/PropRegistry.cpp +++ b/Src/PropRegistry.cpp @@ -38,7 +38,7 @@ static LPCTSTR f_RegValuePath = _T("Executable"); PropRegistry::PropRegistry(COptionsMgr *optionsMgr) : OptionsPanel(optionsMgr, PropRegistry::IDD) -, m_bUseRecycleBin(TRUE) +, m_bUseRecycleBin(true) , m_tempFolderType(0) { } diff --git a/Src/markdown.cpp b/Src/markdown.cpp index 1ff515c1d..c3b0cee00 100644 --- a/Src/markdown.cpp +++ b/Src/markdown.cpp @@ -266,7 +266,7 @@ static const char htmlUTags[] = ); CMarkdown::CMarkdown(const char *upper, const char *ahead, unsigned flags): -first(0), lower(0), upper(upper), ahead(ahead), +first(nullptr), lower(nullptr), upper(upper), ahead(ahead), memcmp(flags & IgnoreCase ? ::_memicmp : ::memcmp), utags(flags & HtmlUTags ? htmlUTags : NULL) { @@ -756,7 +756,7 @@ int CMarkdown::FileImage::GuessByteOrder(unsigned dwBOM) } CMarkdown::FileImage::FileImage(const TCHAR *path, size_t trunc, unsigned flags) -: pImage(NULL), cbImage(0), nByteOrder(0), m_pSharedMemory(NULL), pCopy(NULL) +: pImage(nullptr), cbImage(0), nByteOrder(0), m_pSharedMemory(nullptr), pCopy(nullptr) { if (flags & Mapping) { -- 2.11.0