summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/data-lua.lua
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2009-08-23 11:11:32 +0000
committerTaco Hoekwater <taco@elvenkind.com>2009-08-23 11:11:32 +0000
commit8fc3039c82d48605b5ca8b2eda3f4fdd755681e1 (patch)
tree3cd9bbdd599bc4d1ac0409e167fee2136e4c0ec9 /Master/texmf-dist/tex/context/base/data-lua.lua
parent850fc99b7cd3ae7a20065531fe866ff7bae642ec (diff)
this is context 2009.08.19 17:10
git-svn-id: svn://tug.org/texlive/trunk@14827 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/data-lua.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/data-lua.lua55
1 files changed, 55 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/data-lua.lua b/Master/texmf-dist/tex/context/base/data-lua.lua
new file mode 100644
index 00000000000..86231b3a3a9
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/data-lua.lua
@@ -0,0 +1,55 @@
+if not modules then modules = { } end modules ['data-lua'] = {
+ version = 1.001,
+ comment = "companion to luat-lib.tex",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- some loading stuff ... we might move this one to slot 1 depending
+-- on the developments (the loaders must not trigger kpse); we could
+-- of course use a more extensive lib path spec
+
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
+
+local gsub = string.gsub
+
+local libformats = { 'luatexlibs', 'tex', 'texmfscripts', 'othertextfiles' }
+local libpaths = file.split_path(package.path)
+
+package.loaders[#package.loaders+1] = function(name)
+ for i=1,#libformats do
+ local format = libformats[i]
+ local resolved = resolvers.find_file(name,format) or ""
+ if resolved ~= "" then
+ if trace_locating then
+ logs.report("fileio","! lib '%s' located via environment: '%s'",name,resolved)
+ end
+ return function() return dofile(resolved) end
+ end
+ end
+ local simple = file.removesuffix(name)
+ for i=1,#libpaths do
+ local resolved = gsub(libpaths[i],"?",simple)
+ if resolvers.isreadable.file(resolved) then
+ if trace_locating then
+ logs.report("fileio","! lib '%s' located via 'package.path': '%s'",name,resolved)
+ end
+ return function() return dofile(resolved) end
+ end
+ end
+ -- just in case the distribution is messed up
+ local resolved = resolvers.find_file(file.basename(name),'luatexlibs') or ""
+ if resolved ~= "" then
+ if trace_locating then
+ logs.report("fileio","! lib '%s' located by basename via environment: '%s'",name,resolved)
+ end
+ return function() return dofile(resolved) end
+ end
+ if trace_locating then
+ logs.report("fileio",'? unable to locate lib: %s',name)
+ end
+ return "unable to locate " .. name
+end
+
+resolvers.loadlualib = require