summaryrefslogtreecommitdiff
path: root/src/mir_core
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/mir_core
parentaf4c6d82d1e4dfa9aa60aeabed408486a3979a3e (diff)
mir_wstrstri - case-insensitive search of substring, Unicode version
Diffstat (limited to 'src/mir_core')
-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
3 files changed, 12 insertions, 0 deletions
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;