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/ClientChangeNotify/src/CString.cpp | 2 +- .../ClientChangeNotify/src/ClientChangeNotify.cpp | 8 +++--- plugins/ClientChangeNotify/src/OptDlg.cpp | 12 ++++----- plugins/ClientChangeNotify/src/Options.cpp | 30 +++++++++++----------- plugins/ClientChangeNotify/src/pcre.cpp | 8 +++--- 5 files changed, 30 insertions(+), 30 deletions(-) (limited to 'plugins/ClientChangeNotify/src') diff --git a/plugins/ClientChangeNotify/src/CString.cpp b/plugins/ClientChangeNotify/src/CString.cpp index edee2fe0e6..2ed5f49062 100644 --- a/plugins/ClientChangeNotify/src/CString.cpp +++ b/plugins/ClientChangeNotify/src/CString.cpp @@ -39,7 +39,7 @@ void TString::Free() { // HeapFree(GetProcessHeap(), 0, pBuf); free(pBuf); - pBuf = NULL; + pBuf = nullptr; nBufSize = 0; nAllocSize = 0; } diff --git a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp index cca57b1975..05a4423f30 100644 --- a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp +++ b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp @@ -70,12 +70,12 @@ static VOID NTAPI ShowContactMenu(ULONG_PTR wParam) // wParam = hContact { POINT pt; - HWND hMenuWnd = CreateWindowEx(WS_EX_TOOLWINDOW, L"static", _A2W(MOD_NAME) L"_MenuWindow", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, g_hInstance, NULL); + HWND hMenuWnd = CreateWindowEx(WS_EX_TOOLWINDOW, L"static", _A2W(MOD_NAME) L"_MenuWindow", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, g_hInstance, nullptr); SetWindowLongPtr(hMenuWnd, GWLP_WNDPROC, (LONG_PTR)MenuWndProc); HMENU hMenu = Menu_BuildContactMenu(wParam); GetCursorPos(&pt); SetForegroundWindow(hMenuWnd); - Clist_MenuProcessCommand(TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, hMenuWnd, NULL), MPCF_CONTACTMENU, wParam); + Clist_MenuProcessCommand(TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, hMenuWnd, nullptr), MPCF_CONTACTMENU, wParam); PostMessage(hMenuWnd, WM_NULL, 0, 0); DestroyMenu(hMenu); DestroyWindow(hMenuWnd); @@ -166,7 +166,7 @@ void ShowPopup(SHOWPOPUP_DATA *sd) if (!ppd.lchIcon || (INT_PTR)ppd.lchIcon == CALLSERVICE_NOTFOUND) { // if we didn't succeed retrieving client icon, show the usual status icon instead ppd.lchIcon = Skin_LoadProtoIcon(szProto, db_get_w(sd->hContact, szProto, "Status", ID_STATUS_OFFLINE)); - pdata->hIcon = NULL; + pdata->hIcon = nullptr; } wcsncpy(ppd.lptzContactName, (wchar_t*)pcli->pfnGetContactDisplayName(sd->hContact, 0), _countof(ppd.lptzContactName) - 1); wcsncpy(ppd.lptzText, PopupText, _countof(ppd.lptzText) - 1); @@ -344,7 +344,7 @@ int MirandaLoaded(WPARAM, LPARAM) // seems that Fingerprint is not installed if (!bFingerprintExists && !db_get_b(NULL, MOD_NAME, DB_NO_FINGERPRINT_ERROR, 0)) - CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_CCN_ERROR), NULL, CCNErrorDlgProc); + CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_CCN_ERROR), nullptr, CCNErrorDlgProc); return 0; } diff --git a/plugins/ClientChangeNotify/src/OptDlg.cpp b/plugins/ClientChangeNotify/src/OptDlg.cpp index 80e1f117e0..21761ed59e 100644 --- a/plugins/ClientChangeNotify/src/OptDlg.cpp +++ b/plugins/ClientChangeNotify/src/OptDlg.cpp @@ -21,7 +21,7 @@ // ================================================ Popup options ================================================ -COptPage g_PopupOptPage(MOD_NAME, NULL); +COptPage g_PopupOptPage(MOD_NAME, nullptr); void EnablePopupOptDlgControls() { @@ -53,7 +53,7 @@ void EnablePopupOptDlgControls() } SetDlgItemText(g_PopupOptPage.GetWnd(), IDC_POPUPOPTDLG_STATIC_REGEXP, TranslateT("(you can use regular expressions here)")); g_PopupOptPage.MemToPage(true); - InvalidateRect(GetDlgItem(g_PopupOptPage.GetWnd(), IDC_POPUPOPTDLG_POPUPDELAY_SPIN), NULL, false); // update spin control + InvalidateRect(GetDlgItem(g_PopupOptPage.GetWnd(), IDC_POPUPOPTDLG_POPUPDELAY_SPIN), nullptr, false); // update spin control } static struct @@ -125,13 +125,13 @@ INT_PTR CALLBACK PopupOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara case IDC_POPUPOPTDLG_POPUPPREVIEW: g_PreviewOptPage = new COptPage(g_PopupOptPage); g_PreviewOptPage->PageToMem(); - DBCONTACTWRITESETTING cws = { 0 }; + DBCONTACTWRITESETTING cws = {}; cws.szModule = "ICQ"; cws.szSetting = DB_MIRVER; db_set_s(NULL, MOD_NAME, DB_OLDMIRVER, "ICQ Lite v5"); ContactSettingChanged(NULL, (LPARAM)&cws); // simulate a version change delete g_PreviewOptPage; - g_PreviewOptPage = NULL; + g_PreviewOptPage = nullptr; break; } break; @@ -152,7 +152,7 @@ INT_PTR CALLBACK PopupOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara break; case WM_DESTROY: - g_PopupOptPage.SetWnd(NULL); + g_PopupOptPage.SetWnd(nullptr); return 0; } return 0; @@ -161,7 +161,7 @@ INT_PTR CALLBACK PopupOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara int OptionsDlgInit(WPARAM wParam, LPARAM) { if (bPopupExists) { - OPTIONSDIALOGPAGE optDi = { sizeof(optDi) }; + OPTIONSDIALOGPAGE optDi = {}; optDi.position = 920000000; optDi.szGroup.a = LPGEN("Popups"); optDi.szTitle.a = LPGEN("ClientChangeNotify"); diff --git a/plugins/ClientChangeNotify/src/Options.cpp b/plugins/ClientChangeNotify/src/Options.cpp index d5647554f3..05660a21f7 100644 --- a/plugins/ClientChangeNotify/src/Options.cpp +++ b/plugins/ClientChangeNotify/src/Options.cpp @@ -98,7 +98,7 @@ COptItem *COptPage::Find(int m_dlgItemID) return Items[i]; _ASSERT(0); - return 0; + return nullptr; } COptPage& COptPage::operator = (const COptPage& Page) @@ -116,7 +116,7 @@ COptPage& COptPage::operator = (const COptPage& Page) int COptItem::GetIntDBVal(const CString &sModule, int bSigned, CString*) { // default procedure for reading value from DB; used only for integral types - if (sDBSetting != NULL) { + if (sDBSetting != nullptr) { _ASSERT(nValueSize == DBVT_BYTE || nValueSize == DBVT_WORD || nValueSize == DBVT_DWORD); DBVARIANT dbv; if (db_get(NULL, sModule, sDBSetting, &dbv)) @@ -129,7 +129,7 @@ int COptItem::GetIntDBVal(const CString &sModule, int bSigned, CString*) void COptItem::SetIntDBVal(const CString &sModule, int m_value, CString*) { // default procedure for writing value to the DB; used only for integral types - if (sDBSetting != NULL && !m_bReadOnly) { + if (sDBSetting != nullptr && !m_bReadOnly) { _ASSERT(nValueSize == DBVT_BYTE || nValueSize == DBVT_WORD || nValueSize == DBVT_DWORD); DBVARIANT dbv; @@ -141,7 +141,7 @@ void COptItem::SetIntDBVal(const CString &sModule, int m_value, CString*) TCString COptItem::GetStrDBVal(const CString &sModule, CString *sDBSettingPrefix) { - if (sDBSetting != NULL) { + if (sDBSetting != nullptr) { _ASSERT(GetDefValue()); return db_get_s(NULL, sModule, sDBSettingPrefix ? (*sDBSettingPrefix + sDBSetting) : sDBSetting, *(TCString*)GetDefValue()); } @@ -150,7 +150,7 @@ TCString COptItem::GetStrDBVal(const CString &sModule, CString *sDBSettingPrefix void COptItem::SetStrDBVal(const CString &sModule, TCString &Str, CString *sDBSettingPrefix) { - if (sDBSetting != NULL && !m_bReadOnly) { + if (sDBSetting != nullptr && !m_bReadOnly) { db_set_ws(NULL, sModule, sDBSettingPrefix ? (*sDBSettingPrefix + sDBSetting) : sDBSetting, Str); } } @@ -282,11 +282,11 @@ int TreeReadEnum(const char *szSetting, LPARAM lParam) pItem.ID = ID; pItem.ParentID = ParentID; pItem.Flags = Flags; - pItem.hItem = NULL; + pItem.hItem = nullptr; pItem.Title = db_get_s(NULL, pData->sModule, *pData->sDBSettingPrefix + szSetting, L""); - pItem.User_Str1 = (pData->TreeCtrl->User_Str1_DBName == NULL) ? NULL : + pItem.User_Str1 = (pData->TreeCtrl->User_Str1_DBName == nullptr) ? nullptr : db_get_s(NULL, pData->sModule, - *pData->sDBSettingPrefix + pData->TreeCtrl->sDBSetting + pData->TreeCtrl->User_Str1_DBName + (szSetting + Len), (wchar_t*)NULL); + *pData->sDBSettingPrefix + pData->TreeCtrl->sDBSetting + pData->TreeCtrl->User_Str1_DBName + (szSetting + Len), (wchar_t*)nullptr); } } return 0; @@ -306,7 +306,7 @@ void COptItem_TreeCtrl::DBToMem(const CString &sModule, CString *sDBSettingPrefi } else { for (int i = 0; i < m_value.GetSize(); i++) { - if (m_value[i].Title == NULL) { + if (m_value[i].Title == nullptr) { m_value.RemoveElem(i); i--; } @@ -334,7 +334,7 @@ void COptItem_TreeCtrl::MemToDB(const CString &sModule, CString *sDBSettingPrefi if (!(TreeFlags & TREECTRL_FLAG_IS_SINGLE_LEVEL) || TreeFlags & TREECTRL_FLAG_HAS_CHECKBOXES) db_set_b(NULL, sModule, *sDBSettingPrefix + sDBSetting + TREEITEM_DBSTR_FLAGS + StrID, m_value[i].Flags); - if (User_Str1_DBName != NULL && m_value[i].User_Str1 != NULL) + if (User_Str1_DBName != nullptr && m_value[i].User_Str1 != nullptr) db_set_ws(NULL, sModule, *sDBSettingPrefix + sDBSetting + User_Str1_DBName + StrID, m_value[i].User_Str1); } COptItem::MemToDB(sModule, sDBSettingPrefix); @@ -372,7 +372,7 @@ void COptItem_TreeCtrl::MemToWnd(HWND hWnd) SetWindowLongPtr(hTreeView, GWL_STYLE, Style | TVS_CHECKBOXES); } - TVINSERTSTRUCT tvIn = { 0 }; + TVINSERTSTRUCT tvIn = {}; int ScrollPos = GetScrollPos(hTreeView, SB_VERT); int SelectOrder = IDToOrder(GetSelectedItemID(hWnd)); SendMessage(hTreeView, WM_SETREDRAW, false, 0); @@ -414,7 +414,7 @@ void COptItem_TreeCtrl::MemToWnd(HWND hWnd) i--; } } - TreeView_SelectItem(hTreeView, (SelectOrder >= 0) ? m_value[SelectOrder].hItem : ((SelectOrder <= TREECTRL_ROOTORDEROFFS) ? RootItems[ROOT_ORDER_TO_INDEX(SelectOrder)].hItem : NULL)); + TreeView_SelectItem(hTreeView, (SelectOrder >= 0) ? m_value[SelectOrder].hItem : ((SelectOrder <= TREECTRL_ROOTORDEROFFS) ? RootItems[ROOT_ORDER_TO_INDEX(SelectOrder)].hItem : nullptr)); SendMessage(hTreeView, WM_SETREDRAW, true, 0); SCROLLBARINFO sbi; sbi.cbSize = sizeof(sbi); @@ -460,7 +460,7 @@ int TreeDeleteEnum(const char *szSetting, LPARAM lParam) if (!strncmp(szSetting, CurSetting, CurSetting.GetLen())) TreeDeleteEnumData->TreeSettings.AddElem(szSetting); - if (TreeDeleteEnumData->TreeCtrl->User_Str1_DBName != NULL) { + if (TreeDeleteEnumData->TreeCtrl->User_Str1_DBName != nullptr) { CurSetting = *TreeDeleteEnumData->sDBSettingPrefix + TreeDeleteEnumData->TreeCtrl->sDBSetting + TreeDeleteEnumData->TreeCtrl->User_Str1_DBName; if (!strncmp(szSetting, CurSetting, CurSetting.GetLen())) TreeDeleteEnumData->TreeSettings.AddElem(szSetting); @@ -524,7 +524,7 @@ CTreeItem* COptItem_TreeCtrl::InsertItem(HWND hWnd, CTreeItem &Item) TVITEM tvi; int SelOrder = -1; Item.ParentID = RootItems[0].ID; - TVINSERTSTRUCT tvIn = { 0 }; + TVINSERTSTRUCT tvIn = {}; tvIn.hParent = RootItems[0].hItem; tvIn.hInsertAfter = TVI_FIRST; if (tvi.hItem = TreeView_GetSelection(hTreeView)) { @@ -668,7 +668,7 @@ void COptItem_ListCtrl::DBToMem(const CString &sModule, CString *sDBSettingPrefi m_value = m_defValue; else { for (int i = 0; i < m_value.GetSize(); i++) { - if (m_value[i].Text == NULL) { + if (m_value[i].Text == nullptr) { m_value.RemoveElem(i); i--; } diff --git a/plugins/ClientChangeNotify/src/pcre.cpp b/plugins/ClientChangeNotify/src/pcre.cpp index c7954f265f..d1796cfe81 100644 --- a/plugins/ClientChangeNotify/src/pcre.cpp +++ b/plugins/ClientChangeNotify/src/pcre.cpp @@ -59,7 +59,7 @@ void FreePcreCompileData() TCString CompileRegexp(TCString Regexp, int bAddAsUsualSubstring, int ID) { TCString Result(L""); - sPcreCompileData s = {0}; + sPcreCompileData s = {}; int NewID = PcreCompileData.AddElem(s); PcreCompileData[NewID].ID = ID; if (!bAddAsUsualSubstring) @@ -119,10 +119,10 @@ TCString CompileRegexp(TCString Regexp, int bAddAsUsualSubstring, int ID) Regexp.ReleaseBuffer(); } - PcreCompileData[NewID].pPcre = pcre16_compile(Regexp, PCRE_UTF8 | PCRE_NO_UTF8_CHECK | Flags, &Err, &ErrOffs, NULL); + PcreCompileData[NewID].pPcre = pcre16_compile(Regexp, PCRE_UTF8 | PCRE_NO_UTF8_CHECK | Flags, &Err, &ErrOffs, nullptr); if (PcreCompileData[NewID].pPcre) { - PcreCompileData[NewID].pExtra = NULL; + PcreCompileData[NewID].pExtra = nullptr; PcreCompileData[NewID].pExtra = pcre16_study(PcreCompileData[NewID].pPcre, 0, &Err); } else { @@ -157,7 +157,7 @@ int PcreCheck(TCString Str, int StartingID) if (PcreCompileData[I].pPcre) { - int Res = pcre16_exec(PcreCompileData[I].pPcre, PcreCompileData[I].pExtra, Str, Str.GetLen() - 1, 0, PCRE_NOTEMPTY | PCRE_NO_UTF8_CHECK, NULL, 0); + int Res = pcre16_exec(PcreCompileData[I].pPcre, PcreCompileData[I].pExtra, Str, Str.GetLen() - 1, 0, PCRE_NOTEMPTY | PCRE_NO_UTF8_CHECK, nullptr, 0); if (Res >= 0) { -- cgit v1.2.3