diff --git a/modules/tcc/Common.cpp b/modules/tcc/Common.cpp index bc4f1418..5d77f720 100644 --- a/modules/tcc/Common.cpp +++ b/modules/tcc/Common.cpp @@ -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)) { /* ... */ } diff --git a/modules/tcc/Common.hpp b/modules/tcc/Common.hpp index 75ac8282..bb71da93 100644 --- a/modules/tcc/Common.hpp +++ b/modules/tcc/Common.hpp @@ -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. }; /* ------------------------------------------------------------------------------------------------ diff --git a/modules/tcc/Module.cpp b/modules/tcc/Module.cpp index 915c5e02..503b3c0b 100644 --- a/modules/tcc/Module.cpp +++ b/modules/tcc/Module.cpp @@ -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