mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Implemented a minimal version of ToStringF with a static buffer.
This commit is contained in:
parent
68ac878fe9
commit
73b93d707c
@ -332,6 +332,27 @@ void DbgFtl(const char * type, const char * func, const char * fmt, ...)
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const SQChar * ToStrF(const char * fmt, ...)
|
||||
{
|
||||
static char buf[128];
|
||||
// Variable arguments structure
|
||||
va_list args;
|
||||
// Get the specified arguments
|
||||
va_start (args, fmt);
|
||||
// Run the specified format
|
||||
int ret = std::vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
// Check for formatting errors
|
||||
if (ret < 0)
|
||||
{
|
||||
LogErr("Failed to run the specified string format");
|
||||
// Return an empty string
|
||||
buf[0] = 0;
|
||||
}
|
||||
// Return the buffer
|
||||
return buf;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const SQChar * ToStringF(const char * fmt, ...)
|
||||
{
|
||||
|
@ -109,6 +109,11 @@ void DbgWrn(const char * type, const char * func, const char * fmt, ...);
|
||||
void DbgErr(const char * type, const char * func, const char * fmt, ...);
|
||||
void DbgFtl(const char * type, const char * func, const char * fmt, ...);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
const SQChar * ToStrF(const char * fmt, ...);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* ...
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user