7 lines
3.8 KiB
Lua
7 lines
3.8 KiB
Lua
-- Penlight 1.11.0-1 | /lua/pl/compat.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
|
|
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
|
|
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
local a={}a.lua51=_VERSION=='Lua 5.1'a.jit=tostring(assert):match('builtin')~=nil;if a.jit then a.jit52=not loadstring("local goto = 1")end;a.dir_separator=_G.package.config:sub(1,1)a.is_windows=a.dir_separator=='\\'function a.execute(b)local c,d,e=os.execute(b)if d=="No error"and e==0 and a.is_windows then e=-1 end;if a.lua51 and not a.jit52 then if a.is_windows then return c==0,c else c=c>255 and c/256 or c;return c==0,c end else if a.is_windows then return e==0,e else return not not c,e end end end;if a.lua51 then if not a.jit then local f=load;function a.load(g,h,i,j)local k,l;if type(g)=='string'then if g:byte(1)==27 and not(i or'bt'):find'b'then return nil,"attempt to load a binary chunk"end;k,l=loadstring(g,h)else k,l=f(g,h)end;if k and j then setfenv(k,j)end;return k,l end else a.load=load end;a.setfenv,a.getfenv=setfenv,getfenv else a.load=load;function a.setfenv(m,n)m=type(m)=='function'and m or debug.getinfo(m+1,'f').func;local o;local p=0;repeat p=p+1;o=debug.getupvalue(m,p)until o=='_ENV'or o==nil;if o then debug.upvaluejoin(m,p,function()return o end,1)debug.setupvalue(m,p,n)end;if m~=0 then return m end end;function a.getfenv(m)local m=m or 0;m=type(m)=='function'and m or debug.getinfo(m+1,'f').func;local o,q;local p=0;repeat p=p+1;o,q=debug.getupvalue(m,p)until o=='_ENV'or o==nil;return q end end;if not table.pack then function table.pack(...)return{n=select('#',...),...}end end;if not table.unpack then table.unpack=unpack end;if not package.searchpath then function package.searchpath(o,r,s,t)if type(o)~="string"then error(("bad argument #1 to 'searchpath' (string expected, got %s)"):format(type(r)),2)end;if type(r)~="string"then error(("bad argument #2 to 'searchpath' (string expected, got %s)"):format(type(r)),2)end;if s~=nil and type(s)~="string"then error(("bad argument #3 to 'searchpath' (string expected, got %s)"):format(type(r)),2)end;if t~=nil and type(t)~="string"then error(("bad argument #4 to 'searchpath' (string expected, got %s)"):format(type(r)),2)end;s=s or"."t=t or a.dir_separator;do local u,v=o:find(s,nil,true)while u do o=o:sub(1,u-1)..t..o:sub(v+1,-1)u,v=o:find(s,u+#t+1,true)end end;local w={}for x in r:gmatch('[^;]+')do local y=x:gsub('?',o)w[#w+1]=y;local m=io.open(y,'r')if m then m:close()return y end end;return nil,"\tno file '"..table.concat(w,"'\n\tno file '").."'"end end;if not warn then local z=false;function warn(A,...)if type(A)=="string"and A:sub(1,1)=="@"then if A=="@on"then z=true;return end;if A=="@off"then z=false;return end;return end;if z then io.stderr:write("Lua warning: ",A,...)io.stderr:write("\n")end end end;return a
|