diff options
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
9 files changed, 193 insertions, 99 deletions
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 19c148ca3e8..358b028300c 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 : Thu May 9 16:30:14 2013 +-- merge date : Sat May 18 12:25:19 2013 do -- begin closure to overcome local limits and interference @@ -2874,7 +2874,11 @@ function file.splitname(str,splitdrive) end end function file.splitbase(str) - return str and lpegmatch(pattern_d,str) + if str then + return lpegmatch(pattern_d,str) + else + return "",str + end end function file.nametotable(str,splitdrive) if str then diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua index 4530756fdb8..5f6bc0fbc77 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-basic.lua @@ -27,7 +27,7 @@ local loadmodule = lualibs.loadmodule local lualibs_basic_module = { name = "lualibs-basic", version = 2.00, - date = "2013/04/30", + date = "2013/05/18", 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 4df0eb6f9cd..fe87e8a09b8 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 : Thu May 9 16:30:14 2013 +-- merge date : Sat May 18 12:25:20 2013 do -- begin closure to overcome local limits and interference @@ -1066,7 +1066,9 @@ patterns.settings_to_hash_a=pattern_a_s patterns.settings_to_hash_b=pattern_b_s patterns.settings_to_hash_c=pattern_c_s function parsers.make_settings_to_hash_pattern(set,how) - if how=="strict" then + if type(str)=="table" then + return set + elseif how=="strict" then return (pattern_c/set)^1 elseif how=="tolerant" then return (pattern_b/set)^1 @@ -1075,7 +1077,16 @@ function parsers.make_settings_to_hash_pattern(set,how) end end function parsers.settings_to_hash(str,existing) - if str and str~="" then + if type(str)=="table" then + if existing then + for k,v in next,str do + existing[k]=v + end + return exiting + else + return str + end + elseif str and str~="" then hash=existing or {} lpegmatch(pattern_a_s,str) return hash @@ -1084,7 +1095,16 @@ function parsers.settings_to_hash(str,existing) end end function parsers.settings_to_hash_tolerant(str,existing) - if str and str~="" then + if type(str)=="table" then + if existing then + for k,v in next,str do + existing[k]=v + end + return exiting + else + return str + end + elseif str and str~="" then hash=existing or {} lpegmatch(pattern_b_s,str) return hash @@ -1093,7 +1113,16 @@ function parsers.settings_to_hash_tolerant(str,existing) end end function parsers.settings_to_hash_strict(str,existing) - if str and str~="" then + if type(str)=="table" then + if existing then + for k,v in next,str do + existing[k]=v + end + return exiting + else + return str + end + elseif str and str~="" then hash=existing or {} lpegmatch(pattern_c_s,str) return next(hash) and hash @@ -1106,7 +1135,9 @@ local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C((nestedbraces+(1-comm local pattern=spaces*Ct(value*(separator*value)^0) patterns.settings_to_array=pattern function parsers.settings_to_array(str,strict) - if not str or str=="" then + if type(str)=="table" then + return str + elseif not str or str=="" then return {} elseif strict then if find(str,"{") then @@ -1594,6 +1625,107 @@ end -- closure do -- begin closure to overcome local limits and interference +if not modules then modules={} end modules ['util-jsn']={ + version=1.001, + comment="companion to m-json.mkiv", + author="Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright="PRAGMA ADE / ConTeXt Development Team", + license="see context related readme files" +} +local P,V,R,S,C,Cc,Cs,Ct,Cf,Cg=lpeg.P,lpeg.V,lpeg.R,lpeg.S,lpeg.C,lpeg.Cc,lpeg.Cs,lpeg.Ct,lpeg.Cf,lpeg.Cg +local lpegmatch=lpeg.match +local format=string.format +local utfchar=utf.char +local concat=table.concat +local tonumber,tostring,rawset,type=tonumber,tostring,rawset,type +local json=utilities.json or {} +utilities.json=json +local lbrace=P("{") +local rbrace=P("}") +local lparent=P("[") +local rparent=P("]") +local comma=P(",") +local colon=P(":") +local dquote=P('"') +local whitespace=lpeg.patterns.whitespace +local optionalws=whitespace^0 +local escape=C(P("\\u")/"0x"*S("09","AF","af"))/function(s) return utfchar(tonumber(s)) end +local jstring=dquote*Cs((escape+(1-dquote))^0)*dquote +local jtrue=P("true")*Cc(true) +local jfalse=P("false")*Cc(false) +local jnull=P("null")*Cc(nil) +local jnumber=(1-whitespace-rparent-rbrace-comma)^1/tonumber +local key=jstring +local jsonconverter={ "value", + object=lbrace*Cf(Ct("")*V("pair")*(comma*V("pair"))^0,rawset)*rbrace, + pair=Cg(optionalws*key*optionalws*colon*V("value")), + array=Ct(lparent*V("value")*(comma*V("value"))^0*rparent), + value=optionalws*(jstring+V("object")+V("array")+jtrue+jfalse+jnull+jnumber+#rparent)*optionalws, +} +function json.tolua(str) + return lpegmatch(jsonconverter,str) +end +local function tojson(value,t) + local kind=type(value) + if kind=="table" then + local done=false + local size=#value + if size==0 then + for k,v in next,value do + if done then + t[#t+1]="," + else + t[#t+1]="{" + done=true + end + t[#t+1]=format("%q:",k) + tojson(v,t) + end + if done then + t[#t+1]="}" + else + t[#t+1]="{}" + end + elseif size==1 then + t[#t+1]="[" + tojson(value[1],t) + t[#t+1]="]" + else + for i=1,size do + if done then + t[#t+1]="," + else + t[#t+1]="[" + done=true + end + tojson(value[i],t) + end + t[#t+1]="]" + end + elseif kind=="string" then + t[#t+1]=format("%q",value) + elseif kind=="number" then + t[#t+1]=value + elseif kind=="boolean" then + t[#t+1]=tostring(value) + end + return t +end +function json.tostring(value) + local kind=type(value) + if kind=="table" then + return concat(tojson(value,{}),"") + elseif kind=="string" or kind=="number" then + return value + else + return tostring(value) + end +end + +end -- closure + +do -- begin closure to overcome local limits and interference + if not modules then modules={} end modules ['trac-inf']={ version=1.001, comment="companion to trac-inf.mkiv", diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua index edd0a215b56..5029c88cb1f 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-extended.lua @@ -28,7 +28,7 @@ lualibs = lualibs or { } local lualibs_extended_module = { name = "lualibs-extended", version = 2.00, - date = "2013/04/30", + date = "2013/05/18", description = "ConTeXt Lua libraries -- extended collection.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", @@ -130,7 +130,7 @@ if loaded == false then loadmodule("lualibs-util-prs.lua")--- miscellaneous parsers; cool. cool cool cool ----------("lualibs-util-fmt.lua")---!column formatter (rarely used) loadmodule("lualibs-util-dim.lua")--- conversions between dimensions - ----------("lualibs-util-jsn.lua")--- JSON parser + loadmodule("lualibs-util-jsn.lua")--- JSON parser ----------("lualibs-trac-set.lua")---!generalization of trackers ----------("lualibs-trac-log.lua")---!logging @@ -146,8 +146,6 @@ if loaded == false then ----------("lualibs-core-con.lua")--- end -loadmodule"lualibs-util-jsn.lua"--- cannot be merged because of return statement - unfake_context() --- TODO check if this works at runtime lualibs.extended_loaded = true diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua index 29416caf03b..acb4216b0d4 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-file.lua @@ -153,7 +153,11 @@ function file.splitname(str,splitdrive) end function file.splitbase(str) - return str and lpegmatch(pattern_d,str) -- returns path, base+suffix + if str then + return lpegmatch(pattern_d,str) -- returns path, base+suffix (path has / appended, might change at some point) + else + return "", str -- assume no path + end end ---- stripslash = C((1 - P("/")^1*P(-1))^0) diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-fmt.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-fmt.lua deleted file mode 100644 index 371a5dfcece..00000000000 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-fmt.lua +++ /dev/null @@ -1,76 +0,0 @@ -if not modules then modules = { } end modules ['util-fmt'] = { - 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" -} - -utilities = utilities or { } -utilities.formatters = utilities.formatters or { } -local formatters = utilities.formatters - -local concat, format = table.concat, string.format -local tostring, type = tostring, type -local strip = string.strip - -local lpegmatch = lpeg.match -local stripper = lpeg.patterns.stripzeros - -function formatters.stripzeros(str) - return lpegmatch(stripper,str) -end - -function formatters.formatcolumns(result,between) - if result and #result > 0 then - between = between or " " - local widths, numbers = { }, { } - local first = result[1] - local n = #first - for i=1,n do - widths[i] = 0 - end - for i=1,#result do - local r = result[i] - for j=1,n do - local rj = r[j] - local tj = type(rj) - if tj == "number" then - numbers[j] = true - end - if tj ~= "string" then - rj = tostring(rj) - r[j] = rj - end - local w = #rj - if w > widths[j] then - widths[j] = w - end - end - end - for i=1,n do - local w = widths[i] - if numbers[i] then - if w > 80 then - widths[i] = "%s" .. between - else - widths[i] = "%0" .. w .. "i" .. between - end - else - if w > 80 then - widths[i] = "%s" .. between - elseif w > 0 then - widths[i] = "%-" .. w .. "s" .. between - else - widths[i] = "%s" - end - end - end - local template = strip(concat(widths)) - for i=1,#result do - local str = format(template,unpack(result[i])) - result[i] = strip(str) - end - end - return result -end 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 7493f108d22..29587cd3834 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-jsn.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-jsn.lua @@ -11,6 +11,9 @@ if not modules then modules = { } end modules ['util-jsn'] = { -- a correct stream. If not, we have some fatal error anyway. So, we can just rely -- on strings being strings (apart from the unicode escape which is not in 5.1) and -- as we first catch known types we just assume that anything else is a number. +-- +-- Reminder for me: check usage in framework and extend when needed. Also document +-- it in the cld lib documentation. local P, V, R, S, C, Cc, Cs, Ct, Cf, Cg = lpeg.P, lpeg.V, lpeg.R, lpeg.S, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Ct, lpeg.Cf, lpeg.Cg local lpegmatch = lpeg.match @@ -141,5 +144,3 @@ end -- inspect(tmp) -- inspect(json.tostring(true)) - -return json 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 31e7ffa535b..cdf497588ea 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-util-prs.lua @@ -93,7 +93,9 @@ patterns.settings_to_hash_b = pattern_b_s patterns.settings_to_hash_c = pattern_c_s function parsers.make_settings_to_hash_pattern(set,how) - if how == "strict" then + if type(str) == "table" then + return set + elseif how == "strict" then return (pattern_c/set)^1 elseif how == "tolerant" then return (pattern_b/set)^1 @@ -103,7 +105,16 @@ function parsers.make_settings_to_hash_pattern(set,how) end function parsers.settings_to_hash(str,existing) - if str and str ~= "" then + if type(str) == "table" then + if existing then + for k, v in next, str do + existing[k] = v + end + return exiting + else + return str + end + elseif str and str ~= "" then hash = existing or { } lpegmatch(pattern_a_s,str) return hash @@ -113,7 +124,16 @@ function parsers.settings_to_hash(str,existing) end function parsers.settings_to_hash_tolerant(str,existing) - if str and str ~= "" then + if type(str) == "table" then + if existing then + for k, v in next, str do + existing[k] = v + end + return exiting + else + return str + end + elseif str and str ~= "" then hash = existing or { } lpegmatch(pattern_b_s,str) return hash @@ -123,7 +143,16 @@ function parsers.settings_to_hash_tolerant(str,existing) end function parsers.settings_to_hash_strict(str,existing) - if str and str ~= "" then + if type(str) == "table" then + if existing then + for k, v in next, str do + existing[k] = v + end + return exiting + else + return str + end + elseif str and str ~= "" then hash = existing or { } lpegmatch(pattern_c_s,str) return next(hash) and hash @@ -144,7 +173,9 @@ patterns.settings_to_array = pattern -- we could use a weak table as cache function parsers.settings_to_array(str,strict) - if not str or str == "" then + if type(str) == "table" then + return str + elseif not str or str == "" then return { } elseif strict then if find(str,"{") then diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua index ae498b20de5..5e4d818e93f 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs.lua @@ -23,7 +23,7 @@ lualibs = lualibs or { } lualibs.module_info = { name = "lualibs", version = 2.00, - date = "2013/04/30", + date = "2013/05/18", description = "ConTeXt Lua standard libraries.", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang", copyright = "PRAGMA ADE / ConTeXt Development Team", @@ -101,7 +101,7 @@ end --- This restores the default of loading everything should a package --- have requested otherwise. Will be gone once there is a canonical --- interface for parameterized loading of libraries. -lualibs.load_extended = true +config.lualibs.load_extended = true -- vim:tw=71:sw=2:ts=2:expandtab |