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/Non-IM Contact/src/contactinfo.cpp | 10 ++++----- plugins/Non-IM Contact/src/dialog.cpp | 22 +++++++++---------- plugins/Non-IM Contact/src/files.cpp | 6 +++--- plugins/Non-IM Contact/src/main.cpp | 4 ++-- plugins/Non-IM Contact/src/namereplacing.cpp | 32 ++++++++++++++-------------- plugins/Non-IM Contact/src/timer.cpp | 4 ++-- 6 files changed, 39 insertions(+), 39 deletions(-) (limited to 'plugins/Non-IM Contact') diff --git a/plugins/Non-IM Contact/src/contactinfo.cpp b/plugins/Non-IM Contact/src/contactinfo.cpp index 11ac955a3a..a9b27e33eb 100644 --- a/plugins/Non-IM Contact/src/contactinfo.cpp +++ b/plugins/Non-IM Contact/src/contactinfo.cpp @@ -58,7 +58,7 @@ INT_PTR CALLBACK DlgProcContactInfo(HWND hwnd, UINT msg, WPARAM, LPARAM lParam) return FALSE; } -static WNDPROC g_PrevBtnWndProc = 0; +static WNDPROC g_PrevBtnWndProc = nullptr; LRESULT CALLBACK ButtWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -73,7 +73,7 @@ LRESULT CALLBACK ButtWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar rc.top += (rc.bottom - rc.top - 16) / 2; if (isPressed) OffsetRect(&rc, 1, 1); - DrawIconEx(dc, rc.left, rc.top, (HICON)GetWindowLongPtr(hWnd, GWLP_USERDATA), 16, 16, 0, 0, DI_NORMAL); + DrawIconEx(dc, rc.left, rc.top, (HICON)GetWindowLongPtr(hWnd, GWLP_USERDATA), 16, 16, 0, nullptr, DI_NORMAL); ReleaseDC(hWnd, dc); } @@ -87,7 +87,7 @@ int BrowseForFolder(HWND hwnd, char *szPath) if (SUCCEEDED(CoGetMalloc(1, &pMalloc))) { ptrW tszPath(mir_a2u(szPath)); - BROWSEINFO bi = { 0 }; + BROWSEINFO bi = {}; bi.hwndOwner = hwnd; bi.pszDisplayName = tszPath; bi.lpszTitle = TranslateT("Select Folder"); @@ -132,7 +132,7 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP /* group*/ wchar_t *szGroup; - for (int i = 1; (szGroup = Clist_GroupGetName(i, NULL)) != NULL; i++) + for (int i = 1; (szGroup = Clist_GroupGetName(i, nullptr)) != nullptr; i++) SendDlgItemMessage(hwnd, IDC_GROUP, CB_INSERTSTRING, 0, LPARAM(szGroup)); if (!db_get_ws(hContact, "CList", "Group", &dbv)) { @@ -631,7 +631,7 @@ INT_PTR ImportContacts(WPARAM, LPARAM) } } - if (MessageBoxA(0, msg, modFullname, MB_YESNO) == IDYES) { + if (MessageBoxA(nullptr, msg, modFullname, MB_YESNO) == IDYES) { if (!(hContact = db_add_contact())) { msg("contact did get created", ""); continue; diff --git a/plugins/Non-IM Contact/src/dialog.cpp b/plugins/Non-IM Contact/src/dialog.cpp index 7b441b99e8..3a70ccde26 100644 --- a/plugins/Non-IM Contact/src/dialog.cpp +++ b/plugins/Non-IM Contact/src/dialog.cpp @@ -123,7 +123,7 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM) case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_HELPMSG: - CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_HELP), 0, HelpWindowDlgProc); + CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_HELP), nullptr, HelpWindowDlgProc); break; case IDCANCEL: @@ -205,13 +205,13 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM) INT_PTR testStringReplacer(WPARAM, LPARAM) { - CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_TEST_LINE), 0, TestWindowDlgProc); + CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_TEST_LINE), nullptr, TestWindowDlgProc); return 0; } INT_PTR LoadFilesDlg(WPARAM, LPARAM) { - CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_ADD_FILE), 0, DlgProcFiles); + CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_ADD_FILE), nullptr, DlgProcFiles); return 0; } @@ -243,44 +243,44 @@ void DoPropertySheet(MCONTACT hContact) psp[0].dwFlags = PSP_USEICONID | PSP_USETITLE; psp[0].hInstance = g_hInst; psp[0].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_INFO); - psp[0].pszIcon = NULL; + psp[0].pszIcon = nullptr; psp[0].pfnDlgProc = DlgProcContactInfo; psp[0].pszTitle = Translate("Contacts Display Info"); psp[0].lParam = hContact; - psp[0].pfnCallback = NULL; + psp[0].pfnCallback = nullptr; /* other settings */ psp[1].dwSize = sizeof(PROPSHEETPAGE); psp[1].dwFlags = PSP_USEICONID | PSP_USETITLE; psp[1].hInstance = g_hInst; psp[1].pszTemplate = MAKEINTRESOURCEA(IDD_OTHER_STUFF); - psp[1].pszIcon = NULL; + psp[1].pszIcon = nullptr; psp[1].pfnDlgProc = DlgProcOtherStuff; psp[1].pszTitle = Translate("Link and Contact list Settings"); psp[1].lParam = hContact; - psp[1].pfnCallback = NULL; + psp[1].pfnCallback = nullptr; /* copy contact */ psp[2].dwSize = sizeof(PROPSHEETPAGE); psp[2].dwFlags = PSP_USEICONID | PSP_USETITLE; psp[2].hInstance = g_hInst; psp[2].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_COPYEXPORT); - psp[2].pszIcon = NULL; + psp[2].pszIcon = nullptr; psp[2].pfnDlgProc = DlgProcCopy; psp[2].pszTitle = Translate("Copy Contact"); psp[2].lParam = hContact; - psp[2].pfnCallback = NULL; + psp[2].pfnCallback = nullptr; /* files */ psp[3].dwSize = sizeof(PROPSHEETPAGE); psp[3].dwFlags = PSP_USEICONID | PSP_USETITLE; psp[3].hInstance = g_hInst; psp[3].pszTemplate = MAKEINTRESOURCEA(IDD_ADD_FILE); - psp[3].pszIcon = NULL; + psp[3].pszIcon = nullptr; psp[3].pfnDlgProc = DlgProcFiles; psp[3].pszTitle = Translate("Files"); psp[3].lParam = 0; - psp[3].pfnCallback = NULL; + psp[3].pfnCallback = nullptr; /* propery sheet header.. dont touch !!!! */ PROPSHEETHEADERA psh = { sizeof(psh) }; diff --git a/plugins/Non-IM Contact/src/files.cpp b/plugins/Non-IM Contact/src/files.cpp index bbc4788ae4..232532dc4a 100644 --- a/plugins/Non-IM Contact/src/files.cpp +++ b/plugins/Non-IM Contact/src/files.cpp @@ -7,7 +7,7 @@ INT_PTR exportContacts(WPARAM, LPARAM) return 0; FILE* file; - if (MessageBox(0, TranslateT("Do you want to overwrite the contents of the file?\r\n\r\nPressing No will append these contacts to the end of the file."), _A2W(modFullname), MB_YESNO) == IDYES) + if (MessageBox(nullptr, TranslateT("Do you want to overwrite the contents of the file?\r\n\r\nPressing No will append these contacts to the end of the file."), _A2W(modFullname), MB_YESNO) == IDYES) file = fopen(fn, "w"); else file = fopen(fn, "a"); @@ -116,7 +116,7 @@ void readFile(HWND hwnd) FILE *filen = fopen(szFileName, "r"); if (!filen) { - MessageBox(0, TranslateT("File couldn't be opened,2"), _A2W(modFullname), MB_OK); + MessageBox(nullptr, TranslateT("File couldn't be opened,2"), _A2W(modFullname), MB_OK); return; } lineNumber = 0; @@ -315,7 +315,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) char* getMimDir(char* file) { - GetModuleFileNameA(NULL, file, MAX_PATH); + GetModuleFileNameA(nullptr, file, MAX_PATH); char *p1 = strrchr(file, '\\'); if (p1) diff --git a/plugins/Non-IM Contact/src/main.cpp b/plugins/Non-IM Contact/src/main.cpp index 03b2a77ad1..5f7f769469 100644 --- a/plugins/Non-IM Contact/src/main.cpp +++ b/plugins/Non-IM Contact/src/main.cpp @@ -38,7 +38,7 @@ INT_PTR doubleClick(WPARAM wParam, LPARAM) if (strstr(program, "http://") || strstr(program, "https://")) Utils_OpenUrl(program); else - shellEXEerror = (INT_PTR)ShellExecuteA(NULL, NULL, program, params, NULL, SW_SHOW); //ignore the warning, its M$'s backwards compatabilty screwup :) + shellEXEerror = (INT_PTR)ShellExecuteA(nullptr, nullptr, program, params, nullptr, SW_SHOW); //ignore the warning, its M$'s backwards compatabilty screwup :) if (shellEXEerror == ERROR_FILE_NOT_FOUND || shellEXEerror == ERROR_PATH_NOT_FOUND) Utils_OpenUrl(program); } @@ -181,7 +181,7 @@ extern "C" __declspec(dllexport) int Load() Menu_AddMainMenuItem(&mi); SET_UID(mi, 0x1033e16d, 0x8a7c, 0x43db, 0xa9, 0x83, 0x56, 0x2f, 0x8a, 0x16, 0x7c, 0xe9); - mi.root = NULL; + mi.root = nullptr; mi.position = -2000080000; mi.name.a = LPGEN("E&dit Contact Settings"); mi.pszService = "EditLCcontact"; diff --git a/plugins/Non-IM Contact/src/namereplacing.cpp b/plugins/Non-IM Contact/src/namereplacing.cpp index 4077e12eb6..cb1103260b 100644 --- a/plugins/Non-IM Contact/src/namereplacing.cpp +++ b/plugins/Non-IM Contact/src/namereplacing.cpp @@ -6,7 +6,7 @@ int readFileIntoArray(int fileNumber, char *FileContents[]) mir_snprintf(dbSetting, "fn%d", fileNumber); char *szVar = db_get_sa(NULL, MODNAME, dbSetting); - if (szVar == NULL) + if (szVar == nullptr) return 0; char tszFileName[MAX_PATH]; @@ -17,7 +17,7 @@ int readFileIntoArray(int fileNumber, char *FileContents[]) mir_free(szVar); FILE* file = fopen(tszFileName, "r"); - if (file == NULL) + if (file == nullptr) return 0; // read the file into the FileContents array @@ -29,7 +29,7 @@ int readFileIntoArray(int fileNumber, char *FileContents[]) else temp[mir_strlen(temp)] = '\0'; FileContents[i] = (char*)malloc(mir_strlen(temp) + 1); - if (FileContents[i] == NULL) break; + if (FileContents[i] == nullptr) break; mir_strcpy(FileContents[i], temp); } fclose(file); @@ -214,9 +214,9 @@ void checkStringForcompare(CMStringA &str) if (!strncmp(str.c_str()+i, "compare(\"", mir_strlen("compare(\""))) { i += (int)mir_strlen("compare(\""); A = strtok(©OfStr[i], "\",\""); - B = strtok(NULL, "\",\""); - X = strtok(NULL, "\",\""); - Y = strtok(NULL, ",\")"); + B = strtok(nullptr, "\",\""); + X = strtok(nullptr, "\",\""); + Y = strtok(nullptr, ",\")"); j = Y - ©OfStr[i] + (int)mir_strlen(Y) + 1; if (A && B && X && Y) { if (!mir_strcmp(A, B)) @@ -243,7 +243,7 @@ void checkStringForSave(MCONTACT hContact, CMStringA &str) if (!strncmp(str.c_str()+i, "save(\"", mir_strlen("save(\""))) { i += (int)mir_strlen("save(\""); A = strtok(©OfStr[i], "\",\""); - B = strtok(NULL, ",\")"); + B = strtok(nullptr, ",\")"); j = B - ©OfStr[i] + (int)mir_strlen(B) + 1; if (A && B) db_set_s(hContact, MODNAME, A, B); @@ -294,9 +294,9 @@ void checkStringForSaveN(CMStringA &str) if (!strncmp(str.c_str()+i, "saveN(\"", mir_strlen("saveN(\""))) { i += (int)mir_strlen("saveN(\""); A = strtok(©OfStr[i], "\",\""); - B = strtok(NULL, ",\""); - C = strtok(NULL, ",\""); - D = strtok(NULL, ",\")"); + B = strtok(nullptr, ",\""); + C = strtok(nullptr, ",\""); + D = strtok(nullptr, ",\")"); j = D - ©OfStr[i] + (int)mir_strlen(D) + 1; if (A && B && C && D) { switch (D[0]) { @@ -337,7 +337,7 @@ void checkStringForLoadN(CMStringA &str) if (!strncmp(str.c_str()+i, "loadN(\"", mir_strlen("loadN(\""))) { i += (int)mir_strlen("loadN(\""); char *A = strtok(©OfStr[i], "\",\""); - char *B = strtok(NULL, ",\")"); + char *B = strtok(nullptr, ",\")"); if (A && B) { j = B - ©OfStr[i] + (int)mir_strlen(B) + 1; DBVARIANT dbv; @@ -378,7 +378,7 @@ BOOL GetLastWriteTime(HANDLE hFile, LPSTR lpszString) // Convert the last-write time to local time. FileTimeToSystemTime(&ftWrite, &stUTC); - SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal); + SystemTimeToTzSpecificLocalTime(nullptr, &stUTC, &stLocal); // Build a string showing the date and time. wsprintfA(lpszString, "%02d/%02d/%d %02d:%02d", @@ -401,7 +401,7 @@ int lastChecked(CMStringA &szNewStr, const char *str) mir_snprintf(szSetting, "fn%d", file); char *szVar = db_get_sa(NULL, MODNAME, szSetting); - if (szVar == NULL) + if (szVar == nullptr) return 0; if (!strncmp("http://", szVar, 7) || !strncmp("https://", szVar, 8)) @@ -410,7 +410,7 @@ int lastChecked(CMStringA &szNewStr, const char *str) mir_strncpy(tszFileName, szVar, _countof(tszFileName)); mir_free(szVar); - HANDLE hFile = CreateFileA(tszFileName, 0, FILE_SHARE_READ, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileA(tszFileName, 0, FILE_SHARE_READ, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) return 0; @@ -443,7 +443,7 @@ int stringReplacer(const char *oldString, CMStringA &szNewString, MCONTACT hCont int tempInt; int startLine = 0, endLine = 0, startChar = 0, endChar = 0, wholeLine = -1, linesInFile; int positionInOldString = 0; - char *fileContents[MAXLINES] = { NULL }, tempString[MAX_STRING_LENGTH]; + char *fileContents[MAXLINES] = {}, tempString[MAX_STRING_LENGTH]; // setup the variable names szNewString.Empty(); @@ -556,7 +556,7 @@ int stringReplacer(const char *oldString, CMStringA &szNewString, MCONTACT hCont } } // free the file strings - for (tempInt = 0; (tempInt < MAXLINES) && (fileContents[tempInt] != NULL); tempInt++) + for (tempInt = 0; (tempInt < MAXLINES) && (fileContents[tempInt] != nullptr); tempInt++) free(fileContents[tempInt]); // check for load("A","B") diff --git a/plugins/Non-IM Contact/src/timer.cpp b/plugins/Non-IM Contact/src/timer.cpp index 18fdf21778..dc20309a9b 100644 --- a/plugins/Non-IM Contact/src/timer.cpp +++ b/plugins/Non-IM Contact/src/timer.cpp @@ -63,7 +63,7 @@ void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD) // int startTimer(int interval) { - timerId = SetTimer(NULL, 0, interval, timerProc); + timerId = SetTimer(nullptr, 0, interval, timerProc); return 0; } @@ -78,7 +78,7 @@ int killTimer() { if (timerId != 0) { db_set_w(NULL, MODNAME, "timerCount", 0); - KillTimer(NULL, timerId); + KillTimer(nullptr, timerId); timerId = 0; } return 0; -- cgit v1.2.3