summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/utils.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-12-13 19:53:55 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-12-13 19:53:55 +0000
commit087300b294b87ab2705244908ec932a5a8c98262 (patch)
tree2f95e894f876d3d8876ac8f1902edc994b9992bd /plugins/TabSRMM/src/utils.cpp
parentcb6be442595479bfd577d4cc7399861ff246f5e7 (diff)
fix for the url extractor
git-svn-id: http://svn.miranda-ng.org/main/trunk@11377 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/utils.cpp')
-rw-r--r--plugins/TabSRMM/src/utils.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp
index 960def80c4..80bded6da8 100644
--- a/plugins/TabSRMM/src/utils.cpp
+++ b/plugins/TabSRMM/src/utils.cpp
@@ -959,23 +959,22 @@ bool Utils::extractResource(const HMODULE h, const UINT uID, const TCHAR *tszNam
// @param hwndRich - rich edit window handle
// @return wchar_t* extracted URL
-const wchar_t* Utils::extractURLFromRichEdit(const ENLINK* _e, const HWND hwndRich)
+TCHAR* Utils::extractURLFromRichEdit(const ENLINK* _e, const HWND hwndRich)
{
- TEXTRANGEW tr = {0};
- CHARRANGE sel = {0};
-
- ::SendMessageW(hwndRich, EM_EXGETSEL, 0, (LPARAM)&sel);
+ CHARRANGE sel = {0};
+ ::SendMessage(hwndRich, EM_EXGETSEL, 0, (LPARAM)&sel);
if (sel.cpMin != sel.cpMax)
return 0;
+ TEXTRANGE tr;
tr.chrg = _e->chrg;
- tr.lpstrText = (wchar_t *)mir_alloc(2 * (tr.chrg.cpMax - tr.chrg.cpMin + 8));
- ::SendMessageW(hwndRich, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
- if (wcschr(tr.lpstrText, '@') != NULL && wcschr(tr.lpstrText, ':') == NULL && wcschr(tr.lpstrText, '/') == NULL) {
- ::memmove(tr.lpstrText + 7, tr.lpstrText, sizeof(wchar_t) * (tr.chrg.cpMax - tr.chrg.cpMin + 1));
- ::memcpy(tr.lpstrText, L"mailto:", 7 * sizeof(wchar_t));
+ tr.lpstrText = (TCHAR*)mir_alloc(sizeof(TCHAR) * (tr.chrg.cpMax - tr.chrg.cpMin + 8));
+ ::SendMessage(hwndRich, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
+ if (_tcschr(tr.lpstrText, '@') != NULL && _tcschr(tr.lpstrText, ':') == NULL && _tcschr(tr.lpstrText, '/') == NULL) {
+ mir_tstrncpy(tr.lpstrText, _T("mailto:"), 7);
+ mir_tstrncpy(tr.lpstrText + 7, tr.lpstrText, tr.chrg.cpMax - tr.chrg.cpMin + 1);
}
- return(tr.lpstrText);
+ return tr.lpstrText;
}
/////////////////////////////////////////////////////////////////////////////////////////