diff options
25 files changed, 1753 insertions, 1776 deletions
diff --git a/metapost/context/base/mpxl/mp-abck.mpxl b/metapost/context/base/mpxl/mp-abck.mpxl index 730aed21d..7566ae4e4 100644 --- a/metapost/context/base/mpxl/mp-abck.mpxl +++ b/metapost/context/base/mpxl/mp-abck.mpxl @@ -36,26 +36,26 @@ par_strut_depth := 0 ; pair boxgriddirection ; boxgriddirection := up ; % to be interfaced numeric boxgriddistance ; boxgriddistance := .5cm ; % to be interfaced -def boxgridtype = (runscript mfid_mpvarn "gridtype" ) enddef ; -def boxgridwidth = (runscript mfid_mpvard "gridwidth" ) enddef ; -def boxgridshift = (runscript mfid_mpvard "gridshift" ) enddef ; -def boxgridcolor = (runscript mfid_mpvars "gridcolor" ) enddef ; +def boxgridtype = (runscript mfid_mpvarn "gridtype") enddef ; +def boxgridwidth = (runscript mfid_mpvard "gridwidth") enddef ; +def boxgridshift = (runscript mfid_mpvard "gridshift") enddef ; +def boxgridcolor = (runscript mfid_mpvars "gridcolor") enddef ; -def boxlinetype = (runscript mfid_mpvarn "linetype" ) enddef ; -def boxlinewidth = (runscript mfid_mpvard "linewidth" ) enddef ; +def boxlinetype = (runscript mfid_mpvarn "linetype") enddef ; +def boxlinewidth = (runscript mfid_mpvard "linewidth") enddef ; def boxlineradius = (runscript mfid_mpvard "lineradius") enddef ; def boxlineoffset = (runscript mfid_mpvard "lineoffset") enddef ; -def boxlinecolor = (runscript mfid_mpvars "linecolor" ) enddef ; +def boxlinecolor = (runscript mfid_mpvars "linecolor") enddef ; -def boxfilltype = (runscript mfid_mpvarn "filltype" ) enddef ; +def boxfilltype = (runscript mfid_mpvarn "filltype") enddef ; def boxfilloffset = (runscript mfid_mpvard "filloffset") enddef ; -def boxfillcolor = (runscript mfid_mpvars "fillcolor" ) enddef ; +def boxfillcolor = (runscript mfid_mpvars "fillcolor") enddef ; -def boxdashtype = (runscript mfid_mpvarn "dashtype" ) enddef ; +def boxdashtype = (runscript mfid_mpvarn "dashtype") enddef ; -def boxalternative = (runscript mfid_mpvarn "alternative" ) enddef; -def boxdistance = (runscript mfid_mpvard "distance" ) enddef; -def boxtopoffset = (runscript mfid_mpvard "topoffset" ) enddef; +def boxalternative = (runscript mfid_mpvarn "alternative") enddef; +def boxdistance = (runscript mfid_mpvard "distance") enddef; +def boxtopoffset = (runscript mfid_mpvard "topoffset") enddef; def boxbottomoffset = (runscript mfid_mpvard "bottomoffset") enddef; def boxgridoptions = withcolor boxgridcolor enddef ; diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 2317496b5..40ac12fe8 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -3837,7 +3837,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-os"] = package.loaded["l-os"] or true --- original size: 19514, stripped down to: 10470 +-- original size: 19654, stripped down to: 10479 if not modules then modules={} end modules ['l-os']={ version=1.001, @@ -3980,245 +3980,227 @@ if os.type=="windows" then else os.libsuffix,os.binsuffix,os.binsuffixes='so','',{ '' } end -local execute=os.execute -local iopopen=io.popen -local ostype=os.type -local function resultof(command) - local handle=iopopen(command,ostype=="windows" and "rb" or "r") - if handle then - local result=handle:read("*all") or "" - handle:close() - return result - else - return "" +do + local execute=os.execute + local iopopen=io.popen + local ostype=os.type + local function resultof(command) + local handle=iopopen(command,ostype=="windows" and "rb" or "r") + if handle then + local result=handle:read("*all") or "" + handle:close() + return result + else + return "" + end + end + os.resultof=resultof + function os.pipeto(command) + return iopopen(command,"w") + end + local launchers={ + windows="start %s", + macosx="open %s", + unix="xdg-open %s &> /dev/null &", + } + function os.launch(str) + local command=format(launchers[os.name] or launchers.unix,str) + execute(command) end end -os.resultof=resultof -function os.pipeto(command) - return iopopen(command,"w") +do + local gettimeofday=os.gettimeofday or os.clock + os.gettimeofday=gettimeofday + local startuptime=gettimeofday() + function os.runtime() + return gettimeofday()-startuptime + end end -local launchers={ - windows="start %s", - macosx="open %s", - unix="xdg-open %s &> /dev/null &", -} -function os.launch(str) - local command=format(launchers[os.name] or launchers.unix,str) - execute(command) -end -local gettimeofday=os.gettimeofday or os.clock -os.gettimeofday=gettimeofday -local startuptime=gettimeofday() -function os.runtime() - return gettimeofday()-startuptime -end -local resolvers=os.resolvers or {} -os.resolvers=resolvers -setmetatable(os,{ __index=function(t,k) - local r=resolvers[k] - return r and r(t,k) or nil -end }) -local name,platform=os.name or "linux",os.getenv("MTX_PLATFORM") or "" -if platform~="" then - os.platform=platform -elseif os.type=="windows" then - function resolvers.platform(t,k) - local architecture=os.getenv("PROCESSOR_ARCHITECTURE") or "" - local platform="" - if find(architecture,"AMD64",1,true) then - platform="win64" +do + local name=os.name or "linux" + local platform=os.getenv("MTX_PLATFORM") or "" + local architecture=os.uname and os.uname().machine + local bits=os.getenv("MTX_BITS") or find(platform,"64") and 64 or 32 + if platform~="" then + elseif os.type=="windows" then + architecture=architecture or os.getenv("PROCESSOR_ARCHITECTURE") or "" + if architecture=="x86_64" then + bits,platform=64,"win64" + elseif find(architecture,"AMD64") then + bits,platform=64,"win64" + elseif find(architecture,"ARM64") then + bits,platform=64,"windows-arm64" + elseif find(architecture,"ARM32") then + bits,platform=32,"windows-arm32" else - platform="mswin" + bits,platform=32,"mswin" end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="linux" then - function resolvers.platform(t,k) - local architecture=os.getenv("HOSTTYPE") or resultof("uname -m") or "" - local platform=os.getenv("MTX_PLATFORM") or "" + elseif name=="linux" then + architecture=architecture or os.getenv("HOSTTYPE") or resultof("uname -m") or "" local musl=find(os.selfdir or "","linuxmusl") - if platform~="" then - elseif find(architecture,"x86_64",1,true) then - platform=musl and "linuxmusl" or "linux-64" - elseif find(architecture,"ppc",1,true) then - platform="linux-ppc" + if find(architecture,"x86_64") then + bits,platform=64,musl and "linuxmusl" or "linux-64" + elseif find(architecture,"ppc") then + bits,platform=32,"linux-ppc" else - platform=musl and "linuxmusl" or "linux" + bits,platform=32,musl and "linuxmusl" or "linux" end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="macosx" then - function resolvers.platform(t,k) - local architecture=resultof("echo $HOSTTYPE") or "" - local platform="" + elseif name=="macosx" then + architecture=architecture or resultof("echo $HOSTTYPE") or "" if architecture=="" then - platform="osx-intel" - elseif find(architecture,"i386",1,true) then - platform="osx-intel" - elseif find(architecture,"x86_64",1,true) then - platform="osx-64" - elseif find(architecture,"arm64",1,true) then - platform="osx-arm" + bits,platform=64,"osx-intel" + elseif find(architecture,"i386") then + bits,platform=64,"osx-intel" + elseif find(architecture,"x86_64") then + bits,platform=64,"osx-64" + elseif find(architecture,"arm64") then + bits,platform=64,"osx-arm" else - platform="osx-ppc" - end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="sunos" then - function resolvers.platform(t,k) - local architecture=resultof("uname -m") or "" - local platform="" - if find(architecture,"sparc",1,true) then - platform="solaris-sparc" + bits,platform=32,"osx-ppc" + end + elseif name=="sunos" then + architecture=architecture or resultof("uname -m") or "" + if find(architecture,"sparc") then + bits,platform=32,"solaris-sparc" else - platform="solaris-intel" - end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="freebsd" then - function resolvers.platform(t,k) - local architecture=resultof("uname -m") or "" - local platform="" - if find(architecture,"amd64",1,true) then - platform="freebsd-amd64" + bits,platform=32,"solaris-intel" + end + elseif name=="freebsd" then + architecture=architecture or resultof("uname -m") or "" + if find(architecture)=="amd64" or find(architecture)=="AMD64" then + bits,platform=64,"freebsd-amd64" + else + bits,platform=32,"freebsd" + end + elseif name=="kfreebsd" then + architecture=architecture or os.getenv("HOSTTYPE") or resultof("uname -m") or "" + if architecture=="x86_64" then + bits,platform=64,"kfreebsd-amd64" else - platform="freebsd" - end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="kfreebsd" then - function resolvers.platform(t,k) - local architecture=os.getenv("HOSTTYPE") or resultof("uname -m") or "" - local platform="" - if find(architecture,"x86_64",1,true) then - platform="kfreebsd-amd64" + bits,platform=32,"kfreebsd-i386" + end + else + architecture=architecture or resultof("uname -m") or "" + if find(architecture,"aarch64") then + bits,platform="linux-aarch64" + elseif find(architecture,"armv7l") then + bits,platform=32,"linux-armhf" + elseif find(architecture,"mips64") or find(architecture,"mips64el") then + bits,platform=64,"linux-mipsel" + elseif find(architecture,"mipsel") or find(architecture,"mips") then + bits,platform=32,"linux-mipsel" else - platform="kfreebsd-i386" + bits,platform=64,"linux-64" end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -else - function resolvers.platform(t,k) - local platform="linux" - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform end -end -os.newline=name=="windows" and "\013\010" or "\010" -function resolvers.bits(t,k) - local bits=find(os.platform,"64",1,true) and 64 or 32 + os.setenv("MTX_PLATFORM",platform) + os.setenv("MTX_BITS",bits) + os.platform=platform os.bits=bits - return bits -end -local t={ 8,9,"a","b" } -function os.uuid() - return format("%04x%04x-4%03x-%s%03x-%04x-%04x%04x%04x", - random(0xFFFF),random(0xFFFF), - random(0x0FFF), - t[ceil(random(4))] or 8,random(0x0FFF), - random(0xFFFF), - random(0xFFFF),random(0xFFFF),random(0xFFFF) - ) + os.newline=name=="windows" and "\013\010" or "\010" +end +do + local t={ 8,9,"a","b" } + function os.uuid() + return format("%04x%04x-4%03x-%s%03x-%04x-%04x%04x%04x", + random(0xFFFF),random(0xFFFF), + random(0x0FFF), + t[ceil(random(4))] or 8,random(0x0FFF), + random(0xFFFF), + random(0xFFFF),random(0xFFFF),random(0xFFFF) + ) + end end -local d -function os.timezone(delta) - d=d or ((tonumber(date("%H")) or 0)-(tonumber(date("!%H")) or 0)) - if delta then - if d>0 then - return format("+%02i:00",d) +do + local d + function os.timezone(delta) + d=d or ((tonumber(date("%H")) or 0)-(tonumber(date("!%H")) or 0)) + if delta then + if d>0 then + return format("+%02i:00",d) + else + return format("-%02i:00",-d) + end else - return format("-%02i:00",-d) + return 1 end - else - return 1 end -end -local timeformat=format("%%s%s",os.timezone(true)) -local dateformat="!%Y-%m-%d %H:%M:%S" -local lasttime=nil -local lastdate=nil -function os.fulltime(t,default) - t=t and tonumber(t) or 0 - if t>0 then - elseif default then - return default - else - t=time() + local timeformat=format("%%s%s",os.timezone(true)) + local dateformat="!%Y-%m-%d %H:%M:%S" + local lasttime=nil + local lastdate=nil + function os.fulltime(t,default) + t=t and tonumber(t) or 0 + if t>0 then + elseif default then + return default + else + t=time() + end + if t~=lasttime then + lasttime=t + lastdate=format(timeformat,date(dateformat)) + end + return lastdate end - if t~=lasttime then - lasttime=t - lastdate=format(timeformat,date(dateformat)) + local dateformat="%Y-%m-%d %H:%M:%S" + local lasttime=nil + local lastdate=nil + function os.localtime(t,default) + t=t and tonumber(t) or 0 + if t>0 then + elseif default then + return default + else + t=time() + end + if t~=lasttime then + lasttime=t + lastdate=date(dateformat,t) + end + return lastdate end - return lastdate -end -local dateformat="%Y-%m-%d %H:%M:%S" -local lasttime=nil -local lastdate=nil -function os.localtime(t,default) - t=t and tonumber(t) or 0 - if t>0 then - elseif default then - return default - else - t=time() + function os.converttime(t,default) + local t=tonumber(t) + if t and t>0 then + return date(dateformat,t) + else + return default or "-" + end end - if t~=lasttime then - lasttime=t - lastdate=date(dateformat,t) + function os.today() + return date("!*t") end - return lastdate -end -function os.converttime(t,default) - local t=tonumber(t) - if t and t>0 then - return date(dateformat,t) - else - return default or "-" + function os.now() + return date("!%Y-%m-%d %H:%M:%S") end end -local memory={} -local function which(filename) - local fullname=memory[filename] - if fullname==nil then - local suffix=file.suffix(filename) - local suffixes=suffix=="" and os.binsuffixes or { suffix } - for directory in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do - local df=file.join(directory,filename) - for i=1,#suffixes do - local dfs=file.addsuffix(df,suffixes[i]) - if io.exists(dfs) then - fullname=dfs - break +do + local cache={} + local function which(filename) + local fullname=cache[filename] + if fullname==nil then + local suffix=file.suffix(filename) + local suffixes=suffix=="" and os.binsuffixes or { suffix } + for directory in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do + local df=file.join(directory,filename) + for i=1,#suffixes do + local dfs=file.addsuffix(df,suffixes[i]) + if io.exists(dfs) then + fullname=dfs + break + end end end + if not fullname then + fullname=false + end + cache[filename]=fullname end - if not fullname then - fullname=false - end - memory[filename]=fullname + return fullname end - return fullname -end -os.which=which -os.where=which -function os.today() - return date("!*t") -end -function os.now() - return date("!%Y-%m-%d %H:%M:%S") + os.which=which + os.where=which end if not os.sleep then local socket=socket @@ -4229,65 +4211,69 @@ if not os.sleep then socket.sleep(n) end end -local function isleapyear(year) - return (year%4==0) and (year%100~=0 or year%400==0) -end -os.isleapyear=isleapyear -local days={ 31,28,31,30,31,30,31,31,30,31,30,31 } -local function nofdays(year,month,day) - if not month then - return isleapyear(year) and 365 or 364 - elseif not day then - return month==2 and isleapyear(year) and 29 or days[month] - else - for i=1,month-1 do - day=day+days[i] - end - if month>2 and isleapyear(year) then - day=day+1 +do + local function isleapyear(year) + return (year%4==0) and (year%100~=0 or year%400==0) + end + os.isleapyear=isleapyear + local days={ 31,28,31,30,31,30,31,31,30,31,30,31 } + local function nofdays(year,month,day) + if not month then + return isleapyear(year) and 365 or 364 + elseif not day then + return month==2 and isleapyear(year) and 29 or days[month] + else + for i=1,month-1 do + day=day+days[i] + end + if month>2 and isleapyear(year) then + day=day+1 + end + return day end - return day end -end -os.nofdays=nofdays -function os.weekday(day,month,year) - return date("%w",time { year=year,month=month,day=day })+1 -end -function os.validdate(year,month,day) - if month<1 then - month=1 - elseif month>12 then - month=12 + os.nofdays=nofdays + function os.weekday(day,month,year) + return date("%w",time { year=year,month=month,day=day })+1 end - if day<1 then - day=1 - else - local max=nofdays(year,month) - if day>max then - day=max + function os.validdate(year,month,day) + if month<1 then + month=1 + elseif month>12 then + month=12 + end + if day<1 then + day=1 + else + local max=nofdays(year,month) + if day>max then + day=max + end end + return year,month,day end - return year,month,day -end -function os.date(fmt,...) - if not fmt then - fmt="%Y-%m-%d %H:%M" + function os.date(fmt,...) + if not fmt then + fmt="%Y-%m-%d %H:%M" + end + return date(fmt,...) end - return date(fmt,...) end -local osexit=os.exit -local exitcode=nil -function os.setexitcode(code) - exitcode=code -end -function os.exit(c) - if exitcode~=nil then - return osexit(exitcode) +do + local osexit=os.exit + local exitcode=nil + function os.setexitcode(code) + exitcode=code end - if c~=nil then - return osexit(c) + function os.exit(c) + if exitcode~=nil then + return osexit(exitcode) + end + if c~=nil then + return osexit(c) + end + return osexit() end - return osexit() end @@ -15705,7 +15691,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-zip"] = package.loaded["util-zip"] or true --- original size: 23162, stripped down to: 13844 +-- original size: 23104, stripped down to: 14029 if not modules then modules={} end modules ['util-zip']={ version=1.001, @@ -15714,12 +15700,14 @@ if not modules then modules={} end modules ['util-zip']={ license="see context related readme files" } local type,tostring,tonumber=type,tostring,tonumber -local sort=table.sort +local sort,concat=table.sort,table.concat local find,format,sub,gsub=string.find,string.format,string.sub,string.gsub local osdate,ostime,osclock=os.date,os.time,os.clock local ioopen=io.open local loaddata,savedata=io.loaddata,io.savedata local filejoin,isdir,dirname,mkdirs=file.join,lfs.isdir,file.dirname,dir.mkdirs +local suffix,suffixes=file.suffix,file.suffixes +local openfile=io.open gzip=gzip or {} if not zlib then zlib=xzip @@ -16132,16 +16120,31 @@ if xzip then zipfiles.zipdir=zipdir zipfiles.unzipdir=unzipdir end -if not gzip.compress then - local suffix=file.suffix - local suffixes=file.suffixes - local find=string.find - local concat=table.concat - local openfile=io.open +local pattern="^\x1F\x8B\x08" +local gziplevel=3 +function gzip.suffix(filename) + local suffix,extra=suffixes(filename) + local gzipped=extra=="gz" + return suffix,gzipped +end +function gzip.compressed(s) + return s and find(s,pattern) +end +local getdecompressed +local putcompressed +if gzip.compress then + local gzipwindow=15+16 + local compress=zlib.compress + local decompress=zlib.decompress + getdecompressed=function(str) + return decompress(str,gzipwindow) + end + putcompressed=function(str,level) + return compress(str,level or gziplevel,nil,gzipwindow) + end +else local gzipwindow=-15 - local gziplevel=3 local identifier="\x1F\x8B" - local pattern="^\x1F\x8B\x08" local compress=zlib.compress local decompress=zlib.decompress local crc32=zlib.crc32 @@ -16157,7 +16160,7 @@ if not gzip.compress then local skipbytes=streams.skip local tocardinal1=streams.tocardinal1 local tocardinal4=streams.tocardinal4le - local function getdecompressed(str) + getdecompressed=function(str) local s=openstream(str) local identifier=readstring(s,2) local method=readbyte(s,1) @@ -16174,7 +16177,7 @@ if not gzip.compress then local data=decompress(compressed,gzipwindow) return data end - local function putcompressed(str,level,originalname) + putcompressed=function(str,level,originalname) return concat { identifier, tocardinal1(0x08), @@ -16188,58 +16191,50 @@ if not gzip.compress then tocardinal4(#str), } end - function gzip.load(filename) - local f=openfile(filename,"rb") - if not f then - else - local data=f:read("*all") - f:close() - if data and data~="" then - if suffix(filename)=="gz" then - data=getdecompressed(data) - end - return data +end +function gzip.load(filename) + local f=openfile(filename,"rb") + if not f then + else + local data=f:read("*all") + f:close() + if data and data~="" then + if suffix(filename)=="gz" then + data=getdecompressed(data) end + return data end end - function gzip.save(filename,data,level,originalname) - if suffix(filename)~="gz" then - filename=filename..".gz" - end - local f=openfile(filename,"wb") - if f then - data=putcompressed(data or "",level or gziplevel,originalname) - f:write(data) - f:close() - return #data - end - end - function gzip.suffix(filename) - local suffix,extra=suffixes(filename) - local gzipped=extra=="gz" - return suffix,gzipped - end - function gzip.compressed(s) - return s and find(s,identifier) +end +function gzip.save(filename,data,level,originalname) + if suffix(filename)~="gz" then + filename=filename..".gz" end - function gzip.compress(s,level) - if s and not find(s,identifier) then - if not level then - level=gziplevel - elseif level<=0 then - return s - elseif level>9 then - level=9 - end - return putcompressed(s,level or gziplevel) or s - end + local f=openfile(filename,"wb") + if f then + data=putcompressed(data or "",level or gziplevel,originalname) + f:write(data) + f:close() + return #data end - function gzip.decompress(s) - if s and find(s,identifier) then - return getdecompressed(s) - else +end +function gzip.compress(s,level) + if s and not find(s,pattern) then + if not level then + level=gziplevel + elseif level<=0 then return s + elseif level>9 then + level=9 end + return putcompressed(s,level or gziplevel) or s + end +end +function gzip.decompress(s) + if s and find(s,pattern) then + return getdecompressed(s) + else + return s end end zipfiles.gunzipfile=gzip.load @@ -25897,8 +25892,8 @@ end -- of closure -- used libraries : l-bit32.lua 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-sha.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 util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.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 util-zip.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 libs-ini.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 1024388 --- stripped bytes : 402181 +-- original bytes : 1024470 +-- stripped bytes : 402069 -- end library merge diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 2317496b5..40ac12fe8 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -3837,7 +3837,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-os"] = package.loaded["l-os"] or true --- original size: 19514, stripped down to: 10470 +-- original size: 19654, stripped down to: 10479 if not modules then modules={} end modules ['l-os']={ version=1.001, @@ -3980,245 +3980,227 @@ if os.type=="windows" then else os.libsuffix,os.binsuffix,os.binsuffixes='so','',{ '' } end -local execute=os.execute -local iopopen=io.popen -local ostype=os.type -local function resultof(command) - local handle=iopopen(command,ostype=="windows" and "rb" or "r") - if handle then - local result=handle:read("*all") or "" - handle:close() - return result - else - return "" +do + local execute=os.execute + local iopopen=io.popen + local ostype=os.type + local function resultof(command) + local handle=iopopen(command,ostype=="windows" and "rb" or "r") + if handle then + local result=handle:read("*all") or "" + handle:close() + return result + else + return "" + end + end + os.resultof=resultof + function os.pipeto(command) + return iopopen(command,"w") + end + local launchers={ + windows="start %s", + macosx="open %s", + unix="xdg-open %s &> /dev/null &", + } + function os.launch(str) + local command=format(launchers[os.name] or launchers.unix,str) + execute(command) end end -os.resultof=resultof -function os.pipeto(command) - return iopopen(command,"w") +do + local gettimeofday=os.gettimeofday or os.clock + os.gettimeofday=gettimeofday + local startuptime=gettimeofday() + function os.runtime() + return gettimeofday()-startuptime + end end -local launchers={ - windows="start %s", - macosx="open %s", - unix="xdg-open %s &> /dev/null &", -} -function os.launch(str) - local command=format(launchers[os.name] or launchers.unix,str) - execute(command) -end -local gettimeofday=os.gettimeofday or os.clock -os.gettimeofday=gettimeofday -local startuptime=gettimeofday() -function os.runtime() - return gettimeofday()-startuptime -end -local resolvers=os.resolvers or {} -os.resolvers=resolvers -setmetatable(os,{ __index=function(t,k) - local r=resolvers[k] - return r and r(t,k) or nil -end }) -local name,platform=os.name or "linux",os.getenv("MTX_PLATFORM") or "" -if platform~="" then - os.platform=platform -elseif os.type=="windows" then - function resolvers.platform(t,k) - local architecture=os.getenv("PROCESSOR_ARCHITECTURE") or "" - local platform="" - if find(architecture,"AMD64",1,true) then - platform="win64" +do + local name=os.name or "linux" + local platform=os.getenv("MTX_PLATFORM") or "" + local architecture=os.uname and os.uname().machine + local bits=os.getenv("MTX_BITS") or find(platform,"64") and 64 or 32 + if platform~="" then + elseif os.type=="windows" then + architecture=architecture or os.getenv("PROCESSOR_ARCHITECTURE") or "" + if architecture=="x86_64" then + bits,platform=64,"win64" + elseif find(architecture,"AMD64") then + bits,platform=64,"win64" + elseif find(architecture,"ARM64") then + bits,platform=64,"windows-arm64" + elseif find(architecture,"ARM32") then + bits,platform=32,"windows-arm32" else - platform="mswin" + bits,platform=32,"mswin" end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="linux" then - function resolvers.platform(t,k) - local architecture=os.getenv("HOSTTYPE") or resultof("uname -m") or "" - local platform=os.getenv("MTX_PLATFORM") or "" + elseif name=="linux" then + architecture=architecture or os.getenv("HOSTTYPE") or resultof("uname -m") or "" local musl=find(os.selfdir or "","linuxmusl") - if platform~="" then - elseif find(architecture,"x86_64",1,true) then - platform=musl and "linuxmusl" or "linux-64" - elseif find(architecture,"ppc",1,true) then - platform="linux-ppc" + if find(architecture,"x86_64") then + bits,platform=64,musl and "linuxmusl" or "linux-64" + elseif find(architecture,"ppc") then + bits,platform=32,"linux-ppc" else - platform=musl and "linuxmusl" or "linux" + bits,platform=32,musl and "linuxmusl" or "linux" end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="macosx" then - function resolvers.platform(t,k) - local architecture=resultof("echo $HOSTTYPE") or "" - local platform="" + elseif name=="macosx" then + architecture=architecture or resultof("echo $HOSTTYPE") or "" if architecture=="" then - platform="osx-intel" - elseif find(architecture,"i386",1,true) then - platform="osx-intel" - elseif find(architecture,"x86_64",1,true) then - platform="osx-64" - elseif find(architecture,"arm64",1,true) then - platform="osx-arm" + bits,platform=64,"osx-intel" + elseif find(architecture,"i386") then + bits,platform=64,"osx-intel" + elseif find(architecture,"x86_64") then + bits,platform=64,"osx-64" + elseif find(architecture,"arm64") then + bits,platform=64,"osx-arm" else - platform="osx-ppc" - end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="sunos" then - function resolvers.platform(t,k) - local architecture=resultof("uname -m") or "" - local platform="" - if find(architecture,"sparc",1,true) then - platform="solaris-sparc" + bits,platform=32,"osx-ppc" + end + elseif name=="sunos" then + architecture=architecture or resultof("uname -m") or "" + if find(architecture,"sparc") then + bits,platform=32,"solaris-sparc" else - platform="solaris-intel" - end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="freebsd" then - function resolvers.platform(t,k) - local architecture=resultof("uname -m") or "" - local platform="" - if find(architecture,"amd64",1,true) then - platform="freebsd-amd64" + bits,platform=32,"solaris-intel" + end + elseif name=="freebsd" then + architecture=architecture or resultof("uname -m") or "" + if find(architecture)=="amd64" or find(architecture)=="AMD64" then + bits,platform=64,"freebsd-amd64" + else + bits,platform=32,"freebsd" + end + elseif name=="kfreebsd" then + architecture=architecture or os.getenv("HOSTTYPE") or resultof("uname -m") or "" + if architecture=="x86_64" then + bits,platform=64,"kfreebsd-amd64" else - platform="freebsd" - end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="kfreebsd" then - function resolvers.platform(t,k) - local architecture=os.getenv("HOSTTYPE") or resultof("uname -m") or "" - local platform="" - if find(architecture,"x86_64",1,true) then - platform="kfreebsd-amd64" + bits,platform=32,"kfreebsd-i386" + end + else + architecture=architecture or resultof("uname -m") or "" + if find(architecture,"aarch64") then + bits,platform="linux-aarch64" + elseif find(architecture,"armv7l") then + bits,platform=32,"linux-armhf" + elseif find(architecture,"mips64") or find(architecture,"mips64el") then + bits,platform=64,"linux-mipsel" + elseif find(architecture,"mipsel") or find(architecture,"mips") then + bits,platform=32,"linux-mipsel" else - platform="kfreebsd-i386" + bits,platform=64,"linux-64" end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -else - function resolvers.platform(t,k) - local platform="linux" - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform end -end -os.newline=name=="windows" and "\013\010" or "\010" -function resolvers.bits(t,k) - local bits=find(os.platform,"64",1,true) and 64 or 32 + os.setenv("MTX_PLATFORM",platform) + os.setenv("MTX_BITS",bits) + os.platform=platform os.bits=bits - return bits -end -local t={ 8,9,"a","b" } -function os.uuid() - return format("%04x%04x-4%03x-%s%03x-%04x-%04x%04x%04x", - random(0xFFFF),random(0xFFFF), - random(0x0FFF), - t[ceil(random(4))] or 8,random(0x0FFF), - random(0xFFFF), - random(0xFFFF),random(0xFFFF),random(0xFFFF) - ) + os.newline=name=="windows" and "\013\010" or "\010" +end +do + local t={ 8,9,"a","b" } + function os.uuid() + return format("%04x%04x-4%03x-%s%03x-%04x-%04x%04x%04x", + random(0xFFFF),random(0xFFFF), + random(0x0FFF), + t[ceil(random(4))] or 8,random(0x0FFF), + random(0xFFFF), + random(0xFFFF),random(0xFFFF),random(0xFFFF) + ) + end end -local d -function os.timezone(delta) - d=d or ((tonumber(date("%H")) or 0)-(tonumber(date("!%H")) or 0)) - if delta then - if d>0 then - return format("+%02i:00",d) +do + local d + function os.timezone(delta) + d=d or ((tonumber(date("%H")) or 0)-(tonumber(date("!%H")) or 0)) + if delta then + if d>0 then + return format("+%02i:00",d) + else + return format("-%02i:00",-d) + end else - return format("-%02i:00",-d) + return 1 end - else - return 1 end -end -local timeformat=format("%%s%s",os.timezone(true)) -local dateformat="!%Y-%m-%d %H:%M:%S" -local lasttime=nil -local lastdate=nil -function os.fulltime(t,default) - t=t and tonumber(t) or 0 - if t>0 then - elseif default then - return default - else - t=time() + local timeformat=format("%%s%s",os.timezone(true)) + local dateformat="!%Y-%m-%d %H:%M:%S" + local lasttime=nil + local lastdate=nil + function os.fulltime(t,default) + t=t and tonumber(t) or 0 + if t>0 then + elseif default then + return default + else + t=time() + end + if t~=lasttime then + lasttime=t + lastdate=format(timeformat,date(dateformat)) + end + return lastdate end - if t~=lasttime then - lasttime=t - lastdate=format(timeformat,date(dateformat)) + local dateformat="%Y-%m-%d %H:%M:%S" + local lasttime=nil + local lastdate=nil + function os.localtime(t,default) + t=t and tonumber(t) or 0 + if t>0 then + elseif default then + return default + else + t=time() + end + if t~=lasttime then + lasttime=t + lastdate=date(dateformat,t) + end + return lastdate end - return lastdate -end -local dateformat="%Y-%m-%d %H:%M:%S" -local lasttime=nil -local lastdate=nil -function os.localtime(t,default) - t=t and tonumber(t) or 0 - if t>0 then - elseif default then - return default - else - t=time() + function os.converttime(t,default) + local t=tonumber(t) + if t and t>0 then + return date(dateformat,t) + else + return default or "-" + end end - if t~=lasttime then - lasttime=t - lastdate=date(dateformat,t) + function os.today() + return date("!*t") end - return lastdate -end -function os.converttime(t,default) - local t=tonumber(t) - if t and t>0 then - return date(dateformat,t) - else - return default or "-" + function os.now() + return date("!%Y-%m-%d %H:%M:%S") end end -local memory={} -local function which(filename) - local fullname=memory[filename] - if fullname==nil then - local suffix=file.suffix(filename) - local suffixes=suffix=="" and os.binsuffixes or { suffix } - for directory in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do - local df=file.join(directory,filename) - for i=1,#suffixes do - local dfs=file.addsuffix(df,suffixes[i]) - if io.exists(dfs) then - fullname=dfs - break +do + local cache={} + local function which(filename) + local fullname=cache[filename] + if fullname==nil then + local suffix=file.suffix(filename) + local suffixes=suffix=="" and os.binsuffixes or { suffix } + for directory in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do + local df=file.join(directory,filename) + for i=1,#suffixes do + local dfs=file.addsuffix(df,suffixes[i]) + if io.exists(dfs) then + fullname=dfs + break + end end end + if not fullname then + fullname=false + end + cache[filename]=fullname end - if not fullname then - fullname=false - end - memory[filename]=fullname + return fullname end - return fullname -end -os.which=which -os.where=which -function os.today() - return date("!*t") -end -function os.now() - return date("!%Y-%m-%d %H:%M:%S") + os.which=which + os.where=which end if not os.sleep then local socket=socket @@ -4229,65 +4211,69 @@ if not os.sleep then socket.sleep(n) end end -local function isleapyear(year) - return (year%4==0) and (year%100~=0 or year%400==0) -end -os.isleapyear=isleapyear -local days={ 31,28,31,30,31,30,31,31,30,31,30,31 } -local function nofdays(year,month,day) - if not month then - return isleapyear(year) and 365 or 364 - elseif not day then - return month==2 and isleapyear(year) and 29 or days[month] - else - for i=1,month-1 do - day=day+days[i] - end - if month>2 and isleapyear(year) then - day=day+1 +do + local function isleapyear(year) + return (year%4==0) and (year%100~=0 or year%400==0) + end + os.isleapyear=isleapyear + local days={ 31,28,31,30,31,30,31,31,30,31,30,31 } + local function nofdays(year,month,day) + if not month then + return isleapyear(year) and 365 or 364 + elseif not day then + return month==2 and isleapyear(year) and 29 or days[month] + else + for i=1,month-1 do + day=day+days[i] + end + if month>2 and isleapyear(year) then + day=day+1 + end + return day end - return day end -end -os.nofdays=nofdays -function os.weekday(day,month,year) - return date("%w",time { year=year,month=month,day=day })+1 -end -function os.validdate(year,month,day) - if month<1 then - month=1 - elseif month>12 then - month=12 + os.nofdays=nofdays + function os.weekday(day,month,year) + return date("%w",time { year=year,month=month,day=day })+1 end - if day<1 then - day=1 - else - local max=nofdays(year,month) - if day>max then - day=max + function os.validdate(year,month,day) + if month<1 then + month=1 + elseif month>12 then + month=12 + end + if day<1 then + day=1 + else + local max=nofdays(year,month) + if day>max then + day=max + end end + return year,month,day end - return year,month,day -end -function os.date(fmt,...) - if not fmt then - fmt="%Y-%m-%d %H:%M" + function os.date(fmt,...) + if not fmt then + fmt="%Y-%m-%d %H:%M" + end + return date(fmt,...) end - return date(fmt,...) end -local osexit=os.exit -local exitcode=nil -function os.setexitcode(code) - exitcode=code -end -function os.exit(c) - if exitcode~=nil then - return osexit(exitcode) +do + local osexit=os.exit + local exitcode=nil + function os.setexitcode(code) + exitcode=code end - if c~=nil then - return osexit(c) + function os.exit(c) + if exitcode~=nil then + return osexit(exitcode) + end + if c~=nil then + return osexit(c) + end + return osexit() end - return osexit() end @@ -15705,7 +15691,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-zip"] = package.loaded["util-zip"] or true --- original size: 23162, stripped down to: 13844 +-- original size: 23104, stripped down to: 14029 if not modules then modules={} end modules ['util-zip']={ version=1.001, @@ -15714,12 +15700,14 @@ if not modules then modules={} end modules ['util-zip']={ license="see context related readme files" } local type,tostring,tonumber=type,tostring,tonumber -local sort=table.sort +local sort,concat=table.sort,table.concat local find,format,sub,gsub=string.find,string.format,string.sub,string.gsub local osdate,ostime,osclock=os.date,os.time,os.clock local ioopen=io.open local loaddata,savedata=io.loaddata,io.savedata local filejoin,isdir,dirname,mkdirs=file.join,lfs.isdir,file.dirname,dir.mkdirs +local suffix,suffixes=file.suffix,file.suffixes +local openfile=io.open gzip=gzip or {} if not zlib then zlib=xzip @@ -16132,16 +16120,31 @@ if xzip then zipfiles.zipdir=zipdir zipfiles.unzipdir=unzipdir end -if not gzip.compress then - local suffix=file.suffix - local suffixes=file.suffixes - local find=string.find - local concat=table.concat - local openfile=io.open +local pattern="^\x1F\x8B\x08" +local gziplevel=3 +function gzip.suffix(filename) + local suffix,extra=suffixes(filename) + local gzipped=extra=="gz" + return suffix,gzipped +end +function gzip.compressed(s) + return s and find(s,pattern) +end +local getdecompressed +local putcompressed +if gzip.compress then + local gzipwindow=15+16 + local compress=zlib.compress + local decompress=zlib.decompress + getdecompressed=function(str) + return decompress(str,gzipwindow) + end + putcompressed=function(str,level) + return compress(str,level or gziplevel,nil,gzipwindow) + end +else local gzipwindow=-15 - local gziplevel=3 local identifier="\x1F\x8B" - local pattern="^\x1F\x8B\x08" local compress=zlib.compress local decompress=zlib.decompress local crc32=zlib.crc32 @@ -16157,7 +16160,7 @@ if not gzip.compress then local skipbytes=streams.skip local tocardinal1=streams.tocardinal1 local tocardinal4=streams.tocardinal4le - local function getdecompressed(str) + getdecompressed=function(str) local s=openstream(str) local identifier=readstring(s,2) local method=readbyte(s,1) @@ -16174,7 +16177,7 @@ if not gzip.compress then local data=decompress(compressed,gzipwindow) return data end - local function putcompressed(str,level,originalname) + putcompressed=function(str,level,originalname) return concat { identifier, tocardinal1(0x08), @@ -16188,58 +16191,50 @@ if not gzip.compress then tocardinal4(#str), } end - function gzip.load(filename) - local f=openfile(filename,"rb") - if not f then - else - local data=f:read("*all") - f:close() - if data and data~="" then - if suffix(filename)=="gz" then - data=getdecompressed(data) - end - return data +end +function gzip.load(filename) + local f=openfile(filename,"rb") + if not f then + else + local data=f:read("*all") + f:close() + if data and data~="" then + if suffix(filename)=="gz" then + data=getdecompressed(data) end + return data end end - function gzip.save(filename,data,level,originalname) - if suffix(filename)~="gz" then - filename=filename..".gz" - end - local f=openfile(filename,"wb") - if f then - data=putcompressed(data or "",level or gziplevel,originalname) - f:write(data) - f:close() - return #data - end - end - function gzip.suffix(filename) - local suffix,extra=suffixes(filename) - local gzipped=extra=="gz" - return suffix,gzipped - end - function gzip.compressed(s) - return s and find(s,identifier) +end +function gzip.save(filename,data,level,originalname) + if suffix(filename)~="gz" then + filename=filename..".gz" end - function gzip.compress(s,level) - if s and not find(s,identifier) then - if not level then - level=gziplevel - elseif level<=0 then - return s - elseif level>9 then - level=9 - end - return putcompressed(s,level or gziplevel) or s - end + local f=openfile(filename,"wb") + if f then + data=putcompressed(data or "",level or gziplevel,originalname) + f:write(data) + f:close() + return #data end - function gzip.decompress(s) - if s and find(s,identifier) then - return getdecompressed(s) - else +end +function gzip.compress(s,level) + if s and not find(s,pattern) then + if not level then + level=gziplevel + elseif level<=0 then return s + elseif level>9 then + level=9 end + return putcompressed(s,level or gziplevel) or s + end +end +function gzip.decompress(s) + if s and find(s,pattern) then + return getdecompressed(s) + else + return s end end zipfiles.gunzipfile=gzip.load @@ -25897,8 +25892,8 @@ end -- of closure -- used libraries : l-bit32.lua 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-sha.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 util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.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 util-zip.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 libs-ini.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 1024388 --- stripped bytes : 402181 +-- original bytes : 1024470 +-- stripped bytes : 402069 -- end library merge diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 2317496b5..40ac12fe8 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -3837,7 +3837,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-os"] = package.loaded["l-os"] or true --- original size: 19514, stripped down to: 10470 +-- original size: 19654, stripped down to: 10479 if not modules then modules={} end modules ['l-os']={ version=1.001, @@ -3980,245 +3980,227 @@ if os.type=="windows" then else os.libsuffix,os.binsuffix,os.binsuffixes='so','',{ '' } end -local execute=os.execute -local iopopen=io.popen -local ostype=os.type -local function resultof(command) - local handle=iopopen(command,ostype=="windows" and "rb" or "r") - if handle then - local result=handle:read("*all") or "" - handle:close() - return result - else - return "" +do + local execute=os.execute + local iopopen=io.popen + local ostype=os.type + local function resultof(command) + local handle=iopopen(command,ostype=="windows" and "rb" or "r") + if handle then + local result=handle:read("*all") or "" + handle:close() + return result + else + return "" + end + end + os.resultof=resultof + function os.pipeto(command) + return iopopen(command,"w") + end + local launchers={ + windows="start %s", + macosx="open %s", + unix="xdg-open %s &> /dev/null &", + } + function os.launch(str) + local command=format(launchers[os.name] or launchers.unix,str) + execute(command) end end -os.resultof=resultof -function os.pipeto(command) - return iopopen(command,"w") +do + local gettimeofday=os.gettimeofday or os.clock + os.gettimeofday=gettimeofday + local startuptime=gettimeofday() + function os.runtime() + return gettimeofday()-startuptime + end end -local launchers={ - windows="start %s", - macosx="open %s", - unix="xdg-open %s &> /dev/null &", -} -function os.launch(str) - local command=format(launchers[os.name] or launchers.unix,str) - execute(command) -end -local gettimeofday=os.gettimeofday or os.clock -os.gettimeofday=gettimeofday -local startuptime=gettimeofday() -function os.runtime() - return gettimeofday()-startuptime -end -local resolvers=os.resolvers or {} -os.resolvers=resolvers -setmetatable(os,{ __index=function(t,k) - local r=resolvers[k] - return r and r(t,k) or nil -end }) -local name,platform=os.name or "linux",os.getenv("MTX_PLATFORM") or "" -if platform~="" then - os.platform=platform -elseif os.type=="windows" then - function resolvers.platform(t,k) - local architecture=os.getenv("PROCESSOR_ARCHITECTURE") or "" - local platform="" - if find(architecture,"AMD64",1,true) then - platform="win64" +do + local name=os.name or "linux" + local platform=os.getenv("MTX_PLATFORM") or "" + local architecture=os.uname and os.uname().machine + local bits=os.getenv("MTX_BITS") or find(platform,"64") and 64 or 32 + if platform~="" then + elseif os.type=="windows" then + architecture=architecture or os.getenv("PROCESSOR_ARCHITECTURE") or "" + if architecture=="x86_64" then + bits,platform=64,"win64" + elseif find(architecture,"AMD64") then + bits,platform=64,"win64" + elseif find(architecture,"ARM64") then + bits,platform=64,"windows-arm64" + elseif find(architecture,"ARM32") then + bits,platform=32,"windows-arm32" else - platform="mswin" + bits,platform=32,"mswin" end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="linux" then - function resolvers.platform(t,k) - local architecture=os.getenv("HOSTTYPE") or resultof("uname -m") or "" - local platform=os.getenv("MTX_PLATFORM") or "" + elseif name=="linux" then + architecture=architecture or os.getenv("HOSTTYPE") or resultof("uname -m") or "" local musl=find(os.selfdir or "","linuxmusl") - if platform~="" then - elseif find(architecture,"x86_64",1,true) then - platform=musl and "linuxmusl" or "linux-64" - elseif find(architecture,"ppc",1,true) then - platform="linux-ppc" + if find(architecture,"x86_64") then + bits,platform=64,musl and "linuxmusl" or "linux-64" + elseif find(architecture,"ppc") then + bits,platform=32,"linux-ppc" else - platform=musl and "linuxmusl" or "linux" + bits,platform=32,musl and "linuxmusl" or "linux" end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="macosx" then - function resolvers.platform(t,k) - local architecture=resultof("echo $HOSTTYPE") or "" - local platform="" + elseif name=="macosx" then + architecture=architecture or resultof("echo $HOSTTYPE") or "" if architecture=="" then - platform="osx-intel" - elseif find(architecture,"i386",1,true) then - platform="osx-intel" - elseif find(architecture,"x86_64",1,true) then - platform="osx-64" - elseif find(architecture,"arm64",1,true) then - platform="osx-arm" + bits,platform=64,"osx-intel" + elseif find(architecture,"i386") then + bits,platform=64,"osx-intel" + elseif find(architecture,"x86_64") then + bits,platform=64,"osx-64" + elseif find(architecture,"arm64") then + bits,platform=64,"osx-arm" else - platform="osx-ppc" - end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="sunos" then - function resolvers.platform(t,k) - local architecture=resultof("uname -m") or "" - local platform="" - if find(architecture,"sparc",1,true) then - platform="solaris-sparc" + bits,platform=32,"osx-ppc" + end + elseif name=="sunos" then + architecture=architecture or resultof("uname -m") or "" + if find(architecture,"sparc") then + bits,platform=32,"solaris-sparc" else - platform="solaris-intel" - end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="freebsd" then - function resolvers.platform(t,k) - local architecture=resultof("uname -m") or "" - local platform="" - if find(architecture,"amd64",1,true) then - platform="freebsd-amd64" + bits,platform=32,"solaris-intel" + end + elseif name=="freebsd" then + architecture=architecture or resultof("uname -m") or "" + if find(architecture)=="amd64" or find(architecture)=="AMD64" then + bits,platform=64,"freebsd-amd64" + else + bits,platform=32,"freebsd" + end + elseif name=="kfreebsd" then + architecture=architecture or os.getenv("HOSTTYPE") or resultof("uname -m") or "" + if architecture=="x86_64" then + bits,platform=64,"kfreebsd-amd64" else - platform="freebsd" - end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="kfreebsd" then - function resolvers.platform(t,k) - local architecture=os.getenv("HOSTTYPE") or resultof("uname -m") or "" - local platform="" - if find(architecture,"x86_64",1,true) then - platform="kfreebsd-amd64" + bits,platform=32,"kfreebsd-i386" + end + else + architecture=architecture or resultof("uname -m") or "" + if find(architecture,"aarch64") then + bits,platform="linux-aarch64" + elseif find(architecture,"armv7l") then + bits,platform=32,"linux-armhf" + elseif find(architecture,"mips64") or find(architecture,"mips64el") then + bits,platform=64,"linux-mipsel" + elseif find(architecture,"mipsel") or find(architecture,"mips") then + bits,platform=32,"linux-mipsel" else - platform="kfreebsd-i386" + bits,platform=64,"linux-64" end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -else - function resolvers.platform(t,k) - local platform="linux" - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform end -end -os.newline=name=="windows" and "\013\010" or "\010" -function resolvers.bits(t,k) - local bits=find(os.platform,"64",1,true) and 64 or 32 + os.setenv("MTX_PLATFORM",platform) + os.setenv("MTX_BITS",bits) + os.platform=platform os.bits=bits - return bits -end -local t={ 8,9,"a","b" } -function os.uuid() - return format("%04x%04x-4%03x-%s%03x-%04x-%04x%04x%04x", - random(0xFFFF),random(0xFFFF), - random(0x0FFF), - t[ceil(random(4))] or 8,random(0x0FFF), - random(0xFFFF), - random(0xFFFF),random(0xFFFF),random(0xFFFF) - ) + os.newline=name=="windows" and "\013\010" or "\010" +end +do + local t={ 8,9,"a","b" } + function os.uuid() + return format("%04x%04x-4%03x-%s%03x-%04x-%04x%04x%04x", + random(0xFFFF),random(0xFFFF), + random(0x0FFF), + t[ceil(random(4))] or 8,random(0x0FFF), + random(0xFFFF), + random(0xFFFF),random(0xFFFF),random(0xFFFF) + ) + end end -local d -function os.timezone(delta) - d=d or ((tonumber(date("%H")) or 0)-(tonumber(date("!%H")) or 0)) - if delta then - if d>0 then - return format("+%02i:00",d) +do + local d + function os.timezone(delta) + d=d or ((tonumber(date("%H")) or 0)-(tonumber(date("!%H")) or 0)) + if delta then + if d>0 then + return format("+%02i:00",d) + else + return format("-%02i:00",-d) + end else - return format("-%02i:00",-d) + return 1 end - else - return 1 end -end -local timeformat=format("%%s%s",os.timezone(true)) -local dateformat="!%Y-%m-%d %H:%M:%S" -local lasttime=nil -local lastdate=nil -function os.fulltime(t,default) - t=t and tonumber(t) or 0 - if t>0 then - elseif default then - return default - else - t=time() + local timeformat=format("%%s%s",os.timezone(true)) + local dateformat="!%Y-%m-%d %H:%M:%S" + local lasttime=nil + local lastdate=nil + function os.fulltime(t,default) + t=t and tonumber(t) or 0 + if t>0 then + elseif default then + return default + else + t=time() + end + if t~=lasttime then + lasttime=t + lastdate=format(timeformat,date(dateformat)) + end + return lastdate end - if t~=lasttime then - lasttime=t - lastdate=format(timeformat,date(dateformat)) + local dateformat="%Y-%m-%d %H:%M:%S" + local lasttime=nil + local lastdate=nil + function os.localtime(t,default) + t=t and tonumber(t) or 0 + if t>0 then + elseif default then + return default + else + t=time() + end + if t~=lasttime then + lasttime=t + lastdate=date(dateformat,t) + end + return lastdate end - return lastdate -end -local dateformat="%Y-%m-%d %H:%M:%S" -local lasttime=nil -local lastdate=nil -function os.localtime(t,default) - t=t and tonumber(t) or 0 - if t>0 then - elseif default then - return default - else - t=time() + function os.converttime(t,default) + local t=tonumber(t) + if t and t>0 then + return date(dateformat,t) + else + return default or "-" + end end - if t~=lasttime then - lasttime=t - lastdate=date(dateformat,t) + function os.today() + return date("!*t") end - return lastdate -end -function os.converttime(t,default) - local t=tonumber(t) - if t and t>0 then - return date(dateformat,t) - else - return default or "-" + function os.now() + return date("!%Y-%m-%d %H:%M:%S") end end -local memory={} -local function which(filename) - local fullname=memory[filename] - if fullname==nil then - local suffix=file.suffix(filename) - local suffixes=suffix=="" and os.binsuffixes or { suffix } - for directory in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do - local df=file.join(directory,filename) - for i=1,#suffixes do - local dfs=file.addsuffix(df,suffixes[i]) - if io.exists(dfs) then - fullname=dfs - break +do + local cache={} + local function which(filename) + local fullname=cache[filename] + if fullname==nil then + local suffix=file.suffix(filename) + local suffixes=suffix=="" and os.binsuffixes or { suffix } + for directory in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do + local df=file.join(directory,filename) + for i=1,#suffixes do + local dfs=file.addsuffix(df,suffixes[i]) + if io.exists(dfs) then + fullname=dfs + break + end end end + if not fullname then + fullname=false + end + cache[filename]=fullname end - if not fullname then - fullname=false - end - memory[filename]=fullname + return fullname end - return fullname -end -os.which=which -os.where=which -function os.today() - return date("!*t") -end -function os.now() - return date("!%Y-%m-%d %H:%M:%S") + os.which=which + os.where=which end if not os.sleep then local socket=socket @@ -4229,65 +4211,69 @@ if not os.sleep then socket.sleep(n) end end -local function isleapyear(year) - return (year%4==0) and (year%100~=0 or year%400==0) -end -os.isleapyear=isleapyear -local days={ 31,28,31,30,31,30,31,31,30,31,30,31 } -local function nofdays(year,month,day) - if not month then - return isleapyear(year) and 365 or 364 - elseif not day then - return month==2 and isleapyear(year) and 29 or days[month] - else - for i=1,month-1 do - day=day+days[i] - end - if month>2 and isleapyear(year) then - day=day+1 +do + local function isleapyear(year) + return (year%4==0) and (year%100~=0 or year%400==0) + end + os.isleapyear=isleapyear + local days={ 31,28,31,30,31,30,31,31,30,31,30,31 } + local function nofdays(year,month,day) + if not month then + return isleapyear(year) and 365 or 364 + elseif not day then + return month==2 and isleapyear(year) and 29 or days[month] + else + for i=1,month-1 do + day=day+days[i] + end + if month>2 and isleapyear(year) then + day=day+1 + end + return day end - return day end -end -os.nofdays=nofdays -function os.weekday(day,month,year) - return date("%w",time { year=year,month=month,day=day })+1 -end -function os.validdate(year,month,day) - if month<1 then - month=1 - elseif month>12 then - month=12 + os.nofdays=nofdays + function os.weekday(day,month,year) + return date("%w",time { year=year,month=month,day=day })+1 end - if day<1 then - day=1 - else - local max=nofdays(year,month) - if day>max then - day=max + function os.validdate(year,month,day) + if month<1 then + month=1 + elseif month>12 then + month=12 + end + if day<1 then + day=1 + else + local max=nofdays(year,month) + if day>max then + day=max + end end + return year,month,day end - return year,month,day -end -function os.date(fmt,...) - if not fmt then - fmt="%Y-%m-%d %H:%M" + function os.date(fmt,...) + if not fmt then + fmt="%Y-%m-%d %H:%M" + end + return date(fmt,...) end - return date(fmt,...) end -local osexit=os.exit -local exitcode=nil -function os.setexitcode(code) - exitcode=code -end -function os.exit(c) - if exitcode~=nil then - return osexit(exitcode) +do + local osexit=os.exit + local exitcode=nil + function os.setexitcode(code) + exitcode=code end - if c~=nil then - return osexit(c) + function os.exit(c) + if exitcode~=nil then + return osexit(exitcode) + end + if c~=nil then + return osexit(c) + end + return osexit() end - return osexit() end @@ -15705,7 +15691,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-zip"] = package.loaded["util-zip"] or true --- original size: 23162, stripped down to: 13844 +-- original size: 23104, stripped down to: 14029 if not modules then modules={} end modules ['util-zip']={ version=1.001, @@ -15714,12 +15700,14 @@ if not modules then modules={} end modules ['util-zip']={ license="see context related readme files" } local type,tostring,tonumber=type,tostring,tonumber -local sort=table.sort +local sort,concat=table.sort,table.concat local find,format,sub,gsub=string.find,string.format,string.sub,string.gsub local osdate,ostime,osclock=os.date,os.time,os.clock local ioopen=io.open local loaddata,savedata=io.loaddata,io.savedata local filejoin,isdir,dirname,mkdirs=file.join,lfs.isdir,file.dirname,dir.mkdirs +local suffix,suffixes=file.suffix,file.suffixes +local openfile=io.open gzip=gzip or {} if not zlib then zlib=xzip @@ -16132,16 +16120,31 @@ if xzip then zipfiles.zipdir=zipdir zipfiles.unzipdir=unzipdir end -if not gzip.compress then - local suffix=file.suffix - local suffixes=file.suffixes - local find=string.find - local concat=table.concat - local openfile=io.open +local pattern="^\x1F\x8B\x08" +local gziplevel=3 +function gzip.suffix(filename) + local suffix,extra=suffixes(filename) + local gzipped=extra=="gz" + return suffix,gzipped +end +function gzip.compressed(s) + return s and find(s,pattern) +end +local getdecompressed +local putcompressed +if gzip.compress then + local gzipwindow=15+16 + local compress=zlib.compress + local decompress=zlib.decompress + getdecompressed=function(str) + return decompress(str,gzipwindow) + end + putcompressed=function(str,level) + return compress(str,level or gziplevel,nil,gzipwindow) + end +else local gzipwindow=-15 - local gziplevel=3 local identifier="\x1F\x8B" - local pattern="^\x1F\x8B\x08" local compress=zlib.compress local decompress=zlib.decompress local crc32=zlib.crc32 @@ -16157,7 +16160,7 @@ if not gzip.compress then local skipbytes=streams.skip local tocardinal1=streams.tocardinal1 local tocardinal4=streams.tocardinal4le - local function getdecompressed(str) + getdecompressed=function(str) local s=openstream(str) local identifier=readstring(s,2) local method=readbyte(s,1) @@ -16174,7 +16177,7 @@ if not gzip.compress then local data=decompress(compressed,gzipwindow) return data end - local function putcompressed(str,level,originalname) + putcompressed=function(str,level,originalname) return concat { identifier, tocardinal1(0x08), @@ -16188,58 +16191,50 @@ if not gzip.compress then tocardinal4(#str), } end - function gzip.load(filename) - local f=openfile(filename,"rb") - if not f then - else - local data=f:read("*all") - f:close() - if data and data~="" then - if suffix(filename)=="gz" then - data=getdecompressed(data) - end - return data +end +function gzip.load(filename) + local f=openfile(filename,"rb") + if not f then + else + local data=f:read("*all") + f:close() + if data and data~="" then + if suffix(filename)=="gz" then + data=getdecompressed(data) end + return data end end - function gzip.save(filename,data,level,originalname) - if suffix(filename)~="gz" then - filename=filename..".gz" - end - local f=openfile(filename,"wb") - if f then - data=putcompressed(data or "",level or gziplevel,originalname) - f:write(data) - f:close() - return #data - end - end - function gzip.suffix(filename) - local suffix,extra=suffixes(filename) - local gzipped=extra=="gz" - return suffix,gzipped - end - function gzip.compressed(s) - return s and find(s,identifier) +end +function gzip.save(filename,data,level,originalname) + if suffix(filename)~="gz" then + filename=filename..".gz" end - function gzip.compress(s,level) - if s and not find(s,identifier) then - if not level then - level=gziplevel - elseif level<=0 then - return s - elseif level>9 then - level=9 - end - return putcompressed(s,level or gziplevel) or s - end + local f=openfile(filename,"wb") + if f then + data=putcompressed(data or "",level or gziplevel,originalname) + f:write(data) + f:close() + return #data end - function gzip.decompress(s) - if s and find(s,identifier) then - return getdecompressed(s) - else +end +function gzip.compress(s,level) + if s and not find(s,pattern) then + if not level then + level=gziplevel + elseif level<=0 then return s + elseif level>9 then + level=9 end + return putcompressed(s,level or gziplevel) or s + end +end +function gzip.decompress(s) + if s and find(s,pattern) then + return getdecompressed(s) + else + return s end end zipfiles.gunzipfile=gzip.load @@ -25897,8 +25892,8 @@ end -- of closure -- used libraries : l-bit32.lua 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-sha.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 util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.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 util-zip.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 libs-ini.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 1024388 --- stripped bytes : 402181 +-- original bytes : 1024470 +-- stripped bytes : 402069 -- end library merge diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua index 2317496b5..40ac12fe8 100644 --- a/scripts/context/stubs/win64/mtxrun.lua +++ b/scripts/context/stubs/win64/mtxrun.lua @@ -3837,7 +3837,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-os"] = package.loaded["l-os"] or true --- original size: 19514, stripped down to: 10470 +-- original size: 19654, stripped down to: 10479 if not modules then modules={} end modules ['l-os']={ version=1.001, @@ -3980,245 +3980,227 @@ if os.type=="windows" then else os.libsuffix,os.binsuffix,os.binsuffixes='so','',{ '' } end -local execute=os.execute -local iopopen=io.popen -local ostype=os.type -local function resultof(command) - local handle=iopopen(command,ostype=="windows" and "rb" or "r") - if handle then - local result=handle:read("*all") or "" - handle:close() - return result - else - return "" +do + local execute=os.execute + local iopopen=io.popen + local ostype=os.type + local function resultof(command) + local handle=iopopen(command,ostype=="windows" and "rb" or "r") + if handle then + local result=handle:read("*all") or "" + handle:close() + return result + else + return "" + end + end + os.resultof=resultof + function os.pipeto(command) + return iopopen(command,"w") + end + local launchers={ + windows="start %s", + macosx="open %s", + unix="xdg-open %s &> /dev/null &", + } + function os.launch(str) + local command=format(launchers[os.name] or launchers.unix,str) + execute(command) end end -os.resultof=resultof -function os.pipeto(command) - return iopopen(command,"w") +do + local gettimeofday=os.gettimeofday or os.clock + os.gettimeofday=gettimeofday + local startuptime=gettimeofday() + function os.runtime() + return gettimeofday()-startuptime + end end -local launchers={ - windows="start %s", - macosx="open %s", - unix="xdg-open %s &> /dev/null &", -} -function os.launch(str) - local command=format(launchers[os.name] or launchers.unix,str) - execute(command) -end -local gettimeofday=os.gettimeofday or os.clock -os.gettimeofday=gettimeofday -local startuptime=gettimeofday() -function os.runtime() - return gettimeofday()-startuptime -end -local resolvers=os.resolvers or {} -os.resolvers=resolvers -setmetatable(os,{ __index=function(t,k) - local r=resolvers[k] - return r and r(t,k) or nil -end }) -local name,platform=os.name or "linux",os.getenv("MTX_PLATFORM") or "" -if platform~="" then - os.platform=platform -elseif os.type=="windows" then - function resolvers.platform(t,k) - local architecture=os.getenv("PROCESSOR_ARCHITECTURE") or "" - local platform="" - if find(architecture,"AMD64",1,true) then - platform="win64" +do + local name=os.name or "linux" + local platform=os.getenv("MTX_PLATFORM") or "" + local architecture=os.uname and os.uname().machine + local bits=os.getenv("MTX_BITS") or find(platform,"64") and 64 or 32 + if platform~="" then + elseif os.type=="windows" then + architecture=architecture or os.getenv("PROCESSOR_ARCHITECTURE") or "" + if architecture=="x86_64" then + bits,platform=64,"win64" + elseif find(architecture,"AMD64") then + bits,platform=64,"win64" + elseif find(architecture,"ARM64") then + bits,platform=64,"windows-arm64" + elseif find(architecture,"ARM32") then + bits,platform=32,"windows-arm32" else - platform="mswin" + bits,platform=32,"mswin" end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="linux" then - function resolvers.platform(t,k) - local architecture=os.getenv("HOSTTYPE") or resultof("uname -m") or "" - local platform=os.getenv("MTX_PLATFORM") or "" + elseif name=="linux" then + architecture=architecture or os.getenv("HOSTTYPE") or resultof("uname -m") or "" local musl=find(os.selfdir or "","linuxmusl") - if platform~="" then - elseif find(architecture,"x86_64",1,true) then - platform=musl and "linuxmusl" or "linux-64" - elseif find(architecture,"ppc",1,true) then - platform="linux-ppc" + if find(architecture,"x86_64") then + bits,platform=64,musl and "linuxmusl" or "linux-64" + elseif find(architecture,"ppc") then + bits,platform=32,"linux-ppc" else - platform=musl and "linuxmusl" or "linux" + bits,platform=32,musl and "linuxmusl" or "linux" end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="macosx" then - function resolvers.platform(t,k) - local architecture=resultof("echo $HOSTTYPE") or "" - local platform="" + elseif name=="macosx" then + architecture=architecture or resultof("echo $HOSTTYPE") or "" if architecture=="" then - platform="osx-intel" - elseif find(architecture,"i386",1,true) then - platform="osx-intel" - elseif find(architecture,"x86_64",1,true) then - platform="osx-64" - elseif find(architecture,"arm64",1,true) then - platform="osx-arm" + bits,platform=64,"osx-intel" + elseif find(architecture,"i386") then + bits,platform=64,"osx-intel" + elseif find(architecture,"x86_64") then + bits,platform=64,"osx-64" + elseif find(architecture,"arm64") then + bits,platform=64,"osx-arm" else - platform="osx-ppc" - end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="sunos" then - function resolvers.platform(t,k) - local architecture=resultof("uname -m") or "" - local platform="" - if find(architecture,"sparc",1,true) then - platform="solaris-sparc" + bits,platform=32,"osx-ppc" + end + elseif name=="sunos" then + architecture=architecture or resultof("uname -m") or "" + if find(architecture,"sparc") then + bits,platform=32,"solaris-sparc" else - platform="solaris-intel" - end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="freebsd" then - function resolvers.platform(t,k) - local architecture=resultof("uname -m") or "" - local platform="" - if find(architecture,"amd64",1,true) then - platform="freebsd-amd64" + bits,platform=32,"solaris-intel" + end + elseif name=="freebsd" then + architecture=architecture or resultof("uname -m") or "" + if find(architecture)=="amd64" or find(architecture)=="AMD64" then + bits,platform=64,"freebsd-amd64" + else + bits,platform=32,"freebsd" + end + elseif name=="kfreebsd" then + architecture=architecture or os.getenv("HOSTTYPE") or resultof("uname -m") or "" + if architecture=="x86_64" then + bits,platform=64,"kfreebsd-amd64" else - platform="freebsd" - end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -elseif name=="kfreebsd" then - function resolvers.platform(t,k) - local architecture=os.getenv("HOSTTYPE") or resultof("uname -m") or "" - local platform="" - if find(architecture,"x86_64",1,true) then - platform="kfreebsd-amd64" + bits,platform=32,"kfreebsd-i386" + end + else + architecture=architecture or resultof("uname -m") or "" + if find(architecture,"aarch64") then + bits,platform="linux-aarch64" + elseif find(architecture,"armv7l") then + bits,platform=32,"linux-armhf" + elseif find(architecture,"mips64") or find(architecture,"mips64el") then + bits,platform=64,"linux-mipsel" + elseif find(architecture,"mipsel") or find(architecture,"mips") then + bits,platform=32,"linux-mipsel" else - platform="kfreebsd-i386" + bits,platform=64,"linux-64" end - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform - end -else - function resolvers.platform(t,k) - local platform="linux" - os.setenv("MTX_PLATFORM",platform) - os.platform=platform - return platform end -end -os.newline=name=="windows" and "\013\010" or "\010" -function resolvers.bits(t,k) - local bits=find(os.platform,"64",1,true) and 64 or 32 + os.setenv("MTX_PLATFORM",platform) + os.setenv("MTX_BITS",bits) + os.platform=platform os.bits=bits - return bits -end -local t={ 8,9,"a","b" } -function os.uuid() - return format("%04x%04x-4%03x-%s%03x-%04x-%04x%04x%04x", - random(0xFFFF),random(0xFFFF), - random(0x0FFF), - t[ceil(random(4))] or 8,random(0x0FFF), - random(0xFFFF), - random(0xFFFF),random(0xFFFF),random(0xFFFF) - ) + os.newline=name=="windows" and "\013\010" or "\010" +end +do + local t={ 8,9,"a","b" } + function os.uuid() + return format("%04x%04x-4%03x-%s%03x-%04x-%04x%04x%04x", + random(0xFFFF),random(0xFFFF), + random(0x0FFF), + t[ceil(random(4))] or 8,random(0x0FFF), + random(0xFFFF), + random(0xFFFF),random(0xFFFF),random(0xFFFF) + ) + end end -local d -function os.timezone(delta) - d=d or ((tonumber(date("%H")) or 0)-(tonumber(date("!%H")) or 0)) - if delta then - if d>0 then - return format("+%02i:00",d) +do + local d + function os.timezone(delta) + d=d or ((tonumber(date("%H")) or 0)-(tonumber(date("!%H")) or 0)) + if delta then + if d>0 then + return format("+%02i:00",d) + else + return format("-%02i:00",-d) + end else - return format("-%02i:00",-d) + return 1 end - else - return 1 end -end -local timeformat=format("%%s%s",os.timezone(true)) -local dateformat="!%Y-%m-%d %H:%M:%S" -local lasttime=nil -local lastdate=nil -function os.fulltime(t,default) - t=t and tonumber(t) or 0 - if t>0 then - elseif default then - return default - else - t=time() + local timeformat=format("%%s%s",os.timezone(true)) + local dateformat="!%Y-%m-%d %H:%M:%S" + local lasttime=nil + local lastdate=nil + function os.fulltime(t,default) + t=t and tonumber(t) or 0 + if t>0 then + elseif default then + return default + else + t=time() + end + if t~=lasttime then + lasttime=t + lastdate=format(timeformat,date(dateformat)) + end + return lastdate end - if t~=lasttime then - lasttime=t - lastdate=format(timeformat,date(dateformat)) + local dateformat="%Y-%m-%d %H:%M:%S" + local lasttime=nil + local lastdate=nil + function os.localtime(t,default) + t=t and tonumber(t) or 0 + if t>0 then + elseif default then + return default + else + t=time() + end + if t~=lasttime then + lasttime=t + lastdate=date(dateformat,t) + end + return lastdate end - return lastdate -end -local dateformat="%Y-%m-%d %H:%M:%S" -local lasttime=nil -local lastdate=nil -function os.localtime(t,default) - t=t and tonumber(t) or 0 - if t>0 then - elseif default then - return default - else - t=time() + function os.converttime(t,default) + local t=tonumber(t) + if t and t>0 then + return date(dateformat,t) + else + return default or "-" + end end - if t~=lasttime then - lasttime=t - lastdate=date(dateformat,t) + function os.today() + return date("!*t") end - return lastdate -end -function os.converttime(t,default) - local t=tonumber(t) - if t and t>0 then - return date(dateformat,t) - else - return default or "-" + function os.now() + return date("!%Y-%m-%d %H:%M:%S") end end -local memory={} -local function which(filename) - local fullname=memory[filename] - if fullname==nil then - local suffix=file.suffix(filename) - local suffixes=suffix=="" and os.binsuffixes or { suffix } - for directory in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do - local df=file.join(directory,filename) - for i=1,#suffixes do - local dfs=file.addsuffix(df,suffixes[i]) - if io.exists(dfs) then - fullname=dfs - break +do + local cache={} + local function which(filename) + local fullname=cache[filename] + if fullname==nil then + local suffix=file.suffix(filename) + local suffixes=suffix=="" and os.binsuffixes or { suffix } + for directory in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do + local df=file.join(directory,filename) + for i=1,#suffixes do + local dfs=file.addsuffix(df,suffixes[i]) + if io.exists(dfs) then + fullname=dfs + break + end end end + if not fullname then + fullname=false + end + cache[filename]=fullname end - if not fullname then - fullname=false - end - memory[filename]=fullname + return fullname end - return fullname -end -os.which=which -os.where=which -function os.today() - return date("!*t") -end -function os.now() - return date("!%Y-%m-%d %H:%M:%S") + os.which=which + os.where=which end if not os.sleep then local socket=socket @@ -4229,65 +4211,69 @@ if not os.sleep then socket.sleep(n) end end -local function isleapyear(year) - return (year%4==0) and (year%100~=0 or year%400==0) -end -os.isleapyear=isleapyear -local days={ 31,28,31,30,31,30,31,31,30,31,30,31 } -local function nofdays(year,month,day) - if not month then - return isleapyear(year) and 365 or 364 - elseif not day then - return month==2 and isleapyear(year) and 29 or days[month] - else - for i=1,month-1 do - day=day+days[i] - end - if month>2 and isleapyear(year) then - day=day+1 +do + local function isleapyear(year) + return (year%4==0) and (year%100~=0 or year%400==0) + end + os.isleapyear=isleapyear + local days={ 31,28,31,30,31,30,31,31,30,31,30,31 } + local function nofdays(year,month,day) + if not month then + return isleapyear(year) and 365 or 364 + elseif not day then + return month==2 and isleapyear(year) and 29 or days[month] + else + for i=1,month-1 do + day=day+days[i] + end + if month>2 and isleapyear(year) then + day=day+1 + end + return day end - return day end -end -os.nofdays=nofdays -function os.weekday(day,month,year) - return date("%w",time { year=year,month=month,day=day })+1 -end -function os.validdate(year,month,day) - if month<1 then - month=1 - elseif month>12 then - month=12 + os.nofdays=nofdays + function os.weekday(day,month,year) + return date("%w",time { year=year,month=month,day=day })+1 end - if day<1 then - day=1 - else - local max=nofdays(year,month) - if day>max then - day=max + function os.validdate(year,month,day) + if month<1 then + month=1 + elseif month>12 then + month=12 + end + if day<1 then + day=1 + else + local max=nofdays(year,month) + if day>max then + day=max + end end + return year,month,day end - return year,month,day -end -function os.date(fmt,...) - if not fmt then - fmt="%Y-%m-%d %H:%M" + function os.date(fmt,...) + if not fmt then + fmt="%Y-%m-%d %H:%M" + end + return date(fmt,...) end - return date(fmt,...) end -local osexit=os.exit -local exitcode=nil -function os.setexitcode(code) - exitcode=code -end -function os.exit(c) - if exitcode~=nil then - return osexit(exitcode) +do + local osexit=os.exit + local exitcode=nil + function os.setexitcode(code) + exitcode=code end - if c~=nil then - return osexit(c) + function os.exit(c) + if exitcode~=nil then + return osexit(exitcode) + end + if c~=nil then + return osexit(c) + end + return osexit() end - return osexit() end @@ -15705,7 +15691,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-zip"] = package.loaded["util-zip"] or true --- original size: 23162, stripped down to: 13844 +-- original size: 23104, stripped down to: 14029 if not modules then modules={} end modules ['util-zip']={ version=1.001, @@ -15714,12 +15700,14 @@ if not modules then modules={} end modules ['util-zip']={ license="see context related readme files" } local type,tostring,tonumber=type,tostring,tonumber -local sort=table.sort +local sort,concat=table.sort,table.concat local find,format,sub,gsub=string.find,string.format,string.sub,string.gsub local osdate,ostime,osclock=os.date,os.time,os.clock local ioopen=io.open local loaddata,savedata=io.loaddata,io.savedata local filejoin,isdir,dirname,mkdirs=file.join,lfs.isdir,file.dirname,dir.mkdirs +local suffix,suffixes=file.suffix,file.suffixes +local openfile=io.open gzip=gzip or {} if not zlib then zlib=xzip @@ -16132,16 +16120,31 @@ if xzip then zipfiles.zipdir=zipdir zipfiles.unzipdir=unzipdir end -if not gzip.compress then - local suffix=file.suffix - local suffixes=file.suffixes - local find=string.find - local concat=table.concat - local openfile=io.open +local pattern="^\x1F\x8B\x08" +local gziplevel=3 +function gzip.suffix(filename) + local suffix,extra=suffixes(filename) + local gzipped=extra=="gz" + return suffix,gzipped +end +function gzip.compressed(s) + return s and find(s,pattern) +end +local getdecompressed +local putcompressed +if gzip.compress then + local gzipwindow=15+16 + local compress=zlib.compress + local decompress=zlib.decompress + getdecompressed=function(str) + return decompress(str,gzipwindow) + end + putcompressed=function(str,level) + return compress(str,level or gziplevel,nil,gzipwindow) + end +else local gzipwindow=-15 - local gziplevel=3 local identifier="\x1F\x8B" - local pattern="^\x1F\x8B\x08" local compress=zlib.compress local decompress=zlib.decompress local crc32=zlib.crc32 @@ -16157,7 +16160,7 @@ if not gzip.compress then local skipbytes=streams.skip local tocardinal1=streams.tocardinal1 local tocardinal4=streams.tocardinal4le - local function getdecompressed(str) + getdecompressed=function(str) local s=openstream(str) local identifier=readstring(s,2) local method=readbyte(s,1) @@ -16174,7 +16177,7 @@ if not gzip.compress then local data=decompress(compressed,gzipwindow) return data end - local function putcompressed(str,level,originalname) + putcompressed=function(str,level,originalname) return concat { identifier, tocardinal1(0x08), @@ -16188,58 +16191,50 @@ if not gzip.compress then tocardinal4(#str), } end - function gzip.load(filename) - local f=openfile(filename,"rb") - if not f then - else - local data=f:read("*all") - f:close() - if data and data~="" then - if suffix(filename)=="gz" then - data=getdecompressed(data) - end - return data +end +function gzip.load(filename) + local f=openfile(filename,"rb") + if not f then + else + local data=f:read("*all") + f:close() + if data and data~="" then + if suffix(filename)=="gz" then + data=getdecompressed(data) end + return data end end - function gzip.save(filename,data,level,originalname) - if suffix(filename)~="gz" then - filename=filename..".gz" - end - local f=openfile(filename,"wb") - if f then - data=putcompressed(data or "",level or gziplevel,originalname) - f:write(data) - f:close() - return #data - end - end - function gzip.suffix(filename) - local suffix,extra=suffixes(filename) - local gzipped=extra=="gz" - return suffix,gzipped - end - function gzip.compressed(s) - return s and find(s,identifier) +end +function gzip.save(filename,data,level,originalname) + if suffix(filename)~="gz" then + filename=filename..".gz" end - function gzip.compress(s,level) - if s and not find(s,identifier) then - if not level then - level=gziplevel - elseif level<=0 then - return s - elseif level>9 then - level=9 - end - return putcompressed(s,level or gziplevel) or s - end + local f=openfile(filename,"wb") + if f then + data=putcompressed(data or "",level or gziplevel,originalname) + f:write(data) + f:close() + return #data end - function gzip.decompress(s) - if s and find(s,identifier) then - return getdecompressed(s) - else +end +function gzip.compress(s,level) + if s and not find(s,pattern) then + if not level then + level=gziplevel + elseif level<=0 then return s + elseif level>9 then + level=9 end + return putcompressed(s,level or gziplevel) or s + end +end +function gzip.decompress(s) + if s and find(s,pattern) then + return getdecompressed(s) + else + return s end end zipfiles.gunzipfile=gzip.load @@ -25897,8 +25892,8 @@ end -- of closure -- used libraries : l-bit32.lua 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-sha.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 util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.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 util-zip.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 libs-ini.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 1024388 --- stripped bytes : 402181 +-- original bytes : 1024470 +-- stripped bytes : 402069 -- end library merge diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 8d536ed0f..7be29328f 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2021.06.24 23:39} +\newcontextversion{2021.06.25 22:44} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 90520a150..787df8bda 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2021.06.24 23:39} +\edef\contextversion{2021.06.25 22:44} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 3323fde71..a75fb7ae8 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.06.24 23:39} +\newcontextversion{2021.06.25 22:44} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 853812de2..3df274b35 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2021.06.24 23:39} +\edef\contextversion{2021.06.25 22:44} %D Kind of special: diff --git a/tex/context/base/mkiv/l-os.lua b/tex/context/base/mkiv/l-os.lua index b46036757..d7934a937 100644 --- a/tex/context/base/mkiv/l-os.lua +++ b/tex/context/base/mkiv/l-os.lua @@ -36,12 +36,17 @@ local type, setmetatable, tonumber, tostring = type, setmetatable, tonumber, tos -- if we pass --binpath= (which is useful anyway) do + local selfdir = os.selfdir + if selfdir == "" then selfdir = nil end + if not selfdir then + -- We need a fallback plan so let's see what we get. + if arg then -- passed by mtx-context ... saves network access for i=1,#arg do @@ -52,6 +57,7 @@ do end end end + if not selfdir then selfdir = os.selfbin or "luatex" if find(selfdir,"[/\\]") then @@ -92,11 +98,16 @@ do end end end + -- let's hope we're okay now + os.selfdir = selfdir or "." + end + + -- print(os.selfdir) os.exit() + end --- print(os.selfdir) os.exit() -- The following code permits traversing the environment table, at least in luatex. Internally all -- environment names are uppercase. @@ -184,11 +195,13 @@ end -- end of environment hack if not io.fileseparator then + if find(os.getenv("PATH"),";",1,true) then io.fileseparator, io.pathseparator, os.type = "\\", ";", os.type or "windows" else io.fileseparator, io.pathseparator, os.type = "/" , ":", os.type or "unix" end + end os.type = os.type or (io.pathseparator == ";" and "windows") or "unix" @@ -200,374 +213,343 @@ else os.libsuffix, os.binsuffix, os.binsuffixes = 'so', '', { '' } end -local execute = os.execute -local iopopen = io.popen -local ostype = os.type - -local function resultof(command) - -- already has flush, b is new and we need it to pipe xz output - local handle = iopopen(command,ostype == "windows" and "rb" or "r") - if handle then - local result = handle:read("*all") or "" - handle:close() - return result - else - return "" - end -end - -os.resultof = resultof - -function os.pipeto(command) - return iopopen(command,"w") -- already has flush -end - +do -local launchers = { - windows = "start %s", - macosx = "open %s", - unix = "xdg-open %s &> /dev/null &", -} + local execute = os.execute + local iopopen = io.popen + local ostype = os.type + + local function resultof(command) + -- already has flush, b is new and we need it to pipe xz output + local handle = iopopen(command,ostype == "windows" and "rb" or "r") + if handle then + local result = handle:read("*all") or "" + handle:close() + return result + else + return "" + end + end -function os.launch(str) - local command = format(launchers[os.name] or launchers.unix,str) - -- todo: pcall --- print(command) - execute(command) -end + os.resultof = resultof -local gettimeofday = os.gettimeofday or os.clock -os.gettimeofday = gettimeofday + function os.pipeto(command) + return iopopen(command,"w") -- already has flush + end -local startuptime = gettimeofday() + local launchers = { + windows = "start %s", + macosx = "open %s", + unix = "xdg-open %s &> /dev/null &", + } + + function os.launch(str) + local command = format(launchers[os.name] or launchers.unix,str) + -- todo: pcall + -- print(command) + execute(command) + end -function os.runtime() - return gettimeofday() - startuptime end --- print(os.gettimeofday()-os.time()) --- os.sleep(1.234) --- print (">>",os.runtime()) --- print(os.date("%H:%M:%S",os.gettimeofday())) --- print(os.date("%H:%M:%S",os.time())) - --- no need for function anymore as we have more clever code and helpers now --- this metatable trickery might as well disappear +do -local resolvers = os.resolvers or { } -os.resolvers = resolvers + local gettimeofday = os.gettimeofday or os.clock + os.gettimeofday = gettimeofday -setmetatable(os, { __index = function(t,k) - local r = resolvers[k] - return r and r(t,k) or nil -- no memoize -end }) + local startuptime = gettimeofday() --- we can use HOSTTYPE on some platforms + function os.runtime() + return gettimeofday() - startuptime + end -local name, platform = os.name or "linux", os.getenv("MTX_PLATFORM") or "" + -- print(os.gettimeofday()-os.time()) + -- os.sleep(1.234) + -- print (">>",os.runtime()) + -- print(os.date("%H:%M:%S",os.gettimeofday())) + -- print(os.date("%H:%M:%S",os.time())) --- local function guess() --- local architecture = resultof("uname -m") or "" --- if architecture ~= "" then --- return architecture --- end --- architecture = os.getenv("HOSTTYPE") or "" --- if architecture ~= "" then --- return architecture --- end --- return resultof("echo $HOSTTYPE") or "" --- end +end +-- We can use HOSTTYPE on some platforms (but not consistently on e.g. Linux). +-- -- os.bits = 32 | 64 +-- +-- os.uname() : return { +-- machine = "x86_64", +-- nodename = "MYLAPTOP", +-- release = "build 9200", +-- sysname = "Windows", +-- version = "6.02", +-- } --- os.uname() --- sysname --- machine --- release --- version --- nodename - -if platform ~= "" then +do - os.platform = platform + local name = os.name or "linux" + local platform = os.getenv("MTX_PLATFORM") or "" + local architecture = os.uname and os.uname().machine -- lmtx + local bits = os.getenv("MTX_BITS") or find(platform,"64") and 64 or 32 -elseif os.type == "windows" then + if platform ~= "" then - -- we could set the variable directly, no function needed here + -- we're okay already - -- PROCESSOR_ARCHITECTURE : binary platform - -- PROCESSOR_ARCHITEW6432 : OS platform + elseif os.type == "windows" then - -- mswin-64 is now win64 + -- PROCESSOR_ARCHITECTURE : binary platform + -- PROCESSOR_ARCHITEW6432 : OS platform - function resolvers.platform(t,k) - local architecture = os.getenv("PROCESSOR_ARCHITECTURE") or "" - local platform = "" - if find(architecture,"AMD64",1,true) then - platform = "win64" + architecture = architecture or os.getenv("PROCESSOR_ARCHITECTURE") or "" + if architecture == "x86_64" then + bits, platform = 64, "win64" + elseif find(architecture,"AMD64") then + bits, platform = 64, "win64" + elseif find(architecture,"ARM64") then + bits, platform = 64, "windows-arm64" + elseif find(architecture,"ARM32") then + bits, platform = 32, "windows-arm32" else - platform = "mswin" + bits, platform = 32, "mswin" end - os.setenv("MTX_PLATFORM",platform) - os.platform = platform - return platform - end -elseif name == "linux" then - - function resolvers.platform(t,k) - -- we sometimes have HOSTTYPE set so let's check that first - local architecture = os.getenv("HOSTTYPE") or resultof("uname -m") or "" - local platform = os.getenv("MTX_PLATFORM") or "" - local musl = find(os.selfdir or "","linuxmusl") - if platform ~= "" then - -- we're done - elseif find(architecture,"x86_64",1,true) then - platform = musl and "linuxmusl" or "linux-64" - elseif find(architecture,"ppc",1,true) then - platform = "linux-ppc" + elseif name == "linux" then + + -- There is no way to detect if musl is used because there is no __MUSL__ + -- and it looks like there never will be. Folks don't care about cases where + -- one ships multipe binaries (as with TeX distibutions) and want to select + -- the right one. So probably it expects users to compile locally in which + -- case we don't care to much as they can then sort it out. + + architecture = architecture or os.getenv("HOSTTYPE") or resultof("uname -m") or "" + local musl = find(os.selfdir or "","linuxmusl") + if find(architecture,"x86_64") then + bits, platform = 64, musl and "linuxmusl" or "linux-64" + elseif find(architecture,"ppc") then + bits, platform = 32, "linux-ppc" -- this will be dropped else - platform = musl and "linuxmusl" or "linux" + bits, platform = 32, musl and "linuxmusl" or "linux" end - os.setenv("MTX_PLATFORM",platform) - os.platform = platform - return platform - end -elseif name == "macosx" then - - --[[ - Identifying the architecture of OSX is quite a mess and this - is the best we can come up with. For some reason $HOSTTYPE is - a kind of pseudo environment variable, not known to the current - environment. And yes, uname cannot be trusted either, so there - is a change that you end up with a 32 bit run on a 64 bit system. - Also, some proper 64 bit intel macs are too cheap (low-end) and - therefore not permitted to run the 64 bit kernel. - ]]-- - - function resolvers.platform(t,k) - -- local platform = "" - -- local architecture = os.getenv("HOSTTYPE") or "" - -- if architecture == "" then - -- architecture = resultof("echo $HOSTTYPE") or "" - -- end - local architecture = resultof("echo $HOSTTYPE") or "" - local platform = "" + elseif name == "macosx" then + + -- Identifying the architecture of OSX is quite a mess and this is the best + -- we can come up with. For some reason $HOSTTYPE is a kind of pseudo + -- environment variable, not known to the current environment. And yes, + -- uname cannot be trusted either, so there is a change that you end up with + -- a 32 bit run on a 64 bit system. Also, some proper 64 bit intel macs are + -- too cheap (low-end) and therefore not permitted to run the 64 bit kernel. + + architecture = architecture or resultof("echo $HOSTTYPE") or "" if architecture == "" then - -- print("\nI have no clue what kind of OSX you're running so let's assume an 32 bit intel.\n") - platform = "osx-intel" - elseif find(architecture,"i386",1,true) then - platform = "osx-intel" - elseif find(architecture,"x86_64",1,true) then - platform = "osx-64" - elseif find(architecture,"arm64",1,true) then - platform = "osx-arm" + bits, platform = 64, "osx-intel" + elseif find(architecture,"i386") then + bits, platform = 64, "osx-intel" + elseif find(architecture,"x86_64") then + bits, platform = 64, "osx-64" + elseif find(architecture,"arm64") then + bits, platform = 64, "osx-arm" else - platform = "osx-ppc" + bits, platform = 32, "osx-ppc" end - os.setenv("MTX_PLATFORM",platform) - os.platform = platform - return platform - end -elseif name == "sunos" then + elseif name == "sunos" then - function resolvers.platform(t,k) - local architecture = resultof("uname -m") or "" - local platform = "" - if find(architecture,"sparc",1,true) then - platform = "solaris-sparc" + architecture = architecture or resultof("uname -m") or "" + if find(architecture,"sparc") then + bits, platform = 32, "solaris-sparc" else -- if architecture == 'i86pc' - platform = "solaris-intel" + bits, platform = 32, "solaris-intel" end - os.setenv("MTX_PLATFORM",platform) - os.platform = platform - return platform - end -elseif name == "freebsd" then + elseif name == "freebsd" then - function resolvers.platform(t,k) - local architecture = resultof("uname -m") or "" - local platform = "" - if find(architecture,"amd64",1,true) then - platform = "freebsd-amd64" + architecture = architecture or resultof("uname -m") or "" + if find(architecture) == "amd64" or find(architecture) == "AMD64" then + bits, platform = 64, "freebsd-amd64" else - platform = "freebsd" + bits, platform = 32, "freebsd" end - os.setenv("MTX_PLATFORM",platform) - os.platform = platform - return platform - end -elseif name == "kfreebsd" then + elseif name == "kfreebsd" then - function resolvers.platform(t,k) - -- we sometimes have HOSTTYPE set so let's check that first - local architecture = os.getenv("HOSTTYPE") or resultof("uname -m") or "" - local platform = "" - if find(architecture,"x86_64",1,true) then - platform = "kfreebsd-amd64" + architecture = architecture or os.getenv("HOSTTYPE") or resultof("uname -m") or "" + if architecture == "x86_64" then + bits, platform = 64, "kfreebsd-amd64" else - platform = "kfreebsd-i386" + bits, platform = 32, "kfreebsd-i386" end - os.setenv("MTX_PLATFORM",platform) - os.platform = platform - return platform - end -else + else - -- platform = "linux" - -- os.setenv("MTX_PLATFORM",platform) - -- os.platform = platform + architecture = architecture or resultof("uname -m") or "" + + if find(architecture,"aarch64") then + bits, platform = "linux-aarch64" + elseif find(architecture,"armv7l") then + -- linux-armel + bits, platform = 32, "linux-armhf" + elseif find(architecture,"mips64") or find(architecture,"mips64el") then + bits, platform = 64, "linux-mipsel" + elseif find(architecture,"mipsel") or find(architecture,"mips") then + bits, platform = 32, "linux-mipsel" + else + bits, platform = 64, "linux-64" -- was 32, "linux" + end - function resolvers.platform(t,k) - local platform = "linux" - os.setenv("MTX_PLATFORM",platform) - os.platform = platform - return platform end -end + os.setenv("MTX_PLATFORM",platform) + os.setenv("MTX_BITS", bits) -os.newline = name == "windows" and "\013\010" or "\010" -- crlf or lf + os.platform = platform + os.bits = bits + os.newline = name == "windows" and "\013\010" or "\010" -- crlf or lf -function resolvers.bits(t,k) - local bits = find(os.platform,"64",1,true) and 64 or 32 - os.bits = bits - return bits end -- beware, we set the randomseed --- from wikipedia: Version 4 UUIDs use a scheme relying only on random numbers. This algorithm sets the --- version number as well as two reserved bits. All other bits are set using a random or pseudorandom --- data source. Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx with hexadecimal --- digits x and hexadecimal digits 8, 9, A, or B for y. e.g. f47ac10b-58cc-4372-a567-0e02b2c3d479. --- --- as we don't call this function too often there is not so much risk on repetition - -local t = { 8, 9, "a", "b" } - -function os.uuid() - return format("%04x%04x-4%03x-%s%03x-%04x-%04x%04x%04x", - random(0xFFFF),random(0xFFFF), - random(0x0FFF), - t[ceil(random(4))] or 8,random(0x0FFF), - random(0xFFFF), - random(0xFFFF),random(0xFFFF),random(0xFFFF) - ) +-- From wikipedia: Version 4 UUIDs use a scheme relying only on random numbers. This +-- algorithm sets the version number as well as two reserved bits. All other bits +-- are set using a random or pseudorandom data source. Version 4 UUIDs have the form +-- xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx with hexadecimal digits x and hexadecimal +-- digits 8, 9, A, or B for y. e.g. f47ac10b-58cc-4372-a567-0e02b2c3d479. As we don't +-- call this function too often there is not so much risk on repetition. + +do + + local t = { 8, 9, "a", "b" } + + function os.uuid() + return format("%04x%04x-4%03x-%s%03x-%04x-%04x%04x%04x", + random(0xFFFF),random(0xFFFF), + random(0x0FFF), + t[ceil(random(4))] or 8,random(0x0FFF), + random(0xFFFF), + random(0xFFFF),random(0xFFFF),random(0xFFFF) + ) + end + end -local d +do + + local d -function os.timezone(delta) - d = d or ((tonumber(date("%H")) or 0) - (tonumber(date("!%H")) or 0)) - if delta then - if d > 0 then - return format("+%02i:00",d) + function os.timezone(delta) + d = d or ((tonumber(date("%H")) or 0) - (tonumber(date("!%H")) or 0)) + if delta then + if d > 0 then + return format("+%02i:00",d) + else + return format("-%02i:00",-d) + end else - return format("-%02i:00",-d) + return 1 end - else - return 1 end -end -local timeformat = format("%%s%s",os.timezone(true)) -local dateformat = "!%Y-%m-%d %H:%M:%S" -local lasttime = nil -local lastdate = nil - -function os.fulltime(t,default) - t = t and tonumber(t) or 0 - if t > 0 then - -- valid time - elseif default then - return default - else - t = time() - end - if t ~= lasttime then - lasttime = t - lastdate = format(timeformat,date(dateformat)) + local timeformat = format("%%s%s",os.timezone(true)) + local dateformat = "!%Y-%m-%d %H:%M:%S" + local lasttime = nil + local lastdate = nil + + function os.fulltime(t,default) + t = t and tonumber(t) or 0 + if t > 0 then + -- valid time + elseif default then + return default + else + t = time() + end + if t ~= lasttime then + lasttime = t + lastdate = format(timeformat,date(dateformat)) + end + return lastdate end - return lastdate -end -local dateformat = "%Y-%m-%d %H:%M:%S" -local lasttime = nil -local lastdate = nil + local dateformat = "%Y-%m-%d %H:%M:%S" + local lasttime = nil + local lastdate = nil -function os.localtime(t,default) - t = t and tonumber(t) or 0 - if t > 0 then - -- valid time - elseif default then - return default - else - t = time() + function os.localtime(t,default) + t = t and tonumber(t) or 0 + if t > 0 then + -- valid time + elseif default then + return default + else + t = time() + end + if t ~= lasttime then + lasttime = t + lastdate = date(dateformat,t) + end + return lastdate end - if t ~= lasttime then - lasttime = t - lastdate = date(dateformat,t) + + function os.converttime(t,default) + local t = tonumber(t) + if t and t > 0 then + return date(dateformat,t) + else + return default or "-" + end end - return lastdate -end -function os.converttime(t,default) - local t = tonumber(t) - if t and t > 0 then - return date(dateformat,t) - else - return default or "-" + function os.today() + return date("!*t") -- table with values end + + function os.now() + return date("!%Y-%m-%d %H:%M:%S") -- 2011-12-04 14:59:12 + end + end -local memory = { } - -local function which(filename) - local fullname = memory[filename] - if fullname == nil then - local suffix = file.suffix(filename) - local suffixes = suffix == "" and os.binsuffixes or { suffix } - for directory in gmatch(os.getenv("PATH"),"[^" .. io.pathseparator .."]+") do - local df = file.join(directory,filename) - for i=1,#suffixes do - local dfs = file.addsuffix(df,suffixes[i]) - if io.exists(dfs) then - fullname = dfs - break +do + + local cache = { } + + local function which(filename) + local fullname = cache[filename] + if fullname == nil then + local suffix = file.suffix(filename) + local suffixes = suffix == "" and os.binsuffixes or { suffix } + for directory in gmatch(os.getenv("PATH"),"[^" .. io.pathseparator .."]+") do + local df = file.join(directory,filename) + for i=1,#suffixes do + local dfs = file.addsuffix(df,suffixes[i]) + if io.exists(dfs) then + fullname = dfs + break + end end end + if not fullname then + fullname = false + end + cache[filename] = fullname end - if not fullname then - fullname = false - end - memory[filename] = fullname + return fullname end - return fullname -end -os.which = which -os.where = which + os.which = which + os.where = which -function os.today() - return date("!*t") -- table with values -end + -- print(os.which("inkscape.exe")) + -- print(os.which("inkscape")) + -- print(os.which("gs.exe")) + -- print(os.which("ps2pdf")) -function os.now() - return date("!%Y-%m-%d %H:%M:%S") -- 2011-12-04 14:59:12 end --- if not os.sleep and socket then --- os.sleep = socket.sleep --- end - if not os.sleep then + local socket = socket + function os.sleep(n) if not socket then -- so we delay ... if os.sleep is really needed then one should also @@ -576,101 +558,105 @@ if not os.sleep then end socket.sleep(n) end -end --- print(os.which("inkscape.exe")) --- print(os.which("inkscape")) --- print(os.which("gs.exe")) --- print(os.which("ps2pdf")) - --- These are moved from core-con.lua (as I needed them elsewhere). - -local function isleapyear(year) -- timed for bram's cs practicum - -- return (year % 400 == 0) or (year % 100 ~= 0 and year % 4 == 0) -- 3:4:1600:1900 = 9.9 : 8.2 : 5.0 : 6.8 (29.9) - return (year % 4 == 0) and (year % 100 ~= 0 or year % 400 == 0) -- 3:4:1600:1900 = 5.1 : 6.5 : 8.1 : 10.2 (29.9) - -- return (year % 4 == 0) and (year % 400 == 0 or year % 100 ~= 0) -- 3:4:1600:1900 = 5.2 : 8.5 : 6.8 : 10.1 (30.6) end -os.isleapyear = isleapyear +-- These are moved from core-con.lua (as I needed them elsewhere). --- nicer: --- --- local days = { --- [false] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, --- [true] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } --- } --- --- local function nofdays(year,month) --- return days[isleapyear(year)][month] --- return month == 2 and isleapyear(year) and 29 or days[month] --- end --- --- more efficient: +do -local days = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } + local function isleapyear(year) -- timed for bram's cs practicum + -- return (year % 400 == 0) or (year % 100 ~= 0 and year % 4 == 0) -- 3:4:1600:1900 = 9.9 : 8.2 : 5.0 : 6.8 (29.9) + return (year % 4 == 0) and (year % 100 ~= 0 or year % 400 == 0) -- 3:4:1600:1900 = 5.1 : 6.5 : 8.1 : 10.2 (29.9) + -- return (year % 4 == 0) and (year % 400 == 0 or year % 100 ~= 0) -- 3:4:1600:1900 = 5.2 : 8.5 : 6.8 : 10.1 (30.6) + end -local function nofdays(year,month,day) - if not month then - return isleapyear(year) and 365 or 364 - elseif not day then - return month == 2 and isleapyear(year) and 29 or days[month] - else - for i=1,month-1 do - day = day + days[i] - end - if month > 2 and isleapyear(year) then - day = day + 1 + os.isleapyear = isleapyear + + -- nicer: + -- + -- local days = { + -- [false] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, + -- [true] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } + -- } + -- + -- local function nofdays(year,month) + -- return days[isleapyear(year)][month] + -- return month == 2 and isleapyear(year) and 29 or days[month] + -- end + -- + -- more efficient: + + local days = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } + + local function nofdays(year,month,day) + if not month then + return isleapyear(year) and 365 or 364 + elseif not day then + return month == 2 and isleapyear(year) and 29 or days[month] + else + for i=1,month-1 do + day = day + days[i] + end + if month > 2 and isleapyear(year) then + day = day + 1 + end + return day end - return day end -end -os.nofdays = nofdays + os.nofdays = nofdays -function os.weekday(day,month,year) - return date("%w",time { year = year, month = month, day = day }) + 1 -end - -function os.validdate(year,month,day) - -- we assume that all three values are set - -- year is always ok, even if lua has a 1970 time limit - if month < 1 then - month = 1 - elseif month > 12 then - month = 12 + function os.weekday(day,month,year) + return date("%w",time { year = year, month = month, day = day }) + 1 end - if day < 1 then - day = 1 - else - local max = nofdays(year,month) - if day > max then - day = max + + function os.validdate(year,month,day) + -- we assume that all three values are set + -- year is always ok, even if lua has a 1970 time limit + if month < 1 then + month = 1 + elseif month > 12 then + month = 12 end + if day < 1 then + day = 1 + else + local max = nofdays(year,month) + if day > max then + day = max + end + end + return year, month, day end - return year, month, day -end -function os.date(fmt,...) - if not fmt then - -- otherwise differences between unix, mingw and msvc - fmt = "%Y-%m-%d %H:%M" + function os.date(fmt,...) + if not fmt then + -- otherwise differences between unix, mingw and msvc + fmt = "%Y-%m-%d %H:%M" + end + return date(fmt,...) end - return date(fmt,...) + end -local osexit = os.exit -local exitcode = nil +do -function os.setexitcode(code) - exitcode = code -end + local osexit = os.exit + local exitcode = nil -function os.exit(c) - if exitcode ~= nil then - return osexit(exitcode) + function os.setexitcode(code) + exitcode = code end - if c ~= nil then - return osexit(c) + + function os.exit(c) + if exitcode ~= nil then + return osexit(exitcode) + end + if c ~= nil then + return osexit(c) + end + return osexit() end - return osexit() + end diff --git a/tex/context/base/mkiv/luat-lib.mkiv b/tex/context/base/mkiv/luat-lib.mkiv index 2879ca62a..3df374de9 100644 --- a/tex/context/base/mkiv/luat-lib.mkiv +++ b/tex/context/base/mkiv/luat-lib.mkiv @@ -45,6 +45,8 @@ \registerctxluafile{util-soc-imp-http} {} \registerctxluafile{util-soc-imp-tp} {} +\registerctxluafile{util-zip}{} + \registerctxluafile{data-ini}{} \registerctxluafile{data-exp}{} \registerctxluafile{data-env}{} diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 3e3408ef5..5de1fae5b 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex d8d7fbd47..4a947eb3f 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/util-zip.lua b/tex/context/base/mkiv/util-zip.lua index 67c1a715f..ea13e1faa 100644 --- a/tex/context/base/mkiv/util-zip.lua +++ b/tex/context/base/mkiv/util-zip.lua @@ -13,13 +13,15 @@ if not modules then modules = { } end modules ['util-zip'] = { -- keep some hybrid functionality. local type, tostring, tonumber = type, tostring, tonumber -local sort = table.sort +local sort, concat = table.sort, table.concat local find, format, sub, gsub = string.find, string.format, string.sub, string.gsub local osdate, ostime, osclock = os.date, os.time, os.clock local ioopen = io.open local loaddata, savedata = io.loaddata, io.savedata local filejoin, isdir, dirname, mkdirs = file.join, lfs.isdir, file.dirname, dir.mkdirs +local suffix, suffixes = file.suffix, file.suffixes +local openfile = io.open gzip = gzip or { } -- so in luatex we keep the old ones too @@ -505,42 +507,61 @@ if xzip then -- flate then do end -if not gzip.compress then - - -- todo: compress/decompress that work with offset in string - - -- We only have a few official methods here: - -- - -- local decompressed = gzip.load (filename) - -- local resultsize = gzip.save (filename,compresslevel) - -- local compressed = gzip.compress (str,compresslevel) - -- local decompressed = gzip.decompress (str) - -- local iscompressed = gzip.compressed (str) - -- local suffix, okay = gzip.suffix (filename) - -- - -- In LuaMetaTeX we have only xzip which implements a very few methods: - -- - -- compress (str,level,method,window,memory,strategy) - -- decompress (str,window) - -- adler32 (str,checksum) - -- crc32 (str,checksum) - -- - -- Special window values are: - -- - -- flate : - 15 - -- zlib : 15 - -- gzip : - 15 - - local suffix = file.suffix - local suffixes = file.suffixes - local find = string.find - local concat = table.concat - local openfile = io.open +-- todo: compress/decompress that work with offset in string + +-- We only have a few official methods here: +-- +-- local decompressed = gzip.load (filename) +-- local resultsize = gzip.save (filename,compresslevel) +-- local compressed = gzip.compress (str,compresslevel) +-- local decompressed = gzip.decompress (str) +-- local iscompressed = gzip.compressed (str) +-- local suffix, okay = gzip.suffix (filename) +-- +-- In LuaMetaTeX we have only xzip which implements a very few methods: +-- +-- compress (str,level,method,window,memory,strategy) +-- decompress (str,window) +-- adler32 (str,checksum) +-- crc32 (str,checksum) + +local pattern = "^\x1F\x8B\x08" +local gziplevel = 3 + +function gzip.suffix(filename) + local suffix, extra = suffixes(filename) + local gzipped = extra == "gz" + return suffix, gzipped +end + +function gzip.compressed(s) + return s and find(s,pattern) +end + +local getdecompressed +local putcompressed + +if gzip.compress then + + local gzipwindow = 15 + 16 -- +16: gzip, +32: gzip|zlib + + local compress = zlib.compress + local decompress = zlib.decompress + + getdecompressed = function(str) + return decompress(str,gzipwindow) -- pass offset + end + + putcompressed = function(str,level) + return compress(str,level or gziplevel,nil,gzipwindow) + end + +else + + -- Special window values are: flate: -15, zlib: 15, gzip : -15 local gzipwindow = -15 -- miniz needs this - local gziplevel = 3 local identifier = "\x1F\x8B" - local pattern = "^\x1F\x8B\x08" local compress = zlib.compress local decompress = zlib.decompress @@ -560,7 +581,7 @@ if not gzip.compress then local tocardinal1 = streams.tocardinal1 local tocardinal4 = streams.tocardinal4le - local function getdecompressed(str) + getdecompressed = function(str) local s = openstream(str) local identifier = readstring(s,2) local method = readbyte(s,1) @@ -578,7 +599,7 @@ if not gzip.compress then return data end - local function putcompressed(str,level,originalname) + putcompressed = function(str,level,originalname) return concat { identifier, -- 2 identifier tocardinal1(0x08), -- 1 method @@ -593,67 +614,56 @@ if not gzip.compress then } end - function gzip.load(filename) - local f = openfile(filename,"rb") - if not f then - -- invalid file - else - local data = f:read("*all") - f:close() - if data and data ~= "" then - if suffix(filename) == "gz" then - data = getdecompressed(data) - end - return data - end - end - end +end - function gzip.save(filename,data,level,originalname) - if suffix(filename) ~= "gz" then - filename = filename .. ".gz" - end - local f = openfile(filename,"wb") - if f then - data = putcompressed(data or "",level or gziplevel,originalname) - f:write(data) - f:close() - return #data +function gzip.load(filename) + local f = openfile(filename,"rb") + if not f then + -- invalid file + else + local data = f:read("*all") + f:close() + if data and data ~= "" then + if suffix(filename) == "gz" then + data = getdecompressed(data) + end + return data end end +end - function gzip.suffix(filename) - local suffix, extra = suffixes(filename) - local gzipped = extra == "gz" - return suffix, gzipped - end - - function gzip.compressed(s) - return s and find(s,identifier) +function gzip.save(filename,data,level,originalname) + if suffix(filename) ~= "gz" then + filename = filename .. ".gz" end - - function gzip.compress(s,level) - if s and not find(s,identifier) then -- the find check might go away - if not level then - level = gziplevel - elseif level <= 0 then - return s - elseif level > 9 then - level = 9 - end - return putcompressed(s,level or gziplevel) or s - end + local f = openfile(filename,"wb") + if f then + data = putcompressed(data or "",level or gziplevel,originalname) + f:write(data) + f:close() + return #data end +end - function gzip.decompress(s) - if s and find(s,identifier) then - return getdecompressed(s) - else +function gzip.compress(s,level) + if s and not find(s,pattern) then + if not level then + level = gziplevel + elseif level <= 0 then return s + elseif level > 9 then + level = 9 end + return putcompressed(s,level or gziplevel) or s end +end - +function gzip.decompress(s) + if s and find(s,pattern) then + return getdecompressed(s) + else + return s + end end zipfiles.gunzipfile = gzip.load diff --git a/tex/context/base/mkxl/anch-bck.mklx b/tex/context/base/mkxl/anch-bck.mklx index 1d0009949..740ed693b 100644 --- a/tex/context/base/mkxl/anch-bck.mklx +++ b/tex/context/base/mkxl/anch-bck.mklx @@ -158,11 +158,11 @@ \let\anch_backgrounds_text_start_indeed\relax \let\anch_backgrounds_text_stop_indeed \relax -\setvalue{\??textbackgroundlevel\v!text}% +\defcsname\??textbackgroundlevel\v!text\endcsname {\let\anch_backgrounds_text_start_indeed\anch_backgrounds_text_start_txt \let\anch_backgrounds_text_stop_indeed \anch_backgrounds_text_stop_txt} -\setvalue{\??textbackgroundlevel\v!paragraph}% +\defcsname\??textbackgroundlevel\v!paragraph\endcsname {\ifnum\c_anch_backgrounds_text_level>\textbackgroundparameter\c!criterium\relax \let\anch_backgrounds_text_start_indeed\anch_backgrounds_text_start_txt \let\anch_backgrounds_text_stop_indeed \anch_backgrounds_text_stop_txt @@ -171,11 +171,11 @@ \let\anch_backgrounds_text_stop_indeed \anch_backgrounds_text_stop_par \fi} -\setvalue{\??textbackgroundlevel\v!always}% +\defcsname\??textbackgroundlevel\v!always\endcsname {\let\anch_backgrounds_text_start_indeed\anch_backgrounds_text_start_par \let\anch_backgrounds_text_stop_indeed \anch_backgrounds_text_stop_par} -\setvalue{\??textbackgroundlevel\v!none}% +\defcsname\??textbackgroundlevel\v!none\endcsname {\anch_backgrounds_text_preset_nop} \def\anch_backgrounds_text_preset_nop diff --git a/tex/context/base/mkxl/anch-pgr.mkxl b/tex/context/base/mkxl/anch-pgr.mkxl index d3504c50d..3c4dcf680 100644 --- a/tex/context/base/mkxl/anch-pgr.mkxl +++ b/tex/context/base/mkxl/anch-pgr.mkxl @@ -327,6 +327,7 @@ \def\anch_positions_meta_graphic_use#1#2#3% {\begingroup + \edef\currentmpcategory{#1}% \anch_positions_meta_graphic_prepare \startMPcode#3\stopMPcode \endgroup} @@ -351,7 +352,7 @@ \obeyMPboxorigin % do we also set the size ? when needed this must be done in mp ... might change \enforced\tolerant\protected\def\MPpositiongraphic##=##*##={\anch_positions_meta_graphic_nested{#3}{##1}{##2}}% takes two extra arguments % \def\anch_positions_meta_graphic_direct{\anch_positions_meta_graphic_nested{#3}}% takes two extra arguments - \setbox\b_anch_positions_graphic\hbox % \hpack + \setbox\b_anch_positions_graphic\hpack {\ignorespaces\begincsname#1#2\endcsname\removelastspace}% \smashbox\b_anch_positions_graphic \box\b_anch_positions_graphic diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 9e0a56317..b1c57cd7a 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.06.24 23:39} +\newcontextversion{2021.06.25 22:44} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index f26dcc6cd..e28506a3a 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2021.06.24 23:39} +\immutable\edef\contextversion{2021.06.25 22:44} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/mlib-lmp.lmt b/tex/context/base/mkxl/mlib-lmp.lmt index c4a141eee..e4944c92e 100644 --- a/tex/context/base/mkxl/mlib-lmp.lmt +++ b/tex/context/base/mkxl/mlib-lmp.lmt @@ -124,25 +124,25 @@ registerdirect("mpvard", function() end) registerdirect("mpvarn", function() - if not expandtex(integer_value, "mpcategoryparameter",true,scanstring(),0) then + if not expandtex(integer_value,"mpcategoryparameter",true,scanstring()) then injectnumeric(0) end end) registerdirect("mpvars", function() - if not expandtex(string_value, "mpcategoryparameter",true,scanstring(),"") then + if not expandtex(string_value,"mpcategoryparameter",true,scanstring()) then injectstring("") end end) registerdirect("mpvarb", function() - if not expandtex(boolean_value, "mpcategoryparameter",true,scanstring(),false) then + if not expandtex(boolean_value,"mpcategoryparameter",true,scanstring()) then injectboolean(false) end end) registerdirect("mpvar", function() - if not expandtex(unknown_value, "mpcategoryparameter",true,scanstring(),0) then + if not expandtex(unknown_value,"mpcategoryparameter",true,scanstring()) then injectnumeric(0) end end) diff --git a/tex/context/base/mkxl/mlib-scn.lmt b/tex/context/base/mkxl/mlib-scn.lmt index 5339fff6e..b64533cae 100644 --- a/tex/context/base/mkxl/mlib-scn.lmt +++ b/tex/context/base/mkxl/mlib-scn.lmt @@ -92,6 +92,9 @@ local tokenscanners = nil local scanset = nil local scanparameters = nil +scanners.typescanners = typescanners +scanners.tokenscanners = tokenscanners + scanset = function() -- can be optimized, we now read twice scantoken() if scantoken(true) == rightbrace_code then diff --git a/tex/context/base/mkxl/strc-reg.mkxl b/tex/context/base/mkxl/strc-reg.mkxl index 22a6614b7..16226c5fc 100644 --- a/tex/context/base/mkxl/strc-reg.mkxl +++ b/tex/context/base/mkxl/strc-reg.mkxl @@ -819,10 +819,10 @@ \registerparameter\c!after \nobreak} -\setvalue{\??registerindicator a}#1{\strc_registers_indicator_a{#1}{#1}} -\setvalue{\??registerindicator A}#1{\strc_registers_indicator_a{#1}{\WORD{#1}}} -\setvalue{\??registerindicator b}#1{\strc_registers_indicator_b{#1}{#1}} -\setvalue{\??registerindicator B}#1{\strc_registers_indicator_b{#1}{\WORD{#1}}} +\defcsname\??registerindicator a\endcsname#1{\strc_registers_indicator_a{#1}{#1}} +\defcsname\??registerindicator A\endcsname#1{\strc_registers_indicator_a{#1}{\WORD{#1}}} +\defcsname\??registerindicator b\endcsname#1{\strc_registers_indicator_b{#1}{#1}} +\defcsname\??registerindicator B\endcsname#1{\strc_registers_indicator_b{#1}{\WORD{#1}}} %D The following macros are the interface to the rendering. These are %D generated by \LUA. This might change. @@ -1181,23 +1181,23 @@ \installcorenamespace{registersymbol} -\setvalue{\??registersymbol n}% +\defcsname\??registersymbol n\endcsname {\enforced\frozen\def\registerpageseparatorsymbol{,\space}} -\setvalue{\??registersymbol a}% +\defcsname\??registersymbol a\endcsname {\enforced\frozen\def\registerpageseparatorsymbol{,\space}} % now done via conversion -\setvalue{\??registersymbol\v!none}% +\defcsname\??registersymbol\v!none\endcsname {\enforced\frozen\let\registerpageseparatorsymbol\empty \enforced\frozen\let\registeronepage\gobblefivearguments \enforced\frozen\let\registerpagerange\gobbleeightarguments} -\setvalue{\??registersymbol 1}% +\defcsname\??registersymbol 1\endcsname {\enforced\frozen\let\registerpageseparatorsymbol\space \enforced\frozen\def\registeronepage{\symbol[1]\gobblefivearguments}% \enforced\frozen\def\registerpagerange{\symbol[1]\gobbleeightarguments}} -\setvalue{\??registersymbol 2}% +\defcsname\??registersymbol 2\endcsname {\enforced\frozen\let\registerpageseparatorsymbol\space \enforced\frozen\def\registeronepage{\registerpagebuttonsymbol\gobblefivearguments}% \enforced\frozen\def\registerpagerange{\registerpagebuttonsymbol\gobbleeightarguments}} diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt index fc136539e..da71535ce 100644 --- a/tex/context/base/mkxl/trac-vis.lmt +++ b/tex/context/base/mkxl/trac-vis.lmt @@ -699,14 +699,11 @@ local math do else local text, width = sometext(formatters["M:%s"](tag and tags[tag] or what),usedfont,nil,"trace:dr") local rule = new_rule(skip,-655360/fraction,2*655360/fraction) + local dist = tag == "beginmath" and width or skip setcolor(rule,"trace:dr") settransparency(rule,"trace:dr") setattr(rule,a_layer,l_math) - if tag == "beginmath" then - info = new_hlist(setlink(new_glue(-skip),rule,new_glue(-width),text)) - else - info = new_hlist(setlink(new_glue(-skip),rule,new_glue(-skip),text)) - end + info = new_hlist(setlink(new_glue(-skip),rule,new_glue(-dist),text)) setattr(info,a_layer,l_math) m_cache[tag][skip] = info end diff --git a/tex/context/base/mkxl/typo-del.mkxl b/tex/context/base/mkxl/typo-del.mkxl index 9cac52ab8..dc26b4295 100644 --- a/tex/context/base/mkxl/typo-del.mkxl +++ b/tex/context/base/mkxl/typo-del.mkxl @@ -851,8 +851,7 @@ {\dontleavehmode \begingroup \dostarttaggedchained\t!delimited\currentdelimitedtext\??delimitedtext - % \usedlanguageparameter{\c!left\currentparentdelimitedtext}% was: \currentdelimitedtext - \usedlanguageparameter{\c!left\currentdelimitedtextparent}% + \usedlanguageparameter{\c!left\currentparentdelimitedtext}% was: \currentdelimitedtext \usedelimitedtextstyleandcolor\c!style\c!color \typo_delimited_start_content \bgroup @@ -861,8 +860,7 @@ \def\typo_delimited_fontdriven_e {\typo_delimited_stop_content - % \usedlanguageparameter{\c!right\currentparentdelimitedtext}% was: \currentdelimitedtext - \usedlanguageparameter{\c!right\currentdelimitedtextparent}% + \usedlanguageparameter{\c!right\currentparentdelimitedtext}% was: \currentdelimitedtext \dostoptagged \typo_delimited_pop \endgroup} diff --git a/tex/context/base/mkxl/typo-inj.mkxl b/tex/context/base/mkxl/typo-inj.mkxl index f615014b0..9dae32253 100644 --- a/tex/context/base/mkxl/typo-inj.mkxl +++ b/tex/context/base/mkxl/typo-inj.mkxl @@ -65,8 +65,8 @@ \letcsname typo_injectors_check_#1\endcsname\donothing} \permanent\protected\def\doactivateinjector#1% used at lua end - {\protected\defcsname typo_injectors_mark_#1\endcsname{\dontleavehmode\noexpand\clf_markinjector{#1}}% - \protected\defcsname typo_injectors_check_#1\endcsname{\noexpand\clf_checkinjector{#1}}} + {\protected\edefcsname typo_injectors_mark_#1\endcsname{\dontleavehmode\noexpand\clf_markinjector{#1}}% + \protected\edefcsname typo_injectors_check_#1\endcsname{\noexpand\clf_checkinjector{#1}}} \permanent\protected\def\dotestinjector#1% only for testing outside unprotect {\begincsname typo_injectors_check_#1\endcsname diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index f112ba224..7b4602115 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 2021-06-24 23:39 +-- merge date : 2021-06-25 22:44 do -- begin closure to overcome local limits and interference |