From d4c9d098600133e1037474f20731dc248e84c05e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 13 Oct 2014 19:48:43 +0000 Subject: wrong special char processing git-svn-id: http://svn.miranda-ng.org/main/trunk@10775 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/chat/tools.cpp | 49 +++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) (limited to 'src/modules/chat') diff --git a/src/modules/chat/tools.cpp b/src/modules/chat/tools.cpp index 40e1dd3cc5..ae118c1cb2 100644 --- a/src/modules/chat/tools.cpp +++ b/src/modules/chat/tools.cpp @@ -32,23 +32,26 @@ int GetRichTextLength(HWND hwnd) return (int)SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); } -TCHAR* RemoveFormatting(const TCHAR* pszWord) -{ - static TCHAR szTemp[10000]; - int i = 0; - int j = 0; +///////////////////////////////////////////////////////////////////////////////////////// - if (pszWord == 0 || pszWord[0] == 0) +static TCHAR szTemp[10000]; + +TCHAR* RemoveFormatting(const TCHAR *pszWord) +{ + if (pszWord == NULL) return NULL; - while (j < 9999 && i <= lstrlen(pszWord)) { + TCHAR *d = szTemp; + int cbLen = lstrlen(pszWord); + if (cbLen > SIZEOF(szTemp)) + cbLen = SIZEOF(szTemp)-1; + + for (int i = 0; i < cbLen; ) { if (pszWord[i] == '%') { - switch (pszWord[i + 1]) { + switch (pszWord[i+1]) { case '%': - szTemp[j] = '%'; - j++; - i++; i++; - break; + *d++ = '%'; + case 'b': case 'u': case 'i': @@ -58,29 +61,21 @@ TCHAR* RemoveFormatting(const TCHAR* pszWord) case 'r': case 'C': case 'F': - i++; i++; - break; + i += 2; + continue; case 'c': case 'f': i += 4; - break; - - default: - szTemp[j] = pszWord[i]; - j++; - i++; - break; + continue; } } - else { - szTemp[j] = pszWord[i]; - j++; - i++; - } + + *d++ = pszWord[i++]; } + *d = 0; - return (TCHAR*)&szTemp; + return szTemp; } BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce) -- cgit v1.2.3