From 0ca0de7698b523effaaf6cc9c608e936fa5aaf86 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 2 Dec 2014 21:55:57 +0000 Subject: useless calls of mir_*strlen in DrawText replaced with -1 git-svn-id: http://svn.miranda-ng.org/main/trunk@11223 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/GTalkExt/src/avatar.cpp | 13 +++++-------- protocols/GTalkExt/src/handlers.cpp | 2 +- protocols/GTalkExt/src/inbox.cpp | 6 +++--- protocols/GTalkExt/src/notifications.cpp | 4 ++-- protocols/Gadu-Gadu/src/sessions.cpp | 15 +++++++-------- protocols/IRCG/src/irclib.cpp | 2 +- protocols/JabberG/src/jabber_api.cpp | 2 +- protocols/JabberG/src/jabber_console.cpp | 2 +- protocols/JabberG/src/jabber_file.cpp | 2 +- protocols/JabberG/src/jabber_form.cpp | 7 ++++--- protocols/JabberG/src/jabber_frame.cpp | 4 ++-- protocols/JabberG/src/jabber_groupchat.cpp | 4 ++-- protocols/JabberG/src/jabber_privacy.cpp | 2 +- protocols/Yahoo/src/proto.cpp | 3 +-- 14 files changed, 32 insertions(+), 36 deletions(-) (limited to 'protocols') diff --git a/protocols/GTalkExt/src/avatar.cpp b/protocols/GTalkExt/src/avatar.cpp index 4f3e848c4b..433ac0db65 100644 --- a/protocols/GTalkExt/src/avatar.cpp +++ b/protocols/GTalkExt/src/avatar.cpp @@ -33,21 +33,18 @@ LPTSTR CreateAvaFile(HANDLE *hFile) { TCHAR name[MAX_PATH + 2]; - TCHAR path[MAX_PATH + 2]; - TCHAR full[MAX_PATH + 2]; - if (CallService(MS_DB_GETPROFILENAMET, (WPARAM)SIZEOF(name), (LPARAM)&name)) return NULL; - for (int i = mir_tstrlen(name); i >= 0; i--) - if ('.' == name[i]) { - name[i] = 0; - break; - } + TCHAR *p = _tcsrchr(name, '.'); + if (p) + *p = 0; + TCHAR path[MAX_PATH + 2]; if (CallService(MS_DB_GETPROFILEPATHT, (WPARAM)SIZEOF(path), (LPARAM)&path)) return NULL; + TCHAR full[MAX_PATH + 2]; mir_sntprintf(full, SIZEOF(full), AVA_FILE_NAME_FORMAT, path, name); CreateDirectoryTreeT(full); diff --git a/protocols/GTalkExt/src/handlers.cpp b/protocols/GTalkExt/src/handlers.cpp index 361c33463b..0bfbc8f980 100644 --- a/protocols/GTalkExt/src/handlers.cpp +++ b/protocols/GTalkExt/src/handlers.cpp @@ -45,7 +45,7 @@ GoogleTalkAcc* isGoogle(LPARAM lParam) void FormatMessageUrl(LPCTSTR format, LPTSTR buf, LPCTSTR mailbox, LPCTSTR tid) { ULARGE_INTEGER iTid; iTid.QuadPart = _tstoi64(tid); - int l = mir_tstrlen(buf); + size_t l = mir_tstrlen(buf); mir_sntprintf(buf, l, format, mailbox, iTid.HighPart, iTid.LowPart); assert(l >= mir_tstrlen(buf)); } diff --git a/protocols/GTalkExt/src/inbox.cpp b/protocols/GTalkExt/src/inbox.cpp index 6cf8958914..218c3d28bc 100644 --- a/protocols/GTalkExt/src/inbox.cpp +++ b/protocols/GTalkExt/src/inbox.cpp @@ -60,7 +60,7 @@ LPSTR HttpPost(HANDLE hUser, LPSTR reqUrl, LPSTR reqParams) nlhr.headers = (NETLIBHTTPHEADER*)&HEADER_URL_ENCODED; nlhr.headersCount = 1; nlhr.pData = reqParams; - nlhr.dataLength = mir_strlen(reqParams); + nlhr.dataLength = (int)mir_strlen(reqParams); NETLIBHTTPREQUEST *pResp = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hUser, (LPARAM)&nlhr); if (!pResp) return NULL; @@ -177,8 +177,8 @@ BOOL OpenUrlWithAuth(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url) int pwdLen = GetMailboxPwd(acc, mailbox, NULL, 0); if (!pwdLen++) return FALSE; - int urlLen = mir_tstrlen(url) + 1; - int mailboxLen = mir_tstrlen(mailbox) + 1; + size_t urlLen = mir_tstrlen(url) + 1; + size_t mailboxLen = mir_tstrlen(mailbox) + 1; OPEN_URL_HEADER *data = (OPEN_URL_HEADER*)malloc(sizeof(OPEN_URL_HEADER) + urlLen + mailboxLen + pwdLen); data->url = (LPSTR)data + sizeof(OPEN_URL_HEADER); diff --git a/protocols/GTalkExt/src/notifications.cpp b/protocols/GTalkExt/src/notifications.cpp index ebd601737d..0cdbc1e3b4 100644 --- a/protocols/GTalkExt/src/notifications.cpp +++ b/protocols/GTalkExt/src/notifications.cpp @@ -231,8 +231,8 @@ void ShowNotification(LPCSTR acc, POPUPDATAT *data, LPCTSTR jid, LPCTSTR url, LP } data->PluginWindowProc = PopupProc; - int lurl = (mir_tstrlen(url) + 1) * sizeof(TCHAR); - int ljid = (mir_tstrlen(jid) + 1) * sizeof(TCHAR); + size_t lurl = (mir_tstrlen(url) + 1) * sizeof(TCHAR); + size_t ljid = (mir_tstrlen(jid) + 1) * sizeof(TCHAR); POPUP_DATA_HEADER *ppdh = (POPUP_DATA_HEADER*)malloc(sizeof(POPUP_DATA_HEADER) + lurl + ljid); ppdh->MarkRead = FALSE; diff --git a/protocols/Gadu-Gadu/src/sessions.cpp b/protocols/Gadu-Gadu/src/sessions.cpp index 411730e68d..e9e0205201 100644 --- a/protocols/Gadu-Gadu/src/sessions.cpp +++ b/protocols/Gadu-Gadu/src/sessions.cpp @@ -142,7 +142,7 @@ static BOOL IsOverAction(HWND hwndDlg) szText[0] = 0; ListView_GetItemText(hList, hti.iItem, hti.iSubItem, szText, SIZEOF(szText)); hdc = GetDC(hList); - GetTextExtentPoint32(hdc, szText, mir_tstrlen(szText), &textSize); + GetTextExtentPoint32(hdc, szText, (int)mir_tstrlen(szText), &textSize); ReleaseDC(hList, hdc); textPosX = rc.left + (((rc.right - rc.left) - textSize.cx) / 2); return (hti.pt.x > textPosX && hti.pt.x < textPosX + textSize.cx); @@ -241,18 +241,17 @@ static INT_PTR CALLBACK gg_sessions_viewdlg(HWND hwndDlg, UINT message, WPARAM w : TranslateT("You have to be logged in to view concurrent sessions."); RECT rc; HWND hwndHeader = ListView_GetHeader(nm->nmcd.hdr.hwndFrom); - SIZE textSize; - int textPosX; GetClientRect(nm->nmcd.hdr.hwndFrom, &rc); - if (hwndHeader != NULL) - { + if (hwndHeader != NULL) { RECT rcHeader; GetClientRect(hwndHeader, &rcHeader); rc.top += rcHeader.bottom; } - GetTextExtentPoint32(nm->nmcd.hdc, szText, mir_tstrlen(szText), &textSize); - textPosX = rc.left + (((rc.right - rc.left) - textSize.cx) / 2); - ExtTextOut(nm->nmcd.hdc, textPosX, rc.top + textSize.cy, ETO_OPAQUE, &rc, szText, mir_tstrlen(szText), NULL); + int cbLen = (int)mir_tstrlen(szText); + SIZE textSize; + GetTextExtentPoint32(nm->nmcd.hdc, szText, cbLen, &textSize); + int textPosX = rc.left + (((rc.right - rc.left) - textSize.cx) / 2); + ExtTextOut(nm->nmcd.hdc, textPosX, rc.top + textSize.cy, ETO_OPAQUE, &rc, szText, cbLen, NULL); } // FALL THROUGH diff --git a/protocols/IRCG/src/irclib.cpp b/protocols/IRCG/src/irclib.cpp index 6ecc46abba..97396f1b32 100644 --- a/protocols/IRCG/src/irclib.cpp +++ b/protocols/IRCG/src/irclib.cpp @@ -279,7 +279,7 @@ int CIrcProto::NLSend(const unsigned char* buf, int cbBuf) if (!con || !buf) return 0; if (m_scriptingEnabled && cbBuf == 0) - cbBuf = mir_strlen((const char *)buf); + cbBuf = (int)mir_strlen((const char *)buf); return Netlib_Send(con, (const char*)buf, cbBuf, MSG_DUMPASTEXT); } diff --git a/protocols/JabberG/src/jabber_api.cpp b/protocols/JabberG/src/jabber_api.cpp index 9379e767b5..f23bdb1d6c 100644 --- a/protocols/JabberG/src/jabber_api.cpp +++ b/protocols/JabberG/src/jabber_api.cpp @@ -331,7 +331,7 @@ LPTSTR CJabberProto::GetResourceFeatures(LPCTSTR jid) mir_cslockfull lck(m_csLists); int i; - int iLen = 1; // 1 for extra zero terminator at the end of the string + size_t iLen = 1; // 1 for extra zero terminator at the end of the string // calculate total necessary string length for (i=0; g_JabberFeatCapPairs[i].szFeature; i++) if (jcb & g_JabberFeatCapPairs[i].jcbCap) diff --git a/protocols/JabberG/src/jabber_console.cpp b/protocols/JabberG/src/jabber_console.cpp index 11aae68660..97b027f82a 100644 --- a/protocols/JabberG/src/jabber_console.cpp +++ b/protocols/JabberG/src/jabber_console.cpp @@ -154,7 +154,7 @@ static void sttAppendBufRaw(StringBuf *buf, const char *str) { if (!str) return; - int length = mir_strlen(str); + size_t length = mir_strlen(str); if (buf->size - buf->offset < length + 1) { buf->size += (length + STRINGBUF_INCREMENT); buf->buf = (char *)mir_realloc(buf->buf, buf->size); diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index f22ea22984..1db2348c6e 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -298,7 +298,7 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) mir_free(pFileName); - int len = mir_tstrlen(ptszResource) + mir_tstrlen(ft->jid) + 2; + size_t len = mir_tstrlen(ptszResource) + mir_tstrlen(ft->jid) + 2; TCHAR *fulljid = (TCHAR *)alloca(sizeof(TCHAR) * len); mir_sntprintf(fulljid, len, _T("%s/%s"), ft->jid, ptszResource); diff --git a/protocols/JabberG/src/jabber_form.cpp b/protocols/JabberG/src/jabber_form.cpp index 86dae77ec8..7afa2152b4 100644 --- a/protocols/JabberG/src/jabber_form.cpp +++ b/protocols/JabberG/src/jabber_form.cpp @@ -116,11 +116,12 @@ void JabberFormSetInstruction(HWND hwndForm, const TCHAR *text) { if (!text) text = _T(""); - int len = mir_tstrlen(text); - int fixedLen = len; + size_t len = mir_tstrlen(text); + size_t fixedLen = len; for (int i = 1; i < len; i++) if ((text[i - 1] == _T('\n')) && (text[i] != _T('\r'))) ++fixedLen; + TCHAR *fixedText = NULL; if (fixedLen != len) { fixedText = (TCHAR *)mir_alloc(sizeof(TCHAR) * (fixedLen+1)); @@ -147,7 +148,7 @@ void JabberFormSetInstruction(HWND hwndForm, const TCHAR *text) SetRect(&rcText, 0, 0, rcText.right-rcText.left, 0); HDC hdcEdit = GetDC(GetDlgItem(hwndForm, IDC_INSTRUCTION)); HFONT hfntSave = (HFONT)SelectObject(hdcEdit, (HFONT)SendDlgItemMessage(hwndForm, IDC_INSTRUCTION, WM_GETFONT, 0, 0)); - DrawTextEx(hdcEdit, (TCHAR *)text, mir_tstrlen(text), &rcText, + DrawTextEx(hdcEdit, (TCHAR *)text, (int)mir_tstrlen(text), &rcText, DT_CALCRECT|DT_EDITCONTROL|DT_TOP|DT_WORDBREAK, NULL); SelectObject(hdcEdit, hfntSave); ReleaseDC(GetDlgItem(hwndForm, IDC_INSTRUCTION), hdcEdit); diff --git a/protocols/JabberG/src/jabber_frame.cpp b/protocols/JabberG/src/jabber_frame.cpp index 57f88a79e1..5e0e19cb18 100644 --- a/protocols/JabberG/src/jabber_frame.cpp +++ b/protocols/JabberG/src/jabber_frame.cpp @@ -370,7 +370,7 @@ void CJabberInfoFrame::PaintCompact(HDC hdc) } RECT rcText; SetRect(&rcText, cx_icon + SZ_FRAMEPADDING + SZ_ICONSPACING, 0, rc.right - SZ_FRAMEPADDING, rc.bottom); - DrawText(hdc, item.m_pszText, mir_tstrlen(item.m_pszText), &rcText, DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); + DrawText(hdc, item.m_pszText, -1, &rcText, DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS); } else { if (item.m_hIcolibIcon) { @@ -433,7 +433,7 @@ void CJabberInfoFrame::PaintNormal(HDC hdc) SetTextColor(hdc, depth ? m_clText : m_clTitle); RECT rcText; SetRect(&rcText, cx, cy, rc.right - SZ_FRAMEPADDING, cy + line_height); - DrawText(hdc, item.m_pszText, mir_tstrlen(item.m_pszText), &rcText, DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); + DrawText(hdc, item.m_pszText, -1, &rcText, DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); RemoveTooltip(item.m_tooltipId); diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index 3bdb6ee215..673332e484 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -546,13 +546,13 @@ INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) rc.bottom -= (rc.bottom - rc.top) / 2; rc.left += 20; SetTextColor(lpdis->hDC, clLine1); - DrawText(lpdis->hDC, info->line1, mir_tstrlen(info->line1), &rc, DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_WORD_ELLIPSIS); + DrawText(lpdis->hDC, info->line1, -1, &rc, DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_WORD_ELLIPSIS); rc = lpdis->rcItem; rc.top += (rc.bottom - rc.top) / 2; rc.left += 20; SetTextColor(lpdis->hDC, clLine2); - DrawText(lpdis->hDC, info->line2, mir_tstrlen(info->line2), &rc, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS); + DrawText(lpdis->hDC, info->line2, -1, &rc, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS); DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("group"), 16, 16, 0, NULL, DI_NORMAL); switch (info->overlay) { diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp index d8dfb66fb3..2d0cdc792f 100644 --- a/protocols/JabberG/src/jabber_privacy.cpp +++ b/protocols/JabberG/src/jabber_privacy.cpp @@ -1049,7 +1049,7 @@ void CJabberDlgPrivacyLists::ShowAdvancedList(CPrivacyList *pList) void CJabberDlgPrivacyLists::DrawNextRulePart(HDC hdc, COLORREF color, const TCHAR *text, RECT *rc) { SetTextColor(hdc, color); - DrawText(hdc, text, mir_tstrlen(text), rc, DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_WORD_ELLIPSIS); + DrawText(hdc, text, -1, rc, DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_WORD_ELLIPSIS); SIZE sz; GetTextExtentPoint32(hdc, text, mir_tstrlen(text), &sz); diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp index 635463a261..96a661a942 100644 --- a/protocols/Yahoo/src/proto.cpp +++ b/protocols/Yahoo/src/proto.cpp @@ -513,7 +513,6 @@ int __cdecl CYahooProto::SetStatus(int iNewStatus) void __cdecl CYahooProto::get_status_thread(void *param) { - int l; DBVARIANT dbv; char *gm = NULL, *sm = NULL, *fm; MCONTACT hContact = (MCONTACT)param; @@ -538,7 +537,7 @@ void __cdecl CYahooProto::get_status_thread(void *param) if (sm) sm = strdup(sm); /* we need this to go global FREE later */ } - l = 0; + size_t l = 0; if (gm) l += mir_strlen(gm) + 3; -- cgit v1.2.3