summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/texdoc/texdoclib.tlu
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/scripts/texdoc/texdoclib.tlu')
-rw-r--r--Master/texmf-dist/scripts/texdoc/texdoclib.tlu23
1 files changed, 18 insertions, 5 deletions
diff --git a/Master/texmf-dist/scripts/texdoc/texdoclib.tlu b/Master/texmf-dist/scripts/texdoc/texdoclib.tlu
index ccaad778d93..c92ef185b17 100644
--- a/Master/texmf-dist/scripts/texdoc/texdoclib.tlu
+++ b/Master/texmf-dist/scripts/texdoc/texdoclib.tlu
@@ -38,15 +38,19 @@ end
-- initialise the shared environment with a copy of the global environment
local prv_env = simple_copy(_G)
-setfenv(1, prv_env)
+if setfenv then
+ setfenv(1, prv_env)
+else
+ _ENV = prv_env
+end
-- import symbols from a table to the share environment
local function import_symbols(symbols, name)
for sym, val in pairs(symbols) do
assert(val ~= nil,
- 'Internal error: '..name..'exporting undefined symbol '..sym..'.')
+ 'Internal error: '..name..' exporting undefined symbol '..sym..'.')
assert(prv_env[sym] == nil,
- 'Internal error: '..name..'exporting existing symbol '..sym..'.')
+ 'Internal error: '..name..' exporting existing symbol '..sym..'.')
prv_env[sym] = val
end
end
@@ -55,8 +59,17 @@ end
local function texdoc_do(name)
local pathname = kpse.find_file('texdoc/'..name, 'lua')
assert(pathname, 'Internal error: missing submodule: '..name)
- local submod = assert(loadfile (pathname))
- setfenv(submod, simple_copy(prv_env))
+ local submod
+ if setfenv then
+ submod = assert(loadfile (pathname))
+ setfenv(submod, simple_copy(prv_env))
+ else
+ local f = assert(io.open(pathname))
+ local s = f:read('*a')
+ f:close()
+ submod = assert(load(s, pathname, 'bt', simple_copy(prv_env)))
+ -- submod = assert(loadfile(pathname, 'bt', simple_copy(prv_env)))
+ end
local symbols = submod()
if symbols then import_symbols(symbols, name) end
end