From 46be94cd275231bb124f2887878d5a78be5abf9a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 20 May 2021 17:18:15 +0300 Subject: mir_wstrstri - case-insensitive search of substring, Unicode version --- src/mir_core/src/mir_core.def | 1 + src/mir_core/src/mir_core64.def | 1 + src/mir_core/src/utils.cpp | 10 ++++++++++ 3 files changed, 12 insertions(+) (limited to 'src/mir_core') 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; -- cgit v1.2.3