1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Minor fixes in the TCC module.

This commit is contained in:
Sandu Liviu Catalin 2016-04-02 13:12:52 +03:00
parent a947a68256
commit 04c14f2c6a
3 changed files with 23 additions and 9 deletions

View File

@ -40,9 +40,9 @@ void SqThrowF(CSStr str, ...)
va_list args;
va_start (args, str);
// Write the requested contents
if (vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
{
strcpy(g_Buffer, "Unknown error has occurred");
std::strcpy(g_Buffer, "Unknown error has occurred");
}
// Release the argument list
va_end(args);
@ -57,17 +57,26 @@ CSStr FmtStr(CSStr str, ...)
va_list args;
va_start (args, str);
// Write the requested contents
if (snprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
g_Buffer[0] = 0; /* make sure the string is terminated */
if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
{
g_Buffer[0] = 0; // Make sure the string is terminated
}
// Release the argument list
va_end(args);
// Return the data from the buffer
return g_Buffer;
}
// ------------------------------------------------------------------------------------------------
StackGuard::StackGuard()
: m_VM(_SqVM), m_Top(sq_gettop(m_VM))
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
StackGuard::StackGuard(HSQUIRRELVM vm)
: m_Top(sq_gettop(vm)), m_VM(vm)
: m_VM(vm), m_Top(sq_gettop(vm))
{
/* ... */
}

View File

@ -66,6 +66,11 @@ CSStr FmtStr(CSStr str, ...);
*/
struct StackGuard
{
/* --------------------------------------------------------------------------------------------
* Default constructor.
*/
StackGuard();
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
@ -101,8 +106,8 @@ private:
private:
// --------------------------------------------------------------------------------------------
Int32 m_Top; /* The top of the stack when this instance was created. */
HSQUIRRELVM m_VM; /* The VM where the stack should be restored. */
HSQUIRRELVM m_VM; // The VM where the stack should be restored.
Int32 m_Top; // The top of the stack when this instance was created.
};
/* ------------------------------------------------------------------------------------------------

View File

@ -107,7 +107,7 @@ void OnSquirrelTerminate()
bool CheckAPIVer(CCStr ver)
{
// Obtain the numeric representation of the API version
long vernum = strtol(ver, nullptr, 10);
long vernum = std::strtol(ver, nullptr, 10);
// Check against version mismatch
if (vernum == SQMOD_API_VER)
{
@ -492,7 +492,7 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs* functions, PluginCallb
_Info = info;
// Assign plugin information
_Info->uPluginVer = SQTCC_VERSION;
strcpy(_Info->szName, SQTCC_HOST_NAME);
std::strcpy(_Info->szName, SQTCC_HOST_NAME);
// Bind callbacks
BindCallbacks();
// Notify that the plugin was successfully loaded