From 3944b14a2aaad2fcb95bf448d9b18c35e6f74ec8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 11 Aug 2015 22:42:09 +0000 Subject: missing string comparison functions git-svn-id: http://svn.miranda-ng.org/main/trunk@14918 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_core/src/mir_core.def | 4 ++++ src/mir_core/src/mir_core64.def | 4 ++++ src/mir_core/src/utils.cpp | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) (limited to 'src') diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 8412723e7f..57f8bfcfd9 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -977,3 +977,7 @@ GetOSDisplayString @1134 IsWinVer10Plus @1135 IsWinVer81Plus @1136 IsWinVer8Plus @1137 +mir_strncmp @1138 +mir_strncmpi @1139 +mir_wstrncmp @1140 +mir_wstrncmpi @1141 diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index b29f37541d..c44c595634 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -977,3 +977,7 @@ GetOSDisplayString @1134 IsWinVer10Plus @1135 IsWinVer81Plus @1136 IsWinVer8Plus @1137 +mir_strncmp @1138 +mir_strncmpi @1139 +mir_wstrncmp @1140 +mir_wstrncmpi @1141 diff --git a/src/mir_core/src/utils.cpp b/src/mir_core/src/utils.cpp index af1685a63e..5f4d0d063b 100644 --- a/src/mir_core/src/utils.cpp +++ b/src/mir_core/src/utils.cpp @@ -410,6 +410,42 @@ MIR_CORE_DLL(int) mir_wstrcmpi(const wchar_t *p1, const wchar_t *p2) return CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE, p1, -1, p2, -1) - 2; } +MIR_CORE_DLL(int) mir_strncmp(const char *p1, const char *p2, size_t n) +{ + if (p1 == NULL) + return (p2 == NULL) ? 0 : -1; + if (p2 == NULL) + return 1; + return CompareStringA(LOCALE_USER_DEFAULT, 0, p1, (int)n, p2, (int)n) - 2; +} + +MIR_CORE_DLL(int) mir_wstrncmp(const wchar_t *p1, const wchar_t *p2, size_t n) +{ + if (p1 == NULL) + return (p2 == NULL) ? 0 : -1; + if (p2 == NULL) + return 1; + return CompareStringW(LOCALE_USER_DEFAULT, 0, p1, (int)n, p2, (int)n) - 2; +} + +MIR_CORE_DLL(int) mir_strncmpi(const char *p1, const char *p2, size_t n) +{ + if (p1 == NULL) + return (p2 == NULL) ? 0 : -1; + if (p2 == NULL) + return 1; + return CompareStringA(LOCALE_USER_DEFAULT, NORM_IGNORECASE, p1, (int)n, p2, (int)n) - 2; +} + +MIR_CORE_DLL(int) mir_wstrncmpi(const wchar_t *p1, const wchar_t *p2, size_t n) +{ + if (p1 == NULL) + return (p2 == NULL) ? 0 : -1; + if (p2 == NULL) + return 1; + return CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE, p1, (int)n, p2, (int)n) - 2; +} + ///////////////////////////////////////////////////////////////////////////////////////// PGENRANDOM pfnRtlGenRandom; -- cgit v1.2.3