summaryrefslogtreecommitdiff
path: root/plugins/SmileyAdd
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-08-18 12:01:58 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-08-18 12:02:08 +0300
commitdb9944a090e6be30b3a5ffd5d7919dcddffc8478 (patch)
tree0161de1a6e1ee4b2ca4b17f78457ffb9b77395ad /plugins/SmileyAdd
parent600f344d88bec6dd61aa123be1d2114bffbdf493 (diff)
minor code cleaning
Diffstat (limited to 'plugins/SmileyAdd')
-rw-r--r--plugins/SmileyAdd/src/download.cpp2
-rw-r--r--plugins/SmileyAdd/src/smileyroutines.cpp15
-rw-r--r--plugins/SmileyAdd/src/smileys.cpp36
-rw-r--r--plugins/SmileyAdd/src/stdafx.h1
4 files changed, 27 insertions, 27 deletions
diff --git a/plugins/SmileyAdd/src/download.cpp b/plugins/SmileyAdd/src/download.cpp
index 3d0c5ebcba..e524d9ad8b 100644
--- a/plugins/SmileyAdd/src/download.cpp
+++ b/plugins/SmileyAdd/src/download.cpp
@@ -159,7 +159,7 @@ void __cdecl SmileyDownloadThread(void*)
bool GetSmileyFile(CMStringW &url, const CMStringW &packstr)
{
_TPattern *urlsplit = _TPattern::compile(L".*/(.*)");
- _TMatcher *m0 = urlsplit->createTMatcher(url);
+ _TMatcher *m0 = urlsplit->createWCMatcher(url);
m0->findFirstMatch();
diff --git a/plugins/SmileyAdd/src/smileyroutines.cpp b/plugins/SmileyAdd/src/smileyroutines.cpp
index b893fca9fa..e8b6f8c0d2 100644
--- a/plugins/SmileyAdd/src/smileyroutines.cpp
+++ b/plugins/SmileyAdd/src/smileyroutines.cpp
@@ -97,11 +97,12 @@ void LookupAllSmileys(SmileyPackType *smileyPack, SmileyPackCType *smileyCPack,
if (firstSml == -1)
break;
- ReplaceSmileyType *dat = new ReplaceSmileyType;
-
+ SmileyLookup::SmileyLocType &psmlf = (*smlf)[firstSmlRef];
const wchar_t *textToSearch = lpstrText + smloff;
- const wchar_t *textSmlStart = lpstrText + (*smlf)[firstSmlRef].pos;
- const wchar_t *textSmlEnd = textSmlStart + (*smlf)[firstSmlRef].len;
+ const wchar_t *textSmlStart = lpstrText + psmlf.pos;
+ const wchar_t *textSmlEnd = textSmlStart + psmlf.len;
+
+ ReplaceSmileyType *dat = new ReplaceSmileyType;
// check if leading space exist
const wchar_t *prech = _wcsdec(textToSearch, textSmlStart);
@@ -111,8 +112,8 @@ void LookupAllSmileys(SmileyPackType *smileyPack, SmileyPackCType *smileyCPack,
dat->trspace = *textSmlEnd == 0 || iswspace(*textSmlEnd);
// compute text location in RichEdit
- dat->loc.cpMin = (long)_wcsncnt(textToSearch, (*smlf)[firstSmlRef].pos - smloff) + numCharsSoFar;
- dat->loc.cpMax = numCharsSoFar = (long)_wcsncnt(textSmlStart, (*smlf)[firstSmlRef].len) + dat->loc.cpMin;
+ dat->loc.cpMin = (long)_wcsncnt(textToSearch, psmlf.pos - smloff) + numCharsSoFar;
+ dat->loc.cpMax = numCharsSoFar = (long)_wcsncnt(textSmlStart, psmlf.len) + dat->loc.cpMin;
if (!opt.EnforceSpaces || (dat->ldspace && dat->trspace)) {
dat->ldspace |= !opt.SurroundSmileyWithSpaces;
@@ -137,7 +138,7 @@ void LookupAllSmileys(SmileyPackType *smileyPack, SmileyPackCType *smileyCPack,
else delete dat;
// Advance string pointer to search for the next smiley
- smloff = int((*smlf)[firstSmlRef].pos + (*smlf)[firstSmlRef].len);
+ smloff = int(psmlf.pos + psmlf.len);
csmlit[firstSml]++;
}
delete[] smileys;
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp
index c555ede84e..b52472d5d6 100644
--- a/plugins/SmileyAdd/src/smileys.cpp
+++ b/plugins/SmileyAdd/src/smileys.cpp
@@ -223,7 +223,7 @@ static DWORD_PTR ConvertServiceParam(MCONTACT hContact, const wchar_t *param)
void SmileyType::CallSmileyService(MCONTACT hContact)
{
_TPattern *srvsplit = _TPattern::compile(L"(.*)\\|(.*)\\|(.*)");
- _TMatcher *m0 = srvsplit->createTMatcher(GetTriggerText());
+ _TMatcher *m0 = srvsplit->createWCMatcher(GetTriggerText());
m0->findFirstMatch();
CMStringW name = m0->getGroup(1);
@@ -281,7 +281,7 @@ void SmileyPackType::AddTriggersToSmileyLookup(void)
else if (!m_SmileyList[dist].IsService()) {
bool first = true;
int li = 0;
- _TMatcher *m0 = p->createTMatcher(m_SmileyList[dist].GetTriggerText());
+ _TMatcher *m0 = p->createWCMatcher(m_SmileyList[dist].GetTriggerText());
while (m0->findNextMatch()) {
int stind = m0->getStartingIndex();
if (li != stind) {
@@ -410,7 +410,7 @@ bool SmileyPackType::LoadSmileyFileMSL(CMStringW &tbuf, bool onlyInfo, CMStringW
CMStringW pathstr, packstr;
{
_TPattern *pathsplit = _TPattern::compile(L"(.*\\\\)(.*)\\.|$");
- _TMatcher *m0 = pathsplit->createTMatcher(modpath);
+ _TMatcher *m0 = pathsplit->createWCMatcher(modpath);
m0->findFirstMatch();
pathstr = m0->getGroup(1);
packstr = m0->getGroup(2);
@@ -422,7 +422,7 @@ bool SmileyPackType::LoadSmileyFileMSL(CMStringW &tbuf, bool onlyInfo, CMStringW
L"^\\s*(Name|Author|Date|Version|ButtonSmiley)\\s*=\\s*\"(.*)\"",
_TPattern::MULTILINE_MATCHING);
- _TMatcher *m0 = otherf->createTMatcher(tbuf);
+ _TMatcher *m0 = otherf->createWCMatcher(tbuf);
while (m0->findNextMatch()) {
if (m0->getGroup(1) == L"Name") m_Name = m0->getGroup(2);
if (m0->getGroup(1) == L"Author") m_Author = m0->getGroup(2);
@@ -440,7 +440,7 @@ bool SmileyPackType::LoadSmileyFileMSL(CMStringW &tbuf, bool onlyInfo, CMStringW
_TPattern *pat = _TPattern::compile(
L"^\\s*(Selection|Window)Size\\s*=\\s*(\\d+)\\s*,\\s*(\\d+)",
_TPattern::MULTILINE_MATCHING);
- _TMatcher *m0 = pat->createTMatcher(tbuf);
+ _TMatcher *m0 = pat->createWCMatcher(tbuf);
while (m0->findNextMatch()) {
POINT tpt;
tpt.x = _wtol(m0->getGroup(2).c_str());
@@ -467,7 +467,7 @@ bool SmileyPackType::LoadSmileyFileMSL(CMStringW &tbuf, bool onlyInfo, CMStringW
SmileyVectorType hiddenSmileys;
unsigned smnum = 0;
{
- _TMatcher *m0 = smiley->createTMatcher(tbuf);
+ _TMatcher *m0 = smiley->createWCMatcher(tbuf);
while (m0->findNextMatch()) {
CMStringW resname = m0->getGroup(2);
if (resname.Find(L"http://") != -1) {
@@ -582,18 +582,18 @@ bool SmileyPackType::LoadSmileyFileXEP(CMStringW &tbuf, bool onlyInfo, CMStringW
_TPattern *settings_re = _TPattern::compile(L"<settings>(.*?)</settings>",
_TPattern::MULTILINE_MATCHING | _TPattern::DOT_MATCHES_ALL);
- m0 = settings_re->createTMatcher(tbuf);
+ m0 = settings_re->createWCMatcher(tbuf);
if (m0->findFirstMatch()) {
CMStringW settings = m0->getGroup(1);
- m1 = author_re->createTMatcher(settings);
+ m1 = author_re->createWCMatcher(settings);
if (m1->findFirstMatch()) {
m_Author = m1->getGroup(1);
DecodeHTML(m_Author);
}
delete m1;
- m1 = dbname_re->createTMatcher(settings);
+ m1 = dbname_re->createWCMatcher(settings);
if (m1->findFirstMatch()) {
m_Name = m1->getGroup(1);
DecodeHTML(m_Name);
@@ -620,11 +620,11 @@ bool SmileyPackType::LoadSmileyFileXEP(CMStringW &tbuf, bool onlyInfo, CMStringW
_TPattern *imagedt_re = _TPattern::compile(L"<!\\[CDATA\\[(.*?)\\]\\]>",
_TPattern::MULTILINE_MATCHING);
- m0 = images_re->createTMatcher(tbuf);
+ m0 = images_re->createWCMatcher(tbuf);
if (m0->findFirstMatch()) {
CMStringW images = m0->getGroup(1);
- m1 = imagedt_re->createTMatcher(images);
+ m1 = imagedt_re->createWCMatcher(images);
if (m1->findFirstMatch()) {
IStream *pStream = DecodeBase64Data(_T2A(m1->getGroup(1).c_str()));
if (pStream != NULL) {
@@ -637,7 +637,7 @@ bool SmileyPackType::LoadSmileyFileXEP(CMStringW &tbuf, bool onlyInfo, CMStringW
}
delete m0;
- m0 = record_re->createTMatcher(tbuf);
+ m0 = record_re->createWCMatcher(tbuf);
while (m0->findNextMatch()) {
SmileyType *dat = new SmileyType;
@@ -648,14 +648,14 @@ bool SmileyPackType::LoadSmileyFileXEP(CMStringW &tbuf, bool onlyInfo, CMStringW
CMStringW rec = m0->getGroup(3);
- m1 = expression_re->createTMatcher(rec);
+ m1 = expression_re->createWCMatcher(rec);
if (m1->findFirstMatch()) {
dat->m_TriggerText = m1->getGroup(1);
DecodeHTML(dat->m_TriggerText);
}
delete m1;
- m1 = pastetext_re->createTMatcher(rec);
+ m1 = pastetext_re->createWCMatcher(rec);
if (m1->findFirstMatch()) {
dat->m_InsertText = m1->getGroup(1);
DecodeHTML(dat->m_InsertText);
@@ -663,11 +663,11 @@ bool SmileyPackType::LoadSmileyFileXEP(CMStringW &tbuf, bool onlyInfo, CMStringW
delete m1;
dat->SetHidden(dat->m_InsertText.IsEmpty());
- m1 = image_re->createTMatcher(rec);
+ m1 = image_re->createWCMatcher(rec);
if (m1->findFirstMatch()) {
CMStringW images = m1->getGroup(1);
- m2 = imagedt_re->createTMatcher(images);
+ m2 = imagedt_re->createWCMatcher(images);
if (m2->findFirstMatch()) {
IStream *pStream = DecodeBase64Data(_T2A(m2->getGroup(1).c_str()));
if (pStream != NULL) {
@@ -1063,7 +1063,7 @@ SmileyLookup::SmileyLookup(const CMStringW &str, const bool regexs, const int in
m_pattern = _TPattern::compile(str);
m_valid = m_pattern != NULL;
if (m_valid) {
- _TMatcher *matcher = m_pattern->createTMatcher(testString);
+ _TMatcher *matcher = m_pattern->createWCMatcher(testString);
m_valid &= (!matcher->findFirstMatch() ||
matcher->getStartingIndex() != matcher->getEndingIndex());
if (!m_valid) {
@@ -1099,7 +1099,7 @@ void SmileyLookup::Find(const CMStringW &str, SmileyLocVecType &smlcur, bool fir
if (!m_valid) return;
if (m_text.IsEmpty()) {
- _TMatcher *matcher = m_pattern->createTMatcher(str);
+ _TMatcher *matcher = m_pattern->createWCMatcher(str);
while (matcher->findNextMatch()) {
int st = matcher->getStartingIndex();
int sz = matcher->getEndingIndex() - st;
diff --git a/plugins/SmileyAdd/src/stdafx.h b/plugins/SmileyAdd/src/stdafx.h
index 0df3e383a1..0beb3b3005 100644
--- a/plugins/SmileyAdd/src/stdafx.h
+++ b/plugins/SmileyAdd/src/stdafx.h
@@ -77,7 +77,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
typedef WCPattern _TPattern;
typedef WCMatcher _TMatcher;
-#define createTMatcher createWCMatcher
#include "resource.h"
#include "version.h"