From a7c24ca48995cf2bf436156302f96b91bf135409 Mon Sep 17 00:00:00 2001 From: Goraf <22941576+Goraf@users.noreply.github.com> Date: Mon, 13 Nov 2017 15:03:31 +0100 Subject: Code modernize ... * replace 0/NULL with nullptr [using clang-tidy] --- plugins/SmileyAdd/src/AniSmileyObject.cpp | 20 +++---- plugins/SmileyAdd/src/SmileyBase.cpp | 52 ++++++++-------- plugins/SmileyAdd/src/anim.cpp | 8 +-- plugins/SmileyAdd/src/customsmiley.cpp | 8 +-- plugins/SmileyAdd/src/dlgboxsubclass.cpp | 10 ++-- plugins/SmileyAdd/src/download.cpp | 12 ++-- plugins/SmileyAdd/src/general.cpp | 14 ++--- plugins/SmileyAdd/src/imagecache.cpp | 96 +++++++++++++++--------------- plugins/SmileyAdd/src/options.cpp | 26 ++++---- plugins/SmileyAdd/src/regexp/WCPattern.cpp | 44 +++++++------- plugins/SmileyAdd/src/richcall.cpp | 22 +++---- plugins/SmileyAdd/src/services.cpp | 56 ++++++++--------- plugins/SmileyAdd/src/smileyroutines.cpp | 48 +++++++-------- plugins/SmileyAdd/src/smileys.cpp | 94 ++++++++++++++--------------- plugins/SmileyAdd/src/smltool.cpp | 32 +++++----- 15 files changed, 271 insertions(+), 271 deletions(-) (limited to 'plugins/SmileyAdd/src') diff --git a/plugins/SmileyAdd/src/AniSmileyObject.cpp b/plugins/SmileyAdd/src/AniSmileyObject.cpp index c0c41f39c6..78bf8dba2b 100644 --- a/plugins/SmileyAdd/src/AniSmileyObject.cpp +++ b/plugins/SmileyAdd/src/AniSmileyObject.cpp @@ -60,7 +60,7 @@ public: void LoadSmiley() { - if (m_img != NULL) return; + if (m_img != nullptr) return; m_img = m_sml->CreateCachedImage(); if (m_img && m_img->IsAnimated() && opt.AnimateDlg) { @@ -76,15 +76,15 @@ public: m_bRegistered = false; } - if (m_img != NULL) { + if (m_img != nullptr) { m_img->Release(); - m_img = NULL; + m_img = nullptr; } } void GetDrawingProp() { - if (m_hwnd == NULL) + if (m_hwnd == nullptr) return; REOBJECT reObj = { 0 }; @@ -173,7 +173,7 @@ public: DoDirectDraw(hdc); - SelectClipRgn(hdc, res < 1 ? NULL : hrgnOld); + SelectClipRgn(hdc, res < 1 ? nullptr : hrgnOld); DeleteObject(hrgnOld); } else { @@ -186,7 +186,7 @@ public: void DrawOnHPP() { - FVCNDATA_NMHDR nmh = { 0 }; + FVCNDATA_NMHDR nmh = {}; nmh.code = NM_FIREVIEWCHANGE; nmh.hwndFrom = m_hwnd; @@ -263,7 +263,7 @@ public: if (m_visible) LoadSmiley(); else UnloadSmiley(); - if (lpRect == NULL) return; + if (lpRect == nullptr) return; if (m_animtype == animStdOle) { m_animtype = animDrctRichEd; GetDrawingProp(); @@ -296,11 +296,11 @@ public: STDMETHOD(Draw)(DWORD dwAspect, LONG, void*, DVTARGETDEVICE*, HDC, HDC hdc, LPCRECTL pRectBounds, LPCRECTL, BOOL(__stdcall *)(ULONG_PTR), ULONG_PTR) { if (dwAspect != DVASPECT_CONTENT) return DV_E_DVASPECT; - if (pRectBounds == NULL) return E_INVALIDARG; + if (pRectBounds == nullptr) return E_INVALIDARG; LoadSmiley(); - if (m_img == NULL) return E_FAIL; + if (m_img == nullptr) return E_FAIL; m_sizeExtent.cx = pRectBounds->right - pRectBounds->left; m_sizeExtent.cy = pRectBounds->bottom - pRectBounds->top; @@ -358,7 +358,7 @@ public: ISmileyBase* CreateAniSmileyObject(SmileyType *sml, COLORREF clr, bool ishpp) { if (!sml->IsValid()) - return NULL; + return nullptr; return new CAniSmileyObject(sml, clr, ishpp); } diff --git a/plugins/SmileyAdd/src/SmileyBase.cpp b/plugins/SmileyAdd/src/SmileyBase.cpp index 2749923e6f..3ecc9e7a10 100644 --- a/plugins/SmileyAdd/src/SmileyBase.cpp +++ b/plugins/SmileyAdd/src/SmileyBase.cpp @@ -20,10 +20,10 @@ along with this program. If not, see . static void HiMetricToPixel(const SIZEL *lpSizeInHiMetric, LPSIZEL lpSizeInPix) { - HDC hDCScreen = GetDC(NULL); + HDC hDCScreen = GetDC(nullptr); const int nPixelsPerInchX = GetDeviceCaps(hDCScreen, LOGPIXELSX); const int nPixelsPerInchY = GetDeviceCaps(hDCScreen, LOGPIXELSY); - ReleaseDC(NULL, hDCScreen); + ReleaseDC(nullptr, hDCScreen); lpSizeInPix->cx = (lpSizeInHiMetric->cx * nPixelsPerInchX + (2540 / 2)) / 2540; lpSizeInPix->cy = (lpSizeInHiMetric->cy * nPixelsPerInchY + (2540 / 2)) / 2540; @@ -41,13 +41,13 @@ const GUID IID_ITooltipData = ISmileyBase::ISmileyBase(void) { - m_spAdviseSink = NULL; - m_spClientSite = NULL; - m_spAdviseHolder = NULL; + m_spAdviseSink = nullptr; + m_spClientSite = nullptr; + m_spAdviseHolder = nullptr; m_lRefCount = 1; m_advf = 0; - m_smltxt = NULL; - m_hwnd = NULL; + m_smltxt = nullptr; + m_hwnd = nullptr; m_visible = false; m_dirAniAllow = false; @@ -66,12 +66,12 @@ ISmileyBase::~ISmileyBase(void) if (m_spClientSite) { m_spClientSite->Release(); - m_spClientSite = NULL; + m_spClientSite = nullptr; } if (m_spAdviseHolder) { m_spAdviseHolder->Release(); - m_spAdviseHolder = NULL; + m_spAdviseHolder = nullptr; } } @@ -86,7 +86,7 @@ void ISmileyBase::SendOnViewChange(void) if (m_spAdviseSink) m_spAdviseSink->OnViewChange(DVASPECT_CONTENT, -1); if (m_advf & ADVF_ONLYONCE) { m_spAdviseSink->Release(); - m_spAdviseSink = NULL; + m_spAdviseSink = nullptr; m_advf = 0; } } @@ -110,7 +110,7 @@ void ISmileyBase::SetHint(wchar_t *smltxt) void ISmileyBase::SetPosition(HWND hwnd, LPCRECT lpRect) { m_hwnd = hwnd; - if (lpRect == NULL || lpRect->top == -1 || lpRect->bottom == -1) { + if (lpRect == nullptr || lpRect->top == -1 || lpRect->bottom == -1) { m_visible = false; return; } @@ -154,7 +154,7 @@ ULONG ISmileyBase::Release(void) HRESULT ISmileyBase::QueryInterface(REFIID iid, void **ppvObject) { // check to see what interface has been requested - if (ppvObject == NULL) return E_POINTER; + if (ppvObject == nullptr) return E_POINTER; if (iid == IID_ISmileyAddSmiley) *ppvObject = this; else if (iid == IID_ITooltipData) @@ -168,7 +168,7 @@ HRESULT ISmileyBase::QueryInterface(REFIID iid, void **ppvObject) else if (iid == IID_IViewObject2) *ppvObject = static_cast(this); else { - *ppvObject = NULL; + *ppvObject = nullptr; return E_NOINTERFACE; } AddRef(); @@ -180,17 +180,17 @@ HRESULT ISmileyBase::QueryInterface(REFIID iid, void **ppvObject) // HRESULT ISmileyBase::SetClientSite(IOleClientSite *pClientSite) { - if (m_spClientSite != NULL) m_spClientSite->Release(); + if (m_spClientSite != nullptr) m_spClientSite->Release(); m_spClientSite = pClientSite; - if (m_spClientSite != NULL) m_spClientSite->AddRef(); + if (m_spClientSite != nullptr) m_spClientSite->AddRef(); return S_OK; } HRESULT ISmileyBase::GetClientSite(IOleClientSite **ppClientSite) { - if (ppClientSite == NULL) return E_POINTER; + if (ppClientSite == nullptr) return E_POINTER; *ppClientSite = m_spClientSite; - if (m_spClientSite != NULL) m_spClientSite->AddRef(); + if (m_spClientSite != nullptr) m_spClientSite->AddRef(); return S_OK; } @@ -205,7 +205,7 @@ HRESULT ISmileyBase::Close(DWORD) if (m_spAdviseSink) { m_spAdviseSink->Release(); - m_spAdviseSink = NULL; + m_spAdviseSink = nullptr; } return S_OK; @@ -255,7 +255,7 @@ HRESULT ISmileyBase::GetUserType(DWORD, LPOLESTR*) HRESULT ISmileyBase::SetExtent(DWORD dwDrawAspect, SIZEL *psizel) { if (dwDrawAspect != DVASPECT_CONTENT) return E_FAIL; - if (psizel == NULL) return E_POINTER; + if (psizel == nullptr) return E_POINTER; HiMetricToPixel(psizel, &m_sizeExtent); m_sizeExtentHiM = *psizel; @@ -265,7 +265,7 @@ HRESULT ISmileyBase::SetExtent(DWORD dwDrawAspect, SIZEL *psizel) HRESULT ISmileyBase::GetExtent(DWORD dwDrawAspect, SIZEL *psizel) { if (dwDrawAspect != DVASPECT_CONTENT) return E_FAIL; - if (psizel == NULL) return E_POINTER; + if (psizel == nullptr) return E_POINTER; *psizel = m_sizeExtentHiM; return S_OK; @@ -274,12 +274,12 @@ HRESULT ISmileyBase::GetExtent(DWORD dwDrawAspect, SIZEL *psizel) HRESULT ISmileyBase::Advise(IAdviseSink *pAdvSink, DWORD *pdwConnection) { HRESULT hr = S_OK; - if (m_spAdviseHolder == NULL) + if (m_spAdviseHolder == nullptr) hr = CreateOleAdviseHolder(&m_spAdviseHolder); if (SUCCEEDED(hr)) hr = m_spAdviseHolder->Advise(pAdvSink, pdwConnection); else - m_spAdviseHolder = NULL; + m_spAdviseHolder = nullptr; return hr; } @@ -290,13 +290,13 @@ HRESULT ISmileyBase::Unadvise(DWORD dwConnection) HRESULT ISmileyBase::EnumAdvise(IEnumSTATDATA **ppEnumAdvise) { - if (ppEnumAdvise == NULL) return E_POINTER; + if (ppEnumAdvise == nullptr) return E_POINTER; return m_spAdviseHolder ? m_spAdviseHolder->EnumAdvise(ppEnumAdvise) : E_FAIL; } HRESULT ISmileyBase::GetMiscStatus(DWORD dwAspect, DWORD *pdwStatus) { - if (pdwStatus == NULL) return E_POINTER; + if (pdwStatus == nullptr) return E_POINTER; if (dwAspect == DVASPECT_CONTENT) { *pdwStatus = OLEMISC_STATIC | OLEMISC_INVISIBLEATRUNTIME | OLEMISC_CANTLINKINSIDE | OLEMISC_NOUIACTIVATE; @@ -343,7 +343,7 @@ HRESULT ISmileyBase::GetColorSet(DWORD, long, void*, DVTARGETDEVICE*, HDC, LOGPA // HRESULT ISmileyBase::GetExtent(DWORD aspect, long, DVTARGETDEVICE*, SIZEL *pSize) { - if (pSize == NULL) return E_POINTER; + if (pSize == nullptr) return E_POINTER; if (aspect != DVASPECT_CONTENT) return DV_E_DVASPECT; *pSize = m_sizeExtent; return S_OK; @@ -360,7 +360,7 @@ HRESULT ISmileyBase::SetTooltip(BSTR) HRESULT ISmileyBase::GetTooltip(BSTR *bstrHint) { - if (bstrHint == NULL) return E_POINTER; + if (bstrHint == nullptr) return E_POINTER; *bstrHint = SysAllocString(m_smltxt); return S_OK; } diff --git a/plugins/SmileyAdd/src/anim.cpp b/plugins/SmileyAdd/src/anim.cpp index 6770f81064..4e04871e89 100644 --- a/plugins/SmileyAdd/src/anim.cpp +++ b/plugins/SmileyAdd/src/anim.cpp @@ -20,7 +20,7 @@ along with this program. If not, see . Animate::Animate(SmileyType *sml, RECT &rect, HDC hdcMem, HBRUSH hbr, bool clip) : m_sml(sml), - m_img(NULL), + m_img(nullptr), m_nFramePosition(0), m_sel(false), m_clip(clip), m_offset(0), m_running(false), m_hdcMem(hdcMem), m_hbr(hbr) @@ -97,15 +97,15 @@ void Animate::SetOffset(int off, int wsize) m_running = m_cliprect.top >= 0 && m_cliprect.top < wsize; if (m_running) { - if (m_img == NULL) { + if (m_img == nullptr) { StartAnimation(); - if (m_img == NULL) + if (m_img == nullptr) m_running = false; } } else { if (m_img) m_img->Release(); - m_img = NULL; + m_img = nullptr; } } diff --git a/plugins/SmileyAdd/src/customsmiley.cpp b/plugins/SmileyAdd/src/customsmiley.cpp index 5f9ff1b9fb..aa631e3b2e 100644 --- a/plugins/SmileyAdd/src/customsmiley.cpp +++ b/plugins/SmileyAdd/src/customsmiley.cpp @@ -23,7 +23,7 @@ SmileyPackCListType g_SmileyPackCStore; bool SmileyPackCListType::AddSmileyPack(MCONTACT hContact, wchar_t *dir) { bool res = true; - if (GetSmileyPack(hContact) == NULL) { + if (GetSmileyPack(hContact) == nullptr) { SmileyPackCType *smileyPack = new SmileyPackCType; res = smileyPack->LoadSmileyDir(dir); @@ -39,7 +39,7 @@ bool SmileyPackCListType::AddSmileyPack(MCONTACT hContact, wchar_t *dir) bool SmileyPackCListType::AddSmiley(MCONTACT hContact, wchar_t *path) { SmileyPackCType *smpack = GetSmileyPack(hContact); - if (smpack == NULL) { + if (smpack == nullptr) { smpack = new SmileyPackCType; smpack->SetId(hContact); @@ -55,7 +55,7 @@ SmileyPackCType* SmileyPackCListType::GetSmileyPack(MCONTACT id) if (m_SmileyPacks[i].GetId() == id) return &m_SmileyPacks[i]; - return NULL; + return nullptr; } @@ -81,7 +81,7 @@ bool SmileyCType::CreateTriggerText(char *text) wchar_t *txt = mir_utf8decodeW(res); res[reslen] = save; - if (txt == NULL) + if (txt == nullptr) return false; m_TriggerText = txt; diff --git a/plugins/SmileyAdd/src/dlgboxsubclass.cpp b/plugins/SmileyAdd/src/dlgboxsubclass.cpp index fff1cfee75..b502c72000 100644 --- a/plugins/SmileyAdd/src/dlgboxsubclass.cpp +++ b/plugins/SmileyAdd/src/dlgboxsubclass.cpp @@ -36,7 +36,7 @@ struct MsgWndData : public MZeroedObject doSmileyButton = opt.ButtonStatus != 0; SmileyPackType *SmileyPack = GetSmileyPack(ProtocolName, hContact); - doSmileyButton &= SmileyPack != NULL && SmileyPack->VisibleSmileyCount() != 0; + doSmileyButton &= SmileyPack != nullptr && SmileyPack->VisibleSmileyCount() != 0; doSmileyReplace = true; @@ -83,7 +83,7 @@ static MsgWndData* IsMsgWnd(HWND hwnd) static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { MsgWndData *dat = IsMsgWnd(hwnd); - if (dat == NULL) + if (dat == nullptr) return 0; switch (uMsg) { @@ -122,7 +122,7 @@ static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, if (dat->doSmileyReplace) { SmileyPackCType *smcp; SmileyPackType *SmileyPack = GetSmileyPack(dat->ProtocolName, dat->hContact, &smcp); - if (SmileyPack != NULL) { + if (SmileyPack != nullptr) { const CHARRANGE sel = { dat->idxLastChar, LONG_MAX }; ReplaceSmileys(dat->hwndLog, SmileyPack, smcp, sel, false, false, false); } @@ -133,7 +133,7 @@ static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, if (dat->doSmileyReplace) { SmileyPackCType *smcp; SmileyPackType *SmileyPack = GetSmileyPack(dat->ProtocolName, dat->hContact, &smcp); - if (SmileyPack != NULL) { + if (SmileyPack != nullptr) { static const CHARRANGE sel = { 0, LONG_MAX }; ReplaceSmileys(dat->hwndLog, SmileyPack, smcp, sel, false, false, false); } @@ -176,7 +176,7 @@ int SmileyButtonPressed(WPARAM, LPARAM lParam) return 0; MsgWndData *dat = IsMsgWnd(pcbc->hwndFrom); - if (dat == NULL) + if (dat == nullptr) return 0; SmileyToolWindowParam *stwp = new SmileyToolWindowParam; diff --git a/plugins/SmileyAdd/src/download.cpp b/plugins/SmileyAdd/src/download.cpp index e524d9ad8b..a305436364 100644 --- a/plugins/SmileyAdd/src/download.cpp +++ b/plugins/SmileyAdd/src/download.cpp @@ -42,7 +42,7 @@ static bool threadRunning; bool InternetDownloadFile(const char *szUrl, char *szDest, HNETLIBCONN &hHttpDwnl) { int result = 0xBADBAD; - char *szRedirUrl = NULL; + char *szRedirUrl = nullptr; NETLIBHTTPREQUEST nlhr = { 0 }; // initialize the netlib request @@ -94,7 +94,7 @@ bool InternetDownloadFile(const char *szUrl, char *szDest, HNETLIBCONN &hHttpDwn const char *szPref = strstr(szUrl, "://"); szPref = szPref ? szPref + 3 : szUrl; const char *szPath = strchr(szPref, '/'); - rlen = szPath != NULL ? szPath - szUrl : mir_strlen(szUrl); + rlen = szPath != nullptr ? szPath - szUrl : mir_strlen(szUrl); } szRedirUrl = (char*)mir_realloc(szRedirUrl, rlen + mir_strlen(nlhrReply->headers[i].szValue) * 3 + 1); @@ -110,7 +110,7 @@ bool InternetDownloadFile(const char *szUrl, char *szDest, HNETLIBCONN &hHttpDwn else result = 1; } else { - hHttpDwnl = NULL; + hHttpDwnl = nullptr; result = 1; } @@ -127,7 +127,7 @@ void __cdecl SmileyDownloadThread(void*) Thread_SetName("SmileyAdd: SmileyDownloadThread"); bool needext = false; - HNETLIBCONN hHttpDwnl = NULL; + HNETLIBCONN hHttpDwnl = nullptr; WaitForSingleObject(g_hDlMutex, 3000); while (!Miranda_IsTerminated() && dlQueue.getCount()) { ReleaseMutex(g_hDlMutex); @@ -193,7 +193,7 @@ bool GetSmileyFile(CMStringW &url, const CMStringW &packstr) if (!threadRunning) { threadRunning = true; - mir_forkthread(SmileyDownloadThread, NULL); + mir_forkthread(SmileyDownloadThread, nullptr); } url = filename; @@ -225,7 +225,7 @@ void DownloadInit(void) hNetlibUser = Netlib_RegisterUser(&nlu); GetSmileyCacheFolder(); - g_hDlMutex = CreateMutex(NULL, FALSE, NULL); + g_hDlMutex = CreateMutex(nullptr, FALSE, nullptr); } void DownloadClose(void) diff --git a/plugins/SmileyAdd/src/general.cpp b/plugins/SmileyAdd/src/general.cpp index 277e49bda6..e23f1e835b 100644 --- a/plugins/SmileyAdd/src/general.cpp +++ b/plugins/SmileyAdd/src/general.cpp @@ -49,7 +49,7 @@ int CalculateTextHeight(HDC hdc, CHARFORMAT2 *chf) HICON GetDefaultIcon(bool copy) { HICON resIco = IcoLib_GetIcon("SmileyAdd_ButtonSmiley"); - if (resIco == NULL) + if (resIco == nullptr) resIco = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_SMILINGICON), IMAGE_ICON, 0, 0, copy ? 0 : LR_SHARED); else if (copy) { resIco = (HICON)CopyImage(resIco, IMAGE_ICON, 0, 0, 0); @@ -93,20 +93,20 @@ HICON ImageList_GetIconFixed(HIMAGELIST himl, INT i, UINT fStyle) int cx, cy; ImageList_GetIconSize(himl, &cx, &cy); - hdcDst = CreateCompatibleDC(NULL); + hdcDst = CreateCompatibleDC(nullptr); ii.fIcon = TRUE; ii.xHotspot = 0; ii.yHotspot = 0; // draw mask - ii.hbmMask = CreateBitmap(cx, cy, 1, 1, NULL); + ii.hbmMask = CreateBitmap(cx, cy, 1, 1, nullptr); hOldDstBitmap = (HBITMAP)SelectObject(hdcDst, ii.hbmMask); PatBlt(hdcDst, 0, 0, cx, cy, WHITENESS); ImageList_Draw(himl, i, hdcDst, 0, 0, fStyle | ILD_MASK); // draw image - ii.hbmColor = CreateBitmap(cx, cy, 1, 32, NULL); + ii.hbmColor = CreateBitmap(cx, cy, 1, 32, nullptr); SelectObject(hdcDst, ii.hbmColor); PatBlt(hdcDst, 0, 0, cx, cy, BLACKNESS); ImageList_Draw(himl, i, hdcDst, 0, 0, fStyle | ILD_TRANSPARENT); @@ -136,7 +136,7 @@ void pathToAbsolute(const CMStringW &pSrc, CMStringW &pOut) wchar_t szOutPath[MAX_PATH]; wchar_t *szVarPath = Utils_ReplaceVarsW(pSrc.c_str()); - if (szVarPath == (wchar_t*)CALLSERVICE_NOTFOUND || szVarPath == NULL) { + if (szVarPath == (wchar_t*)CALLSERVICE_NOTFOUND || szVarPath == nullptr) { wchar_t szExpPath[MAX_PATH]; ExpandEnvironmentStrings(pSrc.c_str(), szExpPath, _countof(szExpPath)); PathToAbsoluteW(szExpPath, szOutPath); @@ -191,7 +191,7 @@ bool InitGdiPlus(void) __try { if (g_gdiplusToken == 0 && !gdiPlusFail) - Gdiplus::GdiplusStartup(&g_gdiplusToken, &gdiplusStartupInput, NULL); + Gdiplus::GdiplusStartup(&g_gdiplusToken, &gdiplusStartupInput, nullptr); } __except (EXCEPTION_EXECUTE_HANDLER) { @@ -236,5 +236,5 @@ void ReportError(const wchar_t *errmsg) mir_wstrcpy(pd.lpwzText, errmsg); pd.iSeconds = -1; if (PUAddPopupT(&pd) == CALLSERVICE_NOTFOUND) - MessageBox(NULL, errmsg, title, MB_OK | MB_ICONWARNING | MB_TOPMOST); + MessageBox(nullptr, errmsg, title, MB_OK | MB_ICONWARNING | MB_TOPMOST); } diff --git a/plugins/SmileyAdd/src/imagecache.cpp b/plugins/SmileyAdd/src/imagecache.cpp index 8f4ea9fe4c..26842e284b 100644 --- a/plugins/SmileyAdd/src/imagecache.cpp +++ b/plugins/SmileyAdd/src/imagecache.cpp @@ -29,10 +29,10 @@ static UINT_PTR timerId; static void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD) { WaitForSingleObject(g_hMutexIm, 3000); - const time_t ts = time(NULL) - 10; + const time_t ts = time(nullptr) - 10; if (lastmodule && ts > laststamp) { FreeLibrary(lastmodule); - lastmodule = NULL; + lastmodule = nullptr; lastdllname.Empty(); } @@ -41,8 +41,8 @@ static void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD) if (g_imagecache.getCount() == 0) { g_imagecache.destroy(); - if (timerId && (timerId + 1) && lastmodule == NULL) { - KillTimer(NULL, timerId); + if (timerId && (timerId + 1) && lastmodule == nullptr) { + KillTimer(nullptr, timerId); timerId = 0; } } @@ -54,7 +54,7 @@ static void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD) static void CALLBACK sttMainThreadCallback(PVOID) { if (timerId == 0xffffffff) - timerId = SetTimer(NULL, 0, 10000, (TIMERPROC)timerProc); + timerId = SetTimer(nullptr, 0, 10000, (TIMERPROC)timerProc); } @@ -66,10 +66,10 @@ static HMODULE LoadDll(const CMStringW &file) FreeLibrary(lastmodule); lastdllname = file; - lastmodule = LoadLibraryEx(file.c_str(), NULL, LOAD_LIBRARY_AS_DATAFILE); + lastmodule = LoadLibraryEx(file.c_str(), nullptr, LOAD_LIBRARY_AS_DATAFILE); } - laststamp = time(NULL); + laststamp = time(nullptr); ReleaseMutex(g_hMutexIm); return lastmodule; @@ -98,7 +98,7 @@ long ImageBase::Release(void) long cnt = m_lRefCount; if (cnt) m_lRefCount = --cnt; - if (cnt == 0) m_timestamp = time(NULL); + if (cnt == 0) m_timestamp = time(nullptr); ReleaseMutex(g_hMutexIm); return cnt; @@ -125,7 +125,7 @@ int ImageBase::CompareImg(const ImageBase *p1, const ImageBase *p2) void ImageBase::Draw(HDC hdc, RECT &rc, bool clip) { - HRGN hrgn = NULL; + HRGN hrgn = nullptr; if (clip) { hrgn = CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom); SelectClipRgn(hdc, hrgn); @@ -146,7 +146,7 @@ void ImageBase::Draw(HDC hdc, RECT &rc, bool clip) DrawInternal(hdc, x, y, scaleX, scaleY); if (clip) { - SelectClipRgn(hdc, NULL); + SelectClipRgn(hdc, nullptr); DeleteObject(hrgn); } } @@ -165,7 +165,7 @@ HBITMAP ImageBase::GetBitmap(COLORREF bkgClr, int sizeX, int sizeY) } HBRUSH hBkgBrush = CreateSolidBrush(bkgClr); - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); HBITMAP hBmp = CreateCompatibleBitmap(hdc, rc.right, rc.bottom); HDC hdcMem = CreateCompatibleDC(hdc); SelectObject(hdcMem, hBmp); @@ -175,7 +175,7 @@ HBITMAP ImageBase::GetBitmap(COLORREF bkgClr, int sizeX, int sizeY) Draw(hdcMem, rc, false); DeleteDC(hdcMem); - ReleaseDC(NULL, hdc); + ReleaseDC(nullptr, hdc); DeleteObject(hBkgBrush); return hBmp; @@ -193,23 +193,23 @@ int ImageBase::SelectNextFrame(const int frame) IconType::IconType(const unsigned id, const CMStringW &file, const int index, const IcoTypeEnum type) : ImageBase(id) { - m_SmileyIcon = NULL; + m_SmileyIcon = nullptr; switch (type) { case icoDll: { const HMODULE hModule = LoadDll(file); - if (hModule != NULL) + if (hModule != nullptr) m_SmileyIcon = (HICON)LoadImage(hModule, MAKEINTRESOURCE(-index), IMAGE_ICON, 0, 0, 0); } break; case icoFile: - m_SmileyIcon = (HICON)LoadImage(NULL, file.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE); + m_SmileyIcon = (HICON)LoadImage(nullptr, file.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE); break; default: - ExtractIconEx(file.c_str(), index, NULL, &m_SmileyIcon, 1); + ExtractIconEx(file.c_str(), index, nullptr, &m_SmileyIcon, 1); break; } } @@ -221,8 +221,8 @@ IconType::~IconType() void IconType::DrawInternal(HDC hdc, int x, int y, int sizeX, int sizeY) { - if (m_SmileyIcon != NULL) - DrawIconEx(hdc, x, y, m_SmileyIcon, sizeX, sizeY, 0, NULL, DI_NORMAL); + if (m_SmileyIcon != nullptr) + DrawIconEx(hdc, x, y, m_SmileyIcon, sizeX, sizeY, 0, nullptr, DI_NORMAL); } HICON IconType::GetIcon(void) @@ -232,7 +232,7 @@ HICON IconType::GetIcon(void) void IconType::GetSize(SIZE &size) { - if (m_SmileyIcon == NULL) + if (m_SmileyIcon == nullptr) return; ICONINFO ii; @@ -264,7 +264,7 @@ void ImageListItemType::DrawInternal(HDC hdc, int x, int y, int sizeX, int sizeY ImageList_Draw(m_hImList, m_index, hdc, x, y, ILD_TRANSPARENT); else { HICON hIcon = ImageList_GetIconFixed(m_hImList, m_index, ILD_TRANSPARENT); - DrawIconEx(hdc, x, y, hIcon, sizeX, sizeY, 0, NULL, DI_NORMAL); + DrawIconEx(hdc, x, y, hIcon, sizeX, sizeY, 0, nullptr, DI_NORMAL); DestroyIcon(hIcon); } } @@ -282,8 +282,8 @@ void ImageListItemType::GetSize(SIZE &size) ImageType::ImageType(const unsigned id, const CMStringW &file, IStream *pStream) : ImageBase(id) { - m_bmp = NULL; - m_pPropertyItem = NULL; + m_bmp = nullptr; + m_pPropertyItem = nullptr; m_nCurrentFrame = 0; m_nFrameCount = 0; @@ -296,7 +296,7 @@ ImageType::ImageType(const unsigned id, const CMStringW &file, IStream *pStream) if (m_bmp->GetLastStatus() != Gdiplus::Ok) { delete m_bmp; - m_bmp = NULL; + m_bmp = nullptr; return; } @@ -313,8 +313,8 @@ ImageType::ImageType(const unsigned id, const CMStringW &file, IStream *pStream) ImageType::ImageType(const unsigned id, const CMStringW &file, const int index, const IcoTypeEnum type) : ImageBase(id) { - m_bmp = NULL; - m_pPropertyItem = NULL; + m_bmp = nullptr; + m_pPropertyItem = nullptr; m_nCurrentFrame = 0; m_nFrameCount = 0; @@ -324,7 +324,7 @@ ImageType::ImageType(const unsigned id, const CMStringW &file, const int index, case icoDll: { const HMODULE hModule = LoadDll(file); - if (hModule != NULL) { + if (hModule != nullptr) { HICON hIcon = (HICON)LoadImage(hModule, MAKEINTRESOURCE(-index), IMAGE_ICON, 0, 0, 0); m_bmp = new Gdiplus::Bitmap(hIcon); DestroyIcon(hIcon); @@ -337,8 +337,8 @@ ImageType::ImageType(const unsigned id, const CMStringW &file, const int index, break; default: - HICON hIcon = NULL; - ExtractIconEx(file.c_str(), index, NULL, &hIcon, 1); + HICON hIcon = nullptr; + ExtractIconEx(file.c_str(), index, nullptr, &hIcon, 1); m_bmp = new Gdiplus::Bitmap(hIcon); DestroyIcon(hIcon); break; @@ -346,7 +346,7 @@ ImageType::ImageType(const unsigned id, const CMStringW &file, const int index, if (m_bmp->GetLastStatus() != Gdiplus::Ok) { delete m_bmp; - m_bmp = NULL; + m_bmp = nullptr; } } @@ -370,7 +370,7 @@ void ImageType::SelectFrame(int frame) void ImageType::DrawInternal(HDC hdc, int x, int y, int sizeX, int sizeY) { - if (m_bmp == NULL) return; + if (m_bmp == nullptr) return; WaitForSingleObject(g_hMutexIm, 3000); @@ -388,9 +388,9 @@ int ImageType::GetFrameDelay(void) const HICON ImageType::GetIcon(void) { - if (m_bmp == NULL) return NULL; + if (m_bmp == nullptr) return nullptr; - HICON hIcon = NULL; + HICON hIcon = nullptr; WaitForSingleObject(g_hMutexIm, 3000); m_bmp->GetHICON(&hIcon); @@ -413,13 +413,13 @@ void ImageType::GetSize(SIZE &size) ImageFType::ImageFType(const unsigned id) : ImageBase(id) { - m_bmp = NULL; + m_bmp = nullptr; } ImageFType::ImageFType(const unsigned id, const CMStringW &file) : ImageBase(id) { - m_bmp = NULL; + m_bmp = nullptr; FREE_IMAGE_FORMAT fif = fei->FI_GetFileTypeU(file.c_str(), 0); if (fif == FIF_UNKNOWN) @@ -427,7 +427,7 @@ ImageFType::ImageFType(const unsigned id, const CMStringW &file) if (fif == FIF_UNKNOWN) return; FIBITMAP *dib = fei->FI_LoadU(fif, file.c_str(), 0); - if (dib == NULL) return; + if (dib == nullptr) return; bool transp = fei->FI_IsTransparent(dib) != 0; FREE_IMAGE_TYPE imt = fei->FI_GetImageType(dib); @@ -458,7 +458,7 @@ ImageFType::~ImageFType() void ImageFType::DrawInternal(HDC hdc, int x, int y, int sizeX, int sizeY) { - if (m_bmp == NULL) return; + if (m_bmp == nullptr) return; HDC hdcImg = CreateCompatibleDC(hdc); HBITMAP oldBmp = (HBITMAP)SelectObject(hdcImg, m_bmp); @@ -480,8 +480,8 @@ void ImageFType::DrawInternal(HDC hdc, int x, int y, int sizeX, int sizeY) HICON ImageFType::GetIcon(void) { - if (m_bmp == NULL) - return NULL; + if (m_bmp == nullptr) + return nullptr; BITMAP bm; GetObject(m_bmp, sizeof(bm), &bm); @@ -490,7 +490,7 @@ HICON ImageFType::GetIcon(void) ii.fIcon = TRUE; ii.xHotspot = 0; ii.yHotspot = 0; - ii.hbmMask = CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1, NULL); + ii.hbmMask = CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1, nullptr); ii.hbmColor = m_bmp; HICON hIcon = CreateIconIndirect(&ii); DeleteObject(ii.hbmMask); @@ -510,14 +510,14 @@ void ImageFType::GetSize(SIZE &size) void InitImageCache(void) { - g_hMutexIm = CreateMutex(NULL, FALSE, NULL); + g_hMutexIm = CreateMutex(nullptr, FALSE, nullptr); } void DestroyImageCache(void) { WaitForSingleObject(g_hMutexIm, 3000); - if (timerId) KillTimer(NULL, timerId); + if (timerId) KillTimer(nullptr, timerId); if (lastmodule) FreeLibrary(lastmodule); g_imagecache.destroy(); @@ -535,10 +535,10 @@ ImageBase* AddCacheImage(const CMStringW &file, int index) ImageBase srch(id); ImageBase *img = g_imagecache.find(&srch); - if (img == NULL) { + if (img == nullptr) { int ind = file.ReverseFind('.'); if (ind == -1) - return NULL; + return nullptr; CMStringW ext = file.Mid(ind + 1); ext.MakeLower(); @@ -549,17 +549,17 @@ ImageBase* AddCacheImage(const CMStringW &file, int index) else if (ext == L"icl") img = opt.HQScaling ? (ImageBase*)new ImageType(id, file, index, icoIcl) : (ImageBase*)new IconType(id, file, index, icoIcl); else if (ext == L"gif") - img = new ImageType(id, file, NULL); - else if (fei == NULL || ext == L"tif" || ext == L"tiff") - img = new ImageType(id, file, NULL); + img = new ImageType(id, file, nullptr); + else if (fei == nullptr || ext == L"tif" || ext == L"tiff") + img = new ImageType(id, file, nullptr); else - img = opt.HQScaling ? (ImageBase*)new ImageType(id, file, NULL) : (ImageBase*)new ImageFType(id, file); + img = opt.HQScaling ? (ImageBase*)new ImageType(id, file, nullptr) : (ImageBase*)new ImageFType(id, file); g_imagecache.insert(img); if (timerId == 0) { timerId = 0xffffffff; - CallFunctionAsync(sttMainThreadCallback, NULL); + CallFunctionAsync(sttMainThreadCallback, nullptr); } } else img->AddRef(); diff --git a/plugins/SmileyAdd/src/options.cpp b/plugins/SmileyAdd/src/options.cpp index 30a6bd2798..b0fd12b50b 100644 --- a/plugins/SmileyAdd/src/options.cpp +++ b/plugins/SmileyAdd/src/options.cpp @@ -43,7 +43,7 @@ private: void PopulateSmPackList(void); void UpdateVisibleSmPackList(void); void UserAction(HTREEITEM hItem); - long GetSelProto(HTREEITEM hItem = NULL); + long GetSelProto(HTREEITEM hItem = nullptr); public: OptionsDialogType(HWND hWnd) { m_hwndDialog = hWnd; } @@ -245,7 +245,7 @@ void OptionsDialogType::SetChanged(void) void OptionsDialogType::UpdateControls(bool force) { const SmileyCategoryType *smc = tmpsmcat.GetSmileyCategory(GetSelProto()); - if (smc == NULL) + if (smc == nullptr) return; const CMStringW &smf = smc->GetFilename(); @@ -268,7 +268,7 @@ long OptionsDialogType::GetSelProto(HTREEITEM hItem) TVITEM tvi = { 0 }; tvi.mask = TVIF_PARAM; - tvi.hItem = hItem == NULL ? TreeView_GetSelection(hLstView) : hItem; + tvi.hItem = hItem == nullptr ? TreeView_GetSelection(hLstView) : hItem; TreeView_GetItem(hLstView, &tvi); @@ -300,7 +300,7 @@ void OptionsDialogType::UpdateVisibleSmPackList(void) if (!ProtoName.IsEmpty()) { PhysProtoName += ProtoName; SmileyCategoryType *scm = tmpsmcat.GetSmileyCategory(PhysProtoName); - if (scm == NULL) + if (scm == nullptr) visible = false; else if (scm->GetFilename().IsEmpty()) visible = true; @@ -318,7 +318,7 @@ void OptionsDialogType::PopulateSmPackList(void) TreeView_SelectItem(hLstView, NULL); TreeView_DeleteAllItems(hLstView); - TVINSERTSTRUCT tvi = { 0 }; + TVINSERTSTRUCT tvi = {}; tvi.hParent = TVI_ROOT; tvi.hInsertAfter = TVI_LAST; tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_STATE | TVIF_SELECTEDIMAGE | TVIF_PARAM; @@ -389,13 +389,13 @@ void OptionsDialogType::InitDialog(void) SmileyCategoryListType::SmileyCategoryVectorType &smc = *g_SmileyCategories.GetSmileyCategoryList(); for (int i = 0; i < smc.getCount(); i++) { - HICON hIcon = NULL; + HICON hIcon = nullptr; if (smc[i].IsProto()) { hIcon = (HICON)CallProtoService(_T2A(smc[i].GetName().c_str()), PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0); - if (hIcon == NULL || (INT_PTR)hIcon == CALLSERVICE_NOTFOUND) + if (hIcon == nullptr || (INT_PTR)hIcon == CALLSERVICE_NOTFOUND) hIcon = (HICON)CallProtoService(_T2A(smc[i].GetName().c_str()), PS_LOADICON, PLI_PROTOCOL, 0); } - if (hIcon == NULL || hIcon == (HICON)CALLSERVICE_NOTFOUND) + if (hIcon == nullptr || hIcon == (HICON)CALLSERVICE_NOTFOUND) hIcon = GetDefaultIcon(); ImageList_AddIcon(hImList, hIcon); @@ -437,8 +437,8 @@ void OptionsDialogType::ApplyChanges(void) opt.HorizontalSorting = IsDlgButtonChecked(m_hwndDialog, IDC_SORTING_HORIZONTAL) == BST_CHECKED; opt.ButtonStatus = (unsigned)SendDlgItemMessage(m_hwndDialog, IDC_SMLBUT, CB_GETCURSEL, 0, 0); - opt.MaxCustomSmileySize = GetDlgItemInt(m_hwndDialog, IDC_MAXCUSTSMSZ, NULL, FALSE); - opt.MinSmileySize = GetDlgItemInt(m_hwndDialog, IDC_MINSMSZ, NULL, FALSE); + opt.MaxCustomSmileySize = GetDlgItemInt(m_hwndDialog, IDC_MAXCUSTSMSZ, nullptr, FALSE); + opt.MinSmileySize = GetDlgItemInt(m_hwndDialog, IDC_MINSMSZ, nullptr, FALSE); opt.Save(); @@ -446,7 +446,7 @@ void OptionsDialogType::ApplyChanges(void) CMStringW empty; SmileyCategoryListType::SmileyCategoryVectorType &smc = *g_SmileyCategories.GetSmileyCategoryList(); for (int i = 0; i < smc.getCount(); i++) - if (tmpsmcat.GetSmileyCategory(smc[i].GetName()) == NULL) + if (tmpsmcat.GetSmileyCategory(smc[i].GetName()) == nullptr) opt.WritePackFileName(empty, smc[i].GetName()); g_SmileyCategories = tmpsmcat; @@ -530,7 +530,7 @@ void OptionsDialogType::ShowSmileyPreview(void) SmileyToolWindowParam *stwp = new SmileyToolWindowParam; stwp->pSmileyPack = &smPack; stwp->hWndParent = m_hwndDialog; - stwp->hWndTarget = NULL; + stwp->hWndTarget = nullptr; stwp->targetMessage = 0; stwp->targetWParam = 0; stwp->xPosition = rect.left; @@ -637,7 +637,7 @@ void OptionsType::WriteContactCategory(MCONTACT hContact, const CMStringW &cats) static INT_PTR CALLBACK DlgProcSmileysOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { OptionsDialogType *pOD = (OptionsDialogType*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - if (pOD == NULL) { + if (pOD == nullptr) { pOD = new OptionsDialogType(hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)pOD); } diff --git a/plugins/SmileyAdd/src/regexp/WCPattern.cpp b/plugins/SmileyAdd/src/regexp/WCPattern.cpp index 2ce1a1b301..e2b99b6f3e 100644 --- a/plugins/SmileyAdd/src/regexp/WCPattern.cpp +++ b/plugins/SmileyAdd/src/regexp/WCPattern.cpp @@ -64,13 +64,13 @@ static inline int str_icmp(const wchar_t *a, const wchar_t *b) WCPattern::WCPattern(const CMStringW &rhs) { - matcher = NULL; + matcher = nullptr; pattern = rhs; curInd = 0; groupCount = 0; nonCapGroupCount = 0; error = 0; - head = NULL; + head = nullptr; } // convenient function in case we want to add any extra debugging output @@ -165,7 +165,7 @@ bool WCPattern::quantifyCurly(int &sNum, int &eNum) NFAUNode* WCPattern::quantifyGroup(NFAUNode *start, NFAUNode *stop, const int gn) { - NFAUNode *newNode = NULL; + NFAUNode *newNode = nullptr; int type = 0; if (curInd < pattern.GetLength()) { @@ -218,7 +218,7 @@ NFAUNode* WCPattern::quantifyGroup(NFAUNode *start, NFAUNode *stop, const int gn } } } - return NULL; + return nullptr; } NFAUNode* WCPattern::quantify(NFAUNode *newNode) @@ -531,15 +531,15 @@ NFAUNode* WCPattern::parseRegisteredWCPattern(NFAUNode **end) { int i, j; CMStringW s; - NFAUNode *ret = NULL; + NFAUNode *ret = nullptr; for (i = curInd; i < pattern.GetLength() && pattern[i] != '}'; ++i) {} - if (pattern[i] != '}') { raiseError(); return NULL; } - if (i == curInd + 1) { raiseError(); return NULL; } // {} + if (pattern[i] != '}') { raiseError(); return nullptr; } + if (i == curInd + 1) { raiseError(); return nullptr; } // {} if (!((pattern[curInd] >= 'a' && pattern[curInd] <= 'z') || (pattern[curInd] >= 'A' && pattern[curInd] <= 'Z') || (pattern[curInd] == '_'))) { raiseError(); - return NULL; + return nullptr; } for (j = curInd; !error && j < i; ++j) { @@ -548,7 +548,7 @@ NFAUNode* WCPattern::parseRegisteredWCPattern(NFAUNode **end) (pattern[j] >= '0' && pattern[j] <= '9') || (pattern[j] == '_'))) { raiseError(); - return NULL; + return nullptr; } } s = pattern.Mid(curInd, i - curInd); @@ -569,7 +569,7 @@ NFAUNode* WCPattern::parseRegisteredWCPattern(NFAUNode **end) curInd = ci; flags = oflags; } - if (error) { *end = ret = NULL; } + if (error) { *end = ret = nullptr; } return ret; } @@ -620,7 +620,7 @@ NFAUNode* WCPattern::parseQuote() } NFAUNode* WCPattern::parse(const bool inParen, const bool inOr, NFAUNode **end) { - NFAUNode *start, *cur, *next = NULL; + NFAUNode *start, *cur, *next = nullptr; CMStringW t; int grc = groupCount++; bool inv, quo; @@ -642,7 +642,7 @@ NFAUNode* WCPattern::parse(const bool inParen, const bool inOr, NFAUNode **end) while (!done) { if (curInd >= pattern.GetLength()) { raiseError(); - return NULL; + return nullptr; } else if (negate) { switch (pattern[curInd]) { @@ -658,7 +658,7 @@ NFAUNode* WCPattern::parse(const bool inParen, const bool inOr, NFAUNode **end) case '-': default: raiseError(); - return NULL; + return nullptr; } } else { @@ -675,7 +675,7 @@ NFAUNode* WCPattern::parse(const bool inParen, const bool inOr, NFAUNode **end) return *end; default: raiseError(); - return NULL; + return nullptr; } } ++curInd; @@ -694,8 +694,8 @@ NFAUNode* WCPattern::parse(const bool inParen, const bool inOr, NFAUNode **end) while (curInd < pattern.GetLength()) { wchar_t ch = pattern[curInd++]; - next = NULL; - if (error) return NULL; + next = nullptr; + if (error) return nullptr; switch (ch) { case '^': if ((flags & WCPattern::MULTILINE_MATCHING) != 0) next = registerNode(new NFAStartOfLineUNode); @@ -774,7 +774,7 @@ NFAUNode* WCPattern::parse(const bool inParen, const bool inOr, NFAUNode **end) NFAUNode *pEnd, *t1, *t2; t1 = parse(1, 0, &pEnd); if (!t1) raiseError(); - else if (t1->isGroupHeadNode() && (t2 = quantifyGroup(t1, pEnd, grc)) != NULL) { + else if (t1->isGroupHeadNode() && (t2 = quantifyGroup(t1, pEnd, grc)) != nullptr) { cur->next = t2; cur = t2->next; } @@ -840,7 +840,7 @@ NFAUNode* WCPattern::parse(const bool inParen, const bool inOr, NFAUNode **end) } flags = oldFlags; - if (error) return NULL; + if (error) return nullptr; return start; } @@ -861,7 +861,7 @@ WCPattern* WCPattern::compile(const CMStringW &pattern, const unsigned long mode p->head = p->parse(0, 0, &end); if (!p->head) { delete p; - p = NULL; + p = nullptr; } else { if (!(p->head && p->head->isStartOfInputNode())) { @@ -873,7 +873,7 @@ WCPattern* WCPattern::compile(const CMStringW &pattern, const unsigned long mode } } - if (p != NULL) + if (p != nullptr) p->matcher = new WCMatcher(p, L""); return p; @@ -881,7 +881,7 @@ WCPattern* WCPattern::compile(const CMStringW &pattern, const unsigned long mode WCPattern* WCPattern::compileAndKeep(const CMStringW &pattern, const unsigned long mode) { - WCPattern *ret = NULL; + WCPattern *ret = nullptr; std::map::iterator it = compiledWCPatterns.find(pattern); if (it != compiledWCPatterns.end()) ret = it->second; @@ -1060,7 +1060,7 @@ WCMatcher *WCPattern::createWCMatcher(const CMStringW &str) // NFAUNode -NFAUNode::NFAUNode() { next = NULL; } +NFAUNode::NFAUNode() { next = nullptr; } NFAUNode::~NFAUNode() {} void NFAUNode::findAllNodes(std::map &soFar) { diff --git a/plugins/SmileyAdd/src/richcall.cpp b/plugins/SmileyAdd/src/richcall.cpp index fcfcdac239..67ab0a5c98 100644 --- a/plugins/SmileyAdd/src/richcall.cpp +++ b/plugins/SmileyAdd/src/richcall.cpp @@ -107,7 +107,7 @@ static void SetTooltip(long x, long y, HWND hwnd, RichEditData *rdt) if (needtip != -1) { if (rdt->tipActive == -1) { rdt->hToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, L"", TTS_NOPREFIX | WS_POPUP, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, NULL, g_hInst, NULL); + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, nullptr, g_hInst, nullptr); SendMessage(rdt->hToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti); } @@ -119,7 +119,7 @@ static void SetTooltip(long x, long y, HWND hwnd, RichEditData *rdt) else if (rdt->tipActive != -1) { SendMessage(rdt->hToolTip, TTM_ACTIVATE, FALSE, 0); DestroyWindow(rdt->hToolTip); - rdt->hToolTip = NULL; + rdt->hToolTip = nullptr; } rdt->tipActive = needtip; @@ -130,8 +130,8 @@ static const CHARRANGE allsel = { 0, LONG_MAX }; static void ReplaceContactSmileys(RichEditData *rdt, const CHARRANGE &sel, bool ignoreLast, bool unFreeze) { if ((rdt->inputarea && !opt.InputSmileys) || rdt->dontReplace) return; - SmileyPackCType *smcp = NULL; - SmileyPackType *SmileyPack = GetSmileyPack(NULL, rdt->hContact, rdt->inputarea ? NULL : &smcp); + SmileyPackCType *smcp = nullptr; + SmileyPackType *SmileyPack = GetSmileyPack(nullptr, rdt->hContact, rdt->inputarea ? nullptr : &smcp); ReplaceSmileys(rdt->hwnd, SmileyPack, smcp, sel, false, ignoreLast, unFreeze); } @@ -161,13 +161,13 @@ static void SmileyToTextCutRest(RichEditData *rdt) SendMessage(rdt->hwnd, EM_EXGETSEL, 0, (LPARAM)&sel); ReplaceContactSmileys(rdt, sel, false, true); SendMessage(rdt->hwnd, WM_SETREDRAW, TRUE, 0); - RedrawWindow(rdt->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); + RedrawWindow(rdt->hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW); } static LRESULT CALLBACK RichEditSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { RichEditData *rdt = g_RichEditList.find((RichEditData*)&hwnd); - if (rdt == NULL) + if (rdt == nullptr) return 0; CHARRANGE sel; @@ -294,7 +294,7 @@ static LRESULT CALLBACK RichEditSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LP bool SetRichCallback(HWND hwnd, MCONTACT hContact, bool subany, bool subnew) { RichEditData *rdt = g_RichEditList.find((RichEditData*)&hwnd); - if (rdt == NULL) { + if (rdt == nullptr) { CComPtr RichEditOle; if (SendMessage(hwnd, EM_GETOLEINTERFACE, 0, (LPARAM)&RichEditOle) == 0) return false; @@ -338,7 +338,7 @@ void CloseRichCallback(HWND hwnd) static LRESULT CALLBACK RichEditOwnerSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { RichEditOwnerData *rdto = g_RichEditOwnerList.find((RichEditOwnerData*)&hwnd); - if (rdto == NULL) + if (rdto == nullptr) return 0; switch (uMsg) { @@ -383,7 +383,7 @@ static LRESULT CALLBACK RichEditOwnerSubclass(HWND hwnd, UINT uMsg, WPARAM wPara void SetRichOwnerCallback(HWND hwnd, HWND hwndInput, HWND hwndLog) { RichEditOwnerData *rdto = g_RichEditOwnerList.find((RichEditOwnerData*)&hwnd); - if (rdto == NULL) { + if (rdto == nullptr) { rdto = new RichEditOwnerData; rdto->hwnd = hwnd; rdto->hwndInput = hwndInput; @@ -396,9 +396,9 @@ void SetRichOwnerCallback(HWND hwnd, HWND hwndInput, HWND hwndLog) mir_subclassWindow(hwnd, RichEditOwnerSubclass); } else { - if (rdto->hwndInput == NULL) + if (rdto->hwndInput == nullptr) rdto->hwndInput = hwndInput; - if (rdto->hwndLog == NULL) + if (rdto->hwndLog == nullptr) rdto->hwndLog = hwndLog; } } diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp index 33bb7fb796..c4583145d3 100644 --- a/plugins/SmileyAdd/src/services.cpp +++ b/plugins/SmileyAdd/src/services.cpp @@ -28,23 +28,23 @@ SmileyPackType* GetSmileyPack(const char *proto, MCONTACT hContact, SmileyPackCT { hContact = DecodeMetaContact(hContact); if (smlc) - *smlc = opt.DisableCustom ? NULL : g_SmileyPackCStore.GetSmileyPack(hContact); + *smlc = opt.DisableCustom ? nullptr : g_SmileyPackCStore.GetSmileyPack(hContact); - if (proto != NULL && IsBadStringPtrA(proto, 10)) - return NULL; + if (proto != nullptr && IsBadStringPtrA(proto, 10)) + return nullptr; CMStringW categoryName; if (hContact != NULL) { opt.ReadContactCategory(hContact, categoryName); - if (categoryName == L"") return NULL; - if (!categoryName.IsEmpty() && g_SmileyCategories.GetSmileyCategory(categoryName) == NULL) { + if (categoryName == L"") return nullptr; + if (!categoryName.IsEmpty() && g_SmileyCategories.GetSmileyCategory(categoryName) == nullptr) { categoryName.Empty(); opt.WriteContactCategory(hContact, categoryName); } if (categoryName.IsEmpty() && !opt.UseOneForAll) { char *protonam = GetContactProto(hContact); - if (protonam != NULL) { + if (protonam != nullptr) { DBVARIANT dbv; if (db_get_ws(hContact, protonam, "Transport", &dbv) == 0) { categoryName = dbv.ptszVal; @@ -65,13 +65,13 @@ SmileyPackType* GetSmileyPack(const char *proto, MCONTACT hContact, SmileyPackCT } if (categoryName.IsEmpty()) { - if (proto == NULL || proto[0] == 0) + if (proto == nullptr || proto[0] == 0) categoryName = L"Standard"; else { categoryName = _A2T(proto); if (opt.UseOneForAll) { SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(categoryName); - if (smc == NULL || smc->IsProto()) + if (smc == nullptr || smc->IsProto()) categoryName = L"Standard"; } } @@ -84,19 +84,19 @@ SmileyPackType* GetSmileyPack(const char *proto, MCONTACT hContact, SmileyPackCT INT_PTR ReplaceSmileysCommand(WPARAM, LPARAM lParam) { SMADD_RICHEDIT3 *smre = (SMADD_RICHEDIT3*)lParam; - if (smre == NULL) + if (smre == nullptr) return FALSE; SMADD_RICHEDIT3 smrec = { 0 }; memcpy(&smrec, smre, min(smre->cbSize, sizeof(smrec))); static const CHARRANGE selection = { 0, LONG_MAX }; - if (smre->rangeToReplace == NULL) smrec.rangeToReplace = (CHARRANGE*)&selection; + if (smre->rangeToReplace == nullptr) smrec.rangeToReplace = (CHARRANGE*)&selection; else if (smrec.rangeToReplace->cpMax < 0) smrec.rangeToReplace->cpMax = LONG_MAX; - SmileyPackCType *smcp = NULL; + SmileyPackCType *smcp = nullptr; SmileyPackType *SmileyPack = GetSmileyPack(smrec.Protocolname, smrec.hContact, - (smrec.flags & (SAFLRE_OUTGOING | SAFLRE_NOCUSTOM)) ? NULL : &smcp); + (smrec.flags & (SAFLRE_OUTGOING | SAFLRE_NOCUSTOM)) ? nullptr : &smcp); ReplaceSmileys(smre->hwndRichEditControl, SmileyPack, smcp, *smrec.rangeToReplace, smrec.hContact == NULL, false, false, (smre->flags & SAFLRE_FIREVIEW) ? true : false); @@ -109,7 +109,7 @@ INT_PTR ShowSmileySelectionCommand(WPARAM, LPARAM lParam) { SMADD_SHOWSEL3 *smaddInfo = (SMADD_SHOWSEL3*)lParam; - if (smaddInfo == NULL) return FALSE; + if (smaddInfo == nullptr) return FALSE; HWND parent = smaddInfo->hwndParent; MCONTACT hContact = smaddInfo->hContact; @@ -133,13 +133,13 @@ INT_PTR ShowSmileySelectionCommand(WPARAM, LPARAM lParam) static int GetInfoCommandE(SMADD_INFO2 *smre, bool retDup) { - if (smre == NULL) return FALSE; + if (smre == nullptr) return FALSE; MCONTACT hContact = smre->hContact; SmileyPackType *SmileyPack = GetSmileyPack(smre->Protocolname, hContact); - if (SmileyPack == NULL || SmileyPack->SmileyCount() == 0) { - smre->ButtonIcon = NULL; + if (SmileyPack == nullptr || SmileyPack->SmileyCount() == 0) { + smre->ButtonIcon = nullptr; smre->NumberOfSmileys = 0; smre->NumberOfVisibleSmileys = 0; return FALSE; @@ -147,7 +147,7 @@ static int GetInfoCommandE(SMADD_INFO2 *smre, bool retDup) SmileyType *sml = FindButtonSmiley(SmileyPack); - if (sml != NULL) + if (sml != nullptr) smre->ButtonIcon = retDup ? sml->GetIconDup() : sml->GetIcon(); else smre->ButtonIcon = GetDefaultIcon(retDup); @@ -176,12 +176,12 @@ INT_PTR ParseTextBatch(WPARAM, LPARAM lParam) { SMADD_BATCHPARSE2 *smre = (SMADD_BATCHPARSE2*)lParam; - if (smre == NULL) return FALSE; + if (smre == nullptr) return FALSE; MCONTACT hContact = smre->hContact; - SmileyPackCType *smcp = NULL; + SmileyPackCType *smcp = nullptr; SmileyPackType *SmileyPack = GetSmileyPack(smre->Protocolname, hContact, - (smre->flag & (SAFL_OUTGOING | SAFL_NOCUSTOM)) ? NULL : &smcp); + (smre->flag & (SAFL_OUTGOING | SAFL_NOCUSTOM)) ? nullptr : &smcp); SmileysQueueType smllist; @@ -231,7 +231,7 @@ INT_PTR RegisterPack(WPARAM, LPARAM lParam) { SMADD_REGCAT *smre = (SMADD_REGCAT*)lParam; - if (smre == NULL || smre->cbSize < sizeof(SMADD_REGCAT)) return FALSE; + if (smre == nullptr || smre->cbSize < sizeof(SMADD_REGCAT)) return FALSE; if (IsBadStringPtrA(smre->name, 50) || IsBadStringPtrA(smre->dispname, 50)) return FALSE; @@ -246,7 +246,7 @@ INT_PTR CustomCatMenu(WPARAM hContact, LPARAM lParam) { if (lParam != 0) { SmileyCategoryType *smct = g_SmileyCategories.GetSmileyCategory((unsigned)lParam - 3); - if (smct != NULL) + if (smct != nullptr) opt.WriteContactCategory(hContact, smct->GetName()); else { CMStringW empty; @@ -342,7 +342,7 @@ INT_PTR ReloadPack(WPARAM, LPARAM lParam) if (lParam) { CMStringW categoryName = _A2T((char*)lParam); SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(categoryName); - if (smc != NULL) + if (smc != nullptr) smc->Load(); } else { @@ -381,7 +381,7 @@ int AccountListChanged(WPARAM wParam, LPARAM lParam) switch (wParam) { case PRAC_ADDED: - if (acc != NULL) { + if (acc != nullptr) { CMStringW catname(L"Standard"); const CMStringW &defaultFile = g_SmileyCategories.GetSmileyCategory(catname)->GetFilename(); g_SmileyCategories.AddAccountAsCategory(acc, defaultFile); @@ -389,10 +389,10 @@ int AccountListChanged(WPARAM wParam, LPARAM lParam) break; case PRAC_CHANGED: - if (acc != NULL && acc->szModuleName != NULL) { + if (acc != nullptr && acc->szModuleName != nullptr) { CMStringW name(_A2T(acc->szModuleName)); SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(name); - if (smc != NULL) { + if (smc != nullptr) { if (acc->tszAccountName) name = acc->tszAccountName; smc->SetDisplayName(name); } @@ -404,7 +404,7 @@ int AccountListChanged(WPARAM wParam, LPARAM lParam) break; case PRAC_CHECKED: - if (acc != NULL) { + if (acc != nullptr) { if (acc->bIsEnabled) { CMStringW catname(L"Standard"); const CMStringW &defaultFile = g_SmileyCategories.GetSmileyCategory(catname)->GetFilename(); @@ -429,7 +429,7 @@ int DbSettingChanged(WPARAM hContact, LPARAM lParam) if (strcmp(cws->szSetting, "Transport") == 0) { CMStringW catname(L"Standard"); SmileyCategoryType *smc = g_SmileyCategories.GetSmileyCategory(catname); - if (smc != NULL) + if (smc != nullptr) g_SmileyCategories.AddContactTransportAsCategory(hContact, smc->GetFilename()); } return 0; diff --git a/plugins/SmileyAdd/src/smileyroutines.cpp b/plugins/SmileyAdd/src/smileyroutines.cpp index 2dbc049b16..2741cab5d6 100644 --- a/plugins/SmileyAdd/src/smileyroutines.cpp +++ b/plugins/SmileyAdd/src/smileyroutines.cpp @@ -32,10 +32,10 @@ const GUID IID_ITextDocument = void LookupAllSmileys(SmileyPackType *smileyPack, SmileyPackCType *smileyCPack, const wchar_t *lpstrText, SmileysQueueType &smllist, const bool firstOnly) { - if (lpstrText == NULL || *lpstrText == 0) return; + if (lpstrText == nullptr || *lpstrText == 0) return; - SmileyPackType::SmileyLookupType *sml = smileyPack ? smileyPack->GetSmileyLookup() : NULL; - SmileyPackCType::SmileyLookupType *smlc = smileyCPack ? &smileyCPack->GetSmileyLookup() : NULL; + SmileyPackType::SmileyLookupType *sml = smileyPack ? smileyPack->GetSmileyLookup() : nullptr; + SmileyPackCType::SmileyLookupType *smlc = smileyCPack ? &smileyCPack->GetSmileyLookup() : nullptr; // Precompute number of smileys int smlszo = sml ? sml->getCount() : 0; @@ -72,7 +72,7 @@ void LookupAllSmileys(SmileyPackType *smileyPack, SmileyPackCType *smileyCPack, while (true) { int firstSml = -1; int firstSmlRef = -1; - SmileyLookup::SmileyLocVecType *smlf = NULL; + SmileyLookup::SmileyLocVecType *smlf = nullptr; for (int csml=0; csml < smlsz; csml++) { SmileyLookup::SmileyLocVecType &smlv = smileys[csml]; @@ -106,7 +106,7 @@ void LookupAllSmileys(SmileyPackType *smileyPack, SmileyPackCType *smileyCPack, // check if leading space exist const wchar_t *prech = _wcsdec(textToSearch, textSmlStart); - dat->ldspace = prech != NULL ? iswspace(*prech) != 0 : smloff == 0; + dat->ldspace = prech != nullptr ? iswspace(*prech) != 0 : smloff == 0; // check if trailing space exist dat->trspace = *textSmlEnd == 0 || iswspace(*textSmlEnd); @@ -121,14 +121,14 @@ void LookupAllSmileys(SmileyPackType *smileyPack, SmileyPackCType *smileyCPack, if (firstSml < smlszo) { dat->sml = smileyPack->GetSmiley((*sml)[firstSml].GetIndex()); - dat->smlc = NULL; + dat->smlc = nullptr; } else { dat->smlc = smileyCPack->GetSmiley((*smlc)[firstSml-smlszo].GetIndex()); - dat->sml = NULL; + dat->sml = nullptr; } - if (dat->sml != NULL || dat->smlc != NULL) { + if (dat->sml != nullptr || dat->smlc != nullptr) { // First smiley found record it smllist.insert(dat); if (firstOnly) break; @@ -148,10 +148,10 @@ void LookupAllSmileys(SmileyPackType *smileyPack, SmileyPackCType *smileyCPack, void FindSmileyInText(SmileyPackType *smp, const wchar_t *str, unsigned &first, unsigned &size, SmileyType **sml) { SmileysQueueType smllist; - LookupAllSmileys(smp, NULL, str, smllist, true); + LookupAllSmileys(smp, nullptr, str, smllist, true); if (smllist.getCount() == 0) { size = 0; - *sml = NULL; + *sml = nullptr; } else { first = smllist[0].loc.cpMin; @@ -190,7 +190,7 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType *smp, SmileyPackCType *smcp, const CComPtr RichEditOle; if (SendMessage(hwnd, EM_GETOLEINTERFACE, 0, (LPARAM)&RichEditOle) == 0) return; - if (RichEditOle == NULL) + if (RichEditOle == nullptr) return; CComPtr TextDocument; @@ -198,7 +198,7 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType *smp, SmileyPackCType *smcp, const return; long cnt; - if (smp == NULL && smcp == NULL) { + if (smp == nullptr && smcp == nullptr) { if (unFreeze) TextDocument->Unfreeze(&cnt); return; @@ -210,7 +210,7 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType *smp, SmileyPackCType *smcp, const return; // retrieve text to parse for smileys - BSTR btxt = 0; + BSTR btxt = nullptr; if (TextRange->GetText(&btxt) != S_OK) return; @@ -296,15 +296,15 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType *smp, SmileyPackCType *smcp, const SmileyType *sml = smllist[j].sml; SmileyCType *smlc = smllist[j].smlc; - if (sml == NULL && smlc == NULL) + if (sml == nullptr && smlc == nullptr) continue; // Select text analyze TextSelection->SetRange(smlpos.cpMin, smlpos.cpMax); - BSTR bstrText = NULL; + BSTR bstrText = nullptr; - if (smlc == NULL && sml->IsText()) { + if (smlc == nullptr && sml->IsText()) { bstrText = SysAllocString(sml->GetToolText().c_str()); TextSelection->SetText(bstrText); } @@ -343,7 +343,7 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType *smp, SmileyPackCType *smcp, const sizeY = osize.cy; } - if (smlc != NULL && opt.MaxCustomSmileySize && (unsigned)sizeY > opt.MaxCustomSmileySize) { + if (smlc != nullptr && opt.MaxCustomSmileySize && (unsigned)sizeY > opt.MaxCustomSmileySize) { sizeY = opt.MaxCustomSmileySize; sizeX = osize.cx * sizeY / osize.cy; @@ -391,13 +391,13 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType *smp, SmileyPackCType *smcp, const else UpdateSelection(oldSel, smlpos.cpMin, -(int)SysStringLen(bstrText)+1); ISmileyBase *smileyBase = CreateAniSmileyObject(smlc ? smlc : sml, chf.crBackColor, ishpp); - if (smileyBase == NULL) + if (smileyBase == nullptr) continue; smileyBase->SetExtent(DVASPECT_CONTENT, &sizehm); smileyBase->SetHint(bstrText); - smileyBase->SetPosition(hwnd, NULL); + smileyBase->SetPosition(hwnd, nullptr); // Get the RichEdit container site IOleClientSite *pOleClientSite; @@ -448,10 +448,10 @@ void ReplaceSmileys(HWND hwnd, SmileyPackType *smp, SmileyPackCType *smcp, const void ReplaceSmileysWithText(HWND hwnd, CHARRANGE &sel, bool keepFrozen) { - CComPtr RichEditOle = NULL; + CComPtr RichEditOle = nullptr; if (SendMessage(hwnd, EM_GETOLEINTERFACE, 0, (LPARAM)&RichEditOle) == 0) return; - if (RichEditOle == NULL) + if (RichEditOle == nullptr) return; CComPtr TextDocument; @@ -487,17 +487,17 @@ void ReplaceSmileysWithText(HWND hwnd, CHARRANGE &sel, bool keepFrozen) break; } - ISmileyBase *igsc = NULL; + ISmileyBase *igsc = nullptr; if (reObj.cp < sel.cpMax && reObj.clsid == CLSID_NULL) reObj.poleobj->QueryInterface(IID_ISmileyAddSmiley, (void**) &igsc); reObj.poleobj->Release(); - if (igsc == NULL) + if (igsc == nullptr) continue; TextRange->SetRange(reObj.cp, reObj.cp + 1); - BSTR bstr = NULL; + BSTR bstr = nullptr; igsc->GetTooltip(&bstr); TextRange->SetText(bstr); diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp index c08b7f4bb6..f66a6e374e 100644 --- a/plugins/SmileyAdd/src/smileys.cpp +++ b/plugins/SmileyAdd/src/smileys.cpp @@ -23,7 +23,7 @@ along with this program. If not, see . SmileyPackListType g_SmileyPacks; SmileyCategoryListType g_SmileyCategories; -static HWND hwndHidden = NULL; +static HWND hwndHidden = nullptr; static void CALLBACK timerProc(HWND, UINT, UINT_PTR param, DWORD) { @@ -34,8 +34,8 @@ static void CALLBACK timerProc(HWND, UINT, UINT_PTR param, DWORD) // these two functions must be called from the main thread static void CALLBACK sttStartTimer(PVOID obj) { - if (hwndHidden == NULL) - hwndHidden = CreateWindowEx(0, L"STATIC", NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL); + if (hwndHidden == nullptr) + hwndHidden = CreateWindowEx(0, L"STATIC", nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr); SmileyType *pType = (SmileyType*)obj; pType->SetFrameDelay(); @@ -53,8 +53,8 @@ static void CALLBACK sttStopTimer(PVOID obj) SmileyType::SmileyType(void) : m_arSmileys(10, PtrKeySortT) { - m_SmileyIcon = NULL; - m_xepimg = NULL; + m_SmileyIcon = nullptr; + m_xepimg = nullptr; m_flags = 0; m_index = 0; m_size.cx = 0; @@ -65,19 +65,19 @@ SmileyType::~SmileyType() { if (m_xepimg) { m_xepimg->Release(); - m_xepimg = NULL; + m_xepimg = nullptr; } - if (m_SmileyIcon != NULL) { + if (m_SmileyIcon != nullptr) { DestroyIcon(m_SmileyIcon); - m_SmileyIcon = NULL; + m_SmileyIcon = nullptr; } } void SmileyType::AddObject(ISmileyBase *pObject) { if (m_arSmileys.getCount() == 0) { - if (m_xepimg == NULL) + if (m_xepimg == nullptr) m_xepimg = AddCacheImage(m_filepath, m_index); CallFunctionAsync(sttStartTimer, this); } @@ -98,7 +98,7 @@ void SmileyType::RemoveObject(ISmileyBase *pObject) void SmileyType::SetFrameDelay() { - int iFrameDelay = (m_xepimg == NULL) ? 0 : m_xepimg->GetFrameDelay(); + int iFrameDelay = (m_xepimg == nullptr) ? 0 : m_xepimg->GetFrameDelay(); if (iFrameDelay <= 0) KillTimer(hwndHidden, (DWORD_PTR)this); else @@ -117,10 +117,10 @@ void SmileyType::MoveToNextFrame() HICON SmileyType::GetIcon(void) { - if (m_SmileyIcon == NULL) { + if (m_SmileyIcon == nullptr) { ImageBase *img = CreateCachedImage(); if (!img) - return NULL; + return nullptr; img->SelectFrame(m_index); m_SmileyIcon = img->GetIcon(); @@ -185,7 +185,7 @@ void SmileyType::SetImList(HIMAGELIST hImLst, long i) HBITMAP SmileyType::GetBitmap(COLORREF bkgClr, int sizeX, int sizeY) { ImageBase *img = CreateCachedImage(); - if (!img) return NULL; + if (!img) return nullptr; img->SelectFrame(m_index); HBITMAP hBmp = img->GetBitmap(bkgClr, sizeX, sizeY); img->Release(); @@ -199,18 +199,18 @@ HBITMAP SmileyType::GetBitmap(COLORREF bkgClr, int sizeX, int sizeY) SmileyPackType::SmileyPackType() { - m_hSmList = NULL; + m_hSmList = nullptr; errorFound = false; } SmileyType* SmileyPackType::GetSmiley(unsigned index) { - return (index < (unsigned)m_SmileyList.getCount()) ? &m_SmileyList[index] : NULL; + return (index < (unsigned)m_SmileyList.getCount()) ? &m_SmileyList[index] : nullptr; } static DWORD_PTR ConvertServiceParam(MCONTACT hContact, const wchar_t *param) { - if (param == NULL) + if (param == nullptr) return 0; if (mir_wstrcmpi(L"hContact", param) == 0) return hContact; @@ -238,7 +238,7 @@ void SmileyType::CallSmileyService(MCONTACT hContact) if (name[0] == '/') { proto = (const char*)GetContactProto(hContact); - if (proto == NULL) return; + if (proto == nullptr) return; } mir_snprintf(str, "%s%s", proto, _T2A(name.c_str())); CallService(str, @@ -250,7 +250,7 @@ void SmileyType::CallSmileyService(MCONTACT hContact) SmileyPackType::~SmileyPackType() { - if (m_hSmList != NULL) ImageList_Destroy(m_hSmList); + if (m_hSmList != nullptr) ImageList_Destroy(m_hSmList); } static const wchar_t urlRegEx[] = @@ -330,7 +330,7 @@ void SmileyPackType::Clear(void) { m_SmileyList.destroy(); m_SmileyLookup.destroy(); - if (m_hSmList != NULL) { ImageList_Destroy(m_hSmList); m_hSmList = NULL; } + if (m_hSmList != nullptr) { ImageList_Destroy(m_hSmList); m_hSmList = nullptr; } m_Filename.Empty(); m_Name.Empty(); m_Date.Empty(); @@ -554,18 +554,18 @@ static IStream* DecodeBase64Data(const char *pData) unsigned dataLen; ptrA data((char*)mir_base64_decode(pData, &dataLen)); if (data == NULL) - return NULL; + return nullptr; // Read image list HGLOBAL hBuffer = GlobalAlloc(GMEM_MOVEABLE, dataLen); if (!hBuffer) - return NULL; + return nullptr; void *dst = GlobalLock(hBuffer); memcpy(dst, data, dataLen); GlobalUnlock(hBuffer); - IStream *pStream = NULL; + IStream *pStream = nullptr; CreateStreamOnHGlobal(hBuffer, TRUE, &pStream); return pStream; } @@ -627,8 +627,8 @@ bool SmileyPackType::LoadSmileyFileXEP(CMStringW &tbuf, bool onlyInfo, CMStringW m1 = imagedt_re->createWCMatcher(images); if (m1->findFirstMatch()) { IStream *pStream = DecodeBase64Data(_T2A(m1->getGroup(1).c_str())); - if (pStream != NULL) { - if (m_hSmList != NULL) ImageList_Destroy(m_hSmList); + if (pStream != nullptr) { + if (m_hSmList != nullptr) ImageList_Destroy(m_hSmList); m_hSmList = ImageList_Read(pStream); pStream->Release(); } @@ -670,7 +670,7 @@ bool SmileyPackType::LoadSmileyFileXEP(CMStringW &tbuf, bool onlyInfo, CMStringW m2 = imagedt_re->createWCMatcher(images); if (m2->findFirstMatch()) { IStream *pStream = DecodeBase64Data(_T2A(m2->getGroup(1).c_str())); - if (pStream != NULL) { + if (pStream != nullptr) { dat->LoadFromImage(pStream); pStream->Release(); } @@ -712,7 +712,7 @@ bool SmileyPackType::LoadSmileyFileXEP(CMStringW &tbuf, bool onlyInfo, CMStringW bool SmileyPackListType::AddSmileyPack(CMStringW &filename, CMStringW &packname) { bool res = true; - if (GetSmileyPack(filename) == NULL) { //not exist yet, so add + if (GetSmileyPack(filename) == nullptr) { //not exist yet, so add SmileyPackType *smileyPack = new SmileyPackType; res = smileyPack->LoadSmileyFile(filename, packname, FALSE); @@ -735,7 +735,7 @@ SmileyPackType* SmileyPackListType::GetSmileyPack(CMStringW &filename) pathToAbsolute(m_SmileyPacks[i].GetFilename(), modpath1); if (mir_wstrcmpi(modpath.c_str(), modpath1.c_str()) == 0) return &m_SmileyPacks[i]; } - return NULL; + return nullptr; } void SmileyPackListType::ClearAndFreeAll() @@ -806,20 +806,20 @@ SmileyCategoryType* SmileyCategoryListType::GetSmileyCategory(const CMStringW &n if (name.CompareNoCase(m_SmileyCategories[i].GetName()) == 0) return &m_SmileyCategories[i]; - return NULL; + return nullptr; } SmileyCategoryType* SmileyCategoryListType::GetSmileyCategory(unsigned index) { - return index < (unsigned)m_SmileyCategories.getCount() ? &m_SmileyCategories[index] : NULL; + return index < (unsigned)m_SmileyCategories.getCount() ? &m_SmileyCategories[index] : nullptr; } SmileyPackType* SmileyCategoryListType::GetSmileyPack(CMStringW &categoryname) { SmileyCategoryType *smc = GetSmileyCategory(categoryname); - return smc != NULL ? smc->GetSmileyPack() : NULL; + return smc != nullptr ? smc->GetSmileyPack() : nullptr; } @@ -839,7 +839,7 @@ void SmileyCategoryListType::SaveSettings(void) void SmileyCategoryListType::AddAndLoad(const CMStringW &name, const CMStringW &displayName) { - if (GetSmileyCategory(name) != NULL) + if (GetSmileyCategory(name) != nullptr) return; AddCategory(name, displayName, smcExt); @@ -851,7 +851,7 @@ void SmileyCategoryListType::AddAndLoad(const CMStringW &name, const CMStringW & void SmileyCategoryListType::AddCategory(const CMStringW &name, const CMStringW &displayName, SmcType typ, const CMStringW &defaultFilename) { - if (GetSmileyCategory(name) == NULL) + if (GetSmileyCategory(name) == nullptr) m_SmileyCategories.insert(new SmileyCategoryType(m_pSmileyPackStore, name, displayName, defaultFilename, typ)); } @@ -887,7 +887,7 @@ void SmileyCategoryListType::AddAccountAsCategory(PROTOACCOUNT *acc, const CMStr const char *packnam = acc->szProtoName; if (mir_strcmp(packnam, "JABBER") == 0) packnam = "JGMail"; - else if (strstr(packnam, "SIP") != NULL) + else if (strstr(packnam, "SIP") != nullptr) packnam = "MSN"; char path[MAX_PATH]; @@ -908,13 +908,13 @@ void SmileyCategoryListType::AddAccountAsCategory(PROTOACCOUNT *acc, const CMStr void SmileyCategoryListType::AddProtoAsCategory(char *acc, const CMStringW &defaultFile) { - if (acc == NULL) + if (acc == nullptr) return; const char *packnam = acc; if (mir_strcmp(packnam, "JABBER") == 0) packnam = "JGMail"; - else if (strstr(packnam, "SIP") != NULL) + else if (strstr(packnam, "SIP") != nullptr) packnam = "MSN"; char path[MAX_PATH]; @@ -938,7 +938,7 @@ void SmileyCategoryListType::DeleteAccountAsCategory(PROTOACCOUNT *acc) for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { char *proto = GetContactProto(hContact); - if (proto == NULL) + if (proto == nullptr) continue; DBVARIANT dbv; @@ -961,7 +961,7 @@ void SmileyCategoryListType::DeleteAccountAsCategory(PROTOACCOUNT *acc) void SmileyCategoryListType::AddContactTransportAsCategory(MCONTACT hContact, const CMStringW &defaultFile) { char *proto = GetContactProto(hContact); - if (proto == NULL) + if (proto == nullptr) return; DBVARIANT dbv; @@ -973,22 +973,22 @@ void SmileyCategoryListType::AddContactTransportAsCategory(MCONTACT hContact, co char *trsp = mir_strdup(_T2A(dbv.ptszVal)); _strlwr(trsp); - const char *packname = NULL; - if (strstr(trsp, "msn") != NULL) + const char *packname = nullptr; + if (strstr(trsp, "msn") != nullptr) packname = "msn"; - else if (strstr(trsp, "icq") != NULL) + else if (strstr(trsp, "icq") != nullptr) packname = "icq"; - else if (strstr(trsp, "yahoo") != NULL) + else if (strstr(trsp, "yahoo") != nullptr) packname = "yahoo"; - else if (strstr(trsp, "aim") != NULL) + else if (strstr(trsp, "aim") != nullptr) packname = "aim"; - else if (strstr(trsp, "lcs") != NULL) + else if (strstr(trsp, "lcs") != nullptr) packname = "msn"; mir_free(trsp); CMStringW displayName = dbv.ptszVal; - if (packname != NULL) { + if (packname != nullptr) { char path[MAX_PATH]; mir_snprintf(path, "Smileys\\nova\\%s.msl", packname); @@ -1061,7 +1061,7 @@ SmileyLookup::SmileyLookup(const CMStringW &str, const bool regexs, const int in m_ind = ind; if (regexs) { m_pattern = _TPattern::compile(str); - m_valid = m_pattern != NULL; + m_valid = m_pattern != nullptr; if (m_valid) { _TMatcher *matcher = m_pattern->createWCMatcher(testString); m_valid &= (!matcher->findFirstMatch() || @@ -1082,7 +1082,7 @@ SmileyLookup::SmileyLookup(const CMStringW &str, const bool regexs, const int in } else { m_text = str; - m_pattern = NULL; + m_pattern = nullptr; m_valid = !str.IsEmpty(); } } @@ -1113,7 +1113,7 @@ void SmileyLookup::Find(const CMStringW &str, SmileyLocVecType &smlcur, bool fir } else { const wchar_t *pos = str.c_str(); - while ((pos = wcsstr(pos, m_text.c_str())) != NULL) { + while ((pos = wcsstr(pos, m_text.c_str())) != nullptr) { smlcur.insert(new SmileyLocType(pos - str.c_str(), m_text.GetLength())); pos += m_text.GetLength(); if (firstOnly && m_ind != -1) diff --git a/plugins/SmileyAdd/src/smltool.cpp b/plugins/SmileyAdd/src/smltool.cpp index c71d2e5aac..84c0e687ea 100644 --- a/plugins/SmileyAdd/src/smltool.cpp +++ b/plugins/SmileyAdd/src/smltool.cpp @@ -76,7 +76,7 @@ public: LRESULT CALLBACK DlgProcSmileyToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { SmileyToolWindowType *pOD = (SmileyToolWindowType*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - if (pOD == NULL) { + if (pOD == nullptr) { pOD = new SmileyToolWindowType(hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)pOD); } @@ -96,7 +96,7 @@ SmileyToolWindowType::SmileyToolWindowType(HWND hWnd) { m_hwndDialog = hWnd; rowSel = -1; - m_AniPack = NULL; + m_AniPack = nullptr; m_NumberOfVerticalButtons = 0; m_NumberOfHorizontalButtons = 0; @@ -130,7 +130,7 @@ LRESULT SmileyToolWindowType::DialogProcedure(UINT msg, WPARAM wParam, LPARAM lP case WM_DESTROY: KillTimer(m_hwndDialog, 1); if (m_AniPack) delete m_AniPack; - m_AniPack = NULL; + m_AniPack = nullptr; DestroyWindow(m_hToolTip); PostQuitMessage(0); if (m_Choosing) @@ -194,7 +194,7 @@ void CALLBACK smileyServiceCallback(void *arg) void SmileyToolWindowType::InsertSmiley(void) { - if (m_CurrentHotTrack >= 0 && m_hWndTarget != NULL) { + if (m_CurrentHotTrack >= 0 && m_hWndTarget != nullptr) { SmileyType *sml = m_pSmileyPack->GetSmiley(m_CurrentHotTrack); if (sml->IsService()) { @@ -213,7 +213,7 @@ void SmileyToolWindowType::InsertSmiley(void) m_Choosing = true; DestroyWindow(m_hwndDialog); } - else if (m_hWndTarget == NULL) + else if (m_hWndTarget == nullptr) DestroyWindow(m_hwndDialog); } @@ -315,7 +315,7 @@ void SmileyToolWindowType::ScrollV(int action, int dist) m_AniPack->SetOffset(si.nPos*GetRowSize()); ScrollWindowEx(m_hwndDialog, 0, (yPos - si.nPos) * GetRowSize(), - NULL, NULL, NULL, NULL, SW_INVALIDATE); + nullptr, nullptr, nullptr, nullptr, SW_INVALIDATE); UpdateWindow(m_hwndDialog); } @@ -536,7 +536,7 @@ void SmileyToolWindowType::InitDialog(LPARAM lParam) if (m_XPosition < xoScreen) m_XPosition = xoScreen; // Move window to desired location - SetWindowPos(m_hwndDialog, NULL, m_XPosition, m_YPosition, + SetWindowPos(m_hwndDialog, nullptr, m_XPosition, m_YPosition, width, height, SWP_NOZORDER); m_AniPack = new AnimatedPack(m_hwndDialog, height, m_ButtonSize, opt.SelWndBkgClr); @@ -548,11 +548,11 @@ void SmileyToolWindowType::InitDialog(LPARAM lParam) m_AniPack->SetOffset(0); - if (opt.AnimateSel) SetTimer(m_hwndDialog, 1, 100, NULL); + if (opt.AnimateSel) SetTimer(m_hwndDialog, 1, 100, nullptr); //add tooltips m_hToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, L"", - TTS_NOPREFIX | WS_POPUP, 0, 0, 0, 0, m_hwndDialog, NULL, g_hInst, NULL); + TTS_NOPREFIX | WS_POPUP, 0, 0, 0, 0, m_hwndDialog, nullptr, g_hInst, nullptr); TOOLINFO ti = { 0 }; ti.cbSize = sizeof(ti); ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; @@ -750,23 +750,23 @@ void __cdecl SmileyToolThread(void *arg) wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 4; wndclass.hInstance = g_hInst; - wndclass.hIcon = NULL; - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hIcon = nullptr; + wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW); wndclass.hbrBackground = CreateSolidBrush(opt.SelWndBkgClr); - wndclass.lpszMenuName = NULL; + wndclass.lpszMenuName = nullptr; wndclass.lpszClassName = L"SmileyTool"; - wndclass.hIconSm = NULL; + wndclass.hIconSm = nullptr; RegisterClassEx(&wndclass); - CreateWindowEx(WS_EX_TOPMOST | WS_EX_NOPARENTNOTIFY, L"SmileyTool", NULL, + CreateWindowEx(WS_EX_TOPMOST | WS_EX_NOPARENTNOTIFY, L"SmileyTool", nullptr, WS_BORDER | WS_POPUP | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - ((SmileyToolWindowParam*)arg)->hWndParent, NULL, g_hInst, arg); + ((SmileyToolWindowParam*)arg)->hWndParent, nullptr, g_hInst, arg); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL); MSG msg; - while (GetMessage(&msg, NULL, 0, 0)) { + while (GetMessage(&msg, nullptr, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } -- cgit v1.2.3