Move `setlocale` from Lua to C++.
authorred-001 <red-001@outlook.ie>
Sun, 21 Jan 2018 12:28:47 +0000 (12:28 +0000)
committersfan5 <sfan5@live.de>
Thu, 8 Feb 2018 14:38:34 +0000 (15:38 +0100)
builtin/init.lua
src/script/cpp_api/s_base.cpp
src/script/cpp_api/s_security.cpp

index e94f3213a41fe679dc50c8a3deaa9482d1349106..f76174be7d5c727fe85b5b20a9a83a584e39646d 100644 (file)
@@ -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)))
index 59107b3ff7d23cbf42dd03ee0246b8839e658921..f451156bdac1e1aaafef11dcdda2d0b785c5a1fd 100644 (file)
@@ -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()
index 690a3b47fa7da9a35dafca3557090f366b7e85ae..6c50218d31ef71d3113e7ec80c3a505714f5dbc9 100644 (file)
@@ -261,8 +261,7 @@ void ScriptApiSecurity::initializeSecurityClient()
                "clock",
                "date",
                "difftime",
-               "time",
-               "setlocale",
+               "time"
        };
        static const char *debug_whitelist[] = {
                "getinfo",