summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--luatexbase-loader.dtx58
2 files changed, 50 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index c9d9c62..8194e77 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,8 @@ UNPACKED_ATTR = luatexbase-attr.sty attr.lua \
UNPACKED_CCTB = luatexbase-cctb.sty cctb.lua \
test-cctb-plain.tex test-cctb-latex.tex
UNPACKED_LOADER = $(LOADER_RUN) \
- test-loader-plain.tex test-loader-latex.tex
+ test-loader-plain.tex test-loader-latex.tex \
+ test-loader.lua test-loader.sub.lua
UNPACKED_MODUTILS = $(MOD_RUN) test-modutils.lua \
test-modutils-plain.tex test-modutils-latex.tex
UNPACKED_COMPAT = $(COMPAT_RUN) \
diff --git a/luatexbase-loader.dtx b/luatexbase-loader.dtx
index 73dcc72..6d72a36 100644
--- a/luatexbase-loader.dtx
+++ b/luatexbase-loader.dtx
@@ -67,6 +67,9 @@ See source file '\inFileName' for details.
\generate{%
\usedir{tex/luatex/luatexbase}%
\file{luatexbase.loader.lua}{\from{luatexbase-loader.dtx}{luamodule}}%
+ \usedir{doc/luatex/luatexbase}%
+ \file{test-loader.lua}{\from{luatexbase-loader.dtx}{testdummy}}%
+ \file{test-loader.sub.lua}{\from{luatexbase-loader.dtx}{testdummy}}%
}
\obeyspaces
@@ -280,12 +283,40 @@ See source file '\inFileName' for details.
module('luatexbase', package.seeall)
% \end{macrocode}
%
-% Find the full path corresponding to a mudole name.
+% Emulate (approximatively) kpse's lua format search.
+%
+% \begin{macrocode}
+local lua_suffixes = {
+ "",
+ ".luc", ".luctex", ".texluc",
+ ".lua", ".luatex", ".texlua",
+}
+local function find_file_lua(name)
+ for _, suf in ipairs(lua_suffixes) do
+ local name = name..suf
+ local f = kpse.find_file(name, 'texmfscripts')
+ or kpse.find_file(name, 'tex')
+ if f then return f end
+ end
+end
+% \end{macrocode}
+%
+% Don't use the emulated version if kpse lua format works.
+%
+% \begin{macrocode}
+if pcall('kpse.find_file', 'dummy', 'lua') then
+ find_file_lua = function(name)
+ return kpse.find_file(name, 'lua')
+ end
+end
+% \end{macrocode}
+%
+% Find the full path corresponding to a module name.
%
% \begin{macrocode}
local function find_module_file(mod)
- return kpse.find_file(mod:gsub('%.', '/'), 'lua')
- or kpse.find_file(mod, 'lua')
+ return find_file_lua(mod:gsub('%.', '/'), 'lua')
+ or find_file_lua(mod, 'lua')
end
% \end{macrocode}
%
@@ -305,23 +336,30 @@ end
% \end{macrocode}
%
% \begin{macrocode}
-table.insert(package.loaders, load_module)
+table.insert(package.loaders, 2, load_module)
%</luamodule>
% \end{macrocode}
%
% \section{Test files}
%
-% We just check that the package loads properly, under both LaTeX and Plain
-% TeX. Anyway, the test files of other modules using this one already are a
-% test\dots
+% A dummy lua file for tests.
%
% \begin{macrocode}
-%<testplain>\input luatexbase-loader.sty
-%<testlatex>\RequirePackage{luatexbase-loader}
-%<*testplain,testlatex>
+%<*testdummy>
+return true
+%</testdummy>
% \end{macrocode}
%
+% Check that the package loads properly, under both LaTeX and Plain TeX,
+% and load a dummy module in the current diretory.
+%
% \begin{macrocode}
+%<testplain>\input luatexbase-loader.sty
+%<testlatex>\RequirePackage{luatexbase-loader}
+%<*testplain,testlatex>
+\catcode64 11
+\luatexbase@directlua{require "test-loader"}
+\luatexbase@directlua{require "test-loader.sub"}
%</testplain,testlatex>
%<testplain>\bye
%<testlatex>\stop