From 9537cfd3f8264700619f58d15741829489e1099e Mon Sep 17 00:00:00 2001 From: nOOb3167 Date: Sun, 22 Jul 2018 21:56:06 +0200 Subject: Add a MSVC / Windows compatible snprintf function (#7353) Use sizeof where applicable for mt_snprintf --- src/script/common/c_internal.cpp | 3 ++- src/script/cpp_api/s_base.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/script') diff --git a/src/script/common/c_internal.cpp b/src/script/common/c_internal.cpp index 9a24b0e78..be9691ef4 100644 --- a/src/script/common/c_internal.cpp +++ b/src/script/common/c_internal.cpp @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common/c_internal.h" #include "debug.h" #include "log.h" +#include "porting.h" #include "settings.h" std::string script_get_backtrace(lua_State *L) @@ -82,7 +83,7 @@ void script_error(lua_State *L, int pcall_result, const char *mod, const char *f err_descr = ""; char buf[256]; - snprintf(buf, sizeof(buf), "%s error from mod '%s' in callback %s(): ", + porting::mt_snprintf(buf, sizeof(buf), "%s error from mod '%s' in callback %s(): ", err_type, mod, fxn); std::string err_msg(buf); diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp index 293c774b0..d98359d20 100644 --- a/src/script/cpp_api/s_base.cpp +++ b/src/script/cpp_api/s_base.cpp @@ -293,7 +293,7 @@ void ScriptApiBase::stackDump(std::ostream &o) break; case LUA_TNUMBER: /* numbers */ { char buf[10]; - snprintf(buf, 10, "%lf", lua_tonumber(m_luastack, i)); + porting::mt_snprintf(buf, sizeof(buf), "%lf", lua_tonumber(m_luastack, i)); o << buf; break; } -- cgit v1.2.3