summaryrefslogtreecommitdiff
path: root/ThirdParty/toluapp/src/bin/lua/compat-5.1.lua
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-11-08 01:17:11 +0800
committerchai <chaifix@163.com>2021-11-08 01:17:11 +0800
commitefce5b6bd5c9d4f8214a71e0f7a7c35751710a4c (patch)
tree0789475ded5c377667165a3ddb047ca6703bcf33 /ThirdParty/toluapp/src/bin/lua/compat-5.1.lua
parented78df90944bbe6b7de7308bda2bf3a7f1bc3de6 (diff)
+ tolua
+ lpeg
Diffstat (limited to 'ThirdParty/toluapp/src/bin/lua/compat-5.1.lua')
-rw-r--r--ThirdParty/toluapp/src/bin/lua/compat-5.1.lua57
1 files changed, 57 insertions, 0 deletions
diff --git a/ThirdParty/toluapp/src/bin/lua/compat-5.1.lua b/ThirdParty/toluapp/src/bin/lua/compat-5.1.lua
new file mode 100644
index 0000000..7a2c60b
--- /dev/null
+++ b/ThirdParty/toluapp/src/bin/lua/compat-5.1.lua
@@ -0,0 +1,57 @@
+if string.find(_VERSION, "5%.0") then
+ return
+end
+
+-- "loadfile"
+local function pp_dofile(path)
+
+ local loaded = false
+ local getfile = function()
+
+ if loaded then
+ return
+ else
+ local file,err = io.open(path)
+ if not file then
+ error("error loading file "..path..": "..err)
+ end
+ local ret = file:read("*a")
+ file:close()
+
+ ret = string.gsub(ret, "%.%.%.%s*%)", "...) local arg = {n=select('#', ...), ...};")
+
+ loaded = true
+ return ret
+ end
+ end
+
+ local f = load(getfile, path)
+ if not f then
+
+ error("error loading file "..path)
+ end
+ return f()
+end
+
+old_dofile = dofile
+dofile = pp_dofile
+
+
+-- string.gsub
+--[[
+local ogsub = string.gsub
+local function compgsub(a,b,c,d)
+ if type(c) == "function" then
+ local oc = c
+ c = function (...) return oc(...) or '' end
+ end
+ return ogsub(a,b,c,d)
+end
+string.repl = ogsub
+--]]
+
+--string.gsub = compgsub
+
+
+
+