diff options
author | 2011-12-19 09:48:37 -0500 | |
---|---|---|
committer | 2011-12-19 09:48:37 -0500 | |
commit | 742b89b1895a091385dc47d410687bbb70f76dbd (patch) | |
tree | 9fb1f5f8c9253127ae105615e7cd5c121c1ab020 /core/compat.lua | |
parent | 440359f59f990ba2be471381ea8accf0c1359b1b (diff) | |
download | textadept-742b89b1895a091385dc47d410687bbb70f76dbd.tar.gz textadept-742b89b1895a091385dc47d410687bbb70f76dbd.zip |
Added more LuaJIT compatibility functions; core/compat.lua
Diffstat (limited to 'core/compat.lua')
-rw-r--r-- | core/compat.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/compat.lua b/core/compat.lua index 1bbf4a3b..953e06b4 100644 --- a/core/compat.lua +++ b/core/compat.lua @@ -17,3 +17,23 @@ function load(ld, source, mode, env) if f and env then return setfenv(f, env) end return f, err end + +-- In Lua 5.1, `loadfile` did not take mode and environment parameters. +local loadfile51 = loadfile +function loadfile(filename, mode, env) + local f, err = loadfile51(filename) + if f and env then return setfenv(f, env) end + return f, err +end + +-- TODO: string.rep +-- In Lua 5.1, `string.rep` did not take separation string parameter. + +-- 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 +function os.execute(command) + if not command then return os_execute51() ~= 0 end + local code = os_execute51(command) + return code == 0, 'exit', code +end |