[latex3-commits] [git/LaTeX3-latex3-latex2e] earlier-expl3: Provide rollback for optional expl3 loading (92d7d48e)

PhelypeOleinik tex.phelype at gmail.com
Tue Jun 9 16:37:53 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : earlier-expl3
Link       : https://github.com/latex3/latex2e/commit/92d7d48e6261d588905f66aa74b881f0a2d8b435

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

commit 92d7d48e6261d588905f66aa74b881f0a2d8b435
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date:   Tue Jun 9 11:37:53 2020 -0300

    Provide rollback for optional expl3 loading


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

92d7d48e6261d588905f66aa74b881f0a2d8b435
 base/ltexpl.dtx                                    |  55 +++++----
 base/testfiles/tlb-early-expl3.lvt                 | 135 +++++++++++++++++++++
 base/testfiles/tlb-early-expl3.tlg                 |  33 +++++
 .../tlb-latexrelease-rollback-003-often.luatex.tlg |   2 +
 .../tlb-latexrelease-rollback-003-often.tlg        |   2 +
 .../tlb-latexrelease-rollback-003-often.xetex.tlg  |   2 +
 base/testfiles/tlb-rollback-004-often.luatex.tlg   |   3 +-
 base/testfiles/tlb-rollback-004-often.tlg          |   3 +-
 base/testfiles/tlb-rollback-004-often.xetex.tlg    |   3 +-
 9 files changed, 214 insertions(+), 24 deletions(-)

diff --git a/base/ltexpl.dtx b/base/ltexpl.dtx
index 1cfbb5c7..87c2c8da 100644
--- a/base/ltexpl.dtx
+++ b/base/ltexpl.dtx
@@ -55,23 +55,8 @@
 %
 % \changes{v0.0}{2019-10-02}{Initial version}
 %
-%    \begin{macrocode}
-%<*2ekernel>
-%    \end{macrocode}
-%
 % \subsection{Loader}
 %
-%  Check for the required primitive/engine support and the existence of
-%  a loader.
-%    \begin{macrocode}
-%</2ekernel>
-%<*2ekernel|latexrelease>
-%<latexrelease>\IncludeInRelease{2020/02/02}%
-%<latexrelease>                 {expl3}{Pre-load expl3}%
-%    \end{macrocode}
-%    If we are doing a rollback with a format containing expl3 we
-%    aren't reloading it as that creates havoc. This may need a
-%    refined version!
 % \changes{v1.0a}{2020/03/02}
 %         {Don't load expl3 if already in the format (gh/295)}
 % \changes{v1.1}{2020/03/05}
@@ -98,10 +83,6 @@
 % so we define simpler versions just to suit our needs.
 %    \begin{macrocode}
 %<*2ekernel>
-\long\def\@gobble#1{}
-\long\def\@firstofone#1{#1}
-\long\def\@firstoftwo#1#2{#1}
-\long\def\@secondoftwo#1#2{#2}
 \long\def\IfFileExists#1{%
   \openin\@inputcheck"#1" %
   \ifeof\@inputcheck
@@ -123,6 +104,14 @@
   \fi}
 %</2ekernel>
 %    \end{macrocode}
+%
+%    If we are doing a rollback with a format containing expl3 we
+%    aren't reloading it as that creates havoc. This may need a
+%    refined version!
+%    \begin{macrocode}
+%<*2ekernel|latexrelease>
+%<latexrelease>\IncludeInRelease{2020/10/01}%
+%<latexrelease>                 {expl3}{Pre-load expl3}%
 \expandafter\ifx\csname tex\string _let:D\endcsname\relax
   \expandafter\@firstofone
 \else
@@ -130,6 +119,11 @@
 %<2ekernel>  \expandafter\endinput
 %<latexrelease>  \expandafter\@gobble
 \fi
+%    \end{macrocode}
+%
+%  Check for the required primitive/engine support and the existence of
+%  a loader.
+%    \begin{macrocode}
   {%
     \IfFileExists{expl3.ltx}
       {%
@@ -185,14 +179,33 @@
          \fi
       }%
   }
-%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>
+%<latexrelease>\IncludeInRelease{2020/02/02}%
+%<latexrelease>                 {expl3}{Pre-load expl3}%
+%<latexrelease>\IfFileExists{expl3.ltx}
+%<latexrelease>  {%
+%<latexrelease>    \ifnum0%
+%<latexrelease>      \ifdefined\pdffilesize 1\fi
+%<latexrelease>      \ifdefined\filesize 1\fi
+%<latexrelease>      \ifdefined\luatexversion\ifnum\luatexversion>94 1\fi\fi
+%<latexrelease>      >0 %
+%<latexrelease>    \else
+%<latexrelease>      \message{Skipping expl3-dependent extensions}
+%<latexrelease>      \expandafter\@gobbletwo
+%<latexrelease>    \fi
+%<latexrelease>  }
+%<latexrelease>  {%
+%<latexrelease>    \message{Skipping expl3-dependent extensions}%
+%<latexrelease>    \@gobbletwo
+%<latexrelease>  }%
+%<latexrelease>\input{expl3.ltx}
 %<latexrelease>\EndIncludeInRelease
 %    \end{macrocode}
 %
 %    \subsection{Using expl3 code}
 %
 %    \begin{macrocode}
-%<*2ekernel|latexrelease>
 %<latexrelease>\IncludeInRelease{2020/10/01}%
 %<latexrelease>                 {\@expl at tl@trim at spaces@apply@@nN}
 %<latexrelease>                 {l3 macro for use in include}%
diff --git a/base/testfiles/tlb-early-expl3.lvt b/base/testfiles/tlb-early-expl3.lvt
new file mode 100644
index 00000000..63816fa8
--- /dev/null
+++ b/base/testfiles/tlb-early-expl3.lvt
@@ -0,0 +1,135 @@
+
+\input{test2e}
+\AUTHOR{Phelype Oleinik}
+\START
+
+\makeatletter
+
+\let\@filelist\@empty
+% Avoid needing an additional log file for eTeX (pdfTeX loads utf8 files):
+\expandafter\def\csname\string\UTFviii at invalid+latexrelease+IIR\endcsname{}
+% Avoid needing an additional log file for XeTeX (loads interchar stuff):
+\expandafter\def\csname\string\XeTeXintercharclasses+latexrelease+IIR\endcsname{}
+% Avoid needing an additional log file for LuaTeX (luatexversion is restored):
+\ifx\directlua\undefined
+\else \directlua{function tex.enableprimitives (...) return end}
+\fi
+
+\def\ReloadLTX{%
+\def\undef##1{%
+  \ifx\relax##1%
+  \else \let##1\relax \expandafter\undef
+  \fi}
+% Here we'll re-load LaTeX on top of LaTeX, thus some commands need
+% to be undefined beforehand.  This macro does all the necessary
+% un-definitions:
+\undef
+  \encodingdefault \rmdefault
+  \sfdefault       \ttdefault
+  \bfdefault       \mddefault
+  \itdefault       \sldefault
+  \scdefault       \updefault
+  \familydefault   \seriesdefault
+  \shapedefault    \symoperators
+  \symletters      \symsymbols
+  \symlargesymbols \mathbf
+  \mathsf          \mathit
+  \mathtt          \qbezier
+  \topfraction     \bottomfraction
+  \textfraction    \floatpagefraction
+  \dbltopfraction  \dblfloatpagefraction
+    \relax
+\expandafter\let\csname T at OT1\endcsname\relax
+\expandafter\let\csname T at OML\endcsname\relax
+\expandafter\let\csname T at OMS\endcsname\relax
+\expandafter\let\csname T at OMX\endcsname\relax
+% These can only be used in INITEX mode:
+\let\hyphenation\@gobble
+\let\patterns\@gobble
+\let\dump\@gobble
+% \tex_let:D is used as a marked that expl3 is already
+% loaded. We don't want that:
+\expandafter\let\csname tex_let:D\endcsname\UNDEFINED
+% But \cs_set_eq:NN has to work nonetheless:
+\protected\expandafter\def\csname cs_set_eq:NN\endcsname##1{\let##1= }%
+% \@iinput won't use LaTeX's machinery. Just pass it to the primitive
+% (although \@@input{#1} could be used...):
+\def\@iinput##1{\@@input"##1" }
+\catcode`\{=12 %
+\OMIT\input latex.ltx \TIMO }
+
+
+\makeatletter
+% -------------------------------------------------
+% We have expl3 preloaded, so we can first test that
+% the rollback doesn't try to load expl3 again
+% (omitting output to avoid the extensive logging of latexrelease):
+\OMIT
+\RequirePackage[2020-02-02]{latexrelease}
+\TIMO
+% In 2020-02-02 expl3.ltx is always loaded (it's reload-safe)
+\typeout{\@filelist}
+
+% latex.ltx should should be loadable (almost) without problems now:
+\ReloadLTX
+
+
+\makeatletter
+% -------------------------------------------------
+% Fake un-load latexrelease:
+\expandafter\let\csname opt at latexrelease.sty\endcsname\UNDEFINED
+\expandafter\let\csname ver at latexrelease.sty\endcsname\UNDEFINED
+\expandafter\let\csname expl3+latexrelease+IIR\endcsname\UNDEFINED
+% Now go to the past and pretend we're LaTeX 2020-02-02:
+\def\fmtversion{2020-02-02}
+% And back to the future:
+\OMIT
+\RequirePackage[2020-10-01]{latexrelease}
+\TIMO
+% In 2020-10-01 expl3-code.tex gets loaded (but its loading is
+% stopped internally so it doesn't blow up).
+\typeout{\@filelist}
+
+% This one's pointless here:
+% \ReloadLTX
+
+
+
+% Now we'll pretend an unsupported engine:
+\let\pdffilesize\UNDEFINED
+\let\filesize\UNDEFINED
+\let\luatexversion\UNDEFINED
+\let\kanjiskip\UNDEFINED
+
+% And put errors in the .tlg:
+\let\TEXERR\errmessage
+\def\errmessage#1{{\TIMO\scrollmode\TEXERR{#1}\OMIT}}
+
+\makeatletter
+% -------------------------------------------------
+% Then try to load latexrelease once more:
+\expandafter\let\csname opt at latexrelease.sty\endcsname\UNDEFINED
+\expandafter\let\csname ver at latexrelease.sty\endcsname\UNDEFINED
+\expandafter\let\csname expl3+latexrelease+IIR\endcsname\UNDEFINED
+% Now go to the past and pretend we're LaTeX 2020-02-02:
+\def\fmtversion{2020-02-02}
+% And back to the future:
+\OMIT
+\RequirePackage[2020-10-01]{latexrelease}
+\TIMO
+% latexrelease is loaded again, but nothing else:
+\typeout{\@filelist}
+
+
+
+% -------------------------------------------------
+% And now for the grand-finale:  try to build the
+% format in an unsupported engine.  The TeX run should
+% abort, and the statement after should not be reached.
+
+\ReloadLTX
+
+\scrollmode
+\ImNeverExecuted
+
+\END
diff --git a/base/testfiles/tlb-early-expl3.tlg b/base/testfiles/tlb-early-expl3.tlg
new file mode 100644
index 00000000..37d979f7
--- /dev/null
+++ b/base/testfiles/tlb-early-expl3.tlg
@@ -0,0 +1,33 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+,latexrelease.sty,expl3.ltx
+latexrelease.sty,expl3-code.tex
+! LaTeX Error: LaTeX requires the e-TeX primitives and additional
+               functionality available in the engines:
+               - pdfTeX v1.40
+               - XeTeX v0.99992
+               - LuaTeX v0.95
+               - e-(u)pTeX mid-2012
+               or later.
+See the LaTeX manual or LaTeX Companion for explanation.
+Type  H <return>  for immediate help.
+\errmessage #1->{\TIMO \scrollmode \TEXERR {#1}
+                                               \OMIT }
+l. ...  }
+You're in trouble here.  Try typing  <return>  to proceed.
+If that doesn't work, type  X <return>  to quit.
+latexrelease.sty,expl3-code.tex,latexrelease.sty
+! LaTeX Error: LaTeX requires the e-TeX primitives and additional
+               functionality available in the engines:
+               - pdfTeX v1.40
+               - XeTeX v0.99992
+               - LuaTeX v0.95
+               - e-(u)pTeX mid-2012
+               or later.
+\errmessage #1->{\TIMO \scrollmode \TEXERR {#1}
+                                               \OMIT }
+l. ...  }
+This error message was generated by an \errmessage
+command, so I can't give any explicit help.
+Pretend that you're Hercule Poirot: Examine all clues,
+and deduce the truth by order and method.
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
index b69165e6..58659d1b 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
@@ -309,6 +309,7 @@ Applying: [....-..-..] LuaTeX on input line ....
 Skipping: [....-..-..] TU in everyjob on input line ....
 Applying: [....-..-..] TU in everyjob on input line ....
 Skipping: [....-..-..] Pre-load expl3 on input line ....
+Skipping: [....-..-..] Pre-load expl3 on input line ....
 Skipping: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] l3 macro for use in include on input line ....
 Skipping: [....-..-..] Extended Allocation on input line ....
@@ -720,6 +721,7 @@ Already applied: [....-..-..] LuaTeX on input line ....
 Applying: [....-..-..] TU in everyjob on input line ....
 Already applied: [....-..-..] TU in everyjob on input line ....
 Skipping: [....-..-..] Pre-load expl3 on input line ....
+Skipping: [....-..-..] Pre-load expl3 on input line ....
 Skipping: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] Extended Allocation on input line ....
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
index 7dabe46c..a4de10c9 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
@@ -303,6 +303,7 @@ Applying: [....-..-..] Setup visible space for \verb  on input line ....
 Skipping: [....-..-..] Disable hyphenation in verb on input line ....
 Applying: [....-..-..] Disable hyphenation in verb on input line ....
 Skipping: [....-..-..] Pre-load expl3 on input line ....
+Skipping: [....-..-..] Pre-load expl3 on input line ....
 Skipping: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] l3 macro for use in include on input line ....
 Skipping: [....-..-..] Extended Allocation on input line ....
@@ -704,6 +705,7 @@ Already applied: [....-..-..] Setup visible space for \verb  on input line ....
 Applying: [....-..-..] Disable hyphenation in verb on input line ....
 Already applied: [....-..-..] Disable hyphenation in verb on input line ...
 Skipping: [....-..-..] Pre-load expl3 on input line ....
+Skipping: [....-..-..] Pre-load expl3 on input line ....
 Skipping: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] Extended Allocation on input line ....
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
index 8ab8a59a..22e15c3b 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
@@ -303,6 +303,7 @@ Applying: [....-..-..] Setup visible space for \verb  on input line ....
 Skipping: [....-..-..] Disable hyphenation in verb on input line ....
 Applying: [....-..-..] Disable hyphenation in verb on input line ....
 Skipping: [....-..-..] Pre-load expl3 on input line ....
+Skipping: [....-..-..] Pre-load expl3 on input line ....
 Skipping: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] l3 macro for use in include on input line ....
 Skipping: [....-..-..] Extended Allocation on input line ....
@@ -713,6 +714,7 @@ Already applied: [....-..-..] Setup visible space for \verb  on input line ....
 Applying: [....-..-..] Disable hyphenation in verb on input line ....
 Already applied: [....-..-..] Disable hyphenation in verb on input line ...
 Skipping: [....-..-..] Pre-load expl3 on input line ....
+Skipping: [....-..-..] Pre-load expl3 on input line ....
 Skipping: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] Extended Allocation on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.luatex.tlg b/base/testfiles/tlb-rollback-004-often.luatex.tlg
index d09fc209..4f16c82b 100644
--- a/base/testfiles/tlb-rollback-004-often.luatex.tlg
+++ b/base/testfiles/tlb-rollback-004-often.luatex.tlg
@@ -718,8 +718,9 @@ Already applied: [....-..-..] LuaTeX on input line ....
 Applying: [....-..-..] TU in everyjob on input line ....
 luaotfload | load : Luaotfload initialization requested but is already loaded, ignoring.
 Already applied: [....-..-..] TU in everyjob on input line ....
+Skipping: [....-..-..] Pre-load expl3 on input line ....
 Applying: [....-..-..] Pre-load expl3 on input line ....
-Skipping: expl3 code already part of the format on input line ....
+(../expl3.ltx)
 Skipping: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] Extended Allocation on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.tlg b/base/testfiles/tlb-rollback-004-often.tlg
index b781f064..6d2a31e5 100644
--- a/base/testfiles/tlb-rollback-004-often.tlg
+++ b/base/testfiles/tlb-rollback-004-often.tlg
@@ -706,8 +706,9 @@ Applying: [....-..-..] Setup visible space for \verb  on input line ....
 Already applied: [....-..-..] Setup visible space for \verb  on input line ....
 Applying: [....-..-..] Disable hyphenation in verb on input line ....
 Already applied: [....-..-..] Disable hyphenation in verb on input line ...
+Skipping: [....-..-..] Pre-load expl3 on input line ....
 Applying: [....-..-..] Pre-load expl3 on input line ....
-Skipping: expl3 code already part of the format on input line ....
+(../expl3.ltx)
 Skipping: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] Extended Allocation on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.xetex.tlg b/base/testfiles/tlb-rollback-004-often.xetex.tlg
index d14fcb1c..3c69ad2b 100644
--- a/base/testfiles/tlb-rollback-004-often.xetex.tlg
+++ b/base/testfiles/tlb-rollback-004-often.xetex.tlg
@@ -707,8 +707,9 @@ Applying: [....-..-..] Setup visible space for \verb  on input line ....
 Already applied: [....-..-..] Setup visible space for \verb  on input line ....
 Applying: [....-..-..] Disable hyphenation in verb on input line ....
 Already applied: [....-..-..] Disable hyphenation in verb on input line ...
+Skipping: [....-..-..] Pre-load expl3 on input line ....
 Applying: [....-..-..] Pre-load expl3 on input line ....
-Skipping: expl3 code already part of the format on input line ....
+(../expl3.ltx)
 Skipping: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] l3 macro for use in include on input line ....
 Applying: [....-..-..] Extended Allocation on input line ....





More information about the latex3-commits mailing list.