From 37fdb3c6983d960811ba78a31b01b7f44da425ec Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 5 Feb 2020 21:26:20 +0000 Subject: lualibs (4feb20) git-svn-id: svn://tug.org/texlive/trunk@53682 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/luatex/lualibs/NEWS | 3 + Master/texmf-dist/doc/luatex/lualibs/README.md | 6 +- Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf | Bin 81170 -> 80955 bytes .../texmf-dist/source/luatex/lualibs/lualibs.dtx | 18 +- .../tex/luatex/lualibs/lualibs-basic-merged.lua | 145 +++++++--------- .../tex/luatex/lualibs/lualibs-basic.lua | 4 +- .../tex/luatex/lualibs/lualibs-extended-merged.lua | 9 +- .../tex/luatex/lualibs/lualibs-extended.lua | 4 +- .../texmf-dist/tex/luatex/lualibs/lualibs-file.lua | 20 ++- .../texmf-dist/tex/luatex/lualibs/lualibs-gzip.lua | 191 ++++++++++++++------- .../texmf-dist/tex/luatex/lualibs/lualibs-io.lua | 2 +- .../texmf-dist/tex/luatex/lualibs/lualibs-lua.lua | 6 +- .../texmf-dist/tex/luatex/lualibs/lualibs-md5.lua | 28 +-- .../texmf-dist/tex/luatex/lualibs/lualibs-os.lua | 2 +- .../tex/luatex/lualibs/lualibs-table.lua | 2 +- .../tex/luatex/lualibs/lualibs-util-sta.lua | 9 +- .../tex/luatex/lualibs/lualibs-util-str.lua | 2 +- Master/texmf-dist/tex/luatex/lualibs/lualibs.lua | 4 +- 18 files changed, 267 insertions(+), 188 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/luatex/lualibs/NEWS b/Master/texmf-dist/doc/luatex/lualibs/NEWS index 075b7ce05ea..42846f767af 100644 --- a/Master/texmf-dist/doc/luatex/lualibs/NEWS +++ b/Master/texmf-dist/doc/luatex/lualibs/NEWS @@ -1,4 +1,7 @@ History of the lualibs package +2020/02/02 v2.70/ + * sync with Context current as of 2020/01/26. + 2019/11/06 v2.69/ * corrected github address and version info. diff --git a/Master/texmf-dist/doc/luatex/lualibs/README.md b/Master/texmf-dist/doc/luatex/lualibs/README.md index b4b8fa774c8..3a7d760a946 100644 --- a/Master/texmf-dist/doc/luatex/lualibs/README.md +++ b/Master/texmf-dist/doc/luatex/lualibs/README.md @@ -1,10 +1,10 @@ # The Lualibs Package -VERSION: 2.69 +VERSION: 2.70 -DATE: 2019-11-06 +DATE: 2020-02-02 -FONTLOADERDATE: 2019-10-29 +FONTLOADERDATE: 2020-01-26 Lualibs is a collection of Lua modules useful for general programming. diff --git a/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf b/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf index 725e3cd14b1..721f42266fa 100644 Binary files a/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf and b/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf differ diff --git a/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx b/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx index 66e40a1a6f2..579982e5426 100644 --- a/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx +++ b/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx @@ -37,7 +37,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: lualibs 2019-11-06 v2.69 Lua additional functions.} +\Msg{* Package: lualibs 2020-02-02 v2.70 Lua additional functions.} \Msg{************************************************************************} \keepsilent @@ -107,7 +107,7 @@ and lualibs-extended.lua. %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{lualibs.drv} - [2019/11/06 v2.69 Lua Libraries.] + [2020/02/02 v2.70 Lua Libraries.] \documentclass{ltxdoc} \usepackage{fancyvrb,xspace} \usepackage[x11names]{xcolor} @@ -208,7 +208,7 @@ and lualibs-extended.lua. % \GetFileInfo{lualibs.drv} % % \title{The \identifier{lualibs} package} -% \date{2019/11/06 v2.69} +% \date{2020/02/02 v2.70} % \author{Élie Roux · \email{elie.roux@telecom-bretagne.eu}\\ % Philipp Gesang · \email{phg@phi-gamma.net}\\ % The \LaTeX3 Project · \email{https://github.com/latex3/lualibs/}\\ @@ -429,8 +429,8 @@ lualibs = lualibs or { } lualibs.module_info = { name = "lualibs", - version = "2.69", --TAGVERSION - date = "2019-11-06", --TAGDATE + version = "2.70", --TAGVERSION + date = "2020-02-02", --TAGDATE description = "ConTeXt Lua standard libraries.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", @@ -583,8 +583,8 @@ local loadmodule = lualibs.loadmodule local lualibs_basic_module = { name = "lualibs-basic", - version = "2.69", --TAGVERSION - date = "2019-11-06", --TAGDATE + version = "2.70", --TAGVERSION + date = "2020-02-02", --TAGDATE description = "ConTeXt Lua libraries -- basic collection.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", @@ -665,8 +665,8 @@ lualibs = lualibs or { } local lualibs_extended_module = { name = "lualibs-extended", - version = "2.69", --TAGVERSION - date = "2019-11-06", --TAGDATE + version = "2.70", --TAGVERSION + date = "2020-02-02", --TAGDATE description = "ConTeXt Lua libraries -- extended collection.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua index bee6c7de542..38c4debd9b4 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua @@ -1,6 +1,6 @@ -- merged file : lualibs-basic-merged.lua -- parent file : lualibs-basic.lua --- merge date : Tue Oct 29 16:47:31 2019 +-- merge date : Sun Feb 2 22:31:00 2020 do -- begin closure to overcome local limits and interference @@ -20,9 +20,6 @@ if LUAVERSION<5.2 and jit then MINORVERSION=2 LUAVERSION=5.2 end -if lua and lua.openfile then - io.open=lua.openfile -end if not lpeg then lpeg=require("lpeg") end @@ -1369,7 +1366,7 @@ if not modules then modules={} end modules ['l-table']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -local type,next,tostring,tonumber,select=type,next,tostring,tonumber,select +local type,next,tostring,tonumber,select,rawget=type,next,tostring,tonumber,select,rawget local table,string=table,string local concat,sort=table.concat,table.sort local format,lower,dump=string.format,string.lower,string.dump @@ -2774,7 +2771,7 @@ local open,flush,write,read=io.open,io.flush,io.write,io.read local byte,find,gsub,format=string.byte,string.find,string.gsub,string.format local concat=table.concat local type=type -if string.find(os.getenv("PATH"),";",1,true) then +if string.find(os.getenv("PATH") or "",";",1,true) then io.fileseparator,io.pathseparator="\\",";" else io.fileseparator,io.pathseparator="/",":" @@ -3121,7 +3118,7 @@ local date,time=os.date,os.time local find,format,gsub,upper,gmatch=string.find,string.format,string.gsub,string.upper,string.gmatch local concat=table.concat local random,ceil,randomseed=math.random,math.ceil,math.randomseed -local rawget,rawset,type,getmetatable,setmetatable,tonumber,tostring=rawget,rawset,type,getmetatable,setmetatable,tonumber,tostring +local type,setmetatable,tonumber,tostring=type,setmetatable,tonumber,tostring do local selfdir=os.selfdir if selfdir=="" then @@ -3567,15 +3564,24 @@ local checkedsplit=string.checkedsplit local P,R,S,C,Cs,Cp,Cc,Ct=lpeg.P,lpeg.R,lpeg.S,lpeg.C,lpeg.Cs,lpeg.Cp,lpeg.Cc,lpeg.Ct local attributes=lfs.attributes function lfs.isdir(name) - return attributes(name,"mode")=="directory" + if name then + return attributes(name,"mode")=="directory" + end end function lfs.isfile(name) - local a=attributes(name,"mode") - return a=="file" or a=="link" or nil + if name then + local a=attributes(name,"mode") + return a=="file" or a=="link" or nil + end end function lfs.isfound(name) - local a=attributes(name,"mode") - return (a=="file" or a=="link") and name or nil + if name then + local a=attributes(name,"mode") + return (a=="file" or a=="link") and name or nil + end +end +function lfs.modification(name) + return name and attributes(name,"modification") or nil end if sandbox then sandbox.redefine(lfs.isfile,"lfs.isfile") @@ -3957,35 +3963,46 @@ if not modules then modules={} end modules ['l-gzip']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -if gzip then - local suffix,suffixes=file.suffix,file.suffixes +gzip=gzip or {} +if not zlib then + zlib=xzip +elseif not xzip then + xzip=zlib +end +if zlib then + local suffix=file.suffix + local suffixes=file.suffixes + local find=string.find + local openfile=io.open + local gzipwindow=15+16 + local gziplevel=3 + local identifier="^\x1F\x8B\x08" + local compress=zlib.compress + local decompress=zlib.decompress function gzip.load(filename) - local f=io.open(filename,"rb") + local f=openfile(filename,"rb") if not f then - elseif suffix(filename)=="gz" then - f:close() - local g=gzip.open(filename,"rb") - if g then - local str=g:read("*all") - g:close() - return str - end else - local str=f:read("*all") + local data=f:read("*all") f:close() - return str + if data and data~="" then + if suffix(filename)=="gz" then + data=decompress(data,gzipwindow) + end + return data + end end end - function gzip.save(filename,data) + function gzip.save(filename,data,level) if suffix(filename)~="gz" then filename=filename..".gz" end - local f=io.open(filename,"wb") + local f=openfile(filename,"wb") if f then - local s=zlib.compress(data or "",9,nil,15+16) - f:write(s) + data=compress(data or "",level or gziplevel,nil,gzipwindow) + f:write(data) f:close() - return #s + return #data end end function gzip.suffix(filename) @@ -3993,58 +4010,24 @@ if gzip then local gzipped=extra=="gz" return suffix,gzipped end -else -end -if flate then - local type=type - local find=string.find - local compress=flate.gz_compress - local decompress=flate.gz_decompress - local absmax=128*1024*1024 - local initial=64*1024 - local identifier="^\x1F\x8B\x08" function gzip.compressed(s) return s and find(s,identifier) end function gzip.compress(s,level) if s and not find(s,identifier) then if not level then - level=3 + level=gziplevel elseif level<=0 then return s elseif level>9 then level=9 end - return compress(s,level) or s + return compress(s,level or gziplevel,nil,gzipwindow) or s end end - function gzip.decompress(s,size,iterate) + function gzip.decompress(s) if s and find(s,identifier) then - if type(size)~="number" then - size=initial - end - if size>absmax then - size=absmax - end - if type(iterate)=="number" then - max=size*iterate - elseif iterate==nil or iterate==true then - iterate=true - max=absmax - end - if max>absmax then - max=absmax - end - while true do - local d=decompress(s,size) - if d then - return d - end - size=2*size - if not iterate or size>max then - return false - end - end + return decompress(s,gzipwindow) else return s end @@ -4072,6 +4055,8 @@ if not md5 then end local md5,file=md5,file local gsub=string.gsub +local modification,isfile,touch=lfs.modification,lfs.isfile,lfs.touch +local loaddata,savedata=io.loaddata,io.savedata do local patterns=lpeg and lpeg.patterns if patterns then @@ -4087,10 +4072,11 @@ do md5.sumHEXA=md5.HEX end end +local md5HEX=md5.HEX function file.needsupdating(oldname,newname,threshold) - local oldtime=lfs.attributes(oldname,"modification") + local oldtime=modification(oldname) if oldtime then - local newtime=lfs.attributes(newname,"modification") + local newtime=modification(newname) if not newtime then return true elseif newtime>=oldtime then @@ -4106,31 +4092,32 @@ function file.needsupdating(oldname,newname,threshold) end file.needs_updating=file.needsupdating function file.syncmtimes(oldname,newname) - local oldtime=lfs.attributes(oldname,"modification") - if oldtime and lfs.isfile(newname) then - lfs.touch(newname,oldtime,oldtime) + local oldtime=modification(oldname) + if oldtime and isfile(newname) then + touch(newname,oldtime,oldtime) end end -function file.checksum(name) +local function checksum(name) if md5 then - local data=io.loaddata(name) + local data=loaddata(name) if data then - return md5.HEX(data) + return md5HEX(data) end end return nil end +file.checksum=checksum function file.loadchecksum(name) if md5 then - local data=io.loaddata(name..".md5") + local data=loaddata(name..".md5") return data and (gsub(data,"%s","")) end return nil end function file.savechecksum(name,checksum) - if not checksum then checksum=file.checksum(name) end + if not checksum then checksum=checksum(name) end if checksum then - io.savedata(name..".md5",checksum) + savedata(name..".md5",checksum) return checksum end return nil diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua index a9c63e68139..807e81c752b 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua @@ -29,8 +29,8 @@ local loadmodule = lualibs.loadmodule local lualibs_basic_module = { name = "lualibs-basic", - version = "2.69", --TAGVERSION - date = "2019-11-06", --TAGDATE + version = "2.70", --TAGVERSION + date = "2020-02-02", --TAGDATE description = "ConTeXt Lua libraries -- basic collection.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua index c2502401af4..acf7c5a0c5e 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended-merged.lua @@ -1,6 +1,6 @@ -- merged file : lualibs-extended-merged.lua -- parent file : lualibs-extended.lua --- merge date : Tue Oct 29 16:47:22 2019 +-- merge date : Sun Feb 2 22:30:49 2020 do -- begin closure to overcome local limits and interference @@ -579,7 +579,7 @@ local format_N if environment.FORMAT then n=n+1 if not f or f=="" then return format("FORMAT(a%s,'%%.9f')",n) - elseif f==".6" then + elseif f==".6" or f=="0.6" then return format("FORMAT(a%s)",n) else return format("FORMAT(a%s,'%%%sf')",n,f) @@ -4134,8 +4134,11 @@ function stacker.new(name) insert(tops,top) end local function resolve_step(ti) + if not top then + return + end local result=nil - local noftop=top and #top or 0 + local noftop=#top if ti>0 then local current=list[ti] if current then diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua index 6ddf9216d7d..df53b86b458 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua @@ -30,8 +30,8 @@ lualibs = lualibs or { } local lualibs_extended_module = { name = "lualibs-extended", - version = "2.69", --TAGVERSION - date = "2019-11-06", --TAGDATE + version = "2.70", --TAGVERSION + date = "2020-02-02", --TAGDATE description = "ConTeXt Lua libraries -- extended collection.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua index 1b039a43866..d0af94f09d4 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua @@ -76,17 +76,27 @@ local P, R, S, C, Cs, Cp, Cc, Ct = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cs, lpeg local attributes = lfs.attributes function lfs.isdir(name) - return attributes(name,"mode") == "directory" + if name then + return attributes(name,"mode") == "directory" + end end function lfs.isfile(name) - local a = attributes(name,"mode") - return a == "file" or a == "link" or nil + if name then + local a = attributes(name,"mode") + return a == "file" or a == "link" or nil + end end function lfs.isfound(name) - local a = attributes(name,"mode") - return (a == "file" or a == "link") and name or nil + if name then + local a = attributes(name,"mode") + return (a == "file" or a == "link") and name or nil + end +end + +function lfs.modification(name) + return name and attributes(name,"modification") or nil end if sandbox then diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-gzip.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-gzip.lua index 31466bde8f4..f141b5ebbbe 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-gzip.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-gzip.lua @@ -5,39 +5,77 @@ if not modules then modules = { } end modules ['l-gzip'] = { license = "see context related readme files" } -if gzip then +-- 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 | 16 +-- auto : 15 | 32 + +gzip = gzip or { } -- so in luatex we keep the old ones too + +if not zlib then + zlib = xzip -- in luametatex we shadow the old one +elseif not xzip then + xzip = zlib +end + +if zlib then - local suffix, suffixes = file.suffix, file.suffixes + local suffix = file.suffix + local suffixes = file.suffixes + local find = string.find + local openfile = io.open + + local gzipwindow = 15 + 16 -- +16: gzip, +32: gzip|zlib + local gziplevel = 3 + local identifier = "^\x1F\x8B\x08" + + local compress = zlib.compress + local decompress = zlib.decompress function gzip.load(filename) - local f = io.open(filename,"rb") + local f = openfile(filename,"rb") if not f then -- invalid file - elseif suffix(filename) == "gz" then - f:close() - local g = gzip.open(filename,"rb") - if g then - local str = g:read("*all") - g:close() - return str - end else - local str = f:read("*all") + local data = f:read("*all") f:close() - return str + if data and data ~= "" then + if suffix(filename) == "gz" then + data = decompress(data,gzipwindow) + end + return data + end end end - function gzip.save(filename,data) + function gzip.save(filename,data,level) if suffix(filename) ~= "gz" then filename = filename .. ".gz" end - local f = io.open(filename,"wb") + local f = openfile(filename,"wb") if f then - local s = zlib.compress(data or "",9,nil,15+16) - f:write(s) + data = compress(data or "",level or gziplevel,nil,gzipwindow) + f:write(data) f:close() - return #s + return #data end end @@ -47,24 +85,6 @@ if gzip then return suffix, gzipped end -else - - -- todo: fallback on flate - -end - -if flate then - - local type = type - local find = string.find - - local compress = flate.gz_compress - local decompress = flate.gz_decompress - - local absmax = 128*1024*1024 - local initial = 64*1024 - local identifier = "^\x1F\x8B\x08" - function gzip.compressed(s) return s and find(s,identifier) end @@ -72,46 +92,89 @@ if flate then function gzip.compress(s,level) if s and not find(s,identifier) then -- the find check might go away if not level then - level = 3 + level = gziplevel elseif level <= 0 then return s elseif level > 9 then level = 9 end - return compress(s,level) or s + return compress(s,level or gziplevel,nil,gzipwindow) or s end end - function gzip.decompress(s,size,iterate) + function gzip.decompress(s) if s and find(s,identifier) then - if type(size) ~= "number" then - size = initial - end - if size > absmax then - size = absmax - end - if type(iterate) == "number" then - max = size * iterate - elseif iterate == nil or iterate == true then - iterate = true - max = absmax - end - if max > absmax then - max = absmax - end - while true do - local d = decompress(s,size) - if d then - return d - end - size = 2 * size - if not iterate or size > max then - return false - end - end + return decompress(s,gzipwindow) else return s end end end + +-- In luametatex we can use this one but it doesn't look like there wil be stream +-- support so for now we still use zlib (the performance difference is not that +-- spectacular in our usage. + +-- if flate then +-- +-- local type = type +-- local find = string.find +-- +-- local compress = flate.gz_compress +-- local decompress = flate.gz_decompress +-- +-- local absmax = 128*1024*1024 +-- local initial = 64*1024 +-- local identifier = "^\x1F\x8B\x08" +-- +-- function gzip.compressed(s) +-- return s and find(s,identifier) +-- 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 = 3 +-- elseif level <= 0 then +-- return s +-- elseif level > 9 then +-- level = 9 +-- end +-- return compress(s,level) or s +-- end +-- end +-- +-- function gzip.decompress(s,size,iterate) +-- if s and find(s,identifier) then +-- if type(size) ~= "number" then +-- size = initial +-- end +-- if size > absmax then +-- size = absmax +-- end +-- if type(iterate) == "number" then +-- max = size * iterate +-- elseif iterate == nil or iterate == true then +-- iterate = true +-- max = absmax +-- end +-- if max > absmax then +-- max = absmax +-- end +-- while true do +-- local d = decompress(s,size) +-- if d then +-- return d +-- end +-- size = 2 * size +-- if not iterate or size > max then +-- return false +-- end +-- end +-- else +-- return s +-- end +-- end +-- +-- end diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-io.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-io.lua index fa3ad3c4cda..a955262a31e 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-io.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-io.lua @@ -13,7 +13,7 @@ local concat = table.concat ----- floor = math.floor local type = type -if string.find(os.getenv("PATH"),";",1,true) then +if string.find(os.getenv("PATH") or "",";",1,true) then io.fileseparator, io.pathseparator = "\\", ";" else io.fileseparator, io.pathseparator = "/" , ":" diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua index 51399216ccf..f411230d4aa 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua @@ -37,9 +37,9 @@ end -- this is lmtx only: -if lua and lua.openfile then - io.open = lua.openfile -end +-- if lua and lua.openfile then +-- io.open = lua.openfile +-- end -- lpeg diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-md5.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-md5.lua index 6758fa44441..9e3f7672d6b 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-md5.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-md5.lua @@ -20,6 +20,8 @@ end local md5, file = md5, file local gsub = string.gsub +local modification, isfile, touch = lfs.modification, lfs.isfile, lfs.touch +local loaddata, savedata = io.loaddata, io.savedata -- local gsub, format, byte = string.gsub, string.format, string.byte -- @@ -55,10 +57,12 @@ do end +local md5HEX = md5.HEX + function file.needsupdating(oldname,newname,threshold) -- size modification access change - local oldtime = lfs.attributes(oldname,"modification") + local oldtime = modification(oldname) if oldtime then - local newtime = lfs.attributes(newname,"modification") + local newtime = modification(newname) if not newtime then return true -- no new file, so no updating needed elseif newtime >= oldtime then @@ -76,34 +80,36 @@ end file.needs_updating = file.needsupdating function file.syncmtimes(oldname,newname) - local oldtime = lfs.attributes(oldname,"modification") - if oldtime and lfs.isfile(newname) then - lfs.touch(newname,oldtime,oldtime) + local oldtime = modification(oldname) + if oldtime and isfile(newname) then + touch(newname,oldtime,oldtime) end end -function file.checksum(name) +local function checksum(name) if md5 then - local data = io.loaddata(name) + local data = loaddata(name) if data then - return md5.HEX(data) + return md5HEX(data) end end return nil end +file.checksum = checksum + function file.loadchecksum(name) if md5 then - local data = io.loaddata(name .. ".md5") + local data = loaddata(name .. ".md5") return data and (gsub(data,"%s","")) end return nil end function file.savechecksum(name,checksum) - if not checksum then checksum = file.checksum(name) end + if not checksum then checksum = checksum(name) end if checksum then - io.savedata(name .. ".md5",checksum) + savedata(name .. ".md5",checksum) return checksum end return nil diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua index aa04e254df8..8394d19e7cc 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-os.lua @@ -30,7 +30,7 @@ local date, time = os.date, os.time local find, format, gsub, upper, gmatch = string.find, string.format, string.gsub, string.upper, string.gmatch local concat = table.concat local random, ceil, randomseed = math.random, math.ceil, math.randomseed -local rawget, rawset, type, getmetatable, setmetatable, tonumber, tostring = rawget, rawset, type, getmetatable, setmetatable, tonumber, tostring +local type, setmetatable, tonumber, tostring = type, setmetatable, tonumber, tostring -- This check needs to happen real early on. Todo: we can pick it up from the commandline -- if we pass --binpath= (which is useful anyway) diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua index e8282038674..98b377bdc1c 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua @@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['l-table'] = { license = "see context related readme files" } -local type, next, tostring, tonumber, select = type, next, tostring, tonumber, select +local type, next, tostring, tonumber, select, rawget = type, next, tostring, tonumber, select, rawget local table, string = table, string local concat, sort = table.concat, table.sort local format, lower, dump = string.format, string.lower, string.dump diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-sta.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-sta.lua index 7819395f69c..9ca1c67e9ad 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-sta.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-sta.lua @@ -81,6 +81,8 @@ end function stacker.new(name) + -- to be sped up, mmaybe foo:bar syntax here but then quite some access + local report = logs.reporter("stacker",name or nil) local s @@ -93,6 +95,7 @@ function stacker.new(name) local hashing = true local function push(...) + -- todo check if more than 1 argument for i=1,select("#",...) do insert(stack,(select(i,...))) -- watch the () end @@ -153,8 +156,12 @@ function stacker.new(name) local function resolve_step(ti) -- keep track of changes outside function ! -- todo: optimize for n=1 etc + if not top then + -- report("messed op stacker %a",name) + return + end local result = nil - local noftop = top and #top or 0 + local noftop = #top if ti > 0 then local current = list[ti] if current then diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua index 432b39ec5ad..68c9be5860b 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua @@ -944,7 +944,7 @@ local format_N if environment.FORMAT then n = n + 1 if not f or f == "" then return format("FORMAT(a%s,'%%.9f')",n) - elseif f == ".6" then + elseif f == ".6" or f == "0.6" then return format("FORMAT(a%s)",n) else return format("FORMAT(a%s,'%%%sf')",n,f) diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua index 14d24ff7880..ea6f1eb208b 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua @@ -25,8 +25,8 @@ lualibs = lualibs or { } lualibs.module_info = { name = "lualibs", - version = "2.69", --TAGVERSION - date = "2019-11-06", --TAGDATE + version = "2.70", --TAGVERSION + date = "2020-02-02", --TAGDATE description = "ConTeXt Lua standard libraries.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", -- cgit v1.2.3