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 --- bin10/lib/mir_core.lib | Bin 298390 -> 299232 bytes bin10/lib/mir_core64.lib | Bin 299714 -> 300460 bytes bin12/lib/mir_core.lib | Bin 298390 -> 299232 bytes bin12/lib/mir_core64.lib | Bin 299714 -> 300460 bytes bin14/lib/mir_core.lib | Bin 298390 -> 299232 bytes bin14/lib/mir_core64.lib | Bin 299714 -> 300460 bytes include/m_core.h | 44 ++++++++++++++++++++++++---------------- src/mir_core/src/mir_core.def | 4 ++++ src/mir_core/src/mir_core64.def | 4 ++++ src/mir_core/src/utils.cpp | 36 ++++++++++++++++++++++++++++++++ 10 files changed, 70 insertions(+), 18 deletions(-) diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib index 8c6019c2af..4a21171a87 100644 Binary files a/bin10/lib/mir_core.lib and b/bin10/lib/mir_core.lib differ diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib index 144b3bedb0..057a49680d 100644 Binary files a/bin10/lib/mir_core64.lib and b/bin10/lib/mir_core64.lib differ diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib index 8c6019c2af..4a21171a87 100644 Binary files a/bin12/lib/mir_core.lib and b/bin12/lib/mir_core.lib differ diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib index 144b3bedb0..057a49680d 100644 Binary files a/bin12/lib/mir_core64.lib and b/bin12/lib/mir_core64.lib differ diff --git a/bin14/lib/mir_core.lib b/bin14/lib/mir_core.lib index 8c6019c2af..4a21171a87 100644 Binary files a/bin14/lib/mir_core.lib and b/bin14/lib/mir_core.lib differ diff --git a/bin14/lib/mir_core64.lib b/bin14/lib/mir_core64.lib index 144b3bedb0..057a49680d 100644 Binary files a/bin14/lib/mir_core64.lib and b/bin14/lib/mir_core64.lib differ diff --git a/include/m_core.h b/include/m_core.h index f8626f975a..148839e2ce 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -280,10 +280,14 @@ MIR_CORE_DLL(char*) mir_strncat(char *dest, const char *src, size_t len); MIR_CORE_DLL(wchar_t*) mir_wstrncat(wchar_t *dest, const wchar_t *src, size_t len); MIR_CORE_DLL(int) mir_strcmp(const char *p1, const char *p2); +MIR_CORE_DLL(int) mir_strncmp(const char *p1, const char *p2, size_t n); MIR_CORE_DLL(int) mir_wstrcmp(const wchar_t *p1, const wchar_t *p2); +MIR_CORE_DLL(int) mir_wstrncmp(const wchar_t *p1, const wchar_t *p2, size_t n); MIR_CORE_DLL(int) mir_strcmpi(const char *p1, const char *p2); +MIR_CORE_DLL(int) mir_strncmpi(const char *p1, const char *p2, size_t n); MIR_CORE_DLL(int) mir_wstrcmpi(const wchar_t *p1, const wchar_t *p2); +MIR_CORE_DLL(int) mir_wstrncmpi(const wchar_t *p1, const wchar_t *p2, size_t n); MIR_CORE_DLL(char*) mir_strdup(const char* str); MIR_CORE_DLL(wchar_t*) mir_wstrdup(const wchar_t* str); @@ -419,15 +423,17 @@ typedef union { #define mir_t2u_cp(s,c) mir_wstrdup(s) #define mir_u2t_cp(s,c) mir_wstrdup(s) - #define mir_tstrlen mir_wstrlen - #define mir_tstrcpy mir_wstrcpy - #define mir_tstrncpy mir_wstrncpy - #define mir_tstrcat mir_wstrcat - #define mir_tstrncat mir_wstrncat - #define mir_tstrcmp mir_wstrcmp - #define mir_tstrcmpi mir_wstrcmpi - #define mir_tstrdup mir_wstrdup - #define mir_tstrndup mir_wstrndup + #define mir_tstrlen mir_wstrlen + #define mir_tstrcpy mir_wstrcpy + #define mir_tstrncpy mir_wstrncpy + #define mir_tstrcat mir_wstrcat + #define mir_tstrncat mir_wstrncat + #define mir_tstrcmp mir_wstrcmp + #define mir_tstrcmpi mir_wstrcmpi + #define mir_tstrncmp mir_wstrncmp + #define mir_tstrncmpi mir_wstrncmpi + #define mir_tstrdup mir_wstrdup + #define mir_tstrndup mir_wstrndup #define replaceStrT replaceStrW #define bin2hexT bin2hexW @@ -455,15 +461,17 @@ typedef union { #define mir_t2u_cp(s,c) mir_a2u_cp(s,c) #define mir_u2t_cp(s,c) mir_u2a_cp(s,c) - #define mir_tstrlen mir_strlen - #define mir_tstrcpy mir_strcpy - #define mir_tstrncpy mir_strncpy - #define mir_tstrcat mir_strcat - #define mir_tstrncat mir_strncat - #define mir_tstrcmp mir_strcmp - #define mir_tstrcmpi mir_strcmpi - #define mir_tstrdup mir_strdup - #define mir_tstrndup mir_strndup + #define mir_tstrlen mir_strlen + #define mir_tstrcpy mir_strcpy + #define mir_tstrncpy mir_strncpy + #define mir_tstrcat mir_strcat + #define mir_tstrncat mir_strncat + #define mir_tstrcmp mir_strcmp + #define mir_tstrcmpi mir_strcmpi + #define mir_tstrncmp mir_strncmp + #define mir_tstrncmpi mir_strncmpi + #define mir_tstrdup mir_strdup + #define mir_tstrndup mir_strndup #define replaceStrT replaceStr #define bin2hexT bin2hex 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