summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-05-20 17:18:15 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-05-20 17:18:15 +0300
commit46be94cd275231bb124f2887878d5a78be5abf9a (patch)
treeca025fcd5cb689a763d86176700dbcd7f4231aca /src
parentaf4c6d82d1e4dfa9aa60aeabed408486a3979a3e (diff)
mir_wstrstri - case-insensitive search of substring, Unicode version
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/chat.h2
-rw-r--r--src/mir_app/src/chat_manager.cpp2
-rw-r--r--src/mir_app/src/chat_tools.cpp11
-rw-r--r--src/mir_core/src/mir_core.def1
-rw-r--r--src/mir_core/src/mir_core64.def1
-rw-r--r--src/mir_core/src/utils.cpp10
6 files changed, 13 insertions, 14 deletions
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h
index 88f9660f17..3d158e5beb 100644
--- a/src/mir_app/src/chat.h
+++ b/src/mir_app/src/chat.h
@@ -126,6 +126,4 @@ CSrmmLogWindow *Srmm_GetLogWindow(CMsgDialog *pDlg);
void Chat_RemoveContact(MCONTACT hContact);
-const wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2);
-
#pragma comment(lib,"comctl32.lib")
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index ce6af63eee..8daeeaadf0 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -827,7 +827,7 @@ static wchar_t* UM_FindUserAutoComplete(SESSION_INFO *si, const wchar_t* pszOrig
wchar_t *pszName = nullptr;
for (auto &ui : si->getUserList())
- if (ui->pszNick && my_strstri(ui->pszNick, pszOriginal) == ui->pszNick)
+ if (ui->pszNick && mir_wstrstri(ui->pszNick, pszOriginal) == ui->pszNick)
if (mir_wstrcmpi(ui->pszNick, pszCurrent) > 0 && (!pszName || mir_wstrcmpi(ui->pszNick, pszName) < 0))
pszName = ui->pszNick;
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp
index 980fcd2ea8..f334a128b5 100644
--- a/src/mir_app/src/chat_tools.cpp
+++ b/src/mir_app/src/chat_tools.cpp
@@ -416,17 +416,6 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
return TRUE;
}
-const wchar_t* my_strstri(const wchar_t *s1, const wchar_t *s2)
-{
- int i, j, k;
- for (i = 0; s1[i]; i++)
- for (j = i, k = 0; towlower(s1[j]) == towlower(s2[k]); j++, k++)
- if (!s2[k + 1])
- return s1 + i;
-
- return nullptr;
-}
-
static wchar_t szTrimString[] = L":,.!?;\'>)";
bool IsHighlighted(SESSION_INFO *si, GCEVENT *gce)
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index b823bc88f8..b5dd1fc756 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -188,6 +188,7 @@ mir_closeLog @259
LoadLangPackDescr @262
PathIsAbsolute @263
PathIsAbsoluteW @264
+mir_wstrstri @265
mir_strlen @267
mir_wstrlen @268
mir_strcpy @269
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index e4515d39d6..41694e7d20 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -188,6 +188,7 @@ mir_closeLog @259
LoadLangPackDescr @262
PathIsAbsolute @263
PathIsAbsoluteW @264
+mir_wstrstri @265
mir_strlen @267
mir_wstrlen @268
mir_strcpy @269
diff --git a/src/mir_core/src/utils.cpp b/src/mir_core/src/utils.cpp
index b9cd736054..ccd89aabcc 100644
--- a/src/mir_core/src/utils.cpp
+++ b/src/mir_core/src/utils.cpp
@@ -518,6 +518,16 @@ MIR_CORE_DLL(int) mir_wstrncmpi(const wchar_t *p1, const wchar_t *p2, size_t n)
return wcsnicmp(p1, p2, n);
}
+MIR_CORE_DLL(const wchar_t*) mir_wstrstri(const wchar_t *s1, const wchar_t *s2)
+{
+ for (int i = 0; s1[i]; i++)
+ for (int j = i, k = 0; towlower(s1[j]) == towlower(s2[k]); j++, k++)
+ if (!s2[k + 1])
+ return s1 + i;
+
+ return nullptr;
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
PGENRANDOM pfnRtlGenRandom;