diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-23 08:27:32 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-23 08:27:32 +0000 |
commit | 78a92aad0e3c2941b11b3115d9fd7aae44e5fc37 (patch) | |
tree | 28cf61c18a6d5d41bd2a1556b37b1f7026cb0ed0 | |
parent | 36ac355b3009665069258c76f9ce8b7f7229ece9 (diff) |
- added unicode analogs of ltrim, ltrimp, wildcmp;
- wildcmpi[w] added
git-svn-id: http://svn.miranda-ng.org/main/trunk@4511 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | bin10/lib/mir_core.lib | bin | 34880 -> 35798 bytes | |||
-rw-r--r-- | bin10/lib/mir_core64.lib | bin | 31852 -> 32674 bytes | |||
-rw-r--r-- | bin11/lib/mir_core.lib | bin | 34880 -> 35798 bytes | |||
-rw-r--r-- | bin11/lib/mir_core64.lib | bin | 31852 -> 32674 bytes | |||
-rw-r--r-- | include/delphi/m_core.inc | 11 | ||||
-rw-r--r-- | include/m_core.h | 33 | ||||
-rw-r--r-- | src/mir_core/mir_core.def | 5 | ||||
-rw-r--r-- | src/mir_core/utils.cpp | 101 |
8 files changed, 137 insertions, 13 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib Binary files differindex 93fe2e26e3..1bed180db9 100644 --- a/bin10/lib/mir_core.lib +++ b/bin10/lib/mir_core.lib diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib Binary files differindex 4e05648914..5e34e2dd56 100644 --- a/bin10/lib/mir_core64.lib +++ b/bin10/lib/mir_core64.lib diff --git a/bin11/lib/mir_core.lib b/bin11/lib/mir_core.lib Binary files differindex 875cf1ce32..299bac14d7 100644 --- a/bin11/lib/mir_core.lib +++ b/bin11/lib/mir_core.lib diff --git a/bin11/lib/mir_core64.lib b/bin11/lib/mir_core64.lib Binary files differindex bcff920f11..42f1abbf5a 100644 --- a/bin11/lib/mir_core64.lib +++ b/bin11/lib/mir_core64.lib diff --git a/include/delphi/m_core.inc b/include/delphi/m_core.inc index 773b93a11c..5c550e109c 100644 --- a/include/delphi/m_core.inc +++ b/include/delphi/m_core.inc @@ -561,12 +561,23 @@ function wrtrim(str:pWideChar):pWideChar; stdcall; // returns pointer to the beginning of string
function ltrim(str:pAnsiChar):pAnsiChar; stdcall;
external CoreDLL name 'ltrim';
+function ltrimw(str:pWideChar):pWideChar; stdcall;
+ external CoreDLL name 'ltrimw';
// returns pointer to the trimmed portion of string
function ltrimp(str:pAnsiChar):pAnsiChar; stdcall;
external CoreDLL name 'ltrimp';
+function ltrimpw(str:pWideChar):pWideChar; stdcall;
+ external CoreDLL name 'ltrimpw';
function wildcmp(name:pAnsiChar; mask:pAnsiChar):int; stdcall;
external CoreDLL name 'wildcmp';
+function wildcmpw(name:pWideChar; mask:pWideChar):int; stdcall;
+ external CoreDLL name 'wildcmpw';
+
+function wildcmpi(name:pAnsiChar; mask:pAnsiChar):int; stdcall;
+ external CoreDLL name 'wildcmpi';
+function wildcmpiw(name:pWideChar; mask:pWideChar):int; stdcall;
+ external CoreDLL name 'wildcmpiw';
// mir_free dest, mir_strdup src to dest
function replaceStr(var dest:pAnsiChar; const src:pAnsiChar):pAnsiChar; stdcall;
diff --git a/include/m_core.h b/include/m_core.h index 87595defce..0b4fdf7ca6 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -463,19 +463,26 @@ MIR_CORE_DLL(WCHAR*) wrtrim(WCHAR *str); #endif
MIR_CORE_DLL(char*) ltrim(char *str); // returns pointer to the beginning of string
+MIR_CORE_DLL(WCHAR*) ltrimw(WCHAR *str);
+
MIR_CORE_DLL(char*) ltrimp(char *str); // returns pointer to the trimmed portion of string
+MIR_CORE_DLL(WCHAR*) ltrimpw(WCHAR *str);
+
+MIR_CORE_DLL(int) wildcmp(const char *name, const char *mask);
+MIR_CORE_DLL(int) wildcmpw(const WCHAR *name, const WCHAR *mask);
-MIR_CORE_DLL(int) wildcmp(char *name, char *mask);
+MIR_CORE_DLL(int) wildcmpi(const char *name, const char *mask);
+MIR_CORE_DLL(int) wildcmpiw(const WCHAR *name, const WCHAR *mask);
-__forceinline char* lrtrim(char* str) { return ltrim(rtrim(str)); };
-__forceinline char* lrtrimp(char* str) { return ltrimp(rtrim(str)); };
+__forceinline char* lrtrim(char *str) { return ltrim(rtrim(str)); };
+__forceinline char* lrtrimp(char *str) { return ltrimp(rtrim(str)); };
#if defined( __cplusplus )
- MIR_CORE_DLL(char*) replaceStr( char* &dest, const char *src );
- MIR_CORE_DLL(WCHAR*) replaceStrW( WCHAR* &dest, const WCHAR *src );
+ MIR_CORE_DLL(char*) replaceStr(char* &dest, const char *src);
+ MIR_CORE_DLL(WCHAR*) replaceStrW(WCHAR* &dest, const WCHAR *src);
#else
- MIR_CORE_DLL(char*) replaceStr( char **dest, const char *src );
- MIR_CORE_DLL(WCHAR*) replaceStrW( WCHAR **dest, const WCHAR *src );
+ MIR_CORE_DLL(char*) replaceStr(char **dest, const char *src);
+ MIR_CORE_DLL(WCHAR*) replaceStrW(WCHAR **dest, const WCHAR *src);
#endif
///////////////////////////////////////////////////////////////////////////////
@@ -495,6 +502,12 @@ __forceinline char* lrtrimp(char* str) { return ltrimp(rtrim(str)); }; #define mir_tstrdup mir_wstrdup
#define mir_tstrndup mir_wstrndup
#define replaceStrT replaceStrW
+
+ #define ltrimt ltrimw
+ #define ltrimpt ltrimpw
+
+ #define wildcmpt wildcmpw
+ #define wildcmpit wildcmpiw
#else
#define mir_t2a(s) mir_strdup(s)
#define mir_a2t(s) mir_strdup(s)
@@ -509,6 +522,12 @@ __forceinline char* lrtrimp(char* str) { return ltrimp(rtrim(str)); }; #define mir_tstrdup mir_strdup
#define mir_tstrndup mir_strndup
#define replaceStrT replaceStr
+
+ #define ltrimt ltrim
+ #define ltrimpt ltrimp
+
+ #define wildcmpt wildcmp
+ #define wildcmpit wildcmpi
#endif
MIR_CORE_DLL(WCHAR*) mir_a2u_cp(const char* src, int codepage);
diff --git a/src/mir_core/mir_core.def b/src/mir_core/mir_core.def index 6e923548b6..c436496a31 100644 --- a/src/mir_core/mir_core.def +++ b/src/mir_core/mir_core.def @@ -154,3 +154,8 @@ db_event_last @151 db_event_markRead @152
db_event_next @153
db_event_prev @154
+ltrimw @155
+ltrimpw @156
+wildcmpw @157
+wildcmpi @158
+wildcmpiw @159
diff --git a/src/mir_core/utils.cpp b/src/mir_core/utils.cpp index fb6076865a..a98444d5da 100644 --- a/src/mir_core/utils.cpp +++ b/src/mir_core/utils.cpp @@ -61,7 +61,7 @@ MIR_CORE_DLL(WCHAR*) wrtrim(WCHAR *str) if (str == NULL)
return NULL;
- WCHAR* p = _tcschr(str, 0);
+ WCHAR *p = _tcschr(str, 0);
while (--p >= str) {
switch (*p) {
case ' ': case '\t': case '\n': case '\r':
@@ -90,12 +90,45 @@ MIR_CORE_DLL(char*) ltrim(char* str) }
}
-MIR_CORE_DLL(char*) ltrimp(char* str)
+MIR_CORE_DLL(WCHAR*) ltrimw(WCHAR *str)
{
if (str == NULL)
return NULL;
- char* p = str;
+ WCHAR *p = str;
+ for (;;) {
+ switch (*p) {
+ case ' ': case '\t': case '\n': case '\r':
+ ++p; break;
+ default:
+ memmove(str, p, sizeof(WCHAR)*(wcslen(p) + 1));
+ return str;
+ }
+ }
+}
+
+MIR_CORE_DLL(char*) ltrimp(char *str)
+{
+ if (str == NULL)
+ return NULL;
+
+ char *p = str;
+ for (;;) {
+ switch (*p) {
+ case ' ': case '\t': case '\n': case '\r':
+ ++p; break;
+ default:
+ return p;
+ }
+ }
+}
+
+MIR_CORE_DLL(WCHAR*) ltrimpw(WCHAR *str)
+{
+ if (str == NULL)
+ return NULL;
+
+ WCHAR *p = str;
for (;;) {
switch (*p) {
case ' ': case '\t': case '\n': case '\r':
@@ -106,15 +139,15 @@ MIR_CORE_DLL(char*) ltrimp(char* str) }
}
-MIR_CORE_DLL(int) wildcmp(char * name, char * mask)
+MIR_CORE_DLL(int) wildcmp(const char *name, const char *mask)
{
- char * last='\0';
+ const char *last='\0';
for (;; mask++, name++) {
if (*mask != '?' && *mask != *name) break;
if (*name == '\0') return ((BOOL)!*mask);
}
if (*mask != '*') return FALSE;
- for (;; mask++, name++){
+ for (;; mask++, name++) {
while (*mask == '*') {
last = mask++;
if (*mask == '\0') return ((BOOL)!*mask); /* true */
@@ -123,3 +156,59 @@ MIR_CORE_DLL(int) wildcmp(char * name, char * mask) if (*mask != '?' && *mask != *name) name -= (size_t)(mask - last) - 1, mask = last;
}
}
+
+MIR_CORE_DLL(int) wildcmpw(const WCHAR *name, const WCHAR *mask)
+{
+ const WCHAR* last = '\0';
+ for (;; mask++, name++) {
+ if (*mask != '?' && *mask != *name) break;
+ if (*name == '\0') return ((BOOL)!*mask);
+ }
+ if (*mask != '*') return FALSE;
+ for (;; mask++, name++) {
+ while(*mask == '*') {
+ last = mask++;
+ if (*mask == '\0') return ((BOOL)!*mask); /* true */
+ }
+ if (*name == '\0') return ((BOOL)!*mask); /* *mask == EOS */
+ if (*mask != '?' && *mask != *name) name -= (size_t)(mask - last) - 1, mask = last;
+ }
+}
+
+#define _qtoupper(_c) (((_c) >= 'a' && (_c) <= 'z')?((_c)-('a'+'A')):(_c))
+
+MIR_CORE_DLL(int) wildcmpi(const char *name, const char *mask)
+{
+ const char *last = NULL;
+ for (;; mask++, name++) {
+ if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) break;
+ if (*name == '\0') return ((BOOL)!*mask);
+ }
+ if (*mask != '*') return FALSE;
+ for (;; mask++, name++) {
+ while(*mask == '*') {
+ last = mask++;
+ if (*mask == '\0') return ((BOOL)!*mask); /* true */
+ }
+ if (*name == '\0') return ((BOOL)!*mask); /* *mask == EOS */
+ if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) name -= (size_t)(mask - last) - 1, mask = last;
+ }
+}
+
+MIR_CORE_DLL(int) wildcmpiw(const WCHAR *name, const WCHAR *mask)
+{
+ const WCHAR* last = NULL;
+ for (;; mask++, name++) {
+ if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) break;
+ if (*name == '\0') return ((BOOL)!*mask);
+ }
+ if (*mask != '*') return FALSE;
+ for (;; mask++, name++) {
+ while(*mask == '*') {
+ last = mask++;
+ if (*mask == '\0') return ((BOOL)!*mask); /* true */
+ }
+ if (*name == '\0') return ((BOOL)!*mask); /* *mask == EOS */
+ if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) name -= (size_t)(mask - last) - 1, mask = last;
+ }
+}
|