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/SpellChecker/src/RichEdit.cpp | 38 ++++----- plugins/SpellChecker/src/ardialog.cpp | 10 +-- plugins/SpellChecker/src/autoreplace.cpp | 16 ++-- plugins/SpellChecker/src/dictionary.cpp | 64 +++++++-------- plugins/SpellChecker/src/options.cpp | 4 +- plugins/SpellChecker/src/spellchecker.cpp | 24 +++--- plugins/SpellChecker/src/utils.cpp | 124 +++++++++++++++--------------- 7 files changed, 140 insertions(+), 140 deletions(-) (limited to 'plugins/SpellChecker') diff --git a/plugins/SpellChecker/src/RichEdit.cpp b/plugins/SpellChecker/src/RichEdit.cpp index e81e679606..8cc6fd0e20 100644 --- a/plugins/SpellChecker/src/RichEdit.cpp +++ b/plugins/SpellChecker/src/RichEdit.cpp @@ -7,9 +7,9 @@ DEFINE_GUIDXXX(IID_ITextDocument,0x8CC497C0,0xA1DF,0x11CE,0x80,0x98,0x00,0xAA,0x00,0x47,0xBE,0x5D); RichEdit::RichEdit(HWND hwnd) : - m_hwnd(NULL), - m_ole(NULL), - m_textDocument(NULL), + m_hwnd(nullptr), + m_ole(nullptr), + m_textDocument(nullptr), m_stopped(0), m_undoEnabled(TRUE) { @@ -18,12 +18,12 @@ RichEdit::RichEdit(HWND hwnd) : RichEdit::~RichEdit() { - SetHWND(NULL); + SetHWND(nullptr); } bool RichEdit::IsValid() const { - return m_ole != NULL; + return m_ole != nullptr; } HWND RichEdit::GetHWND() const @@ -33,26 +33,26 @@ HWND RichEdit::GetHWND() const void RichEdit::SetHWND(HWND hwnd) { - if (m_textDocument != NULL) { + if (m_textDocument != nullptr) { m_textDocument->Release(); - m_textDocument = NULL; + m_textDocument = nullptr; } - if (m_ole != NULL) { + if (m_ole != nullptr) { m_ole->Release(); - m_ole = NULL; + m_ole = nullptr; } m_hwnd = hwnd; - if (hwnd == NULL) + if (hwnd == nullptr) return; SendMessage(EM_GETOLEINTERFACE, 0, (LPARAM)&m_ole); - if (m_ole == NULL) + if (m_ole == nullptr) return; if (m_ole->QueryInterface(IID_ITextDocument, (void**)&m_textDocument) != S_OK) - m_textDocument = NULL; + m_textDocument = nullptr; } LRESULT RichEdit::SendMessage(UINT Msg, WPARAM wParam, LPARAM lParam) const @@ -67,16 +67,16 @@ bool RichEdit::IsReadOnly() const void RichEdit::SuspendUndo() { - if (m_textDocument != NULL) { - m_textDocument->Undo(tomSuspend, NULL); + if (m_textDocument != nullptr) { + m_textDocument->Undo(tomSuspend, nullptr); m_undoEnabled = FALSE; } } void RichEdit::ResumeUndo() { - if (m_textDocument != NULL) { - m_textDocument->Undo(tomResume, NULL); + if (m_textDocument != nullptr) { + m_textDocument->Undo(tomResume, nullptr); m_undoEnabled = TRUE; } } @@ -123,7 +123,7 @@ void RichEdit::Start() SendMessage(EM_SETSCROLLPOS, 0, (LPARAM)&m_old_scroll_pos); SendMessage(WM_SETREDRAW, TRUE, 0); - InvalidateRect(m_hwnd, NULL, FALSE); + InvalidateRect(m_hwnd, nullptr, FALSE); ResumeUndo(); } @@ -198,12 +198,12 @@ wchar_t* RichEdit::GetText(int start, int end) const if (end <= start) end = GetTextLength(); - if (m_textDocument != NULL) { + if (m_textDocument != nullptr) { ITextRange *range; if (m_textDocument->Range(start, end, &range) != S_OK) return mir_wstrdup(L""); - BSTR text = NULL; + BSTR text = nullptr; if (FAILED(range->GetText(&text))) { if (text) ::SysFreeString(text); diff --git a/plugins/SpellChecker/src/ardialog.cpp b/plugins/SpellChecker/src/ardialog.cpp index f74058bcab..a5948d3ec7 100644 --- a/plugins/SpellChecker/src/ardialog.cpp +++ b/plugins/SpellChecker/src/ardialog.cpp @@ -48,10 +48,10 @@ BOOL ShowAutoReplaceDialog(HWND parent, BOOL modal, data->callback = callback; data->param = param; - if (find != NULL) + if (find != nullptr) data->find = find; - if (replace != NULL) + if (replace != nullptr) data->replace = replace; if (modal) @@ -110,7 +110,7 @@ static LRESULT CALLBACK OnlyCharsEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP static BOOL CenterParent(HWND hwnd) { HWND hwndParent = GetParent(hwnd); - if (hwndParent == NULL) + if (hwndParent == nullptr) return FALSE; RECT rect, rectP; @@ -194,7 +194,7 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa GetWindowRect(GetDlgItem(hwndDlg, IDC_NEW), &rc_new); rc_new.right = rc_old.right; - SetWindowPos(GetDlgItem(hwndDlg, IDC_NEW), NULL, 0, 0, + SetWindowPos(GetDlgItem(hwndDlg, IDC_NEW), nullptr, 0, 0, rc_new.right - rc_new.left, rc_new.bottom - rc_new.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOZORDER); } @@ -252,7 +252,7 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa break; case IDC_VAR_HELP: - variables_showhelp(hwndDlg, IDC_NEW, VHF_FULLDLG, NULL, "The wrong word typed by the user"); + variables_showhelp(hwndDlg, IDC_NEW, VHF_FULLDLG, nullptr, "The wrong word typed by the user"); break; } break; diff --git a/plugins/SpellChecker/src/autoreplace.cpp b/plugins/SpellChecker/src/autoreplace.cpp index 5eb276939b..ea3449e56d 100644 --- a/plugins/SpellChecker/src/autoreplace.cpp +++ b/plugins/SpellChecker/src/autoreplace.cpp @@ -40,7 +40,7 @@ AutoReplaceMap::AutoReplaceMap(wchar_t *aFilename, Dictionary *dict) void AutoReplaceMap::loadAutoReplaceMap() { FILE *file = _wfopen(m_filename, L"rb"); - if (file == NULL) + if (file == nullptr) return; char tmp[1024]; @@ -53,17 +53,17 @@ void AutoReplaceMap::loadAutoReplaceMap() // Get from BOOL useVars = FALSE; char *p; - if ((p = strstr(tmp, "->")) != NULL) { + if ((p = strstr(tmp, "->")) != nullptr) { *p = '\0'; p += 2; } - else if ((p = strstr(tmp, "-V>")) != NULL) { + else if ((p = strstr(tmp, "-V>")) != nullptr) { *p = '\0'; p += 3; useVars = TRUE; } - if (p != NULL) { + if (p != nullptr) { Utf8ToTchar find(tmp); Utf8ToTchar replace(p); @@ -89,7 +89,7 @@ void AutoReplaceMap::writeAutoReplaceMap() { // Create path wchar_t *p = wcsrchr(m_filename, '\\'); - if (p != NULL) { + if (p != nullptr) { *p = 0; CreateDirectoryTreeW(m_filename); *p = '\\'; @@ -97,7 +97,7 @@ void AutoReplaceMap::writeAutoReplaceMap() // Write it FILE *file = _wfopen(m_filename, L"wb"); - if (file != NULL) { + if (file != nullptr) { map::iterator it = m_replacements.begin(); for (; it != m_replacements.end(); it++) { AutoReplacement &ar = it->second; @@ -120,7 +120,7 @@ BOOL AutoReplaceMap::isWordChar(wchar_t c) if (IsNumber(c)) return TRUE; - if (wcschr(L"-_.!@#$%&*()[]{}<>:?/\\=+", c) != NULL) + if (wcschr(L"-_.!@#$%&*()[]{}<>:?/\\=+", c) != nullptr) return TRUE; return m_dict->isWordChar(c); @@ -132,7 +132,7 @@ wchar_t* AutoReplaceMap::autoReplace(const wchar_t * word) scoped_free from = wcslwr(wcsdup(word)); if (m_replacements.find(from.get()) == m_replacements.end()) - return NULL; + return nullptr; AutoReplacement &ar = m_replacements[from.get()]; diff --git a/plugins/SpellChecker/src/dictionary.cpp b/plugins/SpellChecker/src/dictionary.cpp index b5efcd4b29..30ab2b499a 100644 --- a/plugins/SpellChecker/src/dictionary.cpp +++ b/plugins/SpellChecker/src/dictionary.cpp @@ -368,7 +368,7 @@ protected: mir_snwprintf(filename, L"%s\\%s.cdic", userPath, language); FILE *file = _wfopen(filename, L"rb"); - if (file != NULL) { + if (file != nullptr) { char tmp[1024]; int c, pos = 0; while ((c = fgetc(file)) != EOF) { @@ -396,7 +396,7 @@ protected: mir_snwprintf(filename, L"%s\\%s.cdic", userPath, language); FILE *file = _wfopen(filename, L"ab"); - if (file != NULL) { + if (file != nullptr) { char tmp[1024]; toHunspell(tmp, word, _countof(tmp)); fprintf(file, "%s\n", tmp); @@ -417,12 +417,12 @@ protected: void toHunspell(char *hunspellWord, const wchar_t *word, size_t hunspellWordLen) { - WideCharToMultiByte(codePage, 0, word, -1, hunspellWord, (int)hunspellWordLen, NULL, NULL); + WideCharToMultiByte(codePage, 0, word, -1, hunspellWord, (int)hunspellWordLen, nullptr, nullptr); } wchar_t* fromHunspell(const char *hunspellWord) { - int len = MultiByteToWideChar(codePage, 0, hunspellWord, -1, NULL, 0); + int len = MultiByteToWideChar(codePage, 0, hunspellWord, -1, nullptr, 0); WCHAR *ret = (WCHAR *)malloc((len + 1) * sizeof(WCHAR)); MultiByteToWideChar(codePage, 0, hunspellWord, -1, ret, len + 1); return ret; @@ -430,8 +430,8 @@ protected: wchar_t* fromHunspellAndFree(char *hunspellWord) { - if (hunspellWord == NULL) - return NULL; + if (hunspellWord == nullptr) + return nullptr; wchar_t *ret = fromHunspell(hunspellWord); free(hunspellWord); @@ -444,7 +444,7 @@ public: mir_wstrncpy(language, aLanguage, _countof(language)); mir_wstrncpy(fileWithoutExtension, aFileWithoutExtension, _countof(fileWithoutExtension)); mir_wstrncpy(userPath, anUserPath, _countof(userPath)); - if (aSource == NULL) + if (aSource == nullptr) source[0] = '\0'; else mir_wstrncpy(source, aSource, _countof(source)); @@ -453,24 +453,24 @@ public: localized_name[0] = '\0'; english_name[0] = '\0'; full_name[0] = '\0'; - hunspell = NULL; - wordChars = NULL; + hunspell = nullptr; + wordChars = nullptr; codePage = CP_ACP; - autoReplace = NULL; + autoReplace = nullptr; } virtual ~HunspellDictionary() { - if (hunspell != NULL) + if (hunspell != nullptr) delete hunspell; - if (wordChars != NULL) + if (wordChars != nullptr) free(wordChars); } wchar_t * merge(wchar_t * s1, wchar_t *s2) { - int len1 = (s1 == NULL ? 0 : mir_wstrlen(s1)); - int len2 = (s2 == NULL ? 0 : mir_wstrlen(s2)); + int len1 = (s1 == nullptr ? 0 : mir_wstrlen(s1)); + int len2 = (s2 == nullptr ? 0 : mir_wstrlen(s2)); wchar_t *ret; if (len1 > 0 && len2 > 0) { @@ -556,11 +556,11 @@ public: wordChars = merge(merge(casechars, hwordchars), try_string); // Make a suggestion to load hunspell internalls - char ** words = NULL; + char ** words = nullptr; int count = hunspell->suggest(&words, "asdf"); for (int i = 0; i < count; i++) free(words[i]); - if (words != NULL) + if (words != nullptr) free(words); loadCustomDict(); @@ -586,7 +586,7 @@ public: // Return a list of suggestions to a word virtual Suggestions suggest(const wchar_t * word) { - Suggestions ret = { 0 }; + Suggestions ret = {}; load(); if (loaded != LANGUAGE_LOADED) @@ -595,10 +595,10 @@ public: char hunspell_word[1024]; toHunspell(hunspell_word, word, _countof(hunspell_word)); - char ** words = NULL; + char ** words = nullptr; ret.count = hunspell->suggest(&words, hunspell_word); - if (ret.count > 0 && words != NULL) { + if (ret.count > 0 && words != nullptr) { // Oki, lets make our array ret.words = (wchar_t **)malloc(ret.count * sizeof(wchar_t *)); for (unsigned i = 0; i < ret.count; i++) { @@ -606,7 +606,7 @@ public: free(words[i]); } } - if (words != NULL) + if (words != nullptr) free(words); return ret; @@ -615,7 +615,7 @@ public: // Return a list of auto suggestions to a word virtual Suggestions autoSuggest(const wchar_t * word) { - Suggestions ret = { 0 }; + Suggestions ret = {}; load(); if (loaded != LANGUAGE_LOADED) @@ -648,7 +648,7 @@ public: { load(); if (loaded != LANGUAGE_LOADED) - return NULL; + return nullptr; char hunspell_word[1024]; toHunspell(hunspell_word, word, _countof(hunspell_word)); @@ -657,7 +657,7 @@ public: int count = hunspell->suggest(&words, hunspell_word); if (count <= 0) - return NULL; + return nullptr; wchar_t *ret = fromHunspell(words[0]); @@ -679,7 +679,7 @@ public: if (loaded != LANGUAGE_LOADED) return TRUE; - return wcschr(wordChars, c) != NULL; + return wcschr(wordChars, c) != nullptr; } // Assert that all needed data is loaded @@ -725,7 +725,7 @@ LIST *tmp_dicts; // To get the names of the languages BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString) { - wchar_t *stopped = NULL; + wchar_t *stopped = nullptr; USHORT langID = (USHORT)wcstol(lpLocaleString, &stopped, 16); wchar_t ini[32]; @@ -782,7 +782,7 @@ void GetDictsInfo(LIST &dicts) DBVARIANT dbv; char lang[128]; - WideCharToMultiByte(CP_ACP, 0, dict->language, -1, lang, sizeof(lang), NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, dict->language, -1, lang, sizeof(lang), nullptr, nullptr); if (!db_get_ws(NULL, MODULE_NAME, lang, &dbv)) { mir_wstrncpy(dict->localized_name, dbv.ptszVal, _countof(dict->localized_name)); db_free(&dbv); @@ -864,7 +864,7 @@ void GetHunspellDictionariesFromFolder(LIST &dicts, wchar_t *path, w void GetAvaibleDictionaries(LIST &dicts, wchar_t *path, wchar_t *user_path) { // Get miranda folder dicts - GetHunspellDictionariesFromFolder(dicts, path, user_path, NULL); + GetHunspellDictionariesFromFolder(dicts, path, user_path, nullptr); if (opts.use_other_apps_dicts) { // Get other apps dicts @@ -872,11 +872,11 @@ void GetAvaibleDictionaries(LIST &dicts, wchar_t *path, wchar_t *use wchar_t key[1024]; mir_snwprintf(key, APPPATH, otherHunspellApps[i].key); - HKEY hKey = 0; + HKEY hKey = nullptr; LONG lResult = 0; if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_QUERY_VALUE, &hKey)) { DWORD size = _countof(key); - lResult = RegQueryValueEx(hKey, L"Path", NULL, NULL, (LPBYTE)key, &size); + lResult = RegQueryValueEx(hKey, L"Path", nullptr, nullptr, (LPBYTE)key, &size); RegCloseKey(hKey); } else { @@ -884,13 +884,13 @@ void GetAvaibleDictionaries(LIST &dicts, wchar_t *path, wchar_t *use lResult = RegOpenKeyEx(HKEY_CURRENT_USER, MUICACHE, 0, KEY_QUERY_VALUE, &hKey); if (ERROR_SUCCESS == lResult) { DWORD numValues; - if (ERROR_SUCCESS != RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &numValues, NULL, NULL, NULL, NULL)) + if (ERROR_SUCCESS != RegQueryInfoKey(hKey, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, &numValues, nullptr, nullptr, nullptr, nullptr)) numValues = 0; lResult = ERROR_NO_MORE_ITEMS; for (DWORD local = 0; local < numValues; local++) { DWORD cchValue = _countof(key); - if (ERROR_SUCCESS != RegEnumValue(hKey, local, key, &cchValue, NULL, NULL, NULL, NULL)) + if (ERROR_SUCCESS != RegEnumValue(hKey, local, key, &cchValue, nullptr, nullptr, nullptr, nullptr)) break; key[cchValue] = 0; wchar_t *pos; @@ -955,6 +955,6 @@ void FreeSuggestions(Suggestions &suggestions) free(suggestions.words); - suggestions.words = NULL; + suggestions.words = nullptr; suggestions.count = 0; } diff --git a/plugins/SpellChecker/src/options.cpp b/plugins/SpellChecker/src/options.cpp index 578d36c88f..5dd5db0a0d 100644 --- a/plugins/SpellChecker/src/options.cpp +++ b/plugins/SpellChecker/src/options.cpp @@ -140,7 +140,7 @@ static void DrawItem(LPDRAWITEMSTRUCT lpdis, Dictionary *dict) HICON hFlag = IcoLib_GetIconByHandle(dict->hIcolib); rc.top = (lpdis->rcItem.bottom + lpdis->rcItem.top - ICON_SIZE) / 2; - DrawIconEx(lpdis->hDC, rc.left, rc.top, hFlag, 16, 16, 0, NULL, DI_NORMAL); + DrawIconEx(lpdis->hDC, rc.left, rc.top, hFlag, 16, 16, 0, nullptr, DI_NORMAL); rc.left += ICON_SIZE + 4; @@ -343,7 +343,7 @@ static void ShowAddReplacement(HWND hwndDlg, int item = -1) AutoreplaceData *data = (AutoreplaceData *)SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, sel, 0); wchar_t find[256]; - const wchar_t *replace = NULL; + const wchar_t *replace = nullptr; BOOL useVariables = FALSE; if (item < 0) diff --git a/plugins/SpellChecker/src/spellchecker.cpp b/plugins/SpellChecker/src/spellchecker.cpp index 4726369e2b..935749e4ac 100644 --- a/plugins/SpellChecker/src/spellchecker.cpp +++ b/plugins/SpellChecker/src/spellchecker.cpp @@ -39,13 +39,13 @@ HINSTANCE hInst; int hLangpack = 0; -HANDLE hDictionariesFolder = NULL; +HANDLE hDictionariesFolder = nullptr; wchar_t *dictionariesFolder; -HANDLE hCustomDictionariesFolder = NULL; +HANDLE hCustomDictionariesFolder = nullptr; wchar_t *customDictionariesFolder; -HANDLE hFlagsDllFolder = NULL; +HANDLE hFlagsDllFolder = nullptr; wchar_t *flagsDllFolder; HBITMAP hCheckedBmp; @@ -135,12 +135,12 @@ static int ModulesLoaded(WPARAM, LPARAM) // Load flags dll wchar_t flag_file[MAX_PATH]; mir_snwprintf(flag_file, L"%s\\flags_icons.dll", flagsDllFolder); - HMODULE hFlagsDll = LoadLibraryEx(flag_file, NULL, LOAD_LIBRARY_AS_DATAFILE); + HMODULE hFlagsDll = LoadLibraryEx(flag_file, nullptr, LOAD_LIBRARY_AS_DATAFILE); wchar_t path[MAX_PATH]; GetModuleFileName(hInst, path, MAX_PATH); - SKINICONDESC sid = { 0 }; + SKINICONDESC sid = {}; sid.flags = SIDF_ALL_UNICODE | SIDF_SORTED; sid.section.w = LPGENW("Spell Checker") L"/" LPGENW("Flags"); @@ -153,26 +153,26 @@ static int ModulesLoaded(WPARAM, LPARAM) mir_snprintf(lang, "spell_lang_%d", i); sid.pszName = lang; - HICON hFlag = NULL, hFlagIcoLib = NULL; - if (hFlagsDll != NULL) + HICON hFlag = nullptr, hFlagIcoLib = nullptr; + if (hFlagsDll != nullptr) hFlag = (HICON)LoadImage(hFlagsDll, p->language, IMAGE_ICON, 16, 16, 0); - if (hFlag != NULL) { + if (hFlag != nullptr) { sid.hDefaultIcon = hFlag; - sid.defaultFile.w = NULL; + sid.defaultFile.w = nullptr; sid.iDefaultIndex = 0; } else { hFlagIcoLib = IcoLib_GetIcon("spellchecker_unknown"); sid.hDefaultIcon = hFlagIcoLib; - sid.defaultFile.w = NULL; + sid.defaultFile.w = nullptr; sid.iDefaultIndex = 0; } // Oki, lets add to IcoLib, then p->hIcolib = IcoLib_AddIcon(&sid); - if (hFlag != NULL) + if (hFlag != nullptr) DestroyIcon(hFlag); else IcoLib_ReleaseIcon(hFlagIcoLib); @@ -248,7 +248,7 @@ extern "C" int __declspec(dllexport) Load(void) CreateServiceFunction(MS_SPELLCHECKER_REMOVE_RICHEDIT, RemoveContactTextBoxService); CreateServiceFunction(MS_SPELLCHECKER_SHOW_POPUP_MENU, ShowPopupMenuService); - hCheckedBmp = LoadBitmap(NULL, MAKEINTRESOURCE(OBM_CHECK)); + hCheckedBmp = LoadBitmap(nullptr, MAKEINTRESOURCE(OBM_CHECK)); if (GetObject(hCheckedBmp, sizeof(bmpChecked), &bmpChecked) == 0) bmpChecked.bmHeight = bmpChecked.bmWidth = 10; diff --git a/plugins/SpellChecker/src/utils.cpp b/plugins/SpellChecker/src/utils.cpp index 0c62b9e307..57f29e47ff 100644 --- a/plugins/SpellChecker/src/utils.cpp +++ b/plugins/SpellChecker/src/utils.cpp @@ -108,7 +108,7 @@ inline BOOL IsURL(wchar_t c) || c == '@' || c == '#'; } -int FindURLEnd(Dialog *dlg, wchar_t *text, int start_pos, int *checked_until = NULL) +int FindURLEnd(Dialog *dlg, wchar_t *text, int start_pos, int *checked_until = nullptr) { int num_slashes = 0; int num_ats = 0; @@ -126,7 +126,7 @@ int FindURLEnd(Dialog *dlg, wchar_t *text, int start_pos, int *checked_until = N num_ats++; } - if (checked_until != NULL) + if (checked_until != nullptr) *checked_until = i; if (num_slashes <= 0 && num_ats <= 0 && num_dots <= 0) @@ -218,7 +218,7 @@ public: // Has to auto-correct? if (opts.auto_replace_dict) { *replacement = dict->autoSuggestOne(text); - if (*replacement != NULL) { + if (*replacement != nullptr) { *replace = true; return; } @@ -264,7 +264,7 @@ public: virtual void deal(const wchar_t *text, bool*, bool *replace, wchar_t **replacement) { *replacement = ar->autoReplace(text); - if (*replacement != NULL) + if (*replacement != nullptr) *replace = true; } }; @@ -356,7 +356,7 @@ int CheckTextLine(Dialog *dlg, int line, TextParser *parser, bool mark = false; bool replace = false; - wchar_t *replacement = NULL; + wchar_t *replacement = nullptr; parser->deal(&text[last_pos], &mark, &replace, &replacement); if (replace) { @@ -378,7 +378,7 @@ int CheckTextLine(Dialog *dlg, int line, TextParser *parser, else if (mark) { SetUnderline(dlg, sel.cpMin, sel.cpMax); - if (callback != NULL) + if (callback != nullptr) callback(&text[last_pos], sel, param); errors++; @@ -389,7 +389,7 @@ int CheckTextLine(Dialog *dlg, int line, TextParser *parser, } // Checks for errors in all text -int CheckText(Dialog *dlg, BOOL check_all, FoundWrongWordCallback callback = NULL, void *param = NULL) +int CheckText(Dialog *dlg, BOOL check_all, FoundWrongWordCallback callback = nullptr, void *param = nullptr) { int errors = 0; @@ -433,7 +433,7 @@ int CheckText(Dialog *dlg, BOOL check_all, FoundWrongWordCallback callback = NUL void ToLocaleID(wchar_t *szKLName, size_t size) { - wchar_t *stopped = NULL; + wchar_t *stopped = nullptr; USHORT langID = (USHORT)wcstol(szKLName, &stopped, 16); wchar_t ini[32], end[32]; @@ -466,11 +466,11 @@ int TimerCheck(Dialog *dlg, BOOL forceCheck = FALSE) { KillTimer(dlg->hwnd, TIMER_ID); - if (!dlg->enabled || dlg->lang == NULL) + if (!dlg->enabled || dlg->lang == nullptr) return -1; if (!dlg->lang->isLoaded()) { - SetTimer(dlg->hwnd, TIMER_ID, 500, NULL); + SetTimer(dlg->hwnd, TIMER_ID, 500, nullptr); return -1; } @@ -517,7 +517,7 @@ LRESULT CALLBACK OwnerProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) // Schedule to re-parse KillTimer(dlg->hwnd, TIMER_ID); - SetTimer(dlg->hwnd, TIMER_ID, 100, NULL); + SetTimer(dlg->hwnd, TIMER_ID, 100, nullptr); dlg->changed = TRUE; } @@ -534,7 +534,7 @@ void ToggleEnabled(Dialog *dlg) SetNoUnderline(dlg); else { dlg->changed = TRUE; - SetTimer(dlg->hwnd, TIMER_ID, 100, NULL); + SetTimer(dlg->hwnd, TIMER_ID, 100, nullptr); } if (dlg->srmm) @@ -548,7 +548,7 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return -1; Dialog *dlg = dlgit->second; - if (dlg == NULL) + if (dlg == nullptr) return -1; // Hotkey support @@ -584,14 +584,14 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) // Need to do that to avoid changing the word while typing KillTimer(hwnd, TIMER_ID); - SetTimer(hwnd, TIMER_ID, 1000, NULL); + SetTimer(hwnd, TIMER_ID, 1000, nullptr); dlg->changed = TRUE; if (!deleting && (lParam & 0xFF) > 1) // Repeat rate break; - if (!dlg->enabled || dlg->lang == NULL || !dlg->lang->isLoaded()) + if (!dlg->enabled || dlg->lang == nullptr || !dlg->lang->isLoaded()) break; // Don't check if field is read-only @@ -632,7 +632,7 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; KillTimer(hwnd, TIMER_ID); - SetTimer(hwnd, TIMER_ID, 100, NULL); + SetTimer(hwnd, TIMER_ID, 100, nullptr); dlg->changed = TRUE; break; @@ -644,7 +644,7 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WMU_DICT_CHANGED: KillTimer(hwnd, TIMER_ID); - SetTimer(hwnd, TIMER_ID, 100, NULL); + SetTimer(hwnd, TIMER_ID, 100, nullptr); dlg->changed = TRUE; break; @@ -652,7 +652,7 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WMU_KBDL_CHANGED: if (opts.auto_locale) { KillTimer(hwnd, TIMER_ID); - SetTimer(hwnd, TIMER_ID, 100, NULL); + SetTimer(hwnd, TIMER_ID, 100, nullptr); dlg->changed = TRUE; @@ -683,7 +683,7 @@ int GetClosestLanguage(wchar_t *lang_name) mir_wstrncpy(lang, lang_name, _countof(lang)); { wchar_t *p = wcschr(lang, '_'); - if (p != NULL) *p = '\0'; + if (p != nullptr) *p = '\0'; } // First check if there is a language that is only the prefix @@ -695,7 +695,7 @@ int GetClosestLanguage(wchar_t *lang_name) size_t len = mir_wstrlen(lang); for (i = 0; i < languages.getCount(); i++) { wchar_t *p = wcschr(languages[i]->language, '_'); - if (p == NULL) + if (p == nullptr) continue; size_t prefix_len = p - languages[i]->language; @@ -716,7 +716,7 @@ void GetUserProtoLanguageSetting(Dialog *dlg, MCONTACT hContact, char *group, ch int caps = (isProtocol ? CallProtoService(group, PS_GETCAPS, PFLAGNUM_4, 0) : 0); if (caps & PF4_INFOSETTINGSVC) { - DBCONTACTGETSETTING cgs = { 0 }; + DBCONTACTGETSETTING cgs = {}; cgs.szModule = group; cgs.szSetting = setting; cgs.pValue = &dbv; @@ -728,7 +728,7 @@ void GetUserProtoLanguageSetting(Dialog *dlg, MCONTACT hContact, char *group, ch return; } - if (dbv.type == DBVT_WCHAR && dbv.ptszVal != NULL) { + if (dbv.type == DBVT_WCHAR && dbv.ptszVal != nullptr) { wchar_t *lang = dbv.ptszVal; for (int i = 0; i < languages.getCount(); i++) { @@ -747,7 +747,7 @@ void GetUserProtoLanguageSetting(Dialog *dlg, MCONTACT hContact, char *group, ch void GetUserLanguageSetting(Dialog *dlg, char *setting) { char *proto = GetContactProto(dlg->hContact); - if (proto == NULL) + if (proto == nullptr) return; GetUserProtoLanguageSetting(dlg, dlg->hContact, proto, setting); @@ -834,7 +834,7 @@ void GetContactLanguage(Dialog *dlg) dlg->lang = languages[i]; dlg->lang->load(); } - else dlg->lang = NULL; + else dlg->lang = nullptr; } void ModifyIcon(Dialog *dlg) @@ -857,10 +857,10 @@ void ModifyIcon(Dialog *dlg) INT_PTR AddContactTextBoxService(WPARAM wParam, LPARAM) { SPELLCHECKER_ITEM *sci = (SPELLCHECKER_ITEM *)wParam; - if (sci == NULL || sci->cbSize != sizeof(SPELLCHECKER_ITEM)) + if (sci == nullptr || sci->cbSize != sizeof(SPELLCHECKER_ITEM)) return -1; - return AddContactTextBox(sci->hContact, sci->hwnd, sci->window_name, FALSE, NULL); + return AddContactTextBox(sci->hContact, sci->hwnd, sci->window_name, FALSE, nullptr); } int AddContactTextBox(MCONTACT hContact, HWND hwnd, char *name, BOOL srmm, HWND hwndOwner) @@ -894,7 +894,7 @@ int AddContactTextBox(MCONTACT hContact, HWND hwnd, char *name, BOOL srmm, HWND mir_subclassWindow(dlg->hwnd, EditProc); dialogs[hwnd] = dlg; - if (dlg->srmm && hwndOwner != NULL) { + if (dlg->srmm && hwndOwner != nullptr) { dlg->hwnd_owner = hwndOwner; mir_subclassWindow(dlg->hwnd_owner, OwnerProc); dialogs[dlg->hwnd_owner] = dlg; @@ -902,10 +902,10 @@ int AddContactTextBox(MCONTACT hContact, HWND hwnd, char *name, BOOL srmm, HWND ModifyIcon(dlg); } - if (dlg->lang != NULL) + if (dlg->lang != nullptr) dlg->lang->load(); - SetTimer(hwnd, TIMER_ID, 1000, NULL); + SetTimer(hwnd, TIMER_ID, 1000, nullptr); } return 0; @@ -918,7 +918,7 @@ void FreePopupData(Dialog *dlg) DESTROY_MENY(dlg->hLanguageSubMenu); DESTROY_MENY(dlg->hWrongWordsSubMenu); - if (dlg->wrong_words != NULL) { + if (dlg->wrong_words != nullptr) { for (unsigned i = 0; i < dlg->wrong_words->size(); i++) { FREE((*dlg->wrong_words)[i].word); @@ -930,14 +930,14 @@ void FreePopupData(Dialog *dlg) } delete dlg->wrong_words; - dlg->wrong_words = NULL; + dlg->wrong_words = nullptr; } } INT_PTR RemoveContactTextBoxService(WPARAM wParam, LPARAM) { HWND hwnd = (HWND)wParam; - if (hwnd == NULL) + if (hwnd == nullptr) return -1; return RemoveContactTextBox(hwnd); @@ -956,7 +956,7 @@ int RemoveContactTextBox(HWND hwnd) mir_unsubclassWindow(dlg->hwnd_owner, OwnerProc); dialogs.erase(hwnd); - if (dlg->hwnd_owner != NULL) + if (dlg->hwnd_owner != nullptr) dialogs.erase(dlg->hwnd_owner); delete dlg->re; @@ -1004,7 +1004,7 @@ wchar_t *GetWordUnderPoint(Dialog *dlg, POINT pt, CHARRANGE &sel) { // Get text if (dlg->re->GetTextLength() <= 0) - return NULL; + return nullptr; // Get pos sel.cpMin = sel.cpMax = dlg->re->GetCharFromPos(pt); @@ -1014,7 +1014,7 @@ wchar_t *GetWordUnderPoint(Dialog *dlg, POINT pt, CHARRANGE &sel) int first_char; if (!GetWordCharRange(dlg, sel, text, _countof(text), first_char)) - return NULL; + return nullptr; // copy the word text[sel.cpMax - first_char] = '\0'; @@ -1058,7 +1058,7 @@ void AppendMenuItem(HMENU hMenu, int id, wchar_t *name, HICON hIcon, BOOL checke void AddMenuForWord(Dialog *dlg, wchar_t *word, CHARRANGE &pos, HMENU hMenu, BOOL in_submenu, UINT base) { - if (dlg->wrong_words == NULL) + if (dlg->wrong_words == nullptr) dlg->wrong_words = new vector(1); else dlg->wrong_words->resize(dlg->wrong_words->size() + 1); @@ -1083,7 +1083,7 @@ void AddMenuForWord(Dialog *dlg, wchar_t *word, CHARRANGE &pos, HMENU hMenu, BOO InsertMenu(data.hReplaceSubMenu, 0, MF_BYPOSITION, base + AUTOREPLACE_MENU_ID_BASE + suggestions.count, TranslateT("Other...")); if (suggestions.count > 0) { - InsertMenu(data.hReplaceSubMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0); + InsertMenu(data.hReplaceSubMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, nullptr); for (int i = (int)suggestions.count - 1; i >= 0; i--) InsertMenu(data.hReplaceSubMenu, 0, MF_BYPOSITION, base + AUTOREPLACE_MENU_ID_BASE + i, suggestions.words[i]); } @@ -1100,7 +1100,7 @@ void AddMenuForWord(Dialog *dlg, wchar_t *word, CHARRANGE &pos, HMENU hMenu, BOO AppendSubmenu(hMenu, hSubMenu, TranslateT("Corrections")); } else { - InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0); + InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, nullptr); hSubMenu = hMenu; } @@ -1109,7 +1109,7 @@ void AddMenuForWord(Dialog *dlg, wchar_t *word, CHARRANGE &pos, HMENU hMenu, BOO } if (!in_submenu && opts.show_wrong_word) { - InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0); + InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, nullptr); wchar_t text[128]; mir_snwprintf(text, TranslateT("Wrong word: %s"), word); @@ -1142,12 +1142,12 @@ void AddItemsToMenu(Dialog *dlg, HMENU hMenu, POINT pt, HWND hwndOwner) // Make menu if (GetMenuItemCount(hMenu) > 0) - InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0); + InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, nullptr); if (languages.getCount() > 0 && dlg->enabled) { dlg->hLanguageSubMenu = CreatePopupMenu(); - if (dlg->hwnd_menu_owner != NULL) + if (dlg->hwnd_menu_owner != nullptr) mir_subclassWindow(dlg->hwnd_menu_owner, MenuWndProc); // First add languages @@ -1162,7 +1162,7 @@ void AddItemsToMenu(Dialog *dlg, HMENU hMenu, POINT pt, HWND hwndOwner) CheckMenuItem(hMenu, 1, MF_BYCOMMAND | (dlg->enabled ? MF_CHECKED : MF_UNCHECKED)); // Get text - if (dlg->lang != NULL && dlg->enabled) { + if (dlg->lang != nullptr && dlg->enabled) { if (opts.show_all_corrections) { dlg->hWrongWordsSubMenu = CreatePopupMenu(); @@ -1175,8 +1175,8 @@ void AddItemsToMenu(Dialog *dlg, HMENU hMenu, POINT pt, HWND hwndOwner) else { CHARRANGE sel; wchar_t *word = GetWordUnderPoint(dlg, pt, sel); - if (word != NULL && !dlg->lang->spell(word)) { - InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0); + if (word != nullptr && !dlg->lang->spell(word)) { + InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, nullptr); AddMenuForWord(dlg, word, sel, hMenu, FALSE, WORD_MENU_ID_BASE); } } @@ -1194,7 +1194,7 @@ static void AddWordToDictCallback(BOOL canceled, Dictionary *dict, dict->autoReplace->add(find, replace, useVariables); HWND hwndParent = (HWND)param; - if (hwndParent != NULL) + if (hwndParent != nullptr) PostMessage(hwndParent, WMU_DICT_CHANGED, 0, 0); } @@ -1224,7 +1224,7 @@ BOOL HandleMenuSelection(Dialog *dlg, unsigned selection) ret = TRUE; } - else if (selection > 0 && dlg->wrong_words != NULL + else if (selection > 0 && dlg->wrong_words != nullptr && selection >= WORD_MENU_ID_BASE && selection < (dlg->wrong_words->size() + 1) * WORD_MENU_ID_BASE) { int pos = selection / WORD_MENU_ID_BASE; @@ -1248,8 +1248,8 @@ BOOL HandleMenuSelection(Dialog *dlg, unsigned selection) else if (selection >= AUTOREPLACE_MENU_ID_BASE && selection < AUTOREPLACE_MENU_ID_BASE + data.suggestions.count + 1) { selection -= AUTOREPLACE_MENU_ID_BASE; if (selection == data.suggestions.count) { - ShowAutoReplaceDialog(dlg->hwnd_owner != NULL ? dlg->hwnd_owner : dlg->hwnd, FALSE, - dlg->lang, data.word, NULL, FALSE, + ShowAutoReplaceDialog(dlg->hwnd_owner != nullptr ? dlg->hwnd_owner : dlg->hwnd, FALSE, + dlg->lang, data.word, nullptr, FALSE, TRUE, &AddWordToDictCallback, dlg->hwnd); } else { @@ -1263,7 +1263,7 @@ BOOL HandleMenuSelection(Dialog *dlg, unsigned selection) if (ret) { KillTimer(dlg->hwnd, TIMER_ID); - SetTimer(dlg->hwnd, TIMER_ID, 100, NULL); + SetTimer(dlg->hwnd, TIMER_ID, 100, nullptr); dlg->changed = TRUE; } @@ -1275,7 +1275,7 @@ BOOL HandleMenuSelection(Dialog *dlg, unsigned selection) int MsgWindowPopup(WPARAM, LPARAM lParam) { MessageWindowPopupData *mwpd = (MessageWindowPopupData *)lParam; - if (mwpd == NULL || mwpd->uFlags != MSG_WINDOWPOPUP_INPUT) + if (mwpd == nullptr || mwpd->uFlags != MSG_WINDOWPOPUP_INPUT) return 0; DialogMapType::iterator dlgit = dialogs.find(mwpd->hwnd); @@ -1298,10 +1298,10 @@ int MsgWindowPopup(WPARAM, LPARAM lParam) INT_PTR ShowPopupMenuService(WPARAM wParam, LPARAM) { SPELLCHECKER_POPUPMENU *scp = (SPELLCHECKER_POPUPMENU *)wParam; - if (scp == NULL || scp->cbSize != sizeof(SPELLCHECKER_POPUPMENU)) + if (scp == nullptr || scp->cbSize != sizeof(SPELLCHECKER_POPUPMENU)) return -1; - return ShowPopupMenu(scp->hwnd, scp->hMenu, scp->pt, scp->hwndOwner == NULL ? scp->hwnd : scp->hwndOwner); + return ShowPopupMenu(scp->hwnd, scp->hMenu, scp->pt, scp->hwndOwner == nullptr ? scp->hwnd : scp->hwndOwner); } int ShowPopupMenu(HWND hwnd, HMENU hMenu, POINT pt, HWND hwndOwner) @@ -1321,7 +1321,7 @@ int ShowPopupMenu(HWND hwnd, HMENU hMenu, POINT pt, HWND hwndOwner) } else ScreenToClient(hwnd, &pt); - BOOL create_menu = (hMenu == NULL); + BOOL create_menu = (hMenu == nullptr); if (create_menu) hMenu = CreatePopupMenu(); @@ -1330,7 +1330,7 @@ int ShowPopupMenu(HWND hwnd, HMENU hMenu, POINT pt, HWND hwndOwner) // Show menu ClientToScreen(hwnd, &pt); - int selection = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndOwner, NULL); + int selection = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndOwner, nullptr); // Do action if (HandleMenuSelection(dlg, selection)) @@ -1345,7 +1345,7 @@ int ShowPopupMenu(HWND hwnd, HMENU hMenu, POINT pt, HWND hwndOwner) int MsgWindowEvent(WPARAM, LPARAM lParam) { MessageWindowEventData *event = (MessageWindowEventData *)lParam; - if (event == NULL) + if (event == nullptr) return 0; if (event->uType == MSG_WINDOW_EVT_OPEN) @@ -1360,14 +1360,14 @@ int MsgWindowEvent(WPARAM, LPARAM lParam) int IconPressed(WPARAM hContact, LPARAM lParam) { StatusIconClickData *sicd = (StatusIconClickData *)lParam; - if (sicd == NULL || mir_strcmp(sicd->szModule, MODULE_NAME) != 0) + if (sicd == nullptr || mir_strcmp(sicd->szModule, MODULE_NAME) != 0) return 0; if (hContact == NULL) return 0; // Find the dialog - Dialog *dlg = NULL; + Dialog *dlg = nullptr; for (DialogMapType::iterator it = dialogs.begin(); it != dialogs.end(); it++) { Dialog *p = it->second; if (p->srmm && p->hContact == hContact) { @@ -1376,7 +1376,7 @@ int IconPressed(WPARAM hContact, LPARAM lParam) } } - if (dlg == NULL) + if (dlg == nullptr) return 0; if ((sicd->flags & MBCF_RIGHTBUTTON) == 0) { @@ -1396,14 +1396,14 @@ int IconPressed(WPARAM hContact, LPARAM lParam) for (int i = 0; i < languages.getCount(); i++) AppendMenu(hMenu, MF_STRING | (languages[i] == dlg->lang ? MF_CHECKED : 0), LANGUAGE_MENU_ID_BASE + i, languages[i]->full_name); - InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0); + InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, nullptr); } InsertMenu(hMenu, 0, MF_BYPOSITION, 1, TranslateT("Enable spell checking")); CheckMenuItem(hMenu, 1, MF_BYCOMMAND | (dlg->enabled ? MF_CHECKED : MF_UNCHECKED)); // Show menu - int selection = TrackPopupMenu(hMenu, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, dlg->hwnd, NULL); + int selection = TrackPopupMenu(hMenu, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, dlg->hwnd, nullptr); HandleMenuSelection(dlg, selection); DestroyMenu(hMenu); } @@ -1436,7 +1436,7 @@ LRESULT CALLBACK MenuWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) GetMenuItemInfo(hMenu, id, FALSE, &mii); // Make ownerdraw - ModifyMenu(hMenu, id, mii.fState | MF_BYCOMMAND | MF_OWNERDRAW, id, NULL); + ModifyMenu(hMenu, id, mii.fState | MF_BYCOMMAND | MF_OWNERDRAW, id, nullptr); } } break; @@ -1484,7 +1484,7 @@ LRESULT CALLBACK MenuWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) HICON hFlag = IcoLib_GetIconByHandle(dict->hIcolib); rc.top = (lpdis->rcItem.bottom + lpdis->rcItem.top - ICON_SIZE) / 2; - DrawIconEx(lpdis->hDC, rc.left, rc.top, hFlag, 16, 16, 0, NULL, DI_NORMAL); + DrawIconEx(lpdis->hDC, rc.left, rc.top, hFlag, 16, 16, 0, nullptr, DI_NORMAL); IcoLib_ReleaseIcon(hFlag); -- cgit v1.2.3