Skip to content

Commit

Permalink
Move setlocale from Lua to C++.
Browse files Browse the repository at this point in the history
  • Loading branch information
red-001 authored and sfan5 committed Feb 8, 2018
1 parent 0e4c467 commit 1e94a7f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 0 additions & 2 deletions builtin/init.lua
Expand Up @@ -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
Expand All @@ -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)))
Expand Down
3 changes: 3 additions & 0 deletions src/script/cpp_api/s_base.cpp
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions src/script/cpp_api/s_security.cpp
Expand Up @@ -261,8 +261,7 @@ void ScriptApiSecurity::initializeSecurityClient()
"clock",
"date",
"difftime",
"time",
"setlocale",
"time"
};
static const char *debug_whitelist[] = {
"getinfo",
Expand Down

0 comments on commit 1e94a7f

Please sign in to comment.