diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/luat-iop.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/luat-iop.lua | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/Master/texmf-dist/tex/context/base/luat-iop.lua b/Master/texmf-dist/tex/context/base/luat-iop.lua index e5722d2bd7f..091639de231 100644 --- a/Master/texmf-dist/tex/context/base/luat-iop.lua +++ b/Master/texmf-dist/tex/context/base/luat-iop.lua @@ -13,10 +13,12 @@ if not modules then modules = { } end modules ['luat-iop'] = { local lower, find, sub = string.lower, string.find, string.sub +local allocate = utilities.storage.allocate + local ioinp = io.inp if not ioinp then ioinp = { } io.inp = ioinp end local ioout = io.out if not ioout then ioout = { } io.out = ioout end -ioinp.modes, ioout.modes = { }, { } -- functions +ioinp.modes, ioout.modes = allocate(), allocate() local inp_blocked, inp_permitted = { }, { } local out_blocked, out_permitted = { }, { } @@ -29,10 +31,10 @@ local function o_permit (name) out_permitted[#out_permitted+1] = name end ioinp.inhibit, ioinp.permit = i_inhibit, o_permit ioout.inhibit, ioout.permit = o_inhibit, o_permit -local blocked_openers = { } -- *.open(name,method) +local blockedopeners = { } -- *.open(name,method) -function io.register_opener(func) - blocked_openers[#blocked_openers+1] = func +function io.registeropener(func) + blockedopeners[#blockedopeners+1] = func end local function checked(name,blocked,permitted) @@ -50,7 +52,7 @@ local function checked(name,blocked,permitted) return true end -function io.finalize_openers(func) +function io.finalizeopeners(func) if #out_blocked > 0 or #inp_blocked > 0 then local open = func -- why not directly? return function(name,method) @@ -78,7 +80,7 @@ end --~ io.inp.inhibit('/winnt/') --~ io.inp.permit('c:/windows/wmsetup.log') ---~ io.open = io.finalize_openers(io.open) +--~ io.open = io.finalizeopeners(io.open) --~ f = io.open('.tex') print(f) --~ f = io.open('tufte.tex') print(f) @@ -87,18 +89,6 @@ end --~ f = io.open('c:/windows/crap.log') print(f) --~ f = io.open('c:/windows/wmsetup.log') print(f) -local inpout = { 'inp', 'out' } - -function io.set_opener_modes(i,o) - local first = sub(i,1,1) - for k=1,#inpout do - local iov = io[inpout[k]] - local f = iov[i] or iov[first] - if f then f() end - end - io.open = io.finalize_openers(io.open) -end - -- restricted function ioinp.modes.restricted() @@ -116,12 +106,12 @@ function ioinp.modes.paranoid() i_inhibit('%.%.') i_permit('^%./') i_permit('[^/]') - resolvers.do_with_path('TEXMF',i_permit) + resolvers.dowithpath('TEXMF',i_permit) end function ioout.modes.paranoid() o_inhibit('.*') - resolvers.do_with_path('TEXMFOUTPUT',o_permit) + resolvers.dowithpath('TEXMFOUTPUT',o_permit) end -- handy @@ -143,6 +133,16 @@ function ioout.modes.handy() o_permit('[^/]') end ---~ io.set_opener_modes('p','p') ---~ io.set_opener_modes('r','r') ---~ io.set_opener_modes('h','h') +local input_mode directives.register("system.inputmode", function(v) input_mode = v end) +local output_mode directives.register("system.outputmode", function(v) output_mode = v end) + +function io.checkopeners() + local inp = input_mode or resolvers.variable("input_mode") -- or ... will become obsolete + local out = output_mode or resolvers.variable("output_mode") -- or ... will become obsolete + inp = inp and ioinp.modes[inp] + out = out and ioinp.modes[out] + if inp then inp() end + if out then out() end +end + +--~ io.checkopeners() |