Debian Codegraph @

3rdparty/toluapp/src/bin/lua/compat-5.1.lua

raw
1 if string.find(_VERSION, "5%.0") then
2 return
3 end
4
5 -- "loadfile"
6 local function pp_dofile(path)
7
8 local loaded = false
9 local getfile = function()
10
11 if loaded then
12 return
13 else
14 local file,err = io.open(path)
15 if not file then
16 error("error loading file "..path..": "..err)
17 end
18 local ret = file:read("*a")
19 file:close()
20
21 ret = string.gsub(ret, "%.%.%.%s*%)", "...) local arg = {n=select('#', ...), ...};")
22
23 loaded = true
24 return ret
25 end
26 end
27
28 local f = load(getfile, path)
29 if not f then
30
31 error("error loading file "..path ..": " .. errmsg)
32 end
33 return f()
34 end
35
36 old_dofile = dofile
37 dofile = pp_dofile
38
39
40 -- string.gsub
41 --[[
42 local ogsub = string.gsub
43 local function compgsub(a,b,c,d)
44 if type(c) == "function" then
45 local oc = c
46 c = function (...) return oc(...) or '' end
47 end
48 return ogsub(a,b,c,d)
49 end
50 string.repl = ogsub
51 --]]
52
53 --string.gsub = compgsub
54
55
56
57