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/Msg_Export/src/FileViewer.cpp | 64 ++++++++++++++++----------------- plugins/Msg_Export/src/main.cpp | 6 ++-- plugins/Msg_Export/src/options.cpp | 16 ++++----- plugins/Msg_Export/src/utils.cpp | 68 +++++++++++++++++------------------ 4 files changed, 77 insertions(+), 77 deletions(-) (limited to 'plugins/Msg_Export/src') diff --git a/plugins/Msg_Export/src/FileViewer.cpp b/plugins/Msg_Export/src/FileViewer.cpp index c826b6283a..434e1b025a 100755 --- a/plugins/Msg_Export/src/FileViewer.cpp +++ b/plugins/Msg_Export/src/FileViewer.cpp @@ -35,7 +35,7 @@ bool bUseIntViewer = true; tstring sFileViewerPrg; // handle to the RichEditDll. We need to load this dll to use a RichEdit. -HMODULE hRichEditDll = NULL; +HMODULE hRichEditDll = nullptr; #define CONT(i) ((in[i]&0xc0) == 0x80) @@ -115,7 +115,7 @@ public: CLHistoryDlg(MCONTACT hContact) : hContact(hContact) { - hFindDlg = NULL; + hFindDlg = nullptr; acFindStr[0] = 0; memset(&fr, 0, sizeof(fr)); fr.lStructSize = sizeof(fr); @@ -203,7 +203,7 @@ int CLStreamRTFInfo::nWriteHeader(char *pszTarget, int nLen) if (nSrcLen > nLen) { - MessageBox(NULL, TranslateT("Failed to write to the Rich Edit the buffer was to small."), MSG_BOX_TITEL, MB_OK); + MessageBox(nullptr, TranslateT("Failed to write to the Rich Edit the buffer was to small."), MSG_BOX_TITEL, MB_OK); return 0; // target buffer to small } @@ -236,14 +236,14 @@ int CLStreamRTFInfo::nLoadFileStream(LPBYTE pbBuff, LONG cb) if (nOptimalReadLen < 500) { - MessageBox(NULL, TranslateT("Error: Optimal buffer size decreased to a too low size!"), MSG_BOX_TITEL, MB_OK); + MessageBox(nullptr, TranslateT("Error: Optimal buffer size decreased to a too low size!"), MSG_BOX_TITEL, MB_OK); return 0; } DWORD dwRead; DWORD dwToRead = nOptimalReadLen; - if (!ReadFile(hFile, abBuf, dwToRead, &dwRead, (LPOVERLAPPED)NULL)) + if (!ReadFile(hFile, abBuf, dwToRead, &dwRead, (LPOVERLAPPED)nullptr)) return 0; DWORD dwCurrent = 0; @@ -293,7 +293,7 @@ int CLStreamRTFInfo::nLoadFileStream(LPBYTE pbBuff, LONG cb) // and rewinde file // we will adjust the optima buffer size nOptimalReadLen -= 50; - SetFilePointer(hFile, n - dwRead, NULL, FILE_CURRENT); + SetFilePointer(hFile, n - dwRead, nullptr, FILE_CURRENT); return dwCurrent; } @@ -326,8 +326,8 @@ int CLStreamRTFInfo::nLoadFileStream(LPBYTE pbBuff, LONG cb) LONG lExtraRead = (n + 1) - dwRead; if (lExtraRead >= 0) - MessageBox(NULL, TranslateT("Internal error! (lExtraRead >= 0)"), MSG_BOX_TITEL, MB_OK); - SetFilePointer(hFile, lExtraRead, NULL, FILE_CURRENT); + MessageBox(nullptr, TranslateT("Internal error! (lExtraRead >= 0)"), MSG_BOX_TITEL, MB_OK); + SetFilePointer(hFile, lExtraRead, nullptr, FILE_CURRENT); bCheckFirstForNick = true; return dwCurrent; } @@ -370,7 +370,7 @@ int CLStreamRTFInfo::nLoadFileStream(LPBYTE pbBuff, LONG cb) int nValue; int nLen = __utf8_get_char((const char *)&abBuf[n], &nValue); if (nLen + n > dwRead) { - SetFilePointer(hFile, n - dwRead, NULL, FILE_CURRENT); + SetFilePointer(hFile, n - dwRead, nullptr, FILE_CURRENT); break; } dwCurrent += sprintf((char*)&pbBuff[dwCurrent], "\\u%d?", nValue); //!!!!!!!!! @@ -456,7 +456,7 @@ bool bOpenExternaly(MCONTACT hContact) SHELLEXECUTEINFO st = { 0 }; st.cbSize = sizeof(st); st.fMask = SEE_MASK_INVOKEIDLIST; - st.hwnd = NULL; + st.hwnd = nullptr; st.lpFile = sPath.c_str(); st.nShow = SW_SHOWDEFAULT; ShellExecuteEx(&st); @@ -470,16 +470,16 @@ bool bOpenExternaly(MCONTACT hContact) STARTUPINFO sStartupInfo = { 0 }; GetStartupInfo(&sStartupInfo); // we parse oure owne info on sStartupInfo.lpTitle = (wchar_t*)sFileViewerPrg.c_str(); - PROCESS_INFORMATION stProcesses = { 0 }; + PROCESS_INFORMATION stProcesses = {}; - if (!CreateProcess(NULL, + if (!CreateProcess(nullptr, (wchar_t*)sTmp.c_str(), - NULL, - NULL, + nullptr, + nullptr, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP, - NULL, - NULL, + nullptr, + nullptr, &sStartupInfo, &stProcesses)) { @@ -554,7 +554,7 @@ bool bUseInternalViewer(bool bNew) DWORD CALLBACK RichEditStreamLoadFile(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { - ReadFile((HANDLE)dwCookie, pbBuff, (DWORD)cb, (DWORD *)pcb, (LPOVERLAPPED)NULL); + ReadFile((HANDLE)dwCookie, pbBuff, (DWORD)cb, (DWORD *)pcb, (LPOVERLAPPED)nullptr); return (DWORD)(*pcb >= 0 ? NOERROR : (*pcb = 0, E_FAIL)); } @@ -568,7 +568,7 @@ DWORD CALLBACK RichEditRTFStreamLoadFile(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG DWORD CALLBACK RichEditStreamSaveFile(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { - WriteFile((HANDLE)dwCookie, pbBuff, cb, (DWORD*)pcb, (LPOVERLAPPED)NULL); + WriteFile((HANDLE)dwCookie, pbBuff, cb, (DWORD*)pcb, (LPOVERLAPPED)nullptr); return *pcb != cb; } @@ -614,8 +614,8 @@ bool bLoadFile(HWND hwndDlg, CLHistoryDlg * pclDlg) } HANDLE hFile = CreateFile(pclDlg->sPath.c_str(), GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) { int nDBCount = db_event_count(pclDlg->hContact); wchar_t szTmp[1500]; @@ -707,7 +707,7 @@ bool bAdvancedCopy(HWND hwnd) int nSelLenght = sSelectRange.cpMax - sSelectRange.cpMin + 1; // +1 for null termination if (nSelLenght > 1) { - if (OpenClipboard(NULL)) { + if (OpenClipboard(nullptr)) { EmptyClipboard(); wchar_t *pszSrcBuf = new wchar_t[nSelLenght]; @@ -775,7 +775,7 @@ LRESULT CALLBACK EditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa SendMessage(hwnd, EM_POSFROMCHAR, (WPARAM)&pt, (LPARAM)dwEnd); ClientToScreen(hwnd, &pt); } - TrackPopupMenu(nSubMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, 0); + TrackPopupMenu(nSubMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, nullptr); DestroyMenu(nSubMenu); DestroyMenu(nMenu); @@ -807,7 +807,7 @@ LRESULT CALLBACK EditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa if (msg == UM_FIND_CMD) { FINDREPLACE *fr = (FINDREPLACE*)lParam; if (fr->Flags & FR_DIALOGTERM) { - pclDlg->hFindDlg = NULL; + pclDlg->hFindDlg = nullptr; return 0; } @@ -861,7 +861,7 @@ void SetWindowsCtrls(HWND hwndDlg) GetWindowRect(hButton, &rCurSize); int nButtonHeight = rCurSize.bottom - rCurSize.top; - SetWindowPos(GetDlgItem(hwndDlg, IDC_RICHEDIT), 0, + SetWindowPos(GetDlgItem(hwndDlg, IDC_RICHEDIT), nullptr, nSpacing, nSpacing, rNewSize.right - (nSpacing * 2), rNewSize.bottom - (nSpacing * 3 + nButtonHeight), @@ -872,17 +872,17 @@ void SetWindowsCtrls(HWND hwndDlg) int nButtonTop = rNewSize.bottom - (nSpacing + nButtonHeight); int nCurLeft = nButtonSpace; - SetWindowPos(GetDlgItem(hwndDlg, IDC_FV_FIND), 0, + SetWindowPos(GetDlgItem(hwndDlg, IDC_FV_FIND), nullptr, nCurLeft, nButtonTop, 0, 0, SWP_NOZORDER | SWP_NOSIZE); nCurLeft += nButtonSpace + nButtonWidth; - SetWindowPos(GetDlgItem(hwndDlg, IDC_FV_EXTERNAL), 0, + SetWindowPos(GetDlgItem(hwndDlg, IDC_FV_EXTERNAL), nullptr, nCurLeft, nButtonTop, 0, 0, SWP_NOZORDER | SWP_NOSIZE); nCurLeft += nButtonSpace + nButtonWidth; - SetWindowPos(hButton, 0, nCurLeft, nButtonTop, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + SetWindowPos(hButton, nullptr, nCurLeft, nButtonTop, 0, 0, SWP_NOZORDER | SWP_NOSIZE); } @@ -952,9 +952,9 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam, SendMessage(hRichEdit, EM_AUTOURLDETECT, TRUE, 0); HMENU hSysMenu = GetSystemMenu(hwndDlg, FALSE); - InsertMenu(hSysMenu, 0, MF_SEPARATOR | MF_BYPOSITION, 0, 0); + InsertMenu(hSysMenu, 0, MF_SEPARATOR | MF_BYPOSITION, 0, nullptr); InsertMenu(hSysMenu, 0, MF_STRING | MF_BYPOSITION, ID_FV_SAVE_AS_RTF, LPGENW("Save as RTF")); - InsertMenu(hSysMenu, 0, MF_SEPARATOR | MF_BYPOSITION, 0, 0); + InsertMenu(hSysMenu, 0, MF_SEPARATOR | MF_BYPOSITION, 0, nullptr); BYTE bUseCC = (BYTE)db_get_b(NULL, MODULE, szFileViewDB "UseCC", 0); InsertMenu(hSysMenu, 0, MF_STRING | MF_BYPOSITION | (bUseCC ? MF_CHECKED : 0), ID_FV_COLOR, LPGENW("Color...")); @@ -1104,7 +1104,7 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam, tstring sFile = pclDlg->sPath; sFile += L".rtf"; HANDLE hFile = CreateFile(sFile.c_str(), GENERIC_WRITE, - FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + FILE_SHARE_READ, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) { DisplayLastError(LPGENW("Failed to create file")); @@ -1124,7 +1124,7 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam, CloseHandle(hFile); tstring sReport = TranslateT("History was saved successfully in file\r\n"); sReport += sFile; - MessageBox(NULL, sReport.c_str(), MSG_BOX_TITEL, MB_OK); + MessageBox(nullptr, sReport.c_str(), MSG_BOX_TITEL, MB_OK); return TRUE; } return FALSE; @@ -1201,7 +1201,7 @@ bool bShowFileViewer(MCONTACT hContact) } CLHistoryDlg *pcl = new CLHistoryDlg(hContact); - pcl->hWnd = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_FILE_VIEWER), NULL, DlgProcFileViewer, (LPARAM)pcl); + pcl->hWnd = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_FILE_VIEWER), nullptr, DlgProcFileViewer, (LPARAM)pcl); if (pcl->hWnd) { mir_cslock lck(csHistoryList); clHistoryDlgList.push_front(pcl); diff --git a/plugins/Msg_Export/src/main.cpp b/plugins/Msg_Export/src/main.cpp index 379d25f4ec..e4b7fcaf51 100755 --- a/plugins/Msg_Export/src/main.cpp +++ b/plugins/Msg_Export/src/main.cpp @@ -19,10 +19,10 @@ #include "stdafx.h" CLIST_INTERFACE *pcli; -HINSTANCE hInstance = NULL; +HINSTANCE hInstance = nullptr; int hLangpack = 0; -MWindowList hInternalWindowList = NULL; +MWindowList hInternalWindowList = nullptr; ///////////////////////////////////////////////////// // Remember to update the Version in the resource !!! @@ -208,7 +208,7 @@ extern "C" __declspec(dllexport) int Load() enRenameAction = (ENDialogAction)db_get_b(NULL, MODULE, "RenameAction", enRenameAction); enDeleteAction = (ENDialogAction)db_get_b(NULL, MODULE, "DeleteAction", enDeleteAction); - HANDLE hServiceFunñ = 0; + HANDLE hServiceFunñ = nullptr; if (bReplaceHistory) hServiceFunñ = CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY, ShowExportHistory); //this need new code diff --git a/plugins/Msg_Export/src/options.cpp b/plugins/Msg_Export/src/options.cpp index 8f5eb3ea6a..51b53fe797 100755 --- a/plugins/Msg_Export/src/options.cpp +++ b/plugins/Msg_Export/src/options.cpp @@ -177,7 +177,7 @@ void exportContactsMessages(void *p) } SendMessage(hProg, PBM_SETPOS, nCur, 0); - RedrawWindow(hDlg, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW); + RedrawWindow(hDlg, nullptr, nullptr, RDW_ALLCHILDREN | RDW_UPDATENOW); nCur++; } @@ -204,7 +204,7 @@ void exportContactsMessages(void *p) wstring sFilePath = FileIterator->first; HANDLE hFile = openCreateFile(sFilePath); if (hFile == INVALID_HANDLE_VALUE) { - DisplayErrorDialog(LPGENW("Failed to open or create file :\n"), sFilePath, NULL); + DisplayErrorDialog(LPGENW("Failed to open or create file :\n"), sFilePath, nullptr); continue; } @@ -226,7 +226,7 @@ void exportContactsMessages(void *p) CloseHandle(hFile); SendMessage(hProg, PBM_SETPOS, ++nCur, 0); - RedrawWindow(hDlg, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW); + RedrawWindow(hDlg, nullptr, nullptr, RDW_ALLCHILDREN | RDW_UPDATENOW); } SendMessage(hDlg, WM_CLOSE, 0, 1); @@ -287,7 +287,7 @@ int nExportCompleatList(HWND hParent, bool bOnlySelected) } // Create progress dialog - HWND hDlg = data->hDialog = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EXPORT_ALL_DLG), NULL, DialogProc); + HWND hDlg = data->hDialog = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EXPORT_ALL_DLG), nullptr, DialogProc); ShowWindow(hDlg, SW_SHOWNORMAL); // Process the export in other thread @@ -628,7 +628,7 @@ static INT_PTR CALLBACK DlgProcMsgExportOpts(HWND hwndDlg, UINT msg, WPARAM wPar LVITEM sItem = { 0 }; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { PROTOACCOUNT *pa = Proto_GetAccount(GetContactProto(hContact)); - if (pa == NULL) + if (pa == nullptr) continue; sItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; @@ -842,11 +842,11 @@ static INT_PTR CALLBACK DlgProcMsgExportOpts(HWND hwndDlg, UINT msg, WPARAM wPar BROWSEINFO sBrowseInfo; sBrowseInfo.hwndOwner = hwndDlg; - sBrowseInfo.pidlRoot = NULL; + sBrowseInfo.pidlRoot = nullptr; sBrowseInfo.pszDisplayName = lpDestDir; sBrowseInfo.lpszTitle = TranslateT("Select Destination Directory"); sBrowseInfo.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX; - sBrowseInfo.lpfn = NULL; + sBrowseInfo.lpfn = nullptr; sBrowseInfo.lParam = 0; sBrowseInfo.iImage = 0; @@ -899,7 +899,7 @@ static INT_PTR CALLBACK DlgProcMsgExportOpts(HWND hwndDlg, UINT msg, WPARAM wPar } TranslateMenu(hMenu); - TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwndDlg, NULL); + TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwndDlg, nullptr); DestroyMenu(hMainMenu); } diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index d56a396bfb..7062447709 100755 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -120,7 +120,7 @@ void ShowDebugInfo() sDebug += L"\r\nGetFilePathFromUser(NULL) :"; sDebug += GetFilePathFromUser(NULL); - MessageBox(NULL, sDebug.c_str(), MSG_BOX_TITEL, MB_OK); + MessageBox(nullptr, sDebug.c_str(), MSG_BOX_TITEL, MB_OK); } @@ -168,12 +168,12 @@ tstring sGetErrorString(DWORD dwError) LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, + nullptr, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR)&lpMsgBuf, 0, - NULL); + nullptr); // Process any inserts in lpMsgBuf. // ... // Display the string. @@ -201,7 +201,7 @@ void DisplayLastError(const wchar_t *pszError) mir_snwprintf(szTemp, L"\r\nErrorCode: %d\r\n", error); sError += szTemp; sError += sGetErrorString(error); - MessageBox(NULL, sError.c_str(), MSG_BOX_TITEL, MB_OK); + MessageBox(nullptr, sError.c_str(), MSG_BOX_TITEL, MB_OK); } ///////////////////////////////////////////////////////////////////// @@ -227,7 +227,7 @@ tstring _DBGetStringW(MCONTACT hContact, const char *szModule, const char *szSet //db_get if (!db_get_ws(hContact, szModule, szSetting, &dbv)) { if (dbv.type != DBVT_WCHAR) { - MessageBox(NULL, TranslateT("Database: Attempt to get wrong type of value, string"), MSG_BOX_TITEL, MB_OK); + MessageBox(nullptr, TranslateT("Database: Attempt to get wrong type of value, string"), MSG_BOX_TITEL, MB_OK); ret = pszError; } else ret = (wchar_t*)dbv.pszVal; @@ -244,7 +244,7 @@ string _DBGetStringA(MCONTACT hContact, const char *szModule, const char *szSett DBVARIANT dbv = { 0 }; if (!db_get(hContact, szModule, szSetting, &dbv)) { if (dbv.type != DBVT_ASCIIZ) { - MessageBox(NULL, TranslateT("Database: Attempt to get wrong type of value, string"), MSG_BOX_TITEL, MB_OK); + MessageBox(nullptr, TranslateT("Database: Attempt to get wrong type of value, string"), MSG_BOX_TITEL, MB_OK); ret = pszError; } else ret = dbv.pszVal; @@ -309,7 +309,7 @@ bool bCreatePathToFile(tstring sFilePath) return false; // create directory - if (!CreateDirectory(sFilePath.c_str(), NULL)) { + if (!CreateDirectory(sFilePath.c_str(), nullptr)) { DWORD dwE = GetLastError(); if (dwE == 183) // Cannot create a file when that file already exists. return true; @@ -318,7 +318,7 @@ bool bCreatePathToFile(tstring sFilePath) return false; // try again - if (!CreateDirectory(sFilePath.c_str(), NULL)) + if (!CreateDirectory(sFilePath.c_str(), nullptr)) return false; } return true; @@ -345,7 +345,7 @@ bool bWriteToFile(HANDLE hFile, const char *pszSrc, int nLen = -1) nLen = (int)mir_strlen(pszSrc); DWORD dwBytesWritten; - return WriteFile(hFile, pszSrc, nLen, &dwBytesWritten, NULL) && (dwBytesWritten == (DWORD)nLen); + return WriteFile(hFile, pszSrc, nLen, &dwBytesWritten, nullptr) && (dwBytesWritten == (DWORD)nLen); } @@ -537,7 +537,7 @@ tstring GetFilePathFromUser(MCONTACT hContact) // Here we will try to avoide the (Unknown Contact) in cases where the protocol for // this user has been removed. - if (bNickUsed && (wcsstr(pcli->pfnGetContactDisplayName(hContact, 0), LPGENW("(Unknown Contact)")) != 0)) + if (bNickUsed && (wcsstr(pcli->pfnGetContactDisplayName(hContact, 0), LPGENW("(Unknown Contact)")) != nullptr)) return sPrevFileName; // Then the filename must have changed from a correct path to one including the (Unknown Contact) // file name has changed @@ -548,10 +548,10 @@ tstring GetFilePathFromUser(MCONTACT hContact) HANDLE hPrevFile = CreateFile(sPrevFileName.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, + nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, - NULL); + nullptr); if (hPrevFile != INVALID_HANDLE_VALUE) { CloseHandle(hPrevFile); @@ -567,7 +567,7 @@ tstring GetFilePathFromUser(MCONTACT hContact) sRemoteUser.c_str(), sPrevFileName.c_str(), sFilePath.c_str()); - bTryRename = MessageBox(NULL, szTemp, MSG_BOX_TITEL, MB_YESNO) == IDYES; + bTryRename = MessageBox(nullptr, szTemp, MSG_BOX_TITEL, MB_YESNO) == IDYES; } else bTryRename = true; @@ -586,7 +586,7 @@ tstring GetFilePathFromUser(MCONTACT hContact) sFilePath.c_str(), sGetErrorString().c_str()); - if (MessageBox(NULL, szTemp, MSG_BOX_TITEL, MB_RETRYCANCEL) != IDRETRY) + if (MessageBox(nullptr, szTemp, MSG_BOX_TITEL, MB_RETRYCANCEL) != IDRETRY) break; } } @@ -818,7 +818,7 @@ void DisplayErrorDialog(const wchar_t *pszError, tstring& sFilePath, DBEVENTINFO sError += sGetErrorString(); sError += TranslateT("\nMessage has not been saved!\n"); sError += TranslateT("Do you wish to save debug information?"); - if (MessageBox(NULL, sError.c_str(), MSG_BOX_TITEL, MB_YESNO) == IDYES) { + if (MessageBox(nullptr, sError.c_str(), MSG_BOX_TITEL, MB_YESNO) == IDYES) { OPENFILENAME ofn; // common dialog box structure wchar_t szFile[260]; // buffer for file name mir_wstrcpy(szFile, L"DebugInfo.txt"); @@ -831,18 +831,18 @@ void DisplayErrorDialog(const wchar_t *pszError, tstring& sFilePath, DBEVENTINFO ofn.nMaxFile = _countof(szFile); ofn.lpstrFilter = TranslateT("All\0*.*\0Text\0*.TXT\0\0"); ofn.nFilterIndex = 1; - ofn.lpstrFileTitle = NULL; + ofn.lpstrFileTitle = nullptr; ofn.nMaxFileTitle = 0; - ofn.lpstrInitialDir = NULL; + ofn.lpstrInitialDir = nullptr; ofn.Flags = 0 /*OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST*/; ofn.lpstrDefExt = L"TXT"; // Display the Open dialog box. if (GetSaveFileName(&ofn)) { HANDLE hf = CreateFile(ofn.lpstrFile, GENERIC_WRITE, - 0, (LPSECURITY_ATTRIBUTES)NULL, + 0, (LPSECURITY_ATTRIBUTES)nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, - (HANDLE)NULL); // file handle + (HANDLE)nullptr); // file handle bWriteTextToFile(hf, sError.c_str(), false); if (dbei) { @@ -911,14 +911,14 @@ bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, tstring sFilePath, DBEVE if (dwLowSize == INVALID_FILE_SIZE || dwLowSize != 0 || dwHighSize != 0) { DWORD dwDataRead = 0; BYTE ucByteOrder[3]; - if (ReadFile(hFile, ucByteOrder, 3, &dwDataRead, NULL)) + if (ReadFile(hFile, ucByteOrder, 3, &dwDataRead, nullptr)) bWriteUTF8Format = bIsUtf8Header(ucByteOrder); - DWORD dwPtr = SetFilePointer(hFile, 0, 0, FILE_END); + DWORD dwPtr = SetFilePointer(hFile, 0, nullptr, FILE_END); if (dwPtr == INVALID_SET_FILE_POINTER) { // we need to aborte mission here because if we continue we risk // overwriting old log. - DisplayErrorDialog(LPGENW("Failed to move to the end of the file :\n"), sFilePath, NULL); + DisplayErrorDialog(LPGENW("Failed to move to the end of the file :\n"), sFilePath, nullptr); return false; } } @@ -926,7 +926,7 @@ bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, tstring sFilePath, DBEVE bWriteUTF8Format = bUseUtf8InNewFiles; if (bWriteUTF8Format) { if (!bWriteToFile(hFile, szUtf8ByteOrderHeader, sizeof(szUtf8ByteOrderHeader) - 1)) { - DisplayErrorDialog(LPGENW("Failed to UTF8 byte order code to file :\n"), sFilePath, NULL); + DisplayErrorDialog(LPGENW("Failed to UTF8 byte order code to file :\n"), sFilePath, nullptr); return false; } } @@ -970,7 +970,7 @@ bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, tstring sFilePath, DBEVE ReplaceAll(output, L"%Gender%", szTemp); if (!bWriteTextToFile(hFile, output.data(), bWriteUTF8Format, (int)output.size())) { - DisplayErrorDialog(LPGENW("Failed to write user details to file :\n"), sFilePath, NULL); + DisplayErrorDialog(LPGENW("Failed to write user details to file :\n"), sFilePath, nullptr); return false; } } @@ -990,7 +990,7 @@ bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, tstring sFilePath, DBEVE return false; } - if (dbei.pBlob != NULL && dbei.cbBlob >= 2) { + if (dbei.pBlob != nullptr && dbei.cbBlob >= 2) { dbei.pBlob[dbei.cbBlob] = 0; switch (dbei.eventType) { @@ -1195,12 +1195,12 @@ HANDLE openCreateFile(tstring sFilePath) { GetLastError();// Clear last error !! - HANDLE hFile = CreateFile(sFilePath.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFile(sFilePath.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) { // this might be because the path isent created // so we will try to create it if (bCreatePathToFile(sFilePath)) { - hFile = CreateFile(sFilePath.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFile(sFilePath.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); } } @@ -1230,7 +1230,7 @@ int nExportEvent(WPARAM hContact, LPARAM hDbEvent) tstring sFilePath = GetFilePathFromUser(hContact); HANDLE hFile = openCreateFile(sFilePath); if (hFile == INVALID_HANDLE_VALUE) { - DisplayErrorDialog(LPGENW("Failed to open or create file :\n"), sFilePath, NULL); + DisplayErrorDialog(LPGENW("Failed to open or create file :\n"), sFilePath, nullptr); return 0; } @@ -1299,7 +1299,7 @@ bool bWriteIndentedToFile(HANDLE hFile, int nIndent, const char *pszSrc, bool bU bool bWriteIndentedToFile(HANDLE hFile, int nIndent, const wchar_t *pszSrc, bool bUtf8File) { - if (pszSrc == NULL) + if (pszSrc == nullptr) return true; bool bOk = true; @@ -1358,7 +1358,7 @@ bool bWriteIndentedToFile(HANDLE hFile, int nIndent, const wchar_t *pszSrc, bool if (pszPrev == pszSrc) { // this is an programming error we have not moved forward in string - MessageBox(NULL, L"Programming error on line __LINE__ please report this", MSG_BOX_TITEL, MB_OK); + MessageBox(nullptr, L"Programming error on line __LINE__ please report this", MSG_BOX_TITEL, MB_OK); break; } } @@ -1403,10 +1403,10 @@ int nContactDeleted(WPARAM wparam, LPARAM /*lparam*/) HANDLE hPrevFile = CreateFile(sFilePath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, + nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, - NULL); + nullptr); if (hPrevFile != INVALID_HANDLE_VALUE) { CloseHandle(hPrevFile); @@ -1416,7 +1416,7 @@ int nContactDeleted(WPARAM wparam, LPARAM /*lparam*/) TranslateT("User has been deleted. Do you want to delete the file?"), sFilePath.c_str()); if (enDeleteAction == eDAAutomatic || - MessageBox(NULL, szTemp, MSG_BOX_TITEL, MB_YESNO) == IDYES) { + MessageBox(nullptr, szTemp, MSG_BOX_TITEL, MB_YESNO) == IDYES) { if (!DeleteFile(sFilePath.c_str())) { mir_snwprintf(szTemp, L"%s\r\n%s", @@ -1466,5 +1466,5 @@ void SaveSettings() wchar_t* GetMyOwnNick(MCONTACT hContact) { wchar_t *p = Contact_GetInfo(CNF_DISPLAY, NULL, GetContactProto(hContact)); - return (p != NULL) ? p : mir_wstrdup(TranslateT("No_Nick")); + return (p != nullptr) ? p : mir_wstrdup(TranslateT("No_Nick")); } -- cgit v1.2.3