From 61b92178e79ffc114a80bab4f057eb6f4c3f967f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 14 Aug 2018 20:27:10 +0300 Subject: mir_core: WCHAR replaced with wchar_t --- src/mir_core/src/db.cpp | 6 +++--- src/mir_core/src/langpack.cpp | 4 ++-- src/mir_core/src/logger.cpp | 14 ++++++-------- src/mir_core/src/memory.cpp | 14 +++++++------- src/mir_core/src/path.cpp | 18 +++++++++--------- src/mir_core/src/utf.cpp | 2 +- src/mir_core/src/utils.cpp | 28 ++++++++++++++-------------- 7 files changed, 42 insertions(+), 44 deletions(-) (limited to 'src/mir_core') diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp index 69e998c53c..cb0a4d58ac 100644 --- a/src/mir_core/src/db.cpp +++ b/src/mir_core/src/db.cpp @@ -232,7 +232,7 @@ MIR_CORE_DLL(int) db_get_static_utf(MCONTACT hContact, const char *szModule, con return currDb->GetContactSettingStatic(hContact, szModule, szSetting, &dbv); } -MIR_CORE_DLL(int) db_get_wstatic(MCONTACT hContact, const char *szModule, const char *szSetting, WCHAR *pDest, int cbDest) +MIR_CORE_DLL(int) db_get_wstatic(MCONTACT hContact, const char *szModule, const char *szSetting, wchar_t *pDest, int cbDest) { if (currDb == nullptr) return 1; @@ -306,7 +306,7 @@ MIR_CORE_DLL(INT_PTR) db_set_s(MCONTACT hContact, const char *szModule, const ch return currDb->WriteContactSetting(hContact, &cws); } -MIR_CORE_DLL(INT_PTR) db_set_ws(MCONTACT hContact, const char *szModule, const char *szSetting, const WCHAR *val) +MIR_CORE_DLL(INT_PTR) db_set_ws(MCONTACT hContact, const char *szModule, const char *szSetting, const wchar_t *val) { if (currDb == nullptr) return 1; @@ -314,7 +314,7 @@ MIR_CORE_DLL(INT_PTR) db_set_ws(MCONTACT hContact, const char *szModule, const c cws.szModule = szModule; cws.szSetting = szSetting; cws.value.type = DBVT_WCHAR; - cws.value.pwszVal = (WCHAR*)(val == nullptr ? L"" : val); + cws.value.pwszVal = (wchar_t*)(val == nullptr ? L"" : val); return currDb->WriteContactSetting(hContact, &cws); } diff --git a/src/mir_core/src/langpack.cpp b/src/mir_core/src/langpack.cpp index d924f13f6d..4c54fa338a 100644 --- a/src/mir_core/src/langpack.cpp +++ b/src/mir_core/src/langpack.cpp @@ -526,9 +526,9 @@ MIR_CORE_DLL(char*) TranslateA_LP(const char *str, HPLUGIN pPlugin) return (char*)LangPackTranslateString(GetMuid(pPlugin), str, FALSE); } -MIR_CORE_DLL(WCHAR*) TranslateW_LP(const WCHAR *str, HPLUGIN pPlugin) +MIR_CORE_DLL(wchar_t*) TranslateW_LP(const wchar_t *str, HPLUGIN pPlugin) { - return (WCHAR*)LangPackTranslateString(GetMuid(pPlugin), (LPCSTR)str, TRUE); + return (wchar_t*)LangPackTranslateString(GetMuid(pPlugin), (LPCSTR)str, TRUE); } MIR_CORE_DLL(void) TranslateMenu_LP(HMENU hMenu, HPLUGIN pPlugin) diff --git a/src/mir_core/src/logger.cpp b/src/mir_core/src/logger.cpp index f316329b87..7353876872 100644 --- a/src/mir_core/src/logger.cpp +++ b/src/mir_core/src/logger.cpp @@ -107,12 +107,10 @@ MIR_CORE_DLL(HANDLE) mir_createLog(const char* pszName, const wchar_t *ptszDescr } FILE *fp = _wfopen(ptszFile, L"ab"); - if (fp == nullptr) { - wchar_t tszPath[MAX_PATH]; - wcsncpy_s(tszPath, ptszFile, _TRUNCATE); - CreatePathToFileW(tszPath); - } - else fclose(fp); + if (fp == nullptr) + CreatePathToFileW(ptszFile); + else + fclose(fp); DeleteFile(ptszFile); arLoggers.insert(result); @@ -161,7 +159,7 @@ MIR_C_CORE_DLL(int) mir_writeLogA(HANDLE hLogger, const char *format, ...) return 0; } -MIR_C_CORE_DLL(int) mir_writeLogW(HANDLE hLogger, const WCHAR *format, ...) +MIR_C_CORE_DLL(int) mir_writeLogW(HANDLE hLogger, const wchar_t *format, ...) { Logger *p = prepareLogger(hLogger); if (p == nullptr) @@ -204,7 +202,7 @@ MIR_CORE_DLL(int) mir_writeLogVA(HANDLE hLogger, const char *format, va_list arg return 0; } -MIR_CORE_DLL(int) mir_writeLogVW(HANDLE hLogger, const WCHAR *format, va_list args) +MIR_CORE_DLL(int) mir_writeLogVW(HANDLE hLogger, const wchar_t *format, va_list args) { Logger *p = prepareLogger(hLogger); if (p == nullptr) diff --git a/src/mir_core/src/memory.cpp b/src/mir_core/src/memory.cpp index 73294da47d..cc73faa118 100644 --- a/src/mir_core/src/memory.cpp +++ b/src/mir_core/src/memory.cpp @@ -155,12 +155,12 @@ MIR_CORE_DLL(char*) mir_strdup(const char *str) return p; } -MIR_CORE_DLL(WCHAR*) mir_wstrdup(const WCHAR *str) +MIR_CORE_DLL(wchar_t*) mir_wstrdup(const wchar_t *str) { if (str == nullptr) return nullptr; - WCHAR *p = (WCHAR*)mir_alloc(sizeof(WCHAR)*(wcslen(str)+1)); + wchar_t *p = (wchar_t*)mir_alloc(sizeof(wchar_t)*(wcslen(str)+1)); if (p) wcscpy(p, str); return p; @@ -181,14 +181,14 @@ MIR_CORE_DLL(char*) mir_strndup(const char *str, size_t len) return p; } -MIR_CORE_DLL(WCHAR*) mir_wstrndup(const WCHAR *str, size_t len) +MIR_CORE_DLL(wchar_t*) mir_wstrndup(const wchar_t *str, size_t len) { if (str == nullptr || len == 0) return nullptr; - WCHAR *p = (WCHAR*)mir_alloc(sizeof(WCHAR)*(len+1)); + wchar_t *p = (wchar_t*)mir_alloc(sizeof(wchar_t)*(len+1)); if (p) { - memcpy(p, str, sizeof(WCHAR)*len); + memcpy(p, str, sizeof(wchar_t)*len); p[len] = 0; } return p; @@ -208,7 +208,7 @@ MIR_CORE_DLL(int) mir_snprintf(char *buffer, size_t count, const char* fmt, ...) /******************************************************************************/ -MIR_CORE_DLL(int) mir_snwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, ...) +MIR_CORE_DLL(int) mir_snwprintf(wchar_t *buffer, size_t count, const wchar_t* fmt, ...) { va_list va; va_start(va, fmt); @@ -229,7 +229,7 @@ MIR_CORE_DLL(int) mir_vsnprintf(char *buffer, size_t count, const char* fmt, va_ /******************************************************************************/ -MIR_CORE_DLL(int) mir_vsnwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, va_list va) +MIR_CORE_DLL(int) mir_vsnwprintf(wchar_t *buffer, size_t count, const wchar_t* fmt, va_list va) { int len = _vsntprintf(buffer, count-1, fmt, va); buffer[count-1] = 0; diff --git a/src/mir_core/src/path.cpp b/src/mir_core/src/path.cpp index 5809593ff9..eb1577748e 100644 --- a/src/mir_core/src/path.cpp +++ b/src/mir_core/src/path.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" static char szMirandaPath[MAX_PATH]; -static WCHAR szMirandaPathW[MAX_PATH]; +static wchar_t szMirandaPathW[MAX_PATH]; ///////////////////////////////////////////////////////////////////////////////////////// @@ -119,7 +119,7 @@ MIR_CORE_DLL(int) CreateDirectoryTree(const char *szDir) ///////////////////////////////////////////////////////////////////////////////////////// -MIR_CORE_DLL(int) PathIsAbsoluteW(const WCHAR *path) +MIR_CORE_DLL(int) PathIsAbsoluteW(const wchar_t *path) { if (path && wcslen(path) > 2) if ((path[1] == ':' && path[2] == '\\') || (path[0] == '\\' && path[1] == '\\')) @@ -127,7 +127,7 @@ MIR_CORE_DLL(int) PathIsAbsoluteW(const WCHAR *path) return 0; } -MIR_CORE_DLL(int) PathToRelativeW(const WCHAR *pSrc, WCHAR *pOut, const WCHAR *pBase) +MIR_CORE_DLL(int) PathToRelativeW(const wchar_t *pSrc, wchar_t *pOut, const wchar_t *pBase) { if (!pSrc || !pSrc[0] || wcslen(pSrc) > MAX_PATH) return 0; @@ -147,14 +147,14 @@ MIR_CORE_DLL(int) PathToRelativeW(const WCHAR *pSrc, WCHAR *pOut, const WCHAR *p return (int)wcslen(pOut); } -MIR_CORE_DLL(int) PathToAbsoluteW(const WCHAR *pSrc, WCHAR *pOut, const WCHAR *base) +MIR_CORE_DLL(int) PathToAbsoluteW(const wchar_t *pSrc, wchar_t *pOut, const wchar_t *base) { if (!pSrc || !pSrc[0] || wcslen(pSrc) > MAX_PATH) { *pOut = 0; return 0; } - WCHAR buf[MAX_PATH]; + wchar_t buf[MAX_PATH]; if (pSrc[0] < ' ') return mir_snwprintf(pOut, MAX_PATH, L"%s", pSrc); @@ -185,19 +185,19 @@ MIR_CORE_DLL(int) CreatePathToFileW(const wchar_t *wszFilePath) return CreateDirectoryTreeW(buf); } -MIR_CORE_DLL(int) CreateDirectoryTreeW(const WCHAR *szDir) +MIR_CORE_DLL(int) CreateDirectoryTreeW(const wchar_t *szDir) { if (szDir == nullptr) return 1; - WCHAR szTestDir[MAX_PATH]; + wchar_t szTestDir[MAX_PATH]; mir_wstrncpy(szTestDir, szDir, _countof(szTestDir)); DWORD dwAttributes = GetFileAttributesW(szTestDir); if (dwAttributes != INVALID_FILE_ATTRIBUTES && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)) return 0; - WCHAR *pszLastBackslash = wcsrchr(szTestDir, '\\'); + wchar_t *pszLastBackslash = wcsrchr(szTestDir, '\\'); if (pszLastBackslash == nullptr) return 0; @@ -215,7 +215,7 @@ int InitPathUtils(void) p[1] = 0; GetModuleFileNameW(nullptr, szMirandaPathW, _countof(szMirandaPathW)); - WCHAR *tp = wcsrchr(szMirandaPathW, '\\'); + wchar_t *tp = wcsrchr(szMirandaPathW, '\\'); if (tp) tp[1] = 0; return 0; diff --git a/src/mir_core/src/utf.cpp b/src/mir_core/src/utf.cpp index 580bf35db9..db85660709 100644 --- a/src/mir_core/src/utf.cpp +++ b/src/mir_core/src/utf.cpp @@ -103,7 +103,7 @@ int Ucs2toUtf8(const wchar_t *src, int srclen, char *dst, int dstlen) int len; for (len = dstlen; srclen; srclen--, src++) { - WCHAR ch = *src; + wchar_t ch = *src; unsigned int val; if (ch < 0x80) { /* 0x00-0x7f: 1 byte */ diff --git a/src/mir_core/src/utils.cpp b/src/mir_core/src/utils.cpp index df90e62d2a..761cf45100 100644 --- a/src/mir_core/src/utils.cpp +++ b/src/mir_core/src/utils.cpp @@ -32,7 +32,7 @@ MIR_CORE_DLL(char*) replaceStr(char* &dest, const char *src) return dest = (src != nullptr) ? mir_strdup(src) : nullptr; } -MIR_CORE_DLL(WCHAR*) replaceStrW(WCHAR* &dest, const WCHAR *src) +MIR_CORE_DLL(wchar_t*) replaceStrW(wchar_t* &dest, const wchar_t *src) { if (dest != nullptr) mir_free(dest); @@ -57,12 +57,12 @@ MIR_CORE_DLL(char*) rtrim(char *str) return str; } -MIR_CORE_DLL(WCHAR*) rtrimw(WCHAR *str) +MIR_CORE_DLL(wchar_t*) rtrimw(wchar_t *str) { if (str == nullptr) return nullptr; - WCHAR *p = wcschr(str, 0); + wchar_t *p = wcschr(str, 0); while (--p >= str) { switch (*p) { case ' ': case '\t': case '\n': case '\r': @@ -91,18 +91,18 @@ MIR_CORE_DLL(char*) ltrim(char *str) } } -MIR_CORE_DLL(WCHAR*) ltrimw(WCHAR *str) +MIR_CORE_DLL(wchar_t*) ltrimw(wchar_t *str) { if (str == nullptr) return nullptr; - WCHAR *p = str; + wchar_t *p = str; for (;;) { switch (*p) { case ' ': case '\t': case '\n': case '\r': ++p; break; default: - memmove(str, p, sizeof(WCHAR)*(wcslen(p) + 1)); + memmove(str, p, sizeof(wchar_t)*(wcslen(p) + 1)); return str; } } @@ -124,12 +124,12 @@ MIR_CORE_DLL(char*) ltrimp(char *str) } } -MIR_CORE_DLL(WCHAR*) ltrimpw(WCHAR *str) +MIR_CORE_DLL(wchar_t*) ltrimpw(wchar_t *str) { if (str == nullptr) return nullptr; - WCHAR *p = str; + wchar_t *p = str; for (;;) { switch (*p) { case ' ': case '\t': case '\n': case '\r': @@ -185,12 +185,12 @@ 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) wildcmpw(const wchar_t *name, const wchar_t *mask) { if (name == nullptr || mask == nullptr) return false; - const WCHAR* last = nullptr; + const wchar_t* last = nullptr; for (;; mask++, name++) { if (*mask != '?' && *mask != *name) break; if (*name == '\0') return ((BOOL)!*mask); @@ -229,12 +229,12 @@ MIR_CORE_DLL(int) wildcmpi(const char *name, const char *mask) } } -MIR_CORE_DLL(int) wildcmpiw(const WCHAR *name, const WCHAR *mask) +MIR_CORE_DLL(int) wildcmpiw(const wchar_t *name, const wchar_t *mask) { if (name == nullptr || mask == nullptr) return false; - const WCHAR* last = nullptr; + const wchar_t* last = nullptr; for (;; mask++, name++) { if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) break; if (*name == '\0') return ((BOOL)!*mask); @@ -268,10 +268,10 @@ MIR_CORE_DLL(char*) bin2hex(const void *pData, size_t len, char *dest) return dest; } -MIR_CORE_DLL(WCHAR*) bin2hexW(const void *pData, size_t len, WCHAR *dest) +MIR_CORE_DLL(wchar_t*) bin2hexW(const void *pData, size_t len, wchar_t *dest) { const BYTE *p = (const BYTE*)pData; - WCHAR *d = dest; + wchar_t *d = dest; for (size_t i = 0; i < len; i++, p++) { *d++ = szHexTable[*p >> 4]; -- cgit v1.2.3