summaryrefslogtreecommitdiff
path: root/src/modules/utils
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-06-15 14:13:45 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-06-15 14:13:45 +0000
commit4aa6229698b946e52ce19018aaf13f8b92fb168e (patch)
tree29334e8c5ee492a80f11a97fedab2373b8fbb392 /src/modules/utils
parent5e8e561a80d1ac9ca1c2f1c3d388105733ed4e4e (diff)
another portion of "#ifsef Unicode" removal
git-svn-id: http://svn.miranda-ng.org/main/trunk@426 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/utils')
-rw-r--r--src/modules/utils/bmpfilter.cpp10
-rw-r--r--src/modules/utils/path.cpp14
-rw-r--r--src/modules/utils/timeutils.cpp162
-rw-r--r--src/modules/utils/timezones.cpp22
-rw-r--r--src/modules/utils/utils.cpp2
5 files changed, 7 insertions, 203 deletions
diff --git a/src/modules/utils/bmpfilter.cpp b/src/modules/utils/bmpfilter.cpp
index 5dbf37b12f..8cedc1ba87 100644
--- a/src/modules/utils/bmpfilter.cpp
+++ b/src/modules/utils/bmpfilter.cpp
@@ -129,12 +129,10 @@ static INT_PTR BmpFilterLoadBitmap(WPARAM, LPARAM lParam)
return sttBitmapLoader( StrConvT(( const char* )lParam ));
}
-#if defined( _UNICODE )
static INT_PTR BmpFilterLoadBitmapW(WPARAM, LPARAM lParam)
{
return sttBitmapLoader(( const wchar_t* )lParam );
}
-#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -183,7 +181,6 @@ static INT_PTR BmpFilterGetStrings(WPARAM wParam, LPARAM lParam)
return 0;
}
-#if defined( _UNICODE )
static INT_PTR BmpFilterGetStringsW(WPARAM wParam, LPARAM lParam)
{
int bytesLeft=wParam;
@@ -228,15 +225,12 @@ static INT_PTR BmpFilterGetStringsW(WPARAM wParam, LPARAM lParam)
if (bytesLeft) *pfilter='\0';
return 0;
}
-#endif
int InitBitmapFilter(void)
{
CreateServiceFunction(MS_UTILS_LOADBITMAP, BmpFilterLoadBitmap);
CreateServiceFunction(MS_UTILS_GETBITMAPFILTERSTRINGS, BmpFilterGetStrings);
- #if defined( _UNICODE )
- CreateServiceFunction(MS_UTILS_GETBITMAPFILTERSTRINGSW, BmpFilterGetStringsW);
- CreateServiceFunction(MS_UTILS_LOADBITMAPW, BmpFilterLoadBitmapW);
- #endif
+ CreateServiceFunction(MS_UTILS_GETBITMAPFILTERSTRINGSW, BmpFilterGetStringsW);
+ CreateServiceFunction(MS_UTILS_LOADBITMAPW, BmpFilterLoadBitmapW);
return 0;
}
diff --git a/src/modules/utils/path.cpp b/src/modules/utils/path.cpp
index 49e5ae8bf4..c2915fb7ed 100644
--- a/src/modules/utils/path.cpp
+++ b/src/modules/utils/path.cpp
@@ -129,7 +129,6 @@ static INT_PTR createDirTree(WPARAM, LPARAM lParam)
return CreateDirectoryTree(( char* )lParam );
}
-#ifdef _UNICODE
static TCHAR szMirandaPathW[MAX_PATH];
static TCHAR szMirandaPathWLower[MAX_PATH];
@@ -241,7 +240,6 @@ int InitPathUtilsW(void)
CreateServiceFunction(MS_UTILS_CREATEDIRTREEW, createDirTreeW);
return 0;
}
-#endif
TCHAR *GetContactID(HANDLE hContact)
{
@@ -362,7 +360,6 @@ static __forceinline char *GetPathVarX(char *, int code)
return makeFileName( szFullPath );
}
-#ifdef _UNICODE
static __forceinline int _xcscmp(const TCHAR *s1, const TCHAR *s2) { return _tcscmp(s1, s2); }
static __forceinline int _xcsncmp(const TCHAR *s1, const TCHAR *s2, size_t n) { return _tcsncmp(s1, s2, n); }
static __forceinline size_t _xcslen(const TCHAR *s1) { return _tcslen(s1); }
@@ -443,7 +440,6 @@ static __forceinline TCHAR *GetPathVarX(TCHAR *, int code)
}
return mir_tstrdup( szFullPath );
}
-#endif
template<typename XCHAR>
XCHAR *GetInternalVariable(XCHAR *key, size_t keyLength, HANDLE hContact)
@@ -572,11 +568,8 @@ static INT_PTR replaceVars(WPARAM wParam, LPARAM lParam)
if (!(data->dwFlags & RVF_UNICODE))
return (INT_PTR)ReplaceVariables<char>((char *)wParam, data);
-#ifdef _UNICODE
+
return (INT_PTR)ReplaceVariables<WCHAR>((WCHAR *)wParam, data);
-#else
- return NULL;
-#endif
}
int InitPathUtils(void)
@@ -592,9 +585,6 @@ int InitPathUtils(void)
CreateServiceFunction(MS_UTILS_PATHTOABSOLUTE, pathToAbsolute);
CreateServiceFunction(MS_UTILS_CREATEDIRTREE, createDirTree);
CreateServiceFunction(MS_UTILS_REPLACEVARS, replaceVars);
-#ifdef _UNICODE
+
return InitPathUtilsW();
-#else
- return 0;
-#endif
}
diff --git a/src/modules/utils/timeutils.cpp b/src/modules/utils/timeutils.cpp
index cea409ef82..5e921566d5 100644
--- a/src/modules/utils/timeutils.cpp
+++ b/src/modules/utils/timeutils.cpp
@@ -113,165 +113,3 @@ void FormatTime(const SYSTEMTIME *st, const TCHAR *szFormat, TCHAR *szDest, int
}
*pDest = 0;
}
-
-
-#ifndef _UNICODE
-void ConvertToAbsolute (const SYSTEMTIME * pstLoc, const SYSTEMTIME * pstDst, SYSTEMTIME * pstDstAbs)
-{
- static int iDays [12] = { 31, 28, 31, 30, 31, 30,
- 31, 31, 30, 31, 30, 31 } ;
- int iDay ;
-
- // Set up the aboluste date structure except for wDay, which we must find
-
- pstDstAbs->wYear = pstLoc->wYear ; // Notice from local date/time
- pstDstAbs->wMonth = pstDst->wMonth ;
- pstDstAbs->wDayOfWeek = pstDst->wDayOfWeek ;
-
- pstDstAbs->wHour = pstDst->wHour ;
- pstDstAbs->wMinute = pstDst->wMinute ;
- pstDstAbs->wSecond = pstDst->wSecond ;
- pstDstAbs->wMilliseconds = pstDst->wMilliseconds ;
-
- // Fix the iDays array for leap years
-
- if ((pstLoc->wYear % 4 == 0) && ((pstLoc->wYear % 100 != 0) ||
- (pstLoc->wYear % 400 == 0)))
- {
- iDays[1] = 29 ;
- }
-
- // Find a day of the month that falls on the same
- // day of the week as the transition.
-
- // Suppose today is the 20th of the month (pstLoc->wDay = 20)
- // Suppose today is a Wednesday (pstLoc->wDayOfWeek = 3)
- // Suppose the transition occurs on a Friday (pstDst->wDayOfWeek = 5)
- // Then iDay = 31, meaning that the 31st falls on a Friday
- // (The 7 is this formula avoids negatives.)
-
- iDay = pstLoc->wDay + pstDst->wDayOfWeek + 7 - pstLoc->wDayOfWeek ;
-
- // Now shrink iDay to a value between 1 and 7.
-
- iDay = (iDay - 1) % 7 + 1 ;
-
- // Now iDay is a day of the month ranging from 1 to 7.
- // Recall that the wDay field of the structure can range
- // from 1 to 5, 1 meaning "first", 2 meaning "second",
- // and 5 meaning "last".
- // So, increase iDay so it's the proper day of the month.
-
- iDay += 7 * (pstDst->wDay - 1) ;
-
- // Could be that iDay overshot the end of the month, so
- // fix it up using the number of days in each month
-
- if (iDay > iDays[pstDst->wMonth - 1])
- iDay -= 7 ;
-
- // Assign that day to the structure.
-
- pstDstAbs->wDay = iDay ;
-}
-
-BOOL LocalGreaterThanTransition (const SYSTEMTIME * pstLoc, const SYSTEMTIME * pstTran)
-{
- FILETIME ftLoc, ftTran ;
- LARGE_INTEGER liLoc, liTran ;
- SYSTEMTIME stTranAbs ;
-
- // Easy case: Just compare the two months
-
- if (pstLoc->wMonth != pstTran->wMonth)
- return (pstLoc->wMonth > pstTran->wMonth) ;
-
- // Well, we're in a transition month. That requires a bit more work.
-
- // Check if pstDst is in absolute or day-in-month format.
- // (See documentation of TIME_ZONE_INFORMATION, StandardDate field.)
-
- if (pstTran->wYear) // absolute format (haven't seen one yet!)
- {
- stTranAbs = * pstTran ;
- }
- else // day-in-month format
- {
- ConvertToAbsolute (pstLoc, pstTran, &stTranAbs) ;
- }
-
- // Now convert both date/time structures to large integers & compare
-
- SystemTimeToFileTime (pstLoc, &ftLoc) ;
- liLoc = * (LARGE_INTEGER *) (void *) &ftLoc ;
-
- SystemTimeToFileTime (&stTranAbs, &ftTran) ;
- liTran = * (LARGE_INTEGER *) (void *) &ftTran ;
-
- return (liLoc.QuadPart > liTran.QuadPart) ;
-}
-
-BOOL MySystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION ptzi, LPSYSTEMTIME pstUtc, LPSYSTEMTIME pstLoc)
-{
- // st is UTC
-
- FILETIME ft ;
- LARGE_INTEGER li ;
- SYSTEMTIME stDst ;
-
- if (IsWinVerNT())
- return SystemTimeToTzSpecificLocalTime(ptzi, pstUtc, pstLoc);
-
- // Convert time to a LARGE_INTEGER and subtract the bias
-
- SystemTimeToFileTime (pstUtc, &ft) ;
- li = * (LARGE_INTEGER *) (void *) &ft;
- li.QuadPart -= (LONGLONG) 600000000 * ptzi->Bias ;
-
- // Convert to a local date/time before application of daylight saving time.
- // The local date/time must be used to determine when the conversion occurs.
-
- ft = * (FILETIME *) (void *) &li ;
- FileTimeToSystemTime (&ft, pstLoc) ;
-
- // Find the time assuming Daylight Saving Time
-
- li.QuadPart -= (LONGLONG) 600000000 * ptzi->DaylightBias ;
- ft = * (FILETIME *) (void *) &li ;
- FileTimeToSystemTime (&ft, &stDst) ;
-
- // Now put li back the way it was
-
- li.QuadPart += (LONGLONG) 600000000 * ptzi->DaylightBias ;
-
- if (ptzi->StandardDate.wMonth) // ie, daylight savings time
- {
- // Northern hemisphere
- if ((ptzi->DaylightDate.wMonth < ptzi->StandardDate.wMonth) &&
-
- (stDst.wMonth >= pstLoc->wMonth) && // avoid the end of year problem
-
- LocalGreaterThanTransition (pstLoc, &ptzi->DaylightDate) &&
- !LocalGreaterThanTransition (&stDst, &ptzi->StandardDate))
- {
- li.QuadPart -= (LONGLONG) 600000000 * ptzi->DaylightBias ;
- }
- // Southern hemisphere
-
- else if ((ptzi->StandardDate.wMonth < ptzi->DaylightDate.wMonth) &&
- (!LocalGreaterThanTransition (&stDst, &ptzi->StandardDate) ||
- LocalGreaterThanTransition (pstLoc, &ptzi->DaylightDate)))
- {
- li.QuadPart -= (LONGLONG) 600000000 * ptzi->DaylightBias ;
- }
- else
- {
- li.QuadPart -= (LONGLONG) 600000000 * ptzi->StandardBias ;
- }
- }
-
- ft = * (FILETIME *) (void *) &li ;
- FileTimeToSystemTime (&ft, pstLoc) ;
- return TRUE ;
-}
-#endif
diff --git a/src/modules/utils/timezones.cpp b/src/modules/utils/timezones.cpp
index 1fe186d633..c562ce6460 100644
--- a/src/modules/utils/timezones.cpp
+++ b/src/modules/utils/timezones.cpp
@@ -97,13 +97,7 @@ void FormatTime (const SYSTEMTIME *st, const TCHAR *szFormat, TCHAR *szDest, int
void UnixTimeToFileTime(time_t ts, LPFILETIME pft);
time_t FileTimeToUnixTime(LPFILETIME pft);
-#ifdef _UNICODE
#define fnSystemTimeToTzSpecificLocalTime SystemTimeToTzSpecificLocalTime
-#else
-BOOL MySystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION ptzi, LPSYSTEMTIME pstUtc, LPSYSTEMTIME pstLoc);
-#define fnSystemTimeToTzSpecificLocalTime MySystemTimeToTzSpecificLocalTime
-#endif
-
static int timeapiGetTimeZoneTime(HANDLE hTZ, SYSTEMTIME *st)
{
@@ -490,7 +484,6 @@ static INT_PTR TimestampToStringT(WPARAM wParam, LPARAM lParam)
return 0;
}
-#ifdef _UNICODE
static INT_PTR TimestampToStringA(WPARAM wParam, LPARAM lParam)
{
DBTIMETOSTRING *tts = (DBTIMETOSTRING*)lParam;
@@ -501,7 +494,6 @@ static INT_PTR TimestampToStringA(WPARAM wParam, LPARAM lParam)
WideCharToMultiByte(CP_ACP, 0, szDest, -1, tts->szDest, tts->cbDest, NULL, NULL);
return 0;
}
-#endif
void GetLocalizedString(HKEY hSubKey, const TCHAR *szName, wchar_t *szBuf, DWORD cbLen)
{
@@ -522,15 +514,9 @@ void GetLocalizedString(HKEY hSubKey, const TCHAR *szName, wchar_t *szBuf, DWORD
{
DWORD dwLength = cbLen * sizeof(wchar_t);
-#ifdef _UNICODE
+
RegQueryValueEx(hSubKey, szName, NULL, NULL, (unsigned char *)szBuf, &dwLength);
szBuf[min(dwLength / sizeof(TCHAR), cbLen - 1)] = 0;
-#else
- char* szBufP = (char*)alloca(dwLength);
- RegQueryValueEx(hSubKey, szName, NULL, NULL, (unsigned char *)szBufP, &dwLength);
- szBufP[min(dwLength, cbLen * sizeof(wchar_t) - 1)] = 0;
- MultiByteToWideChar(CP_ACP, 0, szBufP, -1, szBuf, cbLen);
-#endif
}
}
@@ -644,11 +630,9 @@ void InitTimeZones(void)
CreateServiceFunction(MS_DB_TIME_TIMESTAMPTOLOCAL, TimestampToLocal);
CreateServiceFunction(MS_DB_TIME_TIMESTAMPTOSTRINGT, TimestampToStringT);
-#ifdef _UNICODE
+
CreateServiceFunction(MS_DB_TIME_TIMESTAMPTOSTRING, TimestampToStringA);
-#else
- CreateServiceFunction(MS_DB_TIME_TIMESTAMPTOSTRING, TimestampToStringT);
-#endif
+
tmi.cbSize = sizeof(tmi);
diff --git a/src/modules/utils/utils.cpp b/src/modules/utils/utils.cpp
index de49be7ab1..50358ca6f9 100644
--- a/src/modules/utils/utils.cpp
+++ b/src/modules/utils/utils.cpp
@@ -460,7 +460,6 @@ static INT_PTR GenerateRandom(WPARAM wParam, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
-#if defined( _UNICODE )
char* __fastcall rtrim(char* str)
{
if (str == NULL) return NULL;
@@ -477,7 +476,6 @@ char* __fastcall rtrim(char* str)
}
return str;
}
-#endif
TCHAR* __fastcall rtrim(TCHAR *str)
{