diff options
16 files changed, 272 insertions, 168 deletions
diff --git a/Master/texmf-dist/doc/luatex/lualibs/NEWS b/Master/texmf-dist/doc/luatex/lualibs/NEWS index 60642ef03bc..66ee05e8cba 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 +2019/08/11 v2.67/ + * sync with Context current as of 2019/08/11 + 2019/07/04 v2.66/ * sync with Context current as of 2019/07/04 * changed kpse initialization to avoid conflicts with latex-dev format diff --git a/Master/texmf-dist/doc/luatex/lualibs/README b/Master/texmf-dist/doc/luatex/lualibs/README deleted file mode 100644 index ad344eab2f9..00000000000 --- a/Master/texmf-dist/doc/luatex/lualibs/README +++ /dev/null @@ -1,95 +0,0 @@ -******************************************************************************** - The Lualibs Package -******************************************************************************** - - -Lualibs is a collection of Lua modules useful for general programming. - -This work is based on Lua modules shipped with ConTeXt, to make them available -for use independent of ConTeXt. - -This package has been developed by the LuaLaTeX development team on -<http://github.com/lualatex/lualibs>. - -The current verson 2.6601 has been build by Ulrike Fischer on -<https://github.com/u-fischer/lualibs> from context 2019-06-20. - -See the 'NEWS' file for version history. - - - -Installation --------------------------------------------------------------------------------- - - -1. If you are using TeX Live 2010 or later use 'tlmgr install lualibs'. - With miktex, use the miktex console. - Alternatively, use your (TeX or Linux) distribution's package management - system. - -2. a. Grab lualibs.tds.zip on CTAN. - b. Unzip it at the root of one or your TDS trees. - c. You may need to update some filename database after this, see your TeX - distribution's manual for details. - - -Manifest --------------------------------------------------------------------------------- - file TDS location - -Source files: - lualibs.dtx source/luatex/lualibs/lualibs.dtx - lualibs-boolean.lua tex/luatex/lualibs/lualibs-boolean.lua - lualibs-compat.lua tex/luatex/lualibs/lualibs-compat.lua - lualibs-dir.lua tex/luatex/lualibs/lualibs-dir.lua - lualibs-file.lua tex/luatex/lualibs/lualibs-file.lua - lualibs-gzip.lua tex/luatex/lualibs/lualibs-gzip.lua - lualibs-function.lua tex/luatex/lualibs/lualibs-function.lua - lualibs-io.lua tex/luatex/lualibs/lualibs-io.lua - lualibs-lpeg.lua tex/luatex/lualibs/lualibs-lpeg.lua - lualibs-lua.lua tex/luatex/lualibs/lualibs-lua.lua - lualibs-math.lua tex/luatex/lualibs/lualibs-math.lua - lualibs-md5.lua tex/luatex/lualibs/lualibs-md5.lua - lualibs-number.lua tex/luatex/lualibs/lualibs-number.lua - lualibs-os.lua tex/luatex/lualibs/lualibs-os.lua - lualibs-package.lua tex/luatex/lualibs/lualibs-package.lua - lualibs-set.lua tex/luatex/lualibs/lualibs-set.lua - lualibs-string.lua tex/luatex/lualibs/lualibs-string.lua - lualibs-table.lua tex/luatex/lualibs/lualibs-table.lua - lualibs-trac-inf.lua tex/luatex/lualibs/lualibs-trac-inf.lua - lualibs-unicode.lua* tex/luatex/lualibs/lualibs-unicode.lua - lualibs-url.lua tex/luatex/lualibs/lualibs-url.lua - lualibs-util-deb.lua tex/luatex/lualibs/lualibs-util-deb.lua - lualibs-util-dim.lua tex/luatex/lualibs/lualibs-util-dim.lua - lualibs-util-jsn.lua tex/luatex/lualibs/lualibs-util-jsn.lua - lualibs-util-lua.lua tex/luatex/lualibs/lualibs-util-lua.lua - lualibs-util-prs.lua tex/luatex/lualibs/lualibs-util-prs.lua - lualibs-util-sta.lua tex/luatex/lualibs/lualibs-util-sta.lua - lualibs-util-sto.lua tex/luatex/lualibs/lualibs-util-sto.lua - lualibs-util-str.lua tex/luatex/lualibs/lualibs-util-str.lua - lualibs-util-tab.lua tex/luatex/lualibs/lualibs-util-tab.lua - lualibs-util-tpl.lua tex/luatex/lualibs/lualibs-util-tpl.lua - LICENSE doc/luatex/lualibs/LICENSE - NEWS doc/luatex/lualibs/NEWS - README doc/luatex/lualibs/README - -* the file has been modified to enable the unicode library again - -Derived files: - lualibs.lua tex/luatex/lualibs/lualibs.lua - lualibs-basic.lua tex/luatex/lualibs/lualibs-basic.lua - lualibs-basic-merged.lua tex/luatex/lualibs/lualibs-basic-merged.lua - lualibs-extended.lua tex/luatex/lualibs/lualibs-extended.lua - lualibs-extended-merged.lua tex/luatex/lualibs/lualibs-extended-merged.lua - lualibs.pdf doc/luatex/lualibs/lualibs.pdf - -License and Copyright --------------------------------------------------------------------------------- - -As a derived work of Context, this work and the derived files are under the -GNU GPL v.2.0 license. -The full text of the license is included in the file LICENSE. - -The files taken from Context (lualibs-*.lua) are copyright PRAGMA ADE / ConTeXt -Development Team. - diff --git a/Master/texmf-dist/doc/luatex/lualibs/README.md b/Master/texmf-dist/doc/luatex/lualibs/README.md new file mode 100644 index 00000000000..b89ca40fb71 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/lualibs/README.md @@ -0,0 +1,99 @@ +# The Lualibs Package + +VERSION: 2.67 + +DATE: 2019-08-11 + +Lualibs is a collection of Lua modules useful for general programming. + +This work is based on Lua modules shipped with ConTeXt, to make them available +for use independent of ConTeXt. + +This package has been developed by the LuaLaTeX development team on +<https://github.com/lualatex/lualibs>. + +The current version has been build by Ulrike Fischer on +<https://github.com/u-fischer/lualibs>. The date equals the date of the context files. + +See the 'NEWS' file for version history. + + + +## Installation + + +1. If you are using TeX Live 2010 or later use 'tlmgr install lualibs'. + With miktex, use the miktex console. + Alternatively, use your (TeX or Linux) distribution's package management + system. + +2. + 1. Grab lualibs.tds.zip on CTAN. + 2. Unzip it at the root of one or your TDS trees. + 3. You may need to update some filename database after this, see your TeX + distribution's manual for details. + + +## Manifest + +### Source files: + +| file | TDS location +|------------------------------------|----------------------------------- +| lualibs.dtx |source/luatex/lualibs/lualibs.dtx +| lualibs-boolean.lua |tex/luatex/lualibs/lualibs-boolean.lua +| lualibs-compat.lua |tex/luatex/lualibs/lualibs-compat.lua +| lualibs-dir.lua |tex/luatex/lualibs/lualibs-dir.lua +| lualibs-file.lua | tex/luatex/lualibs/lualibs-file.lua +| lualibs-gzip.lua | tex/luatex/lualibs/lualibs-gzip.lua +| lualibs-function.lua | tex/luatex/lualibs/lualibs-function.lua +| lualibs-io.lua | tex/luatex/lualibs/lualibs-io.lua +| lualibs-lpeg.lua | tex/luatex/lualibs/lualibs-lpeg.lua +| lualibs-lua.lua | tex/luatex/lualibs/lualibs-lua.lua +| lualibs-math.lua | tex/luatex/lualibs/lualibs-math.lua +| lualibs-md5.lua | tex/luatex/lualibs/lualibs-md5.lua +| lualibs-number.lua | tex/luatex/lualibs/lualibs-number.lua +| lualibs-os.lua | tex/luatex/lualibs/lualibs-os.lua +| lualibs-package.lua | tex/luatex/lualibs/lualibs-package.lua +| lualibs-set.lua | tex/luatex/lualibs/lualibs-set.lua +| lualibs-string.lua | tex/luatex/lualibs/lualibs-string.lua +| lualibs-table.lua | tex/luatex/lualibs/lualibs-table.lua +| lualibs-trac-inf.lua | tex/luatex/lualibs/lualibs-trac-inf.lua +| lualibs-unicode.lua\* | tex/luatex/lualibs/lualibs-unicode.lua +| lualibs-url.lua | tex/luatex/lualibs/lualibs-url.lua +| lualibs-util-deb.lua | tex/luatex/lualibs/lualibs-util-deb.lua +| lualibs-util-dim.lua | tex/luatex/lualibs/lualibs-util-dim.lua +| lualibs-util-jsn.lua | tex/luatex/lualibs/lualibs-util-jsn.lua +| lualibs-util-lua.lua | tex/luatex/lualibs/lualibs-util-lua.lua +| lualibs-util-prs.lua | tex/luatex/lualibs/lualibs-util-prs.lua +| lualibs-util-sta.lua | tex/luatex/lualibs/lualibs-util-sta.lua +| lualibs-util-sto.lua | tex/luatex/lualibs/lualibs-util-sto.lua +| lualibs-util-str.lua | tex/luatex/lualibs/lualibs-util-str.lua +| lualibs-util-tab.lua | tex/luatex/lualibs/lualibs-util-tab.lua +| lualibs-util-tpl.lua | tex/luatex/lualibs/lualibs-util-tpl.lua +| LICENSE | doc/luatex/lualibs/LICENSE +| NEWS | doc/luatex/lualibs/NEWS +| README | doc/luatex/lualibs/README + +\* the file has been modified to enable the unicode library again + +### Derived files: + +| file | TDS location +|------------------------------------|----------------------------------- +| lualibs.lua | tex/luatex/lualibs/lualibs.lua +| lualibs-basic.lua | tex/luatex/lualibs/lualibs-basic.lua +| lualibs-basic-merged.lua | tex/luatex/lualibs/lualibs-basic-merged.lua +| lualibs-extended.lua | tex/luatex/lualibs/lualibs-extended.lua +| lualibs-extended-merged.lua | tex/luatex/lualibs/lualibs-extended-merged.lua +| lualibs.pdf | doc/luatex/lualibs/lualibs.pdf + +## License and Copyright + +As a derived work of Context, this work and the derived files are under the +GNU GPL v.2.0 license. +The full text of the license is included in the file LICENSE. + +The files taken from Context (lualibs-*.lua) are copyright PRAGMA ADE / ConTeXt +Development Team. + diff --git a/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf b/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf Binary files differindex 6bc0b58f8fc..ad1ee3061b3 100644 --- a/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf +++ b/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf diff --git a/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx b/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx index eae5742b0bb..8c302400f1f 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-07-04 v2.66 Lua additional functions.} +\Msg{* Package: lualibs 2019-08-11 v2.67 Lua additional functions.} \Msg{************************************************************************} \keepsilent @@ -107,7 +107,7 @@ and lualibs-extended.lua. %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{lualibs.drv} - [2019/07/04 v2.66 Lua Libraries.] + [2019/08/11 v2.67 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/07/04 v2.66} +% \date{2019/08/11 v2.67} % \author{Élie Roux · \email{elie.roux@telecom-bretagne.eu}\\ % Philipp Gesang · \email{phg@phi-gamma.net}\\ % Ulrike Fischer · \email{fischer@troubleshooting-tex.de}\\ @@ -429,8 +429,8 @@ lualibs = lualibs or { } lualibs.module_info = { name = "lualibs", - version = 2.66, - date = "2019-07-04", + version = "2.67", --TAGVERSION + date = "2019-08-11", --TAGDATE description = "ConTeXt Lua standard libraries.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", @@ -505,8 +505,7 @@ do lualibs.error, lualibs.warn, lualibs.info = error, warn, info end -local info = status.list() -if info.kpse_used == 0 then +if status.kpse_used == 0 then kpse.set_program_name("luatex") end @@ -584,8 +583,8 @@ local loadmodule = lualibs.loadmodule local lualibs_basic_module = { name = "lualibs-basic", - version = 2.66, - date = "2019-07-04", + version = "2.67", --TAGVERSION + date = "2019-08-11", --TAGDATE description = "ConTeXt Lua libraries -- basic collection.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", @@ -666,8 +665,8 @@ lualibs = lualibs or { } local lualibs_extended_module = { name = "lualibs-extended", - version = 2.66, - date = "2019-07-04", + version = "2.67", --TAGVERSION + date = "2019-08-11", --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 7d5e0d07b1a..0cb07cea2a5 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 : Sun Jul 14 15:31:33 2019 +-- merge date : Tue Aug 13 20:13:08 2019 do -- begin closure to overcome local limits and interference @@ -121,6 +121,9 @@ elseif not ffi.number then end if LUAVERSION>5.3 then end +if status and os.setenv then + os.setenv("engine",string.lower(status.luatex_engine or "unknown")) +end end -- closure @@ -2305,7 +2308,7 @@ end local function sequenced(t,sep,simple) if not t then return "" - elseif type(t)=="string" then + elseif type(t)~="table" then return t end local n=#t @@ -2344,7 +2347,11 @@ local function sequenced(t,sep,simple) end end end - return concat(s,sep or " | ") + if sep==true then + return "{ "..concat(s,", ").." }" + else + return concat(s,sep or " | ") + end end table.sequenced=sequenced function table.print(t,...) diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua index d04c8eebe49..a3092708957 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.66, - date = "2019-07-04", + version = "2.67", --TAGVERSION + date = "2019-08-11", --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 672787f9e50..b3fecf2c3e7 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 : Sun Jul 14 15:31:26 2019 +-- merge date : Tue Aug 13 20:12:59 2019 do -- begin closure to overcome local limits and interference @@ -332,6 +332,13 @@ local template=[[ %s return function(%s) return %s end ]] +local pattern=Cs(Cc('"')*( + (1-S('"\\\n\r'))^1+P('"')/'\\"'+P('\\')/'\\\\'+P('\n')/'\\n'+P('\r')/'\\r' +)^0*Cc('"')) +patterns.escapedquotes=pattern +function string.escapedquotes(s) + return lpegmatch(pattern,s) +end local preamble="" local environment={ global=global or _G, @@ -358,6 +365,7 @@ local environment={ formattedfloat=number.formattedfloat, stripzero=patterns.stripzero, stripzeros=patterns.stripzeros, + escapedquotes=string.escapedquotes, FORMAT=string.f9, } local arguments={ "a1" } @@ -415,7 +423,7 @@ local format_q=function() end local format_Q=function() n=n+1 - return format("format('%%q',tostring(a%s))",n) + return format("escapedquotes(tostring(a%s))",n) end local format_i=function(f) n=n+1 @@ -1389,15 +1397,15 @@ function tables.encapsulate(core,capsule,protect) } ) end end -local f_hashed_string=formatters["[%q]=%q,"] -local f_hashed_number=formatters["[%q]=%s,"] -local f_hashed_boolean=formatters["[%q]=%l,"] -local f_hashed_table=formatters["[%q]="] -local f_indexed_string=formatters["[%s]=%q,"] +local f_hashed_string=formatters["[%Q]=%Q,"] +local f_hashed_number=formatters["[%Q]=%s,"] +local f_hashed_boolean=formatters["[%Q]=%l,"] +local f_hashed_table=formatters["[%Q]="] +local f_indexed_string=formatters["[%s]=%Q,"] local f_indexed_number=formatters["[%s]=%s,"] local f_indexed_boolean=formatters["[%s]=%l,"] local f_indexed_table=formatters["[%s]="] -local f_ordered_string=formatters["%q,"] +local f_ordered_string=formatters["%Q,"] local f_ordered_number=formatters["%s,"] local f_ordered_boolean=formatters["%l,"] function table.fastserialize(t,prefix) @@ -1560,22 +1568,22 @@ local f_start_key_boo=formatters["%w[%l]={"] local f_start_key_nop=formatters["%w{"] local f_stop=formatters["%w},"] local f_key_num_value_num=formatters["%w[%s]=%s,"] -local f_key_str_value_num=formatters["%w[%q]=%s,"] +local f_key_str_value_num=formatters["%w[%Q]=%s,"] local f_key_boo_value_num=formatters["%w[%l]=%s,"] -local f_key_num_value_str=formatters["%w[%s]=%q,"] -local f_key_str_value_str=formatters["%w[%q]=%q,"] -local f_key_boo_value_str=formatters["%w[%l]=%q,"] +local f_key_num_value_str=formatters["%w[%s]=%Q,"] +local f_key_str_value_str=formatters["%w[%Q]=%Q,"] +local f_key_boo_value_str=formatters["%w[%l]=%Q,"] local f_key_num_value_boo=formatters["%w[%s]=%l,"] -local f_key_str_value_boo=formatters["%w[%q]=%l,"] +local f_key_str_value_boo=formatters["%w[%Q]=%l,"] local f_key_boo_value_boo=formatters["%w[%l]=%l,"] local f_key_num_value_not=formatters["%w[%s]={},"] -local f_key_str_value_not=formatters["%w[%q]={},"] +local f_key_str_value_not=formatters["%w[%Q]={},"] local f_key_boo_value_not=formatters["%w[%l]={},"] local f_key_num_value_seq=formatters["%w[%s]={ %, t },"] -local f_key_str_value_seq=formatters["%w[%q]={ %, t },"] +local f_key_str_value_seq=formatters["%w[%Q]={ %, t },"] local f_key_boo_value_seq=formatters["%w[%l]={ %, t },"] local f_val_num=formatters["%w%s,"] -local f_val_str=formatters["%w%q,"] +local f_val_str=formatters["%w%Q,"] local f_val_boo=formatters["%w%l,"] local f_val_not=formatters["%w{},"] local f_val_seq=formatters["%w{ %, t },"] @@ -1583,7 +1591,7 @@ local f_fin_seq=formatters[" %, t }"] local f_table_return=formatters["return {"] local f_table_name=formatters["%s={"] local f_table_direct=formatters["{"] -local f_table_entry=formatters["[%q]={"] +local f_table_entry=formatters["[%Q]={"] local f_table_finish=formatters["}"] local spaces=utilities.strings.newrepeater(" ") local original_serialize=table.serialize @@ -2826,10 +2834,13 @@ do local f_key_val_num=f_key_val_seq local f_key_val_yes=formatters[ "\n"..'%w"%s" : true' ] local f_key_val_nop=formatters[ "\n"..'%w"%s" : false' ] + local f_key_val_null=formatters[ "\n"..'%w"%s" : null' ] local f_val_num=formatters[ "\n"..'%w%s' ] local f_val_str=formatters[ "\n"..'%w"%s"' ] local f_val_yes=formatters[ "\n"..'%wtrue' ] local f_val_nop=formatters[ "\n"..'%wfalse' ] + local f_val_null=formatters[ "\n"..'%wnull' ] + local f_val_empty=formatters[ "\n"..'%w{ }' ] local f_val_seq=f_val_num local t={} local n=0 @@ -2857,8 +2868,10 @@ do n=n+1 t[n]='"' elseif tv=="boolean" then n=n+1 t[n]=v and "true" or "false" - else + elseif v then n=n+1 t[n]=tostring(v) + else + n=n+1 t[n]="null" end end n=n+1 t[n]=" ]" @@ -2915,8 +2928,11 @@ do if st then n=n+1 t[n]=f_val_seq(depth,st) else - tojsonpp(v,k,depth,level+1,0) + tojsonpp(v,nil,depth,level+1,#v) end + else + n=n+1 + t[n]=f_val_empty(depth) end elseif tv=="boolean" then n=n+1 @@ -2925,6 +2941,9 @@ do else t[n]=f_val_nop(depth,v) end + else + n=n+1 + t[n]=f_val_null(depth) end end elseif next(root) then @@ -2942,12 +2961,12 @@ do n=n+1 t[n]=f_key_val_num(depth,k,v) elseif tk=="string" then k=lpegmatch(escaper,k) or k - n=n+1 t[n]=f_key_val_str(depth,k,v) + n=n+1 t[n]=f_key_val_num(depth,k,v) end elseif tv=="string" then if tk=="number" then v=lpegmatch(escaper,v) or v - n=n+1 t[n]=f_key_val_num(depth,k,v) + n=n+1 t[n]=f_key_val_str(depth,k,v) elseif tk=="string" then k=lpegmatch(escaper,k) or k v=lpegmatch(escaper,v) or v @@ -2985,6 +3004,15 @@ do t[n]=f_key_val_nop(depth,k) end end + else + if tk=="number" then + n=n+1 + t[n]=f_key_val_null(depth,k) + elseif tk=="string" then + k=lpegmatch(escaper,k) or k + n=n+1 + t[n]=f_key_val_null(depth,k) + end end end end @@ -3042,6 +3070,8 @@ do n=n+1;t[n]=value elseif kind=="boolean" then n=n+1;t[n]=tostring(value) + else + n=n+1;t[n]="null" end return t,n end @@ -3066,7 +3096,7 @@ do tojsonpp(value,name,0,0,#value) value=concat(t,"",1,n) else - tojson(value,0) + t,n=tojson(value,0) value=concat(t,"",1,n) end t=nil @@ -3279,7 +3309,11 @@ function statistics.show() end function statistics.memused() local round=math.round or math.floor - return format("%s MB (ctx: %s MB)",round(collectgarbage("count")/1000),round(status.luastate_bytes/1000000)) + return format("%s MB, ctx: %s MB, max: %s MB)", + round(collectgarbage("count")/1000), + round(status.luastate_bytes/1000000), + status.luastate_bytes_max and round(status.luastate_bytes_max/1000000) or "unknown" + ) end starttiming(statistics) function statistics.formatruntime(runtime) diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua index 1013fe54580..0b91f6a7c20 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.66, - date = "2019-07-04", + version = "2.67", --TAGVERSION + date = "2019-08-11", --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-lua.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua index 5570e83dc8d..6e9606e849f 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua @@ -212,7 +212,7 @@ FFISUPPORTED = type(ffi) == "table" and ffi.os ~= "" and ffi.arch ~= "" and ffi. if not FFISUPPORTED then - -- Maybe we should check for LUATEXENGINE but that's also a bti tricky as we still + -- Maybe we should check for LUATEXENGINE but that's also a bit tricky as we still -- can have a weird ffi library laying around. Checking for presence of 'jit' is -- also not robust. So for now we hope for the best. @@ -253,3 +253,7 @@ if LUAVERSION > 5.3 then -- collectgarbage("collect") -- collectgarbage("generational") -- crashes on unix end + +if status and os.setenv then + os.setenv("engine",string.lower(status.luatex_engine or "unknown")) +end diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua index 192347b0619..cffdcc23e20 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-table.lua @@ -1261,10 +1261,12 @@ function table.reverse(t) -- check with 5.3 ? end end +-- This one is for really simple cases where need a hash from a table. + local function sequenced(t,sep,simple) if not t then return "" - elseif type(t) == "string" then + elseif type(t) ~= "table" then return t -- handy fallback end local n = #t @@ -1305,7 +1307,11 @@ local function sequenced(t,sep,simple) end end end - return concat(s,sep or " | ") + if sep == true then + return "{ " .. concat(s,", ") .. " }" + else + return concat(s,sep or " | ") + end end table.sequenced = sequenced diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua index 0a4537e3177..24ebc524997 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua @@ -262,7 +262,11 @@ end function statistics.memused() -- no math.round yet -) local round = math.round or math.floor - return format("%s MB (ctx: %s MB)",round(collectgarbage("count")/1000), round(status.luastate_bytes/1000000)) + return format("%s MB, ctx: %s MB, max: %s MB)", + round(collectgarbage("count")/1000), + round(status.luastate_bytes/1000000), + status.luastate_bytes_max and round(status.luastate_bytes_max/1000000) or "unknown" + ) end starttiming(statistics) diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-jsn.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-jsn.lua index 68c6a712edd..8da35189793 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-jsn.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-jsn.lua @@ -122,11 +122,14 @@ do local f_key_val_num = f_key_val_seq local f_key_val_yes = formatters[ "\n" .. '%w"%s" : true' ] local f_key_val_nop = formatters[ "\n" .. '%w"%s" : false' ] + local f_key_val_null = formatters[ "\n" .. '%w"%s" : null' ] local f_val_num = formatters[ "\n" .. '%w%s' ] local f_val_str = formatters[ "\n" .. '%w"%s"' ] local f_val_yes = formatters[ "\n" .. '%wtrue' ] local f_val_nop = formatters[ "\n" .. '%wfalse' ] + local f_val_null = formatters[ "\n" .. '%wnull' ] + local f_val_empty = formatters[ "\n" .. '%w{ }' ] local f_val_seq = f_val_num -- no empty tables because unknown if table or hash @@ -158,8 +161,10 @@ do n = n + 1 t[n] = '"' elseif tv == "boolean" then n = n + 1 t[n] = v and "true" or "false" - else + elseif v then n = n + 1 t[n] = tostring(v) + else + n = n + 1 t[n] = "null" end end n = n + 1 t[n] = " ]" @@ -217,8 +222,11 @@ do if st then n = n + 1 t[n] = f_val_seq(depth,st) else - tojsonpp(v,k,depth,level+1,0) + tojsonpp(v,nil,depth,level+1,#v) end + else + n = n + 1 + t[n] = f_val_empty(depth) end elseif tv == "boolean" then n = n + 1 @@ -227,6 +235,9 @@ do else t[n] = f_val_nop(depth,v) end + else + n = n + 1 + t[n] = f_val_null(depth) end end elseif next(root) then @@ -244,12 +255,12 @@ do n = n + 1 t[n] = f_key_val_num(depth,k,v) elseif tk == "string" then k = lpegmatch(escaper,k) or k - n = n + 1 t[n] = f_key_val_str(depth,k,v) + n = n + 1 t[n] = f_key_val_num(depth,k,v) end elseif tv == "string" then if tk == "number" then v = lpegmatch(escaper,v) or v - n = n + 1 t[n] = f_key_val_num(depth,k,v) + n = n + 1 t[n] = f_key_val_str(depth,k,v) elseif tk == "string" then k = lpegmatch(escaper,k) or k v = lpegmatch(escaper,v) or v @@ -287,6 +298,15 @@ do t[n] = f_key_val_nop(depth,k) end end + else + if tk == "number" then + n = n + 1 + t[n] = f_key_val_null(depth,k) + elseif tk == "string" then + k = lpegmatch(escaper,k) or k + n = n + 1 + t[n] = f_key_val_null(depth,k) + end end end end @@ -348,6 +368,8 @@ do n = n + 1 ; t[n] = value elseif kind == "boolean" then n = n + 1 ; t[n] = tostring(value) + else + n = n + 1 ; t[n] = "null" end return t, n end @@ -377,10 +399,9 @@ do n = 0 if pretty then tojsonpp(value,name,0,0,#value) --- value = concat(t,"\n",1,n) value = concat(t,"",1,n) else - tojson(value,0) + t, n = tojson(value,0) value = concat(t,"",1,n) end t = nil 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 5470c2fd698..ad22302df0c 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-str.lua @@ -584,6 +584,26 @@ local template = [[ return function(%s) return %s end ]] +-- this might move + +local pattern = Cs(Cc('"') * ( + (1-S('"\\\n\r'))^1 + + P('"') / '\\"' + + P('\\') / '\\\\' + + P('\n') / '\\n' + + P('\r') / '\\r' +)^0 * Cc('"')) + +patterns.escapedquotes = pattern + +function string.escapedquotes(s) + return lpegmatch(pattern,s) +end + +-- print(string.escapedquotes('1\\23\n"')) + +-- but for now here + local preamble = "" local environment = { @@ -611,6 +631,7 @@ local environment = { formattedfloat = number.formattedfloat, stripzero = patterns.stripzero, stripzeros = patterns.stripzeros, + escapedquotes = string.escapedquotes, FORMAT = string.f9, } @@ -685,11 +706,13 @@ local format_q = function() -- lua 5.3 has a different q than lua 5.2 (which does a tostring on numbers) -- return format("(a%s ~= nil and format('%%q',a%s) or '')",n,n) return format("(a%s ~= nil and format('%%q',tostring(a%s)) or '')",n,n) + -- return format("(a%s ~= nil and escapedquotes(tostring(a%s)) or '')",n,n) end -local format_Q = function() -- can be optimized +local format_Q = function() -- fast escaping n = n + 1 - return format("format('%%q',tostring(a%s))",n) +-- return format("format('%%q',tostring(a%s))",n) + return format("escapedquotes(tostring(a%s))",n) end local format_i = function(f) diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua index 2f425cca384..f970d8ace0f 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua @@ -314,21 +314,21 @@ end -- best keep [%q] keys (as we have some in older applications i.e. saving user data (otherwise -- we also need to check for reserved words) -local f_hashed_string = formatters["[%q]=%q,"] -local f_hashed_number = formatters["[%q]=%s,"] -local f_hashed_boolean = formatters["[%q]=%l,"] -local f_hashed_table = formatters["[%q]="] +local f_hashed_string = formatters["[%Q]=%Q,"] +local f_hashed_number = formatters["[%Q]=%s,"] +local f_hashed_boolean = formatters["[%Q]=%l,"] +local f_hashed_table = formatters["[%Q]="] -local f_indexed_string = formatters["[%s]=%q,"] +local f_indexed_string = formatters["[%s]=%Q,"] local f_indexed_number = formatters["[%s]=%s,"] local f_indexed_boolean = formatters["[%s]=%l,"] local f_indexed_table = formatters["[%s]="] -local f_ordered_string = formatters["%q,"] +local f_ordered_string = formatters["%Q,"] local f_ordered_number = formatters["%s,"] local f_ordered_boolean = formatters["%l,"] -function table.fastserialize(t,prefix) +function table.fastserialize(t,prefix) -- todo, move local function out -- prefix should contain the = -- not sorted @@ -525,27 +525,27 @@ local f_start_key_nop = formatters["%w{"] local f_stop = formatters["%w},"] local f_key_num_value_num = formatters["%w[%s]=%s,"] -local f_key_str_value_num = formatters["%w[%q]=%s,"] +local f_key_str_value_num = formatters["%w[%Q]=%s,"] local f_key_boo_value_num = formatters["%w[%l]=%s,"] -local f_key_num_value_str = formatters["%w[%s]=%q,"] -local f_key_str_value_str = formatters["%w[%q]=%q,"] -local f_key_boo_value_str = formatters["%w[%l]=%q,"] +local f_key_num_value_str = formatters["%w[%s]=%Q,"] +local f_key_str_value_str = formatters["%w[%Q]=%Q,"] +local f_key_boo_value_str = formatters["%w[%l]=%Q,"] local f_key_num_value_boo = formatters["%w[%s]=%l,"] -local f_key_str_value_boo = formatters["%w[%q]=%l,"] +local f_key_str_value_boo = formatters["%w[%Q]=%l,"] local f_key_boo_value_boo = formatters["%w[%l]=%l,"] local f_key_num_value_not = formatters["%w[%s]={},"] -local f_key_str_value_not = formatters["%w[%q]={},"] +local f_key_str_value_not = formatters["%w[%Q]={},"] local f_key_boo_value_not = formatters["%w[%l]={},"] local f_key_num_value_seq = formatters["%w[%s]={ %, t },"] -local f_key_str_value_seq = formatters["%w[%q]={ %, t },"] +local f_key_str_value_seq = formatters["%w[%Q]={ %, t },"] local f_key_boo_value_seq = formatters["%w[%l]={ %, t },"] local f_val_num = formatters["%w%s,"] -local f_val_str = formatters["%w%q,"] +local f_val_str = formatters["%w%Q,"] local f_val_boo = formatters["%w%l,"] local f_val_not = formatters["%w{},"] local f_val_seq = formatters["%w{ %, t },"] @@ -554,7 +554,7 @@ local f_fin_seq = formatters[" %, t }"] local f_table_return = formatters["return {"] local f_table_name = formatters["%s={"] local f_table_direct = formatters["{"] -local f_table_entry = formatters["[%q]={"] +local f_table_entry = formatters["[%Q]={"] local f_table_finish = formatters["}"] ----- f_string = formatters["%q"] diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua index 02243c8df47..649fe16025e 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.66, - date = "2019-07-04", + version = "2.67", --TAGVERSION + date = "2019-08-11", --TAGDATE description = "ConTeXt Lua standard libraries.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", @@ -79,8 +79,7 @@ do lualibs.error, lualibs.warn, lualibs.info = error, warn, info end -local info = status.list() -if info.kpse_used == 0 then +if status.kpse_used == 0 then kpse.set_program_name("luatex") end |