]> git.lizzy.rs Git - minetest.git/commitdiff
Move `setlocale` from Lua to C++.
authorred-001 <red-001@outlook.ie>
Sun, 21 Jan 2018 12:28:47 +0000 (12:28 +0000)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:32:00 +0000 (17:32 +0200)
builtin/init.lua
src/script/cpp_api/s_base.cpp
src/script/cpp_api/s_security.cpp

index 356e119fba6a3b2c85751f005b08b125b1a0d920..73ab5cfd027ff07013cd6d7ce03739394872eefd 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 2537d895f1cce4190a05e2971dca3ba9916a0150..c75b1c2f83156430f864436f0c895eac55ac29c6 100644 (file)
@@ -119,6 +119,9 @@ ScriptApiBase::ScriptApiBase() :
 
        m_environment = NULL;
        m_guiengine = NULL;
+
+       // Make sure Lua uses the right locale
+       setlocale(LC_NUMERIC, "C");
 }
 
 ScriptApiBase::~ScriptApiBase()
index 5ad7947d5f6791bce4d8475a2887fd693623a765..66a761f4c4ee3f6ffd704cfe4ec08ecf69bd98a9 100644 (file)
@@ -249,9 +249,8 @@ void ScriptApiSecurity::initializeSecurityClient()
        static const char *os_whitelist[] = {
                "clock",
                "date",
-               "difftime",     
-               "time",
-               "setlocale",
+               "difftime",
+               "time"
        };
        static const char *debug_whitelist[] = {
                "getinfo",