[latex3-commits] [latex3/latex3] main: Restore code needed if expl3 is not pre-loaded (a66e0f7b3)

github at latex-project.org github at latex-project.org
Thu May 11 23:18:43 CEST 2023


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/a66e0f7b34a9356bbc9ce8d129cb9072942e5b5c

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

commit a66e0f7b34a9356bbc9ce8d129cb9072942e5b5c
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu May 11 22:18:43 2023 +0100

    Restore code needed if expl3 is not pre-loaded
    
    Looking back, the ISO version of TL'19 didn't have pre-loading:
    it was in the Spring 2020 LaTeX release.


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

a66e0f7b34a9356bbc9ce8d129cb9072942e5b5c
 l3kernel/l3names.dtx | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 123 insertions(+)

diff --git a/l3kernel/l3names.dtx b/l3kernel/l3names.dtx
index d2ee4e1ee..a9962361a 100644
--- a/l3kernel/l3names.dtx
+++ b/l3kernel/l3names.dtx
@@ -1249,6 +1249,90 @@
 \tex_endgroup:D
 %    \end{macrocode}
 %
+% \LaTeXe{} moves a few primitives, so these are sorted out.
+% In newer versions of \LaTeXe{}, \pkg{expl3} is loaded rather early, so
+% only some primitives are already renamed, so we need two tests here.
+% At the beginning of the \LaTeXe{} format, the primitives \tn{end} and
+% \tn{input} are renamed, and only later on the other ones.
+%    \begin{macrocode}
+\tex_ifdefined:D \@@@@end
+  \tex_let:D \tex_end:D                  \@@@@end
+  \tex_let:D \tex_input:D                \@@@@input
+\tex_fi:D
+%    \end{macrocode}
+%
+% If \tn{@@@@hyph} is defined, we are loading \pkg{expl3} in a
+% pre-2020/10/01 release of \LaTeXe{}, so a few other primitives have to
+% be tested as well.
+%    \begin{macrocode}
+\tex_ifdefined:D \@@@@hyph
+  \tex_let:D \tex_everydisplay:D         \frozen at everydisplay
+  \tex_let:D \tex_everymath:D            \frozen at everymath
+  \tex_let:D \tex_hyphen:D               \@@@@hyph
+  \tex_let:D \tex_italiccorrection:D     \@@@@italiccorr
+  \tex_let:D \tex_underline:D            \@@@@underline
+%    \end{macrocode}
+% The \tn{shipout} primitive is particularly tricky as a number of packages
+% want to hook in here. First, we see if a sufficiently-new kernel has saved
+% a copy: if it has, just use that. Otherwise, we need to check each of the
+% possible packages/classes that might move it: here, we are looking for those
+% which do \emph{not} delay action to the \tn{AtBeginDocument} hook. (We
+% cannot use \tn{primitive} as that doesn't
+% allow us to make a direct copy of the primitive \emph{itself}.) As we know
+% that \LaTeXe{} is in use, we use it's \tn{@tfor} loop here.
+%    \begin{macrocode}
+  \tex_ifdefined:D \@@@@shipout
+    \tex_let:D \tex_shipout:D \@@@@shipout
+  \tex_fi:D
+  \tex_begingroup:D
+    \tex_edef:D \l_tmpa_tl { \tex_string:D \shipout }
+    \tex_edef:D \l_tmpb_tl { \tex_meaning:D \shipout }
+    \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
+    \tex_else:D
+      \tex_expandafter:D \@tfor \tex_expandafter:D \@tempa \tex_string:D :=
+        \CROP at shipout
+        \dup at shipout
+        \GPTorg at shipout
+        \LL at shipout
+        \mem at oldshipout
+        \opem at shipout
+        \pgfpages at originalshipout
+        \pr at shipout
+        \Shipout
+        \verso at orig@shipout
+        \do
+          {
+            \tex_edef:D \l_tmpb_tl
+              { \tex_expandafter:D \tex_meaning:D \@tempa }
+            \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
+              \tex_global:D \tex_expandafter:D \tex_let:D
+                \tex_expandafter:D \tex_shipout:D \@tempa
+            \tex_fi:D
+          }
+    \tex_fi:D
+  \tex_endgroup:D
+%    \end{macrocode}
+% Some tidying up is needed for \tn[index=tracingfonts]{(pdf)tracingfonts}.
+% Newer \LuaTeX{} has
+% this simply as \tn{tracingfonts}, but that is overwritten by
+% the \LaTeXe{} kernel. So any spurious definition has to be removed, then
+% the real version saved either from the \pdfTeX{} name or from \LuaTeX{}.
+% In the latter case, we leave \tn{@@tracingfonts} available: this might
+% be useful and almost all \LaTeXe{} users will have \pkg{expl3} loaded by
+% \pkg{fontspec}. (We follow the usual kernel convention that |@@| is used
+% for saved primitives.)
+%   \begin{macrocode}
+  \tex_let:D \tex_tracingfonts:D \tex_undefined:D
+  \tex_ifdefined:D \pdftracingfonts
+    \tex_let:D \tex_tracingfonts:D \pdftracingfonts
+  \tex_else:D
+    \tex_ifdefined:D \tex_directlua:D
+      \tex_directlua:D { tex.enableprimitives("@@@@", {"tracingfonts"}) }
+      \tex_let:D \tex_tracingfonts:D \@@@@tracingfonts
+    \tex_fi:D
+  \tex_fi:D
+\tex_fi:D
+%    \end{macrocode}
 % Only \pdfTeX{} and \LuaTeX{} define \tn{pdfmapfile} and \tn{pdfmapline}:
 % Tidy up the fact that some format-building processes leave
 % a couple of questionable decisions about that!
@@ -1261,6 +1345,45 @@
   \tex_let:D \tex_pdfmapline:D \tex_undefined:D
 \tex_fi:D
 %    \end{macrocode}
+% A few packages do unfortunate things to date-related primitives.
+%    \begin{macrocode}
+\tex_begingroup:D
+  \tex_edef:D \l_tmpa_tl { \tex_meaning:D \tex_time:D }
+  \tex_edef:D \l_tmpb_tl { \tex_string:D \time }
+  \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
+  \tex_else:D
+    \tex_global:D \tex_let:D \tex_time:D \tex_undefined:D
+  \tex_fi:D
+  \tex_edef:D \l_tmpa_tl { \tex_meaning:D \tex_day:D }
+  \tex_edef:D \l_tmpb_tl { \tex_string:D \day }
+  \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
+  \tex_else:D
+    \tex_global:D \tex_let:D \tex_day:D \tex_undefined:D
+  \tex_fi:D
+  \tex_edef:D \l_tmpa_tl { \tex_meaning:D \tex_month:D }
+  \tex_edef:D \l_tmpb_tl { \tex_string:D \month }
+  \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
+  \tex_else:D
+    \tex_global:D \tex_let:D \tex_month:D \tex_undefined:D
+  \tex_fi:D
+  \tex_edef:D \l_tmpa_tl { \tex_meaning:D \tex_year:D }
+  \tex_edef:D \l_tmpb_tl { \tex_string:D \year }
+  \tex_ifx:D \l_tmpa_tl \l_tmpb_tl
+  \tex_else:D
+    \tex_global:D \tex_let:D \tex_year:D \tex_undefined:D
+  \tex_fi:D
+\tex_endgroup:D
+%    \end{macrocode}
+% \pkg{cslatex} moves a couple of primitives which we recover here; as there
+% is no other marker, we can only work by looking for the names.
+%    \begin{macrocode}
+\tex_ifdefined:D \orieveryjob
+  \tex_let:D \tex_everyjob:D \orieveryjob
+\tex_fi:D
+\tex_ifdefined:D \oripdfoutput
+  \tex_let:D \tex_pdfoutput:D \oripdfoutput
+\tex_fi:D
+%    \end{macrocode}
 %
 % For \ConTeXt{}, two tests are needed. Both Mark~II and Mark~IV move several
 % primitives: these are all covered by the first test, again using \cs{end}





More information about the latex3-commits mailing list.