summaryrefslogtreecommitdiff
path: root/scripts/context/lua/mtxrun.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/context/lua/mtxrun.lua')
-rw-r--r--scripts/context/lua/mtxrun.lua255
1 files changed, 184 insertions, 71 deletions
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index dfc90ac56..4e8678e04 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -981,7 +981,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-lpeg"] = package.loaded["l-lpeg"] or true
--- original size: 39305, stripped down to: 21144
+-- original size: 39398, stripped down to: 21142
if not modules then modules={} end modules ['l-lpeg']={
version=1.001,
@@ -1150,8 +1150,8 @@ patterns.propername=(uppercase+lowercase+underscore)*(uppercase+lowercase+unders
patterns.somecontent=(anything-newline-space)^1
patterns.beginline=#(1-newline)
patterns.longtostring=Cs(whitespace^0/""*((patterns.quoted+nonwhitespace^1+whitespace^1/""*(P(-1)+Cc(" ")))^0))
-local function anywhere(pattern)
- return P { P(pattern)+1*V(1) }
+function anywhere(pattern)
+ return (1-P(pattern))^0*P(pattern)
end
lpeg.anywhere=anywhere
function lpeg.instringchecker(p)
@@ -1946,7 +1946,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 40782, stripped down to: 23986
+-- original size: 40802, stripped down to: 24000
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -2861,8 +2861,9 @@ end
function table.reverse(t)
if t then
local n=#t
+ local m=n+1
for i=1,floor(n/2) do
- local j=n-i+1
+ local j=m-i
t[i],t[j]=t[j],t[i]
end
return t
@@ -3583,7 +3584,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-os"] = package.loaded["l-os"] or true
--- original size: 16592, stripped down to: 9462
+-- original size: 16683, stripped down to: 9462
if not modules then modules={} end modules ['l-os']={
version=1.001,
@@ -4778,7 +4779,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-dir"] = package.loaded["l-dir"] or true
--- original size: 17703, stripped down to: 11691
+-- original size: 18035, stripped down to: 11890
if not modules then modules={} end modules ['l-dir']={
version=1.001,
@@ -4842,6 +4843,8 @@ local function glob_pattern_function(path,patt,recurse,action)
usedpath=path
end
local dirs
+ local nofdirs=0
+ local noffiles=#result
for name in walkdir(usedpath) do
if name~="." and name~=".." then
local full=path..name
@@ -4851,16 +4854,18 @@ local function glob_pattern_function(path,patt,recurse,action)
action(full)
end
elseif recurse and mode=="directory" then
- if not dirs then
- dirs={ full }
+ if dirs then
+ nofdirs=nofdirs+1
+ dirs[nofdirs]=full
else
- dirs[#dirs+1]=full
+ nofdirs=1
+ dirs={ full }
end
end
end
end
if dirs then
- for i=1,#dirs do
+ for i=1,nofdirs do
glob_pattern_function(dirs[i],patt,recurse,action)
end
end
@@ -4870,38 +4875,41 @@ local function glob_pattern_table(path,patt,recurse,result)
if not result then
result={}
end
- if isdir(path) then
- local usedpath
- if path=="/" then
- usedpath="/."
- elseif not find(path,"/$") then
- usedpath=path.."/."
- path=path.."/"
- else
- usedpath=path
- end
- local dirs
- for name in walkdir(usedpath) do
- if name~="." and name~=".." then
- local full=path..name
- local mode=attributes(full,'mode')
- if mode=='file' then
- if not patt or find(full,patt) then
- result[#result+1]=full
- end
- elseif recurse and mode=="directory" then
- if not dirs then
- dirs={ full }
- else
- dirs[#dirs+1]=full
- end
+ local usedpath
+ if path=="/" then
+ usedpath="/."
+ elseif not find(path,"/$") then
+ usedpath=path.."/."
+ path=path.."/"
+ else
+ usedpath=path
+ end
+ local dirs
+ local nofdirs=0
+ local noffiles=#result
+ for name,a in walkdir(usedpath) do
+ if name~="." and name~=".." then
+ local full=path..name
+ local mode=attributes(full,'mode')
+ if mode=='file' then
+ if not patt or find(full,patt) then
+ noffiles=noffiles+1
+ result[noffiles]=full
+ end
+ elseif recurse and mode=="directory" then
+ if dirs then
+ nofdirs=nofdirs+1
+ dirs[nofdirs]=full
+ else
+ nofdirs=1
+ dirs={ full }
end
end
end
- if dirs then
- for i=1,#dirs do
- glob_pattern_table(dirs[i],patt,recurse,result)
- end
+ end
+ if dirs then
+ for i=1,nofdirs do
+ glob_pattern_table(dirs[i],patt,recurse,result)
end
end
return result
@@ -4911,12 +4919,13 @@ local function globpattern(path,patt,recurse,method)
if patt and sub(patt,1,-3)==path then
patt=false
end
+ local okay=isdir(path)
if kind=="function" then
- return glob_pattern_function(path,patt,recurse,method)
+ return okay and glob_pattern_function(path,patt,recurse,method) or {}
elseif kind=="table" then
- return glob_pattern_table(path,patt,recurse,method)
+ return okay and glob_pattern_table(path,patt,recurse,method) or method
else
- return glob_pattern_table(path,patt,recurse,{})
+ return okay and glob_pattern_table(path,patt,recurse,{}) or {}
end
end
dir.globpattern=globpattern
@@ -7604,7 +7613,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-fil"] = package.loaded["util-fil"] or true
--- original size: 7787, stripped down to: 5858
+-- original size: 9034, stripped down to: 6958
if not modules then modules={} end modules ['util-fil']={
version=1.001,
@@ -7866,6 +7875,35 @@ if fio and fio.readcardinal1 then
skipposition(f,4*(n or 1))
end
end
+if fio and fio.readcardinaltable then
+ files.readcardinaltable=fio.readcardinaltable
+ files.readintegertable=fio.readintegertable
+else
+ local readcardinal1=files.readcardinal1
+ local readcardinal2=files.readcardinal2
+ local readcardinal3=files.readcardinal3
+ local readcardinal4=files.readcardinal4
+ function files.readcardinaltable(f,n,b)
+ local t={}
+ if b==1 then for i=1,n do t[i]=readcardinal1(f) end
+ elseif b==2 then for i=1,n do t[i]=readcardinal2(f) end
+ elseif b==3 then for i=1,n do t[i]=readcardinal3(f) end
+ elseif b==4 then for i=1,n do t[i]=readcardinal4(f) end end
+ return t
+ end
+ local readinteger1=files.readinteger1
+ local readinteger2=files.readinteger2
+ local readinteger3=files.readinteger3
+ local readinteger4=files.readinteger4
+ function files.readintegertable(f,n,b)
+ local t={}
+ if b==1 then for i=1,n do t[i]=readinteger1(f) end
+ elseif b==2 then for i=1,n do t[i]=readinteger2(f) end
+ elseif b==3 then for i=1,n do t[i]=readinteger3(f) end
+ elseif b==4 then for i=1,n do t[i]=readinteger4(f) end end
+ return t
+ end
+end
end -- of closure
@@ -7874,7 +7912,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-sac"] = package.loaded["util-sac"] or true
--- original size: 8716, stripped down to: 6754
+-- original size: 9987, stripped down to: 7878
if not modules then modules={} end modules ['util-sac']={
version=1.001,
@@ -8207,6 +8245,35 @@ if sio and sio.readcardinal2 then
streams.readcardinal=streams.readcardinal1
streams.readinteger=streams.readinteger1
end
+if sio and sio.readcardinaltable then
+ streams.readcardinaltable=sio.readcardinaltable
+ streams.readintegertable=sio.readintegertable
+else
+ local readcardinal1=streams.readcardinal1
+ local readcardinal2=streams.readcardinal2
+ local readcardinal3=streams.readcardinal3
+ local readcardinal4=streams.readcardinal4
+ function streams.readcardinaltable(f,n,b)
+ local t={}
+ if b==1 then for i=1,n do t[i]=readcardinal1(f) end
+ elseif b==2 then for i=1,n do t[i]=readcardinal2(f) end
+ elseif b==3 then for i=1,n do t[i]=readcardinal3(f) end
+ elseif b==4 then for i=1,n do t[i]=readcardinal4(f) end end
+ return t
+ end
+ local readinteger1=streams.readinteger1
+ local readinteger2=streams.readinteger2
+ local readinteger3=streams.readinteger3
+ local readinteger4=streams.readinteger4
+ function streams.readintegertable(f,n,b)
+ local t={}
+ if b==1 then for i=1,n do t[i]=readinteger1(f) end
+ elseif b==2 then for i=1,n do t[i]=readinteger2(f) end
+ elseif b==3 then for i=1,n do t[i]=readinteger3(f) end
+ elseif b==4 then for i=1,n do t[i]=readinteger4(f) end end
+ return t
+ end
+end
end -- of closure
@@ -13668,7 +13735,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-lpt"] = package.loaded["lxml-lpt"] or true
--- original size: 53326, stripped down to: 32477
+-- original size: 54551, stripped down to: 33353
if not modules then modules={} end modules ['lxml-lpt']={
version=1.001,
@@ -13753,18 +13820,32 @@ apply_axis['child']=function(list)
local ll=list[l]
local dt=ll.dt
if dt then
- local en=0
- for k=1,#dt do
- local dk=dt[k]
+ local n=#dt
+ if n==0 then
+ ll.en=0
+ elseif n==1 then
+ local dk=dt[1]
if dk.tg then
c=c+1
collected[c]=dk
- dk.ni=k
- en=en+1
- dk.ei=en
+ dk.ni=1
+ dk.ei=1
+ ll.en=1
end
+ else
+ local en=0
+ for k=1,#dt do
+ local dk=dt[k]
+ if dk.tg then
+ c=c+1
+ en=en+1
+ collected[c]=dk
+ dk.ni=k
+ dk.ei=en
+ end
+ end
+ ll.en=en
end
- ll.en=en
end
end
return collected
@@ -13772,19 +13853,36 @@ end
local function collect(list,collected,c)
local dt=list.dt
if dt then
- local en=0
- for k=1,#dt do
- local dk=dt[k]
+ local n=#dt
+ if n==0 then
+ list.en=0
+ elseif n==1 then
+ local dk=dt[1]
if dk.tg then
c=c+1
collected[c]=dk
- dk.ni=k
- en=en+1
- dk.ei=en
+ dk.ni=1
+ dk.ei=1
c=collect(dk,collected,c)
+ list.en=1
+ else
+ list.en=0
+ end
+ else
+ local en=0
+ for k=1,n do
+ local dk=dt[k]
+ if dk.tg then
+ c=c+1
+ en=en+1
+ collected[c]=dk
+ dk.ni=k
+ dk.ei=en
+ c=collect(dk,collected,c)
+ end
end
+ list.en=en
end
- list.en=en
end
return c
end
@@ -13798,19 +13896,34 @@ end
local function collect(list,collected,c)
local dt=list.dt
if dt then
- local en=0
- for k=1,#dt do
- local dk=dt[k]
+ local n=#dt
+ if n==0 then
+ list.en=0
+ elseif n==1 then
+ local dk=dt[1]
if dk.tg then
c=c+1
collected[c]=dk
- dk.ni=k
- en=en+1
- dk.ei=en
+ dk.ni=1
+ dk.ei=1
c=collect(dk,collected,c)
+ list.en=1
+ end
+ else
+ local en=0
+ for k=1,#dt do
+ local dk=dt[k]
+ if dk.tg then
+ c=c+1
+ en=en+1
+ collected[c]=dk
+ dk.ni=k
+ dk.ei=en
+ c=collect(dk,collected,c)
+ end
end
+ list.en=en
end
- list.en=en
end
return c
end
@@ -17792,7 +17905,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-res"] = package.loaded["data-res"] or true
--- original size: 68261, stripped down to: 47789
+-- original size: 68255, stripped down to: 47783
if not modules then modules={} end modules ['data-res']={
version=1.001,
@@ -19366,7 +19479,7 @@ function resolvers.dowithfilesintree(pattern,handle,before,after)
end
end
if after then
- after(blobtype,blobpath,pattern,total,checked,done)
+ after(blobtype,blobpath,pattern,checked,done)
end
end
end
@@ -21478,8 +21591,8 @@ end -- of closure
-- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 882905
--- stripped bytes : 319293
+-- original bytes : 887178
+-- stripped bytes : 320261
-- end library merge