aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/compat.lua29
1 files changed, 22 insertions, 7 deletions
diff --git a/core/compat.lua b/core/compat.lua
index 953e06b4..c5248204 100644
--- a/core/compat.lua
+++ b/core/compat.lua
@@ -3,13 +3,6 @@
-- When using LuaJIT try to retain backwards compatibility (Lua 5.1).
-- LuaJIT is compiled with LUAJIT_ENABLE_LUA52COMPAT for some Lua 5.2 features.
--- In Lua 5.1, `xpcall` did not accept function arguments.
-local xpcall51 = xpcall
-function xpcall(f, error, ...)
- local args = {...}
- return xpcall51(function() return f(unpack(args)) end, error)
-end
-
-- In Lua 5.1, `load` did not take mode and environment parameters.
local load51 = load
function load(ld, source, mode, env)
@@ -26,9 +19,31 @@ function loadfile(filename, mode, env)
return f, err
end
+-- In Lua 5.1, `xpcall` did not accept function arguments.
+local xpcall51 = xpcall
+function xpcall(f, error, ...)
+ local args = {...}
+ return xpcall51(function() return f(unpack(args)) end, error)
+end
+
+-- In Lua 5.1, `module` exists.
+module = nil
+
+-- In Lua 5.1, `package.loaders` is `package.searchers`
+package.searchers = package.loaders
+
+-- TODO: table.pack
+-- In Lua 5.1, `table.pack` did not exist.
+
-- TODO: string.rep
-- In Lua 5.1, `string.rep` did not take separation string parameter.
+-- TODO: math.log, math.log10
+-- In Lua 5.1, `math.log` does not take base parameter and `math.log10` existed.
+
+-- In LuaJIT, `bit` is used instead of `bit32`
+bit32 = bit
+
-- In Lua 5.1, `os.execute` returned an integer depending on shell availability.
-- It also returned just a status code.
local os_execute51 = os.execute