From e02170e29b532f6bba86fe149306f3af3f06ac54 Mon Sep 17 00:00:00 2001 From: GreyMerlin Date: Wed, 24 Oct 2018 17:07:58 -0700 Subject: [PATCH] Various refactorings involving NULL, ASSERT, TRUE and FALSE (4) More of the same... --- .../crystaledit/editlib/ccrystaltextbuffer.cpp | 16 +++++----- Externals/crystaledit/editlib/ccrystaltextbuffer.h | 12 ++++---- Externals/crystaledit/editlib/ccrystaltextview.cpp | 36 +++++++++++----------- Externals/crystaledit/editlib/ccrystaltextview.h | 18 +++++------ .../crystaledit/editlib/crystaleditviewex.cpp | 6 ++-- Externals/crystaledit/editlib/crystaleditviewex.h | 6 ++-- Externals/crystaledit/editlib/crystalparser.h | 4 +-- Externals/crystaledit/editlib/registry.cpp | 6 ++-- Externals/crystaledit/editlib/registry.h | 2 +- Src/Common/Picture.cpp | 8 ++--- Src/Common/Picture.h | 4 +-- Src/Common/PreferencesDlg.cpp | 2 +- Src/Common/PreferencesDlg.h | 4 +-- Src/Common/PropertyPageHost.cpp | 2 +- Src/Common/PropertyPageHost.h | 4 +-- Src/Common/ShellContextMenu.h | 2 +- Src/Common/ShellFileOperations.cpp | 2 +- Src/Common/ShellFileOperations.h | 2 +- Src/Common/VersionInfo.cpp | 14 ++++----- Src/Common/VersionInfo.h | 6 ++-- Src/Common/memdc.h | 2 +- Src/Common/multiformatText.h | 2 +- Src/CompareStatisticsDlg.cpp | 2 +- Src/CompareStatisticsDlg.h | 2 +- Src/ConfirmFolderCopyDlg.cpp | 2 +- Src/ConfirmFolderCopyDlg.h | 2 +- Src/DiffList.cpp | 8 ++--- Src/DiffList.h | 2 +- Src/DiffTextBuffer.cpp | 2 +- Src/DiffTextBuffer.h | 2 +- Src/DiffViewBar.cpp | 6 ++-- Src/DiffViewBar.h | 2 +- Src/DirActions.h | 2 +- Src/DirCmpReportDlg.cpp | 2 +- Src/DirCmpReportDlg.h | 2 +- Src/DirColsDlg.cpp | 2 +- Src/DirColsDlg.h | 2 +- Src/DirDoc.h | 4 +-- Src/DirView.cpp | 12 ++++---- Src/DirView.h | 4 +-- Src/Environment.cpp | 2 +- Src/Environment.h | 2 +- Src/Exceptions.h | 4 +-- Src/FileOrFolderSelect.cpp | 28 ++++++++--------- Src/FileOrFolderSelect.h | 10 +++--- Src/FileTransform.cpp | 26 ++++++++-------- Src/FileTransform.h | 3 +- Src/GhostTextBuffer.cpp | 2 +- Src/GhostTextBuffer.h | 2 +- Src/GhostTextView.cpp | 12 ++++---- Src/GhostTextView.h | 4 +-- Src/IListCtrlImpl.h | 10 +++--- 52 files changed, 163 insertions(+), 162 deletions(-) diff --git a/Externals/crystaledit/editlib/ccrystaltextbuffer.cpp b/Externals/crystaledit/editlib/ccrystaltextbuffer.cpp index 30513c3b4..f239ae8d6 100644 --- a/Externals/crystaledit/editlib/ccrystaltextbuffer.cpp +++ b/Externals/crystaledit/editlib/ccrystaltextbuffer.cpp @@ -868,7 +868,7 @@ GetTextWithoutEmptys(int nStartLine, int nStartChar, void CCrystalTextBuffer:: GetText (int nStartLine, int nStartChar, int nEndLine, int nEndChar, - CString & text, LPCTSTR pszCRLF /*= NULL*/, bool bExcludeInvisibleLines/*= true*/) const + CString & text, LPCTSTR pszCRLF /*= nullptr*/, bool bExcludeInvisibleLines/*= true*/) const { ASSERT (m_bInit); // Text buffer not yet initialized. // You must call InitNew() or LoadFromFile() first! @@ -1258,7 +1258,7 @@ CanRedo () const } POSITION CCrystalTextBuffer:: -GetUndoActionCode (int & nAction, POSITION pos /*= NULL*/ ) const +GetUndoActionCode (int & nAction, POSITION pos /*= nullptr*/ ) const { ASSERT (CanUndo ()); // Please call CanUndo() first @@ -1295,7 +1295,7 @@ GetUndoActionCode (int & nAction, POSITION pos /*= NULL*/ ) const } POSITION CCrystalTextBuffer:: -GetRedoActionCode (int & nAction, POSITION pos /*= NULL*/ ) const +GetRedoActionCode (int & nAction, POSITION pos /*= nullptr*/ ) const { ASSERT (CanRedo ()); // Please call CanRedo() before! @@ -1303,7 +1303,7 @@ GetRedoActionCode (int & nAction, POSITION pos /*= NULL*/ ) const ASSERT ((m_aUndoBuf[m_nUndoPosition].m_dwFlags & UNDO_BEGINGROUP) != 0); intptr_t nPosition; - if (pos == NULL) + if (pos == nullptr) { // Start from beginning nPosition = m_nUndoPosition; @@ -1336,7 +1336,7 @@ GetRedoActionCode (int & nAction, POSITION pos /*= NULL*/ ) const } POSITION CCrystalTextBuffer:: -GetUndoDescription (CString & desc, POSITION pos /*= NULL*/ ) const +GetUndoDescription (CString & desc, POSITION pos /*= nullptr*/ ) const { int nAction; POSITION retValue = GetUndoActionCode(nAction, pos); @@ -1349,7 +1349,7 @@ GetUndoDescription (CString & desc, POSITION pos /*= NULL*/ ) const } POSITION CCrystalTextBuffer:: -GetRedoDescription (CString & desc, POSITION pos /*= NULL*/ ) const +GetRedoDescription (CString & desc, POSITION pos /*= nullptr*/ ) const { int nAction; POSITION retValue = GetRedoActionCode(nAction, pos); @@ -1491,8 +1491,8 @@ Redo (CCrystalTextView * pSource, CPoint & ptCursorPos) void CCrystalTextBuffer:: /* virtual base */ AddUndoRecord (bool bInsert, const CPoint & ptStartPos, - const CPoint & ptEndPos, LPCTSTR pszText, size_t cchText, int nActionType, - CDWordArray *paSavedRevisionNumbers) + const CPoint & ptEndPos, LPCTSTR pszText, size_t cchText, int nActionType /*= CE_ACTION_UNKNOWN*/, + CDWordArray *paSavedRevisionNumbers /*= nullptr*/) { // Forgot to call BeginUndoGroup()? ASSERT (m_bUndoGroup); diff --git a/Externals/crystaledit/editlib/ccrystaltextbuffer.h b/Externals/crystaledit/editlib/ccrystaltextbuffer.h index 65d732286..a99705729 100644 --- a/Externals/crystaledit/editlib/ccrystaltextbuffer.h +++ b/Externals/crystaledit/editlib/ccrystaltextbuffer.h @@ -179,7 +179,7 @@ public : // [JRT] Support For Descriptions On Undo/Redo Actions virtual void AddUndoRecord (bool bInsert, const CPoint & ptStartPos, const CPoint & ptEndPos, - LPCTSTR pszText, size_t cchText, int nActionType = CE_ACTION_UNKNOWN, CDWordArray *paSavedRevisionNumbers = NULL); + LPCTSTR pszText, size_t cchText, int nActionType = CE_ACTION_UNKNOWN, CDWordArray *paSavedRevisionNumbers = nullptr); virtual UndoRecord GetUndoRecord (int nUndoPos) const; virtual CDWordArray *CopyRevisionNumbers(int nStartLine, int nEndLine) const; @@ -231,7 +231,7 @@ public : void SetLineFlag (int nLine, DWORD dwFlag, bool bSet, bool bRemoveFromPreviousLine = true, bool bUpdate=true); void GetText (int nStartLine, int nStartChar, int nEndLine, int nEndChar, - CString & text, LPCTSTR pszCRLF = NULL, bool bExcludeInvisibleLines = true) const; + CString & text, LPCTSTR pszCRLF = nullptr, bool bExcludeInvisibleLines = true) const; virtual void GetTextWithoutEmptys (int nStartLine, int nStartChar, int nEndLine, int nEndChar, CString &text, CRLFSTYLE nCrlfStyle = CRLF_STYLE_AUTOMATIC, bool bExcludeInvisibleLines = true) const; @@ -275,10 +275,10 @@ public : // Browse undo sequence - POSITION GetUndoActionCode (int & nAction, POSITION pos = NULL) const; - POSITION GetRedoActionCode (int & nAction, POSITION pos = NULL) const; - POSITION GetUndoDescription (CString & desc, POSITION pos = NULL) const; - POSITION GetRedoDescription (CString & desc, POSITION pos = NULL) const; + POSITION GetUndoActionCode (int & nAction, POSITION pos = nullptr) const; + POSITION GetRedoActionCode (int & nAction, POSITION pos = nullptr) const; + POSITION GetUndoDescription (CString & desc, POSITION pos = nullptr) const; + POSITION GetRedoDescription (CString & desc, POSITION pos = nullptr) const; // Notify all connected views about changes in name of file CCrystalTextView::TextDefinition *RetypeViews (LPCTSTR lpszFileName); diff --git a/Externals/crystaledit/editlib/ccrystaltextview.cpp b/Externals/crystaledit/editlib/ccrystaltextview.cpp index 20b94c8c3..0a131ba45 100644 --- a/Externals/crystaledit/editlib/ccrystaltextview.cpp +++ b/Externals/crystaledit/editlib/ccrystaltextview.cpp @@ -2900,11 +2900,11 @@ OnInitialUpdate () // CCrystalTextView printing void CCrystalTextView:: -OnPrepareDC (CDC * pDC, CPrintInfo * pInfo) +OnPrepareDC (CDC * pDC, CPrintInfo * pInfo /*= nullptr*/) { CView::OnPrepareDC (pDC, pInfo); - if (pInfo != NULL) + if (pInfo != nullptr) { pInfo->m_bContinuePrinting = true; if (m_nPrintPages != 0 && (int) pInfo->m_nCurPage > m_nPrintPages) @@ -3297,8 +3297,8 @@ GetViewableLineLength (int nLineIndex) const LPCTSTR CCrystalTextView:: GetLineChars (int nLineIndex) const { - if (m_pTextBuffer == NULL) - return NULL; + if (m_pTextBuffer == nullptr) + return nullptr; return m_pTextBuffer->GetLineChars (nLineIndex); } @@ -3309,24 +3309,24 @@ GetLineChars (int nLineIndex) const * no need to reset the editor options (m_bOvrMode, m_bLastReplace) */ void CCrystalTextView:: -ReAttachToBuffer (CCrystalTextBuffer * pBuf /*= NULL*/ ) +ReAttachToBuffer (CCrystalTextBuffer * pBuf /*= nullptr*/ ) { - if (m_pTextBuffer != NULL) + if (m_pTextBuffer != nullptr) m_pTextBuffer->RemoveView (this); - if (pBuf == NULL) + if (pBuf == nullptr) { pBuf = LocateTextBuffer (); // ... } m_pTextBuffer = pBuf; - if (m_pTextBuffer != NULL) + if (m_pTextBuffer != nullptr) m_pTextBuffer->AddView (this); // don't reset CCrystalEditView options CCrystalTextView::ResetView (); // Init scrollbars arrows CScrollBar *pVertScrollBarCtrl = GetScrollBarCtrl (SB_VERT); - if (pVertScrollBarCtrl != NULL) + if (pVertScrollBarCtrl != nullptr) pVertScrollBarCtrl->EnableScrollBar (GetScreenLines () >= GetLineCount ()? ESB_DISABLE_BOTH : ESB_ENABLE_BOTH); // Update vertical scrollbar only @@ -3338,27 +3338,27 @@ ReAttachToBuffer (CCrystalTextBuffer * pBuf /*= NULL*/ ) * initialize the view and initialize both scrollbars */ void CCrystalTextView:: -AttachToBuffer (CCrystalTextBuffer * pBuf /*= NULL*/ ) +AttachToBuffer (CCrystalTextBuffer * pBuf /*= nullptr*/ ) { - if (m_pTextBuffer != NULL) + if (m_pTextBuffer != nullptr) m_pTextBuffer->RemoveView (this); - if (pBuf == NULL) + if (pBuf == nullptr) { pBuf = LocateTextBuffer (); // ... } m_pTextBuffer = pBuf; - if (m_pTextBuffer != NULL) + if (m_pTextBuffer != nullptr) m_pTextBuffer->AddView (this); ResetView (); // Init scrollbars CScrollBar *pVertScrollBarCtrl = GetScrollBarCtrl (SB_VERT); - if (pVertScrollBarCtrl != NULL) + if (pVertScrollBarCtrl != nullptr) pVertScrollBarCtrl->EnableScrollBar (GetScreenLines () >= GetLineCount ()? ESB_DISABLE_BOTH : ESB_ENABLE_BOTH); CScrollBar *pHorzScrollBarCtrl = GetScrollBarCtrl (SB_HORZ); - if (pHorzScrollBarCtrl != NULL) + if (pHorzScrollBarCtrl != nullptr) pHorzScrollBarCtrl->EnableScrollBar (GetScreenChars () >= GetMaxLineLength (m_nTopLine, GetScreenLines())? ESB_DISABLE_BOTH : ESB_ENABLE_BOTH); @@ -5582,7 +5582,7 @@ GetViewLineNumbers () const * @return Margin area width in pixels. */ int CCrystalTextView:: -GetMarginWidth (CDC *pdc) +GetMarginWidth (CDC *pdc /*= nullptr*/) { int nMarginWidth = 0; @@ -5600,12 +5600,12 @@ GetMarginWidth (CDC *pdc) if (m_bSelMargin) { - if (pdc == NULL || !pdc->IsPrinting ()) + if (pdc == nullptr || !pdc->IsPrinting ()) nMarginWidth += MARGIN_ICON_WIDTH + 7; // Width for icon markers and some margin } else { - if (pdc == NULL || !pdc->IsPrinting ()) + if (pdc == nullptr || !pdc->IsPrinting ()) nMarginWidth += MARGIN_REV_WIDTH; // Space for revision marks } diff --git a/Externals/crystaledit/editlib/ccrystaltextview.h b/Externals/crystaledit/editlib/ccrystaltextview.h index 8c0981ef4..25bfeb64d 100644 --- a/Externals/crystaledit/editlib/ccrystaltextview.h +++ b/Externals/crystaledit/editlib/ccrystaltextview.h @@ -227,7 +227,7 @@ protected : CPoint m_ptDraggedTextBegin, m_ptDraggedTextEnd; void UpdateCaret (); void SetAnchor (const CPoint & ptNewAnchor); - int GetMarginWidth (CDC *pdc = NULL); + int GetMarginWidth (CDC *pdc = nullptr); bool IsValidTextPos (const CPoint &point); bool IsValidTextPosX (const CPoint &point); bool IsValidTextPosY (const CPoint &point); @@ -522,7 +522,7 @@ protected: not exceed (except whitespaces) @param anBreaks An array of integers. Put the positions where to wrap the line - in that array (its allready allocated). If this pointer is NULL, the function + in that array (its allready allocated). If this pointer is `nullptr`, the function has only to compute the number of breaks (the parameter nBreaks). @param nBreaks The number of breaks this line has (number of sublines - 1). When @@ -540,7 +540,7 @@ protected: method). This function uses an internal cache which contains the number of sublines for each line, so it has only to call WrapLine(), if the cache for the given line is invalid or if the caller wants to get the - wrap postions (anBreaks != NULL). + wrap postions (anBreaks != nullptr). This functions also tests m_bWordWrap -- you can call it even if word wrapping is disabled and you will retrieve a valid value. @@ -551,7 +551,7 @@ protected: not exceed (except whitespaces) @param anBreaks An array of integers. Put the positions where to wrap the line - in that array (its allready allocated). If this pointer is NULL, the function + in that array (its allready allocated). If this pointer is `nullptr`, the function has only to compute the number of breaks (the parameter nBreaks). @param nBreaks The number of breaks this line has (number of sublines - 1). When @@ -730,9 +730,9 @@ public : /** Sets the Parser to use to parse the file. - @param pParser Pointer to parser to use. Set to NULL to use no parser. + @param pParser Pointer to parser to use. Set to `nullptr` to use no parser. - @return Pointer to parser used before or NULL, if no parser has been used before. + @return Pointer to parser used before or `nullptr`, if no parser has been used before. */ CCrystalParser *SetParser( CCrystalParser *pParser ); //END SW @@ -836,8 +836,8 @@ public : // Operations public : - virtual void ReAttachToBuffer (CCrystalTextBuffer * pBuf = NULL); - virtual void AttachToBuffer (CCrystalTextBuffer * pBuf = NULL); + virtual void ReAttachToBuffer (CCrystalTextBuffer * pBuf = nullptr); + virtual void AttachToBuffer (CCrystalTextBuffer * pBuf = nullptr); virtual void DetachFromBuffer (); // Buffer-view interaction, multiple views @@ -879,7 +879,7 @@ public : virtual BOOL PreCreateWindow (CREATESTRUCT & cs); virtual BOOL PreTranslateMessage (MSG * pMsg); - virtual void OnPrepareDC (CDC * pDC, CPrintInfo * pInfo = NULL); + virtual void OnPrepareDC (CDC * pDC, CPrintInfo * pInfo = nullptr); virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO *pHandlerInfo); protected : virtual void OnInitialUpdate (); // called first time after construct diff --git a/Externals/crystaledit/editlib/crystaleditviewex.cpp b/Externals/crystaledit/editlib/crystaleditviewex.cpp index 1d5085ed1..45f75157c 100644 --- a/Externals/crystaledit/editlib/crystaleditviewex.cpp +++ b/Externals/crystaledit/editlib/crystaleditviewex.cpp @@ -16,7 +16,7 @@ IMPLEMENT_DYNCREATE(CCrystalEditViewEx,CCrystalEditView) CCrystalEditViewEx::CCrystalEditViewEx() : CCrystalEditView() { - m_pSyntaxParser = NULL; + m_pSyntaxParser = nullptr; } @@ -34,7 +34,7 @@ HINSTANCE CCrystalEditViewEx::GetResourceHandle() DWORD CCrystalEditViewEx::ParseLine( DWORD dwCookie, int nLineIndex, TEXTBLOCK *pBuf, int &nActualItems ) { - if( m_pSyntaxParser ) + if( m_pSyntaxParser != nullptr ) { CCrystalTextBlock *pTextBlock = pBuf? new CCrystalTextBlock( (CCrystalTextBlock::TEXTBLOCK*)pBuf, nActualItems ) : NULL; @@ -56,7 +56,7 @@ CCrystalParser *CCrystalEditViewEx::SetSyntaxParser( CCrystalParser *pParser ) m_pSyntaxParser = pParser; - if( pParser ) + if( pParser != nullptr ) //BEGIN FP pParser->m_pTextView = this; /*ORIGINAL diff --git a/Externals/crystaledit/editlib/crystaleditviewex.h b/Externals/crystaledit/editlib/crystaleditviewex.h index 1e335ccf0..c0eb8c002 100644 --- a/Externals/crystaledit/editlib/crystaleditviewex.h +++ b/Externals/crystaledit/editlib/crystaleditviewex.h @@ -30,7 +30,7 @@ public: @return The syntax parser that was used until the call to this function or - NULL if no one was attached to this view. + `nullptr` if no one was attached to this view. */ CCrystalParser *SetSyntaxParser( CCrystalParser *pParser ); @@ -66,7 +66,7 @@ protected: color. You have to specifie each one of this blocks in this Buffer. You can define a new Block with the macro DEFINE_BLOCK( pos, colorindex ). - When the function ist called with this parameter set zu NULL, you only + When the function is called with this parameter set to `nullptr`, you only have to calculate the cookies. @param nActualItems Used by the macro DEFINE_BLOCK. @@ -81,7 +81,7 @@ protected: protected: /** @description - The parser used to parse the Text or NULL if no parser is used. + The parser used to parse the Text or `nullptr` if no parser is used. */ CCrystalParser *m_pSyntaxParser; }; diff --git a/Externals/crystaledit/editlib/crystalparser.h b/Externals/crystaledit/editlib/crystalparser.h index 7d1635fa6..ae2b5e574 100644 --- a/Externals/crystaledit/editlib/crystalparser.h +++ b/Externals/crystaledit/editlib/crystalparser.h @@ -60,7 +60,7 @@ public: this block array, using CTextBlock::Add(). You do not have to care about the sort to add the elements. - When the function ist called with this parameter set zu NULL, you only + When the function is called with this parameter set to `nullptr`, you only have to calculate the cookies which can be (hoply) done much more faster. @return The calculated flags for this line (see dwCookie). @@ -83,7 +83,7 @@ public: not exceed @param anBreaks An array of integers. Put the positions where to wrap the line - in that array (its allready allocated). If this pointer is NULL, the function + in that array (its allready allocated). If this pointer is `nullptr`, the function has only to compute the number of breaks (the parameter nBreaks). @param nBreaks The number of breaks this line has (number of sublines - 1). When diff --git a/Externals/crystaledit/editlib/registry.cpp b/Externals/crystaledit/editlib/registry.cpp index 36f0c7bfc..83ed1480e 100644 --- a/Externals/crystaledit/editlib/registry.cpp +++ b/Externals/crystaledit/editlib/registry.cpp @@ -1176,7 +1176,7 @@ HKEY CReg::Connect (HKEY hNewKey, LPCTSTR pszRemote) } /* connect to registry key */ -HKEY CReg::Open (HKEY hNewKey /*= NULL*/) +HKEY CReg::Open (HKEY hNewKey /*= nullptr*/) { return hKey = hNewKey; } @@ -1190,12 +1190,12 @@ HKEY CReg::Open (HKEY hNewKey, LPCTSTR pszSubKey, DWORD dwRights) /* close computer registry */ void CReg::Close () { - if (hKey != NULL) // MAB 8 Nov 1999 - added NULL test + if (hKey != nullptr) // MAB 8 Nov 1999 - added NULL test { RegClose (hKey); //*** MIPO 07-12-1999 - After Closing the Key, hKey must by NULL **** // RegClose - dont do that - it must be done manualy - hKey = NULL; + hKey = nullptr; } } diff --git a/Externals/crystaledit/editlib/registry.h b/Externals/crystaledit/editlib/registry.h index 5873f4237..7aa14a0c8 100644 --- a/Externals/crystaledit/editlib/registry.h +++ b/Externals/crystaledit/editlib/registry.h @@ -261,7 +261,7 @@ struct EDITPADC_CLASS CReg HKEY Connect (HKEY hNewKey, LPCTSTR pszRemote); /* connect to registry key */ - HKEY Open (HKEY hNewKey = NULL); + HKEY Open (HKEY hNewKey = nullptr); /* open computer registry */ HKEY Open (HKEY hNewKey, LPCTSTR pszSubKey, DWORD dwRights); diff --git a/Src/Common/Picture.cpp b/Src/Common/Picture.cpp index 7ce38ae8f..1eb84b1c8 100644 --- a/Src/Common/Picture.cpp +++ b/Src/Common/Picture.cpp @@ -101,7 +101,7 @@ bool CPicture::Load(IStream* pstm) ////////////////// // Render to device context. Covert to HIMETRIC for IPicture. // -bool CPicture::Render(CDC* pDC, CRect rc, LPCRECT prcMFBounds) const +bool CPicture::Render(CDC* pDC, CRect rc /*= CRect(0,0,0,0)*/, LPCRECT prcMFBounds /*= nullptr*/) const { ASSERT(pDC != nullptr); @@ -121,16 +121,16 @@ bool CPicture::Render(CDC* pDC, CRect rc, LPCRECT prcMFBounds) const ////////////////// // Get image size in pixels. Converts from HIMETRIC to device coords. // -CSize CPicture::GetImageSize(CDC* pDC) const +CSize CPicture::GetImageSize(CDC* pDC /*= nullptr*/) const { - if (!m_spIPicture) + if (m_spIPicture == nullptr) return CSize(0,0); LONG hmWidth, hmHeight; // HIMETRIC units if (FAILED(m_spIPicture->get_Width(&hmWidth)) || FAILED(m_spIPicture->get_Height(&hmHeight))) return CSize(0, 0); CSize sz(hmWidth,hmHeight); - if (pDC==NULL) { + if (pDC==nullptr) { CWindowDC dc(nullptr); dc.HIMETRICtoDP(&sz); // convert to pixels } else { diff --git a/Src/Common/Picture.h b/Src/Common/Picture.h index 015d5cb32..9387a7051 100644 --- a/Src/Common/Picture.h +++ b/Src/Common/Picture.h @@ -25,9 +25,9 @@ public: // render to device context bool Render(CDC* pDC, CRect rc=CRect(0,0,0,0), - LPCRECT prcMFBounds=NULL) const; + LPCRECT prcMFBounds=nullptr) const; - CSize GetImageSize(CDC* pDC=NULL) const; + CSize GetImageSize(CDC* pDC=nullptr) const; operator IPicture*() { return m_spIPicture; diff --git a/Src/Common/PreferencesDlg.cpp b/Src/Common/PreferencesDlg.cpp index 88a7464b9..c8ef46122 100644 --- a/Src/Common/PreferencesDlg.cpp +++ b/Src/Common/PreferencesDlg.cpp @@ -35,7 +35,7 @@ static TCHAR OptionsHelpLocation[] = _T("::/htmlhelp/Configuration.html"); const TCHAR PATHDELIM = '>'; CPreferencesDlg::CPreferencesDlg(COptionsMgr *regOptions, SyntaxColors *colors, - UINT nMenuID, CWnd* pParent) // standard constructor + UINT nMenuID /*= 0*/, CWnd* pParent /*= nullptr*/) // standard constructor : CTrDialog(IDD_PREFERENCES, pParent) , m_pOptionsMgr(regOptions) , m_pageGeneral(regOptions) diff --git a/Src/Common/PreferencesDlg.h b/Src/Common/PreferencesDlg.h index b5b7d5d78..e6a571b05 100644 --- a/Src/Common/PreferencesDlg.h +++ b/Src/Common/PreferencesDlg.h @@ -38,9 +38,9 @@ class CPreferencesDlg : public CTrDialog { // Construction public: - //CPreferencesDlg(UINT nMenuID = 0, CWnd* pParent = NULL); // standard constructor + //CPreferencesDlg(UINT nMenuID = 0, CWnd* pParent = nullptr); // standard constructor CPreferencesDlg(COptionsMgr *optionsMgr, SyntaxColors *colors, - UINT nMenuID = 0, CWnd* pParent = NULL); // standard constructor + UINT nMenuID = 0, CWnd* pParent = nullptr); // standard constructor virtual ~CPreferencesDlg(); void SetSyntaxColors(SyntaxColors *pColors); diff --git a/Src/Common/PropertyPageHost.cpp b/Src/Common/PropertyPageHost.cpp index 82bdf2c76..4c3cd98bc 100644 --- a/Src/Common/PropertyPageHost.cpp +++ b/Src/Common/PropertyPageHost.cpp @@ -186,7 +186,7 @@ bool CPropertyPageHost::SetActivePage(CPropertyPage* pPage, bool bAndFocus /*= t return SetActivePage(FindPage(pPage)); } -bool CPropertyPageHost::AddPage(CPropertyPage* pPage, LPCTSTR szTitle, DWORD dwItemData) +bool CPropertyPageHost::AddPage(CPropertyPage* pPage, LPCTSTR szTitle /*= nullptr*/, DWORD dwItemData /*= 0*/) { if (!pPage || !pPage->IsKindOf(RUNTIME_CLASS(CPropertyPage))) return FALSE; diff --git a/Src/Common/PropertyPageHost.h b/Src/Common/PropertyPageHost.h index 23da41954..20c26eea6 100644 --- a/Src/Common/PropertyPageHost.h +++ b/Src/Common/PropertyPageHost.h @@ -16,7 +16,7 @@ struct PAGEITEM { - PAGEITEM(CPropertyPage* _pPage = NULL, LPCTSTR szTitle = NULL, DWORD dwData = 0) : + PAGEITEM(CPropertyPage* _pPage = nullptr, LPCTSTR szTitle = nullptr, DWORD dwData = 0) : pPage(_pPage), sTitle(szTitle), dwItemData(dwData) {} CPropertyPage* pPage; @@ -37,7 +37,7 @@ public: int GetActiveIndex(); CPropertyPage* GetActivePage(); - bool AddPage(CPropertyPage* pPage, LPCTSTR szTitle = NULL, DWORD dwItemData = 0); + bool AddPage(CPropertyPage* pPage, LPCTSTR szTitle = nullptr, DWORD dwItemData = 0); bool SetActivePage(int nIndex, bool bAndFocus = true); bool SetActivePage(CPropertyPage* pPage, bool bAndFocus = true); int GetPageCount() { return (int) m_aPages.GetSize(); } diff --git a/Src/Common/ShellContextMenu.h b/Src/Common/ShellContextMenu.h index 254963ab5..8f479fbbf 100644 --- a/Src/Common/ShellContextMenu.h +++ b/Src/Common/ShellContextMenu.h @@ -128,7 +128,7 @@ public: * Menu is created in constructor and does not normally change when requesting context menu via RequeryShellContextMenu() * It may though change if destroyed by someone. In this case it should be recreated in RequeryShellContextMenu() * - * @retval NULL If handle is destroyed by parent menu, but not yet recreated by RequeryShellContextMenu() + * @retval nullptr If handle is destroyed by parent menu, but not yet recreated by RequeryShellContextMenu() */ HMENU GetHMENU() const; diff --git a/Src/Common/ShellFileOperations.cpp b/Src/Common/ShellFileOperations.cpp index 29980fc3d..03da88b11 100644 --- a/Src/Common/ShellFileOperations.cpp +++ b/Src/Common/ShellFileOperations.cpp @@ -149,7 +149,7 @@ size_t ShellFileOperations::CountStringSize(bool source) const * @param [in] parentWindow Window getting notifications. */ void ShellFileOperations::SetOperation(UINT operation, FILEOP_FLAGS flags, - HWND parentWindow /*= NULL*/) + HWND parentWindow /*= nullptr*/) { m_function = operation; m_flags = flags; diff --git a/Src/Common/ShellFileOperations.h b/Src/Common/ShellFileOperations.h index ecc94ec04..78782c974 100644 --- a/Src/Common/ShellFileOperations.h +++ b/Src/Common/ShellFileOperations.h @@ -39,7 +39,7 @@ public: void AddSourceAndDestination(const String &source, const String &destination); void AddSource(const String &source); void SetDestination(const String &destination); - void SetOperation(UINT operation, FILEOP_FLAGS flags, HWND parentWindow = NULL); + void SetOperation(UINT operation, FILEOP_FLAGS flags, HWND parentWindow = nullptr); bool Run(); bool IsCanceled() const; void Reset(); diff --git a/Src/Common/VersionInfo.cpp b/Src/Common/VersionInfo.cpp index c840dffb3..f15e11e34 100644 --- a/Src/Common/VersionInfo.cpp +++ b/Src/Common/VersionInfo.cpp @@ -65,7 +65,7 @@ CVersionInfo::CVersionInfo(LPCTSTR szFileToVersion, , m_bVersionOnly(false) , m_bDllVersion(bDllVersion) { - if (szFileToVersion != NULL) + if (szFileToVersion != nullptr) m_strFileName = szFileToVersion; GetVersionInfo(); } @@ -76,18 +76,18 @@ CVersionInfo::CVersionInfo(LPCTSTR szFileToVersion, * @param [in] szLanguage Language for version. * @param [in] szCodePage Codepage for version. */ -CVersionInfo::CVersionInfo(LPCTSTR szFileToVersion /* = NULL*/, - LPCTSTR szLanguage /* = NULL*/, - LPCTSTR szCodepage /* = NULL*/) +CVersionInfo::CVersionInfo(LPCTSTR szFileToVersion /* = nullptr*/, + LPCTSTR szLanguage /* = nullptr*/, + LPCTSTR szCodepage /* = nullptr*/) : m_wLanguage(0) , m_bVersionOnly(false) , m_bDllVersion(false) { - if (szFileToVersion != NULL) + if (szFileToVersion != nullptr) m_strFileName = szFileToVersion; - if (szLanguage != NULL) + if (szLanguage != nullptr) m_strLanguage = szLanguage; - if (szCodepage != NULL) + if (szCodepage != nullptr) m_strCodepage = szCodepage; GetVersionInfo(); } diff --git a/Src/Common/VersionInfo.h b/Src/Common/VersionInfo.h index 59e403e66..e62b39520 100644 --- a/Src/Common/VersionInfo.h +++ b/Src/Common/VersionInfo.h @@ -47,9 +47,9 @@ public: explicit CVersionInfo(WORD wLanguage); CVersionInfo(LPCTSTR szFileToVersion, bool bDllVersion); - CVersionInfo(LPCTSTR szFileToVersion = NULL, - LPCTSTR szLanguage = NULL, - LPCTSTR szCodepage = NULL); + CVersionInfo(LPCTSTR szFileToVersion = nullptr, + LPCTSTR szLanguage = nullptr, + LPCTSTR szCodepage = nullptr); explicit CVersionInfo(HINSTANCE hModule); String GetFileVersion() const; String GetCompanyName() const; diff --git a/Src/Common/memdc.h b/Src/Common/memdc.h index 45a540662..5f33cbdec 100644 --- a/Src/Common/memdc.h +++ b/Src/Common/memdc.h @@ -89,7 +89,7 @@ public: // All we need to do is replace the DC with an illegal value, // this keeps us from accidently deleting the handles associated with // the CDC that was passed to the constructor. - m_hDC = m_hAttribDC = NULL; + m_hDC = m_hAttribDC = nullptr; } } diff --git a/Src/Common/multiformatText.h b/Src/Common/multiformatText.h index bb1725f8a..f597794d7 100644 --- a/Src/Common/multiformatText.h +++ b/Src/Common/multiformatText.h @@ -80,7 +80,7 @@ public: newFilename = GetDataFileUnicode(); else newFilename = GetDataFileAnsi(); - if (newFilename == NULL) + if (newFilename == nullptr) { GetLastValidFile(filename); return false; diff --git a/Src/CompareStatisticsDlg.cpp b/Src/CompareStatisticsDlg.cpp index a204ba3a4..7efc15049 100644 --- a/Src/CompareStatisticsDlg.cpp +++ b/Src/CompareStatisticsDlg.cpp @@ -33,7 +33,7 @@ IMPLEMENT_DYNAMIC(CompareStatisticsDlg, CTrDialog) -CompareStatisticsDlg::CompareStatisticsDlg(const CompareStats* pStats, CWnd* pParent /*=NULL*/) : +CompareStatisticsDlg::CompareStatisticsDlg(const CompareStats* pStats, CWnd* pParent /*= nullptr*/) : m_pCompareStats(pStats), CTrDialog(pStats->GetCompareDirs() < 3 ? IDD_COMPARE_STATISTICS : IDD_COMPARE_STATISTICS3, pParent) { diff --git a/Src/CompareStatisticsDlg.h b/Src/CompareStatisticsDlg.h index 8eeba227c..22f4e89a5 100644 --- a/Src/CompareStatisticsDlg.h +++ b/Src/CompareStatisticsDlg.h @@ -35,7 +35,7 @@ class CompareStatisticsDlg : public CTrDialog DECLARE_DYNAMIC(CompareStatisticsDlg) public: - CompareStatisticsDlg(const CompareStats * pStats, CWnd* pParent = NULL); // standard constructor + CompareStatisticsDlg(const CompareStats * pStats, CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CompareStatisticsDlg) diff --git a/Src/ConfirmFolderCopyDlg.cpp b/Src/ConfirmFolderCopyDlg.cpp index 5f712037a..ee39cb59c 100644 --- a/Src/ConfirmFolderCopyDlg.cpp +++ b/Src/ConfirmFolderCopyDlg.cpp @@ -31,7 +31,7 @@ // ConfirmFolderCopyDlg dialog IMPLEMENT_DYNAMIC(ConfirmFolderCopyDlg, CTrDialog) -ConfirmFolderCopyDlg::ConfirmFolderCopyDlg(CWnd* pParent /*=NULL*/) +ConfirmFolderCopyDlg::ConfirmFolderCopyDlg(CWnd* pParent /*= nullptr*/) : CTrDialog(ConfirmFolderCopyDlg::IDD, pParent) { } diff --git a/Src/ConfirmFolderCopyDlg.h b/Src/ConfirmFolderCopyDlg.h index e03ede6b6..65a1aecc9 100644 --- a/Src/ConfirmFolderCopyDlg.h +++ b/Src/ConfirmFolderCopyDlg.h @@ -33,7 +33,7 @@ class ConfirmFolderCopyDlg : public CTrDialog DECLARE_DYNAMIC(ConfirmFolderCopyDlg) public: - explicit ConfirmFolderCopyDlg(CWnd* pParent = NULL); // standard constructor + explicit ConfirmFolderCopyDlg(CWnd* pParent = nullptr); // standard constructor virtual ~ConfirmFolderCopyDlg(); // Dialog Data diff --git a/Src/DiffList.cpp b/Src/DiffList.cpp index ec86bf552..46fb7e57a 100644 --- a/Src/DiffList.cpp +++ b/Src/DiffList.cpp @@ -922,22 +922,22 @@ void DiffList::GetExtraLinesCounts(int nFiles, int extras[3]) } } -void DiffList::AppendDiffList(const DiffList& list, int offset[], int doffset) +void DiffList::AppendDiffList(const DiffList& list, int offset[] /*= nullptr*/, int doffset /*= 0*/) { for (std::vector::const_iterator it = list.m_diffs.begin(); it != list.m_diffs.end(); ++it) { DIFFRANGE dr = *it; for (int file = 0; file < 3; ++file) { - if (offset) + if (offset != nullptr) { dr.begin[file] += offset[file]; dr.end[file] += offset[file]; } - if (doffset) + if (doffset != 0) dr.blank[file] += doffset; } - if (doffset) + if (doffset != 0) { dr.dbegin += doffset; dr.dend += doffset; diff --git a/Src/DiffList.h b/Src/DiffList.h index a8a7d63c2..913a63bc3 100644 --- a/Src/DiffList.h +++ b/Src/DiffList.h @@ -170,7 +170,7 @@ public: std::vector& GetDiffRangeInfoVector() { return m_diffs; } - void AppendDiffList(const DiffList& list, int offset[] = NULL, int doffset = 0); + void AppendDiffList(const DiffList& list, int offset[] = nullptr, int doffset = 0); private: std::vector m_diffs; /**< Difference list. */ diff --git a/Src/DiffTextBuffer.cpp b/Src/DiffTextBuffer.cpp index 78911d398..8d6ec48d3 100644 --- a/Src/DiffTextBuffer.cpp +++ b/Src/DiffTextBuffer.cpp @@ -194,7 +194,7 @@ void CDiffTextBuffer:: /* virtual override */ AddUndoRecord(bool bInsert, const CPoint & ptStartPos, const CPoint & ptEndPos, LPCTSTR pszText, size_t cchText, int nActionType /*= CE_ACTION_UNKNOWN*/, - CDWordArray *paSavedRevisionNumbers) + CDWordArray *paSavedRevisionNumbers /*= nullptr*/) { CGhostTextBuffer::AddUndoRecord(bInsert, ptStartPos, ptEndPos, pszText, cchText, nActionType, paSavedRevisionNumbers); diff --git a/Src/DiffTextBuffer.h b/Src/DiffTextBuffer.h index 39167b3f8..ad8ff7871 100644 --- a/Src/DiffTextBuffer.h +++ b/Src/DiffTextBuffer.h @@ -45,7 +45,7 @@ public : virtual void AddUndoRecord (bool bInsert, const CPoint & ptStartPos, const CPoint & ptEndPos, LPCTSTR pszText, size_t cchText, int nActionType = CE_ACTION_UNKNOWN, - CDWordArray *paSavedRevisionNumbers = NULL) override; + CDWordArray *paSavedRevisionNumbers = nullptr) override; bool curUndoGroup(); void ReplaceFullLines(CDiffTextBuffer& dbuf, CDiffTextBuffer& sbuf, CCrystalTextView * pSource, int nLineBegin, int nLineEnd, int nAction =CE_ACTION_UNKNOWN); diff --git a/Src/DiffViewBar.cpp b/Src/DiffViewBar.cpp index 857394a0a..8e813f81f 100644 --- a/Src/DiffViewBar.cpp +++ b/Src/DiffViewBar.cpp @@ -49,9 +49,9 @@ END_MESSAGE_MAP() */ BOOL CDiffViewBar::Create( CWnd* pParentWnd, - LPCTSTR lpszWindowName, - DWORD dwStyle, - UINT nID) + LPCTSTR lpszWindowName /*= nullptr*/, + DWORD dwStyle /*= WS_CHILD | WS_VISIBLE | CBRS_TOP*/, + UINT nID /*= AFX_IDW_PANE_FIRST*/) { return TViewBarBase::Create( lpszWindowName, diff --git a/Src/DiffViewBar.h b/Src/DiffViewBar.h index 268933d76..0095a4241 100644 --- a/Src/DiffViewBar.h +++ b/Src/DiffViewBar.h @@ -20,7 +20,7 @@ public: virtual ~CDiffViewBar(); virtual BOOL Create( CWnd* pParentWnd, // mandatory - LPCTSTR lpszWindowName = NULL, + LPCTSTR lpszWindowName = nullptr, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP, UINT nID = AFX_IDW_PANE_FIRST); diff --git a/Src/DirActions.h b/Src/DirActions.h index 93384a63c..5d81f3b00 100644 --- a/Src/DirActions.h +++ b/Src/DirActions.h @@ -217,7 +217,7 @@ struct DirActions typedef bool (DirActions::*method_type2)(const DIFFITEM& di) const; typedef FileActionScript *(DirActions::*method_type)(FileActionScript *, const std::pair& it) const; - DirActions(const CDiffContext& ctxt, const bool RO[], method_type func = NULL, method_type2 func2 = NULL) : + DirActions(const CDiffContext& ctxt, const bool RO[], method_type func = nullptr, method_type2 func2 = nullptr) : m_ctxt(ctxt), m_RO(RO), m_cur_method(func), m_cur_method2(func2) {} template diff --git a/Src/DirCmpReportDlg.cpp b/Src/DirCmpReportDlg.cpp index cc43fea1a..2847de09e 100644 --- a/Src/DirCmpReportDlg.cpp +++ b/Src/DirCmpReportDlg.cpp @@ -19,7 +19,7 @@ IMPLEMENT_DYNAMIC(DirCmpReportDlg, CTrDialog) /** * @brief Constructor. */ -DirCmpReportDlg::DirCmpReportDlg(CWnd* pParent /*=NULL*/) +DirCmpReportDlg::DirCmpReportDlg(CWnd* pParent /*= nullptr*/) : CTrDialog(DirCmpReportDlg::IDD, pParent) , m_bCopyToClipboard(false) , m_bIncludeFileCmpReport(false) diff --git a/Src/DirCmpReportDlg.h b/Src/DirCmpReportDlg.h index 4287ea11c..cddf365f3 100644 --- a/Src/DirCmpReportDlg.h +++ b/Src/DirCmpReportDlg.h @@ -21,7 +21,7 @@ class DirCmpReportDlg : public CTrDialog DECLARE_DYNAMIC(DirCmpReportDlg) public: - explicit DirCmpReportDlg(CWnd* pParent = NULL); // standard constructor + explicit DirCmpReportDlg(CWnd* pParent = nullptr); // standard constructor // Dialog Data enum { IDD = IDD_DIRCMP_REPORT }; diff --git a/Src/DirColsDlg.cpp b/Src/DirColsDlg.cpp index c8f2fa4dc..04e884c76 100644 --- a/Src/DirColsDlg.cpp +++ b/Src/DirColsDlg.cpp @@ -22,7 +22,7 @@ * @brief Default dialog constructor. * @param [in] pParent Dialog's parent component (window). */ -CDirColsDlg::CDirColsDlg(CWnd* pParent /*=NULL*/) +CDirColsDlg::CDirColsDlg(CWnd* pParent /*= nullptr*/) : CTrDialog(CDirColsDlg::IDD, pParent) , m_bReset(false) { diff --git a/Src/DirColsDlg.h b/Src/DirColsDlg.h index 1d5bb81cc..79917d79a 100644 --- a/Src/DirColsDlg.h +++ b/Src/DirColsDlg.h @@ -44,7 +44,7 @@ public: // Construction public: - explicit CDirColsDlg(CWnd* pParent = NULL); // standard constructor + explicit CDirColsDlg(CWnd* pParent = nullptr); // standard constructor void AddColumn(const String & name, const String & desc, int log, int phy=-1) { column c(name, desc, log, phy); m_cols.push_back(c); } void AddDefColumn(const String & name, int log, int phy=-1) diff --git a/Src/DirDoc.h b/Src/DirDoc.h index 9da0f9dcf..c7a9cb1ba 100644 --- a/Src/DirDoc.h +++ b/Src/DirDoc.h @@ -87,7 +87,7 @@ public: void SetReportFile(const String& sReportFile) { m_sReportFile = sReportFile; } bool GetGeneratingReport() const { return m_bGeneratingReport; } void SetGeneratingReport(bool bGeneratingReport) { m_bGeneratingReport = bGeneratingReport; } - bool HasDirView() const { return m_pDirView != NULL; } + bool HasDirView() const { return m_pDirView != nullptr; } void RefreshOptions(); void CompareReady(); void UpdateChangedItem(PathContext & paths, @@ -109,7 +109,7 @@ public: void SetDescriptions(const String strDesc[]); void ApplyDisplayRoot(int nIndex, String &); - bool HasDiffs() const { return m_pCtxt != NULL; } + bool HasDiffs() const { return m_pCtxt != nullptr; } const CDiffContext & GetDiffContext() const { return *m_pCtxt; } CDiffContext& GetDiffContext() { return *m_pCtxt.get(); } void SetMarkedRescan() {m_bMarkedRescan = true; } diff --git a/Src/DirView.cpp b/Src/DirView.cpp index bb2068657..1ffac4b74 100644 --- a/Src/DirView.cpp +++ b/Src/DirView.cpp @@ -2315,31 +2315,31 @@ BOOL CDirView::OnChildNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* p /** * @brief User is starting to drag a column header */ -BOOL CDirView::OnHeaderBeginDrag(LPNMHEADER hdr, LRESULT* pResult) +bool CDirView::OnHeaderBeginDrag(LPNMHEADER hdr, LRESULT* pResult) { // save column widths before user reorders them // so we can reload them on the end drag String secname = GetDocument()->m_nDirs < 3 ? _T("DirView") : _T("DirView3"); theApp.WriteProfileString(secname.c_str(), _T("ColumnWidths"), m_pColItems->SaveColumnWidths(std::bind(&CListCtrl::GetColumnWidth, m_pList, _1)).c_str()); - return TRUE; + return true; } /** * @brief User just finished dragging a column header */ -BOOL CDirView::OnHeaderEndDrag(LPNMHEADER hdr, LRESULT* pResult) +bool CDirView::OnHeaderEndDrag(LPNMHEADER hdr, LRESULT* pResult) { int src = hdr->iItem; int dest = hdr->pitem->iOrder; - bool allowDrop = TRUE; - *pResult = !allowDrop; + bool allowDrop = true; + *pResult = allowDrop ? FALSE : TRUE; if (allowDrop && src != dest && dest != -1) { m_pColItems->MoveColumn(src, dest); InitiateSort(); } - return TRUE; + return true; } /** diff --git a/Src/DirView.h b/Src/DirView.h index b0efc5d5a..df1eb602e 100644 --- a/Src/DirView.h +++ b/Src/DirView.h @@ -383,8 +383,8 @@ protected: afx_msg void OnBnClickedComparisonContinue(); //}}AFX_MSG DECLARE_MESSAGE_MAP() - BOOL OnHeaderBeginDrag(LPNMHEADER hdr, LRESULT* pResult); - BOOL OnHeaderEndDrag(LPNMHEADER hdr, LRESULT* pResult); + bool OnHeaderBeginDrag(LPNMHEADER hdr, LRESULT* pResult); + bool OnHeaderEndDrag(LPNMHEADER hdr, LRESULT* pResult); private: void OpenSelection(SELECTIONTYPE selectionType = SELECTIONTYPE_NORMAL, PackingInfo * infoUnpacker = nullptr); diff --git a/Src/Environment.cpp b/Src/Environment.cpp index c3d28970f..1f2cd7b8e 100644 --- a/Src/Environment.cpp +++ b/Src/Environment.cpp @@ -63,7 +63,7 @@ String GetTemporaryPath() * @param [out] pnerr Error code if error happened. * @return Full path for temporary file or empty string if error happened. */ -String GetTemporaryFileName(const String& lpPathName, const String& lpPrefixString, int * pnerr) +String GetTemporaryFileName(const String& lpPathName, const String& lpPrefixString, int * pnerr /*= nullptr*/) { TCHAR buffer[MAX_PATH] = {0}; if (lpPathName.length() > MAX_PATH-14) diff --git a/Src/Environment.h b/Src/Environment.h index 84c38a2f4..c8d4371ad 100644 --- a/Src/Environment.h +++ b/Src/Environment.h @@ -13,7 +13,7 @@ namespace env void SetTemporaryPath(const String& path); String GetTemporaryPath(); String GetTemporaryFileName(const String& lpPathName, const String& lpPrefixString, - int * pnerr = NULL); + int * pnerr = nullptr); String GetTempChildPath(); void SetProgPath(const String& path); String GetProgPath(); diff --git a/Src/Exceptions.h b/Src/Exceptions.h index 308fa8950..befb29b4d 100644 --- a/Src/Exceptions.h +++ b/Src/Exceptions.h @@ -87,13 +87,13 @@ public: // don't localize this as we do not localize the known exceptions return _T("Unknown structured exception"); } - virtual bool GetErrorMessage( TCHAR *lpszError, unsigned nMaxError, unsigned *pnHelpContext = NULL ) + virtual bool GetErrorMessage( TCHAR *lpszError, unsigned nMaxError, unsigned *pnHelpContext = nullptr ) { StringCchPrintf(lpszError, nMaxError, _T("Exception %s (0x%.8x)"), getSeMessage(), static_cast(getSeNumber())); return true; } #else - virtual bool GetErrorMessage( TCHAR *lpszError, unsigned nMaxError, unsigned *pnHelpContext = NULL ) + virtual bool GetErrorMessage( TCHAR *lpszError, unsigned nMaxError, unsigned *pnHelpContext = nullptr ) { return true; } diff --git a/Src/FileOrFolderSelect.cpp b/Src/FileOrFolderSelect.cpp index 96bec532f..3cb35cbd5 100644 --- a/Src/FileOrFolderSelect.cpp +++ b/Src/FileOrFolderSelect.cpp @@ -48,7 +48,7 @@ static String LastSelectedFolder; * file or folder to open or file to save. The last parameter @p is_open selects * between open or save modes. Biggest difference is that in save-mode Windows * asks if user wants to override existing file. - * @param [in] parent Handle to parent window. Can be a NULL, but then + * @param [in] parent Handle to parent window. Can be `nullptr`, but then * CMainFrame is used which can cause modality problems. * @param [out] path Selected path is returned in this string * @param [in] initialPath Initial path (and file) shown when dialog is opened @@ -56,13 +56,13 @@ static String LastSelectedFolder; * @param [in] filterid 0 or STRING ID for filter string * - 0 means "All files (*.*)". Note the string formatting! * @param [in] is_open Selects Open/Save -dialog (mode). - * @note Be careful when setting @p parent to NULL as there are potential + * @note Be careful when setting @p parent to `nullptr` as there are potential * modality problems with this. Dialog can be lost behind other windows! * @param [in] defaultExtension Extension to append if user doesn't provide one */ bool SelectFile(HWND parent, String& path, bool is_open /*= true*/, - LPCTSTR initialPath /*=NULL*/, const String& stitle /*=_T("")*/, - const String& sfilter /*=_T("")*/, LPCTSTR defaultExtension /*=NULL*/) + LPCTSTR initialPath /*= nullptr*/, const String& stitle /*=_T("")*/, + const String& sfilter /*=_T("")*/, LPCTSTR defaultExtension /*= nullptr*/) { path.clear(); // Clear output param @@ -100,13 +100,13 @@ bool SelectFile(HWND parent, String& path, bool is_open /*= true*/, OPENFILENAME_NT4 ofn = { sizeof OPENFILENAME_NT4 }; ofn.hwndOwner = parent; ofn.lpstrFilter = filtersStr; - ofn.lpstrCustomFilter = NULL; + ofn.lpstrCustomFilter = nullptr; ofn.nFilterIndex = 1; ofn.lpstrFile = sSelectedFile; ofn.nMaxFile = MAX_PATH_FULL; ofn.lpstrInitialDir = initialPath; ofn.lpstrTitle = title.c_str(); - ofn.lpstrFileTitle = NULL; + ofn.lpstrFileTitle = nullptr; if (defaultExtension) ofn.lpstrDefExt = defaultExtension; ofn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR; @@ -132,22 +132,22 @@ bool SelectFile(HWND parent, String& path, bool is_open /*= true*/, * @param [in] hwndOwner Handle to owner window or NULL * @return `true` if valid folder selected (not cancelled) */ -bool SelectFolder(String& path, LPCTSTR root_path /*=NULL*/, +bool SelectFolder(String& path, LPCTSTR root_path /*= nullptr*/, const String& stitle /*=_T("")*/, - HWND hwndOwner /*=NULL*/) + HWND hwndOwner /*= nullptr*/) { BROWSEINFO bi; LPITEMIDLIST pidl; TCHAR szPath[MAX_PATH_FULL] = {0}; bool bRet = false; String title = stitle; - if (root_path == NULL) + if (root_path == nullptr) LastSelectedFolder.clear(); else LastSelectedFolder = root_path; bi.hwndOwner = hwndOwner; - bi.pidlRoot = NULL; // Start from desktop folder + bi.pidlRoot = nullptr; // Start from desktop folder bi.pszDisplayName = szPath; bi.lpszTitle = title.c_str(); bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI | BIF_VALIDATE; @@ -155,7 +155,7 @@ bool SelectFolder(String& path, LPCTSTR root_path /*=NULL*/, bi.lParam = (LPARAM)root_path; pidl = SHBrowseForFolder(&bi); - if (pidl) + if (pidl != nullptr) { if (SHGetPathFromIDList(pidl, szPath)) { @@ -206,13 +206,13 @@ static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, * - If existing filename is selected return it * - If filename in (CFileDialog) editbox and current folder doesn't form * a valid path to file, return current folder. - * @param [in] parent Handle to parent window. Can be a NULL, but then + * @param [in] parent Handle to parent window. Can be `nullptr`, but then * CMainFrame is used which can cause modality problems. * @param [out] path Selected folder/filename * @param [in] initialPath Initial file or folder shown/selected. * @return `true` if user choosed a file/folder, `false` if user canceled dialog. */ -bool SelectFileOrFolder(HWND parent, String& path, LPCTSTR initialPath /*=NULL*/) +bool SelectFileOrFolder(HWND parent, String& path, LPCTSTR initialPath /*= nullptr*/) { String title = _("Open"); @@ -221,7 +221,7 @@ bool SelectFileOrFolder(HWND parent, String& path, LPCTSTR initialPath /*=NULL*/ TCHAR sSelectedFile[MAX_PATH_FULL]; // check if specified path is a file - if (initialPath && initialPath[0]) + if (initialPath!=nullptr && initialPath[0] != '\0') { // If initial path info includes a file // we put the bare filename into sSelectedFile diff --git a/Src/FileOrFolderSelect.h b/Src/FileOrFolderSelect.h index ef3df2ee4..4e5fcd33a 100644 --- a/Src/FileOrFolderSelect.h +++ b/Src/FileOrFolderSelect.h @@ -28,11 +28,11 @@ #include "UnicodeString.h" bool SelectFile(HWND parent, String& path, bool is_open = true, - LPCTSTR initialPath = NULL, const String& stitle = _T(""), - const String& sfilter = _T(""), LPCTSTR defaultExtension = NULL); + LPCTSTR initialPath = nullptr, const String& stitle = _T(""), + const String& sfilter = _T(""), LPCTSTR defaultExtension = nullptr); -bool SelectFolder(String& path, LPCTSTR root_path = NULL, +bool SelectFolder(String& path, LPCTSTR root_path = nullptr, const String& title = _T(""), - HWND hwndOwner = NULL); + HWND hwndOwner = nullptr); -bool SelectFileOrFolder(HWND parent, String& path, LPCTSTR root_path = NULL); +bool SelectFileOrFolder(HWND parent, String& path, LPCTSTR root_path = nullptr); diff --git a/Src/FileTransform.cpp b/Src/FileTransform.cpp index 627705d11..b1ea3ef33 100644 --- a/Src/FileTransform.cpp +++ b/Src/FileTransform.cpp @@ -62,9 +62,9 @@ bool Packing(String & filepath, PackingInfo handler) bool bHandled = false; PluginInfo * plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_PACK_UNPACK", handler.pluginName); - if (plugin == NULL) + if (plugin == nullptr) plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_FOLDER_PACK_UNPACK", handler.pluginName); - if (plugin == NULL) + if (plugin == nullptr) plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"BUFFER_PACK_UNPACK", handler.pluginName); LPDISPATCH piScript = plugin->m_lpDispatch; if (handler.bWithFile) @@ -106,7 +106,7 @@ bool Packing(String & filepath, PackingInfo handler) bool Unpacking(String & filepath, const PackingInfo * handler, int * handlerSubcode) { // no handler : return true - if (!handler || handler->pluginName.empty()) + if (handler == nullptr || handler->pluginName.empty()) return true; storageForPlugins bufferData; @@ -119,11 +119,11 @@ bool Unpacking(String & filepath, const PackingInfo * handler, int * handlerSubc bool bHandled = false; PluginInfo * plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_PACK_UNPACK", handler->pluginName); - if (plugin == NULL) + if (plugin == nullptr) plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_FOLDER_PACK_UNPACK", handler->pluginName); - if (plugin == NULL) + if (plugin == nullptr) plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"BUFFER_PACK_UNPACK", handler->pluginName); - if (plugin == NULL) + if (plugin == nullptr) return false; LPDISPATCH piScript = plugin->m_lpDispatch; @@ -188,9 +188,9 @@ bool Unpacking(String & filepath, const String& filteredText, PackingInfo * hand bool bHandled = false; PluginInfo * plugin = CAllThreadsScripts::GetActiveSet()->GetAutomaticPluginByFilter(L"FILE_PACK_UNPACK", filteredText); - if (!plugin) + if (plugin == nullptr) plugin = CAllThreadsScripts::GetActiveSet()->GetAutomaticPluginByFilter(L"FILE_FOLDER_PACK_UNPACK", filteredText); - if (plugin) + if (plugin != nullptr) { handler->pluginName = plugin->m_name; handler->bWithFile = true; @@ -211,7 +211,7 @@ bool Unpacking(String & filepath, const String& filteredText, PackingInfo * hand if (!bHandled) { plugin = CAllThreadsScripts::GetActiveSet()->GetAutomaticPluginByFilter(L"BUFFER_PACK_UNPACK", filteredText); - if (plugin) + if (plugin != nullptr) { handler->pluginName = plugin->m_name; handler->bWithFile = false; @@ -275,10 +275,10 @@ bool Prediffing(String & filepath, PrediffingInfo handler, bool bMayOverwrite) bool bHandled = false; PluginInfo * plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"FILE_PREDIFF", handler.pluginName); - if (!plugin) + if (plugin == nullptr) { plugin = CAllThreadsScripts::GetActiveSet()->GetPluginByName(L"BUFFER_PREDIFF", handler.pluginName); - if (!plugin) + if (plugin == nullptr) return false; } LPDISPATCH piScript = plugin->m_lpDispatch; @@ -333,7 +333,7 @@ bool Prediffing(String & filepath, const String& filteredText, PrediffingInfo * bool bHandled = false; PluginInfo * plugin = CAllThreadsScripts::GetActiveSet()->GetAutomaticPluginByFilter(L"FILE_PREDIFF", filteredText); - if (plugin) + if (plugin != nullptr) { handler->pluginName = plugin->m_name; handler->bWithFile = true; @@ -351,7 +351,7 @@ bool Prediffing(String & filepath, const String& filteredText, PrediffingInfo * if (!bHandled) { plugin = CAllThreadsScripts::GetActiveSet()->GetAutomaticPluginByFilter(L"BUFFER_PREDIFF", filteredText); - if (plugin) + if (plugin != nullptr) { handler->pluginName = plugin->m_name; handler->bWithFile = false; diff --git a/Src/FileTransform.h b/Src/FileTransform.h index 942eb1f2f..9421cc93b 100644 --- a/Src/FileTransform.h +++ b/Src/FileTransform.h @@ -84,7 +84,8 @@ public: int bToBeScanned; // TODO: Convert to PLUGIN_MODE and fix compile errors /// plugin name when it is defined String pluginName; - /// `true` is the plugins exchange data through a file, false is the data is passed as parameter (BSTR/ARRAY) + + /// `true` if the plugins exchange data through a file, `false` is the data is passed as parameter (BSTR/ARRAY) bool bWithFile; }; diff --git a/Src/GhostTextBuffer.cpp b/Src/GhostTextBuffer.cpp index f7139a3aa..844a2f865 100644 --- a/Src/GhostTextBuffer.cpp +++ b/Src/GhostTextBuffer.cpp @@ -836,7 +836,7 @@ void CGhostTextBuffer:: /* virtual override */ AddUndoRecord(bool bInsert, const CPoint & ptStartPos, const CPoint & ptEndPos, LPCTSTR pszText, size_t cchText, int nActionType /*= CE_ACTION_UNKNOWN*/, - CDWordArray *paSavedRevisionNumbers) + CDWordArray *paSavedRevisionNumbers /*= nullptr*/) { CPoint real_ptStartPos(ptStartPos.x, ComputeRealLine(ptStartPos.y)); CPoint real_ptEndPos(ptEndPos.x, real_ptStartPos.y + CountEol(pszText, cchText)); diff --git a/Src/GhostTextBuffer.h b/Src/GhostTextBuffer.h index e60d9fa56..ee08aa8e9 100644 --- a/Src/GhostTextBuffer.h +++ b/Src/GhostTextBuffer.h @@ -90,7 +90,7 @@ public : #endif virtual void AddUndoRecord (bool bInsert, const CPoint & ptStartPos, const CPoint & ptEndPos, - LPCTSTR pszText, size_t cchText, int nActionType = CE_ACTION_UNKNOWN, CDWordArray *paSavedRevisionNumbers = NULL) override; + LPCTSTR pszText, size_t cchText, int nActionType = CE_ACTION_UNKNOWN, CDWordArray *paSavedRevisionNumbers = nullptr) override; virtual UndoRecord GetUndoRecord(int nUndoPos) const override; virtual bool UndoInsert(CCrystalTextView * pSource, CPoint & ptCursorPos, const CPoint apparent_ptStartPos, CPoint const apparent_ptEndPos, const UndoRecord & ur) override; diff --git a/Src/GhostTextView.cpp b/Src/GhostTextView.cpp index b50983ffa..59ea8ca0b 100644 --- a/Src/GhostTextView.cpp +++ b/Src/GhostTextView.cpp @@ -46,9 +46,9 @@ CGhostTextView::CGhostTextView() } void CGhostTextView:: -ReAttachToBuffer (CCrystalTextBuffer * pBuf /*= NULL*/ ) +ReAttachToBuffer (CCrystalTextBuffer * pBuf /*= nullptr*/ ) { - if (pBuf == NULL) + if (pBuf == nullptr) { pBuf = LocateTextBuffer (); // ... @@ -58,9 +58,9 @@ ReAttachToBuffer (CCrystalTextBuffer * pBuf /*= NULL*/ ) } void CGhostTextView:: -AttachToBuffer (CCrystalTextBuffer * pBuf /*= NULL*/ ) +AttachToBuffer (CCrystalTextBuffer * pBuf /*= nullptr*/ ) { - if (pBuf == NULL) + if (pBuf == nullptr) { pBuf = LocateTextBuffer (); // ... @@ -72,8 +72,8 @@ AttachToBuffer (CCrystalTextBuffer * pBuf /*= NULL*/ ) void CGhostTextView:: DetachFromBuffer () { - if (m_pGhostTextBuffer != NULL) - m_pGhostTextBuffer = NULL; + if (m_pGhostTextBuffer != nullptr) + m_pGhostTextBuffer = nullptr; CCrystalEditViewEx::DetachFromBuffer(); } diff --git a/Src/GhostTextView.h b/Src/GhostTextView.h index 5c34c8d73..019ce7867 100644 --- a/Src/GhostTextView.h +++ b/Src/GhostTextView.h @@ -93,8 +93,8 @@ private: // m_ptDropPos : only used inside one function which does not change the buffer public: - virtual void ReAttachToBuffer (CCrystalTextBuffer * pBuf = NULL); - virtual void AttachToBuffer (CCrystalTextBuffer * pBuf = NULL); + virtual void ReAttachToBuffer (CCrystalTextBuffer * pBuf = nullptr); + virtual void AttachToBuffer (CCrystalTextBuffer * pBuf = nullptr); virtual void DetachFromBuffer (); /** real cursor function to preserve cursor during Rescan */ diff --git a/Src/IListCtrlImpl.h b/Src/IListCtrlImpl.h index 4c003ffe3..99a6e6809 100644 --- a/Src/IListCtrlImpl.h +++ b/Src/IListCtrlImpl.h @@ -123,7 +123,7 @@ public: bmpinfo.bmiHeader.biPlanes = 1; bmpinfo.bmiHeader.biBitCount = 32; bmpinfo.bmiHeader.biCompression = BI_RGB; - HBITMAP hbmpImage = CreateDIBSection(NULL, &bmpinfo, DIB_RGB_COLORS, &pBits, NULL, NULL); + HBITMAP hbmpImage = CreateDIBSection(nullptr, &bmpinfo, DIB_RGB_COLORS, &pBits, nullptr, 0); if (hbmpImage) { HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcMem, hbmpImage); @@ -131,8 +131,8 @@ public: CImage image; image.Attach(hbmpImage); image.SetHasAlphaChannel(true); - IStream *pStream = NULL; - if (SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &pStream))) + IStream *pStream = nullptr; + if (SUCCEEDED(CreateStreamOnHGlobal(nullptr, TRUE, &pStream))) { image.Save(pStream, Gdiplus::ImageFormatPNG); STATSTG stat; @@ -140,8 +140,8 @@ public: { LARGE_INTEGER li = { 0 }; ret.resize(stat.cbSize.LowPart, 0); - pStream->Seek(li, STREAM_SEEK_SET, NULL); - pStream->Read(&ret[0], stat.cbSize.LowPart, NULL); + pStream->Seek(li, STREAM_SEEK_SET, nullptr); + pStream->Read(&ret[0], stat.cbSize.LowPart, nullptr); } pStream->Release(); } -- 2.11.0