mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 13:37:00 +00:00
[8388] Replaced UTF8PRINT macro by a function
Should also fix possible color leak on Windows CLI. Signed-off-by: freghar <compmancz@gmail.com>
This commit is contained in:
parent
65e723ba9e
commit
17b94e1e09
4 changed files with 37 additions and 36 deletions
|
|
@ -369,7 +369,7 @@ void Log::outString( const char * str, ... )
|
||||||
if(m_includeTime)
|
if(m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
UTF8PRINTF(stdout,str,);
|
utf8printf(stdout, str);
|
||||||
|
|
||||||
if(m_colored)
|
if(m_colored)
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
|
|
@ -401,7 +401,7 @@ void Log::outError( const char * err, ... )
|
||||||
if(m_includeTime)
|
if(m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
UTF8PRINTF(stderr,err,);
|
utf8printf(stderr, err);
|
||||||
|
|
||||||
if(m_colored)
|
if(m_colored)
|
||||||
ResetColor(false);
|
ResetColor(false);
|
||||||
|
|
@ -434,7 +434,7 @@ void Log::outErrorDb( const char * err, ... )
|
||||||
if(m_includeTime)
|
if(m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
UTF8PRINTF(stderr,err,);
|
utf8printf(stderr, err);
|
||||||
|
|
||||||
if(m_colored)
|
if(m_colored)
|
||||||
ResetColor(false);
|
ResetColor(false);
|
||||||
|
|
@ -483,7 +483,7 @@ void Log::outBasic( const char * str, ... )
|
||||||
if(m_includeTime)
|
if(m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
UTF8PRINTF(stdout,str,);
|
utf8printf(stdout, str);
|
||||||
|
|
||||||
if(m_colored)
|
if(m_colored)
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
|
|
@ -518,7 +518,7 @@ void Log::outDetail( const char * str, ... )
|
||||||
if(m_includeTime)
|
if(m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
UTF8PRINTF(stdout,str,);
|
utf8printf(stdout, str);
|
||||||
|
|
||||||
if(m_colored)
|
if(m_colored)
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
|
|
@ -548,7 +548,7 @@ void Log::outDebugInLine( const char * str, ... )
|
||||||
if(m_colored)
|
if(m_colored)
|
||||||
SetColor(true,m_colors[LogDebug]);
|
SetColor(true,m_colors[LogDebug]);
|
||||||
|
|
||||||
UTF8PRINTF(stdout,str,);
|
utf8printf(stdout, str);
|
||||||
|
|
||||||
if(m_colored)
|
if(m_colored)
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
|
|
@ -574,7 +574,7 @@ void Log::outDebug( const char * str, ... )
|
||||||
if(m_includeTime)
|
if(m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
UTF8PRINTF(stdout,str,);
|
utf8printf(stdout, str);
|
||||||
|
|
||||||
if(m_colored)
|
if(m_colored)
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
|
|
@ -609,7 +609,7 @@ void Log::outCommand( uint32 account, const char * str, ... )
|
||||||
if(m_includeTime)
|
if(m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
UTF8PRINTF(stdout,str,);
|
utf8printf(stdout, str);
|
||||||
|
|
||||||
if(m_colored)
|
if(m_colored)
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
|
|
@ -691,7 +691,7 @@ void Log::outMenu( const char * str, ... )
|
||||||
if(m_includeTime)
|
if(m_includeTime)
|
||||||
outTime();
|
outTime();
|
||||||
|
|
||||||
UTF8PRINTF(stdout,str,);
|
utf8printf(stdout, str);
|
||||||
|
|
||||||
ResetColor(true);
|
ResetColor(true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -419,3 +419,29 @@ bool Utf8FitTo(const std::string& str, std::wstring search)
|
||||||
|
|
||||||
return true;
|
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
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -283,32 +283,7 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension);
|
||||||
bool utf8ToConsole(const std::string& utf8str, std::string& conStr);
|
bool utf8ToConsole(const std::string& utf8str, std::string& conStr);
|
||||||
bool consoleToUtf8(const std::string& conStr,std::string& utf8str);
|
bool consoleToUtf8(const std::string& conStr,std::string& utf8str);
|
||||||
bool Utf8FitTo(const std::string& str, std::wstring search);
|
bool Utf8FitTo(const std::string& str, std::wstring search);
|
||||||
|
void utf8printf(FILE *out, const char *str, ...);
|
||||||
#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
|
|
||||||
|
|
||||||
bool IsIPAddress(char const* ipaddress);
|
bool IsIPAddress(char const* ipaddress);
|
||||||
uint32 CreatePIDFile(const std::string& filename);
|
uint32 CreatePIDFile(const std::string& filename);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "8387"
|
#define REVISION_NR "8388"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue