summaryrefslogtreecommitdiff
path: root/plugins/CommonLibs
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/CommonLibs')
-rw-r--r--plugins/CommonLibs/CString.cpp10
-rw-r--r--plugins/CommonLibs/CString.h71
-rw-r--r--plugins/CommonLibs/pcre.cpp18
3 files changed, 25 insertions, 74 deletions
diff --git a/plugins/CommonLibs/CString.cpp b/plugins/CommonLibs/CString.cpp
index 87266513d0..2b7441a8e0 100644
--- a/plugins/CommonLibs/CString.cpp
+++ b/plugins/CommonLibs/CString.cpp
@@ -310,7 +310,7 @@ CString DBGetContactSettingString(HANDLE hContact, const char *szModule, const c
}
-#ifdef _UNICODE
+
TCString DBGetContactSettingString(HANDLE hContact, const char *szModule, const char *szSetting, const TCHAR *szDefaultValue)
{
DBVARIANT dbv = {0};
@@ -334,7 +334,7 @@ TCString DBGetContactSettingString(HANDLE hContact, const char *szModule, const
}
return Result;
}
-#endif
+
int DBGetContactSettingString(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv)
@@ -355,12 +355,10 @@ TCString DBGetContactSettingAsString(HANDLE hContact, const char *szModule, cons
dbcgs.szModule = szModule;
dbcgs.pValue = &dbv;
dbcgs.szSetting = szSetting;
-#ifdef _UNICODE
+
dbv.type = DBVT_WCHAR;
int iRes = CallService(MS_DB_CONTACT_GETSETTING_STR, (WPARAM)hContact, (LPARAM)&dbcgs);
-#else
- int iRes = CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&dbcgs);
-#endif
+
TCString Result;
if (!iRes && (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR))
{
diff --git a/plugins/CommonLibs/CString.h b/plugins/CommonLibs/CString.h
index ed2540c511..fb956f6e4e 100644
--- a/plugins/CommonLibs/CString.h
+++ b/plugins/CommonLibs/CString.h
@@ -109,7 +109,7 @@ typedef TString<WCHAR> WCString;
__inline CString TCHAR2ANSI(TCString Str)
{
-#ifdef _UNICODE
+
if (Str == NULL)
{
return CString();
@@ -123,15 +123,13 @@ __inline CString TCHAR2ANSI(TCString Str)
AStr.ReleaseBuffer(Str.GetLen());
}
return AStr;
-#else
- return Str;
-#endif
+
}
__inline TCString ANSI2TCHAR(CString Str)
{
-#ifdef _UNICODE
+
if (Str == NULL)
{
return TCString();
@@ -146,64 +144,30 @@ __inline TCString ANSI2TCHAR(CString Str)
TStr.ReleaseBuffer(Len - 1);
}
return TStr;
-#else
- return Str;
-#endif
+
}
__inline WCString TCHAR2WCHAR(TCString Str)
{
-#ifdef _UNICODE
+
return Str;
-#else
- if (Str == NULL)
- {
- return WCString();
- }
- WCString WStr;
- int Len = MultiByteToWideChar(CP_ACP, 0, Str, -1, NULL, 0);
- if (!MultiByteToWideChar(CP_ACP, 0, Str, -1, WStr.GetBuffer(Len), Len))
- {
- WStr.ReleaseBuffer(0);
- } else
- {
- WStr.ReleaseBuffer(Len - 1);
- }
- return WStr;
-#endif
+
}
__inline TCString WCHAR2TCHAR(WCString Str)
{
-#ifdef _UNICODE
+
return Str;
-#else
- if (Str == NULL)
- {
- return TCString();
- }
- CString AStr;
- if (!WideCharToMultiByte(CP_ACP, 0, Str, -1, AStr.GetBuffer(Str.GetLen() + 1), Str.GetLen() + 1, NULL, NULL))
- {
- AStr.ReleaseBuffer(0);
- } else
- {
- AStr.ReleaseBuffer(Str.GetLen());
- }
- return AStr;
-#endif
+
}
-#ifdef _UNICODE
+
#define WCHAR2ANSI TCHAR2ANSI
#define ANSI2WCHAR ANSI2TCHAR
-#else
-#define WCHAR2ANSI WCHAR2TCHAR
-#define ANSI2WCHAR TCHAR2WCHAR
-#endif
+
#ifdef CHARARRAY_CONVERT
@@ -247,7 +211,7 @@ __inline CHARARRAY ANSI2WCHAR_ARRAY(CHARARRAY &c)
return Result;
}
-#ifdef _UNICODE // utf8 conversion doesn't work on win95
+
__inline CHARARRAY WCHAR2UTF8(WCString Str)
{
CHARARRAY Result;
@@ -262,7 +226,7 @@ __inline CHARARRAY WCHAR2UTF8(WCString Str)
}
return Result;
}
-#endif
+
#endif // CHARARRAY_CONVERT
@@ -308,11 +272,8 @@ private:
wchar_t *p;
};
-#ifdef _UNICODE
+
#define UTF8Decode UTF8DecodeW
-#else
-#define UTF8Decode UTF8DecodeA
-#endif
/*class mallocStrA
@@ -339,9 +300,7 @@ private:
wchar_t *p;
};
-#ifdef _UNICODE
+
#define mallocStr mallocStrW
-#else
-#define mallocStr mallocStrA
-#endif
+
*/ \ No newline at end of file
diff --git a/plugins/CommonLibs/pcre.cpp b/plugins/CommonLibs/pcre.cpp
index 5bd85833d9..ae82e43435 100644
--- a/plugins/CommonLibs/pcre.cpp
+++ b/plugins/CommonLibs/pcre.cpp
@@ -128,11 +128,9 @@ TCString CompileRegexp(TCString Regexp, int bAddAsUsualSubstring, int ID)
}
Regexp.ReleaseBuffer();
}
-#ifdef _UNICODE
+
PcreCompileData[NewID].pPcre = pcre_compile(WCHAR2UTF8(Regexp).GetData(), PCRE_UTF8 | PCRE_NO_UTF8_CHECK | Flags, &Err, &ErrOffs, NULL);
-#else
- PcreCompileData[NewID].pPcre = pcre_compile(Regexp, Flags, &Err, &ErrOffs, NULL);
-#endif
+
if (PcreCompileData[NewID].pPcre) {
PcreCompileData[NewID].pExtra = NULL;
if (pcre_study)
@@ -164,7 +162,7 @@ HMODULE LoadPcreLibrary(const char *szPath)
*(FARPROC*)&pcre_free = *(FARPROC*)GetProcAddress(hModule, "pcre_free"); // pcre_free is a pointer to a variable containing pointer to the function %)
if (pcre_compile && pcre_exec && pcre_free)
{
-#ifdef _UNICODE
+
int Utf8Supported = 0;
if (pcre_config)
{
@@ -174,9 +172,7 @@ HMODULE LoadPcreLibrary(const char *szPath)
{
return hModule;
}
-#else
- return hModule;
-#endif
+
}
FreeLibrary(hModule);
return NULL;
@@ -256,12 +252,10 @@ int PcreCheck(TCString Str, int StartingID)
{
if (hPcreDLL && PcreCompileData[I].pPcre)
{
-#ifdef _UNICODE
+
CHARARRAY Utf8Str = WCHAR2UTF8(Str);
int Res = pcre_exec(PcreCompileData[I].pPcre, PcreCompileData[I].pExtra, Utf8Str.GetData(), Utf8Str.GetSize() - 1, 0, PCRE_NOTEMPTY | PCRE_NO_UTF8_CHECK, NULL, 0);
-#else
- int Res = pcre_exec(PcreCompileData[I].pPcre, PcreCompileData[I].pExtra, Str, Str.GetLen(), 0, PCRE_NOTEMPTY, NULL, 0);
-#endif
+
if (Res >= 0)
{
return PcreCompileData[I].ID;