[latex3-commits] [git/LaTeX3-latex3-latex3] LaTeX2020: DocStrip out an expl3 pre-loader (39c3d5a45)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Oct 2 18:20:20 CEST 2019


Repository : https://github.com/latex3/latex3
On branch  : LaTeX2020
Link       : https://github.com/latex3/latex3/commit/39c3d5a45b5ac5d204d9a3bc04530cfaaf8e3e4a

>---------------------------------------------------------------

commit 39c3d5a45b5ac5d204d9a3bc04530cfaaf8e3e4a
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Oct 2 17:20:20 2019 +0100

    DocStrip out an expl3 pre-loader


>---------------------------------------------------------------

39c3d5a45b5ac5d204d9a3bc04530cfaaf8e3e4a
 l3kernel/expl3.dtx | 65 +++++++++++++++++++++++++++++++++++++++++++++++-------
 l3kernel/l3.ins    |  1 +
 2 files changed, 58 insertions(+), 8 deletions(-)

diff --git a/l3kernel/expl3.dtx b/l3kernel/expl3.dtx
index 5b865b481..877ac1815 100644
--- a/l3kernel/expl3.dtx
+++ b/l3kernel/expl3.dtx
@@ -1156,19 +1156,31 @@
 %</!loader>
 %    \end{macrocode}
 %
-% \subsection{\LaTeXe{} loader}
+% \subsection{\LaTeXe{} loaders}
+%
+% Loading with \LaTeXe{} may be as part of the format (pre-loading)
+% or as a package. We have to allow for both possible paths, and of
+% course the package being loaded on to of the pre-load. That means
+% the the code here must be safe against re-loading.
 %
 %    \begin{macrocode}
-%<*package&loader>
+%<*package&loader|2ekernel>
 %    \end{macrocode}
 %
-% Identify the package.
+% Identify the package or add to the format message.
 %    \begin{macrocode}
+%<*2ekernel>
+\everyjob\expandafter{\the\everyjob
+  ^^J\ExplFileDate\space L3 programming layer
+}
+%</2ekernel>
+%<*!2ekernel>
 \ProvidesPackage{expl3}
   [%
     \ExplFileDate\space
     L3 programming layer (loader)
   ]%
+%</!2ekernel>
 %    \end{macrocode}
 %
 % \begin{macro}{\ProvidesExplPackage, \ProvidesExplClass, \ProvidesExplFile}
@@ -1194,8 +1206,16 @@
 % \end{macro}
 %
 %  Load the business end: this leaves \cs{expl3} syntax on.
+%  The test ensures we only load once without needing to know if
+%  there was a preloading step.
 %    \begin{macrocode}
-\input{expl3-code.tex}%
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname tex\string _let:D\endcsname\relax
+  \expandafter\@firstofone
+\else
+  \expandafter\@gobble
+\fi
+  {\input{expl3-code.tex}}%
 %    \end{macrocode}
 %
 % A check that the bootstrap code did not abort loading: if it did,
@@ -1212,9 +1232,10 @@
 %    \end{macrocode}
 %
 % \begin{variable}{\c_@@_def_ext_tl}
-%   Needed by \LaTeXe{}.
+%   Needed by \LaTeXe{}, and avoiding a re-load issue.
 %    \begin{macrocode}
-\tl_const:Nn \c_@@_def_ext_tl { def }
+\cs_if_exist:NF \c_@@_def_ext_tl
+  { \tl_const:Nn \c_@@_def_ext_tl { def } }
 %    \end{macrocode}
 % \end{variable}
 %
@@ -1222,7 +1243,7 @@
 %   For \LaTeXe{}, option loading uses the built-in functionality: as this
 %   may be a reload we have to force the issue.
 %    \begin{macrocode}
-\cs_new_protected:Npn \__kernel_sys_configuration_load:n #1
+\cs_gset_protected:Npn \__kernel_sys_configuration_load:n #1
   {
     \group_begin:
     \cs_set_protected:Npn \ProvidesExplFile
@@ -1244,10 +1265,12 @@
 %
 % \begin{variable}{\l_@@_options_clist}
 %    \begin{macrocode}
+%<*!2ekernel>
 \clist_new:N \l_@@_options_clist
 \DeclareOption*
   { \clist_put_right:NV \l_@@_options_clist \CurrentOption }
 \ProcessOptions \relax
+%</!2ekernel>
 %    \end{macrocode}
 % \end{variable}
 %
@@ -1279,10 +1302,29 @@
   }
 %    \end{macrocode}
 %
+%  A backend has to be in place by the start of the document.
 %    \begin{macrocode}
+%<*2ekernel>
+\AtBeginDocument
+  {
+    \str_if_exist:NF \c_sys_backend_str
+      { \sys_load_backend:n { } }
+  }
+%</2ekernel>
+%<*!2ekernel>
 \keys_set:nV { sys } \l_@@_options_clist
 \str_if_exist:NF \c_sys_backend_str
   { \sys_load_backend:n { } }
+%</!2ekernel>
+%    \end{macrocode}
+%
+% A test for pre-loading: does \tn{@pushfilenameaux} already exist.
+% The alrady-loaded mechanism will handle everything now.
+%    \begin{macrocode}
+%<*package>
+\cs_if_exist:NT \@pushfilenameaux
+  { \endinput }
+%</package>
 %    \end{macrocode}
 %
 % \begin{macro}{\@pushfilename, \@popfilename}
@@ -1351,8 +1393,15 @@
 %    \end{macrocode}
 % \end{variable}
 %
+% For pre-loading, we have to manually disable the syntax.
+%    \begin{macrocode}
+%<*2ekernel>
+\ExplSyntaxOff
+%</2ekernel>
+%    \end{macrocode}
+%
 %    \begin{macrocode}
-%</package&loader>
+%</package&loader|2ekernel>
 %    \end{macrocode}
 %
 % \subsection{Generic loader}
diff --git a/l3kernel/l3.ins b/l3kernel/l3.ins
index 343d8d7f1..d9c7f2e6c 100644
--- a/l3kernel/l3.ins
+++ b/l3kernel/l3.ins
@@ -111,6 +111,7 @@ and all files in that bundle must be distributed together.
   }
 
 \generate{\file{expl3.sty}        {\from{expl3.dtx}       {package,loader}}}
+\generate{\file{expl3.ltx}        {\from{expl3.dtx}       {2ekernel,loader}}}
 \generate{\file{expl3-generic.tex}{\from{expl3.dtx}       {generic,loader}}}
 
 \generate{\file{l3doc.cls}        {\from{l3doc.dtx}       {class}}}





More information about the latex3-commits mailing list