Codechange: replace printf with PRINTF macros by fmt::format for scripts
This commit is contained in:
7
src/3rdparty/squirrel/squirrel/sqdebug.cpp
vendored
7
src/3rdparty/squirrel/squirrel/sqdebug.cpp
vendored
@@ -76,15 +76,12 @@ void SQVM::Raise_Error(SQObjectPtr &desc)
|
||||
|
||||
SQString *SQVM::PrintObjVal(const SQObject &o)
|
||||
{
|
||||
char buf[NUMBER_MAX_CHAR+1];
|
||||
switch(type(o)) {
|
||||
case OT_STRING: return _string(o);
|
||||
case OT_INTEGER:
|
||||
seprintf(buf, lastof(buf), OTTD_PRINTF64, _integer(o));
|
||||
return SQString::Create(_ss(this), buf);
|
||||
return SQString::Create(_ss(this), fmt::format("{}", _integer(o)).c_str());
|
||||
case OT_FLOAT:
|
||||
seprintf(buf, lastof(buf), "%.14g", _float(o));
|
||||
return SQString::Create(_ss(this), buf);
|
||||
return SQString::Create(_ss(this), fmt::format("{:.14g}", _float(o)).c_str());
|
||||
default:
|
||||
return SQString::Create(_ss(this), GetTypeName(o));
|
||||
}
|
||||
|
11
src/3rdparty/squirrel/squirrel/sqfuncstate.cpp
vendored
11
src/3rdparty/squirrel/squirrel/sqfuncstate.cpp
vendored
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#include "../../../stdafx.h"
|
||||
#include "../../fmt/format.h"
|
||||
|
||||
#include "sqpcheader.h"
|
||||
#include "sqcompiler.h"
|
||||
@@ -83,11 +84,11 @@ SQInstructionDesc g_InstrDesc[]={
|
||||
void DumpLiteral(SQObjectPtr &o)
|
||||
{
|
||||
switch(type(o)){
|
||||
case OT_STRING: printf("\"%s\"",_stringval(o));break;
|
||||
case OT_FLOAT: printf("{%f}",_float(o));break;
|
||||
case OT_INTEGER: printf("{" OTTD_PRINTF64 "}",_integer(o));break;
|
||||
case OT_BOOL: printf("%s",_integer(o)?"true":"false");break;
|
||||
default: printf("(%s %p)",GetTypeName(o),(void*)_rawval(o));break; break; //shut up compiler
|
||||
case OT_STRING: fmt::print("\"{}\"",_stringval(o));break;
|
||||
case OT_FLOAT: fmt::print("{{{}}}",_float(o));break;
|
||||
case OT_INTEGER: fmt::print("{{{}}}",_integer(o));break;
|
||||
case OT_BOOL: fmt::print(_integer(o)?"true":"false");break;
|
||||
default: fmt::print("({} {})",GetTypeName(o),(size_t)(void*)_rawval(o));break; break; //shut up compiler
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
12
src/3rdparty/squirrel/squirrel/sqvm.cpp
vendored
12
src/3rdparty/squirrel/squirrel/sqvm.cpp
vendored
@@ -262,19 +262,19 @@ bool SQVM::CMP_OP(CmpOP op, const SQObjectPtr &o1,const SQObjectPtr &o2,SQObject
|
||||
|
||||
void SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
|
||||
{
|
||||
char buf[64];
|
||||
std::string str;
|
||||
switch(type(o)) {
|
||||
case OT_STRING:
|
||||
res = o;
|
||||
return;
|
||||
case OT_FLOAT:
|
||||
seprintf(buf, lastof(buf),"%g",_float(o));
|
||||
str = fmt::format("{}",_float(o));
|
||||
break;
|
||||
case OT_INTEGER:
|
||||
seprintf(buf, lastof(buf),OTTD_PRINTF64,_integer(o));
|
||||
str = fmt::format("{}",_integer(o));
|
||||
break;
|
||||
case OT_BOOL:
|
||||
seprintf(buf, lastof(buf),_integer(o)?"true":"false");
|
||||
str = _integer(o)?"true":"false";
|
||||
break;
|
||||
case OT_TABLE:
|
||||
case OT_USERDATA:
|
||||
@@ -289,9 +289,9 @@ void SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
|
||||
}
|
||||
FALLTHROUGH;
|
||||
default:
|
||||
seprintf(buf, lastof(buf),"(%s : 0x%p)",GetTypeName(o),(void*)_rawval(o));
|
||||
str = fmt::format("({} : 0x{:08X})",GetTypeName(o),(size_t)(void*)_rawval(o));
|
||||
}
|
||||
res = SQString::Create(_ss(this),buf);
|
||||
res = SQString::Create(_ss(this),str.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user