mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
[MSCONFIG_NEW]
Reduce indentation level in code. svn path=/trunk/; revision=69637
This commit is contained in:
parent
9de150d140
commit
0e3bf63096
2 changed files with 105 additions and 107 deletions
|
@ -15,15 +15,17 @@
|
||||||
//
|
//
|
||||||
LPTSTR FormatStringV(LPCTSTR str, va_list args)
|
LPTSTR FormatStringV(LPCTSTR str, va_list args)
|
||||||
{
|
{
|
||||||
LPTSTR lpszString = NULL;
|
LPTSTR lpszString;
|
||||||
|
size_t strLenPlusNull;
|
||||||
|
|
||||||
if (str)
|
if (!str) return NULL;
|
||||||
{
|
|
||||||
size_t strLenPlusNull = _vsctprintf(str, args) + 1;
|
strLenPlusNull = _vsctprintf(str, args) + 1;
|
||||||
lpszString = (LPTSTR)MemAlloc(0, strLenPlusNull * sizeof(TCHAR));
|
|
||||||
if (lpszString)
|
lpszString = (LPTSTR)MemAlloc(0, strLenPlusNull * sizeof(TCHAR));
|
||||||
StringCchVPrintf(lpszString, strLenPlusNull, str, args);
|
if (!lpszString) return NULL;
|
||||||
}
|
|
||||||
|
StringCchVPrintf(lpszString, strLenPlusNull, str, args);
|
||||||
|
|
||||||
return lpszString;
|
return lpszString;
|
||||||
}
|
}
|
||||||
|
@ -45,114 +47,112 @@ LPTSTR FormatString(LPCTSTR str, ...)
|
||||||
//
|
//
|
||||||
LPSTR UnicodeToAnsi(LPCWSTR strW)
|
LPSTR UnicodeToAnsi(LPCWSTR strW)
|
||||||
{
|
{
|
||||||
LPSTR strA = NULL;
|
LPSTR strA;
|
||||||
|
int iNeededChars;
|
||||||
|
|
||||||
if (strW)
|
if (!strW) return NULL;
|
||||||
{
|
|
||||||
int iNeededChars = WideCharToMultiByte(CP_ACP,
|
|
||||||
WC_COMPOSITECHECK /* | WC_NO_BEST_FIT_CHARS */,
|
|
||||||
strW, -1, NULL, 0, NULL, NULL);
|
|
||||||
|
|
||||||
strA = (LPSTR)MemAlloc(0, iNeededChars * sizeof(CHAR));
|
iNeededChars = WideCharToMultiByte(CP_ACP,
|
||||||
if (strA)
|
WC_COMPOSITECHECK /* | WC_NO_BEST_FIT_CHARS */,
|
||||||
{
|
strW, -1, NULL, 0, NULL, NULL);
|
||||||
WideCharToMultiByte(CP_ACP,
|
|
||||||
WC_COMPOSITECHECK /* | WC_NO_BEST_FIT_CHARS */,
|
strA = (LPSTR)MemAlloc(0, iNeededChars * sizeof(CHAR));
|
||||||
strW, -1, strA, iNeededChars, NULL, NULL);
|
if (!strA) return NULL;
|
||||||
}
|
|
||||||
}
|
WideCharToMultiByte(CP_ACP,
|
||||||
|
WC_COMPOSITECHECK /* | WC_NO_BEST_FIT_CHARS */,
|
||||||
|
strW, -1, strA, iNeededChars, NULL, NULL);
|
||||||
|
|
||||||
return strA;
|
return strA;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPWSTR AnsiToUnicode(LPCSTR strA)
|
LPWSTR AnsiToUnicode(LPCSTR strA)
|
||||||
{
|
{
|
||||||
LPWSTR strW = NULL;
|
LPWSTR strW;
|
||||||
|
int iNeededChars;
|
||||||
|
|
||||||
if (strA)
|
if (!strA) return NULL;
|
||||||
{
|
|
||||||
int iNeededChars = MultiByteToWideChar(CP_ACP,
|
|
||||||
MB_PRECOMPOSED,
|
|
||||||
strA, -1, NULL, 0);
|
|
||||||
|
|
||||||
strW = (LPWSTR)MemAlloc(0, iNeededChars * sizeof(WCHAR));
|
iNeededChars = MultiByteToWideChar(CP_ACP,
|
||||||
if (strW)
|
MB_PRECOMPOSED,
|
||||||
{
|
strA, -1, NULL, 0);
|
||||||
MultiByteToWideChar(CP_ACP,
|
|
||||||
MB_PRECOMPOSED,
|
strW = (LPWSTR)MemAlloc(0, iNeededChars * sizeof(WCHAR));
|
||||||
strA, -1, strW, iNeededChars);
|
if (!strW) return NULL;
|
||||||
}
|
|
||||||
}
|
MultiByteToWideChar(CP_ACP,
|
||||||
|
MB_PRECOMPOSED,
|
||||||
|
strA, -1, strW, iNeededChars);
|
||||||
|
|
||||||
return strW;
|
return strW;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPSTR DuplicateStringA(LPCSTR str)
|
LPSTR DuplicateStringA(LPCSTR str)
|
||||||
{
|
{
|
||||||
LPSTR dupStr = NULL;
|
LPSTR dupStr;
|
||||||
|
size_t strSizePlusNull;
|
||||||
|
|
||||||
if (str)
|
if (!str) return NULL;
|
||||||
{
|
|
||||||
size_t strSizePlusNull = strlen(str) + 1;
|
|
||||||
|
|
||||||
dupStr = (LPSTR)MemAlloc(0, strSizePlusNull * sizeof(CHAR));
|
strSizePlusNull = strlen(str) + 1;
|
||||||
if (dupStr)
|
|
||||||
StringCchCopyA(dupStr, strSizePlusNull, str);
|
dupStr = (LPSTR)MemAlloc(0, strSizePlusNull * sizeof(CHAR));
|
||||||
}
|
if (!dupStr) return NULL;
|
||||||
|
|
||||||
|
StringCchCopyA(dupStr, strSizePlusNull, str);
|
||||||
|
|
||||||
return dupStr;
|
return dupStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPWSTR DuplicateStringW(LPCWSTR str)
|
LPWSTR DuplicateStringW(LPCWSTR str)
|
||||||
{
|
{
|
||||||
LPWSTR dupStr = NULL;
|
LPWSTR dupStr;
|
||||||
|
size_t strSizePlusNull;
|
||||||
|
|
||||||
if (str)
|
if (!str) return NULL;
|
||||||
{
|
|
||||||
size_t strSizePlusNull = wcslen(str) + 1;
|
|
||||||
|
|
||||||
dupStr = (LPWSTR)MemAlloc(0, strSizePlusNull * sizeof(WCHAR));
|
strSizePlusNull = wcslen(str) + 1;
|
||||||
if (dupStr)
|
|
||||||
StringCchCopyW(dupStr, strSizePlusNull, str);
|
dupStr = (LPWSTR)MemAlloc(0, strSizePlusNull * sizeof(WCHAR));
|
||||||
}
|
if (!dupStr) return NULL;
|
||||||
|
|
||||||
|
StringCchCopyW(dupStr, strSizePlusNull, str);
|
||||||
|
|
||||||
return dupStr;
|
return dupStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPSTR DuplicateStringAEx(LPCSTR str, size_t numOfChars)
|
LPSTR DuplicateStringAEx(LPCSTR str, size_t numOfChars)
|
||||||
{
|
{
|
||||||
LPSTR dupStr = NULL;
|
LPSTR dupStr;
|
||||||
|
size_t strSize;
|
||||||
|
|
||||||
if (str)
|
if (!str) return NULL;
|
||||||
{
|
|
||||||
size_t strSize = min(strlen(str), numOfChars);
|
|
||||||
|
|
||||||
dupStr = (LPSTR)MemAlloc(0, (strSize + 1) * sizeof(CHAR));
|
strSize = min(strlen(str), numOfChars);
|
||||||
if (dupStr)
|
|
||||||
{
|
dupStr = (LPSTR)MemAlloc(0, (strSize + 1) * sizeof(CHAR));
|
||||||
StringCchCopyNA(dupStr, strSize + 1, str, strSize);
|
if (!dupStr) return NULL;
|
||||||
dupStr[strSize] = '\0';
|
|
||||||
}
|
StringCchCopyNA(dupStr, strSize + 1, str, strSize);
|
||||||
}
|
dupStr[strSize] = '\0';
|
||||||
|
|
||||||
return dupStr;
|
return dupStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPWSTR DuplicateStringWEx(LPCWSTR str, size_t numOfChars)
|
LPWSTR DuplicateStringWEx(LPCWSTR str, size_t numOfChars)
|
||||||
{
|
{
|
||||||
LPWSTR dupStr = NULL;
|
LPWSTR dupStr;
|
||||||
|
size_t strSize;
|
||||||
|
|
||||||
if (str)
|
if (!str) return NULL;
|
||||||
{
|
|
||||||
size_t strSize = min(wcslen(str), numOfChars);
|
|
||||||
|
|
||||||
dupStr = (LPWSTR)MemAlloc(0, (strSize + 1) * sizeof(WCHAR));
|
strSize = min(wcslen(str), numOfChars);
|
||||||
if (dupStr)
|
|
||||||
{
|
dupStr = (LPWSTR)MemAlloc(0, (strSize + 1) * sizeof(WCHAR));
|
||||||
StringCchCopyNW(dupStr, strSize + 1, str, strSize);
|
if (!dupStr) return NULL;
|
||||||
dupStr[strSize] = L'\0';
|
|
||||||
}
|
StringCchCopyNW(dupStr, strSize + 1, str, strSize);
|
||||||
}
|
dupStr[strSize] = L'\0';
|
||||||
|
|
||||||
return dupStr;
|
return dupStr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,42 +41,40 @@ LPWSTR
|
||||||
FormatDateTime(IN LPSYSTEMTIME pDateTime)
|
FormatDateTime(IN LPSYSTEMTIME pDateTime)
|
||||||
{
|
{
|
||||||
LPWSTR lpszDateTime = NULL;
|
LPWSTR lpszDateTime = NULL;
|
||||||
|
int iDateBufSize, iTimeBufSize;
|
||||||
|
|
||||||
if (pDateTime)
|
if (pDateTime == NULL) return NULL;
|
||||||
|
|
||||||
|
iDateBufSize = GetDateFormatW(LOCALE_USER_DEFAULT,
|
||||||
|
/* Only for Windows 7 : DATE_AUTOLAYOUT | */ DATE_SHORTDATE,
|
||||||
|
pDateTime,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
0);
|
||||||
|
iTimeBufSize = GetTimeFormatW(LOCALE_USER_DEFAULT,
|
||||||
|
0,
|
||||||
|
pDateTime,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
0);
|
||||||
|
|
||||||
|
if ( (iDateBufSize > 0) && (iTimeBufSize > 0) )
|
||||||
{
|
{
|
||||||
int iDateBufSize = 0, iTimeBufSize = 0;
|
lpszDateTime = (LPWSTR)MemAlloc(0, (iDateBufSize + iTimeBufSize) * sizeof(TCHAR));
|
||||||
|
|
||||||
iDateBufSize = GetDateFormatW(LOCALE_USER_DEFAULT,
|
GetDateFormatW(LOCALE_USER_DEFAULT,
|
||||||
/* Only for Windows 7 : DATE_AUTOLAYOUT | */ DATE_SHORTDATE,
|
/* Only for Windows 7 : DATE_AUTOLAYOUT | */ DATE_SHORTDATE,
|
||||||
pDateTime,
|
pDateTime,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
lpszDateTime,
|
||||||
0);
|
iDateBufSize);
|
||||||
iTimeBufSize = GetTimeFormatW(LOCALE_USER_DEFAULT,
|
if (iDateBufSize > 0) lpszDateTime[iDateBufSize-1] = L' ';
|
||||||
0,
|
GetTimeFormatW(LOCALE_USER_DEFAULT,
|
||||||
pDateTime,
|
0,
|
||||||
NULL,
|
pDateTime,
|
||||||
NULL,
|
NULL,
|
||||||
0);
|
lpszDateTime + iDateBufSize,
|
||||||
|
iTimeBufSize);
|
||||||
if ( (iDateBufSize > 0) && (iTimeBufSize > 0) )
|
|
||||||
{
|
|
||||||
lpszDateTime = (LPWSTR)MemAlloc(0, (iDateBufSize + iTimeBufSize) * sizeof(TCHAR));
|
|
||||||
|
|
||||||
GetDateFormatW(LOCALE_USER_DEFAULT,
|
|
||||||
/* Only for Windows 7 : DATE_AUTOLAYOUT | */ DATE_SHORTDATE,
|
|
||||||
pDateTime,
|
|
||||||
NULL,
|
|
||||||
lpszDateTime,
|
|
||||||
iDateBufSize);
|
|
||||||
if (iDateBufSize > 0) lpszDateTime[iDateBufSize-1] = L' ';
|
|
||||||
GetTimeFormatW(LOCALE_USER_DEFAULT,
|
|
||||||
0,
|
|
||||||
pDateTime,
|
|
||||||
NULL,
|
|
||||||
lpszDateTime + iDateBufSize,
|
|
||||||
iTimeBufSize);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return lpszDateTime;
|
return lpszDateTime;
|
||||||
|
|
Loading…
Reference in a new issue