summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2010-03-28 00:45:01 +0100
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2010-03-28 00:45:01 +0100
commit7578e441dd20847113adcb9aa5ff29477278f8a4 (patch)
tree941a67611c1c4603b8f08e354b2f5e7aea649d7b
parentad8bcc3e4491d51e5ac37bf6ed7c7337a33c1fc3 (diff)
downloadluatexbase-7578e441dd20847113adcb9aa5ff29477278f8a4.tar.gz
Use loader in modutils.
-rw-r--r--Makefile2
-rw-r--r--luatexbase-modutils.dtx54
2 files changed, 18 insertions, 38 deletions
diff --git a/Makefile b/Makefile
index 9baf7fb..b5c1e4d 100644
--- a/Makefile
+++ b/Makefile
@@ -98,7 +98,7 @@ check-loader: $(UNPACKED_LOADER)
luatex --interaction=batchmode test-loader-plain.tex >/dev/null
lualatex --interaction=batchmode test-loader-latex.tex >/dev/null
-check-modutils: $(UNPACKED_MODUTILS)
+check-modutils: $(UNPACKED_MODUTILS) $(LOADER_RUN)
luatex --interaction=batchmode test-modutils-plain.tex >/dev/null
lualatex --interaction=batchmode test-modutils-latex.tex >/dev/null
diff --git a/luatexbase-modutils.dtx b/luatexbase-modutils.dtx
index 5dcb8dc..4a1580b 100644
--- a/luatexbase-modutils.dtx
+++ b/luatexbase-modutils.dtx
@@ -206,6 +206,17 @@ and the derived files
\catcode64 11
% \end{macrocode}
%
+% Load the package loader.
+%
+% \begin{macrocode}
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname RequirePackage\endcsname\relax
+ \input luatexbase-loader.sty
+\else
+ \RequirePackage{luatexbase-loader}
+\fi
+% \end{macrocode}
+%
% \subsubsection{Main code}
%
% The \texttt{\string\luatexModuleError} macro is called by the lua function
@@ -346,24 +357,6 @@ end
%
% \subsubsection{module loading and providing functions}
%
-% A small function to find a lua module file according to its name, with or
-% without the \texttt{.lua} at the end of the filename.
-%
-% \begin{macrocode}
-
-function luatextra.find_module_file(name)
- if string.sub(name, -4) ~= '.lua' then
- name = name..'.lua'
- end
- path = kpse.find_file(name, 'tex')
- if not path then
- path = kpse.find_file(name, 'texmfscripts')
- end
- return path, name
-end
-
-% \end{macrocode}
-%
% A small patch, for the \texttt{module} function to work in this file. I
% can't understand why it doens't otherwise.
%
@@ -381,31 +374,18 @@ luatextra.module = module
% \texttt{luatextra.provides\_module}.
%
% \begin{macrocode}
-
-
function luatextra.use_module(name)
if not name or luatextra.modules[name] then
return
end
- local path, filename = luatextra.find_module_file(name)
- if not path then
- luatextra.internal_error(format("unable to find lua module %s", name))
- else
- if path:sub(1,2) == "./" then
- path = path:sub(3)
- end
- texio.write_nl('('..path)
- dofile(path)
- if not luatextra.modules[name] then
- luatextra.internal_warning(format("You have requested module `%s',\n%s but the file %s does not provide it.", name, luatextra.internal_warning_spaces, filename))
- end
- if not package.loaded[name] then
- luatextra.module(name, package.seeall)
- end
- texio.write(')')
+ require(name)
+ if not luatextra.modules[name] then
+ luatextra.internal_warning(format("You have requested module `%s',\n%s but the file %s does not provide it.", name, luatextra.internal_warning_spaces, filename))
+ end
+ if not package.loaded[name] then
+ luatextra.module(name, package.seeall)
end
end
-
% \end{macrocode}
%
% \end{macro}