From 1e94a7feaff940494a474ee549d4f2dc61f6a869 Mon Sep 17 00:00:00 2001 From: red-001 Date: Sun, 21 Jan 2018 12:28:47 +0000 Subject: [PATCH] Move `setlocale` from Lua to C++. --- builtin/init.lua | 2 -- src/script/cpp_api/s_base.cpp | 3 +++ src/script/cpp_api/s_security.cpp | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/init.lua b/builtin/init.lua index e94f3213a..f76174be7 100644 --- a/builtin/init.lua +++ b/builtin/init.lua @@ -21,7 +21,6 @@ if core.print then core.print = nil -- don't pollute our namespace end math.randomseed(os.time()) -os.setlocale("C", "numeric") minetest = core -- Load other files @@ -47,7 +46,6 @@ elseif INIT == "mainmenu" then elseif INIT == "async" then dofile(asyncpath .. "init.lua") elseif INIT == "client" then - os.setlocale = nil dofile(clientpath .. "init.lua") else error(("Unrecognized builtin initialization type %s!"):format(tostring(INIT))) diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp index 59107b3ff..f451156bd 100644 --- a/src/script/cpp_api/s_base.cpp +++ b/src/script/cpp_api/s_base.cpp @@ -118,6 +118,9 @@ ScriptApiBase::ScriptApiBase(ScriptingType type): lua_pushstring(m_luastack, porting::getPlatformName()); lua_setglobal(m_luastack, "PLATFORM"); + + // Make sure Lua uses the right locale + setlocale(LC_NUMERIC, "C"); } ScriptApiBase::~ScriptApiBase() diff --git a/src/script/cpp_api/s_security.cpp b/src/script/cpp_api/s_security.cpp index 690a3b47f..6c50218d3 100644 --- a/src/script/cpp_api/s_security.cpp +++ b/src/script/cpp_api/s_security.cpp @@ -261,8 +261,7 @@ void ScriptApiSecurity::initializeSecurityClient() "clock", "date", "difftime", - "time", - "setlocale", + "time" }; static const char *debug_whitelist[] = { "getinfo", -- 2.25.1