summaryrefslogtreecommitdiff
path: root/src/modules/chat
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-10-13 19:48:43 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-10-13 19:48:43 +0000
commitd4c9d098600133e1037474f20731dc248e84c05e (patch)
tree32acb254882639d4473b3bd967211e5e3a98f094 /src/modules/chat
parent547ff12e0cf83fdef769fae8be1b9c3c4ecba332 (diff)
wrong special char processing
git-svn-id: http://svn.miranda-ng.org/main/trunk@10775 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/chat')
-rw-r--r--src/modules/chat/tools.cpp49
1 files changed, 22 insertions, 27 deletions
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)&gtl, 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)