diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-11-07 12:49:36 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-11-07 12:49:36 +0100 |
commit | 75fbb107b15d01179a4b772844144e0661240e77 (patch) | |
tree | c5210f4f9ade25c89a540f755912a52966404792 /scripts | |
parent | 7830451577b876020de2a26bbfbf069625ab4d6f (diff) | |
download | context-75fbb107b15d01179a4b772844144e0661240e77.tar.gz |
2017-11-07 11:43:00
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/context/lua/mtx-youless.lua | 68 | ||||
-rw-r--r-- | scripts/context/lua/mtxrun.lua | 39 | ||||
-rw-r--r-- | scripts/context/stubs/mswin/mtxrun.lua | 39 | ||||
-rw-r--r-- | scripts/context/stubs/setup/setuptex | 100 | ||||
-rw-r--r-- | scripts/context/stubs/unix/mtxrun | 39 | ||||
-rw-r--r-- | scripts/context/stubs/win64/mtxrun.lua | 39 |
6 files changed, 198 insertions, 126 deletions
diff --git a/scripts/context/lua/mtx-youless.lua b/scripts/context/lua/mtx-youless.lua index 740fdcb65..6c600517a 100644 --- a/scripts/context/lua/mtx-youless.lua +++ b/scripts/context/lua/mtx-youless.lua @@ -33,6 +33,7 @@ local helpinfo = [[ <flag name="kwh"><short>summative kwh data</short></flag> <flag name="watt"><short>collected watt data</short></flag> <flag name="host"><short>ip address of device</short></flag> + <flag name="auto"><short>fetch kwh and watt data every hour</short></flag> </subcategory> </category> </flags> @@ -42,6 +43,7 @@ local helpinfo = [[ <subcategory> <example><command>mtxrun --script youless --collect --host=192.168.2.50 --kwh</command></example> <example><command>mtxrun --script youless --collect --host=192.168.2.50 --watt somefile.lua</command></example> + <example><command>mtxrun --script youless --collect --host=192.168.2.50 --auto file-prefix</command></example> </subcategory> </category> </examples> @@ -61,17 +63,32 @@ scripts.youless = scripts.youless or { } function scripts.youless.collect() local host = environment.arguments.host - local variant = environment.arguments.kwh and "kwh" or environment.arguments.watt and "watt" local nobackup = environment.arguments.nobackup local nofile = environment.arguments.nofile local password = environment.arguments.password local filename = environment.files[1] - if not variant then - report("provide variant --kwh or --watt") - return - else + local delay = tonumber(environment.delay) or 12*60*60 + + local function fetch(filename,variant) + local data = utilities.youless.collect { + filename = filename, + host = host, + variant = variant, + nobackup = nobackup, + password = password, + } + if type(data) ~= "table" then + report("no data collected") + elseif filename == "" then + report("data collected but not saved") + end report("using variant %a",variant) + if filename ~= "" then + report("using file %a",filename) + end + report("current time %a",os.now()) end + if not host then host = "192.168.2.50" report("using default host %a",host) @@ -81,25 +98,30 @@ function scripts.youless.collect() if nobackup then report("not backing up data file") end - if not filename and not nofile then - filename = formatters["youless-%s.lua"](variant) - end - if filename ~= "" then - report("using file %a",filename) - end - local data = utilities.youless.collect { - filename = filename, - host = host, - variant = variant, - nobackup = nobackup, - password = password, - } - if type(data) ~= "table" then - report("no data collected") - elseif filename == "" then - report("data collected but not saved") + + if environment.arguments.auto then + local filename_kwh = formatters["%s-kwh.lua" ](filename ~= "" and filename or "youless") + local filename_watt = formatters["%s-watt.lua"](filename ~= "" and filename or "youless") + while true do + fetch(filename_kwh,"kwh") + fetch(filename_watt,"watt") + report("sleeping for %i seconds",delay) + io.flush() + os.sleep(delay) + end + else + local variant = environment.arguments.kwh and "kwh" or environment.arguments.watt and "watt" + if not variant then + report("provide variant --kwh or --watt") + return + end + if nofile then + filename = "" + elseif not filename or filename == "" then + filename = formatters["youless-%s.lua"](variant) + end + fetch(filename,variant) end - report("current time %a",os.now()) end if environment.argument("collect") then diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 558b791fe..a92192a2a 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -598,7 +598,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-package"] = package.loaded["l-package"] or true --- original size: 11545, stripped down to: 8606 +-- original size: 11564, stripped down to: 8625 if not modules then modules={} end modules ['l-package']={ version=1.001, @@ -611,7 +611,7 @@ local type=type local gsub,format,find=string.gsub,string.format,string.find local P,S,Cs,lpegmatch=lpeg.P,lpeg.S,lpeg.Cs,lpeg.match local package=package -local searchers=package.searchers +local searchers=package.searchers or package.loaders local insert,remove=table.insert,table.remove local filejoin=file and file.join or function(path,name) return path.."/"..name end local isreadable=file and file.is_readable or function(name) local f=io.open(name) if f then f:close() return true end end @@ -1735,7 +1735,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-string"] = package.loaded["l-string"] or true --- original size: 6420, stripped down to: 3339 +-- original size: 6461, stripped down to: 3341 if not modules then modules={} end modules ['l-string']={ version=1.001, @@ -1837,9 +1837,9 @@ function string.tformat(fmt,...) end string.quote=string.quoted string.unquote=string.unquoted -if not string.bytetable then +if not string.bytetable then local limit=5000 - function string.bytetable(str) + function string.bytetable(str) local n=#str if n>limit then local t={ byte(str,1,limit) } @@ -3853,7 +3853,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-file"] = package.loaded["l-file"] or true --- original size: 20997, stripped down to: 9986 +-- original size: 21090, stripped down to: 10074 if not modules then modules={} end modules ['l-file']={ version=1.001, @@ -3889,6 +3889,9 @@ end function lfs.isfile(name) return attributes(name,"mode")=="file" end +function lfs.isfound(name) + return attributes(name,"mode")=="file" and name or nil +end local colon=P(":") local period=P(".") local periods=P("..") @@ -10243,7 +10246,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-lua"] = package.loaded["util-lua"] or true --- original size: 6662, stripped down to: 4771 +-- original size: 6921, stripped down to: 4998 if not modules then modules={} end modules ['util-lua']={ version=1.001, @@ -10313,7 +10316,7 @@ function luautilities.loadedluacode(fullname,forcestrip,name,macros) end if macros and macros.enabled then local f=io.open(fullname,"rb") local c=f:read("*a") f:close() - local n=c and macros.resolvestring(c) + local n=c and macros.resolvestring("--[["..fullname.."]] "..c) if n and #n~=#c then report_lua("preprocessed file %a: %i => %i bytes",fullname,#c,#n) end @@ -10343,7 +10346,7 @@ function luautilities.loadedluacode(fullname,forcestrip,name,macros) return code,0 end end -function luautilities.strippedloadstring(code,forcestrip,name) +function luautilities.strippedloadstring(code,name,forcestrip) local code,message=load(code) if not code then report_lua("loading of file %a failed:\n\t%s",name,message or "no message") @@ -10355,6 +10358,13 @@ function luautilities.strippedloadstring(code,forcestrip,name) return code,0 end end +function luautilities.loadstring(code,name) + local code,message=load(code) + if not code then + report_lua("loading of file %a failed:\n\t%s",name,message or "no message") + end + return code,0 +end function luautilities.compile(luafile,lucfile,cleanup,strip,fallback) report_lua("compiling %a into %a",luafile,lucfile) os.remove(lucfile) @@ -20370,7 +20380,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-lib"] = package.loaded["util-lib"] or true --- original size: 14333, stripped down to: 7859 +-- original size: 14415, stripped down to: 7927 if not modules then modules={} end modules ['util-lib']={ version=1.001, @@ -20481,9 +20491,10 @@ local function locate(required,version,trace,report,action) end package.extralibpath(environment.ownpath) local paths=package.libpaths() + local pattern="/[^/]+%."..os.libsuffix.."$" for i=1,#paths do - required_path=paths[i] - local found=check(lfs.isfile) + required_path=gsub(paths[i],pattern,"") + local found=check(lfs.isfound) if type(found)=="string" and (not checkpattern or find(found,checkpattern)) then return found end @@ -20978,8 +20989,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 : 865625 --- stripped bytes : 315093 +-- original bytes : 866119 +-- stripped bytes : 315183 -- end library merge diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 558b791fe..a92192a2a 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -598,7 +598,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-package"] = package.loaded["l-package"] or true --- original size: 11545, stripped down to: 8606 +-- original size: 11564, stripped down to: 8625 if not modules then modules={} end modules ['l-package']={ version=1.001, @@ -611,7 +611,7 @@ local type=type local gsub,format,find=string.gsub,string.format,string.find local P,S,Cs,lpegmatch=lpeg.P,lpeg.S,lpeg.Cs,lpeg.match local package=package -local searchers=package.searchers +local searchers=package.searchers or package.loaders local insert,remove=table.insert,table.remove local filejoin=file and file.join or function(path,name) return path.."/"..name end local isreadable=file and file.is_readable or function(name) local f=io.open(name) if f then f:close() return true end end @@ -1735,7 +1735,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-string"] = package.loaded["l-string"] or true --- original size: 6420, stripped down to: 3339 +-- original size: 6461, stripped down to: 3341 if not modules then modules={} end modules ['l-string']={ version=1.001, @@ -1837,9 +1837,9 @@ function string.tformat(fmt,...) end string.quote=string.quoted string.unquote=string.unquoted -if not string.bytetable then +if not string.bytetable then local limit=5000 - function string.bytetable(str) + function string.bytetable(str) local n=#str if n>limit then local t={ byte(str,1,limit) } @@ -3853,7 +3853,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-file"] = package.loaded["l-file"] or true --- original size: 20997, stripped down to: 9986 +-- original size: 21090, stripped down to: 10074 if not modules then modules={} end modules ['l-file']={ version=1.001, @@ -3889,6 +3889,9 @@ end function lfs.isfile(name) return attributes(name,"mode")=="file" end +function lfs.isfound(name) + return attributes(name,"mode")=="file" and name or nil +end local colon=P(":") local period=P(".") local periods=P("..") @@ -10243,7 +10246,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-lua"] = package.loaded["util-lua"] or true --- original size: 6662, stripped down to: 4771 +-- original size: 6921, stripped down to: 4998 if not modules then modules={} end modules ['util-lua']={ version=1.001, @@ -10313,7 +10316,7 @@ function luautilities.loadedluacode(fullname,forcestrip,name,macros) end if macros and macros.enabled then local f=io.open(fullname,"rb") local c=f:read("*a") f:close() - local n=c and macros.resolvestring(c) + local n=c and macros.resolvestring("--[["..fullname.."]] "..c) if n and #n~=#c then report_lua("preprocessed file %a: %i => %i bytes",fullname,#c,#n) end @@ -10343,7 +10346,7 @@ function luautilities.loadedluacode(fullname,forcestrip,name,macros) return code,0 end end -function luautilities.strippedloadstring(code,forcestrip,name) +function luautilities.strippedloadstring(code,name,forcestrip) local code,message=load(code) if not code then report_lua("loading of file %a failed:\n\t%s",name,message or "no message") @@ -10355,6 +10358,13 @@ function luautilities.strippedloadstring(code,forcestrip,name) return code,0 end end +function luautilities.loadstring(code,name) + local code,message=load(code) + if not code then + report_lua("loading of file %a failed:\n\t%s",name,message or "no message") + end + return code,0 +end function luautilities.compile(luafile,lucfile,cleanup,strip,fallback) report_lua("compiling %a into %a",luafile,lucfile) os.remove(lucfile) @@ -20370,7 +20380,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-lib"] = package.loaded["util-lib"] or true --- original size: 14333, stripped down to: 7859 +-- original size: 14415, stripped down to: 7927 if not modules then modules={} end modules ['util-lib']={ version=1.001, @@ -20481,9 +20491,10 @@ local function locate(required,version,trace,report,action) end package.extralibpath(environment.ownpath) local paths=package.libpaths() + local pattern="/[^/]+%."..os.libsuffix.."$" for i=1,#paths do - required_path=paths[i] - local found=check(lfs.isfile) + required_path=gsub(paths[i],pattern,"") + local found=check(lfs.isfound) if type(found)=="string" and (not checkpattern or find(found,checkpattern)) then return found end @@ -20978,8 +20989,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 : 865625 --- stripped bytes : 315093 +-- original bytes : 866119 +-- stripped bytes : 315183 -- end library merge diff --git a/scripts/context/stubs/setup/setuptex b/scripts/context/stubs/setup/setuptex index d41e36707..78128ee8b 100644 --- a/scripts/context/stubs/setup/setuptex +++ b/scripts/context/stubs/setup/setuptex @@ -22,53 +22,59 @@ system=`uname -s` cpu=`uname -m` case "$system" in - # linux - Linux) - case "$cpu" in - i*86) platform="linux" ;; - x86_64|ia64) platform="linux-64" ;; - # a little bit of cheating with ppc64 (won't work on Gentoo) - ppc|ppc64) platform="linux-ppc" ;; - *) platform="unknown" ;; - esac ;; - # Mac OS X - Darwin) - case "$cpu" in - i*86) platform="osx-intel" ;; - x86_64) platform="osx-64" ;; - ppc*|powerpc|power*|Power*) platform="osx-ppc" ;; - *) platform="unknown" ;; - esac ;; - # FreeBSD - FreeBSD|freebsd) - case "$cpu" in - i*86) platform="freebsd" ;; - x86_64) platform="freebsd" ;; - amd64) platform="freebsd-amd64" ;; - *) platform="unknown" ;; - esac ;; - # kFreeBSD (Debian) - GNU/kFreeBSD) - case "$cpu" in - i*86) platform="kfreebsd-i386" ;; - x86_64|amd64) platform="kfreebsd-amd64" ;; - *) platform="unknown" ;; - esac ;; - # cygwin - CYGWIN) - case "$cpu" in - i*86) platform="cygwin" ;; - x86_64|ia64) platform="cygwin-64" ;; - *) platform="unknown" ;; - esac ;; - # SunOS/Solaris - SunOS) - case "$cpu" in - sparc) platform="solaris-sparc" ;; - i86pc) platform="solaris-intel" ;; - *) platform="unknown" ;; - esac ;; - *) platform="unknown" + # linux + Linux) + case "$cpu" in + i*86) platform="linux" ;; + x86_64|ia64) platform="linux-64" ;; + # a little bit of cheating with ppc64 (won't work on Gentoo) + ppc|ppc64) platform="linux-ppc" ;; + *) platform="unknown" ;; + esac ;; + # Mac OS X + Darwin) + case "$cpu" in + i*86) platform="osx-intel" ;; + x86_64) platform="osx-64" ;; + ppc*|powerpc|power*|Power*) platform="osx-ppc" ;; + *) platform="unknown" ;; + esac ;; + # FreeBSD + FreeBSD|freebsd) + case "$cpu" in + i*86) platform="freebsd" ;; + x86_64) platform="freebsd" ;; + amd64) platform="freebsd-amd64" ;; + *) platform="unknown" ;; + esac ;; + # kFreeBSD (Debian) + GNU/kFreeBSD) + case "$cpu" in + i*86) platform="kfreebsd-i386" ;; + x86_64|amd64) platform="kfreebsd-amd64" ;; + *) platform="unknown" ;; + esac ;; + # MSYS2|MSYS_NT-10.0) + case "$cpu" in + i*86) platform="win32" ;; + x86_64) platform="win64" ;; + *) platform="unknown" ;; + esac ;; + # cygwin + CYGWIN) + case "$cpu" in + i*86) platform="cygwin" ;; + x86_64|ia64) platform="cygwin-64" ;; + *) platform="unknown" ;; + esac ;; + # SunOS/Solaris + SunOS) + case "$cpu" in + sparc) platform="solaris-sparc" ;; + i86pc) platform="solaris-intel" ;; + *) platform="unknown" ;; + esac ;; + *) platform="unknown" esac # temporary fix for Snow Leopard diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 558b791fe..a92192a2a 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -598,7 +598,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-package"] = package.loaded["l-package"] or true --- original size: 11545, stripped down to: 8606 +-- original size: 11564, stripped down to: 8625 if not modules then modules={} end modules ['l-package']={ version=1.001, @@ -611,7 +611,7 @@ local type=type local gsub,format,find=string.gsub,string.format,string.find local P,S,Cs,lpegmatch=lpeg.P,lpeg.S,lpeg.Cs,lpeg.match local package=package -local searchers=package.searchers +local searchers=package.searchers or package.loaders local insert,remove=table.insert,table.remove local filejoin=file and file.join or function(path,name) return path.."/"..name end local isreadable=file and file.is_readable or function(name) local f=io.open(name) if f then f:close() return true end end @@ -1735,7 +1735,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-string"] = package.loaded["l-string"] or true --- original size: 6420, stripped down to: 3339 +-- original size: 6461, stripped down to: 3341 if not modules then modules={} end modules ['l-string']={ version=1.001, @@ -1837,9 +1837,9 @@ function string.tformat(fmt,...) end string.quote=string.quoted string.unquote=string.unquoted -if not string.bytetable then +if not string.bytetable then local limit=5000 - function string.bytetable(str) + function string.bytetable(str) local n=#str if n>limit then local t={ byte(str,1,limit) } @@ -3853,7 +3853,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-file"] = package.loaded["l-file"] or true --- original size: 20997, stripped down to: 9986 +-- original size: 21090, stripped down to: 10074 if not modules then modules={} end modules ['l-file']={ version=1.001, @@ -3889,6 +3889,9 @@ end function lfs.isfile(name) return attributes(name,"mode")=="file" end +function lfs.isfound(name) + return attributes(name,"mode")=="file" and name or nil +end local colon=P(":") local period=P(".") local periods=P("..") @@ -10243,7 +10246,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-lua"] = package.loaded["util-lua"] or true --- original size: 6662, stripped down to: 4771 +-- original size: 6921, stripped down to: 4998 if not modules then modules={} end modules ['util-lua']={ version=1.001, @@ -10313,7 +10316,7 @@ function luautilities.loadedluacode(fullname,forcestrip,name,macros) end if macros and macros.enabled then local f=io.open(fullname,"rb") local c=f:read("*a") f:close() - local n=c and macros.resolvestring(c) + local n=c and macros.resolvestring("--[["..fullname.."]] "..c) if n and #n~=#c then report_lua("preprocessed file %a: %i => %i bytes",fullname,#c,#n) end @@ -10343,7 +10346,7 @@ function luautilities.loadedluacode(fullname,forcestrip,name,macros) return code,0 end end -function luautilities.strippedloadstring(code,forcestrip,name) +function luautilities.strippedloadstring(code,name,forcestrip) local code,message=load(code) if not code then report_lua("loading of file %a failed:\n\t%s",name,message or "no message") @@ -10355,6 +10358,13 @@ function luautilities.strippedloadstring(code,forcestrip,name) return code,0 end end +function luautilities.loadstring(code,name) + local code,message=load(code) + if not code then + report_lua("loading of file %a failed:\n\t%s",name,message or "no message") + end + return code,0 +end function luautilities.compile(luafile,lucfile,cleanup,strip,fallback) report_lua("compiling %a into %a",luafile,lucfile) os.remove(lucfile) @@ -20370,7 +20380,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-lib"] = package.loaded["util-lib"] or true --- original size: 14333, stripped down to: 7859 +-- original size: 14415, stripped down to: 7927 if not modules then modules={} end modules ['util-lib']={ version=1.001, @@ -20481,9 +20491,10 @@ local function locate(required,version,trace,report,action) end package.extralibpath(environment.ownpath) local paths=package.libpaths() + local pattern="/[^/]+%."..os.libsuffix.."$" for i=1,#paths do - required_path=paths[i] - local found=check(lfs.isfile) + required_path=gsub(paths[i],pattern,"") + local found=check(lfs.isfound) if type(found)=="string" and (not checkpattern or find(found,checkpattern)) then return found end @@ -20978,8 +20989,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 : 865625 --- stripped bytes : 315093 +-- original bytes : 866119 +-- stripped bytes : 315183 -- end library merge diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua index 558b791fe..a92192a2a 100644 --- a/scripts/context/stubs/win64/mtxrun.lua +++ b/scripts/context/stubs/win64/mtxrun.lua @@ -598,7 +598,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-package"] = package.loaded["l-package"] or true --- original size: 11545, stripped down to: 8606 +-- original size: 11564, stripped down to: 8625 if not modules then modules={} end modules ['l-package']={ version=1.001, @@ -611,7 +611,7 @@ local type=type local gsub,format,find=string.gsub,string.format,string.find local P,S,Cs,lpegmatch=lpeg.P,lpeg.S,lpeg.Cs,lpeg.match local package=package -local searchers=package.searchers +local searchers=package.searchers or package.loaders local insert,remove=table.insert,table.remove local filejoin=file and file.join or function(path,name) return path.."/"..name end local isreadable=file and file.is_readable or function(name) local f=io.open(name) if f then f:close() return true end end @@ -1735,7 +1735,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-string"] = package.loaded["l-string"] or true --- original size: 6420, stripped down to: 3339 +-- original size: 6461, stripped down to: 3341 if not modules then modules={} end modules ['l-string']={ version=1.001, @@ -1837,9 +1837,9 @@ function string.tformat(fmt,...) end string.quote=string.quoted string.unquote=string.unquoted -if not string.bytetable then +if not string.bytetable then local limit=5000 - function string.bytetable(str) + function string.bytetable(str) local n=#str if n>limit then local t={ byte(str,1,limit) } @@ -3853,7 +3853,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-file"] = package.loaded["l-file"] or true --- original size: 20997, stripped down to: 9986 +-- original size: 21090, stripped down to: 10074 if not modules then modules={} end modules ['l-file']={ version=1.001, @@ -3889,6 +3889,9 @@ end function lfs.isfile(name) return attributes(name,"mode")=="file" end +function lfs.isfound(name) + return attributes(name,"mode")=="file" and name or nil +end local colon=P(":") local period=P(".") local periods=P("..") @@ -10243,7 +10246,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-lua"] = package.loaded["util-lua"] or true --- original size: 6662, stripped down to: 4771 +-- original size: 6921, stripped down to: 4998 if not modules then modules={} end modules ['util-lua']={ version=1.001, @@ -10313,7 +10316,7 @@ function luautilities.loadedluacode(fullname,forcestrip,name,macros) end if macros and macros.enabled then local f=io.open(fullname,"rb") local c=f:read("*a") f:close() - local n=c and macros.resolvestring(c) + local n=c and macros.resolvestring("--[["..fullname.."]] "..c) if n and #n~=#c then report_lua("preprocessed file %a: %i => %i bytes",fullname,#c,#n) end @@ -10343,7 +10346,7 @@ function luautilities.loadedluacode(fullname,forcestrip,name,macros) return code,0 end end -function luautilities.strippedloadstring(code,forcestrip,name) +function luautilities.strippedloadstring(code,name,forcestrip) local code,message=load(code) if not code then report_lua("loading of file %a failed:\n\t%s",name,message or "no message") @@ -10355,6 +10358,13 @@ function luautilities.strippedloadstring(code,forcestrip,name) return code,0 end end +function luautilities.loadstring(code,name) + local code,message=load(code) + if not code then + report_lua("loading of file %a failed:\n\t%s",name,message or "no message") + end + return code,0 +end function luautilities.compile(luafile,lucfile,cleanup,strip,fallback) report_lua("compiling %a into %a",luafile,lucfile) os.remove(lucfile) @@ -20370,7 +20380,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-lib"] = package.loaded["util-lib"] or true --- original size: 14333, stripped down to: 7859 +-- original size: 14415, stripped down to: 7927 if not modules then modules={} end modules ['util-lib']={ version=1.001, @@ -20481,9 +20491,10 @@ local function locate(required,version,trace,report,action) end package.extralibpath(environment.ownpath) local paths=package.libpaths() + local pattern="/[^/]+%."..os.libsuffix.."$" for i=1,#paths do - required_path=paths[i] - local found=check(lfs.isfile) + required_path=gsub(paths[i],pattern,"") + local found=check(lfs.isfound) if type(found)=="string" and (not checkpattern or find(found,checkpattern)) then return found end @@ -20978,8 +20989,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 : 865625 --- stripped bytes : 315093 +-- original bytes : 866119 +-- stripped bytes : 315183 -- end library merge |