Author: hbelusca
Date: Wed Oct 21 23:36:17 2015
New Revision: 69637
URL:
http://svn.reactos.org/svn/reactos?rev=69637&view=rev
Log:
[MSCONFIG_NEW]
Reduce indentation level in code.
Modified:
trunk/reactos/base/applications/msconfig_new/stringutils.c
trunk/reactos/base/applications/msconfig_new/utils.c
Modified: trunk/reactos/base/applications/msconfig_new/stringutils.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/msconfig…
==============================================================================
--- trunk/reactos/base/applications/msconfig_new/stringutils.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/msconfig_new/stringutils.c [iso-8859-1] Wed Oct 21
23:36:17 2015
@@ -15,15 +15,17 @@
//
LPTSTR FormatStringV(LPCTSTR str, va_list args)
{
- LPTSTR lpszString = NULL;
-
- if (str)
- {
- size_t strLenPlusNull = _vsctprintf(str, args) + 1;
- lpszString = (LPTSTR)MemAlloc(0, strLenPlusNull * sizeof(TCHAR));
- if (lpszString)
- StringCchVPrintf(lpszString, strLenPlusNull, str, args);
- }
+ LPTSTR lpszString;
+ size_t strLenPlusNull;
+
+ if (!str) return NULL;
+
+ strLenPlusNull = _vsctprintf(str, args) + 1;
+
+ lpszString = (LPTSTR)MemAlloc(0, strLenPlusNull * sizeof(TCHAR));
+ if (!lpszString) return NULL;
+
+ StringCchVPrintf(lpszString, strLenPlusNull, str, args);
return lpszString;
}
@@ -45,114 +47,112 @@
//
LPSTR UnicodeToAnsi(LPCWSTR strW)
{
- LPSTR strA = NULL;
-
- if (strW)
- {
- 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));
- if (strA)
- {
- WideCharToMultiByte(CP_ACP,
- WC_COMPOSITECHECK /* | WC_NO_BEST_FIT_CHARS */,
- strW, -1, strA, iNeededChars, NULL, NULL);
- }
- }
+ LPSTR strA;
+ int iNeededChars;
+
+ if (!strW) return NULL;
+
+ iNeededChars = WideCharToMultiByte(CP_ACP,
+ WC_COMPOSITECHECK /* | WC_NO_BEST_FIT_CHARS */,
+ strW, -1, NULL, 0, NULL, NULL);
+
+ strA = (LPSTR)MemAlloc(0, iNeededChars * sizeof(CHAR));
+ if (!strA) return NULL;
+
+ WideCharToMultiByte(CP_ACP,
+ WC_COMPOSITECHECK /* | WC_NO_BEST_FIT_CHARS */,
+ strW, -1, strA, iNeededChars, NULL, NULL);
return strA;
}
LPWSTR AnsiToUnicode(LPCSTR strA)
{
- LPWSTR strW = NULL;
-
- if (strA)
- {
- int iNeededChars = MultiByteToWideChar(CP_ACP,
- MB_PRECOMPOSED,
- strA, -1, NULL, 0);
-
- strW = (LPWSTR)MemAlloc(0, iNeededChars * sizeof(WCHAR));
- if (strW)
- {
- MultiByteToWideChar(CP_ACP,
- MB_PRECOMPOSED,
- strA, -1, strW, iNeededChars);
- }
- }
+ LPWSTR strW;
+ int iNeededChars;
+
+ if (!strA) return NULL;
+
+ iNeededChars = MultiByteToWideChar(CP_ACP,
+ MB_PRECOMPOSED,
+ strA, -1, NULL, 0);
+
+ strW = (LPWSTR)MemAlloc(0, iNeededChars * sizeof(WCHAR));
+ if (!strW) return NULL;
+
+ MultiByteToWideChar(CP_ACP,
+ MB_PRECOMPOSED,
+ strA, -1, strW, iNeededChars);
return strW;
}
LPSTR DuplicateStringA(LPCSTR str)
{
- LPSTR dupStr = NULL;
-
- if (str)
- {
- size_t strSizePlusNull = strlen(str) + 1;
-
- dupStr = (LPSTR)MemAlloc(0, strSizePlusNull * sizeof(CHAR));
- if (dupStr)
- StringCchCopyA(dupStr, strSizePlusNull, str);
- }
+ LPSTR dupStr;
+ size_t strSizePlusNull;
+
+ if (!str) return NULL;
+
+ strSizePlusNull = strlen(str) + 1;
+
+ dupStr = (LPSTR)MemAlloc(0, strSizePlusNull * sizeof(CHAR));
+ if (!dupStr) return NULL;
+
+ StringCchCopyA(dupStr, strSizePlusNull, str);
return dupStr;
}
LPWSTR DuplicateStringW(LPCWSTR str)
{
- LPWSTR dupStr = NULL;
-
- if (str)
- {
- size_t strSizePlusNull = wcslen(str) + 1;
-
- dupStr = (LPWSTR)MemAlloc(0, strSizePlusNull * sizeof(WCHAR));
- if (dupStr)
- StringCchCopyW(dupStr, strSizePlusNull, str);
- }
+ LPWSTR dupStr;
+ size_t strSizePlusNull;
+
+ if (!str) return NULL;
+
+ strSizePlusNull = wcslen(str) + 1;
+
+ dupStr = (LPWSTR)MemAlloc(0, strSizePlusNull * sizeof(WCHAR));
+ if (!dupStr) return NULL;
+
+ StringCchCopyW(dupStr, strSizePlusNull, str);
return dupStr;
}
LPSTR DuplicateStringAEx(LPCSTR str, size_t numOfChars)
{
- LPSTR dupStr = NULL;
-
- if (str)
- {
- size_t strSize = min(strlen(str), numOfChars);
-
- dupStr = (LPSTR)MemAlloc(0, (strSize + 1) * sizeof(CHAR));
- if (dupStr)
- {
- StringCchCopyNA(dupStr, strSize + 1, str, strSize);
- dupStr[strSize] = '\0';
- }
- }
+ LPSTR dupStr;
+ size_t strSize;
+
+ if (!str) return NULL;
+
+ strSize = min(strlen(str), numOfChars);
+
+ dupStr = (LPSTR)MemAlloc(0, (strSize + 1) * sizeof(CHAR));
+ if (!dupStr) return NULL;
+
+ StringCchCopyNA(dupStr, strSize + 1, str, strSize);
+ dupStr[strSize] = '\0';
return dupStr;
}
LPWSTR DuplicateStringWEx(LPCWSTR str, size_t numOfChars)
{
- LPWSTR dupStr = NULL;
-
- if (str)
- {
- size_t strSize = min(wcslen(str), numOfChars);
-
- dupStr = (LPWSTR)MemAlloc(0, (strSize + 1) * sizeof(WCHAR));
- if (dupStr)
- {
- StringCchCopyNW(dupStr, strSize + 1, str, strSize);
- dupStr[strSize] = L'\0';
- }
- }
+ LPWSTR dupStr;
+ size_t strSize;
+
+ if (!str) return NULL;
+
+ strSize = min(wcslen(str), numOfChars);
+
+ dupStr = (LPWSTR)MemAlloc(0, (strSize + 1) * sizeof(WCHAR));
+ if (!dupStr) return NULL;
+
+ StringCchCopyNW(dupStr, strSize + 1, str, strSize);
+ dupStr[strSize] = L'\0';
return dupStr;
}
Modified: trunk/reactos/base/applications/msconfig_new/utils.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/msconfig…
==============================================================================
--- trunk/reactos/base/applications/msconfig_new/utils.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/msconfig_new/utils.c [iso-8859-1] Wed Oct 21 23:36:17
2015
@@ -41,42 +41,40 @@
FormatDateTime(IN LPSYSTEMTIME pDateTime)
{
LPWSTR lpszDateTime = NULL;
-
- if (pDateTime)
- {
- int iDateBufSize = 0, iTimeBufSize = 0;
-
- 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) )
- {
- 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);
- }
+ int iDateBufSize, iTimeBufSize;
+
+ 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) )
+ {
+ 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;