From d0dca507c9fc51b566e73fac8c2827daaed441b1 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Fri, 19 Jun 2015 18:39:18 +0000 Subject: MsgExport: - fixed truncation of exported messages (#939) - minor other fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@14267 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Msg_Export/src/FileViewer.cpp | 54 +++++++++++++++++------------------ plugins/Msg_Export/src/utils.cpp | 6 ++-- 2 files changed, 29 insertions(+), 31 deletions(-) (limited to 'plugins') diff --git a/plugins/Msg_Export/src/FileViewer.cpp b/plugins/Msg_Export/src/FileViewer.cpp index 619d97ed3c..e76ac7a885 100755 --- a/plugins/Msg_Export/src/FileViewer.cpp +++ b/plugins/Msg_Export/src/FileViewer.cpp @@ -678,7 +678,6 @@ bool bLoadFile(HWND hwndDlg, CLHistoryDlg * pclDlg) OutputDebugString(szTmp); GETTEXTLENGTHEX sData = { 0 }; - sData.flags = GTL_NUMCHARS; sData.flags = GTL_DEFAULT; DWORD dwDataRead = (DWORD)SendMessage(hRichEdit, EM_GETTEXTLENGTHEX, (WPARAM)&sData, 0); @@ -712,37 +711,38 @@ bool bAdvancedCopy(HWND hwnd) int nSelLenght = sSelectRange.cpMax - sSelectRange.cpMin + 1; // +1 for null termination if (nSelLenght > 1) { - OpenClipboard(NULL); - EmptyClipboard(); - - TCHAR *pszSrcBuf = new TCHAR[nSelLenght]; - pszSrcBuf[0] = 0; - SendMessage(hwnd, EM_GETSELTEXT, 0, (LPARAM)pszSrcBuf); + if (OpenClipboard(NULL)) { + EmptyClipboard(); + + TCHAR *pszSrcBuf = new TCHAR[nSelLenght]; + pszSrcBuf[0] = 0; + SendMessage(hwnd, EM_GETSELTEXT, 0, (LPARAM)pszSrcBuf); + + HANDLE hDecMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, nSelLenght); + TCHAR *pszCurDec = (TCHAR*)GlobalLock(hDecMem); + + bool bInSpaces = false; + for (TCHAR *pszCur = pszSrcBuf; pszCur[0]; pszCur++) { + if (bInSpaces) { + if (pszCur[0] == ' ') + continue; + bInSpaces = false; + } - HANDLE hDecMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, nSelLenght); - TCHAR *pszCurDec = (TCHAR*)GlobalLock(hDecMem); + if (pszCur[0] == '\n') + bInSpaces = true; - bool bInSpaces = false; - for (TCHAR *pszCur = pszSrcBuf; pszCur[0]; pszCur++) { - if (bInSpaces) { - if (pszCur[0] == ' ') - continue; - bInSpaces = false; + pszCurDec[0] = pszCur[0]; + pszCurDec++; } + pszCurDec[0] = 0; + GlobalUnlock(hDecMem); - if (pszCur[0] == '\n') - bInSpaces = true; - - pszCurDec[0] = pszCur[0]; - pszCurDec++; + SetClipboardData(CF_TEXT, hDecMem); + delete[] pszSrcBuf; + CloseClipboard(); + return true; } - pszCurDec[0] = 0; - GlobalUnlock(hDecMem); - - SetClipboardData(CF_TEXT, hDecMem); - delete[] pszSrcBuf; - CloseClipboard(); - return true; } return false; } diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index 65b86fc401..023c90a90b 100755 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -445,8 +445,7 @@ static bool bWriteTextToFile(HANDLE hFile, const TCHAR *pszSrc, bool bUtf8File, { if (nLen != -1) { TCHAR *tmp = (TCHAR*)alloca(sizeof(TCHAR)*(nLen + 1)); - mir_tstrncpy(tmp, pszSrc, nLen); - tmp[nLen] = 0; + mir_tstrncpy(tmp, pszSrc, nLen + 1); pszSrc = tmp; } @@ -468,8 +467,7 @@ static bool bWriteTextToFile(HANDLE hFile, const char *pszSrc, bool bUtf8File, i if (nLen != -1) { char *tmp = (char*)alloca(nLen + 1); - mir_strncpy(tmp, pszSrc, nLen); - tmp[nLen] = 0; + mir_strncpy(tmp, pszSrc, nLen + 1); pszSrc = tmp; } -- cgit v1.2.3