diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/mir_fonts.cpp | 2 | ||||
-rw-r--r-- | utils/mir_options.cpp | 28 | ||||
-rw-r--r-- | utils/mir_smileys.cpp | 34 | ||||
-rw-r--r-- | utils/std_string_utils.cpp | 12 |
4 files changed, 38 insertions, 38 deletions
diff --git a/utils/mir_fonts.cpp b/utils/mir_fonts.cpp index d8b7056adf..7da2bd1eef 100644 --- a/utils/mir_fonts.cpp +++ b/utils/mir_fonts.cpp @@ -19,7 +19,7 @@ int FontService_RegisterFont(const char *pszDbModule, const char *pszDbName, con fid.flags = FIDF_ALLOWREREGISTER; if (bAllowEffects) fid.flags |= FIDF_ALLOWEFFECTS; fid.order = position; - if (plfDefault != NULL) { + if (plfDefault != nullptr) { fid.flags |= FIDF_DEFAULTVALID; fid.deffontsettings.colour = clrDefault; fid.deffontsettings.size = (char)plfDefault->lfHeight; diff --git a/utils/mir_options.cpp b/utils/mir_options.cpp index 20ae7d1f9f..0f4239def3 100644 --- a/utils/mir_options.cpp +++ b/utils/mir_options.cpp @@ -42,7 +42,7 @@ static wchar_t* MyDBGetContactSettingTString(MCONTACT hContact, char* module, ch db_free(&dbv); } else { - if (def != NULL) + if (def != nullptr) mir_wstrncpy(out, def, (int)len); } @@ -97,7 +97,7 @@ static void PathToAbsolute(wchar_t *pOut, size_t outSize, const wchar_t *pSrc) static void LoadOpt(OptPageControl *ctrl, char *module) { - if (ctrl->var == NULL) + if (ctrl->var == nullptr) return; wchar_t tmp[1024]; @@ -126,7 +126,7 @@ static void LoadOpt(OptPageControl *ctrl, char *module) break; case CONTROL_TEXT: - MyDBGetContactSettingTString(NULL, module, ctrl->setting, ((wchar_t *)ctrl->var), min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), ctrl->tszDefValue == NULL ? NULL : TranslateW(ctrl->tszDefValue)); + MyDBGetContactSettingTString(NULL, module, ctrl->setting, ((wchar_t *)ctrl->var), min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), ctrl->tszDefValue == nullptr ? nullptr : TranslateW(ctrl->tszDefValue)); break; case CONTROL_INT: @@ -134,13 +134,13 @@ static void LoadOpt(OptPageControl *ctrl, char *module) break; case CONTROL_FILE: - MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : ctrl->tszDefValue); + MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == nullptr ? nullptr : ctrl->tszDefValue); PathToAbsolute(((wchar_t *)ctrl->var), min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), tmp); break; case CONTROL_COMBO_TEXT: case CONTROL_COMBO_ITEMDATA: - MyDBGetContactSettingTString(NULL, module, ctrl->setting, ((wchar_t *)ctrl->var), min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), ctrl->tszDefValue == NULL ? NULL : TranslateW(ctrl->tszDefValue)); + MyDBGetContactSettingTString(NULL, module, ctrl->setting, ((wchar_t *)ctrl->var), min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), ctrl->tszDefValue == nullptr ? nullptr : TranslateW(ctrl->tszDefValue)); break; } } @@ -162,7 +162,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha for (int i = 0; i < controlsSize; i++) { OptPageControl *ctrl = &controls[i]; - if (GetDlgItem(hwndDlg, ctrl->nID) == NULL) + if (GetDlgItem(hwndDlg, ctrl->nID) == nullptr) continue; switch (ctrl->type) { @@ -213,10 +213,10 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha for (int k = 0; k < count; k++) { PROTOACCOUNT *p = protos[k]; - if (p->szModuleName == NULL || p->szModuleName[0] == '\0') + if (p->szModuleName == nullptr || p->szModuleName[0] == '\0') continue; - if (ctrl->allowProtocol != NULL && !ctrl->allowProtocol(p->szModuleName)) + if (ctrl->allowProtocol != nullptr && !ctrl->allowProtocol(p->szModuleName)) continue; char *setting = (char *)mir_alloc(128 * sizeof(char)); @@ -236,7 +236,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha break; case CONTROL_TEXT: - SetDlgItemText(hwndDlg, ctrl->nID, MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateW(ctrl->tszDefValue))); + SetDlgItemText(hwndDlg, ctrl->nID, MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == nullptr ? nullptr : TranslateW(ctrl->tszDefValue))); SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), 0); break; @@ -246,7 +246,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha break; case CONTROL_FILE: - MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : ctrl->tszDefValue); + MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == nullptr ? nullptr : ctrl->tszDefValue); { wchar_t abs[1024]; PathToAbsolute(abs, 1024, tmp); @@ -256,12 +256,12 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha break; case CONTROL_COMBO_TEXT: - MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateW(ctrl->tszDefValue)); + MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == nullptr ? nullptr : TranslateW(ctrl->tszDefValue)); SendDlgItemMessage(hwndDlg, ctrl->nID, CB_SELECTSTRING, 0, (WPARAM)tmp); break; case CONTROL_COMBO_ITEMDATA: - MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateW(ctrl->tszDefValue)); + MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == nullptr ? nullptr : TranslateW(ctrl->tszDefValue)); { int count = SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCOUNT, 0, 0); int k; @@ -313,7 +313,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha for (int i = 0; i < controlsSize; i++) { OptPageControl *ctrl = &controls[i]; - if (GetDlgItem(hwndDlg, ctrl->nID) == NULL) + if (GetDlgItem(hwndDlg, ctrl->nID) == nullptr) continue; switch (ctrl->type) { @@ -421,7 +421,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha for (int i = 0; i < controlsSize; i++) { OptPageControl *ctrl = &controls[i]; - if (GetDlgItem(hwndDlg, ctrl->nID) == NULL) + if (GetDlgItem(hwndDlg, ctrl->nID) == nullptr) continue; switch (ctrl->type) { diff --git a/utils/mir_smileys.cpp b/utils/mir_smileys.cpp index 64407a4ccf..9758cd5065 100644 --- a/utils/mir_smileys.cpp +++ b/utils/mir_smileys.cpp @@ -89,9 +89,9 @@ SmileysParseInfo Smileys_PreParse(const wchar_t* lpString, int nCount, const cha void Smileys_FreeParse(SmileysParseInfo parseInfo) { - if (parseInfo != NULL) + if (parseInfo != nullptr) { - if (parseInfo->pieces != NULL) + if (parseInfo->pieces != nullptr) DestroySmileyList(parseInfo->pieces); mir_free(parseInfo); @@ -134,7 +134,7 @@ int Smileys_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT nCount = (int)mir_wstrlen(lpString); // Get parse info - if (parseInfo == NULL) + if (parseInfo == nullptr) info = Smileys_PreParse(lpString, nCount, protocol); else info = parseInfo; @@ -162,14 +162,14 @@ int Smileys_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT if (GetClipRgn(hDC, oldRgn) != 1) { DeleteObject(oldRgn); - oldRgn = NULL; + oldRgn = nullptr; } HRGN rgn = CreateRectRgnIndirect(lpRect); ExtSelectClipRgn(hDC, rgn, RGN_AND); // Draw - if (info->pieces == NULL) + if (info->pieces == nullptr) { ret = skin_DrawText(hDC, lpString, nCount, lpRect, uFormat); } @@ -200,7 +200,7 @@ int Smileys_DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT // Free parse info - if (parseInfo == NULL) + if (parseInfo == nullptr) Smileys_FreeParse(info); return ret; @@ -212,7 +212,7 @@ SIZE GetTextSize(HDC hdcMem, const wchar_t *szText, SortedList *plText, UINT uTe { SIZE text_size; - if (szText == NULL) { + if (szText == nullptr) { text_size.cy = 0; text_size.cx = 0; } @@ -223,7 +223,7 @@ SIZE GetTextSize(HDC hdcMem, const wchar_t *szText, SortedList *plText, UINT uTe DrawText(hdcMem, szText, -1, &text_rc, DT_CALCRECT | uTextFormat); text_size.cy = text_rc.bottom - text_rc.top; - if (plText == NULL) + if (plText == nullptr) text_size.cx = text_rc.right - text_rc.left; else { if (!(uTextFormat & DT_RESIZE_SMILEYS)) @@ -260,7 +260,7 @@ SIZE GetTextSize(HDC hdcMem, const wchar_t *szText, SortedList *plText, UINT uTe void DrawTextSmiley(HDC hdcMem, RECT free_rc, const wchar_t *szText, int len, SortedList *plText, UINT uTextFormat, int max_smiley_height) { - if (szText == NULL) + if (szText == nullptr) return; uTextFormat &= ~DT_RIGHT; @@ -345,7 +345,7 @@ void DrawTextSmiley(HDC hdcMem, RECT free_rc, const wchar_t *szText, int len, So text_rc.top += (row_height - (LONG)(piece->smiley_height * factor)) >> 1; skin_DrawIconEx(hdcMem, text_rc.left, text_rc.top, piece->smiley, - (LONG)(piece->smiley_width * factor), (LONG)(piece->smiley_height * factor), 0, NULL, DI_NORMAL); + (LONG)(piece->smiley_width * factor), (LONG)(piece->smiley_height * factor), 0, nullptr, DI_NORMAL); } else { @@ -363,17 +363,17 @@ void DrawTextSmiley(HDC hdcMem, RECT free_rc, const wchar_t *szText, int len, So void DestroySmileyList(SortedList* p_list) { - if (p_list == NULL) + if (p_list == nullptr) return; - if (p_list->items != NULL) + if (p_list->items != nullptr) { int i; for (i = 0; i < p_list->realCount; i++) { TextPiece *piece = (TextPiece *)p_list->items[i]; - if (piece != NULL) + if (piece != nullptr) { if (piece->type == TEXT_PIECE_TYPE_SMILEY) DestroyIcon(piece->smiley); @@ -394,7 +394,7 @@ SortedList * ReplaceSmileys(const wchar_t *text, int text_size, const char *prot *max_smiley_height = 0; if (text[0] == '\0' || !ServiceExists(MS_SMILEYADD_BATCHPARSE)) - return NULL; + return nullptr; // Parse it! SMADD_BATCHPARSE2 sp = { sizeof(sp) }; @@ -402,9 +402,9 @@ SortedList * ReplaceSmileys(const wchar_t *text, int text_size, const char *prot sp.str = (wchar_t*)text; sp.flag = SAFL_TCHAR; SMADD_BATCHPARSERES *spres = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp); - if (spres == NULL) + if (spres == nullptr) // Did not find a simley - return NULL; + return nullptr; // Lets add smileys SortedList *plText = List_Create(0, 10); @@ -416,7 +416,7 @@ SortedList * ReplaceSmileys(const wchar_t *text, int text_size, const char *prot wchar_t *start = _wcsninc(text, spres[i].startChar); wchar_t *end = _wcsninc(start, spres[i].size); - if (spres[i].hIcon != NULL) { // For defective smileypacks + if (spres[i].hIcon != nullptr) { // For defective smileypacks // Add text if (start > next_text_pos) { TextPiece *piece = (TextPiece *)mir_calloc(sizeof(TextPiece)); diff --git a/utils/std_string_utils.cpp b/utils/std_string_utils.cpp index 49cda52844..1cfae0ce69 100644 --- a/utils/std_string_utils.cpp +++ b/utils/std_string_utils.cpp @@ -32,7 +32,7 @@ std::string utils::url::decode(std::string data) if (data.at(i) == '%' && (i + 2) < data.length()) { std::string num = data.substr(i + 1, 2); - unsigned long udn = strtoul(num.c_str(), NULL, 16); + unsigned long udn = strtoul(num.c_str(), nullptr, 16); utils::text::append_ordinal(udn, &new_string); i += 2; continue; @@ -46,7 +46,7 @@ std::string utils::url::decode(std::string data) std::string utils::time::unix_timestamp() { - time_t in = ::time(NULL); + time_t in = ::time(nullptr); return utils::conversion::to_string((void*)&in, UTILS_CONV_TIME_T); } @@ -61,7 +61,7 @@ std::string utils::time::mili_timestamp() time_t utils::time::from_string(const std::string &data) { - long long timestamp = _strtoi64(data.c_str(), NULL, 10); + long long timestamp = _strtoi64(data.c_str(), nullptr, 10); // If it is milli timestamp if (timestamp > 100000000000) @@ -215,7 +215,7 @@ std::string utils::text::html_entities_decode(std::string data) std::string num = data.substr(i, comma - i); if (!num.empty()) { - unsigned long udn = strtoul(num.c_str(), NULL, hexa ? 16 : 10); + unsigned long udn = strtoul(num.c_str(), nullptr, hexa ? 16 : 10); utils::text::append_ordinal(udn, &new_string); } @@ -259,7 +259,7 @@ std::string utils::text::slashu_to_utf8(const std::string &data) { if (data.at(i) == '\\' && (i + 1) < data.length() && data.at(i + 1) == 'u') { - unsigned long udn = strtoul(data.substr(i + 2, 4).c_str(), NULL, 16); + unsigned long udn = strtoul(data.substr(i + 2, 4).c_str(), nullptr, 16); append_ordinal(udn, &new_string); i += 5; continue; @@ -431,7 +431,7 @@ std::string utils::text::truncate_utf8(const std::string &text, size_t maxLength int utils::number::random(int min, int max, unsigned int *number) { - if (number != NULL) { + if (number != nullptr) { errno_t err = rand_s(number); if (!err) return (*number % (max - min)) + min; |