mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-30 05:43:12 +01:00
[8388] Replaced UTF8PRINT macro by a function
Should also fix possible color leak on Windows CLI.
Signed-off-by: freghar <compmancz@gmail.com>
--HG--
branch : trunk
This commit is contained in:
@@ -388,7 +388,7 @@ void Log::outString( const char * str, ... )
|
||||
if(m_colored)
|
||||
SetColor(true,m_colors[LOGL_NORMAL]);
|
||||
|
||||
UTF8PRINTF(stdout,str,);
|
||||
utf8printf(stdout, str);
|
||||
|
||||
if(m_colored)
|
||||
ResetColor(true);
|
||||
@@ -438,7 +438,7 @@ void Log::outCrash( const char * err, ... )
|
||||
if(m_colored)
|
||||
SetColor(false,RED);
|
||||
|
||||
UTF8PRINTF(stderr,err,);
|
||||
utf8printf(stdout, err);
|
||||
|
||||
if(m_colored)
|
||||
ResetColor(false);
|
||||
@@ -478,7 +478,7 @@ void Log::outError( const char * err, ... )
|
||||
if(m_colored)
|
||||
SetColor(false,RED);
|
||||
|
||||
UTF8PRINTF(stderr,err,);
|
||||
utf8printf(stderr, err);
|
||||
|
||||
if(m_colored)
|
||||
ResetColor(false);
|
||||
@@ -526,7 +526,7 @@ void Log::outErrorDb( const char * err, ... )
|
||||
if(m_colored)
|
||||
SetColor(false,RED);
|
||||
|
||||
UTF8PRINTF(stderr,err,);
|
||||
utf8printf(stderr, err);
|
||||
|
||||
if(m_colored)
|
||||
ResetColor(false);
|
||||
@@ -581,7 +581,7 @@ void Log::outBasic( const char * str, ... )
|
||||
if(m_colored)
|
||||
SetColor(true,m_colors[LOGL_BASIC]);
|
||||
|
||||
UTF8PRINTF(stdout,str,);
|
||||
utf8printf(stdout, str);
|
||||
|
||||
if(m_colored)
|
||||
ResetColor(true);
|
||||
@@ -622,7 +622,7 @@ void Log::outDetail( const char * str, ... )
|
||||
if(m_colored)
|
||||
SetColor(true,m_colors[LOGL_DETAIL]);
|
||||
|
||||
UTF8PRINTF(stdout,str,);
|
||||
utf8printf(stdout, str);
|
||||
|
||||
if(m_colored)
|
||||
ResetColor(true);
|
||||
@@ -650,7 +650,7 @@ void Log::outDebugInLine( const char * str, ... )
|
||||
|
||||
if( m_logLevel > LOGL_DETAIL )
|
||||
{
|
||||
UTF8PRINTF(stdout,str,);
|
||||
utf8printf(stdout, str);
|
||||
}
|
||||
if(logfile && m_logFileLevel > LOGL_DETAIL)
|
||||
{
|
||||
@@ -681,7 +681,7 @@ void Log::outDebug( const char * str, ... )
|
||||
if(m_colored)
|
||||
SetColor(true,m_colors[LOGL_DEBUG]);
|
||||
|
||||
UTF8PRINTF(stdout,str,);
|
||||
utf8printf(stdout, str);
|
||||
|
||||
if(m_colored)
|
||||
ResetColor(true);
|
||||
@@ -707,7 +707,7 @@ void Log::outStringInLine( const char * str, ... )
|
||||
if( !str )
|
||||
return;
|
||||
|
||||
UTF8PRINTF(stdout,str,);
|
||||
utf8printf(stdout, str);
|
||||
|
||||
if(logfile)
|
||||
{
|
||||
@@ -739,7 +739,7 @@ void Log::outCommand( uint32 account, const char * str, ... )
|
||||
if(m_colored)
|
||||
SetColor(true,m_colors[LOGL_BASIC]);
|
||||
|
||||
UTF8PRINTF(stdout,str,);
|
||||
utf8printf(stdout, str);
|
||||
|
||||
if(m_colored)
|
||||
ResetColor(true);
|
||||
|
||||
@@ -478,3 +478,28 @@ bool Utf8FitTo(const std::string& str, std::wstring search)
|
||||
return true;
|
||||
}
|
||||
|
||||
void utf8printf(FILE *out, const char *str, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
char temp_buf[32*1024];
|
||||
wchar_t wtemp_buf[32*1024];
|
||||
size_t temp_len;
|
||||
size_t wtemp_len;
|
||||
|
||||
va_start(ap, str);
|
||||
temp_len = vsnprintf(temp_buf, 32*1024, str, ap);
|
||||
va_end(ap);
|
||||
|
||||
wtemp_len = 32*1024-1;
|
||||
Utf8toWStr(temp_buf, temp_len, wtemp_buf, wtemp_len);
|
||||
|
||||
CharToOemBuffW(&wtemp_buf[0], &temp_buf[0], wtemp_len+1);
|
||||
fprintf(out, temp_buf);
|
||||
#else
|
||||
va_start(ap, str);
|
||||
vfprintf(out, str, ap);
|
||||
va_end(ap);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -285,32 +285,7 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension);
|
||||
bool utf8ToConsole(const std::string& utf8str, std::string& conStr);
|
||||
bool consoleToUtf8(const std::string& conStr,std::string& utf8str);
|
||||
bool Utf8FitTo(const std::string& str, std::wstring search);
|
||||
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
#define UTF8PRINTF(OUT,FRM,RESERR) \
|
||||
{ \
|
||||
char temp_buf[32*1024]; \
|
||||
va_list ap; \
|
||||
va_start(ap, FRM); \
|
||||
size_t temp_len = vsnprintf(temp_buf,32*1024,FRM,ap); \
|
||||
va_end(ap); \
|
||||
\
|
||||
wchar_t wtemp_buf[32*1024]; \
|
||||
size_t wtemp_len = 32*1024-1; \
|
||||
if(!Utf8toWStr(temp_buf,temp_len,wtemp_buf,wtemp_len)) \
|
||||
return RESERR; \
|
||||
CharToOemBuffW(&wtemp_buf[0],&temp_buf[0],wtemp_len+1);\
|
||||
fprintf(OUT,temp_buf); \
|
||||
}
|
||||
#else
|
||||
#define UTF8PRINTF(OUT,FRM,RESERR) \
|
||||
{ \
|
||||
va_list ap; \
|
||||
va_start(ap, FRM); \
|
||||
vfprintf(OUT, FRM, ap ); \
|
||||
va_end(ap); \
|
||||
}
|
||||
#endif
|
||||
void utf8printf(FILE *out, const char *str, ...);
|
||||
|
||||
bool IsIPAddress(char const* ipaddress);
|
||||
uint32 CreatePIDFile(const std::string& filename);
|
||||
|
||||
Reference in New Issue
Block a user