diff options
Diffstat (limited to 'Master')
16 files changed, 401 insertions, 51 deletions
diff --git a/Master/texmf-dist/doc/luatex/lualibs/NEWS b/Master/texmf-dist/doc/luatex/lualibs/NEWS index 01642e6fbcc..0a5f935c2c5 100644 --- a/Master/texmf-dist/doc/luatex/lualibs/NEWS +++ b/Master/texmf-dist/doc/luatex/lualibs/NEWS @@ -1,7 +1,13 @@ History of the lualibs package +2016/04/06 v2.4/ + * sync with Context beta as of 2016-04-06 + * basic maintenance + * include util-fil.lua, a fontloader requirement, in the extended + collection + 2015/12/02 v2.3/ * sync with Context beta as of 2015-11-19 - * basic maintainance + * basic maintenance 2014/05/05 v2.2/ * sync with Context beta as of 2014-07-26 diff --git a/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf b/Master/texmf-dist/doc/luatex/lualibs/lualibs.pdf Binary files differindex 7a6b98ca2f0..1b097641b6b 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 23ba5d8a79a..291049d265d 100644 --- a/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx +++ b/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 2009--2015 by +% Copyright (C) 2009--2016 by % % PRAGMA ADE / ConTeXt Development Team % The LuaLaTeX Dev Team @@ -37,7 +37,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: lualibs 2015-12-02 v2.3 Lua additional functions.} +\Msg{* Package: lualibs 2016-04-06 v2.4 Lua additional functions.} \Msg{************************************************************************} \keepsilent @@ -48,7 +48,7 @@ \preamble This is a generated file. -Copyright (C) 2009--2015 by +Copyright (C) 2009--2016 by PRAGMA ADE / ConTeXt Development Team The LuaLaTeX Dev Team @@ -107,7 +107,7 @@ and lualibs-extended.lua. %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{lualibs.drv} - [2015/12/02 v2.3 Lua Libraries.] + [2016/04/06 v2.4 Lua Libraries.] \documentclass{ltxdoc} \usepackage{fancyvrb,xspace} \usepackage[x11names]{xcolor} @@ -208,9 +208,9 @@ and lualibs-extended.lua. % \GetFileInfo{lualibs.drv} % % \title{The \identifier{lualibs} package} -% \date{2015/12/02 v2.3} +% \date{2016/04/06 v2.4} % \author{Élie Roux · \email{elie.roux@telecom-bretagne.eu}\\ -% Philipp Gesang · \email{philipp.gesang@alumni.uni-heidelberg.de}} +% Philipp Gesang · \email{phg@phi-gamma.net}} % % \maketitle % @@ -346,6 +346,7 @@ and lualibs-extended.lua. % \begin{tabular}{l l l} % \identifier{lualibs} name & \CONTEXT name & primary purpose \\[1ex] % lualibs-util-str.lua & util-str.lua & extra |string| functions \\ +% lualibs-util-fil.lua & util-fil.lua & extra |file| functions \\ % lualibs-util-tab.lua & util-tab.lua & extra |table| functions \\ % lualibs-util-sto.lua & util-sto.lua & table allocation \\ % lualibs-util-prs.lua & util-sto.lua & miscellaneous parsers \\ @@ -426,8 +427,8 @@ lualibs = lualibs or { } lualibs.module_info = { name = "lualibs", - version = 2.3, - date = "2015-12-02", + version = 2.4, + date = "2016-04-06", description = "ConTeXt Lua standard libraries.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", @@ -581,8 +582,8 @@ local loadmodule = lualibs.loadmodule local lualibs_basic_module = { name = "lualibs-basic", - version = 2.3, - date = "2015-12-02", + version = 2.4, + date = "2016-04-06", description = "ConTeXt Lua libraries -- basic collection.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", @@ -663,8 +664,8 @@ lualibs = lualibs or { } local lualibs_extended_module = { name = "lualibs-extended", - version = 2.3, - date = "2015-12-02", + version = 2.4, + date = "2016-04-06", description = "ConTeXt Lua libraries -- extended collection.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", @@ -776,6 +777,7 @@ end if loaded == false then loadmodule("lualibs-util-str.lua")--- string formatters (fast) + loadmodule("lualibs-util-fil.lua")--- extra file helpers loadmodule("lualibs-util-tab.lua")--- extended table operations loadmodule("lualibs-util-sto.lua")--- storage (hash allocation) ----------("lualibs-util-pck.lua")---!packers; necessary? diff --git a/Master/texmf-dist/source/luatex/lualibs/whatsnew.lua b/Master/texmf-dist/source/luatex/lualibs/whatsnew.lua index e9cc3789630..35533ca8142 100644 --- a/Master/texmf-dist/source/luatex/lualibs/whatsnew.lua +++ b/Master/texmf-dist/source/luatex/lualibs/whatsnew.lua @@ -17,7 +17,7 @@ local prefixsep = "-" local namespace = "lualibs" local luasuffix = ".lua" -local basedir = "/home/phg/context/tex/texmf-context/tex/context/base" +local basedir = "/home/phg/context/tex/texmf-context/tex/context/base/mkiv" local cmd_diff = [[diff "%s" "%s"]] ----------------------------------------------------------------------- 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 fecdf77232c..ec56b75dc70 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 : Wed Dec 2 07:52:44 2015 +-- merge date : Wed Apr 6 23:53:30 2016 do -- begin closure to overcome local limits and interference @@ -11,10 +11,14 @@ if not modules then modules={} end modules ['l-lua']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -local major,minor=string.match(_VERSION,"^[^%d]+(%d+)%.(%d+).*$") -_MAJORVERSION=tonumber(major) or 5 -_MINORVERSION=tonumber(minor) or 1 +_MAJORVERSION,_MINORVERSION=string.match(_VERSION,"^[^%d]+(%d+)%.(%d+).*$") +_MAJORVERSION=tonumber(_MAJORVERSION) or 5 +_MINORVERSION=tonumber(_MINORVERSION) or 1 _LUAVERSION=_MAJORVERSION+_MINORVERSION/10 +if _LUAVERSION<5.2 and jit then + _MINORVERSION=2 + _LUAVERSION=5.2 +end if not lpeg then lpeg=require("lpeg") end @@ -429,7 +433,7 @@ local uppercase=R("AZ") local underscore=P("_") local hexdigit=digit+lowercase+uppercase local cr,lf,crlf=P("\r"),P("\n"),P("\r\n") -local newline=P("\r")*(P("\n")+P(true))+P("\n") +local newline=P("\r")*(P("\n")+P(true))+P("\n") local escaped=P("\\")*anything local squote=P("'") local dquote=P('"') @@ -4402,9 +4406,10 @@ if not utf.sub then end end end -function utf.remapper(mapping,option) +function utf.remapper(mapping,option,action) local variant=type(mapping) if variant=="table" then + action=action or mapping if option=="dynamic" then local pattern=false table.setmetatablenewindex(mapping,function(t,k,v) rawset(t,k,v) pattern=false end) @@ -4413,15 +4418,15 @@ function utf.remapper(mapping,option) return "" else if not pattern then - pattern=Cs((tabletopattern(mapping)/mapping+p_utf8char)^0) + pattern=Cs((tabletopattern(mapping)/action+p_utf8char)^0) end return lpegmatch(pattern,str) end end elseif option=="pattern" then - return Cs((tabletopattern(mapping)/mapping+p_utf8char)^0) + return Cs((tabletopattern(mapping)/action+p_utf8char)^0) else - local pattern=Cs((tabletopattern(mapping)/mapping+p_utf8char)^0) + local pattern=Cs((tabletopattern(mapping)/action+p_utf8char)^0) return function(str) if not str or str=="" then return "" diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua index 7c8e6f71a96..1cd0c280c6e 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua @@ -7,7 +7,7 @@ -- lualibs.dtx (with options: `basic') -- This is a generated file. -- --- Copyright (C) 2009--2015 by +-- Copyright (C) 2009--2016 by -- PRAGMA ADE / ConTeXt Development Team -- The LuaLaTeX Dev Team -- @@ -29,8 +29,8 @@ local loadmodule = lualibs.loadmodule local lualibs_basic_module = { name = "lualibs-basic", - version = 2.3, - date = "2015-12-02", + version = 2.4, + date = "2016-04-06", 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 3c30f8b7bdc..db833a05eb0 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 : Wed Dec 2 07:52:44 2015 +-- merge date : Wed Apr 6 23:53:30 2016 do -- begin closure to overcome local limits and interference @@ -693,6 +693,149 @@ end -- closure do -- begin closure to overcome local limits and interference +if not modules then modules={} end modules ['util-fil']={ + version=1.001, + comment="companion to luat-lib.mkiv", + author="Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright="PRAGMA ADE / ConTeXt Development Team", + license="see context related readme files" +} +local byte=string.byte +local extract=bit32.extract +utilities=utilities or {} +local files={} +utilities.files=files +local zerobased={} +function files.open(filename,zb) + local f=io.open(filename,"rb") + if f then + zerobased[f]=zb or false + end + return f +end +function files.close(f) + zerobased[f]=nil + f:close() +end +function files.size(f) + return f:seek("end") +end +function files.setposition(f,n) + if zerobased[f] then + f:seek("set",n) + else + f:seek("set",n-1) + end +end +function files.getposition(f) + if zerobased[f] then + return f:seek() + else + return f:seek()+1 + end +end +function files.look(f,n,chars) + local p=f:seek() + local s=f:read(n) + f:seek("set",p) + if chars then + return s + else + return byte(s,1,#s) + end +end +function files.skip(f,n) + if n==1 then + f:read(n) + else + f:seek("set",f:seek()+n) + end +end +function files.readbyte(f) + return byte(f:read(1)) +end +function files.readbytes(f,n) + return byte(f:read(n),1,n) +end +function files.readchar(f) + return f:read(1) +end +function files.readstring(f,n) + return f:read(n or 1) +end +function files.readinteger1(f) + local n=byte(f:read(1)) + if n>=0x80 then + return n-0xFF-1 + else + return n + end +end +files.readcardinal1=files.readbyte +files.readcardinal=files.readcardinal1 +files.readinteger=files.readinteger1 +function files.readcardinal2(f) + local a,b=byte(f:read(2),1,2) + return 0x100*a+b +end +function files.readinteger2(f) + local a,b=byte(f:read(2),1,2) + local n=0x100*a+b + if n>=0x8000 then + return n-0xFFFF-1 + else + return n + end +end +function files.readcardinal3(f) + local a,b,c=byte(f:read(3),1,3) + return 0x10000*a+0x100*b+c +end +function files.readcardinal4(f) + local a,b,c,d=byte(f:read(4),1,4) + return 0x1000000*a+0x10000*b+0x100*c+d +end +function files.readinteger4(f) + local a,b,c,d=byte(f:read(4),1,4) + local n=0x1000000*a+0x10000*b+0x100*c+d + if n>=0x8000000 then + return n-0xFFFFFFFF-1 + else + return n + end +end +function files.readfixed4(f) + local a,b,c,d=byte(f:read(4),1,4) + local n=0x100*a+b + if n>=0x8000 then + return n-0xFFFF-1+(0x100*c+d)/0xFFFF + else + return n+(0x100*c+d)/0xFFFF + end +end +function files.read2dot14(f) + local a,b=byte(f:read(2),1,2) + local n=0x100*a+b + local m=extract(n,0,30) + if n>0x7FFF then + n=extract(n,30,2) + return m/0x4000-4 + else + n=extract(n,30,2) + return n+m/0x4000 + end +end +function files.skipshort(f,n) + f:read(2*(n or 1)) +end +function files.skiplong(f,n) + f:read(4*(n or 1)) +end + +end -- closure + +do -- begin closure to overcome local limits and interference + if not modules then modules={} end modules ['util-tab']={ version=1.001, comment="companion to luat-lib.mkiv", @@ -1352,7 +1495,7 @@ local function serialize(root,name,specification) end table.serialize=serialize if setinspector then - setinspector("table",function(v) if type(v)=="table" then print(serialize(v,"table")) return true end end) + setinspector("table",function(v) if type(v)=="table" then print(serialize(v,"table",{})) return true end end) end end -- closure @@ -1516,6 +1659,8 @@ local setmetatableindex=table.setmetatableindex local sortedhash=table.sortedhash local sortedkeys=table.sortedkeys local tohash=table.tohash +local hashes={} +utilities.parsers.hashes=hashes local digit=R("09") local space=P(' ') local equal=P("=") @@ -1734,9 +1879,15 @@ function parsers.array_to_string(a,separator) end end local pattern=Cf(Ct("")*Cg(C((1-S(", "))^1)*S(", ")^0*Cc(true))^1,rawset) -function utilities.parsers.settings_to_set(str,t) +function utilities.parsers.settings_to_set(str) return str and lpegmatch(pattern,str) or {} end +hashes.settings_to_set=table.setmetatableindex(function(t,k) + local v=k and lpegmatch(pattern,k) or {} + t[k]=v + return v +end) +getmetatable(hashes.settings_to_set).__mode="kv" function parsers.simple_hash_to_string(h,separator) local t,tn={},0 for k,v in sortedhash(h) do @@ -2426,13 +2577,13 @@ function statistics.show() end end register("lua properties",function() - local list=status.list() - local hashchar=tonumber(list.luatex_hashchars) + local hashchar=tonumber(status.luatex_hashchars) + local hashtype=status.luatex_hashtype local mask=lua.mask or "ascii" return format("engine: %s, used memory: %s, hash type: %s, hash chars: min(%s,40), symbol mask: %s (%s)", jit and "luajit" or "lua", statistics.memused(), - list.luatex_hashtype or "default", + hashtype or "default", hashchar and 2^hashchar or "unknown", mask, mask=="utf" and "τεχ" or "tex") diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua index 67455628911..fdd50b80ba3 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua @@ -7,7 +7,7 @@ -- lualibs.dtx (with options: `extended') -- This is a generated file. -- --- Copyright (C) 2009--2015 by +-- Copyright (C) 2009--2016 by -- PRAGMA ADE / ConTeXt Development Team -- The LuaLaTeX Dev Team -- @@ -30,8 +30,8 @@ lualibs = lualibs or { } local lualibs_extended_module = { name = "lualibs-extended", - version = 2.3, - date = "2015-12-02", + version = 2.4, + date = "2016-04-06", description = "ConTeXt Lua libraries -- extended collection.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", @@ -120,6 +120,7 @@ end if loaded == false then loadmodule("lualibs-util-str.lua")--- string formatters (fast) + loadmodule("lualibs-util-fil.lua")--- extra file helpers loadmodule("lualibs-util-tab.lua")--- extended table operations loadmodule("lualibs-util-sto.lua")--- storage (hash allocation) ----------("lualibs-util-pck.lua")---!packers; necessary? diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua index 5be12468bc6..959ca553eb8 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua @@ -110,7 +110,7 @@ local underscore = P("_") local hexdigit = digit + lowercase + uppercase local cr, lf, crlf = P("\r"), P("\n"), P("\r\n") ----- newline = crlf + S("\r\n") -- cr + lf -local newline = P("\r") * (P("\n") + P(true)) + P("\n") +local newline = P("\r") * (P("\n") + P(true)) + P("\n") -- P("\r")^-1 * P("\n")^-1 local escaped = P("\\") * anything local squote = P("'") local dquote = P('"') diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua index cb6182907bf..b90f37e3db3 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-lua.lua @@ -19,12 +19,20 @@ if not modules then modules = { } end modules ['l-lua'] = { -- compatibility hacksand helpers -local major, minor = string.match(_VERSION,"^[^%d]+(%d+)%.(%d+).*$") +_MAJORVERSION, _MINORVERSION = string.match(_VERSION,"^[^%d]+(%d+)%.(%d+).*$") -_MAJORVERSION = tonumber(major) or 5 -_MINORVERSION = tonumber(minor) or 1 +_MAJORVERSION = tonumber(_MAJORVERSION) or 5 +_MINORVERSION = tonumber(_MINORVERSION) or 1 _LUAVERSION = _MAJORVERSION + _MINORVERSION/10 +if _LUAVERSION < 5.2 and jit then + -- + -- we want loadstring cum suis to behave like 5.2 + -- + _MINORVERSION = 2 + _LUAVERSION = 5.2 +end + -- lpeg if not lpeg then 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 5497e54eb70..f4c4e555787 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-trac-inf.lua @@ -145,13 +145,13 @@ function statistics.show() -- so far -- collectgarbage("collect") register("lua properties",function() - local list = status.list() - local hashchar = tonumber(list.luatex_hashchars) + local hashchar = tonumber(status.luatex_hashchars) + local hashtype = status.luatex_hashtype local mask = lua.mask or "ascii" return format("engine: %s, used memory: %s, hash type: %s, hash chars: min(%s,40), symbol mask: %s (%s)", jit and "luajit" or "lua", statistics.memused(), - list.luatex_hashtype or "default", + hashtype or "default", hashchar and 2^hashchar or "unknown", mask, mask == "utf" and "τεχ" or "tex") diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua index 70b60324ac2..3dec8001345 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-unicode.lua @@ -528,9 +528,10 @@ end -- end, pattern -- end -function utf.remapper(mapping,option) -- static also returns a pattern +function utf.remapper(mapping,option,action) -- static also returns a pattern local variant = type(mapping) if variant == "table" then + action = action or mapping if option == "dynamic" then local pattern = false table.setmetatablenewindex(mapping,function(t,k,v) rawset(t,k,v) pattern = false end) @@ -539,16 +540,16 @@ function utf.remapper(mapping,option) -- static also returns a pattern return "" else if not pattern then - pattern = Cs((tabletopattern(mapping)/mapping + p_utf8char)^0) + pattern = Cs((tabletopattern(mapping)/action + p_utf8char)^0) end return lpegmatch(pattern,str) end end elseif option == "pattern" then - return Cs((tabletopattern(mapping)/mapping + p_utf8char)^0) + return Cs((tabletopattern(mapping)/action + p_utf8char)^0) -- elseif option == "static" then else - local pattern = Cs((tabletopattern(mapping)/mapping + p_utf8char)^0) + local pattern = Cs((tabletopattern(mapping)/action + p_utf8char)^0) return function(str) if not str or str == "" then return "" diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-fil.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-fil.lua new file mode 100644 index 00000000000..28c92c7c3c3 --- /dev/null +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-fil.lua @@ -0,0 +1,167 @@ +if not modules then modules = { } end modules ['util-fil'] = { + version = 1.001, + comment = "companion to luat-lib.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local byte = string.byte +local extract = bit32.extract + +-- Here are a few helpers (the starting point were old ones I used for parsing +-- flac files). In Lua 5.3 we can probably do this better. Some code will move +-- here. + +utilities = utilities or { } +local files = { } +utilities.files = files + +local zerobased = { } + +function files.open(filename,zb) + local f = io.open(filename,"rb") + if f then + zerobased[f] = zb or false + end + return f +end + +function files.close(f) + zerobased[f] = nil + f:close() +end + +function files.size(f) + return f:seek("end") +end + +function files.setposition(f,n) + if zerobased[f] then + f:seek("set",n) + else + f:seek("set",n - 1) + end +end + +function files.getposition(f) + if zerobased[f] then + return f:seek() + else + return f:seek() + 1 + end +end + +function files.look(f,n,chars) + local p = f:seek() + local s = f:read(n) + f:seek("set",p) + if chars then + return s + else + return byte(s,1,#s) + end +end + +function files.skip(f,n) + if n == 1 then + f:read(n) + else + f:seek("set",f:seek()+n) + end +end + +function files.readbyte(f) + return byte(f:read(1)) +end + +function files.readbytes(f,n) + return byte(f:read(n),1,n) +end + +function files.readchar(f) + return f:read(1) +end + +function files.readstring(f,n) + return f:read(n or 1) +end + +function files.readinteger1(f) -- one byte + local n = byte(f:read(1)) + if n >= 0x80 then + return n - 0xFF - 1 + else + return n + end +end + +files.readcardinal1 = files.readbyte -- one byte +files.readcardinal = files.readcardinal1 +files.readinteger = files.readinteger1 + +function files.readcardinal2(f) + local a, b = byte(f:read(2),1,2) + return 0x100 * a + b +end + +function files.readinteger2(f) + local a, b = byte(f:read(2),1,2) + local n = 0x100 * a + b + if n >= 0x8000 then + return n - 0xFFFF - 1 + else + return n + end +end + +function files.readcardinal3(f) + local a, b, c = byte(f:read(3),1,3) + return 0x10000 * a + 0x100 * b + c +end + +function files.readcardinal4(f) + local a, b, c, d = byte(f:read(4),1,4) + return 0x1000000 * a + 0x10000 * b + 0x100 * c + d +end + +function files.readinteger4(f) + local a, b, c, d = byte(f:read(4),1,4) + local n = 0x1000000 * a + 0x10000 * b + 0x100 * c + d + if n >= 0x8000000 then + return n - 0xFFFFFFFF - 1 + else + return n + end +end + +function files.readfixed4(f) + local a, b, c, d = byte(f:read(4),1,4) + local n = 0x100 * a + b + if n >= 0x8000 then + return n - 0xFFFF - 1 + (0x100 * c + d)/0xFFFF + else + return n + (0x100 * c + d)/0xFFFF + end +end + +function files.read2dot14(f) + local a, b = byte(f:read(2),1,2) + local n = 0x100 * a + b + local m = extract(n,0,30) + if n > 0x7FFF then + n = extract(n,30,2) + return m/0x4000 - 4 + else + n = extract(n,30,2) + return n + m/0x4000 + end +end + +function files.skipshort(f,n) + f:read(2*(n or 1)) +end + +function files.skiplong(f,n) + f:read(4*(n or 1)) +end diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua index a3c1c6f8f23..01138f1bbb3 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua @@ -24,6 +24,8 @@ local sortedhash = table.sortedhash local sortedkeys = table.sortedkeys local tohash = table.tohash +local hashes = { } +utilities.parsers.hashes = hashes -- we share some patterns local digit = R("09") @@ -315,10 +317,17 @@ end local pattern = Cf(Ct("") * Cg(C((1-S(", "))^1) * S(", ")^0 * Cc(true))^1,rawset) -function utilities.parsers.settings_to_set(str,t) +function utilities.parsers.settings_to_set(str) return str and lpegmatch(pattern,str) or { } end +hashes.settings_to_set = table.setmetatableindex(function(t,k) -- experiment, not public + local v = k and lpegmatch(pattern,k) or { } + t[k] = v + return v +end) + +getmetatable(hashes.settings_to_set).__mode = "kv" -- could be an option (maybe sharing makes sense) function parsers.simple_hash_to_string(h, separator) local t, tn = { }, 0 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 d6f3d673126..a6239adf409 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-tab.lua @@ -833,5 +833,5 @@ end table.serialize = serialize if setinspector then - setinspector("table",function(v) if type(v) == "table" then print(serialize(v,"table")) return true end end) + setinspector("table",function(v) if type(v) == "table" then print(serialize(v,"table",{})) return true end end) end diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua index 9ee84d64098..9810fd7b46a 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua @@ -7,7 +7,7 @@ -- lualibs.dtx (with options: `lualibs') -- This is a generated file. -- --- Copyright (C) 2009--2015 by +-- Copyright (C) 2009--2016 by -- PRAGMA ADE / ConTeXt Development Team -- The LuaLaTeX Dev Team -- @@ -25,8 +25,8 @@ lualibs = lualibs or { } lualibs.module_info = { name = "lualibs", - version = 2.3, - date = "2015-12-02", + version = 2.4, + date = "2016-04-06", description = "ConTeXt Lua standard libraries.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", |