From 601e63e757d4cf40d5923cee4b6b3debff57364c Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Sat, 18 Feb 2017 13:39:16 +0100 Subject: 2017-02-18 11:52:00 --- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/l-lua.lua | 95 ++++----------------- tex/context/base/mkiv/l-sandbox.lua | 36 +------- tex/context/base/mkiv/mlib-run.lua | 1 + tex/context/base/mkiv/status-files.pdf | Bin 25656 -> 25660 bytes tex/context/base/mkiv/status-lua.pdf | Bin 372480 -> 372464 bytes tex/context/base/mkiv/trac-inf.lua | 4 +- tex/context/base/mkiv/util-sbx.lua | 2 +- tex/context/interface/mkiv/i-context.pdf | Bin 804334 -> 804328 bytes tex/context/interface/mkiv/i-readme.pdf | Bin 60764 -> 60764 bytes tex/generic/context/luatex/luatex-fonts-merged.lua | 22 +++-- 14 files changed, 38 insertions(+), 130 deletions(-) (limited to 'tex') diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 360538e07..e3b49959a 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2017.02.17 13:41} +\newcontextversion{2017.02.18 11:47} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 48aec809e..c505ce092 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2017.02.17 13:41} +\edef\contextversion{2017.02.18 11:47} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index dbbb8154a..5f849dd69 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2017.02.17 13:41} +\newcontextversion{2017.02.18 11:47} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index e4bf79f0b..5bda44eea 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2017.02.17 13:41} +\edef\contextversion{2017.02.18 11:47} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/l-lua.lua b/tex/context/base/mkiv/l-lua.lua index adc2c97a8..88cde6d1e 100644 --- a/tex/context/base/mkiv/l-lua.lua +++ b/tex/context/base/mkiv/l-lua.lua @@ -201,83 +201,22 @@ end -- new -if ffi and ffi.number then - -- already loaded -else - local okay - - okay, ffi = pcall(require,"ffi") - - if not ffi then - -- an old version - elseif ffi.os == "" or ffi.arch == "" then - -- no ffi support - ffi = nil - elseif ffi.number then - -- luatex - else - -- luajittex - ffi.number = tonumber - end +FFISUPPORTED = type(ffi) == "table" and ffi.os ~= "" and ffi.arch ~= "" and ffi.load + +if not FFISUPPORTED then + + -- Maybe we should check for LUATEXENGINE but that's also a bti 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. + + local okay ; okay, ffi = pcall(require,"ffi") + + FFISUPPORTED = type(ffi) == "table" and ffi.os ~= "" and ffi.arch ~= "" and ffi.load + end --- done differently in context --- --- if ffi then --- local load = ffi.load --- local select = select --- local type = type --- local next = next --- local sort = table.sort --- local gmatch = string.gmatch --- local okay = true --- local control = { } --- function ffi.load(name,...) --- if okay == true or okay[name] then --- return load(name,...) --- else --- return nil --- end --- end --- function control.permit(...) --- if okay == true then --- okay = { } --- end --- for i=1,select("#",...) do --- local n = select(i,...) --- local t = type(n) --- if t == "table" then --- for i=1,#n do --- control.permit(n[i]) --- end --- elseif t == "string" then --- for s in gmatch(n,"[^,%s]+") do --- okay[n] = true --- end --- end --- end --- end --- function control.freeze(none) --- control.permit = function() end --- control.freeze = function() end --- if none then --- okay = { } --- end --- end --- function control.permitted(name) --- if okay == true then --- return true --- elseif type(name) == "string" then --- return okay[name] or false --- else --- -- no helpers yet --- local t = { } --- for k, v in next, okay do --- t[#t+1] = k --- end --- sort(t) --- return t --- end --- end --- ffi.control = control --- end +if not FFISUPPORTED then + ffi = nil +elseif not ffi.number then + ffi.number = tonumber +end diff --git a/tex/context/base/mkiv/l-sandbox.lua b/tex/context/base/mkiv/l-sandbox.lua index a95e70395..7a89aa8cd 100644 --- a/tex/context/base/mkiv/l-sandbox.lua +++ b/tex/context/base/mkiv/l-sandbox.lua @@ -166,7 +166,9 @@ function require(name) local n = gsub(name,"^.*[\\/]","") local n = gsub(n,"[%.].*$","") local b = blocked[n] - if b then + if b == false then + return nil -- e.g. ffi + elseif b then if trace then report("using blocked: %s",n) end @@ -183,12 +185,7 @@ function blockrequire(name,lib) if trace then report("preventing reload of: %s",name) end - blocked[name] = lib or _G[name] -end - -if TEXENGINE == "luajittex" or not ffi then - local ok - ok, ffi = pcall(require,"ffi") + blocked[name] = lib or _G[name] or false end function sandbox.enable() @@ -242,31 +239,6 @@ function sandbox.enable() report("not overloaded redefined: %s",concat(skip," | ")) end -- - -- if ffi then - -- report("disabling ffi") - -- -- for k, v in next, ffi do - -- -- if k ~= "gc" then - -- -- local t = type(v) - -- -- if t == "function" then - -- -- ffi[k] = function() report("accessing ffi.%s",k) end - -- -- elseif t == "number" then - -- -- ffi[k] = 0 - -- -- elseif t == "string" then - -- -- ffi[k] = "" - -- -- elseif t == "table" then - -- -- ffi[k] = { } - -- -- else - -- -- ffi[k] = false - -- -- end - -- -- end - -- -- end - -- for k, v in next, ffi do - -- if k ~= "gc" then - -- ffi[k] = nil - -- end - -- end - -- end - -- initializers = nil finalizers = nil originals = nil diff --git a/tex/context/base/mkiv/mlib-run.lua b/tex/context/base/mkiv/mlib-run.lua index bc8cf4dbd..93ce1fec2 100644 --- a/tex/context/base/mkiv/mlib-run.lua +++ b/tex/context/base/mkiv/mlib-run.lua @@ -240,6 +240,7 @@ function metapost.load(name,method) script_error = metapost.scripterror, make_text = metapost.maketext, extensions = 1, + -- random_seed = seed, } report_metapost("initializing number mode %a",method) local result diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index b70fcf6f0..de32cee5f 100644 Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf index c47682fe6..584d6e654 100644 Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ diff --git a/tex/context/base/mkiv/trac-inf.lua b/tex/context/base/mkiv/trac-inf.lua index 2aecb6703..f66485015 100644 --- a/tex/context/base/mkiv/trac-inf.lua +++ b/tex/context/base/mkiv/trac-inf.lua @@ -45,9 +45,7 @@ end local ticks = clock local seconds = function(n) return n or 0 end --- local okay, ffi = pcall(require,"ffi") --- --- if ffi and os.type == "windows" then +-- if FFISUPPORTED and ffi and os.type == "windows" then -- -- local okay, kernel = pcall(ffi.load,"kernel32") -- diff --git a/tex/context/base/mkiv/util-sbx.lua b/tex/context/base/mkiv/util-sbx.lua index 9cedcc1a6..48c424f00 100644 --- a/tex/context/base/mkiv/util-sbx.lua +++ b/tex/context/base/mkiv/util-sbx.lua @@ -530,7 +530,7 @@ function sandbox.disablelibraries() validlibraries = false end -if ffi then +if FFISUPPORTED and ffi then function sandbox.disablelibraries() validlibraries = false diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf index 52980cfbd..3a86b8090 100644 Binary files a/tex/context/interface/mkiv/i-context.pdf and b/tex/context/interface/mkiv/i-context.pdf differ diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf index 5c51ce0b6..374b0ec39 100644 Binary files a/tex/context/interface/mkiv/i-readme.pdf and b/tex/context/interface/mkiv/i-readme.pdf differ diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 952ed19ac..8df4c966b 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 02/17/17 13:41:40 +-- merge date : 02/18/17 11:47:12 do -- begin closure to overcome local limits and interference @@ -108,17 +108,15 @@ if flush then local spawn=os.spawn if spawn then function os.spawn (...) flush() return spawn (...) end end local popen=io.popen if popen then function io.popen (...) flush() return popen (...) end end end -if ffi and ffi.number then -else - local okay - okay,ffi=pcall(require,"ffi") - if not ffi then - elseif ffi.os=="" or ffi.arch=="" then - ffi=nil - elseif ffi.number then - else - ffi.number=tonumber - end +FFISUPPORTED=type(ffi)=="table" and ffi.os~="" and ffi.arch~="" and ffi.load +if not FFISUPPORTED then + local okay;okay,ffi=pcall(require,"ffi") + FFISUPPORTED=type(ffi)=="table" and ffi.os~="" and ffi.arch~="" and ffi.load +end +if not FFISUPPORTED then + ffi=nil +elseif not ffi.number then + ffi.number=tonumber end end -- closure -- cgit v1.2.3