Simplify the common combination of sprintf() and OutputDebugString() (PR #1031)

- Update LogOutput() and LogFileOutput().
- Add StrFormat() to produce std::string out of snprintf() & add StrFormat.cpp to projects.
- Add PTRDIFF_T_FMT in parallel to SIZE_T_FMT to StdAfx.h, for completeness.
- In Log.cpp, changed to get timestamp using posix functions.
- Removed TCHAR usage throughout - simply use char.
This commit is contained in:
Kelvin Lee
2022-02-14 08:37:05 +11:00
committed by GitHub
parent 83e56924f7
commit 9a3832084a
22 changed files with 222 additions and 133 deletions
+7 -8
View File
@@ -183,9 +183,9 @@ bool DebuggerSetColor( const int iScheme, const int iColor, const COLORREF nColo
//===========================================================================
static void _SetupColorRamp(const int iPrimary, int & iColor_)
{
TCHAR sRamp[CONSOLE_WIDTH * 2] = TEXT("");
std::string strRamp;
#if DEBUG_COLOR_RAMP
TCHAR sText[CONSOLE_WIDTH];
char sText[CONSOLE_WIDTH];
#endif
bool bR = (iPrimary & 1) ? true : false;
@@ -202,16 +202,15 @@ static void _SetupColorRamp(const int iPrimary, int & iColor_)
DWORD nColor = RGB(nR, nG, nB);
g_aColorPalette[iColor_] = nColor;
#if DEBUG_COLOR_RAMP
wsprintf(sText, TEXT("RGB(%3d,%3d,%3d), "), nR, nG, nB);
strcat(sRamp, sText);
int len = snprintf_s(sText, _TRUNCATE, "RGB(%3d,%3d,%3d), ", nR, nG, nB);
strRamp.append(sText, len);
#endif
iColor_++;
}
#if DEBUG_COLOR_RAMP
wsprintf(sText, TEXT(" // %d%d%d\n"), bB, bG, bR);
strcat(sRamp, sText);
OutputDebugString(sRamp);
sRamp[0] = 0;
int len = snprintf_s(sText, _TRUNCATE, " // %d%d%d\n", bB, bG, bR);
strRamp.append(sText, len);
OutputDebugStringA(strRamp.c_str());
#endif
}
#endif // _DEBUG